Skip to content

Commit

Permalink
[FIRRTL] Change "lowerToBind" Attribute from boolean to unit (#3471)
Browse files Browse the repository at this point in the history
  • Loading branch information
maerhart authored Jul 4, 2022
1 parent a368244 commit 2715c2d
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion include/circt/Dialect/FIRRTL/FIRRTLDeclarations.td
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def InstanceOp : ReferableDeclOp<"instance", [HasParent<"firrtl::FModuleOp, firr
APIntAttr:$portDirections, StrArrayAttr:$portNames,
AnnotationArrayAttr:$annotations,
PortAnnotationsAttr:$portAnnotations,
BoolAttr:$lowerToBind,
UnitAttr:$lowerToBind,
OptionalAttr<InnerSymAttr>:$inner_sym);

let results = (outs Variadic<FIRRTLType>:$results);
Expand Down
9 changes: 3 additions & 6 deletions lib/Dialect/FIRRTL/FIRRTLOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,8 @@ void InstanceOp::build(OpBuilder &builder, OperationState &result,
direction::packAttribute(builder.getContext(), portDirections));
result.addAttribute("portNames", builder.getArrayAttr(portNames));
result.addAttribute("annotations", builder.getArrayAttr(annotations));
result.addAttribute("lowerToBind", builder.getBoolAttr(lowerToBind));
if (lowerToBind)
result.addAttribute("lowerToBind", builder.getUnitAttr());
if (innerSym)
result.addAttribute("inner_sym", innerSym);
result.addAttribute("nameKind",
Expand Down Expand Up @@ -1247,7 +1248,7 @@ void InstanceOp::build(OpBuilder &builder, OperationState &result,
NameKindEnumAttr::get(builder.getContext(), nameKind),
module.getPortDirectionsAttr(), module.getPortNamesAttr(),
builder.getArrayAttr(annotations), portAnnotationsAttr,
builder.getBoolAttr(lowerToBind),
lowerToBind ? builder.getUnitAttr() : UnitAttr(),
innerSym ? InnerSymAttr::get(innerSym) : InnerSymAttr());
}

Expand Down Expand Up @@ -1473,8 +1474,6 @@ void InstanceOp::print(OpAsmPrinter &p) {
"portDirections", "portNames",
"portTypes", "portAnnotations",
"inner_sym", "nameKind"};
if (!lowerToBind())
omittedAttrs.push_back("lowerToBind");
if (annotations().empty())
omittedAttrs.push_back("annotations");
p.printOptionalAttrDict((*this)->getAttrs(), omittedAttrs);
Expand Down Expand Up @@ -1545,8 +1544,6 @@ ParseResult InstanceOp::parse(OpAsmParser &parser, OperationState &result) {
// empty and false, respectively.
if (!resultAttrs.get("annotations"))
resultAttrs.append("annotations", parser.getBuilder().getArrayAttr({}));
if (!resultAttrs.get("lowerToBind"))
resultAttrs.append("lowerToBind", parser.getBuilder().getBoolAttr(false));

// Add result types.
result.types.reserve(portTypes.size());
Expand Down
3 changes: 2 additions & 1 deletion lib/Dialect/FIRRTL/Transforms/GrandCentral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1899,7 +1899,8 @@ void GrandCentralPass::runOnOperation() {
return true;
}

instance.getValue()->setAttr("lowerToBind", trueAttr);
instance.getValue()->setAttr("lowerToBind",
builder.getUnitAttr());
instance.getValue()->setAttr(
"output_file",
hw::OutputFileAttr::getFromFilename(
Expand Down
4 changes: 2 additions & 2 deletions test/Conversion/FIRRTLToHW/lower-to-hw.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -566,9 +566,9 @@ firrtl.circuit "Simple" attributes {annotations = [{class =
// CHECK-NEXT: hw.module private @bindTest()
firrtl.module private @bindTest() {
// CHECK: hw.instance "baz" sym @[[bazSymbol]] @bar
%baz = firrtl.instance baz {lowerToBind = true} @bar(in io_cpu_flush: !firrtl.uint<1>)
%baz = firrtl.instance baz {lowerToBind} @bar(in io_cpu_flush: !firrtl.uint<1>)
// CHECK: hw.instance "qux" sym @[[quxSymbol]] @bar
%qux = firrtl.instance qux {lowerToBind = true, output_file = #hw.output_file<"outputDir/bindings.sv", excludeFromFileList>} @bar(in io_cpu_flush: !firrtl.uint<1>)
%qux = firrtl.instance qux {lowerToBind, output_file = #hw.output_file<"outputDir/bindings.sv", excludeFromFileList>} @bar(in io_cpu_flush: !firrtl.uint<1>)
}


Expand Down
2 changes: 1 addition & 1 deletion test/Dialect/FIRRTL/errors.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ firrtl.hierpath @NLA1 []
firrtl.hierpath @NLA2 [@LowerToBind::@s1]
firrtl.module @InstanceLowerToBind() {}
firrtl.module @LowerToBind() {
firrtl.instance foo sym @s1 {lowerToBind = true} @InstanceLowerToBind()
firrtl.instance foo sym @s1 {lowerToBind} @InstanceLowerToBind()
}
}

Expand Down
4 changes: 2 additions & 2 deletions test/Dialect/FIRRTL/test.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ firrtl.module @VerbatimExpr() {
}

// CHECK-LABL: @LowerToBind
// CHECK: firrtl.instance foo sym @s1 {lowerToBind = true} @InstanceLowerToBind()
// CHECK: firrtl.instance foo sym @s1 {lowerToBind} @InstanceLowerToBind()
firrtl.module @InstanceLowerToBind() {}
firrtl.module @LowerToBind() {
firrtl.instance foo sym @s1 {lowerToBind = true} @InstanceLowerToBind()
firrtl.instance foo sym @s1 {lowerToBind} @InstanceLowerToBind()
}

// CHECK-LABEL: @ProbeTest
Expand Down

0 comments on commit 2715c2d

Please sign in to comment.