[FIRRTLToHW] Copy "output_file" attr on FModuleOp

Copy an "output_file" attribute from a FIRRTL module to a HW module if
such an attribute exists.  This enables FIRRTL transforms to set output
file information in a FIRRTL pass, which may be necessary if such
information is available in an annotation that that pass consumes.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
This commit is contained in:
Schuyler Eldridge 2021-08-04 23:51:44 -04:00
parent db084be5b9
commit 0938ce4508
No known key found for this signature in database
GPG Key ID: 50C5E9936AAD536D
2 changed files with 17 additions and 1 deletions

View File

@ -726,7 +726,11 @@ FIRRTLModuleLowering::lowerModule(FModuleOp oldModule, Block *topLevelModule,
OpBuilder builder(topLevelModule->getParent()->getContext());
builder.setInsertionPointToEnd(topLevelModule);
auto nameAttr = builder.getStringAttr(oldModule.getName());
return builder.create<hw::HWModuleOp>(oldModule.getLoc(), nameAttr, ports);
auto newModule =
builder.create<hw::HWModuleOp>(oldModule.getLoc(), nameAttr, ports);
if (auto outputFile = oldModule->getAttr("output_file"))
newModule->setAttr("output_file", outputFile);
return newModule;
}
/// Given a value of analog type, check to see the only use of it is an attach.

View File

@ -406,6 +406,18 @@ firrtl.circuit "Simple" attributes {annotations = [{class =
%baz = firrtl.instance @bar {lowerToBind = true, name = "baz"} : !firrtl.uint<1>
}
// CHECK-LABEL: hw.module @output_fileTest
// CHECK-SAME: directory = "output_fileTest/dir", exclude_from_filelist = true
// CHECK-SAME: exclude_replicated_ops = true, name = "output_fileTest.sv"
firrtl.module @output_fileTest() attributes {output_file = {
directory = "output_fileTest/dir",
exclude_from_filelist = true,
exclude_replicated_ops = true,
name = "output_fileTest.sv"
}} {
}
// https://github.com/llvm/circt/issues/314
// CHECK-LABEL: hw.module @issue314
firrtl.module @issue314(in %inp_2: !firrtl.uint<27>, in %inpi: !firrtl.uint<65>) {