[Mlir-commits] [mlir] [mlir][spirv] Use `AttrTypeReplacer` in map-memref-storage-class. NFC. (PR #80055)
Quinn Dawkins
llvmlistbot at llvm.org
Tue Jan 30 12:51:13 PST 2024
================
@@ -335,23 +287,25 @@ class MapMemRefStorageClassPass final
MLIRContext *context = &getContext();
Operation *op = getOperation();
+ spirv::MemorySpaceToStorageClassMap spaceToStorage = memorySpaceMap;
if (spirv::TargetEnvAttr attr = spirv::lookupTargetEnv(op)) {
spirv::TargetEnv targetEnv(attr);
if (targetEnv.allows(spirv::Capability::Kernel)) {
- memorySpaceMap = spirv::mapMemorySpaceToOpenCLStorageClass;
+ spaceToStorage = spirv::mapMemorySpaceToOpenCLStorageClass;
} else if (targetEnv.allows(spirv::Capability::Shader)) {
- memorySpaceMap = spirv::mapMemorySpaceToVulkanStorageClass;
+ spaceToStorage = spirv::mapMemorySpaceToVulkanStorageClass;
}
}
- std::unique_ptr<ConversionTarget> target =
- spirv::getMemorySpaceToStorageClassTarget(*context);
- spirv::MemorySpaceToStorageClassConverter converter(memorySpaceMap);
-
- RewritePatternSet patterns(context);
- spirv::populateMemorySpaceToStorageClassPatterns(converter, patterns);
+ spirv::MemorySpaceToStorageClassConverter converter(spaceToStorage);
+ // Perform the replacement.
+ spirv::convertMemRefTypesAndAttrs(op, converter);
- if (failed(applyFullConversion(op, *target, std::move(patterns))))
+ // Only perform the conversion to check that there are no illegal ops
+ // remaining. Do not attempt to convert anything.
+ if (failed(applyFullConversion(
+ op, *spirv::getMemorySpaceToStorageClassTarget(*context),
+ RewritePatternSet{context})))
----------------
qedawkins wrote:
I'm not an expert on dialect conversion, but does this just boil down to a walk + ConversionTarget::isLegal? Ditto for the above.
https://github.com/llvm/llvm-project/pull/80055
More information about the Mlir-commits
mailing list