Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIRParser] Do not swallow stop ops when parsing FIR #6834

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions lib/Dialect/FIRRTL/Import/FIRParserAsserts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,23 +241,6 @@ ParseResult circt::firrtl::foldWhenEncodedVerifOp(PrintFOp printOp) {
auto opIt = std::next(printOp->getIterator());
auto opEnd = thenBlock.end();

// optional `stop(clock, enable, ...)`
//
// FIXME: Currently, we can't detetct stopOp in the following IR:
// when invCond:
// printf(io.clock, UInt<1>(1), "assert: ..")
// stop(io.clock, UInt<1>(1), 1)
// It is because `io.clock` will create another subfield op so StopOp is not
// the next operation. Also, we will have to modify `stopOp.clock() !=
// printOp.clock()` below since they are not CSEd.
if (opIt != opEnd) {
auto stopOp = dyn_cast<StopOp>(*opIt++);
if (!stopOp || opIt != opEnd || stopOp.getClock() != printOp.getClock() ||
stopOp.getCond() != printOp.getCond())
return success();
stopOp.erase();
}

// Detect if we're dealing with a verification statement, and what flavor of
// statement it is.
auto fmt = printOp.getFormatString();
Expand All @@ -281,6 +264,23 @@ ParseResult circt::firrtl::foldWhenEncodedVerifOp(PrintFOp printOp) {
else
return success();

// optional `stop(clock, enable, ...)`
//
// FIXME: Currently, we can't detetct stopOp in the following IR:
// when invCond:
// printf(io.clock, UInt<1>(1), "assert: ..")
// stop(io.clock, UInt<1>(1), 1)
// It is because `io.clock` will create another subfield op so StopOp is not
// the next operation. Also, we will have to modify `stopOp.clock() !=
// printOp.clock()` below since they are not CSEd.
if (opIt != opEnd) {
auto stopOp = dyn_cast<StopOp>(*opIt++);
if (!stopOp || opIt != opEnd || stopOp.getClock() != printOp.getClock() ||
stopOp.getCond() != printOp.getCond())
return success();
stopOp.erase();
}

// Check if the condition of the `WhenOp` is a trivial inversion operation,
// and remove any immediately preceding verification ops that ensure this
// condition. This caters to the following pattern emitted by Chisel:
Expand Down
1 change: 1 addition & 0 deletions test/firtool/stop.fir
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ circuit StopAndFinishTest:
; CHECK: }
; CHECK: }

printf(clock, cond, "Stop message")
stop(clock, cond, 0)
stop(clock, cond, 1)
Loading