Skip to content

Commit

Permalink
Add support for target extension types to OpenCL type checks. (intel#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jcranmer-intel authored and FreddyLeaf committed Mar 22, 2023
1 parent a799330 commit cf0e151
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions llvm-spirv/lib/SPIRV/OCLUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1351,6 +1351,9 @@ bool isSamplerTy(Type *Ty) {
auto *STy = dyn_cast_or_null<StructType>(TPT->getElementType());
return STy && STy->hasName() && STy->getName() == kSPR2TypeName::Sampler;
}
if (auto *TET = dyn_cast_or_null<TargetExtType>(Ty)) {
return TET->getName() == "spirv.Sampler";
}
return false;
}

Expand Down
11 changes: 11 additions & 0 deletions llvm-spirv/lib/SPIRV/SPIRVUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ bool isOCLImageType(llvm::Type *Ty, StringRef *Name) {
return true;
}
}
if (auto *TET = dyn_cast_or_null<TargetExtType>(Ty)) {
assert(!Name && "Cannot get the name for a target-extension type image");
return TET->getName() == "spirv.Image";
}
return false;
}
/// \param BaseTyName is the type Name as in spirv.BaseTyName.Postfixes
Expand Down Expand Up @@ -1607,6 +1611,13 @@ std::string getImageBaseTypeName(StringRef Name) {
}

SPIRVTypeImageDescriptor getImageDescriptor(Type *Ty) {
if (auto *TET = dyn_cast_or_null<TargetExtType>(Ty)) {
auto IntParams = TET->int_params();
assert(IntParams.size() > 6 && "Expected type to be an image type");
return SPIRVTypeImageDescriptor(SPIRVImageDimKind(IntParams[0]),
IntParams[1], IntParams[2], IntParams[3],
IntParams[4], IntParams[5]);
}
StringRef TyName;
[[maybe_unused]] bool IsImg = isOCLImageType(Ty, &TyName);
assert(IsImg && "Must be an image type");
Expand Down

0 comments on commit cf0e151

Please sign in to comment.