Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test program in which string comparison operators are folded. #4867

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions testdata/p4_16_samples/string_ops-bmv2.p4
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#include <core.p4>
#define V1MODEL_VERSION 20180101
#include <v1model.p4>

header ethernet_t {
bit<48> dst_addr;
bit<48> src_addr;
bit<16> eth_type;
}

struct Headers {
ethernet_t eth_hdr;
}

struct Meta {
}

void set_hdr(inout bit<48> addr, in bool option) {
if (option) {
addr = 0xAABBCCDDEEFF;
}
}

parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t sm) {
state start {
pkt.extract(hdr.eth_hdr);
transition accept;
}
}

control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) {
apply {
set_hdr(h.eth_hdr.dst_addr, "a" != "b");
set_hdr(h.eth_hdr.src_addr, "a" == "b");
}
}

control vrfy(inout Headers h, inout Meta m) {
apply {
}
}

control update(inout Headers h, inout Meta m) {
apply {
}
}

control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) {
apply {
}
}

control deparser(packet_out pkt, in Headers h) {
apply {
pkt.emit(h);
}
}

V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main;
58 changes: 58 additions & 0 deletions testdata/p4_16_samples_outputs/string_ops-bmv2-first.p4
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include <core.p4>
#define V1MODEL_VERSION 20180101
#include <v1model.p4>

header ethernet_t {
bit<48> dst_addr;
bit<48> src_addr;
bit<16> eth_type;
}

struct Headers {
ethernet_t eth_hdr;
}

struct Meta {
}

void set_hdr(inout bit<48> addr, in bool option) {
if (option) {
addr = 48w0xaabbccddeeff;
}
}
parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t sm) {
state start {
pkt.extract<ethernet_t>(hdr.eth_hdr);
transition accept;
}
}

control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) {
apply {
set_hdr(h.eth_hdr.dst_addr, true);
set_hdr(h.eth_hdr.src_addr, false);
}
}

control vrfy(inout Headers h, inout Meta m) {
apply {
}
}

control update(inout Headers h, inout Meta m) {
apply {
}
}

control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) {
apply {
}
}

control deparser(packet_out pkt, in Headers h) {
apply {
pkt.emit<Headers>(h);
}
}

V1Switch<Headers, Meta>(p(), vrfy(), ingress(), egress(), update(), deparser()) main;
67 changes: 67 additions & 0 deletions testdata/p4_16_samples_outputs/string_ops-bmv2-frontend.p4
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include <core.p4>
#define V1MODEL_VERSION 20180101
#include <v1model.p4>

header ethernet_t {
bit<48> dst_addr;
bit<48> src_addr;
bit<16> eth_type;
}

struct Headers {
ethernet_t eth_hdr;
}

struct Meta {
}

parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t sm) {
state start {
pkt.extract<ethernet_t>(hdr.eth_hdr);
transition accept;
}
}

control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) {
@name("ingress.addr_0") bit<48> addr;
@name("ingress.option_0") bool option;
@name("ingress.addr_1") bit<48> addr_2;
@name("ingress.option_1") bool option_2;
apply {
addr = h.eth_hdr.dst_addr;
option = true;
if (option) {
addr = 48w0xaabbccddeeff;
}
h.eth_hdr.dst_addr = addr;
addr_2 = h.eth_hdr.src_addr;
option_2 = false;
if (option_2) {
addr_2 = 48w0xaabbccddeeff;
}
h.eth_hdr.src_addr = addr_2;
}
}

control vrfy(inout Headers h, inout Meta m) {
apply {
}
}

control update(inout Headers h, inout Meta m) {
apply {
}
}

control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) {
apply {
}
}

control deparser(packet_out pkt, in Headers h) {
apply {
pkt.emit<Headers>(h);
}
}

V1Switch<Headers, Meta>(p(), vrfy(), ingress(), egress(), update(), deparser()) main;
61 changes: 61 additions & 0 deletions testdata/p4_16_samples_outputs/string_ops-bmv2-midend.p4
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include <core.p4>
#define V1MODEL_VERSION 20180101
#include <v1model.p4>

header ethernet_t {
bit<48> dst_addr;
bit<48> src_addr;
bit<16> eth_type;
}

struct Headers {
ethernet_t eth_hdr;
}

struct Meta {
}

parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t sm) {
state start {
pkt.extract<ethernet_t>(hdr.eth_hdr);
transition accept;
}
}

control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) {
@hidden action act() {
h.eth_hdr.dst_addr = 48w0xaabbccddeeff;
}
@hidden table tbl_act {
actions = {
act();
}
const default_action = act();
}
apply {
tbl_act.apply();
}
}

control vrfy(inout Headers h, inout Meta m) {
apply {
}
}

control update(inout Headers h, inout Meta m) {
apply {
}
}

control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) {
apply {
}
}

control deparser(packet_out pkt, in Headers h) {
apply {
pkt.emit<ethernet_t>(h.eth_hdr);
}
}

V1Switch<Headers, Meta>(p(), vrfy(), ingress(), egress(), update(), deparser()) main;
58 changes: 58 additions & 0 deletions testdata/p4_16_samples_outputs/string_ops-bmv2.p4
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include <core.p4>
#define V1MODEL_VERSION 20180101
#include <v1model.p4>

header ethernet_t {
bit<48> dst_addr;
bit<48> src_addr;
bit<16> eth_type;
}

struct Headers {
ethernet_t eth_hdr;
}

struct Meta {
}

void set_hdr(inout bit<48> addr, in bool option) {
if (option) {
addr = 0xaabbccddeeff;
}
}
parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t sm) {
state start {
pkt.extract(hdr.eth_hdr);
transition accept;
}
}

control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) {
apply {
set_hdr(h.eth_hdr.dst_addr, "a" != "b");
set_hdr(h.eth_hdr.src_addr, "a" == "b");
}
}

control vrfy(inout Headers h, inout Meta m) {
apply {
}
}

control update(inout Headers h, inout Meta m) {
apply {
}
}

control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) {
apply {
}
}

control deparser(packet_out pkt, in Headers h) {
apply {
pkt.emit(h);
}
}

V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main;
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# proto-file: p4/v1/p4runtime.proto
# proto-message: p4.v1.WriteRequest

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# proto-file: p4/config/v1/p4info.proto
# proto-message: p4.config.v1.P4Info

pkg_info {
arch: "v1model"
}
Loading