Skip to content

Commit 515c2f3

Browse files
mbudiu-vmwChris Dodd
mbudiu-vmw
authored and
Chris Dodd
committed
Fix for issue ##136
1 parent 0364864 commit 515c2f3

File tree

8 files changed

+287
-4
lines changed

8 files changed

+287
-4
lines changed

frontends/common/resolveReferences/resolveReferences.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ ResolutionContext::resolve(IR::ID name, P4::ResolutionType type, bool previousOn
6969

7070
auto vector = decls->toVector();
7171
if (!vector->empty()) {
72-
LOG2("Resolved in " << current->getNode());
72+
LOG2("Resolved in " << dbp(current->getNode()));
7373
return vector;
7474
} else {
7575
continue;
@@ -105,7 +105,7 @@ ResolutionContext::resolve(IR::ID name, P4::ResolutionType type, bool previousOn
105105
continue;
106106
}
107107

108-
LOG2("Resolved in " << current->getNode());
108+
LOG2("Resolved in " << dbp(current->getNode()));
109109
auto result = new std::vector<const IR::IDeclaration*>();
110110
result->push_back(decl);
111111
return result;

midend/actionSynthesis.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ const IR::Node* DoMoveActionsToTables::postorder(IR::MethodCallStatement* statem
4444
// Action invocation
4545
BUG_CHECK(ac->expr->method->is<IR::PathExpression>(),
4646
"%1%: Expected a PathExpression", ac->expr->method);
47-
auto actionPath = new IR::PathExpression(ac->action->name);
48-
auto call = new IR::MethodCallExpression(Util::SourceInfo(), actionPath,
47+
auto actionPath = new IR::PathExpression(IR::ID(mc->srcInfo, ac->action->name));
48+
auto call = new IR::MethodCallExpression(mc->srcInfo, actionPath,
4949
new IR::Vector<IR::Type>(), directionArgs);
5050
auto actinst = new IR::ActionListElement(statement->srcInfo, IR::Annotations::empty, call);
5151
auto actions = new IR::IndexedVector<IR::ActionListElement>();
+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
Copyright 2016 VMware, Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
#include <core.p4>
18+
#include <v1model.p4>
19+
20+
struct H { };
21+
struct M { };
22+
23+
parser ParserI(packet_in pk, out H hdr, inout M meta, inout standard_metadata_t smeta) {
24+
state start { transition accept; }
25+
}
26+
27+
control Aux(inout M meta) {
28+
action a() {}
29+
apply {
30+
a();
31+
}
32+
}
33+
34+
control IngressI(inout H hdr, inout M meta, inout standard_metadata_t smeta) {
35+
Aux() aux;
36+
apply {
37+
aux.apply(meta);
38+
}
39+
}
40+
41+
control EgressI(inout H hdr, inout M meta, inout standard_metadata_t smeta) {
42+
apply { }
43+
}
44+
45+
control DeparserI(packet_out pk, in H hdr) {
46+
apply { }
47+
}
48+
49+
control VerifyChecksumI(in H hdr, inout M meta) {
50+
apply { }
51+
}
52+
53+
control ComputeChecksumI(inout H hdr, inout M meta) {
54+
apply { }
55+
}
56+
57+
58+
V1Switch(ParserI(), VerifyChecksumI(), IngressI(), EgressI(),
59+
ComputeChecksumI(), DeparserI()) main;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#include <core.p4>
2+
#include <v1model.p4>
3+
4+
struct H {
5+
}
6+
7+
struct M {
8+
}
9+
10+
parser ParserI(packet_in pk, out H hdr, inout M meta, inout standard_metadata_t smeta) {
11+
state start {
12+
transition accept;
13+
}
14+
}
15+
16+
control Aux(inout M meta) {
17+
action a() {
18+
}
19+
apply {
20+
a();
21+
}
22+
}
23+
24+
control IngressI(inout H hdr, inout M meta, inout standard_metadata_t smeta) {
25+
Aux() aux;
26+
apply {
27+
aux.apply(meta);
28+
}
29+
}
30+
31+
control EgressI(inout H hdr, inout M meta, inout standard_metadata_t smeta) {
32+
apply {
33+
}
34+
}
35+
36+
control DeparserI(packet_out pk, in H hdr) {
37+
apply {
38+
}
39+
}
40+
41+
control VerifyChecksumI(in H hdr, inout M meta) {
42+
apply {
43+
}
44+
}
45+
46+
control ComputeChecksumI(inout H hdr, inout M meta) {
47+
apply {
48+
}
49+
}
50+
51+
V1Switch<H, M>(ParserI(), VerifyChecksumI(), IngressI(), EgressI(), ComputeChecksumI(), DeparserI()) main;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#include <core.p4>
2+
#include <v1model.p4>
3+
4+
struct H {
5+
}
6+
7+
struct M {
8+
}
9+
10+
parser ParserI(packet_in pk, out H hdr, inout M meta, inout standard_metadata_t smeta) {
11+
state start {
12+
transition accept;
13+
}
14+
}
15+
16+
control Aux(inout M meta) {
17+
@name("a") action a_0() {
18+
}
19+
apply {
20+
a_0();
21+
}
22+
}
23+
24+
control IngressI(inout H hdr, inout M meta, inout standard_metadata_t smeta) {
25+
@name("aux") Aux() aux_0;
26+
apply {
27+
aux_0.apply(meta);
28+
}
29+
}
30+
31+
control EgressI(inout H hdr, inout M meta, inout standard_metadata_t smeta) {
32+
apply {
33+
}
34+
}
35+
36+
control DeparserI(packet_out pk, in H hdr) {
37+
apply {
38+
}
39+
}
40+
41+
control VerifyChecksumI(in H hdr, inout M meta) {
42+
apply {
43+
}
44+
}
45+
46+
control ComputeChecksumI(inout H hdr, inout M meta) {
47+
apply {
48+
}
49+
}
50+
51+
V1Switch<H, M>(ParserI(), VerifyChecksumI(), IngressI(), EgressI(), ComputeChecksumI(), DeparserI()) main;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#include <core.p4>
2+
#include <v1model.p4>
3+
4+
struct H {
5+
}
6+
7+
struct M {
8+
}
9+
10+
parser ParserI(packet_in pk, out H hdr, inout M meta, inout standard_metadata_t smeta) {
11+
state start {
12+
transition accept;
13+
}
14+
}
15+
16+
control IngressI(inout H hdr, inout M meta, inout standard_metadata_t smeta) {
17+
M meta_1;
18+
@name("aux.a") action aux_a() {
19+
}
20+
action act() {
21+
meta_1 = meta;
22+
}
23+
action act_0() {
24+
meta = meta_1;
25+
}
26+
table tbl_act() {
27+
actions = {
28+
act();
29+
}
30+
const default_action = act();
31+
}
32+
table tbl_aux_a() {
33+
actions = {
34+
aux_a();
35+
}
36+
const default_action = aux_a();
37+
}
38+
table tbl_act_0() {
39+
actions = {
40+
act_0();
41+
}
42+
const default_action = act_0();
43+
}
44+
apply {
45+
tbl_act.apply();
46+
tbl_aux_a.apply();
47+
tbl_act_0.apply();
48+
}
49+
}
50+
51+
control EgressI(inout H hdr, inout M meta, inout standard_metadata_t smeta) {
52+
apply {
53+
}
54+
}
55+
56+
control DeparserI(packet_out pk, in H hdr) {
57+
apply {
58+
}
59+
}
60+
61+
control VerifyChecksumI(in H hdr, inout M meta) {
62+
apply {
63+
}
64+
}
65+
66+
control ComputeChecksumI(inout H hdr, inout M meta) {
67+
apply {
68+
}
69+
}
70+
71+
V1Switch<H, M>(ParserI(), VerifyChecksumI(), IngressI(), EgressI(), ComputeChecksumI(), DeparserI()) main;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#include <core.p4>
2+
#include <v1model.p4>
3+
4+
struct H {
5+
}
6+
7+
struct M {
8+
}
9+
10+
parser ParserI(packet_in pk, out H hdr, inout M meta, inout standard_metadata_t smeta) {
11+
state start {
12+
transition accept;
13+
}
14+
}
15+
16+
control Aux(inout M meta) {
17+
action a() {
18+
}
19+
apply {
20+
a();
21+
}
22+
}
23+
24+
control IngressI(inout H hdr, inout M meta, inout standard_metadata_t smeta) {
25+
Aux() aux;
26+
apply {
27+
aux.apply(meta);
28+
}
29+
}
30+
31+
control EgressI(inout H hdr, inout M meta, inout standard_metadata_t smeta) {
32+
apply {
33+
}
34+
}
35+
36+
control DeparserI(packet_out pk, in H hdr) {
37+
apply {
38+
}
39+
}
40+
41+
control VerifyChecksumI(in H hdr, inout M meta) {
42+
apply {
43+
}
44+
}
45+
46+
control ComputeChecksumI(inout H hdr, inout M meta) {
47+
apply {
48+
}
49+
}
50+
51+
V1Switch(ParserI(), VerifyChecksumI(), IngressI(), EgressI(), ComputeChecksumI(), DeparserI()) main;

testdata/p4_16_samples_outputs/action-synth.p4-stderr

Whitespace-only changes.

0 commit comments

Comments
 (0)