forked from p4lang/p4c
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix p4lang#4969 by modifying pass LocalizeActions
so that it prepends a "." to @name annotations of global actions, if they do not have one already. Signed-off-by: Andy Fingerhut <[email protected]>
- Loading branch information
1 parent
da04995
commit 682564b
Showing
9 changed files
with
463 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
Copyright 2022 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("bar") action foo2() { | ||
} | ||
|
||
control ingressImpl( | ||
inout headers_t hdr, | ||
inout metadata_t meta, | ||
inout standard_metadata_t stdmeta) | ||
|
||
{ | ||
table t1 { | ||
actions = { NoAction; foo1; foo2; } | ||
key = { hdr.ethernet.etherType: exact; } | ||
default_action = NoAction(); | ||
size = 512; | ||
} | ||
apply { | ||
t1.apply(); | ||
} | ||
} | ||
|
||
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; |
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,69 @@ | ||
#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("bar") action foo2() { | ||
} | ||
control ingressImpl(inout headers_t hdr, inout metadata_t meta, inout standard_metadata_t stdmeta) { | ||
table t1 { | ||
actions = { | ||
NoAction(); | ||
foo1(); | ||
foo2(); | ||
} | ||
key = { | ||
hdr.ethernet.etherType: exact @name("hdr.ethernet.etherType"); | ||
} | ||
default_action = NoAction(); | ||
size = 512; | ||
} | ||
apply { | ||
t1.apply(); | ||
} | ||
} | ||
|
||
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; |
71 changes: 71 additions & 0 deletions
71
testdata/p4_16_samples_outputs/issue-4969-bmv2-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,71 @@ | ||
#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) { | ||
@noWarn("unused") @name(".NoAction") action NoAction_1() { | ||
} | ||
@name(".foo1") action foo1_0() { | ||
} | ||
@name(".bar") action foo2_0() { | ||
} | ||
@name("ingressImpl.t1") table t1_0 { | ||
actions = { | ||
NoAction_1(); | ||
foo1_0(); | ||
foo2_0(); | ||
} | ||
key = { | ||
hdr.ethernet.etherType: exact @name("hdr.ethernet.etherType"); | ||
} | ||
default_action = NoAction_1(); | ||
size = 512; | ||
} | ||
apply { | ||
t1_0.apply(); | ||
} | ||
} | ||
|
||
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; |
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 ethernet_t { | ||
bit<48> dstAddr; | ||
bit<48> 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) { | ||
@noWarn("unused") @name(".NoAction") action NoAction_1() { | ||
} | ||
@name(".foo1") action foo1_0() { | ||
} | ||
@name(".bar") action foo2_0() { | ||
} | ||
@name("ingressImpl.t1") table t1_0 { | ||
actions = { | ||
NoAction_1(); | ||
foo1_0(); | ||
foo2_0(); | ||
} | ||
key = { | ||
hdr.ethernet.etherType: exact @name("hdr.ethernet.etherType"); | ||
} | ||
default_action = NoAction_1(); | ||
size = 512; | ||
} | ||
apply { | ||
t1_0.apply(); | ||
} | ||
} | ||
|
||
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.