-
Notifications
You must be signed in to change notification settings - Fork 366
[FIRRTL] Lint XMRs in the "design" #8668
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
Conversation
3ec3df5
to
6e96938
Compare
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.
If it was necessary to add a new pass to cache InstanceInfo can we just make linter pass circuit op pass? For this specific use case it's safe since Lint pass doesn't mutate operations and circuit passes are executed before and after Lint pass but it means you cannot put Lint pass to arbitrary place
@uenoku: That's the alternative way to proceed here. I was toying with this approach as it seemed beneficial to keep the |
6e96938
to
ebe9283
Compare
llvm::cl::opt<bool> lintStaticAsserts{ | ||
"lint-static-asserts", llvm::cl::desc("Lint static assertions"), | ||
llvm::cl::init(true)}; | ||
llvm::cl::opt<bool> lintXmrsInDesign{ | ||
"lint-xmrs-in-design", llvm::cl::desc("Lint XMRs in the design"), | ||
llvm::cl::init(true)}; |
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.
Do we need options to disable them? 🤔 I feel it's beneficial to run always.
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.
We get that for free with -lint-xmrs-in-design=0
/ -lint-xmrs-in-design=false
. This is slightly not great as users may not realize that they can disable these like that. WDYT?
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.
I think having options are good for me as long as there are use cases.
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.
LGTM
4c6f0f8
to
aba855f
Compare
Convert the FIRRTL linting pass to be a `CircuitOp` pass with internally handled parallelism. This is done in preparation to add XMR linting which requires an `InstanceInfo` analysis which needs to be on the `CircuitOp`. There are two ways of doing this: 1. Make the pass operate on the `CircuitOp` as this patch does. 2. Use a cached parent analysis which requires a dedicated pass to compute the `InstanceInfo` analysis and then careful pass pipeline structuring. (2): is used in one place in IREE and nowhere else. Additionally, (1) was suggested by multiple people in "Hallway Usabilty Testing"-type discussions. (Many people thought (2) was odd.) Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Make the linting of static assertions an option to the linter. While this appears unnecessary now, I am intending to add additional lint checks to the linter and I want to be able to turn each of them off if they become problematic. Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Expose an option to turn off/on the linting of trivially false assertions. This option defaults to "on" because this was the behavior originally. Also, I am intending to follow this going forward where lint checks are always on and have to be turned off. Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Extend the FIRRTL linter to check that there are no XMRs that will be located in the "design". This intentionally only checks for problems in the "design" and NOT the "effective design". This errs on the side of having more false negatives without introducing the possibility of false positives for separate compilation flows. Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Add an option to FIRRTL's linter that allows for disabling/enabling linting of XMRs that exist in the "design". Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Add an option to the `firtool` command line that allows for disabling/enabling the linting of XMRs that exist in the "design". While there is now a general policy of exposing each lint option in firtool, I am particularly nervous about this option as it has a high likelihood of causing problems (false positives). Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Refactor FIRRTL's Lint pass to use the ODS-generated constructor as opposed to hand-rolling one. This avoids weirdness where the command-line options have different defaults from what they are specified as in ODS and avoids the need for a "Config" struct inside the linter's namespace (as the ODS-generated one can be used). h/t @uenoku for the suggestion. Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
aba855f
to
09ea9da
Compare
Add an option to FIRRTL's linter (and expose it up to
firtool
) that willlint (error) if any XMRs exist in the "design". This is intended to catch
problems where downstream consumers of CIRCT-generated Verilog (e.g.,
Physical Design teams) get unexpected unsynthesizable XMRs in the design.
This is almost never what you want.
Unfortunately, this is highly error prone. It's difficult to tell what
is/is not the "design". This relies on the InstanceInfo analysis and
intentionally uses its notion of "design" and not "effective design". In
other words, this will only trigger this kind of linting if there is an
explicit
MarkDUTAnnotation
. It will not assume that the main module hasan implicit
MarkDUTAnnotation
. This is intended to avoid falsepositives.
In order to make this work, there is a lot of prequisite work batched in
this PR. A new pass, which only exists to run the
InstanceInfo
analysis(and thereby cache it) is created. This allows for use of the
getCachedParentAnalysis
function and guaranteeing that it will succeed.(This is a pattern borrowed from IREE.) Options are added for the
singular, existing lint check as well.
This PR is best reviewed as individual commits. I am intending to land
this as individual commits as well.