-
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.
loop fixes to get through midend/p4test
- allow ForIn to refer to decl in the enclosing scope - ensure valid P4 code output for loops in toP4 - fix testcase to no deadcode elim everything
- Loading branch information
Showing
11 changed files
with
121 additions
and
14 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
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include <core.p4> | ||
|
||
control generic<M>(inout M m); | ||
package top<M>(generic<M> c); | ||
header t1 { | ||
bit<32> f1; | ||
bit<16> h1; | ||
bit<8> b1; | ||
bit<8> cnt; | ||
} | ||
|
||
header t2 { | ||
bit<32> x; | ||
} | ||
|
||
struct headers_t { | ||
t1 head; | ||
t2[8] stack; | ||
} | ||
|
||
control c(inout headers_t hdrs) { | ||
@name("c.v") t2 v_0; | ||
@hidden action forloop1l24() { | ||
hdrs.head.f1 = hdrs.head.f1 + v_0.x; | ||
} | ||
@hidden action forloop1l27() { | ||
hdrs.head.h1 = hdrs.head.h1 + 16w1; | ||
} | ||
@hidden table tbl_forloop1l24 { | ||
actions = { | ||
forloop1l24(); | ||
} | ||
const default_action = forloop1l24(); | ||
} | ||
@hidden table tbl_forloop1l27 { | ||
actions = { | ||
forloop1l27(); | ||
} | ||
const default_action = forloop1l27(); | ||
} | ||
apply { | ||
for (v_0 in hdrs.stack) { | ||
tbl_forloop1l24.apply(); | ||
} | ||
for (; 8w0 < hdrs.head.cnt; ) { | ||
tbl_forloop1l27.apply(); | ||
} | ||
} | ||
} | ||
|
||
top<headers_t>(c()) 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
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,4 +1,9 @@ | ||
forloop1.p4(18): [--Wwarn=unused] warning: Control c is not used; removing | ||
control c(inout headers_t hdrs) { | ||
^ | ||
[--Wwarn=missing] warning: Program does not contain a `main' module | ||
forloop1.p4(23): [--Wwarn=uninitialized_use] warning: v may not be completely initialized | ||
for (t2 v in hdrs.stack) { | ||
^ | ||
forloop1.p4(24): [--Wwarn=invalid_header] warning: accessing a field of a potentially invalid header v | ||
hdrs.head.f1 = hdrs.head.f1 + v.x; | ||
^ | ||
forloop1.p4(24): [--Wwarn=uninitialized_use] warning: v.x may be uninitialized | ||
hdrs.head.f1 = hdrs.head.f1 + v.x; | ||
^^^ |