Skip to content

[mlir][spirv] Fix lookup logic spirv.target_env for gpu.module #147262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
9 changes: 9 additions & 0 deletions mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,15 @@ spirv::TargetEnvAttr spirv::lookupTargetEnv(Operation *op) {
if (!op)
break;

if (auto arrAttr = op->getAttrOfType<ArrayAttr>("targets")) {
for (auto attr : arrAttr) {
if (auto spirvTargetEnvAttr =
llvm::dyn_cast<spirv::TargetEnvAttr>(attr)) {
return spirvTargetEnvAttr;
}
}
}

if (auto attr = op->getAttrOfType<spirv::TargetEnvAttr>(
spirv::getTargetEnvAttrName()))
return attr;
Expand Down