Skip to content

Commit a1929a1

Browse files
committed
[firrtl] Fix fprintf round trip issue
Fix a bug where the fprintf op would print in an incorrect way. This resulted in errors if trying to round trip it. Add a test of round tripping to prevent regressing. Signed-off-by: Schuyler Eldridge <[email protected]>
1 parent 9f7ae1e commit a1929a1

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/Dialect/FIRRTL/FIRRTLOps.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -6494,12 +6494,12 @@ void FPrintFOp::print(OpAsmPrinter &p) {
64946494
}
64956495
p << ", ";
64966496
p.printAttributeWithoutType(getFormatStringAttr());
6497-
printFPrintfAttrs(p, *this, (*this)->getAttrDictionary());
64986497
if (!getSubstitutions().empty()) {
64996498
p << "(";
65006499
p.printOperands(getSubstitutions());
65016500
p << ")";
65026501
}
6502+
printFPrintfAttrs(p, *this, (*this)->getAttrDictionary());
65036503
p << " : " << getClock().getType() << ", " << getCond().getType();
65046504
if (!getOutputFileSubstitutions().empty() || !getSubstitutions().empty()) {
65056505
for (auto type : getOperands().drop_front(2).getTypes()) {

test/Dialect/FIRRTL/round-trip.mlir

+10
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,14 @@ firrtl.module @FormatString() {
186186

187187
}
188188

189+
// CHECK-LABEL: firrtl.module @Fprintf
190+
firrtl.module @Fprintf(
191+
in %clock : !firrtl.clock,
192+
in %reset : !firrtl.reset,
193+
in %a : !firrtl.uint<1>
194+
) {
195+
// CHECK-NEXT: firrtl.fprintf %clock, %a, "test%d.txt"(%a), "%x, %b"(%a, %reset) {name = "foo"} : !firrtl.clock, !firrtl.uint<1>, !firrtl.uint<1>, !firrtl.uint<1>, !firrtl.reset
196+
firrtl.fprintf %clock, %a, "test%d.txt"(%a), "%x, %b"(%a, %reset) {name = "foo"} : !firrtl.clock, !firrtl.uint<1>, !firrtl.uint<1>, !firrtl.uint<1>, !firrtl.reset
197+
}
198+
189199
}

0 commit comments

Comments
 (0)