Add initial support for header instances#292
Open
PietroGhg wants to merge 2 commits intop4lang:mainfrom
Open
Conversation
20b3311 to
b519c2c
Compare
8427885 to
280e754
Compare
554fa63 to
30b942f
Compare
Signed-off-by: Pietro Ghiglio <pghiglio@accesssoftek.com>
30b942f to
f1b75ac
Compare
Signed-off-by: Pietro Ghiglio <pghiglio@accesssoftek.com>
f1b75ac to
bdd2406
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a
LowerToHeaderInstancepass that adds header instances to the module. In BMv2, header instances represent data coming from either P4 headers or structs. We add header instances starting from parser args (support for controls arguments and control locals will be added in a follow up PR) or local variables.The pass assumes that structs contain only scalars or headers (so no other structs), and works by "splitting" structs so that we end up generating one header instance for each separate header field in the struct, while keeping all the scalar arguments in the same struct.
Header instances are globals, so we access them via a
SymbolToValueop.This PR also changes ops that refer to header instances to use
SymRefAttrsinstead of raw strings, and adds a couple new ops/lowering patterns that are used when testing.