-
Notifications
You must be signed in to change notification settings - Fork 442
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
[P4Testgen] Add a compiler pass to resolve Type_Name in StructExpressions. #4215
Conversation
a4492e8
to
9052ad1
Compare
@mihaibudiu I updated the constructor to include an optional |
this can't be the whole PR, there is no use of this flag. |
The flag is used in #4231 and #4255. And an extension which is not part of the main repository here: https://github.com/fruffy/flay I factored out the change to make the PR more readable. I could add a compiler pass which resolves |
The pass which resolves the name is called ResolveReferences, it's perhaps the oldest pass in the compiler. |
ir/expression.def
Outdated
@@ -470,7 +470,7 @@ class StructExpression : Expression { | |||
validate { | |||
components.check_null(); components.validate(); | |||
BUG_CHECK(structType == nullptr || structType->is<IR::Type_Name>() || | |||
structType->is<IR::Type_Specialized>(), | |||
structType->is<IR::Type_Specialized>() || structType->is<IR::Type_StructLike>(), |
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.
why do you want this?
There is a difference between a struct declaration (Type_Struct) and a reference to a type by name (Type_Name).
It is more annoying to have to resolve the type everytime, but it is the right distinction.
Without this many passes would break.
Perhaps the type
field holds the information you want.
Thanks! The idea is to resolve all |
Various backends execute additional transformation passes after the mid-end. |
9052ad1
to
192c6cc
Compare
@mihaibudiu I believe I found a more palatable solution which does not affect the ir or the rest of the compiler. When resolving struct expressions, I simply preserve Type_Name for It essentially exploits the inconsistency of |
In some cases, one may want to create a struct expression, which contains the relevant type directly, without having to use aType_Name
as indirection. This PR relaxes the constraints around the creation of struct expressions to make this possible. We simply add a new parameter that allows us to toggle whether or not to acceptIR::Type_StructLike
types.When resolving struct expressions, simply preserve Type_Name for structType but assign the resolved type to type. This works for all dependent PRs and preserves functionality of passes such as toP4 etc.