Author: Michael Liao Date: 2020-03-28T10:20:34-04:00 New Revision: cb6389360b05e8f89d09ff133a4ba1fd011866c5
URL: https://github.com/llvm/llvm-project/commit/cb6389360b05e8f89d09ff133a4ba1fd011866c5 DIFF: https://github.com/llvm/llvm-project/commit/cb6389360b05e8f89d09ff133a4ba1fd011866c5.diff LOG: Fix GCC warning on enum class bitfield. NFC. Added: Modified: clang/lib/CodeGen/CGCUDANV.cpp clang/lib/CodeGen/CGCUDARuntime.h Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp index ed02a7dc9173..6d92ef33b885 100644 --- a/clang/lib/CodeGen/CGCUDANV.cpp +++ b/clang/lib/CodeGen/CGCUDANV.cpp @@ -466,18 +466,19 @@ llvm::Function *CGNVCUDARuntime::makeRegisterGlobalsFn() { for (auto &&Info : DeviceVars) { llvm::GlobalVariable *Var = Info.Var; llvm::Constant *VarName = makeConstantString(getDeviceSideName(Info.D)); - switch (Info.Flags.Kind) { + switch (Info.Flags.getKind()) { case DeviceVarFlags::Variable: { uint64_t VarSize = CGM.getDataLayout().getTypeAllocSize(Var->getValueType()); - llvm::Value *Args[] = {&GpuBinaryHandlePtr, - Builder.CreateBitCast(Var, VoidPtrTy), - VarName, - VarName, - llvm::ConstantInt::get(IntTy, Info.Flags.Extern), - llvm::ConstantInt::get(IntTy, VarSize), - llvm::ConstantInt::get(IntTy, Info.Flags.Constant), - llvm::ConstantInt::get(IntTy, 0)}; + llvm::Value *Args[] = { + &GpuBinaryHandlePtr, + Builder.CreateBitCast(Var, VoidPtrTy), + VarName, + VarName, + llvm::ConstantInt::get(IntTy, Info.Flags.isExtern()), + llvm::ConstantInt::get(IntTy, VarSize), + llvm::ConstantInt::get(IntTy, Info.Flags.isConstant()), + llvm::ConstantInt::get(IntTy, 0)}; Builder.CreateCall(RegisterVar, Args); break; } @@ -485,16 +486,16 @@ llvm::Function *CGNVCUDARuntime::makeRegisterGlobalsFn() { Builder.CreateCall( RegisterSurf, {&GpuBinaryHandlePtr, Builder.CreateBitCast(Var, VoidPtrTy), VarName, - VarName, llvm::ConstantInt::get(IntTy, Info.Flags.SurfTexType), - llvm::ConstantInt::get(IntTy, Info.Flags.Extern)}); + VarName, llvm::ConstantInt::get(IntTy, Info.Flags.getSurfTexType()), + llvm::ConstantInt::get(IntTy, Info.Flags.isExtern())}); break; case DeviceVarFlags::Texture: Builder.CreateCall( RegisterTex, {&GpuBinaryHandlePtr, Builder.CreateBitCast(Var, VoidPtrTy), VarName, - VarName, llvm::ConstantInt::get(IntTy, Info.Flags.SurfTexType), - llvm::ConstantInt::get(IntTy, Info.Flags.Normalized), - llvm::ConstantInt::get(IntTy, Info.Flags.Extern)}); + VarName, llvm::ConstantInt::get(IntTy, Info.Flags.getSurfTexType()), + llvm::ConstantInt::get(IntTy, Info.Flags.isNormalized()), + llvm::ConstantInt::get(IntTy, Info.Flags.isExtern())}); break; } } diff --git a/clang/lib/CodeGen/CGCUDARuntime.h b/clang/lib/CodeGen/CGCUDARuntime.h index b26132420d65..19e70a2022a5 100644 --- a/clang/lib/CodeGen/CGCUDARuntime.h +++ b/clang/lib/CodeGen/CGCUDARuntime.h @@ -42,17 +42,30 @@ class CGCUDARuntime { public: // Global variable properties that must be passed to CUDA runtime. - struct DeviceVarFlags { - enum DeviceVarKind : unsigned { + class DeviceVarFlags { + public: + enum DeviceVarKind { Variable, // Variable Surface, // Builtin surface Texture, // Builtin texture }; - DeviceVarKind Kind : 2; + + private: + unsigned Kind : 2; unsigned Extern : 1; unsigned Constant : 1; // Constant variable. unsigned Normalized : 1; // Normalized texture. int SurfTexType; // Type of surface/texutre. + + public: + DeviceVarFlags(DeviceVarKind K, bool E, bool C, bool N, int T) + : Kind(K), Extern(E), Constant(C), Normalized(N), SurfTexType(T) {} + + DeviceVarKind getKind() const { return static_cast<DeviceVarKind>(Kind); } + bool isExtern() const { return Extern; } + bool isConstant() const { return Constant; } + bool isNormalized() const { return Normalized; } + int getSurfTexType() const { return SurfTexType; } }; CGCUDARuntime(CodeGenModule &CGM) : CGM(CGM) {} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits