diff options
| author | Yaxun Liu <Yaxun.Liu@amd.com> | 2018-03-05 17:50:10 +0000 |
|---|---|---|
| committer | Yaxun Liu <Yaxun.Liu@amd.com> | 2018-03-05 17:50:10 +0000 |
| commit | 1578a0a55d8138e886d739fd195cf4a65f47d091 (patch) | |
| tree | c549407ea349bbde4f1218c8d95ce565c8139172 /clang/lib/Basic | |
| parent | f29e35afffad6e80365832cf0e698e243db454a1 (diff) | |
| download | bcm5719-llvm-1578a0a55d8138e886d739fd195cf4a65f47d091.tar.gz bcm5719-llvm-1578a0a55d8138e886d739fd195cf4a65f47d091.zip | |
[AMDGPU] Clean up old address space mapping and fix constant address space value
Differential Revision: https://reviews.llvm.org/D43911
llvm-svn: 326725
Diffstat (limited to 'clang/lib/Basic')
| -rw-r--r-- | clang/lib/Basic/Targets/AMDGPU.cpp | 100 | ||||
| -rw-r--r-- | clang/lib/Basic/Targets/AMDGPU.h | 40 |
2 files changed, 47 insertions, 93 deletions
diff --git a/clang/lib/Basic/Targets/AMDGPU.cpp b/clang/lib/Basic/Targets/AMDGPU.cpp index a4c0b42f767..a926722a10e 100644 --- a/clang/lib/Basic/Targets/AMDGPU.cpp +++ b/clang/lib/Basic/Targets/AMDGPU.cpp @@ -32,62 +32,33 @@ static const char *const DataLayoutStringR600 = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128" "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"; -static const char *const DataLayoutStringSIPrivateIsZero = - "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-p6:32:32" - "-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128" - "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"; - -static const char *const DataLayoutStringSIGenericIsZero = +static const char *const DataLayoutStringAMDGCN = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32" "-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128" "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"; -static const LangASMap AMDGPUPrivIsZeroDefIsGenMap = { - 4, // Default - 1, // opencl_global - 3, // opencl_local - 4, // opencl_constant - 0, // opencl_private - 4, // opencl_generic - 1, // cuda_device - 4, // cuda_constant - 3 // cuda_shared -}; - -static const LangASMap AMDGPUGenIsZeroDefIsGenMap = { - 0, // Default - 1, // opencl_global - 3, // opencl_local - 4, // opencl_constant - 5, // opencl_private - 0, // opencl_generic - 1, // cuda_device - 4, // cuda_constant - 3 // cuda_shared +const LangASMap AMDGPUTargetInfo::AMDGPUDefIsGenMap = { + Generic, // Default + Global, // opencl_global + Local, // opencl_local + Constant, // opencl_constant + Private, // opencl_private + Generic, // opencl_generic + Global, // cuda_device + Constant, // cuda_constant + Local // cuda_shared }; -static const LangASMap AMDGPUPrivIsZeroDefIsPrivMap = { - 0, // Default - 1, // opencl_global - 3, // opencl_local - 4, // opencl_constant - 0, // opencl_private - 4, // opencl_generic - 1, // cuda_device - 4, // cuda_constant - 3 // cuda_shared -}; - -static const LangASMap AMDGPUGenIsZeroDefIsPrivMap = { - 5, // Default - 1, // opencl_global - 3, // opencl_local - 4, // opencl_constant - 5, // opencl_private - 0, // opencl_generic - 1, // cuda_device - 4, // cuda_constant - 3 // cuda_shared +const LangASMap AMDGPUTargetInfo::AMDGPUDefIsPrivMap = { + Private, // Default + Global, // opencl_global + Local, // opencl_local + Constant, // opencl_constant + Private, // opencl_private + Generic, // opencl_generic + Global, // cuda_device + Constant, // cuda_constant + Local // cuda_shared }; } // namespace targets } // namespace clang @@ -282,29 +253,18 @@ void AMDGPUTargetInfo::fillValidCPUList( } void AMDGPUTargetInfo::setAddressSpaceMap(bool DefaultIsPrivate) { - if (isGenericZero(getTriple())) { - AddrSpaceMap = DefaultIsPrivate ? &AMDGPUGenIsZeroDefIsPrivMap - : &AMDGPUGenIsZeroDefIsGenMap; - } else { - AddrSpaceMap = DefaultIsPrivate ? &AMDGPUPrivIsZeroDefIsPrivMap - : &AMDGPUPrivIsZeroDefIsGenMap; - } + AddrSpaceMap = DefaultIsPrivate ? &AMDGPUDefIsPrivMap : &AMDGPUDefIsGenMap; } AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) - : TargetInfo(Triple), AS(isGenericZero(Triple)), - GPU(isAMDGCN(Triple) ? AMDGCNGPUs[0] : parseR600Name(Opts.CPU)) { - auto IsGenericZero = isGenericZero(Triple); - resetDataLayout(isAMDGCN(getTriple()) - ? (IsGenericZero ? DataLayoutStringSIGenericIsZero - : DataLayoutStringSIPrivateIsZero) - : DataLayoutStringR600); - assert(DataLayout->getAllocaAddrSpace() == AS.Private); + : TargetInfo(Triple), + GPU(isAMDGCN(Triple) ? AMDGCNGPUs[0] : parseR600Name(Opts.CPU)) { + resetDataLayout(isAMDGCN(getTriple()) ? DataLayoutStringAMDGCN + : DataLayoutStringR600); + assert(DataLayout->getAllocaAddrSpace() == Private); setAddressSpaceMap(Triple.getOS() == llvm::Triple::Mesa3D || - Triple.getEnvironment() == llvm::Triple::OpenCL || - Triple.getEnvironmentName() == "amdgizcl" || !isAMDGCN(Triple)); UseAddrSpaceMapMangling = true; @@ -322,7 +282,11 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple &Triple, void AMDGPUTargetInfo::adjust(LangOptions &Opts) { TargetInfo::adjust(Opts); - setAddressSpaceMap(Opts.OpenCL || !isAMDGCN(getTriple())); + // ToDo: There are still a few places using default address space as private + // address space in OpenCL, which needs to be cleaned up, then Opts.OpenCL + // can be removed from the following line. + setAddressSpaceMap(/*DefaultIsPrivate=*/Opts.OpenCL || + !isAMDGCN(getTriple())); } ArrayRef<Builtin::Info> AMDGPUTargetInfo::getTargetBuiltins() const { diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h index b39f6c9ab0a..603c9b2d546 100644 --- a/clang/lib/Basic/Targets/AMDGPU.h +++ b/clang/lib/Basic/Targets/AMDGPU.h @@ -28,24 +28,15 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo { static const Builtin::Info BuiltinInfo[]; static const char *const GCCRegNames[]; - struct LLVM_LIBRARY_VISIBILITY AddrSpace { - unsigned Generic, Global, Local, Constant, Private; - AddrSpace(bool IsGenericZero_ = false) { - if (IsGenericZero_) { - Generic = 0; - Global = 1; - Local = 3; - Constant = 2; - Private = 5; - } else { - Generic = 4; - Global = 1; - Local = 3; - Constant = 2; - Private = 0; - } - } + enum AddrSpace { + Generic = 0, + Global = 1, + Local = 3, + Constant = 4, + Private = 5 }; + static const LangASMap AMDGPUDefIsGenMap; + static const LangASMap AMDGPUDefIsPrivMap; /// \brief GPU kinds supported by the AMDGPU target. enum GPUKind : uint32_t { @@ -178,15 +169,12 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo { GPUInfo parseGPUName(StringRef Name) const; - const AddrSpace AS; GPUInfo GPU; static bool isAMDGCN(const llvm::Triple &TT) { return TT.getArch() == llvm::Triple::amdgcn; } - static bool isGenericZero(const llvm::Triple &TT) { return true; } - public: AMDGPUTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts); @@ -197,7 +185,7 @@ public: uint64_t getPointerWidthV(unsigned AddrSpace) const override { if (GPU.Kind <= GK_R600_LAST) return 32; - if (AddrSpace == AS.Private || AddrSpace == AS.Local) + if (AddrSpace == Private || AddrSpace == Local) return 32; return 64; } @@ -374,11 +362,13 @@ public: } llvm::Optional<LangAS> getConstantAddressSpace() const override { - return getLangASFromTargetAS(AS.Constant); + return getLangASFromTargetAS(Constant); } /// \returns Target specific vtbl ptr address space. - unsigned getVtblPtrAddressSpace() const override { return AS.Constant; } + unsigned getVtblPtrAddressSpace() const override { + return static_cast<unsigned>(Constant); + } /// \returns If a target requires an address within a target specific address /// space \p AddressSpace to be converted in order to be used, then return the @@ -390,9 +380,9 @@ public: getDWARFAddressSpace(unsigned AddressSpace) const override { const unsigned DWARF_Private = 1; const unsigned DWARF_Local = 2; - if (AddressSpace == AS.Private) { + if (AddressSpace == Private) { return DWARF_Private; - } else if (AddressSpace == AS.Local) { + } else if (AddressSpace == Local) { return DWARF_Local; } else { return None; |

