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
Reserved identifiers #929
Comments
I might be wrong, but I think that it is better to have these version constants to be The rationale is that they really need to be examined at the compile-time and typically Obviously, if we change these version constants to become CPP defines, the problem at hand will go away on its own :) |
The main issue with macros is that they are not represented in the compiler IR. They only exist in the preprocessor, and after substitution they completely disappear. So having a const is one way to preserve these values throughout the compilation process. |
I'm confused... as a CPP define, the compiler has even less visibility. The version becomes just another integer literal. Isn't that a step in the wrong direction? |
Looks like @mbudiu-vmw beat me to it. |
The point is that in practice, these constants are used to modify the code before it is fed into the compiler, meaning that we want to see in the IR only whatever is left and not to see in the IR anything that we actually want to remove. Also, for example, imagine the situation where you are using an extern, defined in one version of the architecture and not defined in another one (or, perhaps, the definitions are not quite the same). You cannot use an This is a general issue that goes beyond just the version constants. If you want, we can always have a compromise where you define both, but that is not going to help with the original problem :) I have tons of programs that have many different variations/profiles. Sometimes |
Personnel
Design
Implementation
p4-spec
:p4c
: Make v1model immutable p4c#2706Process
p4-spec
:p4c
:======================
This discussion p4lang/p4c#2706 made it clear that the compiler needs to handle some identifiers specially.
For example, __v1model_version is used to store the version of the v1model.p4 used, and the compiler should not delete this constant declaration even if it is dead, since the back-end depends on it to generate code, and the toP4 pass uses it to generate the proper macro before including v1model.p4. The PR cited assumes that all global identifiers starting with __ are reserved, but the spec does not codify this anywhere.
The text was updated successfully, but these errors were encountered: