|
17 | 17 | #include "clang/Basic/TargetOptions.h"
|
18 | 18 | #include "llvm/ADT/Triple.h"
|
19 | 19 | #include "llvm/Support/Compiler.h"
|
| 20 | +#include "OSTargets.h" |
20 | 21 |
|
21 | 22 | namespace clang {
|
22 | 23 | namespace targets {
|
@@ -143,6 +144,7 @@ class LLVM_LIBRARY_VISIBILITY SPIR64TargetInfo : public SPIRTargetInfo {
|
143 | 144 | PointerWidth = PointerAlign = 64;
|
144 | 145 | SizeType = TargetInfo::UnsignedLong;
|
145 | 146 | PtrDiffType = IntPtrType = TargetInfo::SignedLong;
|
| 147 | + |
146 | 148 | resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-"
|
147 | 149 | "v96:128-v192:256-v256:256-v512:512-v1024:1024");
|
148 | 150 | }
|
@@ -187,6 +189,108 @@ class LLVM_LIBRARY_VISIBILITY SPIR64SYCLDeviceTargetInfo
|
187 | 189 | }
|
188 | 190 | };
|
189 | 191 |
|
| 192 | +// x86-32 SPIR Windows target |
| 193 | +class LLVM_LIBRARY_VISIBILITY WindowsX86_32SPIRTargetInfo |
| 194 | + : public WindowsTargetInfo<SPIR32SYCLDeviceTargetInfo> { |
| 195 | +public: |
| 196 | + WindowsX86_32SPIRTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) |
| 197 | + : WindowsTargetInfo<SPIR32SYCLDeviceTargetInfo>(Triple, Opts) { |
| 198 | + DoubleAlign = LongLongAlign = 64; |
| 199 | + WCharType = UnsignedShort; |
| 200 | + bool IsWinCOFF = |
| 201 | + getTriple().isOSWindows() && getTriple().isOSBinFormatCOFF(); |
| 202 | + resetDataLayout(IsWinCOFF |
| 203 | + ? "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32" |
| 204 | + : "e-m:e-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"); |
| 205 | + } |
| 206 | + |
| 207 | + BuiltinVaListKind getBuiltinVaListKind() const override { |
| 208 | + return TargetInfo::CharPtrBuiltinVaList; |
| 209 | + } |
| 210 | + |
| 211 | + CallingConvCheckResult checkCallingConvention(CallingConv CC) const override { |
| 212 | + if (CC == CC_X86VectorCall) |
| 213 | + // Permit CC_X86VectorCall which is used in Microsoft headers |
| 214 | + return CCCR_OK; |
| 215 | + return (CC == CC_SpirFunction || CC == CC_OpenCLKernel) ? CCCR_OK |
| 216 | + : CCCR_Warning; |
| 217 | + } |
| 218 | +}; |
| 219 | + |
| 220 | +// x86-32 SPIR Windows Visual Studio target |
| 221 | +class LLVM_LIBRARY_VISIBILITY MicrosoftX86_32SPIRTargetInfo |
| 222 | + : public WindowsX86_32SPIRTargetInfo { |
| 223 | +public: |
| 224 | + MicrosoftX86_32SPIRTargetInfo(const llvm::Triple &Triple, |
| 225 | + const TargetOptions &Opts) |
| 226 | + : WindowsX86_32SPIRTargetInfo(Triple, Opts) { |
| 227 | + LongDoubleWidth = LongDoubleAlign = 64; |
| 228 | + LongDoubleFormat = &llvm::APFloat::IEEEdouble(); |
| 229 | + } |
| 230 | + |
| 231 | + void getTargetDefines(const LangOptions &Opts, |
| 232 | + MacroBuilder &Builder) const override { |
| 233 | + WindowsX86_32SPIRTargetInfo::getTargetDefines(Opts, Builder); |
| 234 | + // The value of the following reflects processor type. |
| 235 | + // 300=386, 400=486, 500=Pentium, 600=Blend (default) |
| 236 | + // We lost the original triple, so we use the default. |
| 237 | + // TBD should we keep these lines? Copied from X86.h. |
| 238 | + Builder.defineMacro("_M_IX86", "600"); |
| 239 | + } |
| 240 | +}; |
| 241 | + |
| 242 | +// x86-64 SPIR64 Windows target |
| 243 | +class LLVM_LIBRARY_VISIBILITY WindowsX86_64_SPIR64TargetInfo |
| 244 | + : public WindowsTargetInfo<SPIR64SYCLDeviceTargetInfo> { |
| 245 | +public: |
| 246 | + WindowsX86_64_SPIR64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) |
| 247 | + : WindowsTargetInfo<SPIR64SYCLDeviceTargetInfo>(Triple, Opts) { |
| 248 | + LongWidth = LongAlign = 32; |
| 249 | + DoubleAlign = LongLongAlign = 64; |
| 250 | + IntMaxType = SignedLongLong; |
| 251 | + Int64Type = SignedLongLong; |
| 252 | + SizeType = UnsignedLongLong; |
| 253 | + PtrDiffType = SignedLongLong; |
| 254 | + IntPtrType = SignedLongLong; |
| 255 | + WCharType = UnsignedShort; |
| 256 | + bool IsWinCOFF = |
| 257 | + getTriple().isOSWindows() && getTriple().isOSBinFormatCOFF(); |
| 258 | + resetDataLayout(IsWinCOFF |
| 259 | + ? "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32" |
| 260 | + : "e-m:e-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"); |
| 261 | + } |
| 262 | + |
| 263 | + BuiltinVaListKind getBuiltinVaListKind() const override { |
| 264 | + return TargetInfo::CharPtrBuiltinVaList; |
| 265 | + } |
| 266 | + |
| 267 | + CallingConvCheckResult checkCallingConvention(CallingConv CC) const override { |
| 268 | + if (CC == CC_X86VectorCall) |
| 269 | + // Permit CC_X86VectorCall which is used in Microsoft headers |
| 270 | + return CCCR_OK; |
| 271 | + return (CC == CC_SpirFunction || CC == CC_OpenCLKernel) ? CCCR_OK |
| 272 | + : CCCR_Warning; |
| 273 | + } |
| 274 | +}; |
| 275 | + |
| 276 | +// x86-64 SPIR64 Windows Visual Studio target |
| 277 | +class LLVM_LIBRARY_VISIBILITY MicrosoftX86_64_SPIR64TargetInfo |
| 278 | + : public WindowsX86_64_SPIR64TargetInfo { |
| 279 | +public: |
| 280 | + MicrosoftX86_64_SPIR64TargetInfo(const llvm::Triple &Triple, |
| 281 | + const TargetOptions &Opts) |
| 282 | + : WindowsX86_64_SPIR64TargetInfo(Triple, Opts) { |
| 283 | + LongDoubleWidth = LongDoubleAlign = 64; |
| 284 | + LongDoubleFormat = &llvm::APFloat::IEEEdouble(); |
| 285 | + } |
| 286 | + |
| 287 | + void getTargetDefines(const LangOptions &Opts, |
| 288 | + MacroBuilder &Builder) const override { |
| 289 | + WindowsX86_64_SPIR64TargetInfo::getTargetDefines(Opts, Builder); |
| 290 | + Builder.defineMacro("_M_X64", "100"); |
| 291 | + Builder.defineMacro("_M_AMD64", "100"); |
| 292 | + } |
| 293 | +}; |
190 | 294 | } // namespace targets
|
191 | 295 | } // namespace clang
|
192 | 296 | #endif // LLVM_CLANG_LIB_BASIC_TARGETS_SPIR_H
|
0 commit comments