-
Notifications
You must be signed in to change notification settings - Fork 298
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
[FIRRTL] Verify enabled layers of module, extmodule. #7557
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1694,23 +1694,51 @@ static LogicalResult verifyPortSymbolUses(FModuleLike module, | |
return success(); | ||
} | ||
|
||
static LogicalResult verifyEnabledLayers(FModuleLike module, | ||
SymbolTableCollection &symbolTable) { | ||
auto circuitOp = module->getParentOfType<CircuitOp>(); | ||
for (auto layer : module.getLayers()) { | ||
auto *op = | ||
symbolTable.lookupSymbolIn(circuitOp, cast<SymbolRefAttr>(layer)); | ||
if (!op) | ||
return module->emitOpError() << "enables unknown layer '" << layer << "'"; | ||
if (!isa<LayerOp>(op)) | ||
return module->emitOpError() | ||
.append("enables non-layer '", layer, "'") | ||
.attachNote(op->getLoc()) | ||
.append("expected layer"); | ||
} | ||
|
||
// Check public modules don't enable circuit-disabled layers. | ||
if (auto disabledLayers = circuitOp.getDisableLayersAttr()) { | ||
auto disabledLayersSymRefs = disabledLayers.getAsRange<SymbolRefAttr>(); | ||
if (module.isPublic()) { | ||
for (auto layer : module.getLayers()) | ||
if (llvm::is_contained(disabledLayersSymRefs, layer)) | ||
return module->emitOpError( | ||
"public module has circuit-disabled layer ") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is set membership sufficient, or do we need to walk and check if parent layer disabled....? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're going to have to check if a parent layer is disabled There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great, thanks! |
||
<< layer << " enabled"; | ||
} | ||
} | ||
|
||
return success(); | ||
} | ||
|
||
LogicalResult FModuleOp::verifySymbolUses(SymbolTableCollection &symbolTable) { | ||
if (failed( | ||
verifyPortSymbolUses(cast<FModuleLike>(getOperation()), symbolTable))) | ||
return failure(); | ||
|
||
auto circuitOp = (*this)->getParentOfType<CircuitOp>(); | ||
for (auto layer : getLayers()) { | ||
if (!symbolTable.lookupSymbolIn(circuitOp, cast<SymbolRefAttr>(layer))) | ||
return emitOpError() << "enables unknown layer '" << layer << "'"; | ||
} | ||
|
||
return success(); | ||
return verifyEnabledLayers(cast<FModuleLike>(getOperation()), symbolTable); | ||
} | ||
|
||
LogicalResult | ||
FExtModuleOp::verifySymbolUses(SymbolTableCollection &symbolTable) { | ||
return verifyPortSymbolUses(cast<FModuleLike>(getOperation()), symbolTable); | ||
if (failed( | ||
verifyPortSymbolUses(cast<FModuleLike>(getOperation()), symbolTable))) | ||
return failure(); | ||
|
||
return verifyEnabledLayers(cast<FModuleLike>(getOperation()), symbolTable); | ||
} | ||
|
||
LogicalResult | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only checks the final reference is a layer, but structural requirements on layers ensure all parents will also be layerop's.