From 3578947fc7d27c794d8933bdb354667325f6bd5e Mon Sep 17 00:00:00 2001 From: Jeremy Kun Date: Tue, 5 Mar 2024 13:02:26 -0800 Subject: [PATCH] add unique names for pass type converters Fixes https://github.com/google/heir/issues/482 --- lib/Conversion/CGGIToTfheRust/CGGIToTfheRust.cpp | 6 +++--- templates/Conversion/lib/ConversionPass.cpp.jinja | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Conversion/CGGIToTfheRust/CGGIToTfheRust.cpp b/lib/Conversion/CGGIToTfheRust/CGGIToTfheRust.cpp index e0078cba1..4954b3c08 100644 --- a/lib/Conversion/CGGIToTfheRust/CGGIToTfheRust.cpp +++ b/lib/Conversion/CGGIToTfheRust/CGGIToTfheRust.cpp @@ -84,9 +84,9 @@ int widthFromEncodingAttr(Attribute encoding) { }); } -class PassTypeConverter : public TypeConverter { +class CGGIToTfheRustTypeConverter : public TypeConverter { public: - PassTypeConverter(MLIRContext *ctx) { + CGGIToTfheRustTypeConverter(MLIRContext *ctx) { addConversion([](Type type) { return type; }); addConversion([ctx](lwe::LWECiphertextType type) -> Type { int width = widthFromEncodingAttr(type.getEncoding()); @@ -402,7 +402,7 @@ class CGGIToTfheRust : public impl::CGGIToTfheRustBase { MLIRContext *context = &getContext(); auto *op = getOperation(); - PassTypeConverter typeConverter(context); + CGGIToTfheRustTypeConverter typeConverter(context); RewritePatternSet patterns(context); ConversionTarget target(*context); addStructuralConversionPatterns(typeConverter, patterns, target); diff --git a/templates/Conversion/lib/ConversionPass.cpp.jinja b/templates/Conversion/lib/ConversionPass.cpp.jinja index a3b9c7c9b..3ebf0f162 100644 --- a/templates/Conversion/lib/ConversionPass.cpp.jinja +++ b/templates/Conversion/lib/ConversionPass.cpp.jinja @@ -11,9 +11,9 @@ namespace mlir::heir { #include "include/Conversion/{{ pass_name }}/{{ pass_name }}.h.inc" // Remove this class if no type conversions are necessary -class PassTypeConverter : public TypeConverter { +class {{ pass_name }}TypeConverter : public TypeConverter { public: - PassTypeConverter(MLIRContext *ctx) { + {{ pass_name }}TypeConverter(MLIRContext *ctx) { addConversion([](Type type) { return type; }); // FIXME: implement, replace FooType with the type that needs // to be converted or remove this class @@ -42,7 +42,7 @@ struct {{ pass_name }} : public impl::{{ pass_name }}Base<{{ pass_name }}> { void runOnOperation() override { MLIRContext *context = &getContext(); auto *module = getOperation(); - PassTypeConverter typeConverter(context); + {{ pass_name }}TypeConverter typeConverter(context); RewritePatternSet patterns(context); ConversionTarget target(*context);