diff --git a/lib/Conversion/DCToHW/DCToHW.cpp b/lib/Conversion/DCToHW/DCToHW.cpp index ef0da21d7153..fb57dd7f1051 100644 --- a/lib/Conversion/DCToHW/DCToHW.cpp +++ b/lib/Conversion/DCToHW/DCToHW.cpp @@ -118,7 +118,9 @@ class ESITypeConverter : public TypeConverter { if (inputs.size() != 1) return std::nullopt; - return inputs[0]; + return builder + .create(loc, resultType, inputs[0]) + ->getResult(0); }); addSourceMaterialization( @@ -128,7 +130,9 @@ class ESITypeConverter : public TypeConverter { if (inputs.size() != 1) return std::nullopt; - return inputs[0]; + return builder + .create(loc, resultType, inputs[0]) + ->getResult(0); }); } }; diff --git a/lib/Conversion/HWArithToHW/HWArithToHW.cpp b/lib/Conversion/HWArithToHW/HWArithToHW.cpp index bd7c4ca7a7c5..65349b1fc93a 100644 --- a/lib/Conversion/HWArithToHW/HWArithToHW.cpp +++ b/lib/Conversion/HWArithToHW/HWArithToHW.cpp @@ -393,7 +393,9 @@ HWArithToHWTypeConverter::HWArithToHWTypeConverter() { mlir::Location loc) -> std::optional { if (inputs.size() != 1) return std::nullopt; - return inputs[0]; + return builder + .create(loc, resultType, inputs[0]) + ->getResult(0); }); addSourceMaterialization( @@ -402,7 +404,9 @@ HWArithToHWTypeConverter::HWArithToHWTypeConverter() { mlir::Location loc) -> std::optional { if (inputs.size() != 1) return std::nullopt; - return inputs[0]; + return builder + .create(loc, resultType, inputs[0]) + ->getResult(0); }); } diff --git a/lib/Conversion/HandshakeToDC/HandshakeToDC.cpp b/lib/Conversion/HandshakeToDC/HandshakeToDC.cpp index cbc0171eb317..e6b6a4f0213f 100644 --- a/lib/Conversion/HandshakeToDC/HandshakeToDC.cpp +++ b/lib/Conversion/HandshakeToDC/HandshakeToDC.cpp @@ -92,7 +92,9 @@ class DCTypeConverter : public TypeConverter { if (vt && !vt.getInnerType()) return pack(builder, inputs.front()); - return inputs[0]; + return builder + .create(loc, resultType, inputs[0]) + ->getResult(0); }); addSourceMaterialization( @@ -112,7 +114,9 @@ class DCTypeConverter : public TypeConverter { if (vt && !vt.getInnerType()) return pack(builder, inputs.front()); - return inputs[0]; + return builder + .create(loc, resultType, inputs[0]) + ->getResult(0); }); } }; diff --git a/lib/Conversion/HandshakeToHW/HandshakeToHW.cpp b/lib/Conversion/HandshakeToHW/HandshakeToHW.cpp index 37cfd483fa6e..b4b883606fb9 100644 --- a/lib/Conversion/HandshakeToHW/HandshakeToHW.cpp +++ b/lib/Conversion/HandshakeToHW/HandshakeToHW.cpp @@ -71,7 +71,9 @@ class ESITypeConverter : public TypeConverter { mlir::Location loc) -> std::optional { if (inputs.size() != 1) return std::nullopt; - return inputs[0]; + return builder + .create(loc, resultType, inputs[0]) + ->getResult(0); }); addSourceMaterialization( @@ -80,7 +82,9 @@ class ESITypeConverter : public TypeConverter { mlir::Location loc) -> std::optional { if (inputs.size() != 1) return std::nullopt; - return inputs[0]; + return builder + .create(loc, resultType, inputs[0]) + ->getResult(0); }); } }; diff --git a/lib/Conversion/LTLToCore/LTLToCore.cpp b/lib/Conversion/LTLToCore/LTLToCore.cpp index b6482ac3e19a..4e0a7df05f22 100644 --- a/lib/Conversion/LTLToCore/LTLToCore.cpp +++ b/lib/Conversion/LTLToCore/LTLToCore.cpp @@ -138,7 +138,9 @@ void LowerLTLToCorePass::runOnOperation() { mlir::Location loc) -> std::optional { if (inputs.size() != 1) return std::nullopt; - return inputs[0]; + return builder + .create(loc, resultType, inputs[0]) + ->getResult(0); }); converter.addSourceMaterialization( @@ -147,7 +149,9 @@ void LowerLTLToCorePass::runOnOperation() { mlir::Location loc) -> std::optional { if (inputs.size() != 1) return std::nullopt; - return inputs[0]; + return builder + .create(loc, resultType, inputs[0]) + ->getResult(0); }); // Create the operation rewrite patters diff --git a/lib/Conversion/MooreToCore/MooreToCore.cpp b/lib/Conversion/MooreToCore/MooreToCore.cpp index 323a4287f75b..ee581c63347d 100644 --- a/lib/Conversion/MooreToCore/MooreToCore.cpp +++ b/lib/Conversion/MooreToCore/MooreToCore.cpp @@ -1301,7 +1301,9 @@ static void populateTypeConversion(TypeConverter &typeConverter) { mlir::Location loc) -> std::optional { if (inputs.size() != 1) return std::nullopt; - return inputs[0]; + return builder + .create(loc, resultType, inputs[0]) + ->getResult(0); }); } diff --git a/lib/Conversion/SeqToSV/SeqToSV.cpp b/lib/Conversion/SeqToSV/SeqToSV.cpp index d4a13ea369fe..dd3931dc6eb5 100644 --- a/lib/Conversion/SeqToSV/SeqToSV.cpp +++ b/lib/Conversion/SeqToSV/SeqToSV.cpp @@ -363,7 +363,10 @@ struct SeqToSVTypeConverter : public TypeConverter { mlir::Location loc) -> std::optional { if (inputs.size() != 1) return std::nullopt; - return inputs[0]; + return builder + .create(loc, resultType, + inputs[0]) + ->getResult(0); }); addSourceMaterialization( @@ -372,7 +375,10 @@ struct SeqToSVTypeConverter : public TypeConverter { mlir::Location loc) -> std::optional { if (inputs.size() != 1) return std::nullopt; - return inputs[0]; + return builder + .create(loc, resultType, + inputs[0]) + ->getResult(0); }); } }; diff --git a/lib/Dialect/FIRRTL/Transforms/LowerClasses.cpp b/lib/Dialect/FIRRTL/Transforms/LowerClasses.cpp index a36b25f170ff..d77f52c73972 100644 --- a/lib/Dialect/FIRRTL/Transforms/LowerClasses.cpp +++ b/lib/Dialect/FIRRTL/Transforms/LowerClasses.cpp @@ -1849,18 +1849,22 @@ static void populateTypeConverter(TypeConverter &converter) { converter.addConversion( [](DoubleType type) { return FloatType::getF64(type.getContext()); }); - // Add a target materialization to fold away unrealized conversion casts. + // Add a target materialization such that the conversion does not fail when a + // type conversion could not be reconciled automatically by the framework. converter.addTargetMaterialization( [](OpBuilder &builder, Type type, ValueRange values, Location loc) { assert(values.size() == 1); - return values[0]; + return builder.create(loc, type, values[0]) + ->getResult(0); }); - // Add a source materialization to fold away unrealized conversion casts. + // Add a source materialization such that the conversion does not fail when a + // type conversion could not be reconciled automatically by the framework. converter.addSourceMaterialization( [](OpBuilder &builder, Type type, ValueRange values, Location loc) { assert(values.size() == 1); - return values[0]; + return builder.create(loc, type, values[0]) + ->getResult(0); }); }