[Mlir-commits] [mlir] [mlir][gpu] GPUToROCDL/NVVM: use generic llvm conversion interface instead of hardcoded conversions. (PR #124439)
Ivan Butygin
llvmlistbot at llvm.org
Sun Feb 9 07:14:29 PST 2025
================
@@ -376,17 +376,41 @@ struct LowerGpuOpsToNVVMOpsPass
LLVMTypeConverter converter(m.getContext(), options);
configureGpuToNVVMTypeConverter(converter);
RewritePatternSet llvmPatterns(m.getContext());
+ LLVMConversionTarget target(getContext());
+
+ llvm::SmallDenseSet<StringRef> allowedDialectsSet(allowedDialects.begin(),
+ allowedDialects.end());
+ for (Dialect *dialect : getContext().getLoadedDialects()) {
+ // Skip math patterns as nvvm needs custom math lowering.
+ if (isa<math::MathDialect>(dialect))
+ continue;
+
+ bool allowed = allowedDialectsSet.contains(dialect->getNamespace());
+ // Empty `allowedDialectsSet` means all dialects are allowed.
+ if (!allowedDialectsSet.empty() && !allowed)
+ continue;
+
+ auto iface = dyn_cast<ConvertToLLVMPatternInterface>(dialect);
+ if (!iface) {
+ // Error out if dialect was explicily specified but doesn't implement
+ // conversion interface.
+ if (allowed) {
+ m.emitError()
+ << "dialect does not implement ConvertToLLVMPatternInterface: "
+ << dialect->getNamespace();
----------------
Hardcode84 wrote:
done
https://github.com/llvm/llvm-project/pull/124439
More information about the Mlir-commits
mailing list