diff options
author | Artem Belevich <tra@google.com> | 2020-03-27 10:01:38 -0700 |
---|---|---|
committer | Artem Belevich <tra@google.com> | 2020-03-27 10:01:38 -0700 |
commit | fe8063e1a0e983f1b4d38530f4fb157a26c0771c (patch) | |
tree | 5a5a08763659010e689e88b1bcdbdbf89052d0e7 /clang/lib/CodeGen/TargetInfo.cpp | |
parent | 667781592a44ed02f42d4a07c85cf1a898543304 (diff) | |
download | llvm-fe8063e1a0e983f1b4d38530f4fb157a26c0771c.zip llvm-fe8063e1a0e983f1b4d38530f4fb157a26c0771c.tar.gz llvm-fe8063e1a0e983f1b4d38530f4fb157a26c0771c.tar.bz2 |
Revert "[cuda][hip] Add CUDA builtin surface/texture reference support."
This reverts commit 6a9ad5f3f4ac66f0cae592e911f4baeb6ee5eca6.
The patch breaks CUDA copmilation.
Differential Revision: https://reviews.llvm.org/D76365
Diffstat (limited to 'clang/lib/CodeGen/TargetInfo.cpp')
-rw-r--r-- | clang/lib/CodeGen/TargetInfo.cpp | 91 |
1 files changed, 9 insertions, 82 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index e64fe4f..2b96cc4 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -28,7 +28,6 @@ #include "llvm/ADT/Triple.h" #include "llvm/ADT/Twine.h" #include "llvm/IR/DataLayout.h" -#include "llvm/IR/IntrinsicsNVPTX.h" #include "llvm/IR/Type.h" #include "llvm/Support/raw_ostream.h" #include <algorithm> // std::sort @@ -6415,14 +6414,9 @@ Address ARMABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, namespace { -class NVPTXTargetCodeGenInfo; - class NVPTXABIInfo : public ABIInfo { - NVPTXTargetCodeGenInfo &CGInfo; - public: - NVPTXABIInfo(CodeGenTypes &CGT, NVPTXTargetCodeGenInfo &Info) - : ABIInfo(CGT), CGInfo(Info) {} + NVPTXABIInfo(CodeGenTypes &CGT) : ABIInfo(CGT) {} ABIArgInfo classifyReturnType(QualType RetTy) const; ABIArgInfo classifyArgumentType(QualType Ty) const; @@ -6435,61 +6429,16 @@ public: class NVPTXTargetCodeGenInfo : public TargetCodeGenInfo { public: NVPTXTargetCodeGenInfo(CodeGenTypes &CGT) - : TargetCodeGenInfo(new NVPTXABIInfo(CGT, *this)) {} + : TargetCodeGenInfo(new NVPTXABIInfo(CGT)) {} void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &M) const override; bool shouldEmitStaticExternCAliases() const override; - llvm::Type *getCUDADeviceBuiltinSurfaceDeviceType() const override { - // On the device side, surface reference is represented as an object handle - // in 64-bit integer. - return llvm::Type::getInt64Ty(getABIInfo().getVMContext()); - } - - llvm::Type *getCUDADeviceBuiltinTextureDeviceType() const override { - // On the device side, texture reference is represented as an object handle - // in 64-bit integer. - return llvm::Type::getInt64Ty(getABIInfo().getVMContext()); - } - - bool emitCUDADeviceBuiltinSurfaceDeviceCopy(CodeGenFunction &CGF, LValue Dst, - LValue Src) const override { - emitBuiltinSurfTexDeviceCopy(CGF, Dst, Src); - return true; - } - - bool emitCUDADeviceBuiltinTextureDeviceCopy(CodeGenFunction &CGF, LValue Dst, - LValue Src) const override { - emitBuiltinSurfTexDeviceCopy(CGF, Dst, Src); - return true; - } - private: - // Adds a NamedMDNode with GV, Name, and Operand as operands, and adds the + // Adds a NamedMDNode with F, Name, and Operand as operands, and adds the // resulting MDNode to the nvvm.annotations MDNode. - static void addNVVMMetadata(llvm::GlobalValue *GV, StringRef Name, - int Operand); - - static void emitBuiltinSurfTexDeviceCopy(CodeGenFunction &CGF, LValue Dst, - LValue Src) { - llvm::Value *Handle = nullptr; - llvm::Constant *C = - llvm::dyn_cast<llvm::Constant>(Src.getAddress(CGF).getPointer()); - // Lookup `addrspacecast` through the constant pointer if any. - if (auto *ASC = llvm::dyn_cast_or_null<llvm::AddrSpaceCastOperator>(C)) - C = llvm::cast<llvm::Constant>(ASC->getPointerOperand()); - if (auto *GV = llvm::dyn_cast_or_null<llvm::GlobalVariable>(C)) { - // Load the handle from the specific global variable using - // `nvvm.texsurf.handle.internal` intrinsic. - Handle = CGF.EmitRuntimeCall( - CGF.CGM.getIntrinsic(llvm::Intrinsic::nvvm_texsurf_handle_internal, - {GV->getType()}), - {GV}, "texsurf_handle"); - } else - Handle = CGF.EmitLoadOfScalar(Src, SourceLocation()); - CGF.EmitStoreOfScalar(Handle, Dst); - } + static void addNVVMMetadata(llvm::Function *F, StringRef Name, int Operand); }; /// Checks if the type is unsupported directly by the current target. @@ -6562,19 +6511,8 @@ ABIArgInfo NVPTXABIInfo::classifyArgumentType(QualType Ty) const { Ty = EnumTy->getDecl()->getIntegerType(); // Return aggregates type as indirect by value - if (isAggregateTypeForABI(Ty)) { - // Under CUDA device compilation, tex/surf builtin types are replaced with - // object types and passed directly. - if (getContext().getLangOpts().CUDAIsDevice) { - if (Ty->isCUDADeviceBuiltinSurfaceType()) - return ABIArgInfo::getDirect( - CGInfo.getCUDADeviceBuiltinSurfaceDeviceType()); - if (Ty->isCUDADeviceBuiltinTextureType()) - return ABIArgInfo::getDirect( - CGInfo.getCUDADeviceBuiltinTextureDeviceType()); - } + if (isAggregateTypeForABI(Ty)) return getNaturalAlignIndirect(Ty, /* byval */ true); - } return (Ty->isPromotableIntegerType() ? ABIArgInfo::getExtend(Ty) : ABIArgInfo::getDirect()); @@ -6602,17 +6540,6 @@ void NVPTXTargetCodeGenInfo::setTargetAttributes( const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &M) const { if (GV->isDeclaration()) return; - const VarDecl *VD = dyn_cast_or_null<VarDecl>(D); - if (VD) { - if (M.getLangOpts().CUDA) { - if (VD->getType()->isCUDADeviceBuiltinSurfaceType()) - addNVVMMetadata(GV, "surface", 1); - else if (VD->getType()->isCUDADeviceBuiltinTextureType()) - addNVVMMetadata(GV, "texture", 1); - return; - } - } - const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D); if (!FD) return; @@ -6661,16 +6588,16 @@ void NVPTXTargetCodeGenInfo::setTargetAttributes( } } -void NVPTXTargetCodeGenInfo::addNVVMMetadata(llvm::GlobalValue *GV, - StringRef Name, int Operand) { - llvm::Module *M = GV->getParent(); +void NVPTXTargetCodeGenInfo::addNVVMMetadata(llvm::Function *F, StringRef Name, + int Operand) { + llvm::Module *M = F->getParent(); llvm::LLVMContext &Ctx = M->getContext(); // Get "nvvm.annotations" metadata node llvm::NamedMDNode *MD = M->getOrInsertNamedMetadata("nvvm.annotations"); llvm::Metadata *MDVals[] = { - llvm::ConstantAsMetadata::get(GV), llvm::MDString::get(Ctx, Name), + llvm::ConstantAsMetadata::get(F), llvm::MDString::get(Ctx, Name), llvm::ConstantAsMetadata::get( llvm::ConstantInt::get(llvm::Type::getInt32Ty(Ctx), Operand))}; // Append metadata to nvvm.annotations |