diff options
Diffstat (limited to 'clang/lib/Basic/Targets/SPIR.h')
-rw-r--r-- | clang/lib/Basic/Targets/SPIR.h | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h index a2e812624d37..50f34abd6630 100644 --- a/clang/lib/Basic/Targets/SPIR.h +++ b/clang/lib/Basic/Targets/SPIR.h @@ -21,7 +21,7 @@ namespace clang { namespace targets { -static const unsigned SPIRAddrSpaceMap[] = { +static const unsigned SPIRDefIsPrivMap[] = { 0, // Default 1, // opencl_global 3, // opencl_local @@ -33,6 +33,35 @@ static const unsigned SPIRAddrSpaceMap[] = { 0, // cuda_device 0, // cuda_constant 0, // cuda_shared + // SYCL address space values for this map are dummy + 0, // sycl_global + 0, // sycl_global_device + 0, // sycl_global_host + 0, // sycl_local + 0, // sycl_private + 0, // ptr32_sptr + 0, // ptr32_uptr + 0 // ptr64 +}; + +static const unsigned SPIRDefIsGenMap[] = { + 4, // Default + // OpenCL address space values for this map are dummy and they can't be used + 0, // opencl_global + 0, // opencl_local + 0, // opencl_constant + 0, // opencl_private + 0, // opencl_generic + 0, // opencl_global_device + 0, // opencl_global_host + 0, // cuda_device + 0, // cuda_constant + 0, // cuda_shared + 1, // sycl_global + 5, // sycl_global_device + 6, // sycl_global_host + 3, // sycl_local + 0, // sycl_private 0, // ptr32_sptr 0, // ptr32_uptr 0 // ptr64 @@ -49,7 +78,7 @@ public: TLSSupported = false; VLASupported = false; LongWidth = LongAlign = 64; - AddrSpaceMap = &SPIRAddrSpaceMap; + AddrSpaceMap = &SPIRDefIsPrivMap; UseAddrSpaceMapMangling = true; HasLegalHalfType = true; HasFloat16 = true; @@ -88,6 +117,11 @@ public: return TargetInfo::VoidPtrBuiltinVaList; } + Optional<unsigned> + getDWARFAddressSpace(unsigned AddressSpace) const override { + return AddressSpace; + } + CallingConvCheckResult checkCallingConvention(CallingConv CC) const override { return (CC == CC_SpirFunction || CC == CC_OpenCLKernel) ? CCCR_OK : CCCR_Warning; @@ -97,6 +131,22 @@ public: return CC_SpirFunction; } + void setAddressSpaceMap(bool DefaultIsGeneric) { + AddrSpaceMap = DefaultIsGeneric ? &SPIRDefIsGenMap : &SPIRDefIsPrivMap; + } + + void adjust(DiagnosticsEngine &Diags, LangOptions &Opts) override { + TargetInfo::adjust(Diags, Opts); + // FIXME: SYCL specification considers unannotated pointers and references + // to be pointing to the generic address space. See section 5.9.3 of + // SYCL 2020 specification. + // Currently, there is no way of representing SYCL's default address space + // language semantic along with the semantics of embedded C's default + // address space in the same address space map. Hence the map needs to be + // reset to allow mapping to the desired value of 'Default' entry for SYCL. + setAddressSpaceMap(/*DefaultIsGeneric=*/Opts.SYCLIsDevice); + } + void setSupportedOpenCLOpts() override { // Assume all OpenCL extensions and optional core features are supported // for SPIR since it is a generic target. @@ -107,6 +157,7 @@ public: bool hasInt128Type() const override { return false; } }; + class LLVM_LIBRARY_VISIBILITY SPIR32TargetInfo : public SPIRTargetInfo { public: SPIR32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) |