-
Notifications
You must be signed in to change notification settings - Fork 449
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
Generalized array support #5115
Open
ChrisDodd
wants to merge
3
commits into
p4lang:main
Choose a base branch
from
ChrisDodd:cdodd-array
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ control p() { | |
h b = stack[1231092310293]; | ||
h c = stack[-2]; | ||
h d = stack[6]; | ||
s e = stack1.next; | ||
} | ||
} | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
stack_e.p4(23): [--Werror=type-error] error: Header stack struct s[5] used with non-header type struct s | ||
s[5] stack1; // non-header illegal in header stack | ||
^^^^ | ||
stack_e.p4(26): [--Werror=overlimit] error: 1231092310293: Value too large for int | ||
h b = stack[1231092310293]; | ||
^^^^^^^^^^^^^ | ||
stack_e.p4(29): [--Werror=type-error] error: stack1.next: 'next' can only be used on header stacks | ||
s e = stack1.next; | ||
^^^^^^^^^^^ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#include <core.p4> | ||
#include <v1model.p4> | ||
|
||
header data_t { | ||
bit<32> f1; | ||
bit<32> f2; | ||
bit<16> h1; | ||
bit<16> h2; | ||
bit<8>[16] arr; | ||
} | ||
|
||
struct metadata {} | ||
|
||
struct headers { | ||
data_t data; | ||
} | ||
|
||
parser p(packet_in b, | ||
out headers hdr, | ||
inout metadata meta, | ||
inout standard_metadata_t stdmeta) { | ||
state start { | ||
b.extract(hdr.data); | ||
transition accept; | ||
} | ||
} | ||
|
||
control ingress(inout headers hdr, | ||
inout metadata meta, | ||
inout standard_metadata_t stdmeta) { | ||
apply { | ||
hdr.data.arr[0] = hdr.data.f1[0+:8]; | ||
hdr.data.arr[1] = hdr.data.f1[8+:8]; | ||
hdr.data.arr[2] = hdr.data.f1[16+:8]; | ||
hdr.data.arr[3] = hdr.data.f1[24+:8]; | ||
hdr.data.arr[4] = hdr.data.f2[0+:8]; | ||
hdr.data.arr[5] = hdr.data.f2[8+:8]; | ||
hdr.data.arr[6] = hdr.data.f2[16+:8]; | ||
hdr.data.arr[7] = hdr.data.f2[24+:8]; | ||
} | ||
} | ||
|
||
control egress(inout headers hdr, | ||
inout metadata meta, | ||
inout standard_metadata_t stdmeta) { | ||
apply {} | ||
} | ||
|
||
control vc(inout headers hdr, | ||
inout metadata meta) { | ||
apply {} | ||
} | ||
|
||
control uc(inout headers hdr, | ||
inout metadata meta) { | ||
apply {} | ||
} | ||
|
||
control deparser(packet_out packet, | ||
in headers hdr) { | ||
apply { | ||
packet.emit(hdr); | ||
} | ||
} | ||
|
||
V1Switch<headers, metadata>(p(), | ||
vc(), | ||
ingress(), | ||
egress(), | ||
uc(), | ||
deparser()) main; |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Could you please add positive and/or error test cases similar to the following to demonstrate what is expected when the array type is an array type or contains array types?
and (if the grammar allows it (I did not look very closely at changes to
p4parser.ypp
)):