-
Notifications
You must be signed in to change notification settings - Fork 453
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow arrays of non-header types in frontend
Relax the requirement that IR::Type_Stack element types are headers, which allows using arrays of any type, though non-headers cannot support push/pop/last/next stuff which looks at header valid bits.
- Loading branch information
Showing
14 changed files
with
353 additions
and
8 deletions.
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
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; |
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,61 @@ | ||
#include <core.p4> | ||
#define V1MODEL_VERSION 20180101 | ||
#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<data_t>(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[7:0]; | ||
hdr.data.arr[1] = hdr.data.f1[15:8]; | ||
hdr.data.arr[2] = hdr.data.f1[23:16]; | ||
hdr.data.arr[3] = hdr.data.f1[31:24]; | ||
hdr.data.arr[4] = hdr.data.f2[7:0]; | ||
hdr.data.arr[5] = hdr.data.f2[15:8]; | ||
hdr.data.arr[6] = hdr.data.f2[23:16]; | ||
hdr.data.arr[7] = hdr.data.f2[31:24]; | ||
} | ||
} | ||
|
||
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<headers>(hdr); | ||
} | ||
} | ||
|
||
V1Switch<headers, metadata>(p(), vc(), ingress(), egress(), uc(), deparser()) main; |
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,61 @@ | ||
#include <core.p4> | ||
#define V1MODEL_VERSION 20180101 | ||
#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<data_t>(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[7:0]; | ||
hdr.data.arr[1] = hdr.data.f1[15:8]; | ||
hdr.data.arr[2] = hdr.data.f1[23:16]; | ||
hdr.data.arr[3] = hdr.data.f1[31:24]; | ||
hdr.data.arr[4] = hdr.data.f2[7:0]; | ||
hdr.data.arr[5] = hdr.data.f2[15:8]; | ||
hdr.data.arr[6] = hdr.data.f2[23:16]; | ||
hdr.data.arr[7] = hdr.data.f2[31:24]; | ||
} | ||
} | ||
|
||
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<headers>(hdr); | ||
} | ||
} | ||
|
||
V1Switch<headers, metadata>(p(), vc(), ingress(), egress(), uc(), deparser()) main; |
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,70 @@ | ||
#include <core.p4> | ||
#define V1MODEL_VERSION 20180101 | ||
#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<data_t>(hdr.data); | ||
transition accept; | ||
} | ||
} | ||
|
||
control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t stdmeta) { | ||
@hidden action array1l32() { | ||
hdr.data.arr[0] = hdr.data.f1[7:0]; | ||
hdr.data.arr[1] = hdr.data.f1[15:8]; | ||
hdr.data.arr[2] = hdr.data.f1[23:16]; | ||
hdr.data.arr[3] = hdr.data.f1[31:24]; | ||
hdr.data.arr[4] = hdr.data.f2[7:0]; | ||
hdr.data.arr[5] = hdr.data.f2[15:8]; | ||
hdr.data.arr[6] = hdr.data.f2[23:16]; | ||
hdr.data.arr[7] = hdr.data.f2[31:24]; | ||
} | ||
@hidden table tbl_array1l32 { | ||
actions = { | ||
array1l32(); | ||
} | ||
const default_action = array1l32(); | ||
} | ||
apply { | ||
tbl_array1l32.apply(); | ||
} | ||
} | ||
|
||
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<data_t>(hdr.data); | ||
} | ||
} | ||
|
||
V1Switch<headers, metadata>(p(), vc(), ingress(), egress(), uc(), deparser()) main; |
Oops, something went wrong.