diff --git a/mlir/include/mlir/Transforms/DialectConversion.h b/mlir/include/mlir/Transforms/DialectConversion.h --- a/mlir/include/mlir/Transforms/DialectConversion.h +++ b/mlir/include/mlir/Transforms/DialectConversion.h @@ -103,8 +103,8 @@ /// conversion function to perform the conversion. /// Note: When attempting to convert a type, e.g. via 'convertType', the /// mostly recently added conversions will be invoked first. - template ::template arg_t<0>> + template >::template arg_t<0>> void addConversion(FnT &&callback) { registerConversion(wrapCallback(std::forward(callback))); } @@ -124,8 +124,8 @@ /// /// This method registers a materialization that will be called when /// converting an illegal block argument type, to a legal type. - template ::template arg_t<1>> + template >::template arg_t<1>> void addArgumentMaterialization(FnT &&callback) { argumentMaterializations.emplace_back( wrapMaterialization(std::forward(callback))); @@ -133,16 +133,16 @@ /// This method registers a materialization that will be called when /// converting a legal type to an illegal source type. This is used when /// conversions to an illegal type must persist beyond the main conversion. - template ::template arg_t<1>> + template >::template arg_t<1>> void addSourceMaterialization(FnT &&callback) { sourceMaterializations.emplace_back( wrapMaterialization(std::forward(callback))); } /// This method registers a materialization that will be called when /// converting type from an illegal, or source, type to a legal type. - template ::template arg_t<1>> + template >::template arg_t<1>> void addTargetMaterialization(FnT &&callback) { targetMaterializations.emplace_back( wrapMaterialization(std::forward(callback))); diff --git a/mlir/test/lib/Dialect/Test/TestPatterns.cpp b/mlir/test/lib/Dialect/Test/TestPatterns.cpp --- a/mlir/test/lib/Dialect/Test/TestPatterns.cpp +++ b/mlir/test/lib/Dialect/Test/TestPatterns.cpp @@ -492,8 +492,17 @@ TestTypeConverter() { addConversion(convertType); addArgumentMaterialization(materializeCast); - addArgumentMaterialization(materializeOneToOneCast); addSourceMaterialization(materializeCast); + + /// Materialize the cast for one-to-one conversion from i64 to f64. + const auto materializeOneToOneCast = + [](OpBuilder &builder, IntegerType resultType, ValueRange inputs, + Location loc) -> Optional { + if (resultType.getWidth() == 42 && inputs.size() == 1) + return builder.create(loc, resultType, inputs).getResult(); + return llvm::None; + }; + addArgumentMaterialization(materializeOneToOneCast); } static LogicalResult convertType(Type t, SmallVectorImpl &results) { @@ -532,16 +541,6 @@ return inputs[0]; return builder.create(loc, resultType, inputs).getResult(); } - - /// Materialize the cast for one-to-one conversion from i64 to f64. - static Optional materializeOneToOneCast(OpBuilder &builder, - IntegerType resultType, - ValueRange inputs, - Location loc) { - if (resultType.getWidth() == 42 && inputs.size() == 1) - return builder.create(loc, resultType, inputs).getResult(); - return llvm::None; - } }; struct TestLegalizePatternDriver