Index: cfe/trunk/include/clang/Basic/TargetInfo.h =================================================================== --- cfe/trunk/include/clang/Basic/TargetInfo.h +++ cfe/trunk/include/clang/Basic/TargetInfo.h @@ -986,6 +986,11 @@ return getTargetOpts().SupportedOpenCLOptions; } + /// \brief Get OpenCL image type address space. + virtual LangAS::ID getOpenCLImageAddrSpace() const { + return LangAS::opencl_global; + } + /// \brief Check the target is valid after it is fully initialized. virtual bool validateTarget(DiagnosticsEngine &Diags) const { return true; Index: cfe/trunk/lib/AST/ASTContext.cpp =================================================================== --- cfe/trunk/lib/AST/ASTContext.cpp +++ cfe/trunk/lib/AST/ASTContext.cpp @@ -1750,14 +1750,18 @@ case BuiltinType::OCLQueue: case BuiltinType::OCLNDRange: case BuiltinType::OCLReserveID: -#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ - case BuiltinType::Id: -#include "clang/Basic/OpenCLImageTypes.def" - // Currently these types are pointers to opaque types. Width = Target->getPointerWidth(0); Align = Target->getPointerAlign(0); break; +#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ + case BuiltinType::Id: +#include "clang/Basic/OpenCLImageTypes.def" + { + auto AS = getTargetAddressSpace(Target->getOpenCLImageAddrSpace()); + Width = Target->getPointerWidth(AS); + Align = Target->getPointerAlign(AS); + } } break; case Type::ObjCObjectPointer: Index: cfe/trunk/lib/Basic/Targets.cpp =================================================================== --- cfe/trunk/lib/Basic/Targets.cpp +++ cfe/trunk/lib/Basic/Targets.cpp @@ -2131,6 +2131,10 @@ } } + LangAS::ID getOpenCLImageAddrSpace() const override { + return LangAS::opencl_constant; + } + CallingConvCheckResult checkCallingConvention(CallingConv CC) const override { switch (CC) { default: Index: cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp =================================================================== --- cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp +++ cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp @@ -35,8 +35,8 @@ "Not an OpenCL specific type!"); llvm::LLVMContext& Ctx = CGM.getLLVMContext(); - uint32_t ImgAddrSpc = - CGM.getTargetCodeGenInfo().getOpenCLImageAddrSpace(CGM); + uint32_t ImgAddrSpc = CGM.getContext().getTargetAddressSpace( + CGM.getTarget().getOpenCLImageAddrSpace()); switch (cast(T)->getKind()) { default: llvm_unreachable("Unexpected opencl builtin type!"); Index: cfe/trunk/lib/CodeGen/TargetInfo.h =================================================================== --- cfe/trunk/lib/CodeGen/TargetInfo.h +++ cfe/trunk/lib/CodeGen/TargetInfo.h @@ -220,9 +220,6 @@ /// Get LLVM calling convention for OpenCL kernel. virtual unsigned getOpenCLKernelCallingConv() const; - - /// Get LLVM Image Address Space for OpenCL kernel. - virtual unsigned getOpenCLImageAddrSpace(CodeGen::CodeGenModule &CGM) const; }; } // namespace CodeGen Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp =================================================================== --- cfe/trunk/lib/CodeGen/TargetInfo.cpp +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp @@ -401,10 +401,6 @@ return llvm::CallingConv::C; } -unsigned TargetCodeGenInfo::getOpenCLImageAddrSpace(CodeGen::CodeGenModule &CGM) const { - return CGM.getContext().getTargetAddressSpace(LangAS::opencl_global); -} - static bool isEmptyRecord(ASTContext &Context, QualType T, bool AllowArrays); /// isEmptyField - Return true iff a the field is "empty", that is it @@ -6883,7 +6879,6 @@ void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &M) const override; unsigned getOpenCLKernelCallingConv() const override; - unsigned getOpenCLImageAddrSpace(CodeGen::CodeGenModule &CGM) const override; }; } @@ -6920,10 +6915,6 @@ return llvm::CallingConv::AMDGPU_KERNEL; } -unsigned AMDGPUTargetCodeGenInfo::getOpenCLImageAddrSpace(CodeGen::CodeGenModule &CGM) const { - return CGM.getContext().getTargetAddressSpace(LangAS::opencl_constant); -} - //===----------------------------------------------------------------------===// // SPARC v8 ABI Implementation. // Based on the SPARC Compliance Definition version 2.4.1.