-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix lint warning, and add one more successful test program
Signed-off-by: Andy Fingerhut <[email protected]>
- Loading branch information
1 parent
55da2c3
commit d67df83
Showing
9 changed files
with
712 additions
and
1 deletion.
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
152 changes: 152 additions & 0 deletions
152
testdata/p4_16_samples/actions-almost-duplicate-names1.p4
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,152 @@ | ||
/* | ||
Copyright 2024 Cisco Systems, Inc. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
#include <core.p4> | ||
#include <v1model.p4> | ||
|
||
typedef bit<48> EthernetAddress; | ||
|
||
header ethernet_t { | ||
EthernetAddress dstAddr; | ||
EthernetAddress srcAddr; | ||
bit<16> etherType; | ||
} | ||
|
||
struct headers_t { | ||
ethernet_t ethernet; | ||
} | ||
|
||
struct metadata_t { | ||
} | ||
|
||
parser parserImpl( | ||
packet_in pkt, | ||
out headers_t hdr, | ||
inout metadata_t meta, | ||
inout standard_metadata_t stdmeta) | ||
{ | ||
state start { | ||
pkt.extract(hdr.ethernet); | ||
transition accept; | ||
} | ||
} | ||
|
||
control verifyChecksum( | ||
inout headers_t hdr, | ||
inout metadata_t meta) | ||
{ | ||
apply { } | ||
} | ||
|
||
action foo1() { | ||
} | ||
|
||
@name("foo2") | ||
action foo2() { | ||
} | ||
|
||
@name(".baz") | ||
action foo3() { | ||
} | ||
|
||
control ingressImpl( | ||
inout headers_t hdr, | ||
inout metadata_t meta, | ||
inout standard_metadata_t stdmeta) | ||
{ | ||
bit<8> tmp1; | ||
bit<8> tmp2; | ||
|
||
// This is not a name conflict with foo1, because it has a top | ||
// level name ".foo1", but a1 will have hierarchical name | ||
// "ingressImpl.foo1". | ||
@name("foo1") action a1 (bit<8> x, bit<8> y) { tmp1 = x >> 1; tmp2 = y; } | ||
|
||
// This should not be a name conflict with foo2, because it has a | ||
// top level name ".foo2", but a2 will have hierarchical name | ||
// "ingressImpl.foo2". | ||
// TODO: However, it is a @name conflict in the current p4c | ||
// implementation until a PR like #4970 is merged in. | ||
//@name("foo2") action a2 (bit<8> x, bit<8> y) { tmp1 = x >> 2; tmp2 = y; } | ||
|
||
@name(".bar") action a3 (bit<8> x, bit<8> y) { tmp1 = x >> 3; tmp2 = y; } | ||
// This is not a name conflict with a3, because it has a top level | ||
// name ".bar", but a4 will have hierarchical name | ||
// "ingressImpl.bar". | ||
@name("bar") action a4 (bit<8> x, bit<8> y) { tmp1 = x >> 4; tmp2 = y; } | ||
|
||
// This is not a name conflict with foo3, because it has a top | ||
// level name ".baz", but a5 will have hierarchical name | ||
// "ingressImpl.baz". | ||
@name("baz") action a5 (bit<8> x, bit<8> y) { tmp1 = x >> 5; tmp2 = y; } | ||
|
||
table t1 { | ||
actions = { | ||
NoAction; | ||
a1; | ||
//a2; | ||
a3; | ||
a4; | ||
a5; | ||
foo1; | ||
foo2; | ||
foo3; | ||
} | ||
key = { hdr.ethernet.etherType: exact; } | ||
default_action = NoAction(); | ||
size = 512; | ||
} | ||
apply { | ||
tmp1 = hdr.ethernet.srcAddr[7:0]; | ||
tmp2 = hdr.ethernet.dstAddr[7:0]; | ||
t1.apply(); | ||
// This is here simply to ensure that the compiler cannot | ||
// optimize away the effects of t1 and t2, which can only | ||
// assign values to variables tmp1 and tmp2. | ||
hdr.ethernet.etherType = (bit<16>) (tmp1 - tmp2); | ||
} | ||
} | ||
|
||
control egressImpl( | ||
inout headers_t hdr, | ||
inout metadata_t meta, | ||
inout standard_metadata_t stdmeta) | ||
{ | ||
apply { } | ||
} | ||
|
||
control updateChecksum( | ||
inout headers_t hdr, | ||
inout metadata_t meta) | ||
{ | ||
apply { } | ||
} | ||
|
||
control deparserImpl( | ||
packet_out pkt, | ||
in headers_t hdr) | ||
{ | ||
apply { | ||
pkt.emit(hdr.ethernet); | ||
} | ||
} | ||
|
||
V1Switch(parserImpl(), | ||
verifyChecksum(), | ||
ingressImpl(), | ||
egressImpl(), | ||
updateChecksum(), | ||
deparserImpl()) main; |
97 changes: 97 additions & 0 deletions
97
testdata/p4_16_samples_outputs/actions-almost-duplicate-names1-first.p4
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,97 @@ | ||
#include <core.p4> | ||
#define V1MODEL_VERSION 20180101 | ||
#include <v1model.p4> | ||
|
||
typedef bit<48> EthernetAddress; | ||
header ethernet_t { | ||
EthernetAddress dstAddr; | ||
EthernetAddress srcAddr; | ||
bit<16> etherType; | ||
} | ||
|
||
struct headers_t { | ||
ethernet_t ethernet; | ||
} | ||
|
||
struct metadata_t { | ||
} | ||
|
||
parser parserImpl(packet_in pkt, out headers_t hdr, inout metadata_t meta, inout standard_metadata_t stdmeta) { | ||
state start { | ||
pkt.extract<ethernet_t>(hdr.ethernet); | ||
transition accept; | ||
} | ||
} | ||
|
||
control verifyChecksum(inout headers_t hdr, inout metadata_t meta) { | ||
apply { | ||
} | ||
} | ||
|
||
action foo1() { | ||
} | ||
@name("foo2") action foo2() { | ||
} | ||
@name(".baz") action foo3() { | ||
} | ||
control ingressImpl(inout headers_t hdr, inout metadata_t meta, inout standard_metadata_t stdmeta) { | ||
bit<8> tmp1; | ||
bit<8> tmp2; | ||
@name("foo1") action a1(bit<8> x, bit<8> y) { | ||
tmp1 = x >> 1; | ||
tmp2 = y; | ||
} | ||
@name(".bar") action a3(bit<8> x, bit<8> y) { | ||
tmp1 = x >> 3; | ||
tmp2 = y; | ||
} | ||
@name("bar") action a4(bit<8> x, bit<8> y) { | ||
tmp1 = x >> 4; | ||
tmp2 = y; | ||
} | ||
@name("baz") action a5(bit<8> x, bit<8> y) { | ||
tmp1 = x >> 5; | ||
tmp2 = y; | ||
} | ||
table t1 { | ||
actions = { | ||
NoAction(); | ||
a1(); | ||
a3(); | ||
a4(); | ||
a5(); | ||
foo1(); | ||
foo2(); | ||
foo3(); | ||
} | ||
key = { | ||
hdr.ethernet.etherType: exact @name("hdr.ethernet.etherType"); | ||
} | ||
default_action = NoAction(); | ||
size = 512; | ||
} | ||
apply { | ||
tmp1 = hdr.ethernet.srcAddr[7:0]; | ||
tmp2 = hdr.ethernet.dstAddr[7:0]; | ||
t1.apply(); | ||
hdr.ethernet.etherType = (bit<16>)(tmp1 - tmp2); | ||
} | ||
} | ||
|
||
control egressImpl(inout headers_t hdr, inout metadata_t meta, inout standard_metadata_t stdmeta) { | ||
apply { | ||
} | ||
} | ||
|
||
control updateChecksum(inout headers_t hdr, inout metadata_t meta) { | ||
apply { | ||
} | ||
} | ||
|
||
control deparserImpl(packet_out pkt, in headers_t hdr) { | ||
apply { | ||
pkt.emit<ethernet_t>(hdr.ethernet); | ||
} | ||
} | ||
|
||
V1Switch<headers_t, metadata_t>(parserImpl(), verifyChecksum(), ingressImpl(), egressImpl(), updateChecksum(), deparserImpl()) main; |
99 changes: 99 additions & 0 deletions
99
testdata/p4_16_samples_outputs/actions-almost-duplicate-names1-frontend.p4
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,99 @@ | ||
#include <core.p4> | ||
#define V1MODEL_VERSION 20180101 | ||
#include <v1model.p4> | ||
|
||
typedef bit<48> EthernetAddress; | ||
header ethernet_t { | ||
EthernetAddress dstAddr; | ||
EthernetAddress srcAddr; | ||
bit<16> etherType; | ||
} | ||
|
||
struct headers_t { | ||
ethernet_t ethernet; | ||
} | ||
|
||
struct metadata_t { | ||
} | ||
|
||
parser parserImpl(packet_in pkt, out headers_t hdr, inout metadata_t meta, inout standard_metadata_t stdmeta) { | ||
state start { | ||
pkt.extract<ethernet_t>(hdr.ethernet); | ||
transition accept; | ||
} | ||
} | ||
|
||
control verifyChecksum(inout headers_t hdr, inout metadata_t meta) { | ||
apply { | ||
} | ||
} | ||
|
||
control ingressImpl(inout headers_t hdr, inout metadata_t meta, inout standard_metadata_t stdmeta) { | ||
@name("ingressImpl.tmp1") bit<8> tmp1_0; | ||
@name("ingressImpl.tmp2") bit<8> tmp2_0; | ||
@noWarn("unused") @name(".NoAction") action NoAction_1() { | ||
} | ||
@name(".foo1") action foo1_0() { | ||
} | ||
@name("ingressImpl.foo2") action foo2_0() { | ||
} | ||
@name(".baz") action foo3_0() { | ||
} | ||
@name("ingressImpl.foo1") action a1(@name("x") bit<8> x, @name("y") bit<8> y) { | ||
tmp1_0 = x >> 1; | ||
tmp2_0 = y; | ||
} | ||
@name(".bar") action a3(@name("x") bit<8> x_4, @name("y") bit<8> y_4) { | ||
tmp1_0 = x_4 >> 3; | ||
tmp2_0 = y_4; | ||
} | ||
@name("ingressImpl.bar") action a4(@name("x") bit<8> x_5, @name("y") bit<8> y_5) { | ||
tmp1_0 = x_5 >> 4; | ||
tmp2_0 = y_5; | ||
} | ||
@name("ingressImpl.baz") action a5(@name("x") bit<8> x_6, @name("y") bit<8> y_6) { | ||
tmp1_0 = x_6 >> 5; | ||
tmp2_0 = y_6; | ||
} | ||
@name("ingressImpl.t1") table t1_0 { | ||
actions = { | ||
NoAction_1(); | ||
a1(); | ||
a3(); | ||
a4(); | ||
a5(); | ||
foo1_0(); | ||
foo2_0(); | ||
foo3_0(); | ||
} | ||
key = { | ||
hdr.ethernet.etherType: exact @name("hdr.ethernet.etherType"); | ||
} | ||
default_action = NoAction_1(); | ||
size = 512; | ||
} | ||
apply { | ||
tmp1_0 = hdr.ethernet.srcAddr[7:0]; | ||
tmp2_0 = hdr.ethernet.dstAddr[7:0]; | ||
t1_0.apply(); | ||
hdr.ethernet.etherType = (bit<16>)(tmp1_0 - tmp2_0); | ||
} | ||
} | ||
|
||
control egressImpl(inout headers_t hdr, inout metadata_t meta, inout standard_metadata_t stdmeta) { | ||
apply { | ||
} | ||
} | ||
|
||
control updateChecksum(inout headers_t hdr, inout metadata_t meta) { | ||
apply { | ||
} | ||
} | ||
|
||
control deparserImpl(packet_out pkt, in headers_t hdr) { | ||
apply { | ||
pkt.emit<ethernet_t>(hdr.ethernet); | ||
} | ||
} | ||
|
||
V1Switch<headers_t, metadata_t>(parserImpl(), verifyChecksum(), ingressImpl(), egressImpl(), updateChecksum(), deparserImpl()) main; |
Oops, something went wrong.