Skip to content

Commit 97c68a7

Browse files
committed
Inline more variables
1 parent d4474ed commit 97c68a7

File tree

2 files changed

+22
-32
lines changed

2 files changed

+22
-32
lines changed

lib/Conversion/FIRRTLToHW/LowerToHW.cpp

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,10 +1082,8 @@ void FIRRTLModuleLowering::emitInstanceChoiceIncludeFile(
10821082
}
10831083

10841084
// Create the emit.file operation at the top level
1085-
auto fileSymbolName = circuitNamespace.newName(includeFileName);
1086-
10871085
auto emitFile = emit::FileOp::create(builder, circuit.getLoc(),
1088-
includeFileName, fileSymbolName);
1086+
includeFileName, circuitNamespace.newName(includeFileName));
10891087
OpBuilder::InsertionGuard g(builder);
10901088
builder.setInsertionPointToStart(&emitFile.getBodyRegion().front());
10911089

@@ -1143,9 +1141,8 @@ void FIRRTLModuleLowering::emitInstanceChoiceIncludeFile(
11431141
}
11441142

11451143
// Set output file attribute .svh files should be excluded from file list
1146-
auto outputFileAttr = hw::OutputFileAttr::getFromFilename(
1147-
builder.getContext(), includeFileName, /*excludeFromFileList=*/true);
1148-
emitFile->setAttr("output_file", outputFileAttr);
1144+
emitFile->setAttr("output_file", hw::OutputFileAttr::getFromFilename(
1145+
builder.getContext(), includeFileName, /*excludeFromFileList=*/true));
11491146
}
11501147

11511148
/// Creates one include file per public module and option case following the
@@ -4246,16 +4243,14 @@ LogicalResult FIRRTLLowering::visitDecl(InstanceChoiceOp oldInstanceChoice) {
42464243
SmallVector<StringAttr> macroNames;
42474244
SmallVector<Operation *> altModules;
42484245
for (size_t i = 0, e = caseNames.size(); i < e; ++i) {
4249-
auto caseName = cast<SymbolRefAttr>(caseNames[i]).getLeafReference();
4250-
auto targetModuleRef = cast<FlatSymbolRefAttr>(moduleNames[i + 1]);
4251-
4252-
altModules.push_back(circuitState.getInstanceGraph()
4253-
.lookup(targetModuleRef.getAttr())
4254-
->getModule());
4246+
altModules.push_back(
4247+
circuitState.getInstanceGraph()
4248+
.lookup(cast<FlatSymbolRefAttr>(moduleNames[i + 1]).getAttr())
4249+
->getModule());
42554250

42564251
// Get the macro name for this option case using InstanceChoiceMacroTable.
4257-
auto optionCaseMacroRef =
4258-
circuitState.macroTable.getMacro(optionName, caseName);
4252+
auto optionCaseMacroRef = circuitState.macroTable.getMacro(
4253+
optionName, cast<SymbolRefAttr>(caseNames[i]).getLeafReference());
42594254
if (!optionCaseMacroRef)
42604255
return oldInstanceChoice->emitOpError(
42614256
"failed to get macro for option case");
@@ -4273,23 +4268,22 @@ LogicalResult FIRRTLLowering::visitDecl(InstanceChoiceOp oldInstanceChoice) {
42734268
[&](size_t index) {
42744269
auto caseSymRef =
42754270
cast<SymbolRefAttr>(caseNames[index]).getLeafReference();
4276-
auto inst =
4277-
createInstanceAndAssign(altModules[index], caseSymRef.getValue());
4278-
circuitState.addInstanceChoiceForCase(optionName, caseSymRef,
4279-
theModule.getNameAttr(),
4280-
instanceMacro, inst);
4271+
circuitState.addInstanceChoiceForCase(
4272+
optionName, caseSymRef, theModule.getNameAttr(), instanceMacro,
4273+
createInstanceAndAssign(altModules[index], caseSymRef.getValue()));
42814274
},
42824275
[&]() {
42834276
auto inst = createInstanceAndAssign(defaultModule, "default");
42844277
// Define the instance macro for the default case.
42854278
sv::IfDefOp::create(
42864279
builder, inst.getLoc(), instanceMacro, [&]() {},
42874280
[&]() {
4288-
auto array = builder.getArrayAttr(
4289-
{hw::InnerRefAttr::get(theModule.getNameAttr(),
4290-
inst.getInnerSymAttr().getSymName())});
4291-
sv::MacroDefOp::create(builder, inst.getLoc(), instanceMacro,
4292-
builder.getStringAttr("{{0}}"), array);
4281+
sv::MacroDefOp::create(
4282+
builder, inst.getLoc(), instanceMacro,
4283+
builder.getStringAttr("{{0}}"),
4284+
builder.getArrayAttr({hw::InnerRefAttr::get(
4285+
theModule.getNameAttr(),
4286+
inst.getInnerSymAttr().getSymName())}));
42934287
});
42944288
});
42954289

lib/Dialect/FIRRTL/FIRRTLUtils.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,14 +1225,10 @@ circt::firrtl::InstanceChoiceMacroTable::InstanceChoiceMacroTable(
12251225
if ((operation = dyn_cast<CircuitOp>(&op)))
12261226
break;
12271227

1228-
auto circuit = cast<CircuitOp>(operation);
1229-
for (auto option : circuit.getOps<OptionOp>()) {
1230-
for (auto optionCase : option.getOps<OptionCaseOp>()) {
1231-
auto optionName = option.getSymNameAttr();
1232-
auto caseName = optionCase.getSymNameAttr();
1233-
cache[{optionName, caseName}] = optionCase.getCaseMacroAttr();
1234-
}
1235-
}
1228+
for (auto option : cast<CircuitOp>(operation).getOps<OptionOp>())
1229+
for (auto optionCase : option.getOps<OptionCaseOp>())
1230+
cache[{option.getSymNameAttr(), optionCase.getSymNameAttr()}] =
1231+
optionCase.getCaseMacroAttr();
12361232
}
12371233

12381234
FlatSymbolRefAttr

0 commit comments

Comments
 (0)