clang  19.0.0git
SPIR.h
Go to the documentation of this file.
1 //===--- SPIR.h - Declare SPIR and SPIR-V target feature support *- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file declares SPIR and SPIR-V TargetInfo objects.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_SPIR_H
14 #define LLVM_CLANG_LIB_BASIC_TARGETS_SPIR_H
15 
16 #include "Targets.h"
17 #include "clang/Basic/TargetInfo.h"
19 #include "llvm/IR/DataLayout.h"
20 #include "llvm/Support/Compiler.h"
21 #include "OSTargets.h"
22 #include "llvm/Support/Compiler.h"
23 #include "llvm/Support/VersionTuple.h"
24 #include "llvm/TargetParser/Triple.h"
25 #include <optional>
26 
27 namespace clang {
28 namespace targets {
29 
30 // Used by both the SPIR and SPIR-V targets.
31 static const unsigned SPIRDefIsPrivMap[] = {
32  0, // Default
33  1, // opencl_global
34  3, // opencl_local
35  2, // opencl_constant
36  0, // opencl_private
37  4, // opencl_generic
38  5, // opencl_global_device
39  6, // opencl_global_host
40  0, // cuda_device
41  0, // cuda_constant
42  0, // cuda_shared
43  // SYCL address space values for this map are dummy
44  0, // sycl_global
45  0, // sycl_global_device
46  0, // sycl_global_host
47  0, // sycl_local
48  0, // sycl_private
49  0, // ptr32_sptr
50  0, // ptr32_uptr
51  0, // ptr64
52  0, // hlsl_groupshared
53  // Wasm address space values for this target are dummy values,
54  // as it is only enabled for Wasm targets.
55  20, // wasm_funcref
56 };
57 
58 // Used by both the SPIR and SPIR-V targets.
59 static const unsigned SPIRDefIsGenMap[] = {
60  4, // Default
61  // OpenCL address space values for this map are dummy and they can't be used
62  // FIXME: reset opencl_global entry to 0. Currently CodeGen libary uses
63  // opencl_global in SYCL language mode, but we should switch to using
64  // sycl_global instead.
65  1, // opencl_global
66  0, // opencl_local
67  2, // opencl_constant
68  0, // opencl_private
69  0, // opencl_generic
70  0, // opencl_global_device
71  0, // opencl_global_host
72  // cuda_* address space mapping is intended for HIPSPV (HIP to SPIR-V
73  // translation). This mapping is enabled when the language mode is HIP.
74  1, // cuda_device
75  // cuda_constant pointer can be casted to default/"flat" pointer, but in
76  // SPIR-V casts between constant and generic pointers are not allowed. For
77  // this reason cuda_constant is mapped to SPIR-V CrossWorkgroup.
78  1, // cuda_constant
79  3, // cuda_shared
80  1, // sycl_global
81  5, // sycl_global_device
82  6, // sycl_global_host
83  3, // sycl_local
84  0, // sycl_private
85  0, // ptr32_sptr
86  0, // ptr32_uptr
87  0, // ptr64
88  0, // hlsl_groupshared
89  // Wasm address space values for this target are dummy values,
90  // as it is only enabled for Wasm targets.
91  20, // wasm_funcref
92 };
93 
94 // Base class for SPIR and SPIR-V target info.
95 class LLVM_LIBRARY_VISIBILITY BaseSPIRTargetInfo : public TargetInfo {
96  std::unique_ptr<TargetInfo> HostTarget;
97 
98 protected:
99  BaseSPIRTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
100  : TargetInfo(Triple) {
101  assert((Triple.isSPIR() || Triple.isSPIRV()) &&
102  "Invalid architecture for SPIR or SPIR-V.");
103  TLSSupported = false;
104  VLASupported = false;
105  LongWidth = LongAlign = 64;
106  AddrSpaceMap = &SPIRDefIsPrivMap;
107  UseAddrSpaceMapMangling = true;
108  HasLegalHalfType = true;
109  HasFloat16 = true;
110  // Define available target features
111  // These must be defined in sorted order!
112  NoAsmVariants = true;
113 
114  llvm::Triple HostTriple(Opts.HostTriple);
115  if (!HostTriple.isSPIR() && !HostTriple.isSPIRV() &&
116  HostTriple.getArch() != llvm::Triple::UnknownArch) {
117  HostTarget = AllocateTarget(llvm::Triple(Opts.HostTriple), Opts);
118 
119  // Copy properties from host target.
120  BoolWidth = HostTarget->getBoolWidth();
121  BoolAlign = HostTarget->getBoolAlign();
122  IntWidth = HostTarget->getIntWidth();
123  IntAlign = HostTarget->getIntAlign();
124  HalfWidth = HostTarget->getHalfWidth();
125  HalfAlign = HostTarget->getHalfAlign();
126  FloatWidth = HostTarget->getFloatWidth();
127  FloatAlign = HostTarget->getFloatAlign();
128  DoubleWidth = HostTarget->getDoubleWidth();
129  DoubleAlign = HostTarget->getDoubleAlign();
130  LongWidth = HostTarget->getLongWidth();
131  LongAlign = HostTarget->getLongAlign();
132  LongLongWidth = HostTarget->getLongLongWidth();
133  LongLongAlign = HostTarget->getLongLongAlign();
134  MinGlobalAlign =
135  HostTarget->getMinGlobalAlign(/* TypeSize = */ 0,
136  /* HasNonWeakDef = */ true);
137  NewAlign = HostTarget->getNewAlign();
138  DefaultAlignForAttributeAligned =
139  HostTarget->getDefaultAlignForAttributeAligned();
140  IntMaxType = HostTarget->getIntMaxType();
141  WCharType = HostTarget->getWCharType();
142  WIntType = HostTarget->getWIntType();
143  Char16Type = HostTarget->getChar16Type();
144  Char32Type = HostTarget->getChar32Type();
145  Int64Type = HostTarget->getInt64Type();
146  SigAtomicType = HostTarget->getSigAtomicType();
147  ProcessIDType = HostTarget->getProcessIDType();
148 
149  UseBitFieldTypeAlignment = HostTarget->useBitFieldTypeAlignment();
150  UseZeroLengthBitfieldAlignment =
151  HostTarget->useZeroLengthBitfieldAlignment();
152  UseExplicitBitFieldAlignment = HostTarget->useExplicitBitFieldAlignment();
153  ZeroLengthBitfieldBoundary = HostTarget->getZeroLengthBitfieldBoundary();
154 
155  // This is a bit of a lie, but it controls __GCC_ATOMIC_XXX_LOCK_FREE, and
156  // we need those macros to be identical on host and device, because (among
157  // other things) they affect which standard library classes are defined,
158  // and we need all classes to be defined on both the host and device.
159  MaxAtomicInlineWidth = HostTarget->getMaxAtomicInlineWidth();
160  }
161  }
162 
163 public:
164  // SPIR supports the half type and the only llvm intrinsic allowed in SPIR is
165  // memcpy as per section 3 of the SPIR spec.
166  bool useFP16ConversionIntrinsics() const override { return false; }
167 
169  return std::nullopt;
170  }
171 
172  std::string_view getClobbers() const override { return ""; }
173 
175  return std::nullopt;
176  }
177 
178  bool validateAsmConstraint(const char *&Name,
179  TargetInfo::ConstraintInfo &info) const override {
180  return true;
181  }
182 
184  return std::nullopt;
185  }
186 
189  }
190 
191  std::optional<unsigned>
192  getDWARFAddressSpace(unsigned AddressSpace) const override {
193  return AddressSpace;
194  }
195 
197  return (CC == CC_SpirFunction || CC == CC_OpenCLKernel ||
198  // Permit CC_X86RegCall which is used to mark external functions
199  // with explicit simd or structure type arguments to pass them via
200  // registers.
201  CC == CC_X86RegCall)
202  ? CCCR_OK
203  : CCCR_Warning;
204  }
205 
207  return CC_SpirFunction;
208  }
209 
210  void setAddressSpaceMap(bool DefaultIsGeneric) {
211  AddrSpaceMap = DefaultIsGeneric ? &SPIRDefIsGenMap : &SPIRDefIsPrivMap;
212  }
213 
214  void adjust(DiagnosticsEngine &Diags, LangOptions &Opts) override {
215  TargetInfo::adjust(Diags, Opts);
216  // NOTE: SYCL specification considers unannotated pointers and references
217  // to be pointing to the generic address space. See section 5.9.3 of
218  // SYCL 2020 specification.
219  // Currently, there is no way of representing SYCL's and HIP/CUDA's default
220  // address space language semantic along with the semantics of embedded C's
221  // default address space in the same address space map. Hence the map needs
222  // to be reset to allow mapping to the desired value of 'Default' entry for
223  // SYCL and HIP/CUDA.
224  setAddressSpaceMap(
225  /*DefaultIsGeneric=*/Opts.SYCLIsDevice ||
226  // The address mapping from HIP/CUDA language for device code is only
227  // defined for SPIR-V.
228  (getTriple().isSPIRV() && Opts.CUDAIsDevice));
229  }
230 
231  void setSupportedOpenCLOpts() override {
232  // Assume all OpenCL extensions and optional core features are supported
233  // for SPIR and SPIR-V since they are generic targets.
234  supportAllOpenCLOpts();
235  }
236 
237  bool hasBitIntType() const override { return true; }
238 
239  bool hasInt128Type() const override { return false; }
240 };
241 
242 class LLVM_LIBRARY_VISIBILITY SPIRTargetInfo : public BaseSPIRTargetInfo {
243 public:
244  SPIRTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
245  : BaseSPIRTargetInfo(Triple, Opts) {
246  assert(Triple.isSPIR() && "Invalid architecture for SPIR.");
247  }
248 
249  void getTargetDefines(const LangOptions &Opts,
250  MacroBuilder &Builder) const override;
251 
252  bool hasFeature(StringRef Feature) const override {
253  return Feature == "spir";
254  }
255 
256  bool checkArithmeticFenceSupported() const override { return true; }
257 };
258 
259 class LLVM_LIBRARY_VISIBILITY SPIR32TargetInfo : public SPIRTargetInfo {
260 public:
261  SPIR32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
262  : SPIRTargetInfo(Triple, Opts) {
263  assert(Triple.getArch() == llvm::Triple::spir &&
264  "Invalid architecture for 32-bit SPIR.");
265  PointerWidth = PointerAlign = 32;
266  SizeType = TargetInfo::UnsignedInt;
267  PtrDiffType = IntPtrType = TargetInfo::SignedInt;
268  resetDataLayout(
269  "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
270  "v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1");
271  }
272 
273  void getTargetDefines(const LangOptions &Opts,
274  MacroBuilder &Builder) const override;
275 };
276 
277 class LLVM_LIBRARY_VISIBILITY SPIR64TargetInfo : public SPIRTargetInfo {
278 public:
279  SPIR64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
280  : SPIRTargetInfo(Triple, Opts) {
281  assert(Triple.getArch() == llvm::Triple::spir64 &&
282  "Invalid architecture for 64-bit SPIR.");
283  PointerWidth = PointerAlign = 64;
284  SizeType = TargetInfo::UnsignedLong;
285  PtrDiffType = IntPtrType = TargetInfo::SignedLong;
286 
287  resetDataLayout(
288  "e-i64:64-v16:16-v24:32-v32:32-v48:64-"
289  "v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1");
290  }
291 
292  void getTargetDefines(const LangOptions &Opts,
293  MacroBuilder &Builder) const override;
294 };
295 
296 // spir64_fpga target
297 class LLVM_LIBRARY_VISIBILITY SPIR64FPGATargetInfo : public SPIR64TargetInfo {
298 public:
299  SPIR64FPGATargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
300  : SPIR64TargetInfo(Triple, Opts) {}
301  virtual size_t getMaxBitIntWidth() const override { return 4096; }
302 };
303 
304 // x86-32 SPIR Windows target
305 class LLVM_LIBRARY_VISIBILITY WindowsX86_32SPIRTargetInfo
306  : public WindowsTargetInfo<SPIR32TargetInfo> {
307 public:
308  WindowsX86_32SPIRTargetInfo(const llvm::Triple &Triple,
309  const TargetOptions &Opts)
310  : WindowsTargetInfo<SPIR32TargetInfo>(Triple, Opts) {
311  DoubleAlign = LongLongAlign = 64;
312  WCharType = UnsignedShort;
313  }
314 
315  BuiltinVaListKind getBuiltinVaListKind() const override {
317  }
318 
319  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
320  if (CC == CC_X86VectorCall)
321  // Permit CC_X86VectorCall which is used in Microsoft headers
322  return CCCR_OK;
323  return (CC == CC_SpirFunction || CC == CC_OpenCLKernel) ? CCCR_OK
324  : CCCR_Warning;
325  }
326 };
327 
328 // x86-32 SPIR Windows Visual Studio target
329 class LLVM_LIBRARY_VISIBILITY MicrosoftX86_32SPIRTargetInfo
330  : public WindowsX86_32SPIRTargetInfo {
331 public:
332  MicrosoftX86_32SPIRTargetInfo(const llvm::Triple &Triple,
333  const TargetOptions &Opts)
334  : WindowsX86_32SPIRTargetInfo(Triple, Opts) {
335  }
336 
337  void getTargetDefines(const LangOptions &Opts,
338  MacroBuilder &Builder) const override {
340  // The value of the following reflects processor type.
341  // 300=386, 400=486, 500=Pentium, 600=Blend (default)
342  // We lost the original triple, so we use the default.
343  // TBD should we keep these lines? Copied from X86.h.
344  Builder.defineMacro("_M_IX86", "600");
345  }
346 };
347 
348 // x86-64 SPIR64 Windows target
349 class LLVM_LIBRARY_VISIBILITY WindowsX86_64_SPIR64TargetInfo
350  : public WindowsTargetInfo<SPIR64TargetInfo> {
351 public:
352  WindowsX86_64_SPIR64TargetInfo(const llvm::Triple &Triple,
353  const TargetOptions &Opts)
354  : WindowsTargetInfo<SPIR64TargetInfo>(Triple, Opts) {
355  LongWidth = LongAlign = 32;
356  DoubleAlign = LongLongAlign = 64;
357  IntMaxType = SignedLongLong;
358  Int64Type = SignedLongLong;
359  SizeType = UnsignedLongLong;
360  PtrDiffType = SignedLongLong;
361  IntPtrType = SignedLongLong;
362  WCharType = UnsignedShort;
363  }
364 
365  BuiltinVaListKind getBuiltinVaListKind() const override {
367  }
368 
369  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
370  if (CC == CC_X86VectorCall || CC == CC_X86RegCall)
371  // Permit CC_X86VectorCall which is used in Microsoft headers
372  // Permit CC_X86RegCall which is used to mark external functions with
373  // explicit simd or structure type arguments to pass them via registers.
374  return CCCR_OK;
375  return (CC == CC_SpirFunction || CC == CC_OpenCLKernel) ? CCCR_OK
376  : CCCR_Warning;
377  }
378 };
379 
380 // x86-64 SPIR64 Windows Visual Studio target
381 class LLVM_LIBRARY_VISIBILITY MicrosoftX86_64_SPIR64TargetInfo
383 public:
384  MicrosoftX86_64_SPIR64TargetInfo(const llvm::Triple &Triple,
385  const TargetOptions &Opts)
386  : WindowsX86_64_SPIR64TargetInfo(Triple, Opts) {
387  }
388 
389  void getTargetDefines(const LangOptions &Opts,
390  MacroBuilder &Builder) const override {
392  Builder.defineMacro("_M_X64", "100");
393  Builder.defineMacro("_M_AMD64", "100");
394  }
395 };
396 
397 class LLVM_LIBRARY_VISIBILITY BaseSPIRVTargetInfo : public BaseSPIRTargetInfo {
398 public:
399  BaseSPIRVTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
400  : BaseSPIRTargetInfo(Triple, Opts) {
401  assert(Triple.isSPIRV() && "Invalid architecture for SPIR-V.");
402  }
403 
404  bool hasFeature(StringRef Feature) const override {
405  return Feature == "spirv";
406  }
407 
408  void getTargetDefines(const LangOptions &Opts,
409  MacroBuilder &Builder) const override;
410 };
411 
412 class LLVM_LIBRARY_VISIBILITY SPIRVTargetInfo : public BaseSPIRVTargetInfo {
413 public:
414  SPIRVTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
415  : BaseSPIRVTargetInfo(Triple, Opts) {
416  assert(Triple.getArch() == llvm::Triple::spirv &&
417  "Invalid architecture for Logical SPIR-V.");
418  assert(Triple.getOS() == llvm::Triple::Vulkan &&
419  Triple.getVulkanVersion() != llvm::VersionTuple(0) &&
420  "Logical SPIR-V requires a valid Vulkan environment.");
421  assert(Triple.getEnvironment() >= llvm::Triple::Pixel &&
422  Triple.getEnvironment() <= llvm::Triple::Amplification &&
423  "Logical SPIR-V environment must be a valid shader stage.");
424  PointerWidth = PointerAlign = 64;
425 
426  // SPIR-V IDs are represented with a single 32-bit word.
427  SizeType = TargetInfo::UnsignedInt;
428  resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-"
429  "v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
430  }
431 
432  void getTargetDefines(const LangOptions &Opts,
433  MacroBuilder &Builder) const override;
434 };
435 
436 class LLVM_LIBRARY_VISIBILITY SPIRV32TargetInfo : public BaseSPIRVTargetInfo {
437 public:
438  SPIRV32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
439  : BaseSPIRVTargetInfo(Triple, Opts) {
440  assert(Triple.getArch() == llvm::Triple::spirv32 &&
441  "Invalid architecture for 32-bit SPIR-V.");
442  assert(getTriple().getOS() == llvm::Triple::UnknownOS &&
443  "32-bit SPIR-V target must use unknown OS");
444  assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
445  "32-bit SPIR-V target must use unknown environment type");
446  PointerWidth = PointerAlign = 32;
447  SizeType = TargetInfo::UnsignedInt;
448  PtrDiffType = IntPtrType = TargetInfo::SignedInt;
449  resetDataLayout("e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
450  "v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
451  }
452 
453  void getTargetDefines(const LangOptions &Opts,
454  MacroBuilder &Builder) const override;
455 };
456 
457 class LLVM_LIBRARY_VISIBILITY SPIRV64TargetInfo : public BaseSPIRVTargetInfo {
458 public:
459  SPIRV64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
460  : BaseSPIRVTargetInfo(Triple, Opts) {
461  assert(Triple.getArch() == llvm::Triple::spirv64 &&
462  "Invalid architecture for 64-bit SPIR-V.");
463  assert(getTriple().getOS() == llvm::Triple::UnknownOS &&
464  "64-bit SPIR-V target must use unknown OS");
465  assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
466  "64-bit SPIR-V target must use unknown environment type");
467  PointerWidth = PointerAlign = 64;
468  SizeType = TargetInfo::UnsignedLong;
469  PtrDiffType = IntPtrType = TargetInfo::SignedLong;
470  resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-"
471  "v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
472  }
473 
474  void getTargetDefines(const LangOptions &Opts,
475  MacroBuilder &Builder) const override;
476 };
477 
478 // x86-32 SPIRV32 Windows target
479 class LLVM_LIBRARY_VISIBILITY WindowsX86_32SPIRV32TargetInfo
480  : public WindowsTargetInfo<SPIRV32TargetInfo> {
481 public:
482  WindowsX86_32SPIRV32TargetInfo(const llvm::Triple &Triple,
483  const TargetOptions &Opts)
484  : WindowsTargetInfo<SPIRV32TargetInfo>(Triple, Opts) {
485  DoubleAlign = LongLongAlign = 64;
486  WCharType = UnsignedShort;
487  }
488 
489  BuiltinVaListKind getBuiltinVaListKind() const override {
491  }
492 
493  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
494  if (CC == CC_X86VectorCall)
495  // Permit CC_X86VectorCall which is used in Microsoft headers
496  return CCCR_OK;
497  return (CC == CC_SpirFunction || CC == CC_OpenCLKernel) ? CCCR_OK
498  : CCCR_Warning;
499  }
500 };
501 
502 // x86-32 SPIRV32 Windows Visual Studio target
503 class LLVM_LIBRARY_VISIBILITY MicrosoftX86_32SPIRV32TargetInfo
505 public:
506  MicrosoftX86_32SPIRV32TargetInfo(const llvm::Triple &Triple,
507  const TargetOptions &Opts)
508  : WindowsX86_32SPIRV32TargetInfo(Triple, Opts) {}
509 
510  void getTargetDefines(const LangOptions &Opts,
511  MacroBuilder &Builder) const override {
513  // The value of the following reflects processor type.
514  // 300=386, 400=486, 500=Pentium, 600=Blend (default)
515  // We lost the original triple, so we use the default.
516  Builder.defineMacro("_M_IX86", "600");
517  }
518 };
519 
520 // x86-64 SPIRV64 Windows target
521 class LLVM_LIBRARY_VISIBILITY WindowsX86_64_SPIRV64TargetInfo
522  : public WindowsTargetInfo<SPIRV64TargetInfo> {
523 public:
524  WindowsX86_64_SPIRV64TargetInfo(const llvm::Triple &Triple,
525  const TargetOptions &Opts)
526  : WindowsTargetInfo<SPIRV64TargetInfo>(Triple, Opts) {
527  LongWidth = LongAlign = 32;
528  DoubleAlign = LongLongAlign = 64;
529  IntMaxType = SignedLongLong;
530  Int64Type = SignedLongLong;
531  SizeType = UnsignedLongLong;
532  PtrDiffType = SignedLongLong;
533  IntPtrType = SignedLongLong;
534  WCharType = UnsignedShort;
535  }
536 
537  BuiltinVaListKind getBuiltinVaListKind() const override {
539  }
540 
541  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
542  if (CC == CC_X86VectorCall || CC == CC_X86RegCall)
543  // Permit CC_X86VectorCall which is used in Microsoft headers
544  // Permit CC_X86RegCall which is used to mark external functions with
545  // explicit simd or structure type arguments to pass them via registers.
546  return CCCR_OK;
547  return (CC == CC_SpirFunction || CC == CC_OpenCLKernel) ? CCCR_OK
548  : CCCR_Warning;
549  }
550 };
551 
552 // x86-64 SPIRV64 Windows Visual Studio target
553 class LLVM_LIBRARY_VISIBILITY MicrosoftX86_64_SPIRV64TargetInfo
555 public:
556  MicrosoftX86_64_SPIRV64TargetInfo(const llvm::Triple &Triple,
557  const TargetOptions &Opts)
558  : WindowsX86_64_SPIRV64TargetInfo(Triple, Opts) {}
559 
560  void getTargetDefines(const LangOptions &Opts,
561  MacroBuilder &Builder) const override {
563  Builder.defineMacro("_M_X64", "100");
564  Builder.defineMacro("_M_AMD64", "100");
565  }
566 };
567 
568 } // namespace targets
569 } // namespace clang
570 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_SPIR_H
Defines the clang::TargetOptions class.
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:193
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:482
Exposes information about the current target.
Definition: TargetInfo.h:218
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Definition: TargetInfo.h:319
@ CharPtrBuiltinVaList
typedef char* __builtin_va_list;
Definition: TargetInfo.h:321
@ VoidPtrBuiltinVaList
typedef void* __builtin_va_list;
Definition: TargetInfo.h:324
virtual void adjust(DiagnosticsEngine &Diags, LangOptions &Opts)
Set forced language options.
Definition: TargetInfo.cpp:392
Options for controlling the target.
Definition: TargetOptions.h:26
std::string HostTriple
When compiling for the device side, contains the triple used to compile for the host.
Definition: TargetOptions.h:33
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
Definition: SPIR.h:187
ArrayRef< TargetInfo::GCCRegAlias > getGCCRegAliases() const override
Definition: SPIR.h:183
void adjust(DiagnosticsEngine &Diags, LangOptions &Opts) override
Set forced language options.
Definition: SPIR.h:214
bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &info) const override
Definition: SPIR.h:178
bool hasInt128Type() const override
Determine whether the __int128 type is supported on this target.
Definition: SPIR.h:239
void setAddressSpaceMap(bool DefaultIsGeneric)
Definition: SPIR.h:210
std::optional< unsigned > getDWARFAddressSpace(unsigned AddressSpace) const override
Definition: SPIR.h:192
ArrayRef< const char * > getGCCRegNames() const override
Definition: SPIR.h:174
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:166
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
Definition: SPIR.h:196
BaseSPIRTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: SPIR.h:99
bool hasBitIntType() const override
Determine whether the _BitInt type is supported on this target.
Definition: SPIR.h:237
void setSupportedOpenCLOpts() override
Set supported OpenCL extensions and optional core features.
Definition: SPIR.h:231
ArrayRef< Builtin::Info > getTargetBuiltins() const override
Return information about target-specific builtins for the current primary target, and info about whic...
Definition: SPIR.h:168
std::string_view getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
Definition: SPIR.h:172
CallingConv getDefaultCallingConv() const override
Gets the default calling convention for the given target and declaration context.
Definition: SPIR.h:206
bool hasFeature(StringRef Feature) const override
Determine whether the given target has the given feature.
Definition: SPIR.h:404
BaseSPIRVTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: SPIR.h:399
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
Definition: SPIR.h:337
MicrosoftX86_32SPIRTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: SPIR.h:332
MicrosoftX86_32SPIRV32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: SPIR.h:506
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
Definition: SPIR.h:510
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
Definition: SPIR.h:389
MicrosoftX86_64_SPIR64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: SPIR.h:384
MicrosoftX86_64_SPIRV64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: SPIR.h:556
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
Definition: SPIR.h:560
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
Definition: OSTargets.h:30
SPIR32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: SPIR.h:261
SPIR64FPGATargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: SPIR.h:299
virtual size_t getMaxBitIntWidth() const override
Definition: SPIR.h:301
SPIR64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: SPIR.h:279
SPIRTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: SPIR.h:244
bool checkArithmeticFenceSupported() const override
Controls if __arithmetic_fence is supported in the targeted backend.
Definition: SPIR.h:256
bool hasFeature(StringRef Feature) const override
Determine whether the given target has the given feature.
Definition: SPIR.h:252
SPIRV32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: SPIR.h:438
SPIRV64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: SPIR.h:459
SPIRVTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: SPIR.h:414
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Definition: SPIR.h:319
WindowsX86_32SPIRTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: SPIR.h:308
BuiltinVaListKind getBuiltinVaListKind() const override
Definition: SPIR.h:315
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Definition: SPIR.h:493
WindowsX86_32SPIRV32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: SPIR.h:482
BuiltinVaListKind getBuiltinVaListKind() const override
Definition: SPIR.h:489
WindowsX86_64_SPIR64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: SPIR.h:352
BuiltinVaListKind getBuiltinVaListKind() const override
Definition: SPIR.h:365
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Definition: SPIR.h:369
BuiltinVaListKind getBuiltinVaListKind() const override
Definition: SPIR.h:537
WindowsX86_64_SPIRV64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: SPIR.h:524
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Definition: SPIR.h:541
Defines the clang::TargetInfo interface.
static const unsigned SPIRDefIsPrivMap[]
Definition: SPIR.h:31
static const unsigned SPIRDefIsGenMap[]
Definition: SPIR.h:59
std::unique_ptr< TargetInfo > AllocateTarget(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: Targets.cpp:112
The JSON file list parser is used to communicate input to InstallAPI.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:275
@ CC_OpenCLKernel
Definition: Specifiers.h:289
@ CC_X86RegCall
Definition: Specifiers.h:284
@ CC_X86VectorCall
Definition: Specifiers.h:280
@ CC_SpirFunction
Definition: Specifiers.h:288