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" 2006c3fb27SDimitry Andric #include "llvm/TargetParser/Triple.h" 21bdd1243dSDimitry Andric #include <optional> 220b57cec5SDimitry Andric 230b57cec5SDimitry Andric namespace clang { 240b57cec5SDimitry Andric namespace targets { 250b57cec5SDimitry Andric 26349cc55cSDimitry Andric // Used by both the SPIR and SPIR-V targets. 27fe6060f1SDimitry Andric static const unsigned SPIRDefIsPrivMap[] = { 280b57cec5SDimitry Andric 0, // Default 290b57cec5SDimitry Andric 1, // opencl_global 300b57cec5SDimitry Andric 3, // opencl_local 310b57cec5SDimitry Andric 2, // opencl_constant 320b57cec5SDimitry Andric 0, // opencl_private 330b57cec5SDimitry Andric 4, // opencl_generic 34e8d8bef9SDimitry Andric 5, // opencl_global_device 35e8d8bef9SDimitry Andric 6, // opencl_global_host 360b57cec5SDimitry Andric 0, // cuda_device 370b57cec5SDimitry Andric 0, // cuda_constant 38480093f4SDimitry Andric 0, // cuda_shared 39fe6060f1SDimitry Andric // SYCL address space values for this map are dummy 40fe6060f1SDimitry Andric 0, // sycl_global 41fe6060f1SDimitry Andric 0, // sycl_global_device 42fe6060f1SDimitry Andric 0, // sycl_global_host 43fe6060f1SDimitry Andric 0, // sycl_local 44fe6060f1SDimitry Andric 0, // sycl_private 45fe6060f1SDimitry Andric 0, // ptr32_sptr 46fe6060f1SDimitry Andric 0, // ptr32_uptr 47bdd1243dSDimitry Andric 0, // ptr64 48bdd1243dSDimitry Andric 0, // hlsl_groupshared 4906c3fb27SDimitry Andric // Wasm address space values for this target are dummy values, 5006c3fb27SDimitry Andric // as it is only enabled for Wasm targets. 5106c3fb27SDimitry Andric 20, // wasm_funcref 52fe6060f1SDimitry Andric }; 53fe6060f1SDimitry Andric 54349cc55cSDimitry Andric // Used by both the SPIR and SPIR-V targets. 55fe6060f1SDimitry Andric static const unsigned SPIRDefIsGenMap[] = { 56fe6060f1SDimitry Andric 4, // Default 57fe6060f1SDimitry Andric // OpenCL address space values for this map are dummy and they can't be used 58fe6060f1SDimitry Andric 0, // opencl_global 59fe6060f1SDimitry Andric 0, // opencl_local 60fe6060f1SDimitry Andric 0, // opencl_constant 61fe6060f1SDimitry Andric 0, // opencl_private 62fe6060f1SDimitry Andric 0, // opencl_generic 63fe6060f1SDimitry Andric 0, // opencl_global_device 64fe6060f1SDimitry Andric 0, // opencl_global_host 654824e7fdSDimitry Andric // cuda_* address space mapping is intended for HIPSPV (HIP to SPIR-V 664824e7fdSDimitry Andric // translation). This mapping is enabled when the language mode is HIP. 674824e7fdSDimitry Andric 1, // cuda_device 684824e7fdSDimitry Andric // cuda_constant pointer can be casted to default/"flat" pointer, but in 694824e7fdSDimitry Andric // SPIR-V casts between constant and generic pointers are not allowed. For 704824e7fdSDimitry Andric // this reason cuda_constant is mapped to SPIR-V CrossWorkgroup. 714824e7fdSDimitry Andric 1, // cuda_constant 724824e7fdSDimitry Andric 3, // cuda_shared 73fe6060f1SDimitry Andric 1, // sycl_global 74fe6060f1SDimitry Andric 5, // sycl_global_device 75fe6060f1SDimitry Andric 6, // sycl_global_host 76fe6060f1SDimitry Andric 3, // sycl_local 77fe6060f1SDimitry Andric 0, // sycl_private 78480093f4SDimitry Andric 0, // ptr32_sptr 79480093f4SDimitry Andric 0, // ptr32_uptr 80bdd1243dSDimitry Andric 0, // ptr64 81bdd1243dSDimitry Andric 0, // hlsl_groupshared 8206c3fb27SDimitry Andric // Wasm address space values for this target are dummy values, 8306c3fb27SDimitry Andric // as it is only enabled for Wasm targets. 8406c3fb27SDimitry Andric 20, // wasm_funcref 850b57cec5SDimitry Andric }; 860b57cec5SDimitry Andric 87349cc55cSDimitry Andric // Base class for SPIR and SPIR-V target info. 88349cc55cSDimitry Andric class LLVM_LIBRARY_VISIBILITY BaseSPIRTargetInfo : public TargetInfo { 8906c3fb27SDimitry Andric std::unique_ptr<TargetInfo> HostTarget; 9006c3fb27SDimitry Andric 91349cc55cSDimitry Andric protected: 9206c3fb27SDimitry Andric BaseSPIRTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 930b57cec5SDimitry Andric : TargetInfo(Triple) { 944824e7fdSDimitry Andric assert((Triple.isSPIR() || Triple.isSPIRV()) && 954824e7fdSDimitry Andric "Invalid architecture for SPIR or SPIR-V."); 960b57cec5SDimitry Andric TLSSupported = false; 970b57cec5SDimitry Andric VLASupported = false; 980b57cec5SDimitry Andric LongWidth = LongAlign = 64; 99fe6060f1SDimitry Andric AddrSpaceMap = &SPIRDefIsPrivMap; 1000b57cec5SDimitry Andric UseAddrSpaceMapMangling = true; 1010b57cec5SDimitry Andric HasLegalHalfType = true; 1020b57cec5SDimitry Andric HasFloat16 = true; 1030b57cec5SDimitry Andric // Define available target features 1040b57cec5SDimitry Andric // These must be defined in sorted order! 1050b57cec5SDimitry Andric NoAsmVariants = true; 10606c3fb27SDimitry Andric 10706c3fb27SDimitry Andric llvm::Triple HostTriple(Opts.HostTriple); 10806c3fb27SDimitry Andric if (!HostTriple.isSPIR() && !HostTriple.isSPIRV() && 10906c3fb27SDimitry Andric HostTriple.getArch() != llvm::Triple::UnknownArch) { 11006c3fb27SDimitry Andric HostTarget = AllocateTarget(llvm::Triple(Opts.HostTriple), Opts); 11106c3fb27SDimitry Andric 11206c3fb27SDimitry Andric // Copy properties from host target. 11306c3fb27SDimitry Andric BoolWidth = HostTarget->getBoolWidth(); 11406c3fb27SDimitry Andric BoolAlign = HostTarget->getBoolAlign(); 11506c3fb27SDimitry Andric IntWidth = HostTarget->getIntWidth(); 11606c3fb27SDimitry Andric IntAlign = HostTarget->getIntAlign(); 11706c3fb27SDimitry Andric HalfWidth = HostTarget->getHalfWidth(); 11806c3fb27SDimitry Andric HalfAlign = HostTarget->getHalfAlign(); 11906c3fb27SDimitry Andric FloatWidth = HostTarget->getFloatWidth(); 12006c3fb27SDimitry Andric FloatAlign = HostTarget->getFloatAlign(); 12106c3fb27SDimitry Andric DoubleWidth = HostTarget->getDoubleWidth(); 12206c3fb27SDimitry Andric DoubleAlign = HostTarget->getDoubleAlign(); 12306c3fb27SDimitry Andric LongWidth = HostTarget->getLongWidth(); 12406c3fb27SDimitry Andric LongAlign = HostTarget->getLongAlign(); 12506c3fb27SDimitry Andric LongLongWidth = HostTarget->getLongLongWidth(); 12606c3fb27SDimitry Andric LongLongAlign = HostTarget->getLongLongAlign(); 12706c3fb27SDimitry Andric MinGlobalAlign = HostTarget->getMinGlobalAlign(/* TypeSize = */ 0); 12806c3fb27SDimitry Andric NewAlign = HostTarget->getNewAlign(); 12906c3fb27SDimitry Andric DefaultAlignForAttributeAligned = 13006c3fb27SDimitry Andric HostTarget->getDefaultAlignForAttributeAligned(); 13106c3fb27SDimitry Andric IntMaxType = HostTarget->getIntMaxType(); 13206c3fb27SDimitry Andric WCharType = HostTarget->getWCharType(); 13306c3fb27SDimitry Andric WIntType = HostTarget->getWIntType(); 13406c3fb27SDimitry Andric Char16Type = HostTarget->getChar16Type(); 13506c3fb27SDimitry Andric Char32Type = HostTarget->getChar32Type(); 13606c3fb27SDimitry Andric Int64Type = HostTarget->getInt64Type(); 13706c3fb27SDimitry Andric SigAtomicType = HostTarget->getSigAtomicType(); 13806c3fb27SDimitry Andric ProcessIDType = HostTarget->getProcessIDType(); 13906c3fb27SDimitry Andric 14006c3fb27SDimitry Andric UseBitFieldTypeAlignment = HostTarget->useBitFieldTypeAlignment(); 14106c3fb27SDimitry Andric UseZeroLengthBitfieldAlignment = 14206c3fb27SDimitry Andric HostTarget->useZeroLengthBitfieldAlignment(); 14306c3fb27SDimitry Andric UseExplicitBitFieldAlignment = HostTarget->useExplicitBitFieldAlignment(); 14406c3fb27SDimitry Andric ZeroLengthBitfieldBoundary = HostTarget->getZeroLengthBitfieldBoundary(); 14506c3fb27SDimitry Andric 14606c3fb27SDimitry Andric // This is a bit of a lie, but it controls __GCC_ATOMIC_XXX_LOCK_FREE, and 14706c3fb27SDimitry Andric // we need those macros to be identical on host and device, because (among 14806c3fb27SDimitry Andric // other things) they affect which standard library classes are defined, 14906c3fb27SDimitry Andric // and we need all classes to be defined on both the host and device. 15006c3fb27SDimitry Andric MaxAtomicInlineWidth = HostTarget->getMaxAtomicInlineWidth(); 15106c3fb27SDimitry Andric } 1520b57cec5SDimitry Andric } 1530b57cec5SDimitry Andric 154349cc55cSDimitry Andric public: 1550b57cec5SDimitry Andric // SPIR supports the half type and the only llvm intrinsic allowed in SPIR is 1560b57cec5SDimitry Andric // memcpy as per section 3 of the SPIR spec. 1570b57cec5SDimitry Andric bool useFP16ConversionIntrinsics() const override { return false; } 1580b57cec5SDimitry Andric 159bdd1243dSDimitry Andric ArrayRef<Builtin::Info> getTargetBuiltins() const override { 160bdd1243dSDimitry Andric return std::nullopt; 161bdd1243dSDimitry Andric } 1620b57cec5SDimitry Andric 16306c3fb27SDimitry Andric std::string_view getClobbers() const override { return ""; } 1640b57cec5SDimitry Andric 165bdd1243dSDimitry Andric ArrayRef<const char *> getGCCRegNames() const override { 166bdd1243dSDimitry Andric return std::nullopt; 167bdd1243dSDimitry Andric } 1680b57cec5SDimitry Andric 1690b57cec5SDimitry Andric bool validateAsmConstraint(const char *&Name, 1700b57cec5SDimitry Andric TargetInfo::ConstraintInfo &info) const override { 1710b57cec5SDimitry Andric return true; 1720b57cec5SDimitry Andric } 1730b57cec5SDimitry Andric 1740b57cec5SDimitry Andric ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override { 175bdd1243dSDimitry Andric return std::nullopt; 1760b57cec5SDimitry Andric } 1770b57cec5SDimitry Andric 1780b57cec5SDimitry Andric BuiltinVaListKind getBuiltinVaListKind() const override { 1790b57cec5SDimitry Andric return TargetInfo::VoidPtrBuiltinVaList; 1800b57cec5SDimitry Andric } 1810b57cec5SDimitry Andric 182bdd1243dSDimitry Andric std::optional<unsigned> 183fe6060f1SDimitry Andric getDWARFAddressSpace(unsigned AddressSpace) const override { 184fe6060f1SDimitry Andric return AddressSpace; 185fe6060f1SDimitry Andric } 186fe6060f1SDimitry Andric 1870b57cec5SDimitry Andric CallingConvCheckResult checkCallingConvention(CallingConv CC) const override { 1880b57cec5SDimitry Andric return (CC == CC_SpirFunction || CC == CC_OpenCLKernel) ? CCCR_OK 1890b57cec5SDimitry Andric : CCCR_Warning; 1900b57cec5SDimitry Andric } 1910b57cec5SDimitry Andric 1920b57cec5SDimitry Andric CallingConv getDefaultCallingConv() const override { 1930b57cec5SDimitry Andric return CC_SpirFunction; 1940b57cec5SDimitry Andric } 1950b57cec5SDimitry Andric 196fe6060f1SDimitry Andric void setAddressSpaceMap(bool DefaultIsGeneric) { 197fe6060f1SDimitry Andric AddrSpaceMap = DefaultIsGeneric ? &SPIRDefIsGenMap : &SPIRDefIsPrivMap; 198fe6060f1SDimitry Andric } 199fe6060f1SDimitry Andric 200fe6060f1SDimitry Andric void adjust(DiagnosticsEngine &Diags, LangOptions &Opts) override { 201fe6060f1SDimitry Andric TargetInfo::adjust(Diags, Opts); 202fe6060f1SDimitry Andric // FIXME: SYCL specification considers unannotated pointers and references 203fe6060f1SDimitry Andric // to be pointing to the generic address space. See section 5.9.3 of 204fe6060f1SDimitry Andric // SYCL 2020 specification. 20581ad6265SDimitry Andric // Currently, there is no way of representing SYCL's and HIP/CUDA's default 2064824e7fdSDimitry Andric // address space language semantic along with the semantics of embedded C's 2074824e7fdSDimitry Andric // default address space in the same address space map. Hence the map needs 2084824e7fdSDimitry Andric // to be reset to allow mapping to the desired value of 'Default' entry for 20981ad6265SDimitry Andric // SYCL and HIP/CUDA. 2104824e7fdSDimitry Andric setAddressSpaceMap( 2114824e7fdSDimitry Andric /*DefaultIsGeneric=*/Opts.SYCLIsDevice || 21281ad6265SDimitry Andric // The address mapping from HIP/CUDA language for device code is only 21381ad6265SDimitry Andric // defined for SPIR-V. 21481ad6265SDimitry Andric (getTriple().isSPIRV() && Opts.CUDAIsDevice)); 215fe6060f1SDimitry Andric } 216fe6060f1SDimitry Andric 2170b57cec5SDimitry Andric void setSupportedOpenCLOpts() override { 2180b57cec5SDimitry Andric // Assume all OpenCL extensions and optional core features are supported 219349cc55cSDimitry Andric // for SPIR and SPIR-V since they are generic targets. 220e8d8bef9SDimitry Andric supportAllOpenCLOpts(); 2210b57cec5SDimitry Andric } 2225ffd83dbSDimitry Andric 2230eae32dcSDimitry Andric bool hasBitIntType() const override { return true; } 224e8d8bef9SDimitry Andric 225e8d8bef9SDimitry Andric bool hasInt128Type() const override { return false; } 2260b57cec5SDimitry Andric }; 227fe6060f1SDimitry Andric 228349cc55cSDimitry Andric class LLVM_LIBRARY_VISIBILITY SPIRTargetInfo : public BaseSPIRTargetInfo { 229349cc55cSDimitry Andric public: 230349cc55cSDimitry Andric SPIRTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 231349cc55cSDimitry Andric : BaseSPIRTargetInfo(Triple, Opts) { 2324824e7fdSDimitry Andric assert(Triple.isSPIR() && "Invalid architecture for SPIR."); 233349cc55cSDimitry Andric assert(getTriple().getOS() == llvm::Triple::UnknownOS && 234349cc55cSDimitry Andric "SPIR target must use unknown OS"); 235349cc55cSDimitry Andric assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment && 236349cc55cSDimitry Andric "SPIR target must use unknown environment type"); 237349cc55cSDimitry Andric } 238349cc55cSDimitry Andric 239349cc55cSDimitry Andric void getTargetDefines(const LangOptions &Opts, 240349cc55cSDimitry Andric MacroBuilder &Builder) const override; 241349cc55cSDimitry Andric 242349cc55cSDimitry Andric bool hasFeature(StringRef Feature) const override { 243349cc55cSDimitry Andric return Feature == "spir"; 244349cc55cSDimitry Andric } 24506c3fb27SDimitry Andric 24606c3fb27SDimitry Andric bool checkArithmeticFenceSupported() const override { return true; } 247349cc55cSDimitry Andric }; 248349cc55cSDimitry Andric 2490b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY SPIR32TargetInfo : public SPIRTargetInfo { 2500b57cec5SDimitry Andric public: 2510b57cec5SDimitry Andric SPIR32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 2520b57cec5SDimitry Andric : SPIRTargetInfo(Triple, Opts) { 2534824e7fdSDimitry Andric assert(Triple.getArch() == llvm::Triple::spir && 2544824e7fdSDimitry Andric "Invalid architecture for 32-bit SPIR."); 2550b57cec5SDimitry Andric PointerWidth = PointerAlign = 32; 2560b57cec5SDimitry Andric SizeType = TargetInfo::UnsignedInt; 2570b57cec5SDimitry Andric PtrDiffType = IntPtrType = TargetInfo::SignedInt; 2580b57cec5SDimitry Andric resetDataLayout("e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-" 2590b57cec5SDimitry Andric "v96:128-v192:256-v256:256-v512:512-v1024:1024"); 2600b57cec5SDimitry Andric } 2610b57cec5SDimitry Andric 2620b57cec5SDimitry Andric void getTargetDefines(const LangOptions &Opts, 2630b57cec5SDimitry Andric MacroBuilder &Builder) const override; 2640b57cec5SDimitry Andric }; 2650b57cec5SDimitry Andric 2660b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY SPIR64TargetInfo : public SPIRTargetInfo { 2670b57cec5SDimitry Andric public: 2680b57cec5SDimitry Andric SPIR64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 2690b57cec5SDimitry Andric : SPIRTargetInfo(Triple, Opts) { 2704824e7fdSDimitry Andric assert(Triple.getArch() == llvm::Triple::spir64 && 2714824e7fdSDimitry Andric "Invalid architecture for 64-bit SPIR."); 2720b57cec5SDimitry Andric PointerWidth = PointerAlign = 64; 2730b57cec5SDimitry Andric SizeType = TargetInfo::UnsignedLong; 2740b57cec5SDimitry Andric PtrDiffType = IntPtrType = TargetInfo::SignedLong; 2750b57cec5SDimitry Andric resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-" 2760b57cec5SDimitry Andric "v96:128-v192:256-v256:256-v512:512-v1024:1024"); 2770b57cec5SDimitry Andric } 2780b57cec5SDimitry Andric 2790b57cec5SDimitry Andric void getTargetDefines(const LangOptions &Opts, 2800b57cec5SDimitry Andric MacroBuilder &Builder) const override; 2810b57cec5SDimitry Andric }; 282349cc55cSDimitry Andric 283*5f757f3fSDimitry Andric class LLVM_LIBRARY_VISIBILITY BaseSPIRVTargetInfo : public BaseSPIRTargetInfo { 284349cc55cSDimitry Andric public: 285*5f757f3fSDimitry Andric BaseSPIRVTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 286349cc55cSDimitry Andric : BaseSPIRTargetInfo(Triple, Opts) { 2874824e7fdSDimitry Andric assert(Triple.isSPIRV() && "Invalid architecture for SPIR-V."); 288349cc55cSDimitry Andric } 289349cc55cSDimitry Andric 290349cc55cSDimitry Andric bool hasFeature(StringRef Feature) const override { 291349cc55cSDimitry Andric return Feature == "spirv"; 292349cc55cSDimitry Andric } 293*5f757f3fSDimitry Andric 294*5f757f3fSDimitry Andric void getTargetDefines(const LangOptions &Opts, 295*5f757f3fSDimitry Andric MacroBuilder &Builder) const override; 296349cc55cSDimitry Andric }; 297349cc55cSDimitry Andric 298*5f757f3fSDimitry Andric class LLVM_LIBRARY_VISIBILITY SPIRVTargetInfo : public BaseSPIRVTargetInfo { 299*5f757f3fSDimitry Andric public: 300*5f757f3fSDimitry Andric SPIRVTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 301*5f757f3fSDimitry Andric : BaseSPIRVTargetInfo(Triple, Opts) { 302*5f757f3fSDimitry Andric assert(Triple.getArch() == llvm::Triple::spirv && 303*5f757f3fSDimitry Andric "Invalid architecture for Logical SPIR-V."); 304*5f757f3fSDimitry Andric assert(Triple.getOS() == llvm::Triple::ShaderModel && 305*5f757f3fSDimitry Andric "Logical SPIR-V requires a valid ShaderModel."); 306*5f757f3fSDimitry Andric assert(Triple.getEnvironment() >= llvm::Triple::Pixel && 307*5f757f3fSDimitry Andric Triple.getEnvironment() <= llvm::Triple::Amplification && 308*5f757f3fSDimitry Andric "Logical SPIR-V environment must be a valid shader stage."); 309*5f757f3fSDimitry Andric 310*5f757f3fSDimitry Andric // SPIR-V IDs are represented with a single 32-bit word. 311*5f757f3fSDimitry Andric SizeType = TargetInfo::UnsignedInt; 312*5f757f3fSDimitry Andric resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-" 313*5f757f3fSDimitry Andric "v96:128-v192:256-v256:256-v512:512-v1024:1024"); 314*5f757f3fSDimitry Andric } 315*5f757f3fSDimitry Andric 316*5f757f3fSDimitry Andric void getTargetDefines(const LangOptions &Opts, 317*5f757f3fSDimitry Andric MacroBuilder &Builder) const override; 318*5f757f3fSDimitry Andric }; 319*5f757f3fSDimitry Andric 320*5f757f3fSDimitry Andric class LLVM_LIBRARY_VISIBILITY SPIRV32TargetInfo : public BaseSPIRVTargetInfo { 321349cc55cSDimitry Andric public: 322349cc55cSDimitry Andric SPIRV32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 323*5f757f3fSDimitry Andric : BaseSPIRVTargetInfo(Triple, Opts) { 3244824e7fdSDimitry Andric assert(Triple.getArch() == llvm::Triple::spirv32 && 3254824e7fdSDimitry Andric "Invalid architecture for 32-bit SPIR-V."); 326*5f757f3fSDimitry Andric assert(getTriple().getOS() == llvm::Triple::UnknownOS && 327*5f757f3fSDimitry Andric "32-bit SPIR-V target must use unknown OS"); 328*5f757f3fSDimitry Andric assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment && 329*5f757f3fSDimitry Andric "32-bit SPIR-V target must use unknown environment type"); 330349cc55cSDimitry Andric PointerWidth = PointerAlign = 32; 331349cc55cSDimitry Andric SizeType = TargetInfo::UnsignedInt; 332349cc55cSDimitry Andric PtrDiffType = IntPtrType = TargetInfo::SignedInt; 333349cc55cSDimitry Andric resetDataLayout("e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-" 334349cc55cSDimitry Andric "v96:128-v192:256-v256:256-v512:512-v1024:1024"); 335349cc55cSDimitry Andric } 336349cc55cSDimitry Andric 337349cc55cSDimitry Andric void getTargetDefines(const LangOptions &Opts, 338349cc55cSDimitry Andric MacroBuilder &Builder) const override; 339349cc55cSDimitry Andric }; 340349cc55cSDimitry Andric 341*5f757f3fSDimitry Andric class LLVM_LIBRARY_VISIBILITY SPIRV64TargetInfo : public BaseSPIRVTargetInfo { 342349cc55cSDimitry Andric public: 343349cc55cSDimitry Andric SPIRV64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 344*5f757f3fSDimitry Andric : BaseSPIRVTargetInfo(Triple, Opts) { 3454824e7fdSDimitry Andric assert(Triple.getArch() == llvm::Triple::spirv64 && 3464824e7fdSDimitry Andric "Invalid architecture for 64-bit SPIR-V."); 347*5f757f3fSDimitry Andric assert(getTriple().getOS() == llvm::Triple::UnknownOS && 348*5f757f3fSDimitry Andric "64-bit SPIR-V target must use unknown OS"); 349*5f757f3fSDimitry Andric assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment && 350*5f757f3fSDimitry Andric "64-bit SPIR-V target must use unknown environment type"); 351349cc55cSDimitry Andric PointerWidth = PointerAlign = 64; 352349cc55cSDimitry Andric SizeType = TargetInfo::UnsignedLong; 353349cc55cSDimitry Andric PtrDiffType = IntPtrType = TargetInfo::SignedLong; 354349cc55cSDimitry Andric resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-" 355349cc55cSDimitry Andric "v96:128-v192:256-v256:256-v512:512-v1024:1024"); 356349cc55cSDimitry Andric } 357349cc55cSDimitry Andric 358349cc55cSDimitry Andric void getTargetDefines(const LangOptions &Opts, 359349cc55cSDimitry Andric MacroBuilder &Builder) const override; 360349cc55cSDimitry Andric }; 361349cc55cSDimitry Andric 3620b57cec5SDimitry Andric } // namespace targets 3630b57cec5SDimitry Andric } // namespace clang 3640b57cec5SDimitry Andric #endif // LLVM_CLANG_LIB_BASIC_TARGETS_SPIR_H 365