@@ -37,43 +37,16 @@ llvm::Type *CGOpenCLRuntime::convertOpenCLSpecificType(const Type *T) {
37
37
if (llvm::Type *TransTy = CGM.getTargetCodeGenInfo ().getOpenCLType (CGM, T))
38
38
return TransTy;
39
39
40
- switch (cast<BuiltinType>(T)->getKind ()) {
41
- default :
42
- llvm_unreachable (" Unexpected opencl builtin type!" );
43
- return nullptr ;
44
- #define IMAGE_TYPE (ImgType, Id, SingletonId, Access, Suffix ) \
45
- case BuiltinType::Id: \
46
- return getPointerType (T, " opencl." #ImgType " _" #Suffix " _t" );
47
- #include " clang/Basic/OpenCLImageTypes.def"
48
- case BuiltinType::OCLSampler:
40
+ if (T->isSamplerT ())
49
41
return getSamplerType (T);
50
- case BuiltinType::OCLEvent:
51
- return getPointerType (T, " opencl.event_t" );
52
- case BuiltinType::OCLClkEvent:
53
- return getPointerType (T, " opencl.clk_event_t" );
54
- case BuiltinType::OCLQueue:
55
- return getPointerType (T, " opencl.queue_t" );
56
- case BuiltinType::OCLReserveID:
57
- return getPointerType (T, " opencl.reserve_id_t" );
58
- #define EXT_OPAQUE_TYPE (ExtType, Id, Ext ) \
59
- case BuiltinType::Id: \
60
- return getPointerType (T, " opencl." #ExtType);
61
- #include " clang/Basic/OpenCLExtensionTypes.def"
62
- }
63
- }
64
42
65
- llvm::PointerType *CGOpenCLRuntime::getPointerType (const Type *T,
66
- StringRef Name) {
67
- auto I = CachedTys.find (Name);
68
- if (I != CachedTys.end ())
69
- return I->second ;
43
+ return getPointerType (T);
44
+ }
70
45
71
- llvm::LLVMContext &Ctx = CGM. getLLVMContext ();
46
+ llvm::PointerType * CGOpenCLRuntime::getPointerType ( const Type *T) {
72
47
uint32_t AddrSpc = CGM.getContext ().getTargetAddressSpace (
73
48
CGM.getContext ().getOpenCLTypeAddrSpace (T));
74
- auto *PTy = llvm::PointerType::get (Ctx, AddrSpc);
75
- CachedTys[Name] = PTy;
76
- return PTy;
49
+ return llvm::PointerType::get (CGM.getLLVMContext (), AddrSpc);
77
50
}
78
51
79
52
llvm::Type *CGOpenCLRuntime::getPipeType (const PipeType *T) {
@@ -89,9 +62,7 @@ llvm::Type *CGOpenCLRuntime::getPipeType(const PipeType *T) {
89
62
llvm::Type *CGOpenCLRuntime::getPipeType (const PipeType *T, StringRef Name,
90
63
llvm::Type *&PipeTy) {
91
64
if (!PipeTy)
92
- PipeTy = llvm::PointerType::get (
93
- CGM.getLLVMContext (), CGM.getContext ().getTargetAddressSpace (
94
- CGM.getContext ().getOpenCLTypeAddrSpace (T)));
65
+ PipeTy = getPointerType (T);
95
66
return PipeTy;
96
67
}
97
68
@@ -103,10 +74,7 @@ llvm::Type *CGOpenCLRuntime::getSamplerType(const Type *T) {
103
74
CGM, CGM.getContext ().OCLSamplerTy .getTypePtr ()))
104
75
SamplerTy = TransTy;
105
76
else
106
- // struct opencl.sampler_t*
107
- SamplerTy = llvm::PointerType::get (
108
- CGM.getLLVMContext (), CGM.getContext ().getTargetAddressSpace (
109
- CGM.getContext ().getOpenCLTypeAddrSpace (T)));
77
+ SamplerTy = getPointerType (T);
110
78
return SamplerTy;
111
79
}
112
80
0 commit comments