[Mlir-commits] [mlir] [mlir][SPIR-V] Update the `ConvertToSPIRV` pass to use dialect interfaces (PR #102046)
Fabian Mora
llvmlistbot at llvm.org
Tue Aug 6 06:25:47 PDT 2024
================
@@ -416,3 +417,37 @@ struct ConvertIndexToSPIRVPass
}
};
} // namespace
+
+//===----------------------------------------------------------------------===//
+// ConvertToSPIRVPatternInterface implementation
+//===----------------------------------------------------------------------===//
+namespace {
+/// Implement the interface to convert index to SPIR-V.
+struct ToSPIRVDialectInterface : public ConvertToSPIRVPatternInterface {
+ using ConvertToSPIRVPatternInterface::ConvertToSPIRVPatternInterface;
+ void loadDependentDialects(MLIRContext *context) const final {
+ context->loadDialect<spirv::SPIRVDialect>();
+ }
+
+ /// Hook for derived dialect interface to provide conversion patterns
+ /// and mark dialect legal for the conversion target.
+ void populateConvertToSPIRVConversionPatterns(
+ ConversionTarget &target, SPIRVTypeConverter &typeConverter,
+ RewritePatternSet &patterns) const final {
+ // Use UnrealizedConversionCast as the bridge so that we don't need to pull
+ // in patterns for other dialects.
+ target.addLegalOp<UnrealizedConversionCastOp>();
----------------
fabianmcg wrote:
I removed it as it was not really needed when all patterns run together.
https://github.com/llvm/llvm-project/pull/102046
More information about the Mlir-commits
mailing list