Skip to content

Commit b0c6c70

Browse files
[OpaquePointers] Add support for target extension types to OpenCL type checks. (#1880)
1 parent 9c0a802 commit b0c6c70

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/SPIRV/OCLUtil.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -1359,6 +1359,9 @@ bool isSamplerTy(Type *Ty) {
13591359
auto *STy = dyn_cast_or_null<StructType>(TPT->getElementType());
13601360
return STy && STy->hasName() && STy->getName() == kSPR2TypeName::Sampler;
13611361
}
1362+
if (auto *TET = dyn_cast_or_null<TargetExtType>(Ty)) {
1363+
return TET->getName() == "spirv.Sampler";
1364+
}
13621365
return false;
13631366
}
13641367

lib/SPIRV/SPIRVUtil.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ bool isOCLImageType(llvm::Type *Ty, StringRef *Name) {
189189
return true;
190190
}
191191
}
192+
if (auto *TET = dyn_cast_or_null<TargetExtType>(Ty)) {
193+
assert(!Name && "Cannot get the name for a target-extension type image");
194+
return TET->getName() == "spirv.Image";
195+
}
192196
return false;
193197
}
194198
/// \param BaseTyName is the type Name as in spirv.BaseTyName.Postfixes
@@ -1605,6 +1609,13 @@ std::string getImageBaseTypeName(StringRef Name) {
16051609
}
16061610

16071611
SPIRVTypeImageDescriptor getImageDescriptor(Type *Ty) {
1612+
if (auto *TET = dyn_cast_or_null<TargetExtType>(Ty)) {
1613+
auto IntParams = TET->int_params();
1614+
assert(IntParams.size() > 6 && "Expected type to be an image type");
1615+
return SPIRVTypeImageDescriptor(SPIRVImageDimKind(IntParams[0]),
1616+
IntParams[1], IntParams[2], IntParams[3],
1617+
IntParams[4], IntParams[5]);
1618+
}
16081619
StringRef TyName;
16091620
[[maybe_unused]] bool IsImg = isOCLImageType(Ty, &TyName);
16101621
assert(IsImg && "Must be an image type");

0 commit comments

Comments
 (0)