clang 8.0.0

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"
18 #include "clang/Basic/TargetOptions.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 HasLegalHalfType = true;
51 HasFloat16 = true;
52 // Define available target features
53 // These must be defined in sorted order!
54 NoAsmVariants = true;
55 }
56
57 void getTargetDefines(const LangOptions &Opts,
58 MacroBuilder &Builder) const override;
59
60 bool hasFeature(StringRef Feature) const override {
61 return Feature == "spir";
62 }
63
64 // SPIR supports the half type and the only llvm intrinsic allowed in SPIR is
65 // memcpy as per section 3 of the SPIR spec.
66 bool useFP16ConversionIntrinsics() const override { return false; }
67
68 ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; }
69
70 const char *getClobbers() const override { return ""; }
71
72 ArrayRef<const char *> getGCCRegNames() const override { return None; }
73
74 bool validateAsmConstraint(const char *&Name,
75 TargetInfo::ConstraintInfo &info) const override {
76 return true;
77 }
78
79 ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
80 return None;
81 }
82
83 BuiltinVaListKind getBuiltinVaListKind() const override {
84 return TargetInfo::VoidPtrBuiltinVaList;
85 }
86
87 CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
88 return (CC == CC_SpirFunction || CC == CC_OpenCLKernel) ? CCCR_OK
89 : CCCR_Warning;
90 }
91
92 CallingConv getDefaultCallingConv(CallingConvMethodType MT) const override {
93 return CC_SpirFunction;
94 }
95
96 void setSupportedOpenCLOpts() override {
97 // Assume all OpenCL extensions and optional core features are supported
98 // for SPIR since it is a generic target.
99 getSupportedOpenCLOpts().supportAll();
100 }
101 };
102 class LLVM_LIBRARY_VISIBILITY SPIR32TargetInfo : public SPIRTargetInfo {
103 public:
104 SPIR32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
105 : SPIRTargetInfo(Triple, Opts) {
106 PointerWidth = PointerAlign = 32;
107 SizeType = TargetInfo::UnsignedInt;
108 PtrDiffType = IntPtrType = TargetInfo::SignedInt;
109 resetDataLayout("e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
110 "v96:128-v192:256-v256:256-v512:512-v1024:1024");
111 }
112
113 void getTargetDefines(const LangOptions &Opts,
114 MacroBuilder &Builder) const override;
115 };
116
117 class LLVM_LIBRARY_VISIBILITY SPIR64TargetInfo : public SPIRTargetInfo {
118 public:
119 SPIR64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
120 : SPIRTargetInfo(Triple, Opts) {
121 PointerWidth = PointerAlign = 64;
122 SizeType = TargetInfo::UnsignedLong;
123 PtrDiffType = IntPtrType = TargetInfo::SignedLong;
124 resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-"
125 "v96:128-v192:256-v256:256-v512:512-v1024:1024");
126 }
127
128 void getTargetDefines(const LangOptions &Opts,
129 MacroBuilder &Builder) const override;
130 };
131 } // namespace targets
132 } // namespace clang
133 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_SPIR_H
clang::CC_OpenCLKernel
Definition: Specifiers.h:250
clang::targets::SPIR64TargetInfo
Definition: SPIR.h:117
clang::TargetInfo::UnsignedLong
Definition: TargetInfo.h:167
clang::CC_SpirFunction
Definition: Specifiers.h:249
clang::targets::SPIRTargetInfo::useFP16ConversionIntrinsics
bool useFP16ConversionIntrinsics() const override
Check whether llvm intrinsics such as llvm.convert.to.fp16 should be used to convert to and from __fp...
Definition: SPIR.h:66
clang::targets::SPIRTargetInfo::checkCallingConvention
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
Definition: SPIR.h:87
clang::targets::SPIR32TargetInfo::SPIR32TargetInfo
SPIR32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: SPIR.h:104
clang::TargetOptions
Options for controlling the target.
Definition: TargetOptions.h:27
clang::targets::SPIRTargetInfo::getTargetBuiltins
ArrayRef< Builtin::Info > getTargetBuiltins() const override
Return information about target-specific builtins for the current primary target, and info about whic...
Definition: SPIR.h:68
clang::TargetInfo::SignedInt
Definition: TargetInfo.h:164
clang::LangOptions
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:50
clang::TargetInfo::UnsignedInt
Definition: TargetInfo.h:165
clang::targets::SPIRTargetInfo::SPIRTargetInfo
SPIRTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
Definition: SPIR.h:39
clang::targets::SPIRTargetInfo
Definition: SPIR.h:37
llvm::ArrayRef
Definition: LLVM.h:32
clang::targets::SPIRTargetInfo::getGCCRegNames
ArrayRef< const char * > getGCCRegNames() const override
Definition: SPIR.h:72
clang::TargetInfo::VoidPtrBuiltinVaList
typedef void* __builtin_va_list;
Definition: TargetInfo.h:187
clang::TargetInfo
Exposes information about the current target.
Definition: TargetInfo.h:54
clang::CallingConv
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:236
clang::TargetInfo::ConstraintInfo
Definition: TargetInfo.h:795
clang::targets::SPIRTargetInfo::setSupportedOpenCLOpts
void setSupportedOpenCLOpts() override
Set supported OpenCL extensions and optional core features.
Definition: SPIR.h:96
TargetOptions.h
Defines the clang::TargetOptions class.
clang::targets::SPIRAddrSpaceMap
static const unsigned SPIRAddrSpaceMap[]
Definition: SPIR.h:25
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:22
clang::targets::SPIRTargetInfo::getBuiltinVaListKind
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
Definition: SPIR.h:83
clang::TargetInfo::SignedLong
Definition: TargetInfo.h:166
clang::targets::SPIR32TargetInfo
Definition: SPIR.h:102
clang::MacroBuilder
Definition: MacroBuilder.h:24
clang::targets::SPIR64TargetInfo::SPIR64TargetInfo
SPIR64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: SPIR.h:119
clang::TargetInfo::BuiltinVaListKind
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Definition: TargetInfo.h:182
clang::targets::SPIRTargetInfo::getDefaultCallingConv
CallingConv getDefaultCallingConv(CallingConvMethodType MT) const override
Gets the default calling convention for the given target and declaration context. ...
Definition: SPIR.h:92
clang::targets::SPIRTargetInfo::validateAsmConstraint
bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &info) const override
Definition: SPIR.h:74
clang::targets::SPIRTargetInfo::getGCCRegAliases
ArrayRef< TargetInfo::GCCRegAlias > getGCCRegAliases() const override
Definition: SPIR.h:79
TargetInfo.h
Defines the clang::TargetInfo interface.
clang::targets::SPIRTargetInfo::hasFeature
bool hasFeature(StringRef Feature) const override
Determine whether the given target has the given feature.
Definition: SPIR.h:60
clang::TargetInfo::CallingConvMethodType
CallingConvMethodType
Definition: TargetInfo.h:1220
clang::targets::SPIRTargetInfo::getClobbers
const char * getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
Definition: SPIR.h:70
clang::TargetInfo::CallingConvCheckResult
CallingConvCheckResult
Definition: TargetInfo.h:1235