-
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.
- Loading branch information
Showing
13 changed files
with
442 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include <core.p4> | ||
control generic<M>(inout M m); | ||
package top<M>(generic<M> c); | ||
|
||
header t1 { | ||
bit<64> v; | ||
} | ||
|
||
struct headers_t { | ||
t1 t1; | ||
} | ||
|
||
bit<64> _popcount(in bit<64> val) { | ||
bit<64> n = 0; | ||
bit<64> v = val; | ||
for (bit<64> popcnti in 1 .. 64w63) { | ||
if (v == 0) | ||
return n; | ||
n = n + 1; | ||
v = v & (v - 1); | ||
} | ||
return n; | ||
} | ||
|
||
control c(inout headers_t hdrs) { | ||
apply { | ||
hdrs.t1.v = _popcount(hdrs.t1.v); | ||
} | ||
} | ||
|
||
top(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include <core.p4> | ||
control generic<M>(inout M m); | ||
package top<M>(generic<M> c); | ||
|
||
extern T foo<T>(in T x); | ||
|
||
header t1 { | ||
bit<32> x; | ||
} | ||
|
||
struct headers_t { | ||
t1 t1; | ||
} | ||
|
||
control c(inout headers_t hdrs) { | ||
action a0(bit<8> x, bit<8> y) { | ||
bit<8> idx = 255; | ||
for (bit<8> i1 in 0 .. x) { | ||
for (bit<8> j in i1 .. y) { | ||
idx = foo(j); | ||
if (idx == 255) | ||
break; | ||
} | ||
} | ||
} | ||
|
||
table test { | ||
key = { hdrs.t1.x: exact; } | ||
actions = { a0; } | ||
} | ||
|
||
apply { | ||
test.apply(); | ||
} | ||
} | ||
|
||
top(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +0,0 @@ | ||
forloop1.p4(24): [--Wwarn=uninitialized_use] warning: v.x may be uninitialized | ||
hdrs.head.f1 = hdrs.head.f1 + v.x; | ||
^^^ | ||
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,31 @@ | ||
#include <core.p4> | ||
|
||
control generic<M>(inout M m); | ||
package top<M>(generic<M> c); | ||
header t1 { | ||
bit<64> v; | ||
} | ||
|
||
struct headers_t { | ||
t1 t1; | ||
} | ||
|
||
bit<64> _popcount(in bit<64> val) { | ||
bit<64> n = 64w0; | ||
bit<64> v = val; | ||
for (bit<64> popcnti in 64w1 .. 64w63) { | ||
if (v == 64w0) { | ||
return n; | ||
} | ||
n = n + 64w1; | ||
v = v & v + 64w18446744073709551615; | ||
} | ||
return n; | ||
} | ||
control c(inout headers_t hdrs) { | ||
apply { | ||
hdrs.t1.v = _popcount(hdrs.t1.v); | ||
} | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include <core.p4> | ||
|
||
control generic<M>(inout M m); | ||
package top<M>(generic<M> c); | ||
header t1 { | ||
bit<64> v; | ||
} | ||
|
||
struct headers_t { | ||
t1 t1; | ||
} | ||
|
||
control c(inout headers_t hdrs) { | ||
@name("c.hasReturned") bool hasReturned; | ||
@name("c.retval") bit<64> retval; | ||
@name("c.n") bit<64> n_0; | ||
@name("c.v") bit<64> v_0; | ||
@name("c.popcnti") bit<64> popcnti_0; | ||
apply { | ||
hasReturned = false; | ||
n_0 = 64w0; | ||
for (popcnti_0 in 64w1 .. 64w63) { | ||
if (v_0 == 64w0) { | ||
hasReturned = true; | ||
retval = n_0; | ||
} | ||
if (hasReturned) { | ||
; | ||
} else { | ||
n_0 = n_0 + 64w1; | ||
v_0 = v_0 & v_0 + 64w18446744073709551615; | ||
} | ||
} | ||
if (hasReturned) { | ||
; | ||
} else { | ||
retval = n_0; | ||
} | ||
hdrs.t1.v = retval; | ||
} | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#include <core.p4> | ||
|
||
control generic<M>(inout M m); | ||
package top<M>(generic<M> c); | ||
header t1 { | ||
bit<64> v; | ||
} | ||
|
||
struct headers_t { | ||
t1 t1; | ||
} | ||
|
||
control c(inout headers_t hdrs) { | ||
@name("c.hasReturned") bool hasReturned; | ||
@name("c.retval") bit<64> retval; | ||
@name("c.n") bit<64> n_0; | ||
@name("c.v") bit<64> v_0; | ||
@name("c.popcnti") bit<64> popcnti_0; | ||
@hidden action forloop2l18() { | ||
hasReturned = true; | ||
retval = n_0; | ||
} | ||
@hidden action forloop2l19() { | ||
n_0 = n_0 + 64w1; | ||
v_0 = v_0 & v_0 + 64w18446744073709551615; | ||
} | ||
@hidden action forloop2l14() { | ||
hasReturned = false; | ||
n_0 = 64w0; | ||
} | ||
@hidden action forloop2l22() { | ||
retval = n_0; | ||
} | ||
@hidden action forloop2l27() { | ||
hdrs.t1.v = retval; | ||
} | ||
@hidden table tbl_forloop2l14 { | ||
actions = { | ||
forloop2l14(); | ||
} | ||
const default_action = forloop2l14(); | ||
} | ||
@hidden table tbl_forloop2l18 { | ||
actions = { | ||
forloop2l18(); | ||
} | ||
const default_action = forloop2l18(); | ||
} | ||
@hidden table tbl_forloop2l19 { | ||
actions = { | ||
forloop2l19(); | ||
} | ||
const default_action = forloop2l19(); | ||
} | ||
@hidden table tbl_forloop2l22 { | ||
actions = { | ||
forloop2l22(); | ||
} | ||
const default_action = forloop2l22(); | ||
} | ||
@hidden table tbl_forloop2l27 { | ||
actions = { | ||
forloop2l27(); | ||
} | ||
const default_action = forloop2l27(); | ||
} | ||
apply { | ||
tbl_forloop2l14.apply(); | ||
for (popcnti_0 in 64w1 .. 64w63) { | ||
if (v_0 == 64w0) { | ||
tbl_forloop2l18.apply(); | ||
} | ||
if (hasReturned) { | ||
; | ||
} else { | ||
tbl_forloop2l19.apply(); | ||
} | ||
} | ||
if (hasReturned) { | ||
; | ||
} else { | ||
tbl_forloop2l22.apply(); | ||
} | ||
tbl_forloop2l27.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include <core.p4> | ||
|
||
control generic<M>(inout M m); | ||
package top<M>(generic<M> c); | ||
header t1 { | ||
bit<64> v; | ||
} | ||
|
||
struct headers_t { | ||
t1 t1; | ||
} | ||
|
||
bit<64> _popcount(in bit<64> val) { | ||
bit<64> n = 0; | ||
bit<64> v = val; | ||
for (bit<64> popcnti in 1 .. 64w63) { | ||
if (v == 0) { | ||
return n; | ||
} | ||
n = n + 1; | ||
v = v & v - 1; | ||
} | ||
return n; | ||
} | ||
control c(inout headers_t hdrs) { | ||
apply { | ||
hdrs.t1.v = _popcount(hdrs.t1.v); | ||
} | ||
} | ||
|
||
top(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
forloop2.p4(17): [--Wwarn=uninitialized_use] warning: v may be uninitialized | ||
if (v == 0) | ||
^ | ||
forloop2.p4(20): [--Wwarn=uninitialized_use] warning: v may be uninitialized | ||
v = v & (v - 1); | ||
^ | ||
forloop2.p4(20): [--Wwarn=uninitialized_use] warning: v may be uninitialized | ||
v = v & (v - 1); | ||
^ | ||
[--Wwarn=uninitialized_use] warning: retval may be uninitialized | ||
[--Wwarn=uninitialized_use] warning: retval may be uninitialized |
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,41 @@ | ||
#include <core.p4> | ||
|
||
control generic<M>(inout M m); | ||
package top<M>(generic<M> c); | ||
extern T foo<T>(in T x); | ||
header t1 { | ||
bit<32> x; | ||
} | ||
|
||
struct headers_t { | ||
t1 t1; | ||
} | ||
|
||
control c(inout headers_t hdrs) { | ||
action a0(bit<8> x, bit<8> y) { | ||
bit<8> idx = 8w255; | ||
for (bit<8> i1 in 8w0 .. x) { | ||
for (bit<8> j in i1 .. y) { | ||
idx = foo<bit<8>>(j); | ||
if (idx == 8w255) { | ||
|
||
} | ||
} | ||
} | ||
} | ||
table test { | ||
key = { | ||
hdrs.t1.x: exact @name("hdrs.t1.x"); | ||
} | ||
actions = { | ||
a0(); | ||
@defaultonly NoAction(); | ||
} | ||
default_action = NoAction(); | ||
} | ||
apply { | ||
test.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include <core.p4> | ||
|
||
control generic<M>(inout M m); | ||
package top<M>(generic<M> c); | ||
extern T foo<T>(in T x); | ||
header t1 { | ||
bit<32> x; | ||
} | ||
|
||
struct headers_t { | ||
t1 t1; | ||
} | ||
|
||
control c(inout headers_t hdrs) { | ||
@name("c.idx") bit<8> idx_0; | ||
@name("c.i1") bit<8> i1_0; | ||
@name("c.j") bit<8> j_0; | ||
@noWarn("unused") @name(".NoAction") action NoAction_1() { | ||
} | ||
@name("c.a0") action a0(@name("x") bit<8> x_1, @name("y") bit<8> y) { | ||
for (i1_0 in 8w0 .. x_1) { | ||
for (j_0 in i1_0 .. y) { | ||
idx_0 = foo<bit<8>>(j_0); | ||
if (idx_0 == 8w255) { | ||
|
||
} | ||
} | ||
} | ||
} | ||
@name("c.test") table test_0 { | ||
key = { | ||
hdrs.t1.x: exact @name("hdrs.t1.x"); | ||
} | ||
actions = { | ||
a0(); | ||
@defaultonly NoAction_1(); | ||
} | ||
default_action = NoAction_1(); | ||
} | ||
apply { | ||
test_0.apply(); | ||
} | ||
} | ||
|
||
top<headers_t>(c()) main; |
Oops, something went wrong.