Skip to content

Commit

Permalink
Inliner: include op name for clarity.
Browse files Browse the repository at this point in the history
This especially helps when the location points to a construct
we've lowered to something else (e.g., layerblock -> sv.ifdef).
  • Loading branch information
dtzSiFive committed Jul 29, 2024
1 parent 8d28e82 commit e7ce11d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 5 additions & 3 deletions lib/Dialect/FIRRTL/Transforms/ModuleInliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,8 @@ LogicalResult Inliner::inliningWalk(
return success();
})
.Default([&](Operation *op) {
return op->emitError("unsupported operation cannot be inlined");
return op->emitError("unsupported operation '")
<< op->getName() << "' cannot be inlined";
});
if (failed(result))
return failure();
Expand All @@ -1040,8 +1041,9 @@ LogicalResult Inliner::checkInstanceParents(InstanceOp instance) {
while (!isa<FModuleLike>(parent)) {
if (!isa<LayerBlockOp>(parent))
return instance->emitError("cannot inline instance")
.attachNote(parent->getLoc())
<< "containing operation not safe to inline into";
.attachNote(parent->getLoc())
<< "containing operation '" << parent->getName()
<< "' not safe to inline into";
parent = parent->getParentOp();
}
return success();
Expand Down
8 changes: 4 additions & 4 deletions test/Dialect/FIRRTL/inliner-errors.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
firrtl.circuit "InlineIntoWhen" {
firrtl.module private @Child () attributes {annotations = [{class = "firrtl.passes.InlineAnnotation"}]} {}
firrtl.module @InlineIntoWhen(in %cond : !firrtl.uint<1>) {
// expected-note @below {{containing operation not safe to inline into}}
// expected-note @below {{containing operation 'firrtl.when' not safe to inline into}}
firrtl.when %cond : !firrtl.uint<1> {
// expected-error @below {{cannot inline instance}}
firrtl.instance c @Child()
Expand All @@ -20,7 +20,7 @@ firrtl.circuit "InlineIntoWhen" {
firrtl.circuit "FlattenThroughWhen" {
firrtl.module private @GChild () {}
firrtl.module private @Child (in %cond : !firrtl.uint<1>) {
// expected-note @below {{containing operation not safe to inline into}}
// expected-note @below {{containing operation 'firrtl.when' not safe to inline into}}
firrtl.when %cond : !firrtl.uint<1> {
// expected-error @below {{cannot inline instance}}
firrtl.instance c @GChild()
Expand All @@ -40,7 +40,7 @@ firrtl.circuit "InlineIntoIfdef" {
sv.macro.decl @A_0["A"]
firrtl.module private @Child () attributes {annotations = [{class = "firrtl.passes.InlineAnnotation"}]} {}
firrtl.module @InlineIntoIfdef() {
// expected-note @below {{containing operation not safe to inline into}}
// expected-note @below {{containing operation 'sv.ifdef' not safe to inline into}}
sv.ifdef @A_0 {
// expected-error @below {{cannot inline instance}}
firrtl.instance c @Child()
Expand All @@ -55,7 +55,7 @@ firrtl.circuit "InlineIntoIfdef" {
firrtl.circuit "InlineIfdef" {
sv.macro.decl @A_0["A"]
firrtl.module private @Child () attributes {annotations = [{class = "firrtl.passes.InlineAnnotation"}]} {
// expected-error @below {{unsupported operation cannot be inlined}}
// expected-error @below {{unsupported operation 'sv.ifdef' cannot be inlined}}
sv.ifdef @A_0 { }
}
firrtl.module @InlineIfdef() {
Expand Down

0 comments on commit e7ce11d

Please sign in to comment.