clang  6.0.0svn
SPIR.h
Go to the documentation of this file.
1 //===--- SPIR.h - Declare SPIR target feature support -----------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares SPIR TargetInfo objects.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_SPIR_H
15 #define LLVM_CLANG_LIB_BASIC_TARGETS_SPIR_H
16 
17 #include "clang/Basic/TargetInfo.h"
19 #include "llvm/ADT/Triple.h"
20 #include "llvm/Support/Compiler.h"
21 
22 namespace clang {
23 namespace targets {
24 
25 static const unsigned SPIRAddrSpaceMap[] = {
26  0, // Default
27  1, // opencl_global
28  3, // opencl_local
29  2, // opencl_constant
30  0, // opencl_private
31  4, // opencl_generic
32  0, // cuda_device
33  0, // cuda_constant
34  0 // cuda_shared
35 };
36 
37 class LLVM_LIBRARY_VISIBILITY SPIRTargetInfo : public TargetInfo {
38 public:
39  SPIRTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
40  : TargetInfo(Triple) {
41  assert(getTriple().getOS() == llvm::Triple::UnknownOS &&
42  "SPIR target must use unknown OS");
43  assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
44  "SPIR target must use unknown environment type");
45  TLSSupported = false;
46  VLASupported = false;
47  LongWidth = LongAlign = 64;
48  AddrSpaceMap = &SPIRAddrSpaceMap;
49  UseAddrSpaceMapMangling = true;
50  // Define available target features
51  // These must be defined in sorted order!
52  NoAsmVariants = true;
53  }
54 
55  void getTargetDefines(const LangOptions &Opts,
56  MacroBuilder &Builder) const override;
57 
58  bool hasFeature(StringRef Feature) const override {
59  return Feature == "spir";
60  }
61 
62  ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; }
63 
64  const char *getClobbers() const override { return ""; }
65 
66  ArrayRef<const char *> getGCCRegNames() const override { return None; }
67 
68  bool validateAsmConstraint(const char *&Name,
69  TargetInfo::ConstraintInfo &info) const override {
70  return true;
71  }
72 
74  return None;
75  }
76 
79  }
80 
82  return (CC == CC_SpirFunction || CC == CC_OpenCLKernel) ? CCCR_OK
83  : CCCR_Warning;
84  }
85 
87  return CC_SpirFunction;
88  }
89 
90  void setSupportedOpenCLOpts() override {
91  // Assume all OpenCL extensions and optional core features are supported
92  // for SPIR since it is a generic target.
93  getSupportedOpenCLOpts().supportAll();
94  }
95 };
96 class LLVM_LIBRARY_VISIBILITY SPIR32TargetInfo : public SPIRTargetInfo {
97 public:
98  SPIR32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
99  : SPIRTargetInfo(Triple, Opts) {
100  PointerWidth = PointerAlign = 32;
101  SizeType = TargetInfo::UnsignedInt;
102  PtrDiffType = IntPtrType = TargetInfo::SignedInt;
103  resetDataLayout("e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
104  "v96:128-v192:256-v256:256-v512:512-v1024:1024");
105  }
106 
107  void getTargetDefines(const LangOptions &Opts,
108  MacroBuilder &Builder) const override;
109 };
110 
111 class LLVM_LIBRARY_VISIBILITY SPIR64TargetInfo : public SPIRTargetInfo {
112 public:
113  SPIR64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
114  : SPIRTargetInfo(Triple, Opts) {
115  PointerWidth = PointerAlign = 64;
116  SizeType = TargetInfo::UnsignedLong;
117  PtrDiffType = IntPtrType = TargetInfo::SignedLong;
118  resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-"
119  "v96:128-v192:256-v256:256-v512:512-v1024:1024");
120  }
121 
122  void getTargetDefines(const LangOptions &Opts,
123  MacroBuilder &Builder) const override;
124 };
125 } // namespace targets
126 } // namespace clang
127 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_SPIR_H
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
Definition: SPIR.h:81
SPIR32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: SPIR.h:98
Options for controlling the target.
Definition: TargetOptions.h:26
ArrayRef< Builtin::Info > getTargetBuiltins() const override
Return information about target-specific builtins for the current primary target, and info about whic...
Definition: SPIR.h:62
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:48
SPIRTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
Definition: SPIR.h:39
ArrayRef< const char * > getGCCRegNames() const override
Definition: SPIR.h:66
typedef void* __builtin_va_list;
Definition: TargetInfo.h:157
Exposes information about the current target.
Definition: TargetInfo.h:54
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:233
void setSupportedOpenCLOpts() override
Set supported OpenCL extensions and optional core features.
Definition: SPIR.h:90
Defines the clang::TargetOptions class.
static const unsigned SPIRAddrSpaceMap[]
Definition: SPIR.h:25
Dataflow Directional Tag Classes.
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
Definition: SPIR.h:77
SPIR64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: SPIR.h:113
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Definition: TargetInfo.h:152
CallingConv getDefaultCallingConv(CallingConvMethodType MT) const override
Gets the default calling convention for the given target and declaration context. ...
Definition: SPIR.h:86
bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &info) const override
Definition: SPIR.h:68
ArrayRef< TargetInfo::GCCRegAlias > getGCCRegAliases() const override
Definition: SPIR.h:73
Defines the clang::TargetInfo interface.
bool hasFeature(StringRef Feature) const override
Determine whether the given target has the given feature.
Definition: SPIR.h:58
const char * getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
Definition: SPIR.h:64