Skip to content

Commit

Permalink
Create empty SetOfLocations for don't care arguments passed as action…
Browse files Browse the repository at this point in the history
… out args. (#4762)

Signed-off-by: Kyle Cripps <[email protected]>
  • Loading branch information
kfcripps authored Jun 28, 2024
1 parent 8152186 commit 36fa73d
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 0 deletions.
4 changes: 4 additions & 0 deletions frontends/p4/alias.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ class ReadsWrites : public Inspector {
rw.emplace(expression, result);
}

void postorder(const IR::DefaultExpression *expression) override {
rw.emplace(expression, new SetOfLocations());
}

const SetOfLocations *get(const IR::Expression *expression) {
expression->apply(*this);
auto result = ::get(rw, expression);
Expand Down
27 changes: 27 additions & 0 deletions testdata/p4_16_samples/issue4760_dontcare_action_out_arg.p4
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
struct S {
bit<64> f;
}

control C(inout S s) {
action d(in bit<64> f, out bit<64> b) {
b = f + 4;
}

action foo() {
d(s.f, _);
}

table t {
actions = { foo; }
default_action = foo;
}

apply {
t.apply();
}
}

control proto(inout S s);
package top(proto p);

top(C()) main;
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
struct S {
bit<64> f;
}

control C(inout S s) {
action d(in bit<64> f, out bit<64> b) {
b = f + 64w4;
}
action foo() {
d(s.f, _);
}
table t {
actions = {
foo();
}
default_action = foo();
}
apply {
t.apply();
}
}

control proto(inout S s);
package top(proto p);
top(C()) main;
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
struct S {
bit<64> f;
}

control C(inout S s) {
@name("C.foo") action foo() {
}
@name("C.t") table t_0 {
actions = {
foo();
}
default_action = foo();
}
apply {
t_0.apply();
}
}

control proto(inout S s);
package top(proto p);
top(C()) main;
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
struct S {
bit<64> f;
}

control C(inout S s) {
@name("C.foo") action foo() {
}
@name("C.t") table t_0 {
actions = {
foo();
}
default_action = foo();
}
apply {
t_0.apply();
}
}

control proto(inout S s);
package top(proto p);
top(C()) main;
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
struct S {
bit<64> f;
}

control C(inout S s) {
action d(in bit<64> f, out bit<64> b) {
b = f + 4;
}
action foo() {
d(s.f, _);
}
table t {
actions = {
foo;
}
default_action = foo;
}
apply {
t.apply();
}
}

control proto(inout S s);
package top(proto p);
top(C()) main;
Empty file.

0 comments on commit 36fa73d

Please sign in to comment.