-
Notifications
You must be signed in to change notification settings - Fork 138
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
Add preprocessor option to interpret translate_on/off pragmas #1100
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1100 +/- ##
=======================================
Coverage 94.76% 94.76%
=======================================
Files 191 191
Lines 47743 47771 +28
=======================================
+ Hits 45243 45271 +28
Misses 2500 2500
Continue to review full report in Codecov by Sentry.
|
|
||
/// A flag to enable the interpretation of non-standard line comment | ||
/// pragmas within the preprocessor. | ||
bool enableCompatPragmas = false; |
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.
Is it assumed that these options can only be used from the API?
I think it would be useful to use them from the slang cli interface as well
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.
Right now I am setting these with a downstream patch to Driver.cpp
. For yosys-slang I think we want it on by default, possibly with a cli option to change the regexes or disable it.
If we can agree on standard slang options for this (with yosys-slang having it on by default, vanilla slang having it off by default), that would be great
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 we can agree on standard slang options for this
By that I mean the cli of course
The Lexer already has an optional path for checking for pragma comments -- see Lexer::scanLineComment and scanProtectComment. Can this functionality be put there as well instead of adding a new branch in the preprocessor? Also how necessary is the regex behavior? Can a substring match be used instead? I ask because std::regex is notoriously slow -- if full regex functionality is required we probably want to at least provide the option of pulling in a performant 3rd party regex lib. |
It can though I think we want to collect the full comment line before we try to match it against the user-provided list of pragmas -- both for the off pragma and the on pragma. On the other hand the protect stuff is matched verbatim. So the new functionality can be moved to the Lexer but I think it would involve a new branch there too.
I don't think a simple substring match would cut it but if we write something simple which would bridge over any whitespacing differences in matching against the known pragma list then that would work. In any case rolling out custom matching sounds simpler than setting up the infrastructure for optional 3rd party regex libs. |
@MikePopoloski should I move the detection to the Lexer? |
Yes, I think so. I'd like to keep all comment parsing isolated to that one branch if possible. |
If we're going for legacy, you also have |
The detection is configurable and accounts for those too. There's no set of pragmas which is hard-coded in the patch. |
Going to close this out for now. Feel free to reopen if you modify the approach, or open an issue if you want me to look into it when I get some spare cycles. |
For synthesis tools based on slang, add a preprocessor option to interpret pragmas like
Given the non-standard nature of the pragmas, make the exact regex a preprocessor option.
Related: povik/yosys-slang#28