1349cc55cSDimitry Andric //===--- SPIR.h - Declare SPIR and SPIR-V target feature support *- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 9349cc55cSDimitry Andric // This file declares SPIR and SPIR-V TargetInfo objects. 100b57cec5SDimitry Andric // 110b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_SPIR_H 140b57cec5SDimitry Andric #define LLVM_CLANG_LIB_BASIC_TARGETS_SPIR_H 150b57cec5SDimitry Andric 1606c3fb27SDimitry Andric #include "Targets.h" 170b57cec5SDimitry Andric #include "clang/Basic/TargetInfo.h" 180b57cec5SDimitry Andric #include "clang/Basic/TargetOptions.h" 190b57cec5SDimitry Andric #include "llvm/Support/Compiler.h" 20*7a6dacacSDimitry Andric #include "llvm/Support/VersionTuple.h" 2106c3fb27SDimitry Andric #include "llvm/TargetParser/Triple.h" 22bdd1243dSDimitry Andric #include <optional> 230b57cec5SDimitry Andric 240b57cec5SDimitry Andric namespace clang { 250b57cec5SDimitry Andric namespace targets { 260b57cec5SDimitry Andric 27349cc55cSDimitry Andric // Used by both the SPIR and SPIR-V targets. 28fe6060f1SDimitry Andric static const unsigned SPIRDefIsPrivMap[] = { 290b57cec5SDimitry Andric 0, // Default 300b57cec5SDimitry Andric 1, // opencl_global 310b57cec5SDimitry Andric 3, // opencl_local 320b57cec5SDimitry Andric 2, // opencl_constant 330b57cec5SDimitry Andric 0, // opencl_private 340b57cec5SDimitry Andric 4, // opencl_generic 35e8d8bef9SDimitry Andric 5, // opencl_global_device 36e8d8bef9SDimitry Andric 6, // opencl_global_host 370b57cec5SDimitry Andric 0, // cuda_device 380b57cec5SDimitry Andric 0, // cuda_constant 39480093f4SDimitry Andric 0, // cuda_shared 40fe6060f1SDimitry Andric // SYCL address space values for this map are dummy 41fe6060f1SDimitry Andric 0, // sycl_global 42fe6060f1SDimitry Andric 0, // sycl_global_device 43fe6060f1SDimitry Andric 0, // sycl_global_host 44fe6060f1SDimitry Andric 0, // sycl_local 45fe6060f1SDimitry Andric 0, // sycl_private 46fe6060f1SDimitry Andric 0, // ptr32_sptr 47fe6060f1SDimitry Andric 0, // ptr32_uptr 48bdd1243dSDimitry Andric 0, // ptr64 49bdd1243dSDimitry Andric 0, // hlsl_groupshared 5006c3fb27SDimitry Andric // Wasm address space values for this target are dummy values, 5106c3fb27SDimitry Andric // as it is only enabled for Wasm targets. 5206c3fb27SDimitry Andric 20, // wasm_funcref 53fe6060f1SDimitry Andric }; 54fe6060f1SDimitry Andric 55349cc55cSDimitry Andric // Used by both the SPIR and SPIR-V targets. 56fe6060f1SDimitry Andric static const unsigned SPIRDefIsGenMap[] = { 57fe6060f1SDimitry Andric 4, // Default 58fe6060f1SDimitry Andric // OpenCL address space values for this map are dummy and they can't be used 59fe6060f1SDimitry Andric 0, // opencl_global 60fe6060f1SDimitry Andric 0, // opencl_local 61fe6060f1SDimitry Andric 0, // opencl_constant 62fe6060f1SDimitry Andric 0, // opencl_private 63fe6060f1SDimitry Andric 0, // opencl_generic 64fe6060f1SDimitry Andric 0, // opencl_global_device 65fe6060f1SDimitry Andric 0, // opencl_global_host 664824e7fdSDimitry Andric // cuda_* address space mapping is intended for HIPSPV (HIP to SPIR-V 674824e7fdSDimitry Andric // translation). This mapping is enabled when the language mode is HIP. 684824e7fdSDimitry Andric 1, // cuda_device 694824e7fdSDimitry Andric // cuda_constant pointer can be casted to default/"flat" pointer, but in 704824e7fdSDimitry Andric // SPIR-V casts between constant and generic pointers are not allowed. For 714824e7fdSDimitry Andric // this reason cuda_constant is mapped to SPIR-V CrossWorkgroup. 724824e7fdSDimitry Andric 1, // cuda_constant 734824e7fdSDimitry Andric 3, // cuda_shared 74fe6060f1SDimitry Andric 1, // sycl_global 75fe6060f1SDimitry Andric 5, // sycl_global_device 76fe6060f1SDimitry Andric 6, // sycl_global_host 77fe6060f1SDimitry Andric 3, // sycl_local 78fe6060f1SDimitry Andric 0, // sycl_private 79480093f4SDimitry Andric 0, // ptr32_sptr 80480093f4SDimitry Andric 0, // ptr32_uptr 81bdd1243dSDimitry Andric 0, // ptr64 82bdd1243dSDimitry Andric 0, // hlsl_groupshared 8306c3fb27SDimitry Andric // Wasm address space values for this target are dummy values, 8406c3fb27SDimitry Andric // as it is only enabled for Wasm targets. 8506c3fb27SDimitry Andric 20, // wasm_funcref 860b57cec5SDimitry Andric }; 870b57cec5SDimitry Andric 88349cc55cSDimitry Andric // Base class for SPIR and SPIR-V target info. 89349cc55cSDimitry Andric class LLVM_LIBRARY_VISIBILITY BaseSPIRTargetInfo : public TargetInfo { 9006c3fb27SDimitry Andric std::unique_ptr<TargetInfo> HostTarget; 9106c3fb27SDimitry Andric 92349cc55cSDimitry Andric protected: 9306c3fb27SDimitry Andric BaseSPIRTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 940b57cec5SDimitry Andric : TargetInfo(Triple) { 954824e7fdSDimitry Andric assert((Triple.isSPIR() || Triple.isSPIRV()) && 964824e7fdSDimitry Andric "Invalid architecture for SPIR or SPIR-V."); 970b57cec5SDimitry Andric TLSSupported = false; 980b57cec5SDimitry Andric VLASupported = false; 990b57cec5SDimitry Andric LongWidth = LongAlign = 64; 100fe6060f1SDimitry Andric AddrSpaceMap = &SPIRDefIsPrivMap; 1010b57cec5SDimitry Andric UseAddrSpaceMapMangling = true; 1020b57cec5SDimitry Andric HasLegalHalfType = true; 1030b57cec5SDimitry Andric HasFloat16 = true; 1040b57cec5SDimitry Andric // Define available target features 1050b57cec5SDimitry Andric // These must be defined in sorted order! 1060b57cec5SDimitry Andric NoAsmVariants = true; 10706c3fb27SDimitry Andric 10806c3fb27SDimitry Andric llvm::Triple HostTriple(Opts.HostTriple); 10906c3fb27SDimitry Andric if (!HostTriple.isSPIR() && !HostTriple.isSPIRV() && 11006c3fb27SDimitry Andric HostTriple.getArch() != llvm::Triple::UnknownArch) { 11106c3fb27SDimitry Andric HostTarget = AllocateTarget(llvm::Triple(Opts.HostTriple), Opts); 11206c3fb27SDimitry Andric 11306c3fb27SDimitry Andric // Copy properties from host target. 11406c3fb27SDimitry Andric BoolWidth = HostTarget->getBoolWidth(); 11506c3fb27SDimitry Andric BoolAlign = HostTarget->getBoolAlign(); 11606c3fb27SDimitry Andric IntWidth = HostTarget->getIntWidth(); 11706c3fb27SDimitry Andric IntAlign = HostTarget->getIntAlign(); 11806c3fb27SDimitry Andric HalfWidth = HostTarget->getHalfWidth(); 11906c3fb27SDimitry Andric HalfAlign = HostTarget->getHalfAlign(); 12006c3fb27SDimitry Andric FloatWidth = HostTarget->getFloatWidth(); 12106c3fb27SDimitry Andric FloatAlign = HostTarget->getFloatAlign(); 12206c3fb27SDimitry Andric DoubleWidth = HostTarget->getDoubleWidth(); 12306c3fb27SDimitry Andric DoubleAlign = HostTarget->getDoubleAlign(); 12406c3fb27SDimitry Andric LongWidth = HostTarget->getLongWidth(); 12506c3fb27SDimitry Andric LongAlign = HostTarget->getLongAlign(); 12606c3fb27SDimitry Andric LongLongWidth = HostTarget->getLongLongWidth(); 12706c3fb27SDimitry Andric LongLongAlign = HostTarget->getLongLongAlign(); 12806c3fb27SDimitry Andric MinGlobalAlign = HostTarget->getMinGlobalAlign(/* TypeSize = */ 0); 12906c3fb27SDimitry Andric NewAlign = HostTarget->getNewAlign(); 13006c3fb27SDimitry Andric DefaultAlignForAttributeAligned = 13106c3fb27SDimitry Andric HostTarget->getDefaultAlignForAttributeAligned(); 13206c3fb27SDimitry Andric IntMaxType = HostTarget->getIntMaxType(); 13306c3fb27SDimitry Andric WCharType = HostTarget->getWCharType(); 13406c3fb27SDimitry Andric WIntType = HostTarget->getWIntType(); 13506c3fb27SDimitry Andric Char16Type = HostTarget->getChar16Type(); 13606c3fb27SDimitry Andric Char32Type = HostTarget->getChar32Type(); 13706c3fb27SDimitry Andric Int64Type = HostTarget->getInt64Type(); 13806c3fb27SDimitry Andric SigAtomicType = HostTarget->getSigAtomicType(); 13906c3fb27SDimitry Andric ProcessIDType = HostTarget->getProcessIDType(); 14006c3fb27SDimitry Andric 14106c3fb27SDimitry Andric UseBitFieldTypeAlignment = HostTarget->useBitFieldTypeAlignment(); 14206c3fb27SDimitry Andric UseZeroLengthBitfieldAlignment = 14306c3fb27SDimitry Andric HostTarget->useZeroLengthBitfieldAlignment(); 14406c3fb27SDimitry Andric UseExplicitBitFieldAlignment = HostTarget->useExplicitBitFieldAlignment(); 14506c3fb27SDimitry Andric ZeroLengthBitfieldBoundary = HostTarget->getZeroLengthBitfieldBoundary(); 14606c3fb27SDimitry Andric 14706c3fb27SDimitry Andric // This is a bit of a lie, but it controls __GCC_ATOMIC_XXX_LOCK_FREE, and 14806c3fb27SDimitry Andric // we need those macros to be identical on host and device, because (among 14906c3fb27SDimitry Andric // other things) they affect which standard library classes are defined, 15006c3fb27SDimitry Andric // and we need all classes to be defined on both the host and device. 15106c3fb27SDimitry Andric MaxAtomicInlineWidth = HostTarget->getMaxAtomicInlineWidth(); 15206c3fb27SDimitry Andric } 1530b57cec5SDimitry Andric } 1540b57cec5SDimitry Andric 155349cc55cSDimitry Andric public: 1560b57cec5SDimitry Andric // SPIR supports the half type and the only llvm intrinsic allowed in SPIR is 1570b57cec5SDimitry Andric // memcpy as per section 3 of the SPIR spec. 1580b57cec5SDimitry Andric bool useFP16ConversionIntrinsics() const override { return false; } 1590b57cec5SDimitry Andric 160bdd1243dSDimitry Andric ArrayRef<Builtin::Info> getTargetBuiltins() const override { 161bdd1243dSDimitry Andric return std::nullopt; 162bdd1243dSDimitry Andric } 1630b57cec5SDimitry Andric 16406c3fb27SDimitry Andric std::string_view getClobbers() const override { return ""; } 1650b57cec5SDimitry Andric 166bdd1243dSDimitry Andric ArrayRef<const char *> getGCCRegNames() const override { 167bdd1243dSDimitry Andric return std::nullopt; 168bdd1243dSDimitry Andric } 1690b57cec5SDimitry Andric 1700b57cec5SDimitry Andric bool validateAsmConstraint(const char *&Name, 1710b57cec5SDimitry Andric TargetInfo::ConstraintInfo &info) const override { 1720b57cec5SDimitry Andric return true; 1730b57cec5SDimitry Andric } 1740b57cec5SDimitry Andric 1750b57cec5SDimitry Andric ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override { 176bdd1243dSDimitry Andric return std::nullopt; 1770b57cec5SDimitry Andric } 1780b57cec5SDimitry Andric 1790b57cec5SDimitry Andric BuiltinVaListKind getBuiltinVaListKind() const override { 1800b57cec5SDimitry Andric return TargetInfo::VoidPtrBuiltinVaList; 1810b57cec5SDimitry Andric } 1820b57cec5SDimitry Andric 183bdd1243dSDimitry Andric std::optional<unsigned> 184fe6060f1SDimitry Andric getDWARFAddressSpace(unsigned AddressSpace) const override { 185fe6060f1SDimitry Andric return AddressSpace; 186fe6060f1SDimitry Andric } 187fe6060f1SDimitry Andric 1880b57cec5SDimitry Andric CallingConvCheckResult checkCallingConvention(CallingConv CC) const override { 1890b57cec5SDimitry Andric return (CC == CC_SpirFunction || CC == CC_OpenCLKernel) ? CCCR_OK 1900b57cec5SDimitry Andric : CCCR_Warning; 1910b57cec5SDimitry Andric } 1920b57cec5SDimitry Andric 1930b57cec5SDimitry Andric CallingConv getDefaultCallingConv() const override { 1940b57cec5SDimitry Andric return CC_SpirFunction; 1950b57cec5SDimitry Andric } 1960b57cec5SDimitry Andric 197fe6060f1SDimitry Andric void setAddressSpaceMap(bool DefaultIsGeneric) { 198fe6060f1SDimitry Andric AddrSpaceMap = DefaultIsGeneric ? &SPIRDefIsGenMap : &SPIRDefIsPrivMap; 199fe6060f1SDimitry Andric } 200fe6060f1SDimitry Andric 201fe6060f1SDimitry Andric void adjust(DiagnosticsEngine &Diags, LangOptions &Opts) override { 202fe6060f1SDimitry Andric TargetInfo::adjust(Diags, Opts); 203fe6060f1SDimitry Andric // FIXME: SYCL specification considers unannotated pointers and references 204fe6060f1SDimitry Andric // to be pointing to the generic address space. See section 5.9.3 of 205fe6060f1SDimitry Andric // SYCL 2020 specification. 20681ad6265SDimitry Andric // Currently, there is no way of representing SYCL's and HIP/CUDA's default 2074824e7fdSDimitry Andric // address space language semantic along with the semantics of embedded C's 2084824e7fdSDimitry Andric // default address space in the same address space map. Hence the map needs 2094824e7fdSDimitry Andric // to be reset to allow mapping to the desired value of 'Default' entry for 21081ad6265SDimitry Andric // SYCL and HIP/CUDA. 2114824e7fdSDimitry Andric setAddressSpaceMap( 2124824e7fdSDimitry Andric /*DefaultIsGeneric=*/Opts.SYCLIsDevice || 21381ad6265SDimitry Andric // The address mapping from HIP/CUDA language for device code is only 21481ad6265SDimitry Andric // defined for SPIR-V. 21581ad6265SDimitry Andric (getTriple().isSPIRV() && Opts.CUDAIsDevice)); 216fe6060f1SDimitry Andric } 217fe6060f1SDimitry Andric 2180b57cec5SDimitry Andric void setSupportedOpenCLOpts() override { 2190b57cec5SDimitry Andric // Assume all OpenCL extensions and optional core features are supported 220349cc55cSDimitry Andric // for SPIR and SPIR-V since they are generic targets. 221e8d8bef9SDimitry Andric supportAllOpenCLOpts(); 2220b57cec5SDimitry Andric } 2235ffd83dbSDimitry Andric 2240eae32dcSDimitry Andric bool hasBitIntType() const override { return true; } 225e8d8bef9SDimitry Andric 226e8d8bef9SDimitry Andric bool hasInt128Type() const override { return false; } 2270b57cec5SDimitry Andric }; 228fe6060f1SDimitry Andric 229349cc55cSDimitry Andric class LLVM_LIBRARY_VISIBILITY SPIRTargetInfo : public BaseSPIRTargetInfo { 230349cc55cSDimitry Andric public: 231349cc55cSDimitry Andric SPIRTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 232349cc55cSDimitry Andric : BaseSPIRTargetInfo(Triple, Opts) { 2334824e7fdSDimitry Andric assert(Triple.isSPIR() && "Invalid architecture for SPIR."); 234349cc55cSDimitry Andric assert(getTriple().getOS() == llvm::Triple::UnknownOS && 235349cc55cSDimitry Andric "SPIR target must use unknown OS"); 236349cc55cSDimitry Andric assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment && 237349cc55cSDimitry Andric "SPIR target must use unknown environment type"); 238349cc55cSDimitry Andric } 239349cc55cSDimitry Andric 240349cc55cSDimitry Andric void getTargetDefines(const LangOptions &Opts, 241349cc55cSDimitry Andric MacroBuilder &Builder) const override; 242349cc55cSDimitry Andric 243349cc55cSDimitry Andric bool hasFeature(StringRef Feature) const override { 244349cc55cSDimitry Andric return Feature == "spir"; 245349cc55cSDimitry Andric } 24606c3fb27SDimitry Andric 24706c3fb27SDimitry Andric bool checkArithmeticFenceSupported() const override { return true; } 248349cc55cSDimitry Andric }; 249349cc55cSDimitry Andric 2500b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY SPIR32TargetInfo : public SPIRTargetInfo { 2510b57cec5SDimitry Andric public: 2520b57cec5SDimitry Andric SPIR32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 2530b57cec5SDimitry Andric : SPIRTargetInfo(Triple, Opts) { 2544824e7fdSDimitry Andric assert(Triple.getArch() == llvm::Triple::spir && 2554824e7fdSDimitry Andric "Invalid architecture for 32-bit SPIR."); 2560b57cec5SDimitry Andric PointerWidth = PointerAlign = 32; 2570b57cec5SDimitry Andric SizeType = TargetInfo::UnsignedInt; 2580b57cec5SDimitry Andric PtrDiffType = IntPtrType = TargetInfo::SignedInt; 2590b57cec5SDimitry Andric resetDataLayout("e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-" 2600b57cec5SDimitry Andric "v96:128-v192:256-v256:256-v512:512-v1024:1024"); 2610b57cec5SDimitry Andric } 2620b57cec5SDimitry Andric 2630b57cec5SDimitry Andric void getTargetDefines(const LangOptions &Opts, 2640b57cec5SDimitry Andric MacroBuilder &Builder) const override; 2650b57cec5SDimitry Andric }; 2660b57cec5SDimitry Andric 2670b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY SPIR64TargetInfo : public SPIRTargetInfo { 2680b57cec5SDimitry Andric public: 2690b57cec5SDimitry Andric SPIR64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 2700b57cec5SDimitry Andric : SPIRTargetInfo(Triple, Opts) { 2714824e7fdSDimitry Andric assert(Triple.getArch() == llvm::Triple::spir64 && 2724824e7fdSDimitry Andric "Invalid architecture for 64-bit SPIR."); 2730b57cec5SDimitry Andric PointerWidth = PointerAlign = 64; 2740b57cec5SDimitry Andric SizeType = TargetInfo::UnsignedLong; 2750b57cec5SDimitry Andric PtrDiffType = IntPtrType = TargetInfo::SignedLong; 2760b57cec5SDimitry Andric resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-" 2770b57cec5SDimitry Andric "v96:128-v192:256-v256:256-v512:512-v1024:1024"); 2780b57cec5SDimitry Andric } 2790b57cec5SDimitry Andric 2800b57cec5SDimitry Andric void getTargetDefines(const LangOptions &Opts, 2810b57cec5SDimitry Andric MacroBuilder &Builder) const override; 2820b57cec5SDimitry Andric }; 283349cc55cSDimitry Andric 2845f757f3fSDimitry Andric class LLVM_LIBRARY_VISIBILITY BaseSPIRVTargetInfo : public BaseSPIRTargetInfo { 285349cc55cSDimitry Andric public: 2865f757f3fSDimitry Andric BaseSPIRVTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 287349cc55cSDimitry Andric : BaseSPIRTargetInfo(Triple, Opts) { 2884824e7fdSDimitry Andric assert(Triple.isSPIRV() && "Invalid architecture for SPIR-V."); 289349cc55cSDimitry Andric } 290349cc55cSDimitry Andric 291349cc55cSDimitry Andric bool hasFeature(StringRef Feature) const override { 292349cc55cSDimitry Andric return Feature == "spirv"; 293349cc55cSDimitry Andric } 2945f757f3fSDimitry Andric 2955f757f3fSDimitry Andric void getTargetDefines(const LangOptions &Opts, 2965f757f3fSDimitry Andric MacroBuilder &Builder) const override; 297349cc55cSDimitry Andric }; 298349cc55cSDimitry Andric 2995f757f3fSDimitry Andric class LLVM_LIBRARY_VISIBILITY SPIRVTargetInfo : public BaseSPIRVTargetInfo { 3005f757f3fSDimitry Andric public: 3015f757f3fSDimitry Andric SPIRVTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 3025f757f3fSDimitry Andric : BaseSPIRVTargetInfo(Triple, Opts) { 3035f757f3fSDimitry Andric assert(Triple.getArch() == llvm::Triple::spirv && 3045f757f3fSDimitry Andric "Invalid architecture for Logical SPIR-V."); 305*7a6dacacSDimitry Andric assert(Triple.getOS() == llvm::Triple::Vulkan && 306*7a6dacacSDimitry Andric Triple.getVulkanVersion() != llvm::VersionTuple(0) && 307*7a6dacacSDimitry Andric "Logical SPIR-V requires a valid Vulkan environment."); 3085f757f3fSDimitry Andric assert(Triple.getEnvironment() >= llvm::Triple::Pixel && 3095f757f3fSDimitry Andric Triple.getEnvironment() <= llvm::Triple::Amplification && 3105f757f3fSDimitry Andric "Logical SPIR-V environment must be a valid shader stage."); 3115f757f3fSDimitry Andric 3125f757f3fSDimitry Andric // SPIR-V IDs are represented with a single 32-bit word. 3135f757f3fSDimitry Andric SizeType = TargetInfo::UnsignedInt; 3145f757f3fSDimitry Andric resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-" 3155f757f3fSDimitry Andric "v96:128-v192:256-v256:256-v512:512-v1024:1024"); 3165f757f3fSDimitry Andric } 3175f757f3fSDimitry Andric 3185f757f3fSDimitry Andric void getTargetDefines(const LangOptions &Opts, 3195f757f3fSDimitry Andric MacroBuilder &Builder) const override; 3205f757f3fSDimitry Andric }; 3215f757f3fSDimitry Andric 3225f757f3fSDimitry Andric class LLVM_LIBRARY_VISIBILITY SPIRV32TargetInfo : public BaseSPIRVTargetInfo { 323349cc55cSDimitry Andric public: 324349cc55cSDimitry Andric SPIRV32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 3255f757f3fSDimitry Andric : BaseSPIRVTargetInfo(Triple, Opts) { 3264824e7fdSDimitry Andric assert(Triple.getArch() == llvm::Triple::spirv32 && 3274824e7fdSDimitry Andric "Invalid architecture for 32-bit SPIR-V."); 3285f757f3fSDimitry Andric assert(getTriple().getOS() == llvm::Triple::UnknownOS && 3295f757f3fSDimitry Andric "32-bit SPIR-V target must use unknown OS"); 3305f757f3fSDimitry Andric assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment && 3315f757f3fSDimitry Andric "32-bit SPIR-V target must use unknown environment type"); 332349cc55cSDimitry Andric PointerWidth = PointerAlign = 32; 333349cc55cSDimitry Andric SizeType = TargetInfo::UnsignedInt; 334349cc55cSDimitry Andric PtrDiffType = IntPtrType = TargetInfo::SignedInt; 335349cc55cSDimitry Andric resetDataLayout("e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-" 336349cc55cSDimitry Andric "v96:128-v192:256-v256:256-v512:512-v1024:1024"); 337349cc55cSDimitry Andric } 338349cc55cSDimitry Andric 339349cc55cSDimitry Andric void getTargetDefines(const LangOptions &Opts, 340349cc55cSDimitry Andric MacroBuilder &Builder) const override; 341349cc55cSDimitry Andric }; 342349cc55cSDimitry Andric 3435f757f3fSDimitry Andric class LLVM_LIBRARY_VISIBILITY SPIRV64TargetInfo : public BaseSPIRVTargetInfo { 344349cc55cSDimitry Andric public: 345349cc55cSDimitry Andric SPIRV64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 3465f757f3fSDimitry Andric : BaseSPIRVTargetInfo(Triple, Opts) { 3474824e7fdSDimitry Andric assert(Triple.getArch() == llvm::Triple::spirv64 && 3484824e7fdSDimitry Andric "Invalid architecture for 64-bit SPIR-V."); 3495f757f3fSDimitry Andric assert(getTriple().getOS() == llvm::Triple::UnknownOS && 3505f757f3fSDimitry Andric "64-bit SPIR-V target must use unknown OS"); 3515f757f3fSDimitry Andric assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment && 3525f757f3fSDimitry Andric "64-bit SPIR-V target must use unknown environment type"); 353349cc55cSDimitry Andric PointerWidth = PointerAlign = 64; 354349cc55cSDimitry Andric SizeType = TargetInfo::UnsignedLong; 355349cc55cSDimitry Andric PtrDiffType = IntPtrType = TargetInfo::SignedLong; 356349cc55cSDimitry Andric resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-" 357349cc55cSDimitry Andric "v96:128-v192:256-v256:256-v512:512-v1024:1024"); 358349cc55cSDimitry Andric } 359349cc55cSDimitry Andric 360349cc55cSDimitry Andric void getTargetDefines(const LangOptions &Opts, 361349cc55cSDimitry Andric MacroBuilder &Builder) const override; 362349cc55cSDimitry Andric }; 363349cc55cSDimitry Andric 3640b57cec5SDimitry Andric } // namespace targets 3650b57cec5SDimitry Andric } // namespace clang 3660b57cec5SDimitry Andric #endif // LLVM_CLANG_LIB_BASIC_TARGETS_SPIR_H 367