From ae32631178a3eaeca9fbd6f05b32f0728cc36ff2 Mon Sep 17 00:00:00 2001 From: Mihai Budiu Date: Thu, 23 Mar 2023 14:15:46 -0700 Subject: [PATCH] Remove predication pass from p4test (#3916) * Disable predication pass in p4test Signed-off-by: Mihai Budiu --- backends/p4test/CMakeLists.txt | 14 -- backends/p4test/midend.cpp | 2 - .../p4_14_samples_outputs/misc_prim-midend.p4 | 40 +++- .../modify_conditionally-midend.p4 | 8 +- testdata/p4_16_errors/issue513.p4 | 95 --------- .../p4_16_errors_outputs/issue513-first.p4 | 70 ------ .../p4_16_errors_outputs/issue513-frontend.p4 | 70 ------ testdata/p4_16_errors_outputs/issue513.p4 | 70 ------ .../p4_16_errors_outputs/issue513.p4-stderr | 9 - .../issue513.p4.p4info.txt | 29 --- .../action_call_table_ebpf-midend.p4 | 10 +- .../gauntlet_action_mux-bmv2-midend.p4 | 8 +- .../gauntlet_action_return-bmv2-midend.p4 | 9 +- .../gauntlet_enum_assign-bmv2-midend.p4 | 35 --- .../gauntlet_exit_combination_12-midend.p4 | 7 +- .../gauntlet_index_4-bmv2-midend.p4 | 8 +- .../gauntlet_mux_hdr-bmv2-midend.p4 | 4 +- .../gauntlet_mux_validity-bmv2-midend.p4 | 19 +- .../hdr_stacks2345-midend.p4 | 7 +- .../issue1412-bmv2-midend.p4 | 4 +- .../p4_16_samples_outputs/issue210-midend.p4 | 17 +- .../p4_16_samples_outputs/issue2248-midend.p4 | 12 +- .../issue2330-1-midend.p4 | 18 +- .../p4_16_samples_outputs/issue2330-midend.p4 | 18 +- .../p4_16_samples_outputs/issue2344-midend.p4 | 4 +- .../issue2345-1-midend.p4 | 25 ++- .../issue2345-2-midend.p4 | 31 ++- .../p4_16_samples_outputs/issue2345-midend.p4 | 11 +- .../issue2345-multiple_dependencies-midend.p4 | 19 +- .../issue2345-with_nested_if-midend.p4 | 30 +-- .../p4_16_samples_outputs/issue2359-midend.p4 | 15 +- .../p4_16_samples_outputs/issue420-midend.p4 | 13 +- .../p4_16_samples_outputs/issue512-midend.p4 | 15 +- ...k-non-zero-arg-default-action-08-midend.p4 | 6 +- .../nested_if_else-midend.p4 | 17 +- .../nested_if_lvalue_dependencies-midend.p4 | 16 +- .../nested_if_statement-midend.p4 | 14 +- .../pna-dpdk-direct-counter-first.p4 | 5 +- .../pna-dpdk-direct-counter-frontend.p4 | 5 +- .../pna-dpdk-direct-counter-midend.p4 | 15 +- .../pna-dpdk-direct-counter.p4 | 9 +- .../pna-dpdk-direct-meter-learner-midend.p4 | 8 +- .../pna-example-pass-2-first.p4 | 93 ++++++++ .../pna-example-pass-2-frontend.p4 | 99 +++++++++ .../pna-example-pass-2-midend.p4 | 112 ++++++++++ .../pna-example-pass-2.p4 | 93 ++++++++ .../pna-example-pass-2.p4-stderr} | 0 ...a-example-tcp-connection-tracking-first.p4 | 182 ++++++++++++++++ ...xample-tcp-connection-tracking-frontend.p4 | 178 ++++++++++++++++ ...-example-tcp-connection-tracking-midend.p4 | 201 ++++++++++++++++++ .../pna-example-tcp-connection-tracking.p4 | 181 ++++++++++++++++ ...-example-tcp-connection-tracking.p4-stderr | 9 + .../pna-mux-dismantle-midend.p4 | 14 +- .../predication_issue-midend.p4 | 1 - .../predication_issue_1-midend.p4 | 7 +- .../predication_issue_2-midend.p4 | 13 +- .../predication_issue_3-midend.p4 | 15 +- .../predication_issue_4-midend.p4 | 23 +- .../predication_issue_4.p4-stderr | 3 - .../psa-conditional_operator-midend.p4 | 8 +- .../psa-dpdk-errorcode-1-midend.p4 | 6 +- .../psa-dpdk-errorcode-2-midend.p4 | 6 +- .../psa-dpdk-flatten-local-struct-midend.p4 | 8 +- .../psa-dpdk-hdr-field-non-align-midend.p4 | 10 +- .../psa-dpdk-large-header-fields-midend.p4 | 15 +- .../psa-dpdk-large-struct-fields-midend.p4 | 15 +- ...k-non-zero-arg-default-action-01-midend.p4 | 8 +- ...k-non-zero-arg-default-action-02-midend.p4 | 8 +- ...k-non-zero-arg-default-action-05-midend.p4 | 8 +- ...k-non-zero-arg-default-action-06-midend.p4 | 8 +- ...k-non-zero-arg-default-action-07-midend.p4 | 8 +- ...k-non-zero-arg-default-action-08-midend.p4 | 8 +- ...k-non-zero-arg-default-action-09-midend.p4 | 8 +- .../psa-dpdk-struct-field-midend.p4 | 8 +- .../psa-dpdk-tmp-mask-align-midend.p4 | 6 +- ...sa-example-dpdk-byte-alignment_1-midend.p4 | 22 +- ...sa-example-dpdk-byte-alignment_2-midend.p4 | 22 +- ...sa-example-dpdk-byte-alignment_3-midend.p4 | 22 +- ...sa-example-dpdk-byte-alignment_5-midend.p4 | 22 +- ...sa-example-dpdk-byte-alignment_6-midend.p4 | 29 ++- ...sa-example-dpdk-byte-alignment_7-midend.p4 | 37 ++-- ...sa-example-dpdk-byte-alignment_8-midend.p4 | 37 ++-- ...sa-example-dpdk-byte-alignment_9-midend.p4 | 22 +- .../psa-example-dpdk-directmeter-midend.p4 | 8 +- .../psa-example-dpdk-externs-midend.p4 | 10 +- ...a-example-dpdk-meter-execute-err-midend.p4 | 22 +- .../psa-example-dpdk-meter-midend.p4 | 8 +- .../psa-example-dpdk-meter1-midend.p4 | 8 +- .../psa-subtract-inst1-midend.p4 | 12 +- .../p4_16_samples_outputs/xor_test-midend.p4 | 22 +- 90 files changed, 1849 insertions(+), 657 deletions(-) delete mode 100644 testdata/p4_16_errors/issue513.p4 delete mode 100644 testdata/p4_16_errors_outputs/issue513-first.p4 delete mode 100644 testdata/p4_16_errors_outputs/issue513-frontend.p4 delete mode 100644 testdata/p4_16_errors_outputs/issue513.p4 delete mode 100644 testdata/p4_16_errors_outputs/issue513.p4-stderr delete mode 100644 testdata/p4_16_errors_outputs/issue513.p4.p4info.txt create mode 100644 testdata/p4_16_samples_outputs/pna-example-pass-2-first.p4 create mode 100644 testdata/p4_16_samples_outputs/pna-example-pass-2-frontend.p4 create mode 100644 testdata/p4_16_samples_outputs/pna-example-pass-2-midend.p4 create mode 100644 testdata/p4_16_samples_outputs/pna-example-pass-2.p4 rename testdata/{p4_16_errors_outputs/issue513.p4.entries.txt => p4_16_samples_outputs/pna-example-pass-2.p4-stderr} (100%) create mode 100644 testdata/p4_16_samples_outputs/pna-example-tcp-connection-tracking-first.p4 create mode 100644 testdata/p4_16_samples_outputs/pna-example-tcp-connection-tracking-frontend.p4 create mode 100644 testdata/p4_16_samples_outputs/pna-example-tcp-connection-tracking-midend.p4 create mode 100644 testdata/p4_16_samples_outputs/pna-example-tcp-connection-tracking.p4 create mode 100644 testdata/p4_16_samples_outputs/pna-example-tcp-connection-tracking.p4-stderr diff --git a/backends/p4test/CMakeLists.txt b/backends/p4test/CMakeLists.txt index cf4966d2852..bd4ff4c05f3 100644 --- a/backends/p4test/CMakeLists.txt +++ b/backends/p4test/CMakeLists.txt @@ -100,20 +100,6 @@ set (P4_XFAIL_TESTS # This program uses a list of expressions on the 'psa_implementation' property # which is currently unsupported testdata/p4_16_samples/psa-action-profile2.p4 - # These programs uses conditional execution inside action body which is currently - # unsupported - testdata/p4_16_samples/psa-dpdk-action-jumpOpt.p4 - testdata/p4_16_samples/pna-example-tcp-connection-tracking.p4 - testdata/p4_16_samples/pna-example-tcp-connection-tracking-err-1.p4 - testdata/p4_16_samples/pna-example-tcp-connection-tracking-err.p4 - testdata/p4_16_samples/pna-example-pass-2.p4 - testdata/p4_16_samples/invalid-hdr-warnings5.p4 - testdata/p4_16_samples/invalid-hdr-warnings6.p4 - testdata/p4_16_samples/invalid-hdr-warnings7.p4 - testdata/p4_16_samples/invalid-hdr-warnings8.p4 - testdata/p4_16_samples/pna-dpdk-direct-counter.p4 - testdata/p4_16_samples/issue3001-1.p4 - testdata/p4_16_samples/issue982.p4 # These tests are added to check mirror_packet extern invocation with non-constant # arguments and with incorrect number of arguments testdata/p4_16_samples/pna-example-mirror-packet-error2.p4 diff --git a/backends/p4test/midend.cpp b/backends/p4test/midend.cpp index 0130d0c1f7e..adcf256e38c 100644 --- a/backends/p4test/midend.cpp +++ b/backends/p4test/midend.cpp @@ -49,7 +49,6 @@ limitations under the License. #include "midend/nestedStructs.h" #include "midend/noMatch.h" #include "midend/parserUnroll.h" -#include "midend/predication.h" #include "midend/removeAssertAssume.h" #include "midend/removeExits.h" #include "midend/removeMiss.h" @@ -108,7 +107,6 @@ MidEnd::MidEnd(CompilerOptions &options, std::ostream *outStream) { new P4::FlattenInterfaceStructs(&refMap, &typeMap), new P4::EliminateTypedef(&refMap, &typeMap), new P4::ReplaceSelectRange(&refMap, &typeMap), - new P4::Predication(&refMap), new P4::MoveDeclarations(), // more may have been introduced new P4::ConstantFolding(&refMap, &typeMap), new P4::GlobalCopyPropagation(&refMap, &typeMap), diff --git a/testdata/p4_14_samples_outputs/misc_prim-midend.p4 b/testdata/p4_14_samples_outputs/misc_prim-midend.p4 index 9cc4ac65e5b..a14fb02a878 100644 --- a/testdata/p4_14_samples_outputs/misc_prim-midend.p4 +++ b/testdata/p4_14_samples_outputs/misc_prim-midend.p4 @@ -37,6 +37,11 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout } control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("ingress.tmp") bit<32> tmp; + @name("ingress.tmp_0") bit<32> tmp_0; + @name("ingress.tmp_1") int<32> tmp_1; + @name("ingress.tmp_2") int<32> tmp_2; + @name("ingress.tmp_3") int<32> tmp_3; @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name(".action_0") action action_0() { @@ -52,19 +57,44 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ hdr.pkt.field_a_32 = ~hdr.pkt.field_d_32; } @name(".action_4") action action_4(@name("param0") bit<32> param0_11) { - hdr.pkt.field_a_32 = (hdr.pkt.field_d_32 <= param0_11 ? hdr.pkt.field_d_32 : param0_11); + if (hdr.pkt.field_d_32 <= param0_11) { + tmp = hdr.pkt.field_d_32; + } else { + tmp = param0_11; + } + hdr.pkt.field_a_32 = tmp; } @name(".action_5") action action_5(@name("param0") bit<32> param0_12) { - hdr.pkt.field_a_32 = (param0_12 >= hdr.pkt.field_d_32 ? param0_12 : hdr.pkt.field_d_32); + if (param0_12 >= hdr.pkt.field_d_32) { + tmp_0 = param0_12; + } else { + tmp_0 = hdr.pkt.field_d_32; + } + hdr.pkt.field_a_32 = tmp_0; } @name(".action_6") action action_6() { - hdr.pkt.field_b_32 = ((int<32>)hdr.pkt.field_d_32 <= 32s7 ? (int<32>)hdr.pkt.field_d_32 : 32s7); + if ((int<32>)hdr.pkt.field_d_32 <= 32s7) { + tmp_1 = (int<32>)hdr.pkt.field_d_32; + } else { + tmp_1 = 32s7; + } + hdr.pkt.field_b_32 = tmp_1; } @name(".action_7") action action_7(@name("param0") int<32> param0_13) { - hdr.pkt.field_b_32 = (param0_13 >= (int<32>)hdr.pkt.field_d_32 ? param0_13 : (int<32>)hdr.pkt.field_d_32); + if (param0_13 >= (int<32>)hdr.pkt.field_d_32) { + tmp_2 = param0_13; + } else { + tmp_2 = (int<32>)hdr.pkt.field_d_32; + } + hdr.pkt.field_b_32 = tmp_2; } @name(".action_8") action action_8(@name("param0") int<32> param0_14) { - hdr.pkt.field_x_32 = (hdr.pkt.field_x_32 >= param0_14 ? hdr.pkt.field_x_32 : param0_14); + if (hdr.pkt.field_x_32 >= param0_14) { + tmp_3 = hdr.pkt.field_x_32; + } else { + tmp_3 = param0_14; + } + hdr.pkt.field_x_32 = tmp_3; } @name(".action_9") action action_9() { hdr.pkt.field_x_32 = hdr.pkt.field_x_32 >> 7; diff --git a/testdata/p4_14_samples_outputs/modify_conditionally-midend.p4 b/testdata/p4_14_samples_outputs/modify_conditionally-midend.p4 index 69de0a383e3..822181348f8 100644 --- a/testdata/p4_14_samples_outputs/modify_conditionally-midend.p4 +++ b/testdata/p4_14_samples_outputs/modify_conditionally-midend.p4 @@ -36,11 +36,17 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("ingress.tmp") bit<8> tmp; @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name(".table0_actionlist") action table0_actionlist(@name("do_goto_table") bit<1> do_goto_table_1, @name("goto_table_id") bit<8> goto_table_id_1) { meta._metadata_global_do_goto_table0 = do_goto_table_1; - meta._metadata_global_goto_table_id1 = (do_goto_table_1 != 1w0 ? goto_table_id_1 : meta._metadata_global_goto_table_id1); + if (do_goto_table_1 != 1w0) { + tmp = goto_table_id_1; + } else { + tmp = meta._metadata_global_goto_table_id1; + } + meta._metadata_global_goto_table_id1 = tmp; } @name(".table0") table table0_0 { actions = { diff --git a/testdata/p4_16_errors/issue513.p4 b/testdata/p4_16_errors/issue513.p4 deleted file mode 100644 index 73b2f28fe9b..00000000000 --- a/testdata/p4_16_errors/issue513.p4 +++ /dev/null @@ -1,95 +0,0 @@ -/* -Copyright 2017 Cisco Systems, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -#include -#include - -typedef bit<48> EthernetAddress; - -header Ethernet_h { - EthernetAddress dstAddr; - EthernetAddress srcAddr; - bit<16> etherType; -} - -struct Parsed_packet { - Ethernet_h ethernet; -} - -struct mystruct1 { - bit<4> a; - bit<4> b; -} - -control DeparserI(packet_out packet, - in Parsed_packet hdr) { - apply { packet.emit(hdr.ethernet); } -} - -parser parserI(packet_in pkt, - out Parsed_packet hdr, - inout mystruct1 meta, - inout standard_metadata_t stdmeta) { - state start { - pkt.extract(hdr.ethernet); - transition accept; - } -} - -control cIngress(inout Parsed_packet hdr, - inout mystruct1 meta, - inout standard_metadata_t stdmeta) { - action foo() { - meta.b = meta.b + 5; - if (meta.b > 10) { - // Next line causes error for p4test: MethodCallStatement: - // Predication cannot be applied. - mark_to_drop(); - } - } - table guh { - key = { hdr.ethernet.srcAddr : exact; } - actions = { foo; } - default_action = foo; - } - - apply { - guh.apply(); - } -} - -control cEgress(inout Parsed_packet hdr, - inout mystruct1 meta, - inout standard_metadata_t stdmeta) { - apply { } -} - -control vc(inout Parsed_packet hdr, - inout mystruct1 meta) { - apply { } -} - -control uc(inout Parsed_packet hdr, - inout mystruct1 meta) { - apply { } -} - -V1Switch(parserI(), - vc(), - cIngress(), - cEgress(), - uc(), - DeparserI()) main; diff --git a/testdata/p4_16_errors_outputs/issue513-first.p4 b/testdata/p4_16_errors_outputs/issue513-first.p4 deleted file mode 100644 index cc7b92f116f..00000000000 --- a/testdata/p4_16_errors_outputs/issue513-first.p4 +++ /dev/null @@ -1,70 +0,0 @@ -#include -#define V1MODEL_VERSION 20180101 -#include - -typedef bit<48> EthernetAddress; -header Ethernet_h { - EthernetAddress dstAddr; - EthernetAddress srcAddr; - bit<16> etherType; -} - -struct Parsed_packet { - Ethernet_h ethernet; -} - -struct mystruct1 { - bit<4> a; - bit<4> b; -} - -control DeparserI(packet_out packet, in Parsed_packet hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -parser parserI(packet_in pkt, out Parsed_packet hdr, inout mystruct1 meta, inout standard_metadata_t stdmeta) { - state start { - pkt.extract(hdr.ethernet); - transition accept; - } -} - -control cIngress(inout Parsed_packet hdr, inout mystruct1 meta, inout standard_metadata_t stdmeta) { - action foo() { - meta.b = meta.b + 4w5; - if (meta.b > 4w10) { - mark_to_drop(); - } - } - table guh { - key = { - hdr.ethernet.srcAddr: exact @name("hdr.ethernet.srcAddr"); - } - actions = { - foo(); - } - default_action = foo(); - } - apply { - guh.apply(); - } -} - -control cEgress(inout Parsed_packet hdr, inout mystruct1 meta, inout standard_metadata_t stdmeta) { - apply { - } -} - -control vc(inout Parsed_packet hdr, inout mystruct1 meta) { - apply { - } -} - -control uc(inout Parsed_packet hdr, inout mystruct1 meta) { - apply { - } -} - -V1Switch(parserI(), vc(), cIngress(), cEgress(), uc(), DeparserI()) main; diff --git a/testdata/p4_16_errors_outputs/issue513-frontend.p4 b/testdata/p4_16_errors_outputs/issue513-frontend.p4 deleted file mode 100644 index 2fab7dff906..00000000000 --- a/testdata/p4_16_errors_outputs/issue513-frontend.p4 +++ /dev/null @@ -1,70 +0,0 @@ -#include -#define V1MODEL_VERSION 20180101 -#include - -typedef bit<48> EthernetAddress; -header Ethernet_h { - EthernetAddress dstAddr; - EthernetAddress srcAddr; - bit<16> etherType; -} - -struct Parsed_packet { - Ethernet_h ethernet; -} - -struct mystruct1 { - bit<4> a; - bit<4> b; -} - -control DeparserI(packet_out packet, in Parsed_packet hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -parser parserI(packet_in pkt, out Parsed_packet hdr, inout mystruct1 meta, inout standard_metadata_t stdmeta) { - state start { - pkt.extract(hdr.ethernet); - transition accept; - } -} - -control cIngress(inout Parsed_packet hdr, inout mystruct1 meta, inout standard_metadata_t stdmeta) { - @name("cIngress.foo") action foo() { - meta.b = meta.b + 4w5; - if (meta.b > 4w10) { - mark_to_drop(); - } - } - @name("cIngress.guh") table guh_0 { - key = { - hdr.ethernet.srcAddr: exact @name("hdr.ethernet.srcAddr"); - } - actions = { - foo(); - } - default_action = foo(); - } - apply { - guh_0.apply(); - } -} - -control cEgress(inout Parsed_packet hdr, inout mystruct1 meta, inout standard_metadata_t stdmeta) { - apply { - } -} - -control vc(inout Parsed_packet hdr, inout mystruct1 meta) { - apply { - } -} - -control uc(inout Parsed_packet hdr, inout mystruct1 meta) { - apply { - } -} - -V1Switch(parserI(), vc(), cIngress(), cEgress(), uc(), DeparserI()) main; diff --git a/testdata/p4_16_errors_outputs/issue513.p4 b/testdata/p4_16_errors_outputs/issue513.p4 deleted file mode 100644 index c104042be61..00000000000 --- a/testdata/p4_16_errors_outputs/issue513.p4 +++ /dev/null @@ -1,70 +0,0 @@ -#include -#define V1MODEL_VERSION 20180101 -#include - -typedef bit<48> EthernetAddress; -header Ethernet_h { - EthernetAddress dstAddr; - EthernetAddress srcAddr; - bit<16> etherType; -} - -struct Parsed_packet { - Ethernet_h ethernet; -} - -struct mystruct1 { - bit<4> a; - bit<4> b; -} - -control DeparserI(packet_out packet, in Parsed_packet hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -parser parserI(packet_in pkt, out Parsed_packet hdr, inout mystruct1 meta, inout standard_metadata_t stdmeta) { - state start { - pkt.extract(hdr.ethernet); - transition accept; - } -} - -control cIngress(inout Parsed_packet hdr, inout mystruct1 meta, inout standard_metadata_t stdmeta) { - action foo() { - meta.b = meta.b + 5; - if (meta.b > 10) { - mark_to_drop(); - } - } - table guh { - key = { - hdr.ethernet.srcAddr: exact; - } - actions = { - foo; - } - default_action = foo; - } - apply { - guh.apply(); - } -} - -control cEgress(inout Parsed_packet hdr, inout mystruct1 meta, inout standard_metadata_t stdmeta) { - apply { - } -} - -control vc(inout Parsed_packet hdr, inout mystruct1 meta) { - apply { - } -} - -control uc(inout Parsed_packet hdr, inout mystruct1 meta) { - apply { - } -} - -V1Switch(parserI(), vc(), cIngress(), cEgress(), uc(), DeparserI()) main; diff --git a/testdata/p4_16_errors_outputs/issue513.p4-stderr b/testdata/p4_16_errors_outputs/issue513.p4-stderr deleted file mode 100644 index 894c8e4e166..00000000000 --- a/testdata/p4_16_errors_outputs/issue513.p4-stderr +++ /dev/null @@ -1,9 +0,0 @@ -issue513.p4(60): [--Wwarn=deprecated] warning: mark_to_drop: Using deprecated feature mark_to_drop. Please use mark_to_drop(standard_metadata) instead. - mark_to_drop(); - ^^^^^^^^^^^^ -v1model.p4(406) -extern void mark_to_drop(); - ^^^^^^^^^^^^ -issue513.p4(60): [--Werror=target-error] error: mark_to_drop: Conditional execution in actions unsupported on this target - mark_to_drop(); - ^^^^^^^^^^^^^^ diff --git a/testdata/p4_16_errors_outputs/issue513.p4.p4info.txt b/testdata/p4_16_errors_outputs/issue513.p4.p4info.txt deleted file mode 100644 index c6fae14d75e..00000000000 --- a/testdata/p4_16_errors_outputs/issue513.p4.p4info.txt +++ /dev/null @@ -1,29 +0,0 @@ -pkg_info { - arch: "v1model" -} -tables { - preamble { - id: 48165785 - name: "cIngress.guh" - alias: "guh" - } - match_fields { - id: 1 - name: "hdr.ethernet.srcAddr" - bitwidth: 48 - match_type: EXACT - } - action_refs { - id: 25131402 - } - size: 1024 -} -actions { - preamble { - id: 25131402 - name: "cIngress.foo" - alias: "foo" - } -} -type_info { -} diff --git a/testdata/p4_16_samples_outputs/action_call_table_ebpf-midend.p4 b/testdata/p4_16_samples_outputs/action_call_table_ebpf-midend.p4 index 3eb0698acb4..0c38ac0d921 100644 --- a/testdata/p4_16_samples_outputs/action_call_table_ebpf-midend.p4 +++ b/testdata/p4_16_samples_outputs/action_call_table_ebpf-midend.p4 @@ -12,8 +12,14 @@ parser prs(packet_in p, out Headers_t headers) { control pipe(inout Headers_t headers, out bool pass) { @name("pipe.Reject") action Reject(@name("rej") bit<8> rej, @name("bar") bit<8> bar) { - pass = rej == 8w0; - pass = (bar == 8w0 ? false : rej == 8w0); + if (rej == 8w0) { + pass = true; + } else { + pass = false; + } + if (bar == 8w0) { + pass = false; + } } @name("pipe.t") table t_0 { actions = { diff --git a/testdata/p4_16_samples_outputs/gauntlet_action_mux-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/gauntlet_action_mux-bmv2-midend.p4 index bf7c7ec594c..831fc8f9fea 100644 --- a/testdata/p4_16_samples_outputs/gauntlet_action_mux-bmv2-midend.p4 +++ b/testdata/p4_16_samples_outputs/gauntlet_action_mux-bmv2-midend.p4 @@ -23,8 +23,14 @@ struct Meta { } control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + @name("ingress.tmp") bit<8> tmp; @name("ingress.do_thing") action do_thing() { - h.h.a = (h.h.b >= 8w4 ? h.h.b : h.h.b + 8w1); + if (h.h.b >= 8w4) { + tmp = h.h.b; + } else { + tmp = h.h.b + 8w1; + } + h.h.a = tmp; } @name("ingress.do_thing") action do_thing_1() { } diff --git a/testdata/p4_16_samples_outputs/gauntlet_action_return-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/gauntlet_action_return-bmv2-midend.p4 index 8cb03608b77..04711c44f53 100644 --- a/testdata/p4_16_samples_outputs/gauntlet_action_return-bmv2-midend.p4 +++ b/testdata/p4_16_samples_outputs/gauntlet_action_return-bmv2-midend.p4 @@ -22,10 +22,17 @@ struct Meta { control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { @name("ingress.tmp_key") bit<128> tmp_key_0; + @name("ingress.val") bit<8> val_0; @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("ingress.do_action") action do_action() { - h.h.a = (h.h.a > 8w10 ? 8w2 : 8w3); + val_0 = h.h.a; + if (h.h.a > 8w10) { + val_0 = 8w2; + } else { + val_0 = 8w3; + } + h.h.a = val_0; } @name("ingress.simple_table") table simple_table_0 { key = { diff --git a/testdata/p4_16_samples_outputs/gauntlet_enum_assign-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/gauntlet_enum_assign-bmv2-midend.p4 index 0d6fb4b81ed..814847895a7 100644 --- a/testdata/p4_16_samples_outputs/gauntlet_enum_assign-bmv2-midend.p4 +++ b/testdata/p4_16_samples_outputs/gauntlet_enum_assign-bmv2-midend.p4 @@ -9,42 +9,7 @@ struct Meta { } control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - standard_metadata_t tmp; - bool cond; @name("ingress.do_thing") action do_thing() { - cond = sm.enq_timestamp != 32w6; - tmp.ingress_port = (sm.enq_timestamp != 32w6 ? sm.ingress_port : tmp.ingress_port); - tmp.egress_spec = (sm.enq_timestamp != 32w6 ? 9w2 : tmp.egress_spec); - tmp.egress_port = (sm.enq_timestamp != 32w6 ? sm.egress_port : tmp.egress_port); - tmp.instance_type = (sm.enq_timestamp != 32w6 ? sm.instance_type : tmp.instance_type); - tmp.packet_length = (sm.enq_timestamp != 32w6 ? sm.packet_length : tmp.packet_length); - tmp.enq_timestamp = (sm.enq_timestamp != 32w6 ? sm.enq_timestamp : tmp.enq_timestamp); - tmp.enq_qdepth = (sm.enq_timestamp != 32w6 ? sm.enq_qdepth : tmp.enq_qdepth); - tmp.deq_timedelta = (sm.enq_timestamp != 32w6 ? sm.deq_timedelta : tmp.deq_timedelta); - tmp.deq_qdepth = (sm.enq_timestamp != 32w6 ? sm.deq_qdepth : tmp.deq_qdepth); - tmp.ingress_global_timestamp = (sm.enq_timestamp != 32w6 ? sm.ingress_global_timestamp : tmp.ingress_global_timestamp); - tmp.egress_global_timestamp = (sm.enq_timestamp != 32w6 ? sm.egress_global_timestamp : tmp.egress_global_timestamp); - tmp.mcast_grp = (sm.enq_timestamp != 32w6 ? sm.mcast_grp : tmp.mcast_grp); - tmp.egress_rid = (sm.enq_timestamp != 32w6 ? sm.egress_rid : tmp.egress_rid); - tmp.checksum_error = (sm.enq_timestamp != 32w6 ? sm.checksum_error : tmp.checksum_error); - tmp.parser_error = (sm.enq_timestamp != 32w6 ? sm.parser_error : tmp.parser_error); - tmp.priority = (sm.enq_timestamp != 32w6 ? sm.priority : tmp.priority); - sm.ingress_port = (sm.enq_timestamp != 32w6 ? tmp.ingress_port : sm.ingress_port); - sm.egress_spec = (sm.enq_timestamp != 32w6 ? tmp.egress_spec : 9w2); - sm.egress_port = (sm.enq_timestamp != 32w6 ? tmp.egress_port : sm.egress_port); - sm.instance_type = (sm.enq_timestamp != 32w6 ? tmp.instance_type : sm.instance_type); - sm.packet_length = (sm.enq_timestamp != 32w6 ? tmp.packet_length : sm.packet_length); - sm.enq_timestamp = (sm.enq_timestamp != 32w6 ? tmp.enq_timestamp : sm.enq_timestamp); - sm.enq_qdepth = (cond ? tmp.enq_qdepth : sm.enq_qdepth); - sm.deq_timedelta = (cond ? tmp.deq_timedelta : sm.deq_timedelta); - sm.deq_qdepth = (cond ? tmp.deq_qdepth : sm.deq_qdepth); - sm.ingress_global_timestamp = (cond ? tmp.ingress_global_timestamp : sm.ingress_global_timestamp); - sm.egress_global_timestamp = (cond ? tmp.egress_global_timestamp : sm.egress_global_timestamp); - sm.mcast_grp = (cond ? tmp.mcast_grp : sm.mcast_grp); - sm.egress_rid = (cond ? tmp.egress_rid : sm.egress_rid); - sm.checksum_error = (cond ? tmp.checksum_error : sm.checksum_error); - sm.parser_error = (cond ? tmp.parser_error : sm.parser_error); - sm.priority = (cond ? tmp.priority : sm.priority); } @hidden action gauntlet_enum_assignbmv2l15() { sm.egress_spec = 9w2; diff --git a/testdata/p4_16_samples_outputs/gauntlet_exit_combination_12-midend.p4 b/testdata/p4_16_samples_outputs/gauntlet_exit_combination_12-midend.p4 index f4084cf2e43..03a6ccbe3fb 100644 --- a/testdata/p4_16_samples_outputs/gauntlet_exit_combination_12-midend.p4 +++ b/testdata/p4_16_samples_outputs/gauntlet_exit_combination_12-midend.p4 @@ -22,8 +22,11 @@ control ingress(inout Headers h) { @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("ingress.do_action") action do_action() { - hasExited = (h.eth_hdr.src_addr == 48w1 ? true : hasExited); - h.eth_hdr.src_addr = (h.eth_hdr.src_addr == 48w1 ? h.eth_hdr.src_addr : 48w1); + if (h.eth_hdr.src_addr == 48w1) { + hasExited = true; + } else { + h.eth_hdr.src_addr = 48w1; + } } @name("ingress.simple_table") table simple_table_0 { key = { diff --git a/testdata/p4_16_samples_outputs/gauntlet_index_4-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/gauntlet_index_4-bmv2-midend.p4 index 33639a3fa67..2df20c1372c 100644 --- a/testdata/p4_16_samples_outputs/gauntlet_index_4-bmv2-midend.p4 +++ b/testdata/p4_16_samples_outputs/gauntlet_index_4-bmv2-midend.p4 @@ -30,8 +30,14 @@ parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t } control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + @name("ingress.tmp") bit<32> tmp; @name("ingress.do_something") action do_something() { - h.h[0].a = (h.eth_hdr.eth_type == 16w1 ? 32w1 : 32w2); + if (h.eth_hdr.eth_type == 16w1) { + tmp = 32w1; + } else { + tmp = 32w2; + } + h.h[0].a = tmp; } @hidden table tbl_do_something { actions = { diff --git a/testdata/p4_16_samples_outputs/gauntlet_mux_hdr-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/gauntlet_mux_hdr-bmv2-midend.p4 index d31cf4fa0a4..c867eb1e9b2 100644 --- a/testdata/p4_16_samples_outputs/gauntlet_mux_hdr-bmv2-midend.p4 +++ b/testdata/p4_16_samples_outputs/gauntlet_mux_hdr-bmv2-midend.p4 @@ -30,7 +30,9 @@ control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { tmp1_0[1].setInvalid(); tmp2_0[0].setInvalid(); tmp2_0[1].setInvalid(); - tmp1_0[0] = (tmp2_0[0].a <= 32w3 ? tmp2_0[1] : tmp1_0[0]); + if (tmp2_0[0].a <= 32w3) { + tmp1_0[0] = tmp2_0[1]; + } h.h.a = tmp1_0[0].a; } @name("ingress.simple_table") table simple_table_0 { diff --git a/testdata/p4_16_samples_outputs/gauntlet_mux_validity-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/gauntlet_mux_validity-bmv2-midend.p4 index 638907995cd..08aca04e078 100644 --- a/testdata/p4_16_samples_outputs/gauntlet_mux_validity-bmv2-midend.p4 +++ b/testdata/p4_16_samples_outputs/gauntlet_mux_validity-bmv2-midend.p4 @@ -29,8 +29,24 @@ parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t } control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + @name("ingress.b") bool b_0; + @name("ingress.tmp") bit<16> tmp; @name("ingress.dummy") action dummy_2() { - h.eth_hdr.eth_type = 16w1; + if (b_0) { + tmp = 16w1; + } else { + tmp = 16w1; + } + h.eth_hdr.eth_type = tmp; + } + @hidden action gauntlet_mux_validitybmv2l37() { + b_0 = false; + } + @hidden table tbl_gauntlet_mux_validitybmv2l37 { + actions = { + gauntlet_mux_validitybmv2l37(); + } + const default_action = gauntlet_mux_validitybmv2l37(); } @hidden table tbl_dummy { actions = { @@ -39,6 +55,7 @@ control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { const default_action = dummy_2(); } apply { + tbl_gauntlet_mux_validitybmv2l37.apply(); tbl_dummy.apply(); } } diff --git a/testdata/p4_16_samples_outputs/hdr_stacks2345-midend.p4 b/testdata/p4_16_samples_outputs/hdr_stacks2345-midend.p4 index 4b8a2506d09..29a158feb48 100644 --- a/testdata/p4_16_samples_outputs/hdr_stacks2345-midend.p4 +++ b/testdata/p4_16_samples_outputs/hdr_stacks2345-midend.p4 @@ -31,8 +31,11 @@ parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { @name("ingress.simple_action") action simple_action() { - h.h[0].a = (h.eth_hdr.src_addr != h.eth_hdr.dst_addr ? 8w2 : h.h[0].a); - h.h[1].a = (h.eth_hdr.src_addr != h.eth_hdr.dst_addr ? h.h[1].a : 8w1); + if (h.eth_hdr.src_addr != h.eth_hdr.dst_addr) { + h.h[0].a = 8w2; + } else { + h.h[1].a = 8w1; + } } @hidden table tbl_simple_action { actions = { diff --git a/testdata/p4_16_samples_outputs/issue1412-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/issue1412-bmv2-midend.p4 index 07df135a991..9196cc21f0c 100644 --- a/testdata/p4_16_samples_outputs/issue1412-bmv2-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue1412-bmv2-midend.p4 @@ -30,7 +30,9 @@ control EgressImpl(inout headers_t hdr, inout metadata meta, inout standard_meta @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("EgressImpl.set_true") action set_true() { - meta.cond = (meta.field == 8w0 ? true : meta.cond); + if (meta.field == 8w0) { + meta.cond = true; + } } @name("EgressImpl.change_cond") table change_cond_0 { key = { diff --git a/testdata/p4_16_samples_outputs/issue210-midend.p4 b/testdata/p4_16_samples_outputs/issue210-midend.p4 index bac2d9a445f..934758aa768 100644 --- a/testdata/p4_16_samples_outputs/issue210-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue210-midend.p4 @@ -1,8 +1,22 @@ #include control Ing(out bit<32> a) { + @name("Ing.b") bool b_0; @name("Ing.cond") action cond() { - a = 32w5; + if (b_0) { + a = 32w5; + } else { + a = 32w10; + } + } + @hidden action issue210l30() { + b_0 = true; + } + @hidden table tbl_issue210l30 { + actions = { + issue210l30(); + } + const default_action = issue210l30(); } @hidden table tbl_cond { actions = { @@ -11,6 +25,7 @@ control Ing(out bit<32> a) { const default_action = cond(); } apply { + tbl_issue210l30.apply(); tbl_cond.apply(); } } diff --git a/testdata/p4_16_samples_outputs/issue2248-midend.p4 b/testdata/p4_16_samples_outputs/issue2248-midend.p4 index 942245a6d49..f7182a05e60 100644 --- a/testdata/p4_16_samples_outputs/issue2248-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue2248-midend.p4 @@ -23,12 +23,16 @@ parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t } control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - @name("ingress.tmp_val") bit<48> tmp_val_0; @name("ingress.tmp") bit<48> tmp; @name("ingress.simple_action") action simple_action() { - tmp = (h.eth_hdr.eth_type != 16w0 ? (h.eth_hdr.src_addr != 48w0 ? 48w1 : 48w2) : tmp); - tmp_val_0 = (h.eth_hdr.eth_type != 16w0 ? tmp : tmp_val_0); - h.eth_hdr.dst_addr = (h.eth_hdr.eth_type != 16w0 ? tmp_val_0 : h.eth_hdr.dst_addr); + if (h.eth_hdr.eth_type != 16w0) { + if (h.eth_hdr.src_addr != 48w0) { + tmp = 48w1; + } else { + tmp = 48w2; + } + h.eth_hdr.dst_addr = tmp; + } } @hidden table tbl_simple_action { actions = { diff --git a/testdata/p4_16_samples_outputs/issue2330-1-midend.p4 b/testdata/p4_16_samples_outputs/issue2330-1-midend.p4 index 80e48968a3e..a22a209a696 100644 --- a/testdata/p4_16_samples_outputs/issue2330-1-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue2330-1-midend.p4 @@ -23,13 +23,19 @@ parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t } control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - @name("ingress.tmp") bit<48> tmp; - @name("ingress.val1_0") bit<16> val1; + @name("ingress.hasReturned") bool hasReturned; @name("ingress.do_action") action do_action() { - val1 = (h.eth_hdr.dst_addr != 48w0 ? h.eth_hdr.eth_type : val1); - h.eth_hdr.eth_type = (h.eth_hdr.dst_addr != 48w0 ? val1 : h.eth_hdr.eth_type); - tmp = (h.eth_hdr.dst_addr != 48w0 ? 48w1 : tmp); - h.eth_hdr.src_addr = (h.eth_hdr.dst_addr != 48w0 ? tmp : h.eth_hdr.src_addr); + hasReturned = false; + if (h.eth_hdr.dst_addr != 48w0) { + ; + } else { + hasReturned = true; + } + if (hasReturned) { + ; + } else { + h.eth_hdr.src_addr = 48w1; + } } @hidden table tbl_do_action { actions = { diff --git a/testdata/p4_16_samples_outputs/issue2330-midend.p4 b/testdata/p4_16_samples_outputs/issue2330-midend.p4 index d1474808995..a22a209a696 100644 --- a/testdata/p4_16_samples_outputs/issue2330-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue2330-midend.p4 @@ -23,13 +23,19 @@ parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t } control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - @name("ingress.tmp") bit<48> tmp; - @name("ingress.val_0") bit<16> val; + @name("ingress.hasReturned") bool hasReturned; @name("ingress.do_action") action do_action() { - val = (h.eth_hdr.dst_addr != 48w0 ? h.eth_hdr.eth_type : val); - h.eth_hdr.eth_type = (h.eth_hdr.dst_addr != 48w0 ? val : h.eth_hdr.eth_type); - tmp = (h.eth_hdr.dst_addr != 48w0 ? 48w1 : tmp); - h.eth_hdr.src_addr = (h.eth_hdr.dst_addr != 48w0 ? tmp : h.eth_hdr.src_addr); + hasReturned = false; + if (h.eth_hdr.dst_addr != 48w0) { + ; + } else { + hasReturned = true; + } + if (hasReturned) { + ; + } else { + h.eth_hdr.src_addr = 48w1; + } } @hidden table tbl_do_action { actions = { diff --git a/testdata/p4_16_samples_outputs/issue2344-midend.p4 b/testdata/p4_16_samples_outputs/issue2344-midend.p4 index fd2a7d5e2b8..093e34a8cd1 100644 --- a/testdata/p4_16_samples_outputs/issue2344-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue2344-midend.p4 @@ -20,7 +20,9 @@ control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { } @name("ingress.simple_action") action simple_action() { tmp1_0.setInvalid(); - tmp1_0.a = (tmp1_0.a != 32w10 ? tmp1_0.a + 32w10 : tmp1_0.a); + if (tmp1_0.a != 32w10) { + tmp1_0.a = tmp1_0.a + 32w10; + } h.h.a = tmp1_0.a; } @name("ingress.simple_table") table simple_table_0 { diff --git a/testdata/p4_16_samples_outputs/issue2345-1-midend.p4 b/testdata/p4_16_samples_outputs/issue2345-1-midend.p4 index 165f85aab03..646cc8c707a 100644 --- a/testdata/p4_16_samples_outputs/issue2345-1-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue2345-1-midend.p4 @@ -23,17 +23,26 @@ parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t } control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + @name("ingress.hasReturned") bool hasReturned; ethernet_t val1_eth_hdr; ethernet_t val_eth_hdr; @name("ingress.simple_action") action simple_action() { - h.eth_hdr.src_addr = 48w1; - val1_eth_hdr = h.eth_hdr; - val_eth_hdr = h.eth_hdr; - val_eth_hdr.dst_addr = 48w2; - val_eth_hdr.eth_type = 16w4; - val1_eth_hdr = val_eth_hdr; - val1_eth_hdr.dst_addr = 48w3; - h.eth_hdr = val1_eth_hdr; + hasReturned = false; + if (h.eth_hdr.eth_type == 16w1) { + hasReturned = true; + } + if (hasReturned) { + ; + } else { + h.eth_hdr.src_addr = 48w1; + val1_eth_hdr = h.eth_hdr; + val_eth_hdr = h.eth_hdr; + val_eth_hdr.dst_addr = 48w2; + val_eth_hdr.eth_type = 16w4; + val1_eth_hdr = val_eth_hdr; + val1_eth_hdr.dst_addr = 48w3; + h.eth_hdr = val1_eth_hdr; + } } @hidden action issue23451l47() { h.eth_hdr.src_addr = 48w2; diff --git a/testdata/p4_16_samples_outputs/issue2345-2-midend.p4 b/testdata/p4_16_samples_outputs/issue2345-2-midend.p4 index 06214cb0f23..0d8d5728037 100644 --- a/testdata/p4_16_samples_outputs/issue2345-2-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue2345-2-midend.p4 @@ -23,21 +23,30 @@ parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t } control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + @name("ingress.hasReturned") bool hasReturned; ethernet_t val_eth_hdr; ethernet_t val1_eth_hdr; ethernet_t val1_2_eth_hdr; @name("ingress.simple_action") action simple_action() { - h.eth_hdr.src_addr = 48w1; - val_eth_hdr = h.eth_hdr; - val1_eth_hdr = h.eth_hdr; - val1_eth_hdr.dst_addr = val1_eth_hdr.dst_addr + 48w3; - val_eth_hdr = val1_eth_hdr; - val_eth_hdr.eth_type = 16w2; - val1_2_eth_hdr = val_eth_hdr; - val1_2_eth_hdr.dst_addr = val1_2_eth_hdr.dst_addr + 48w3; - val_eth_hdr = val1_2_eth_hdr; - h.eth_hdr = val1_2_eth_hdr; - h.eth_hdr.dst_addr = h.eth_hdr.dst_addr + 48w4; + hasReturned = false; + if (h.eth_hdr.eth_type == 16w1) { + hasReturned = true; + } + if (hasReturned) { + ; + } else { + h.eth_hdr.src_addr = 48w1; + val_eth_hdr = h.eth_hdr; + val1_eth_hdr = h.eth_hdr; + val1_eth_hdr.dst_addr = val1_eth_hdr.dst_addr + 48w3; + val_eth_hdr = val1_eth_hdr; + val_eth_hdr.eth_type = 16w2; + val1_2_eth_hdr = val_eth_hdr; + val1_2_eth_hdr.dst_addr = val1_2_eth_hdr.dst_addr + 48w3; + val_eth_hdr = val1_2_eth_hdr; + h.eth_hdr = val1_2_eth_hdr; + h.eth_hdr.dst_addr = h.eth_hdr.dst_addr + 48w4; + } } @hidden action issue23452l49() { h.eth_hdr.src_addr = 48w2; diff --git a/testdata/p4_16_samples_outputs/issue2345-midend.p4 b/testdata/p4_16_samples_outputs/issue2345-midend.p4 index 367030f8a4c..1f9d0c58124 100644 --- a/testdata/p4_16_samples_outputs/issue2345-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue2345-midend.p4 @@ -23,8 +23,17 @@ parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t } control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + @name("ingress.hasReturned") bool hasReturned; @name("ingress.simple_action") action simple_action() { - h.eth_hdr.src_addr = 48w1; + hasReturned = false; + if (h.eth_hdr.eth_type == 16w1) { + hasReturned = true; + } + if (hasReturned) { + ; + } else { + h.eth_hdr.src_addr = 48w1; + } } @hidden action issue2345l40() { h.eth_hdr.src_addr = 48w2; diff --git a/testdata/p4_16_samples_outputs/issue2345-multiple_dependencies-midend.p4 b/testdata/p4_16_samples_outputs/issue2345-multiple_dependencies-midend.p4 index 37adcaac966..927fd40f04b 100644 --- a/testdata/p4_16_samples_outputs/issue2345-multiple_dependencies-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue2345-multiple_dependencies-midend.p4 @@ -23,13 +23,22 @@ parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t } control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + @name("ingress.hasReturned") bool hasReturned; ethernet_t val1_eth_hdr; @name("ingress.simple_action") action simple_action() { - h.eth_hdr.src_addr = 48w1; - val1_eth_hdr = h.eth_hdr; - val1_eth_hdr.dst_addr = 48w2; - val1_eth_hdr.dst_addr = 48w5; - h.eth_hdr = val1_eth_hdr; + hasReturned = false; + if (h.eth_hdr.eth_type == 16w1) { + hasReturned = true; + } + if (hasReturned) { + ; + } else { + h.eth_hdr.src_addr = 48w1; + val1_eth_hdr = h.eth_hdr; + val1_eth_hdr.dst_addr = 48w2; + val1_eth_hdr.dst_addr = 48w5; + h.eth_hdr = val1_eth_hdr; + } } @hidden action issue2345multiple_dependencies60() { h.eth_hdr.src_addr = 48w2; diff --git a/testdata/p4_16_samples_outputs/issue2345-with_nested_if-midend.p4 b/testdata/p4_16_samples_outputs/issue2345-with_nested_if-midend.p4 index 3c53d21c9c2..0323f3f9fe7 100644 --- a/testdata/p4_16_samples_outputs/issue2345-with_nested_if-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue2345-with_nested_if-midend.p4 @@ -23,21 +23,27 @@ parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t } control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + @name("ingress.hasReturned") bool hasReturned; ethernet_t val1_eth_hdr; ethernet_t val_eth_hdr; @name("ingress.simple_action") action simple_action() { - h.eth_hdr.src_addr = 48w1; - val1_eth_hdr = h.eth_hdr; - val_eth_hdr = h.eth_hdr; - val_eth_hdr.eth_type = 16w0; - val_eth_hdr.eth_type = 16w0; - val_eth_hdr.eth_type = 16w2; - val_eth_hdr.eth_type = 16w5; - val_eth_hdr.eth_type = 16w5; - val_eth_hdr.eth_type = 16w5; - val1_eth_hdr = val_eth_hdr; - val1_eth_hdr.dst_addr = 48w3; - h.eth_hdr = val1_eth_hdr; + hasReturned = false; + if (h.eth_hdr.eth_type == 16w1) { + hasReturned = true; + } + if (hasReturned) { + ; + } else { + h.eth_hdr.src_addr = 48w1; + val1_eth_hdr = h.eth_hdr; + val_eth_hdr = h.eth_hdr; + val_eth_hdr.eth_type = 16w0; + val_eth_hdr.eth_type = 16w2; + val_eth_hdr.eth_type = 16w5; + val1_eth_hdr = val_eth_hdr; + val1_eth_hdr.dst_addr = 48w3; + h.eth_hdr = val1_eth_hdr; + } } @hidden action issue2345with_nested_if65() { h.eth_hdr.src_addr = 48w2; diff --git a/testdata/p4_16_samples_outputs/issue2359-midend.p4 b/testdata/p4_16_samples_outputs/issue2359-midend.p4 index f861bee187b..fa1659cc3c0 100644 --- a/testdata/p4_16_samples_outputs/issue2359-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue2359-midend.p4 @@ -24,12 +24,17 @@ parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { bool hasExited; - @name("ingress.val") bit<48> val_0; + @name("ingress.hasReturned") bool hasReturned; @name("ingress.do_action") action do_action() { - val_0 = h.eth_hdr.src_addr; - h.eth_hdr.src_addr = h.eth_hdr.src_addr; - hasExited = !(h.eth_hdr.eth_type == 16w1); - h.eth_hdr.src_addr = (h.eth_hdr.eth_type == 16w1 ? val_0 : h.eth_hdr.src_addr); + hasReturned = false; + if (h.eth_hdr.eth_type == 16w1) { + hasReturned = true; + } + if (hasReturned) { + ; + } else { + hasExited = true; + } } @hidden action act() { hasExited = false; diff --git a/testdata/p4_16_samples_outputs/issue420-midend.p4 b/testdata/p4_16_samples_outputs/issue420-midend.p4 index 683780a2017..2386b2be60e 100644 --- a/testdata/p4_16_samples_outputs/issue420-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue420-midend.p4 @@ -31,11 +31,20 @@ parser parserI(packet_in pkt, out Parsed_packet hdr, inout mystruct1 meta, inout } control cIngress(inout Parsed_packet hdr, inout mystruct1 meta, inout standard_metadata_t stdmeta) { + @name("cIngress.hasReturned") bool hasReturned; @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("cIngress.foo") action foo(@name("bar") bit<16> bar) { - hdr.ethernet.srcAddr = (bar == 16w0xf00d ? 48w0xdeadbeeff00d : hdr.ethernet.srcAddr); - hdr.ethernet.srcAddr = (bar == 16w0xf00d ? hdr.ethernet.srcAddr : 48w0x215241100ff2); + hasReturned = false; + if (bar == 16w0xf00d) { + hdr.ethernet.srcAddr = 48w0xdeadbeeff00d; + hasReturned = true; + } + if (hasReturned) { + ; + } else { + hdr.ethernet.srcAddr = 48w0x215241100ff2; + } } @name("cIngress.tbl1") table tbl1_0 { actions = { diff --git a/testdata/p4_16_samples_outputs/issue512-midend.p4 b/testdata/p4_16_samples_outputs/issue512-midend.p4 index 459cc224074..e14b2e27269 100644 --- a/testdata/p4_16_samples_outputs/issue512-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue512-midend.p4 @@ -31,12 +31,19 @@ parser parserI(packet_in pkt, out Parsed_packet hdr, inout mystruct1 meta, inout } control cIngress(inout Parsed_packet hdr, inout mystruct1 meta, inout standard_metadata_t stdmeta) { - bool cond; + @name("cIngress.hasReturned") bool hasReturned; @name("cIngress.foo") action foo() { + hasReturned = false; meta.b = meta.b + 4w5; - cond = meta.b > 4w10; - meta.b = (meta.b > 4w10 ? meta.b ^ 4w5 : meta.b); - meta.b = (cond ? meta.b : meta.b + 4w5); + if (meta.b > 4w10) { + meta.b = meta.b ^ 4w5; + hasReturned = true; + } + if (hasReturned) { + ; + } else { + meta.b = meta.b + 4w5; + } } @name("cIngress.guh") table guh_0 { key = { diff --git a/testdata/p4_16_samples_outputs/m_psa-dpdk-non-zero-arg-default-action-08-midend.p4 b/testdata/p4_16_samples_outputs/m_psa-dpdk-non-zero-arg-default-action-08-midend.p4 index 8195dc2a37f..2c710415c7d 100644 --- a/testdata/p4_16_samples_outputs/m_psa-dpdk-non-zero-arg-default-action-08-midend.p4 +++ b/testdata/p4_16_samples_outputs/m_psa-dpdk-non-zero-arg-default-action-08-midend.p4 @@ -32,8 +32,10 @@ control MyIngressControl(inout headers_t hdr, inout user_meta_data_t m, in psa_i hdr.ethernet.src_addr = m.addr; } @name("MyIngressControl.macswp") action macswp(@name("tmp2") bit<32> tmp2) { - m.addr = (hdr.ethernet.dst_addr == 48w0x1 && tmp2 == 32w0x2 ? hdr.ethernet.dst_addr : m.addr); - hdr.ethernet.src_addr = (hdr.ethernet.dst_addr == 48w0x1 && tmp2 == 32w0x2 ? m.addr : hdr.ethernet.src_addr); + if (hdr.ethernet.dst_addr == 48w0x1 && tmp2 == 32w0x2) { + m.addr = hdr.ethernet.dst_addr; + hdr.ethernet.src_addr = hdr.ethernet.dst_addr; + } } @name("MyIngressControl.stub") table stub_0 { actions = { diff --git a/testdata/p4_16_samples_outputs/nested_if_else-midend.p4 b/testdata/p4_16_samples_outputs/nested_if_else-midend.p4 index 98f0326cdcf..c494e57ec84 100644 --- a/testdata/p4_16_samples_outputs/nested_if_else-midend.p4 +++ b/testdata/p4_16_samples_outputs/nested_if_else-midend.p4 @@ -53,10 +53,25 @@ control MyVerifyChecksum(inout headers hdr, inout metadata meta) { } control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("MyIngress.x") bit<16> x_0; @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("MyIngress.ipv4_forward") action ipv4_forward() { - hdr.ipv4.totalLen = hdr.ipv4.totalLen + (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) + 16w3) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification))) + 16w4 : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) + 16w3) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)))) : (hdr.ipv4.identification > 16w2 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) + 16w3) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification))) + 16w4 : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) + 16w3) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)))) + 16w5 : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) + 16w3) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification))) + 16w4 : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) + 16w3) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)))))) : (hdr.ipv4.identification > 16w2 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) + 16w3) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification))) + 16w4 : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) + 16w3) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)))) : (hdr.ipv4.identification > 16w2 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) + 16w3) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification))) + 16w4 : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) + 16w3) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)))) + 16w5 : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) + 16w3) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification))) + 16w4 : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) + 16w3) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)))))) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) + 16w3) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification))) + 16w4 : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) + 16w3) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)))) : (hdr.ipv4.identification > 16w2 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) + 16w3) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification))) + 16w4 : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) + 16w3) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)))) + 16w5 : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) + 16w3) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification))) + 16w4 : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) + 16w3) : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w1 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + 16w2 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)))))) + 16w6)) + hdr.ipv4.hdrChecksum; + x_0 = hdr.ipv4.identification; + if (hdr.ipv4.identification > 16w0) { + x_0 = 16w1; + if (hdr.ipv4.identification > 16w1) { + x_0 = 16w3; + } else { + x_0 = 16w4; + } + x_0 = x_0 + 16w4; + } else if (hdr.ipv4.identification > 16w2) { + x_0 = hdr.ipv4.identification + 16w5; + } else { + x_0 = hdr.ipv4.identification + 16w6; + } + hdr.ipv4.totalLen = hdr.ipv4.totalLen + x_0 + hdr.ipv4.hdrChecksum; } @name("MyIngress.drop") action drop() { } diff --git a/testdata/p4_16_samples_outputs/nested_if_lvalue_dependencies-midend.p4 b/testdata/p4_16_samples_outputs/nested_if_lvalue_dependencies-midend.p4 index e2e3341e749..4ab1c567682 100644 --- a/testdata/p4_16_samples_outputs/nested_if_lvalue_dependencies-midend.p4 +++ b/testdata/p4_16_samples_outputs/nested_if_lvalue_dependencies-midend.p4 @@ -53,10 +53,24 @@ control MyVerifyChecksum(inout headers hdr, inout metadata meta) { } control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("MyIngress.x") bit<16> x_0; + @name("MyIngress.y") bit<16> y_0; + @name("MyIngress.z") bit<16> z_0; @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("MyIngress.ipv4_forward") action ipv4_forward() { - hdr.ipv4.totalLen = (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + (hdr.ipv4.identification > 16w0 ? 16w2 : hdr.ipv4.hdrChecksum) + 16w3 : hdr.ipv4.totalLen) + (hdr.ipv4.identification > 16w0 ? 16w5 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) + (hdr.ipv4.identification > 16w0 ? 16w4 : (hdr.ipv4.identification > 16w0 ? 16w2 : hdr.ipv4.hdrChecksum)) + 16w13 : (hdr.ipv4.identification > 16w0 ? (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification) + (hdr.ipv4.identification > 16w0 ? 16w2 : hdr.ipv4.hdrChecksum) + 16w3 : hdr.ipv4.totalLen)) + (hdr.ipv4.identification > 16w0 ? 16w5 : (hdr.ipv4.identification > 16w0 ? 16w1 : hdr.ipv4.identification)) + (hdr.ipv4.identification > 16w0 ? 16w4 : (hdr.ipv4.identification > 16w0 ? 16w2 : hdr.ipv4.hdrChecksum)); + x_0 = hdr.ipv4.identification; + y_0 = hdr.ipv4.hdrChecksum; + z_0 = hdr.ipv4.totalLen; + if (hdr.ipv4.identification > 16w0) { + x_0 = 16w1; + y_0 = 16w2; + z_0 = 16w6; + y_0 = 16w4; + x_0 = 16w5; + z_0 = 16w28; + } + hdr.ipv4.totalLen = z_0 + x_0 + y_0; } @name("MyIngress.drop") action drop() { } diff --git a/testdata/p4_16_samples_outputs/nested_if_statement-midend.p4 b/testdata/p4_16_samples_outputs/nested_if_statement-midend.p4 index 4b8b0cf7a62..244da73b082 100644 --- a/testdata/p4_16_samples_outputs/nested_if_statement-midend.p4 +++ b/testdata/p4_16_samples_outputs/nested_if_statement-midend.p4 @@ -53,10 +53,22 @@ control MyVerifyChecksum(inout headers hdr, inout metadata meta) { } control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("MyIngress.x") bit<16> x_0; @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("MyIngress.ipv4_forward") action ipv4_forward() { - hdr.ipv4.totalLen = hdr.ipv4.totalLen + (hdr.ipv4.identification > 16w0 ? 16w0 : (hdr.ipv4.identification > 16w1 ? 16w1 : (hdr.ipv4.identification > 16w2 ? 16w2 : (hdr.ipv4.identification > 16w3 ? 16w3 : 16w4)))) + hdr.ipv4.hdrChecksum; + if (hdr.ipv4.identification > 16w0) { + x_0 = 16w0; + } else if (hdr.ipv4.identification > 16w1) { + x_0 = 16w1; + } else if (hdr.ipv4.identification > 16w2) { + x_0 = 16w2; + } else if (hdr.ipv4.identification > 16w3) { + x_0 = 16w3; + } else { + x_0 = 16w4; + } + hdr.ipv4.totalLen = hdr.ipv4.totalLen + x_0 + hdr.ipv4.hdrChecksum; } @name("MyIngress.drop") action drop() { } diff --git a/testdata/p4_16_samples_outputs/pna-dpdk-direct-counter-first.p4 b/testdata/p4_16_samples_outputs/pna-dpdk-direct-counter-first.p4 index 12dc3ded6aa..c3e6a7e9426 100644 --- a/testdata/p4_16_samples_outputs/pna-dpdk-direct-counter-first.p4 +++ b/testdata/p4_16_samples_outputs/pna-dpdk-direct-counter-first.p4 @@ -28,6 +28,7 @@ struct empty_metadata_t { } struct main_metadata_t { + bit<32> data; } struct headers_t { @@ -64,7 +65,9 @@ control MainControlImpl(inout headers_t hdr, inout main_metadata_t user_meta, in DirectCounter(PNA_CounterType_t.PACKETS_AND_BYTES) per_prefix_pkt_bytes_count; DirectCounter(PNA_CounterType_t.PACKETS) per_prefix_pkt_count; action count() { - per_prefix_pkt_count.count(); + if (user_meta.data == 32w8) { + per_prefix_pkt_count.count(); + } } action bytecount() { per_prefix_bytes_count.count(32w1024); diff --git a/testdata/p4_16_samples_outputs/pna-dpdk-direct-counter-frontend.p4 b/testdata/p4_16_samples_outputs/pna-dpdk-direct-counter-frontend.p4 index 8f94036e210..b11f0afc75d 100644 --- a/testdata/p4_16_samples_outputs/pna-dpdk-direct-counter-frontend.p4 +++ b/testdata/p4_16_samples_outputs/pna-dpdk-direct-counter-frontend.p4 @@ -27,6 +27,7 @@ struct empty_metadata_t { } struct main_metadata_t { + bit<32> data; } struct headers_t { @@ -61,7 +62,9 @@ control MainControlImpl(inout headers_t hdr, inout main_metadata_t user_meta, in @name("MainControlImpl.per_prefix_pkt_bytes_count") DirectCounter(PNA_CounterType_t.PACKETS_AND_BYTES) per_prefix_pkt_bytes_count_0; @name("MainControlImpl.per_prefix_pkt_count") DirectCounter(PNA_CounterType_t.PACKETS) per_prefix_pkt_count_0; @name("MainControlImpl.count") action count_1() { - per_prefix_pkt_count_0.count(); + if (user_meta.data == 32w8) { + per_prefix_pkt_count_0.count(); + } } @name("MainControlImpl.bytecount") action bytecount() { per_prefix_bytes_count_0.count(32w1024); diff --git a/testdata/p4_16_samples_outputs/pna-dpdk-direct-counter-midend.p4 b/testdata/p4_16_samples_outputs/pna-dpdk-direct-counter-midend.p4 index 95b6fa3da7a..d77cedbc2d9 100644 --- a/testdata/p4_16_samples_outputs/pna-dpdk-direct-counter-midend.p4 +++ b/testdata/p4_16_samples_outputs/pna-dpdk-direct-counter-midend.p4 @@ -26,6 +26,7 @@ struct empty_metadata_t { } struct main_metadata_t { + bit<32> data; } struct headers_t { @@ -57,7 +58,9 @@ control MainControlImpl(inout headers_t hdr, inout main_metadata_t user_meta, in @name("MainControlImpl.per_prefix_pkt_bytes_count") DirectCounter>(PNA_CounterType_t.PACKETS_AND_BYTES) per_prefix_pkt_bytes_count_0; @name("MainControlImpl.per_prefix_pkt_count") DirectCounter>(PNA_CounterType_t.PACKETS) per_prefix_pkt_count_0; @name("MainControlImpl.count") action count_1() { - per_prefix_pkt_count_0.count(); + if (user_meta.data == 32w8) { + per_prefix_pkt_count_0.count(); + } } @name("MainControlImpl.bytecount") action bytecount() { per_prefix_bytes_count_0.count(32w1024); @@ -106,18 +109,18 @@ control MainControlImpl(inout headers_t hdr, inout main_metadata_t user_meta, in } control MainDeparserImpl(packet_out pkt, in headers_t hdr, in main_metadata_t user_meta, in pna_main_output_metadata_t ostd) { - @hidden action pnadpdkdirectcounter153() { + @hidden action pnadpdkdirectcounter157() { pkt.emit(hdr.ethernet); pkt.emit(hdr.ipv4); } - @hidden table tbl_pnadpdkdirectcounter153 { + @hidden table tbl_pnadpdkdirectcounter157 { actions = { - pnadpdkdirectcounter153(); + pnadpdkdirectcounter157(); } - const default_action = pnadpdkdirectcounter153(); + const default_action = pnadpdkdirectcounter157(); } apply { - tbl_pnadpdkdirectcounter153.apply(); + tbl_pnadpdkdirectcounter157.apply(); } } diff --git a/testdata/p4_16_samples_outputs/pna-dpdk-direct-counter.p4 b/testdata/p4_16_samples_outputs/pna-dpdk-direct-counter.p4 index 2317fd8bfee..6c0a9d9ce9d 100644 --- a/testdata/p4_16_samples_outputs/pna-dpdk-direct-counter.p4 +++ b/testdata/p4_16_samples_outputs/pna-dpdk-direct-counter.p4 @@ -28,6 +28,7 @@ struct empty_metadata_t { } struct main_metadata_t { + bit<32> data; } struct headers_t { @@ -64,10 +65,14 @@ control MainControlImpl(inout headers_t hdr, inout main_metadata_t user_meta, in DirectCounter(PNA_CounterType_t.PACKETS_AND_BYTES) per_prefix_pkt_bytes_count; DirectCounter(PNA_CounterType_t.PACKETS) per_prefix_pkt_count; action count() { - per_prefix_pkt_count.count(); + if (user_meta.data == 32w8) { + per_prefix_pkt_count.count(); + } } action bytecount() { - per_prefix_bytes_count.count(1024); + { + per_prefix_bytes_count.count(1024); + } } action pktbytecount() { per_prefix_pkt_bytes_count.count(1024); diff --git a/testdata/p4_16_samples_outputs/pna-dpdk-direct-meter-learner-midend.p4 b/testdata/p4_16_samples_outputs/pna-dpdk-direct-meter-learner-midend.p4 index ae8a2d93914..61e1a778453 100644 --- a/testdata/p4_16_samples_outputs/pna-dpdk-direct-meter-learner-midend.p4 +++ b/testdata/p4_16_samples_outputs/pna-dpdk-direct-meter-learner-midend.p4 @@ -62,13 +62,19 @@ struct tuple_0 { control MainControlImpl(inout headers_t hdr, inout main_metadata_t user_meta, in pna_main_input_metadata_t istd, inout pna_main_output_metadata_t ostd) { @name("MainControlImpl.color_out") PNA_MeterColor_t color_out_0; @name("MainControlImpl.color_in") PNA_MeterColor_t color_in_0; + @name("MainControlImpl.tmp") bit<32> tmp_0; @name("MainControlImpl.meter0") DirectMeter(PNA_MeterType_t.PACKETS) meter0_0; @name("MainControlImpl.next_hop") action next_hop(@name("vport") bit<32> vport) { send_to_port(vport); } @name("MainControlImpl.add_on_miss_action") action add_on_miss_action() { color_out_0 = meter0_0.dpdk_execute(color_in_0, 32w1024); - user_meta.port_out = (color_out_0 == PNA_MeterColor_t.GREEN ? 32w1 : 32w0); + if (color_out_0 == PNA_MeterColor_t.GREEN) { + tmp_0 = 32w1; + } else { + tmp_0 = 32w0; + } + user_meta.port_out = tmp_0; add_entry>(action_name = "next_hop", action_params = 32w0, expire_time_profile_id = user_meta.timeout); } @name("MainControlImpl.ipv4_da") table ipv4_da_0 { diff --git a/testdata/p4_16_samples_outputs/pna-example-pass-2-first.p4 b/testdata/p4_16_samples_outputs/pna-example-pass-2-first.p4 new file mode 100644 index 00000000000..620c2515503 --- /dev/null +++ b/testdata/p4_16_samples_outputs/pna-example-pass-2-first.p4 @@ -0,0 +1,93 @@ +#include +#include + +typedef bit<48> EthernetAddress; +header ethernet_t { + EthernetAddress dstAddr; + EthernetAddress srcAddr; + bit<16> etherType; +} + +header ipv4_t { + bit<4> version; + bit<4> ihl; + bit<8> diffserv; + bit<16> totalLen; + bit<16> identification; + bit<3> flags; + bit<13> fragOffset; + bit<8> ttl; + bit<8> protocol; + bit<16> hdrChecksum; + bit<32> srcAddr; + bit<32> dstAddr; +} + +struct empty_metadata_t { +} + +struct main_metadata_t { +} + +struct headers_t { + ethernet_t ethernet; + ipv4_t ipv4; +} + +control PreControlImpl(in headers_t hdr, inout main_metadata_t meta, in pna_pre_input_metadata_t istd, inout pna_pre_output_metadata_t ostd) { + apply { + } +} + +parser MainParserImpl(packet_in pkt, out headers_t hdr, inout main_metadata_t main_meta, in pna_main_parser_input_metadata_t istd) { + state start { + pkt.extract(hdr.ethernet); + transition select(hdr.ethernet.etherType) { + 16w0x800: parse_ipv4; + default: accept; + } + } + state parse_ipv4 { + pkt.extract(hdr.ipv4); + transition accept; + } +} + +control MainControlImpl(inout headers_t hdr, inout main_metadata_t user_meta, in pna_main_input_metadata_t istd, inout pna_main_output_metadata_t ostd) { + action next_hop(in PassNumber_t pass, PortId_t vport) { + if (pass == (PassNumber_t)3w0) { + recirculate(); + } else { + send_to_port(vport); + } + } + action default_route_drop() { + drop_packet(); + } + table ipv4_da_lpm { + key = { + hdr.ipv4.dstAddr: lpm @name("hdr.ipv4.dstAddr"); + } + actions = { + next_hop(istd.pass); + default_route_drop(); + } + const default_action = default_route_drop(); + } + apply { + if (hdr.ipv4.isValid()) { + if ((SelectByDirection>(istd.direction, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr)) == hdr.ipv4.dstAddr) { + ipv4_da_lpm.apply(); + } + } + } +} + +control MainDeparserImpl(packet_out pkt, in headers_t hdr, in main_metadata_t user_meta, in pna_main_output_metadata_t ostd) { + apply { + pkt.emit(hdr.ethernet); + pkt.emit(hdr.ipv4); + } +} + +PNA_NIC(MainParserImpl(), PreControlImpl(), MainControlImpl(), MainDeparserImpl()) main; diff --git a/testdata/p4_16_samples_outputs/pna-example-pass-2-frontend.p4 b/testdata/p4_16_samples_outputs/pna-example-pass-2-frontend.p4 new file mode 100644 index 00000000000..98802ec1347 --- /dev/null +++ b/testdata/p4_16_samples_outputs/pna-example-pass-2-frontend.p4 @@ -0,0 +1,99 @@ +#include +#include + +typedef bit<48> EthernetAddress; +header ethernet_t { + EthernetAddress dstAddr; + EthernetAddress srcAddr; + bit<16> etherType; +} + +header ipv4_t { + bit<4> version; + bit<4> ihl; + bit<8> diffserv; + bit<16> totalLen; + bit<16> identification; + bit<3> flags; + bit<13> fragOffset; + bit<8> ttl; + bit<8> protocol; + bit<16> hdrChecksum; + bit<32> srcAddr; + bit<32> dstAddr; +} + +struct empty_metadata_t { +} + +struct main_metadata_t { +} + +struct headers_t { + ethernet_t ethernet; + ipv4_t ipv4; +} + +control PreControlImpl(in headers_t hdr, inout main_metadata_t meta, in pna_pre_input_metadata_t istd, inout pna_pre_output_metadata_t ostd) { + apply { + } +} + +parser MainParserImpl(packet_in pkt, out headers_t hdr, inout main_metadata_t main_meta, in pna_main_parser_input_metadata_t istd) { + state start { + pkt.extract(hdr.ethernet); + transition select(hdr.ethernet.etherType) { + 16w0x800: parse_ipv4; + default: accept; + } + } + state parse_ipv4 { + pkt.extract(hdr.ipv4); + transition accept; + } +} + +control MainControlImpl(inout headers_t hdr, inout main_metadata_t user_meta, in pna_main_input_metadata_t istd, inout pna_main_output_metadata_t ostd) { + @name("MainControlImpl.tmp") bit<32> tmp; + @name("MainControlImpl.tmp_0") bool tmp_0; + @name("MainControlImpl.pass") PassNumber_t pass_0; + @name("MainControlImpl.next_hop") action next_hop(@name("vport") PortId_t vport) { + pass_0 = istd.pass; + if (pass_0 == (PassNumber_t)3w0) { + recirculate(); + } else { + send_to_port(vport); + } + } + @name("MainControlImpl.default_route_drop") action default_route_drop() { + drop_packet(); + } + @name("MainControlImpl.ipv4_da_lpm") table ipv4_da_lpm_0 { + key = { + hdr.ipv4.dstAddr: lpm @name("hdr.ipv4.dstAddr"); + } + actions = { + next_hop(); + default_route_drop(); + } + const default_action = default_route_drop(); + } + apply { + if (hdr.ipv4.isValid()) { + tmp = SelectByDirection>(istd.direction, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr); + tmp_0 = tmp == hdr.ipv4.dstAddr; + if (tmp_0) { + ipv4_da_lpm_0.apply(); + } + } + } +} + +control MainDeparserImpl(packet_out pkt, in headers_t hdr, in main_metadata_t user_meta, in pna_main_output_metadata_t ostd) { + apply { + pkt.emit(hdr.ethernet); + pkt.emit(hdr.ipv4); + } +} + +PNA_NIC(MainParserImpl(), PreControlImpl(), MainControlImpl(), MainDeparserImpl()) main; diff --git a/testdata/p4_16_samples_outputs/pna-example-pass-2-midend.p4 b/testdata/p4_16_samples_outputs/pna-example-pass-2-midend.p4 new file mode 100644 index 00000000000..f4d778dbfdf --- /dev/null +++ b/testdata/p4_16_samples_outputs/pna-example-pass-2-midend.p4 @@ -0,0 +1,112 @@ +#include +#include + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +header ipv4_t { + bit<4> version; + bit<4> ihl; + bit<8> diffserv; + bit<16> totalLen; + bit<16> identification; + bit<3> flags; + bit<13> fragOffset; + bit<8> ttl; + bit<8> protocol; + bit<16> hdrChecksum; + bit<32> srcAddr; + bit<32> dstAddr; +} + +struct empty_metadata_t { +} + +struct main_metadata_t { +} + +struct headers_t { + ethernet_t ethernet; + ipv4_t ipv4; +} + +control PreControlImpl(in headers_t hdr, inout main_metadata_t meta, in pna_pre_input_metadata_t istd, inout pna_pre_output_metadata_t ostd) { + apply { + } +} + +parser MainParserImpl(packet_in pkt, out headers_t hdr, inout main_metadata_t main_meta, in pna_main_parser_input_metadata_t istd) { + state start { + pkt.extract(hdr.ethernet); + transition select(hdr.ethernet.etherType) { + 16w0x800: parse_ipv4; + default: accept; + } + } + state parse_ipv4 { + pkt.extract(hdr.ipv4); + transition accept; + } +} + +control MainControlImpl(inout headers_t hdr, inout main_metadata_t user_meta, in pna_main_input_metadata_t istd, inout pna_main_output_metadata_t ostd) { + @name("MainControlImpl.tmp") bit<32> tmp; + @name("MainControlImpl.next_hop") action next_hop(@name("vport") bit<32> vport) { + if (istd.pass == 3w0) { + recirculate(); + } else { + send_to_port(vport); + } + } + @name("MainControlImpl.default_route_drop") action default_route_drop() { + drop_packet(); + } + @name("MainControlImpl.ipv4_da_lpm") table ipv4_da_lpm_0 { + key = { + hdr.ipv4.dstAddr: lpm @name("hdr.ipv4.dstAddr"); + } + actions = { + next_hop(); + default_route_drop(); + } + const default_action = default_route_drop(); + } + @hidden action act() { + tmp = SelectByDirection>(istd.direction, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr); + } + @hidden table tbl_act { + actions = { + act(); + } + const default_action = act(); + } + apply { + if (hdr.ipv4.isValid()) { + tbl_act.apply(); + if (tmp == hdr.ipv4.dstAddr) { + ipv4_da_lpm_0.apply(); + } + } + } +} + +control MainDeparserImpl(packet_out pkt, in headers_t hdr, in main_metadata_t user_meta, in pna_main_output_metadata_t ostd) { + @hidden action pnaexamplepass2l139() { + pkt.emit(hdr.ethernet); + pkt.emit(hdr.ipv4); + } + @hidden table tbl_pnaexamplepass2l139 { + actions = { + pnaexamplepass2l139(); + } + const default_action = pnaexamplepass2l139(); + } + apply { + tbl_pnaexamplepass2l139.apply(); + } +} + +PNA_NIC(MainParserImpl(), PreControlImpl(), MainControlImpl(), MainDeparserImpl()) main; diff --git a/testdata/p4_16_samples_outputs/pna-example-pass-2.p4 b/testdata/p4_16_samples_outputs/pna-example-pass-2.p4 new file mode 100644 index 00000000000..a8f90a2c855 --- /dev/null +++ b/testdata/p4_16_samples_outputs/pna-example-pass-2.p4 @@ -0,0 +1,93 @@ +#include +#include + +typedef bit<48> EthernetAddress; +header ethernet_t { + EthernetAddress dstAddr; + EthernetAddress srcAddr; + bit<16> etherType; +} + +header ipv4_t { + bit<4> version; + bit<4> ihl; + bit<8> diffserv; + bit<16> totalLen; + bit<16> identification; + bit<3> flags; + bit<13> fragOffset; + bit<8> ttl; + bit<8> protocol; + bit<16> hdrChecksum; + bit<32> srcAddr; + bit<32> dstAddr; +} + +struct empty_metadata_t { +} + +struct main_metadata_t { +} + +struct headers_t { + ethernet_t ethernet; + ipv4_t ipv4; +} + +control PreControlImpl(in headers_t hdr, inout main_metadata_t meta, in pna_pre_input_metadata_t istd, inout pna_pre_output_metadata_t ostd) { + apply { + } +} + +parser MainParserImpl(packet_in pkt, out headers_t hdr, inout main_metadata_t main_meta, in pna_main_parser_input_metadata_t istd) { + state start { + pkt.extract(hdr.ethernet); + transition select(hdr.ethernet.etherType) { + 0x800: parse_ipv4; + default: accept; + } + } + state parse_ipv4 { + pkt.extract(hdr.ipv4); + transition accept; + } +} + +control MainControlImpl(inout headers_t hdr, inout main_metadata_t user_meta, in pna_main_input_metadata_t istd, inout pna_main_output_metadata_t ostd) { + action next_hop(in PassNumber_t pass, PortId_t vport) { + if (pass == (PassNumber_t)0) { + recirculate(); + } else { + send_to_port(vport); + } + } + action default_route_drop() { + drop_packet(); + } + table ipv4_da_lpm { + key = { + hdr.ipv4.dstAddr: lpm; + } + actions = { + next_hop(istd.pass); + default_route_drop; + } + const default_action = default_route_drop; + } + apply { + if (hdr.ipv4.isValid()) { + if (SelectByDirection(istd.direction, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr) == hdr.ipv4.dstAddr) { + ipv4_da_lpm.apply(); + } + } + } +} + +control MainDeparserImpl(packet_out pkt, in headers_t hdr, in main_metadata_t user_meta, in pna_main_output_metadata_t ostd) { + apply { + pkt.emit(hdr.ethernet); + pkt.emit(hdr.ipv4); + } +} + +PNA_NIC(MainParserImpl(), PreControlImpl(), MainControlImpl(), MainDeparserImpl()) main; diff --git a/testdata/p4_16_errors_outputs/issue513.p4.entries.txt b/testdata/p4_16_samples_outputs/pna-example-pass-2.p4-stderr similarity index 100% rename from testdata/p4_16_errors_outputs/issue513.p4.entries.txt rename to testdata/p4_16_samples_outputs/pna-example-pass-2.p4-stderr diff --git a/testdata/p4_16_samples_outputs/pna-example-tcp-connection-tracking-first.p4 b/testdata/p4_16_samples_outputs/pna-example-tcp-connection-tracking-first.p4 new file mode 100644 index 00000000000..df1e435a60d --- /dev/null +++ b/testdata/p4_16_samples_outputs/pna-example-tcp-connection-tracking-first.p4 @@ -0,0 +1,182 @@ +#include +#include + +typedef bit<48> EthernetAddress; +typedef bit<32> IPv4Address; +header ethernet_t { + EthernetAddress dstAddr; + EthernetAddress srcAddr; + bit<16> etherType; +} + +header ipv4_t { + bit<4> version; + bit<4> ihl; + bit<8> diffserv; + bit<16> totalLength; + bit<16> identification; + bit<3> flags; + bit<13> fragOffset; + bit<8> ttl; + bit<8> protocol; + bit<16> hdrChecksum; + IPv4Address srcAddr; + IPv4Address dstAddr; +} + +header tcp_t { + bit<16> srcPort; + bit<16> dstPort; + bit<32> seqNo; + bit<32> ackNo; + bit<4> dataOffset; + bit<4> res; + bit<8> flags; + bit<16> window; + bit<16> checksum; + bit<16> urgentPtr; +} + +const bit<8> TCP_URG_MASK = 8w0x20; +const bit<8> TCP_ACK_MASK = 8w0x10; +const bit<8> TCP_PSH_MASK = 8w0x8; +const bit<8> TCP_RST_MASK = 8w0x4; +const bit<8> TCP_SYN_MASK = 8w0x2; +const bit<8> TCP_FIN_MASK = 8w0x1; +const ExpireTimeProfileId_t EXPIRE_TIME_PROFILE_TCP_NOW = (ExpireTimeProfileId_t)8w0; +const ExpireTimeProfileId_t EXPIRE_TIME_PROFILE_TCP_NEW = (ExpireTimeProfileId_t)8w1; +const ExpireTimeProfileId_t EXPIRE_TIME_PROFILE_TCP_ESTABLISHED = (ExpireTimeProfileId_t)8w2; +const ExpireTimeProfileId_t EXPIRE_TIME_PROFILE_TCP_NEVER = (ExpireTimeProfileId_t)8w3; +struct metadata_t { +} + +struct headers_t { + ethernet_t eth; + ipv4_t ipv4; + tcp_t tcp; +} + +parser MainParserImpl(packet_in pkt, out headers_t hdr, inout metadata_t meta, in pna_main_parser_input_metadata_t istd) { + state start { + pkt.extract(hdr.eth); + transition select(hdr.eth.etherType) { + 16w0x800: parse_ipv4; + default: accept; + } + } + state parse_ipv4 { + pkt.extract(hdr.ipv4); + transition select(hdr.ipv4.protocol) { + 8w6: parse_tcp; + default: accept; + } + } + state parse_tcp { + pkt.extract(hdr.tcp); + transition accept; + } +} + +control PreControlImpl(in headers_t hdr, inout metadata_t meta, in pna_pre_input_metadata_t istd, inout pna_pre_output_metadata_t ostd) { + apply { + } +} + +struct ct_tcp_table_hit_params_t { +} + +control MainControlImpl(inout headers_t hdr, inout metadata_t meta, in pna_main_input_metadata_t istd, inout pna_main_output_metadata_t ostd) { + action drop() { + drop_packet(); + } + bool do_add_on_miss; + bool update_aging_info; + bool update_expire_time; + ExpireTimeProfileId_t new_expire_time_profile_id; + bool add_succeeded; + action tcp_syn_packet() { + do_add_on_miss = true; + update_aging_info = true; + update_expire_time = true; + new_expire_time_profile_id = (ExpireTimeProfileId_t)8w1; + } + action tcp_fin_or_rst_packet() { + update_aging_info = true; + update_expire_time = true; + new_expire_time_profile_id = (ExpireTimeProfileId_t)8w0; + } + action tcp_other_packets() { + update_aging_info = true; + update_expire_time = true; + new_expire_time_profile_id = (ExpireTimeProfileId_t)8w2; + } + table set_ct_options { + key = { + hdr.tcp.flags: ternary @name("hdr.tcp.flags"); + } + actions = { + tcp_syn_packet(); + tcp_fin_or_rst_packet(); + tcp_other_packets(); + } + const entries = { + 8w0x2 &&& 8w0x2 : tcp_syn_packet(); + 8w0x1 &&& 8w0x1 : tcp_fin_or_rst_packet(); + 8w0x4 &&& 8w0x4 : tcp_fin_or_rst_packet(); + } + const default_action = tcp_other_packets(); + } + action ct_tcp_table_hit() { + if (update_aging_info) { + if (update_expire_time) { + set_entry_expire_time(new_expire_time_profile_id); + } else { + restart_expire_timer(); + } + } else { + ; + } + } + action ct_tcp_table_miss() { + if (do_add_on_miss) { + add_succeeded = add_entry(action_name = "ct_tcp_table_hit", action_params = (ct_tcp_table_hit_params_t){}, expire_time_profile_id = new_expire_time_profile_id); + } else { + drop_packet(); + } + } + table ct_tcp_table { + key = { + SelectByDirection>(istd.direction, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr): exact @name("ipv4_addr_0"); + SelectByDirection>(istd.direction, hdr.ipv4.dstAddr, hdr.ipv4.srcAddr): exact @name("ipv4_addr_1"); + hdr.ipv4.protocol : exact @name("hdr.ipv4.protocol"); + SelectByDirection>(istd.direction, hdr.tcp.srcPort, hdr.tcp.dstPort) : exact @name("tcp_port_0"); + SelectByDirection>(istd.direction, hdr.tcp.dstPort, hdr.tcp.srcPort) : exact @name("tcp_port_1"); + } + actions = { + @tableonly ct_tcp_table_hit(); + @defaultonly ct_tcp_table_miss(); + } + add_on_miss = true; + default_idle_timeout_for_data_plane_added_entries = 1; + idle_timeout_with_auto_delete = true; + const default_action = ct_tcp_table_miss(); + } + apply { + do_add_on_miss = false; + update_expire_time = false; + if (istd.direction == PNA_Direction_t.HOST_TO_NET && hdr.ipv4.isValid() && hdr.tcp.isValid()) { + set_ct_options.apply(); + } + if (hdr.ipv4.isValid() && hdr.tcp.isValid()) { + ct_tcp_table.apply(); + } + } +} + +control MainDeparserImpl(packet_out pkt, in headers_t hdr, in metadata_t meta, in pna_main_output_metadata_t ostd) { + apply { + pkt.emit(hdr.eth); + } +} + +PNA_NIC(MainParserImpl(), PreControlImpl(), MainControlImpl(), MainDeparserImpl()) main; diff --git a/testdata/p4_16_samples_outputs/pna-example-tcp-connection-tracking-frontend.p4 b/testdata/p4_16_samples_outputs/pna-example-tcp-connection-tracking-frontend.p4 new file mode 100644 index 00000000000..6fd9ed082fd --- /dev/null +++ b/testdata/p4_16_samples_outputs/pna-example-tcp-connection-tracking-frontend.p4 @@ -0,0 +1,178 @@ +#include +#include + +typedef bit<48> EthernetAddress; +typedef bit<32> IPv4Address; +header ethernet_t { + EthernetAddress dstAddr; + EthernetAddress srcAddr; + bit<16> etherType; +} + +header ipv4_t { + bit<4> version; + bit<4> ihl; + bit<8> diffserv; + bit<16> totalLength; + bit<16> identification; + bit<3> flags; + bit<13> fragOffset; + bit<8> ttl; + bit<8> protocol; + bit<16> hdrChecksum; + IPv4Address srcAddr; + IPv4Address dstAddr; +} + +header tcp_t { + bit<16> srcPort; + bit<16> dstPort; + bit<32> seqNo; + bit<32> ackNo; + bit<4> dataOffset; + bit<4> res; + bit<8> flags; + bit<16> window; + bit<16> checksum; + bit<16> urgentPtr; +} + +struct metadata_t { +} + +struct headers_t { + ethernet_t eth; + ipv4_t ipv4; + tcp_t tcp; +} + +parser MainParserImpl(packet_in pkt, out headers_t hdr, inout metadata_t meta, in pna_main_parser_input_metadata_t istd) { + state start { + pkt.extract(hdr.eth); + transition select(hdr.eth.etherType) { + 16w0x800: parse_ipv4; + default: accept; + } + } + state parse_ipv4 { + pkt.extract(hdr.ipv4); + transition select(hdr.ipv4.protocol) { + 8w6: parse_tcp; + default: accept; + } + } + state parse_tcp { + pkt.extract(hdr.tcp); + transition accept; + } +} + +control PreControlImpl(in headers_t hdr, inout metadata_t meta, in pna_pre_input_metadata_t istd, inout pna_pre_output_metadata_t ostd) { + apply { + } +} + +struct ct_tcp_table_hit_params_t { +} + +control MainControlImpl(inout headers_t hdr, inout metadata_t meta, in pna_main_input_metadata_t istd, inout pna_main_output_metadata_t ostd) { + @name("MainControlImpl.do_add_on_miss") bool do_add_on_miss_0; + @name("MainControlImpl.update_aging_info") bool update_aging_info_0; + @name("MainControlImpl.update_expire_time") bool update_expire_time_0; + @name("MainControlImpl.new_expire_time_profile_id") ExpireTimeProfileId_t new_expire_time_profile_id_0; + @name("MainControlImpl.key_0") bit<32> key_0; + @name("MainControlImpl.key_1") bit<32> key_1; + @name("MainControlImpl.key_2") bit<8> key_2; + @name("MainControlImpl.key_3") bit<16> key_3; + @name("MainControlImpl.key_4") bit<16> key_4; + @name("MainControlImpl.tcp_syn_packet") action tcp_syn_packet() { + do_add_on_miss_0 = true; + update_aging_info_0 = true; + update_expire_time_0 = true; + new_expire_time_profile_id_0 = (ExpireTimeProfileId_t)8w1; + } + @name("MainControlImpl.tcp_fin_or_rst_packet") action tcp_fin_or_rst_packet() { + update_aging_info_0 = true; + update_expire_time_0 = true; + new_expire_time_profile_id_0 = (ExpireTimeProfileId_t)8w0; + } + @name("MainControlImpl.tcp_other_packets") action tcp_other_packets() { + update_aging_info_0 = true; + update_expire_time_0 = true; + new_expire_time_profile_id_0 = (ExpireTimeProfileId_t)8w2; + } + @name("MainControlImpl.set_ct_options") table set_ct_options_0 { + key = { + hdr.tcp.flags: ternary @name("hdr.tcp.flags"); + } + actions = { + tcp_syn_packet(); + tcp_fin_or_rst_packet(); + tcp_other_packets(); + } + const entries = { + 8w0x2 &&& 8w0x2 : tcp_syn_packet(); + 8w0x1 &&& 8w0x1 : tcp_fin_or_rst_packet(); + 8w0x4 &&& 8w0x4 : tcp_fin_or_rst_packet(); + } + const default_action = tcp_other_packets(); + } + @name("MainControlImpl.ct_tcp_table_hit") action ct_tcp_table_hit() { + if (update_aging_info_0) { + if (update_expire_time_0) { + set_entry_expire_time(new_expire_time_profile_id_0); + } else { + restart_expire_timer(); + } + } else { + ; + } + } + @name("MainControlImpl.ct_tcp_table_miss") action ct_tcp_table_miss() { + if (do_add_on_miss_0) { + add_entry(action_name = "ct_tcp_table_hit", action_params = (ct_tcp_table_hit_params_t){}, expire_time_profile_id = new_expire_time_profile_id_0); + } else { + drop_packet(); + } + } + @name("MainControlImpl.ct_tcp_table") table ct_tcp_table_0 { + key = { + key_0: exact @name("ipv4_addr_0"); + key_1: exact @name("ipv4_addr_1"); + key_2: exact @name("hdr.ipv4.protocol"); + key_3: exact @name("tcp_port_0"); + key_4: exact @name("tcp_port_1"); + } + actions = { + @tableonly ct_tcp_table_hit(); + @defaultonly ct_tcp_table_miss(); + } + add_on_miss = true; + default_idle_timeout_for_data_plane_added_entries = 1; + idle_timeout_with_auto_delete = true; + const default_action = ct_tcp_table_miss(); + } + apply { + do_add_on_miss_0 = false; + update_expire_time_0 = false; + if (istd.direction == PNA_Direction_t.HOST_TO_NET && hdr.ipv4.isValid() && hdr.tcp.isValid()) { + set_ct_options_0.apply(); + } + if (hdr.ipv4.isValid() && hdr.tcp.isValid()) { + key_0 = SelectByDirection>(istd.direction, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr); + key_1 = SelectByDirection>(istd.direction, hdr.ipv4.dstAddr, hdr.ipv4.srcAddr); + key_2 = hdr.ipv4.protocol; + key_3 = SelectByDirection>(istd.direction, hdr.tcp.srcPort, hdr.tcp.dstPort); + key_4 = SelectByDirection>(istd.direction, hdr.tcp.dstPort, hdr.tcp.srcPort); + ct_tcp_table_0.apply(); + } + } +} + +control MainDeparserImpl(packet_out pkt, in headers_t hdr, in metadata_t meta, in pna_main_output_metadata_t ostd) { + apply { + pkt.emit(hdr.eth); + } +} + +PNA_NIC(MainParserImpl(), PreControlImpl(), MainControlImpl(), MainDeparserImpl()) main; diff --git a/testdata/p4_16_samples_outputs/pna-example-tcp-connection-tracking-midend.p4 b/testdata/p4_16_samples_outputs/pna-example-tcp-connection-tracking-midend.p4 new file mode 100644 index 00000000000..11fc512b623 --- /dev/null +++ b/testdata/p4_16_samples_outputs/pna-example-tcp-connection-tracking-midend.p4 @@ -0,0 +1,201 @@ +#include +#include + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +header ipv4_t { + bit<4> version; + bit<4> ihl; + bit<8> diffserv; + bit<16> totalLength; + bit<16> identification; + bit<3> flags; + bit<13> fragOffset; + bit<8> ttl; + bit<8> protocol; + bit<16> hdrChecksum; + bit<32> srcAddr; + bit<32> dstAddr; +} + +header tcp_t { + bit<16> srcPort; + bit<16> dstPort; + bit<32> seqNo; + bit<32> ackNo; + bit<4> dataOffset; + bit<4> res; + bit<8> flags; + bit<16> window; + bit<16> checksum; + bit<16> urgentPtr; +} + +struct metadata_t { +} + +struct headers_t { + ethernet_t eth; + ipv4_t ipv4; + tcp_t tcp; +} + +parser MainParserImpl(packet_in pkt, out headers_t hdr, inout metadata_t meta, in pna_main_parser_input_metadata_t istd) { + state start { + pkt.extract(hdr.eth); + transition select(hdr.eth.etherType) { + 16w0x800: parse_ipv4; + default: accept; + } + } + state parse_ipv4 { + pkt.extract(hdr.ipv4); + transition select(hdr.ipv4.protocol) { + 8w6: parse_tcp; + default: accept; + } + } + state parse_tcp { + pkt.extract(hdr.tcp); + transition accept; + } +} + +control PreControlImpl(in headers_t hdr, inout metadata_t meta, in pna_pre_input_metadata_t istd, inout pna_pre_output_metadata_t ostd) { + apply { + } +} + +struct ct_tcp_table_hit_params_t { +} + +control MainControlImpl(inout headers_t hdr, inout metadata_t meta, in pna_main_input_metadata_t istd, inout pna_main_output_metadata_t ostd) { + @name("MainControlImpl.do_add_on_miss") bool do_add_on_miss_0; + @name("MainControlImpl.update_aging_info") bool update_aging_info_0; + @name("MainControlImpl.update_expire_time") bool update_expire_time_0; + @name("MainControlImpl.new_expire_time_profile_id") bit<8> new_expire_time_profile_id_0; + @name("MainControlImpl.key_0") bit<32> key_0; + @name("MainControlImpl.key_1") bit<32> key_1; + @name("MainControlImpl.key_3") bit<16> key_3; + @name("MainControlImpl.key_4") bit<16> key_4; + @name("MainControlImpl.tcp_syn_packet") action tcp_syn_packet() { + do_add_on_miss_0 = true; + update_aging_info_0 = true; + update_expire_time_0 = true; + new_expire_time_profile_id_0 = 8w1; + } + @name("MainControlImpl.tcp_fin_or_rst_packet") action tcp_fin_or_rst_packet() { + update_aging_info_0 = true; + update_expire_time_0 = true; + new_expire_time_profile_id_0 = 8w0; + } + @name("MainControlImpl.tcp_other_packets") action tcp_other_packets() { + update_aging_info_0 = true; + update_expire_time_0 = true; + new_expire_time_profile_id_0 = 8w2; + } + @name("MainControlImpl.set_ct_options") table set_ct_options_0 { + key = { + hdr.tcp.flags: ternary @name("hdr.tcp.flags"); + } + actions = { + tcp_syn_packet(); + tcp_fin_or_rst_packet(); + tcp_other_packets(); + } + const entries = { + 8w0x2 &&& 8w0x2 : tcp_syn_packet(); + 8w0x1 &&& 8w0x1 : tcp_fin_or_rst_packet(); + 8w0x4 &&& 8w0x4 : tcp_fin_or_rst_packet(); + } + const default_action = tcp_other_packets(); + } + @name("MainControlImpl.ct_tcp_table_hit") action ct_tcp_table_hit() { + if (update_aging_info_0) { + if (update_expire_time_0) { + set_entry_expire_time(new_expire_time_profile_id_0); + } else { + restart_expire_timer(); + } + } else { + ; + } + } + @name("MainControlImpl.ct_tcp_table_miss") action ct_tcp_table_miss() { + if (do_add_on_miss_0) { + add_entry(action_name = "ct_tcp_table_hit", action_params = (ct_tcp_table_hit_params_t){}, expire_time_profile_id = new_expire_time_profile_id_0); + } else { + drop_packet(); + } + } + @name("MainControlImpl.ct_tcp_table") table ct_tcp_table_0 { + key = { + key_0 : exact @name("ipv4_addr_0"); + key_1 : exact @name("ipv4_addr_1"); + hdr.ipv4.protocol: exact @name("hdr.ipv4.protocol"); + key_3 : exact @name("tcp_port_0"); + key_4 : exact @name("tcp_port_1"); + } + actions = { + @tableonly ct_tcp_table_hit(); + @defaultonly ct_tcp_table_miss(); + } + add_on_miss = true; + default_idle_timeout_for_data_plane_added_entries = 1; + idle_timeout_with_auto_delete = true; + const default_action = ct_tcp_table_miss(); + } + @hidden action pnaexampletcpconnectiontracking307() { + do_add_on_miss_0 = false; + update_expire_time_0 = false; + } + @hidden action pnaexampletcpconnectiontracking254() { + key_0 = SelectByDirection>(istd.direction, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr); + key_1 = SelectByDirection>(istd.direction, hdr.ipv4.dstAddr, hdr.ipv4.srcAddr); + key_3 = SelectByDirection>(istd.direction, hdr.tcp.srcPort, hdr.tcp.dstPort); + key_4 = SelectByDirection>(istd.direction, hdr.tcp.dstPort, hdr.tcp.srcPort); + } + @hidden table tbl_pnaexampletcpconnectiontracking307 { + actions = { + pnaexampletcpconnectiontracking307(); + } + const default_action = pnaexampletcpconnectiontracking307(); + } + @hidden table tbl_pnaexampletcpconnectiontracking254 { + actions = { + pnaexampletcpconnectiontracking254(); + } + const default_action = pnaexampletcpconnectiontracking254(); + } + apply { + tbl_pnaexampletcpconnectiontracking307.apply(); + if (istd.direction == PNA_Direction_t.HOST_TO_NET && hdr.ipv4.isValid() && hdr.tcp.isValid()) { + set_ct_options_0.apply(); + } + if (hdr.ipv4.isValid() && hdr.tcp.isValid()) { + tbl_pnaexampletcpconnectiontracking254.apply(); + ct_tcp_table_0.apply(); + } + } +} + +control MainDeparserImpl(packet_out pkt, in headers_t hdr, in metadata_t meta, in pna_main_output_metadata_t ostd) { + @hidden action pnaexampletcpconnectiontracking329() { + pkt.emit(hdr.eth); + } + @hidden table tbl_pnaexampletcpconnectiontracking329 { + actions = { + pnaexampletcpconnectiontracking329(); + } + const default_action = pnaexampletcpconnectiontracking329(); + } + apply { + tbl_pnaexampletcpconnectiontracking329.apply(); + } +} + +PNA_NIC(MainParserImpl(), PreControlImpl(), MainControlImpl(), MainDeparserImpl()) main; diff --git a/testdata/p4_16_samples_outputs/pna-example-tcp-connection-tracking.p4 b/testdata/p4_16_samples_outputs/pna-example-tcp-connection-tracking.p4 new file mode 100644 index 00000000000..7d79609397b --- /dev/null +++ b/testdata/p4_16_samples_outputs/pna-example-tcp-connection-tracking.p4 @@ -0,0 +1,181 @@ +#include +#include + +typedef bit<48> EthernetAddress; +typedef bit<32> IPv4Address; +header ethernet_t { + EthernetAddress dstAddr; + EthernetAddress srcAddr; + bit<16> etherType; +} + +header ipv4_t { + bit<4> version; + bit<4> ihl; + bit<8> diffserv; + bit<16> totalLength; + bit<16> identification; + bit<3> flags; + bit<13> fragOffset; + bit<8> ttl; + bit<8> protocol; + bit<16> hdrChecksum; + IPv4Address srcAddr; + IPv4Address dstAddr; +} + +header tcp_t { + bit<16> srcPort; + bit<16> dstPort; + bit<32> seqNo; + bit<32> ackNo; + bit<4> dataOffset; + bit<4> res; + bit<8> flags; + bit<16> window; + bit<16> checksum; + bit<16> urgentPtr; +} + +const bit<8> TCP_URG_MASK = 0x20; +const bit<8> TCP_ACK_MASK = 0x10; +const bit<8> TCP_PSH_MASK = 0x8; +const bit<8> TCP_RST_MASK = 0x4; +const bit<8> TCP_SYN_MASK = 0x2; +const bit<8> TCP_FIN_MASK = 0x1; +const ExpireTimeProfileId_t EXPIRE_TIME_PROFILE_TCP_NOW = (ExpireTimeProfileId_t)0; +const ExpireTimeProfileId_t EXPIRE_TIME_PROFILE_TCP_NEW = (ExpireTimeProfileId_t)1; +const ExpireTimeProfileId_t EXPIRE_TIME_PROFILE_TCP_ESTABLISHED = (ExpireTimeProfileId_t)2; +const ExpireTimeProfileId_t EXPIRE_TIME_PROFILE_TCP_NEVER = (ExpireTimeProfileId_t)3; +struct metadata_t { +} + +struct headers_t { + ethernet_t eth; + ipv4_t ipv4; + tcp_t tcp; +} + +parser MainParserImpl(packet_in pkt, out headers_t hdr, inout metadata_t meta, in pna_main_parser_input_metadata_t istd) { + state start { + pkt.extract(hdr.eth); + transition select(hdr.eth.etherType) { + 0x800: parse_ipv4; + default: accept; + } + } + state parse_ipv4 { + pkt.extract(hdr.ipv4); + transition select(hdr.ipv4.protocol) { + 6: parse_tcp; + default: accept; + } + } + state parse_tcp { + pkt.extract(hdr.tcp); + transition accept; + } +} + +control PreControlImpl(in headers_t hdr, inout metadata_t meta, in pna_pre_input_metadata_t istd, inout pna_pre_output_metadata_t ostd) { + apply { + } +} + +struct ct_tcp_table_hit_params_t { +} + +control MainControlImpl(inout headers_t hdr, inout metadata_t meta, in pna_main_input_metadata_t istd, inout pna_main_output_metadata_t ostd) { + action drop() { + drop_packet(); + } + bool do_add_on_miss; + bool update_aging_info; + bool update_expire_time; + ExpireTimeProfileId_t new_expire_time_profile_id; + bool add_succeeded; + action tcp_syn_packet() { + do_add_on_miss = true; + update_aging_info = true; + update_expire_time = true; + new_expire_time_profile_id = EXPIRE_TIME_PROFILE_TCP_NEW; + } + action tcp_fin_or_rst_packet() { + update_aging_info = true; + update_expire_time = true; + new_expire_time_profile_id = EXPIRE_TIME_PROFILE_TCP_NOW; + } + action tcp_other_packets() { + update_aging_info = true; + update_expire_time = true; + new_expire_time_profile_id = EXPIRE_TIME_PROFILE_TCP_ESTABLISHED; + } + table set_ct_options { + key = { + hdr.tcp.flags: ternary; + } + actions = { + tcp_syn_packet; + tcp_fin_or_rst_packet; + tcp_other_packets; + } + const entries = { + TCP_SYN_MASK &&& TCP_SYN_MASK : tcp_syn_packet; + TCP_FIN_MASK &&& TCP_FIN_MASK : tcp_fin_or_rst_packet; + TCP_RST_MASK &&& TCP_RST_MASK : tcp_fin_or_rst_packet; + } + const default_action = tcp_other_packets; + } + action ct_tcp_table_hit() { + if (update_aging_info) { + if (update_expire_time) { + set_entry_expire_time(new_expire_time_profile_id); + } else { + restart_expire_timer(); + } + } else { + } + } + action ct_tcp_table_miss() { + if (do_add_on_miss) { + add_succeeded = add_entry(action_name = "ct_tcp_table_hit", action_params = (ct_tcp_table_hit_params_t){ }, expire_time_profile_id = new_expire_time_profile_id); + } else { + drop_packet(); + } + } + table ct_tcp_table { + key = { + SelectByDirection(istd.direction, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr): exact @name("ipv4_addr_0"); + SelectByDirection(istd.direction, hdr.ipv4.dstAddr, hdr.ipv4.srcAddr): exact @name("ipv4_addr_1"); + hdr.ipv4.protocol : exact; + SelectByDirection(istd.direction, hdr.tcp.srcPort, hdr.tcp.dstPort) : exact @name("tcp_port_0"); + SelectByDirection(istd.direction, hdr.tcp.dstPort, hdr.tcp.srcPort) : exact @name("tcp_port_1"); + } + actions = { + @tableonly ct_tcp_table_hit; + @defaultonly ct_tcp_table_miss; + } + add_on_miss = true; + default_idle_timeout_for_data_plane_added_entries = 1; + idle_timeout_with_auto_delete = true; + const default_action = ct_tcp_table_miss; + } + apply { + do_add_on_miss = false; + update_expire_time = false; + if (istd.direction == PNA_Direction_t.HOST_TO_NET && hdr.ipv4.isValid() && hdr.tcp.isValid()) { + set_ct_options.apply(); + } + if (hdr.ipv4.isValid() && hdr.tcp.isValid()) { + ct_tcp_table.apply(); + } + } +} + +control MainDeparserImpl(packet_out pkt, in headers_t hdr, in metadata_t meta, in pna_main_output_metadata_t ostd) { + apply { + pkt.emit(hdr.eth); + } +} + +PNA_NIC(MainParserImpl(), PreControlImpl(), MainControlImpl(), MainDeparserImpl()) main; diff --git a/testdata/p4_16_samples_outputs/pna-example-tcp-connection-tracking.p4-stderr b/testdata/p4_16_samples_outputs/pna-example-tcp-connection-tracking.p4-stderr new file mode 100644 index 00000000000..e01551fd835 --- /dev/null +++ b/testdata/p4_16_samples_outputs/pna-example-tcp-connection-tracking.p4-stderr @@ -0,0 +1,9 @@ +pna-example-tcp-connection-tracking.p4(206): [--Wwarn=uninitialized_use] warning: update_aging_info may be uninitialized + if (update_aging_info) { + ^^^^^^^^^^^^^^^^^ +pna-example-tcp-connection-tracking.p4(208): [--Wwarn=uninitialized_use] warning: new_expire_time_profile_id may not be completely initialized + set_entry_expire_time(new_expire_time_profile_id); + ^^^^^^^^^^^^^^^^^^^^^^^^^^ +pna-example-tcp-connection-tracking.p4(240): [--Wwarn=uninitialized_use] warning: new_expire_time_profile_id may not be completely initialized + expire_time_profile_id = new_expire_time_profile_id); + ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/testdata/p4_16_samples_outputs/pna-mux-dismantle-midend.p4 b/testdata/p4_16_samples_outputs/pna-mux-dismantle-midend.p4 index c903f5e0628..d1e942a2970 100644 --- a/testdata/p4_16_samples_outputs/pna-mux-dismantle-midend.p4 +++ b/testdata/p4_16_samples_outputs/pna-mux-dismantle-midend.p4 @@ -77,6 +77,7 @@ struct tuple_0 { } control MainControlImpl(inout headers_t hdr, inout main_metadata_t user_meta, in pna_main_input_metadata_t istd, inout pna_main_output_metadata_t ostd) { + @name("MainControlImpl.tmp") bit<1> tmp_0; @name("MainControlImpl.tmp_1") bit<1> tmp_1; tcp_t hdr_3_tcp; @name(".do_range_checks_0") action do_range_checks_1(@name("min1") bit<16> min1_2, @name("max1") bit<16> max1_2) { @@ -90,8 +91,17 @@ control MainControlImpl(inout headers_t hdr, inout main_metadata_t user_meta, in add_entry>(action_name = "next_hop", action_params = 32w0, expire_time_profile_id = user_meta.timeout); } @name("MainControlImpl.do_range_checks_1") action do_range_checks_2(@name("min1") bit<16> min1_3, @name("max1") bit<16> max1_3) { - tmp_1 = (min1_3 <= hdr.tcp.srcPort && hdr.tcp.srcPort <= max1_3 ? (16w50 <= hdr.tcp.srcPort && hdr.tcp.srcPort <= 16w100 ? user_meta.val1 : user_meta.val2) : tmp_1); - user_meta.rng_result1 = (min1_3 <= hdr.tcp.srcPort && hdr.tcp.srcPort <= max1_3 ? tmp_1 : user_meta.val1); + if (min1_3 <= hdr.tcp.srcPort && hdr.tcp.srcPort <= max1_3) { + if (16w50 <= hdr.tcp.srcPort && hdr.tcp.srcPort <= 16w100) { + tmp_1 = user_meta.val1; + } else { + tmp_1 = user_meta.val2; + } + tmp_0 = tmp_1; + } else { + tmp_0 = user_meta.val1; + } + user_meta.rng_result1 = tmp_0; } @name("MainControlImpl.ipv4_da") table ipv4_da_0 { key = { diff --git a/testdata/p4_16_samples_outputs/predication_issue-midend.p4 b/testdata/p4_16_samples_outputs/predication_issue-midend.p4 index 44a9f15f071..d79cca4ec1a 100644 --- a/testdata/p4_16_samples_outputs/predication_issue-midend.p4 +++ b/testdata/p4_16_samples_outputs/predication_issue-midend.p4 @@ -29,7 +29,6 @@ control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { h_0_eth_hdr.dst_addr = 48w4; h_0_eth_hdr.dst_addr = 48w2; h_0_eth_hdr.src_addr = 48w3; - h_0_eth_hdr.dst_addr = 48w2; h.eth_hdr = h_0_eth_hdr; } @hidden table tbl_assign_addrs { diff --git a/testdata/p4_16_samples_outputs/predication_issue_1-midend.p4 b/testdata/p4_16_samples_outputs/predication_issue_1-midend.p4 index dd461d9d836..e4067bef82c 100644 --- a/testdata/p4_16_samples_outputs/predication_issue_1-midend.p4 +++ b/testdata/p4_16_samples_outputs/predication_issue_1-midend.p4 @@ -23,8 +23,13 @@ parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t } control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + @name("ingress.target_addr") bit<48> target_addr_0; @name(".assign") action assign_0() { - h.eth_hdr.dst_addr = (16w0xdead != h.eth_hdr.eth_type ? 48w1 : h.eth_hdr.dst_addr); + target_addr_0 = h.eth_hdr.dst_addr; + if (16w0xdead != h.eth_hdr.eth_type) { + target_addr_0 = 48w1; + } + h.eth_hdr.dst_addr = target_addr_0; } @hidden table tbl_assign { actions = { diff --git a/testdata/p4_16_samples_outputs/predication_issue_2-midend.p4 b/testdata/p4_16_samples_outputs/predication_issue_2-midend.p4 index 619ef725b2e..40bf93be307 100644 --- a/testdata/p4_16_samples_outputs/predication_issue_2-midend.p4 +++ b/testdata/p4_16_samples_outputs/predication_issue_2-midend.p4 @@ -37,14 +37,15 @@ parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { @name("ingress.tmp") bit<8> tmp; - bit<8> hsiVar; @name("ingress.simple_action") action simple_action() { - tmp = (h.idx.idx < 8w1 ? h.idx.idx : tmp); - tmp = (h.idx.idx < 8w1 ? h.idx.idx : 8w1); - hsiVar = (h.idx.idx < 8w1 ? h.idx.idx : 8w1); - if (hsiVar == 8w0) { + if (h.idx.idx < 8w1) { + tmp = h.idx.idx; + } else { + tmp = 8w1; + } + if (tmp == 8w0) { h.h[8w0].a = 8w1; - } else if (hsiVar == 8w1) { + } else if (tmp == 8w1) { h.h[8w1].a = 8w1; } } diff --git a/testdata/p4_16_samples_outputs/predication_issue_3-midend.p4 b/testdata/p4_16_samples_outputs/predication_issue_3-midend.p4 index 3d373bca708..37122af9712 100644 --- a/testdata/p4_16_samples_outputs/predication_issue_3-midend.p4 +++ b/testdata/p4_16_samples_outputs/predication_issue_3-midend.p4 @@ -30,8 +30,20 @@ parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t } control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + @name("ingress.bool_val") bool bool_val_0; @name("ingress.perform_action") action perform_action() { - h.h[3w0].a = 8w1; + if (bool_val_0) { + h.h[3w0].a = 8w1; + } + } + @hidden action predication_issue_3l38() { + bool_val_0 = true; + } + @hidden table tbl_predication_issue_3l38 { + actions = { + predication_issue_3l38(); + } + const default_action = predication_issue_3l38(); } @hidden table tbl_perform_action { actions = { @@ -40,6 +52,7 @@ control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { const default_action = perform_action(); } apply { + tbl_predication_issue_3l38.apply(); tbl_perform_action.apply(); } } diff --git a/testdata/p4_16_samples_outputs/predication_issue_4-midend.p4 b/testdata/p4_16_samples_outputs/predication_issue_4-midend.p4 index 03620ff65c2..714f0536720 100644 --- a/testdata/p4_16_samples_outputs/predication_issue_4-midend.p4 +++ b/testdata/p4_16_samples_outputs/predication_issue_4-midend.p4 @@ -32,28 +32,9 @@ parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { @name("ingress.bool_val") bool bool_val_0; - @name("ingress.tmp_0") bit<1> tmp; - @name("ingress.tmp_1") bit<1> tmp_0; - @name("ingress.val_0") bit<1> val; - @name("ingress.bound_0") bit<1> bound; - @name("ingress.retval") bit<1> retval; - @name("ingress.tmp") bit<1> tmp_1; - bit<1> hsiVar; @name("ingress.perform_action") action perform_action() { - val = (bool_val_0 ? 1w0 : val); - bound = (bool_val_0 ? 1w1 : bound); - tmp_1 = (bool_val_0 ? (val < bound ? val : tmp_1) : tmp_1); - tmp_1 = (bool_val_0 ? (val < bound ? val : bound) : tmp_1); - retval = (bool_val_0 ? tmp_1 : retval); - tmp = (bool_val_0 ? retval : tmp); - tmp_0 = (bool_val_0 ? tmp : tmp_0); - hsiVar = (bool_val_0 ? tmp_0 : 1w0); - if (hsiVar == 1w0) { - h.h[1w0].a = (bool_val_0 ? 8w1 : h.h[1w0].a); - } else if (hsiVar == 1w1) { - h.h[1w1].a = (bool_val_0 ? 8w1 : h.h[1w1].a); - } else if (hsiVar == 1w0) { - h.h[1w0].a = (bool_val_0 ? 8w1 : h.h[1w0].a); + if (bool_val_0) { + h.h[1w0].a = 8w1; } } @hidden action predication_issue_4l39() { diff --git a/testdata/p4_16_samples_outputs/predication_issue_4.p4-stderr b/testdata/p4_16_samples_outputs/predication_issue_4.p4-stderr index 3ce1eae9737..e69de29bb2d 100644 --- a/testdata/p4_16_samples_outputs/predication_issue_4.p4-stderr +++ b/testdata/p4_16_samples_outputs/predication_issue_4.p4-stderr @@ -1,3 +0,0 @@ -[--Wwarn=mismatch] warning: 1w2: value does not fit in 1 bits -[--Wwarn=mismatch] warning: 1w2: value does not fit in 1 bits -[--Wwarn=mismatch] warning: 1w2: value does not fit in 1 bits diff --git a/testdata/p4_16_samples_outputs/psa-conditional_operator-midend.p4 b/testdata/p4_16_samples_outputs/psa-conditional_operator-midend.p4 index c94d3963317..ca66edc78cd 100644 --- a/testdata/p4_16_samples_outputs/psa-conditional_operator-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-conditional_operator-midend.p4 @@ -32,11 +32,17 @@ parser MyEP(packet_in buffer, out EMPTY a, inout EMPTY b, in psa_egress_parser_i } control MyIC(inout headers_t hdr, inout user_meta_t b, in psa_ingress_input_metadata_t c, inout psa_ingress_output_metadata_t d) { + @name("MyIC.tmp") bit<16> tmp_0; @name("MyIC.tmp_1") bit<16> tmp_1; @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("MyIC.execute") action execute_1() { - b.data = (b.data != 16w0 ? 16w0 : 16w1) + 16w1; + if (b.data != 16w0) { + tmp_0 = 16w0; + } else { + tmp_0 = 16w1; + } + b.data = tmp_0 + 16w1; } @name("MyIC.tbl") table tbl_0 { key = { diff --git a/testdata/p4_16_samples_outputs/psa-dpdk-errorcode-1-midend.p4 b/testdata/p4_16_samples_outputs/psa-dpdk-errorcode-1-midend.p4 index 51b14661c45..eaf48f4dd0b 100644 --- a/testdata/p4_16_samples_outputs/psa-dpdk-errorcode-1-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-dpdk-errorcode-1-midend.p4 @@ -75,7 +75,11 @@ control ingress(inout headers hdr, inout metadata user_meta, in psa_ingress_inpu @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("ingress.execute") action execute_1() { - user_meta.data = (err_0 ? user_meta.data : 16w1); + if (err_0) { + ; + } else { + user_meta.data = 16w1; + } } @name("ingress.tbl") table tbl_0 { key = { diff --git a/testdata/p4_16_samples_outputs/psa-dpdk-errorcode-2-midend.p4 b/testdata/p4_16_samples_outputs/psa-dpdk-errorcode-2-midend.p4 index 354d22312d1..a3356138f4b 100644 --- a/testdata/p4_16_samples_outputs/psa-dpdk-errorcode-2-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-dpdk-errorcode-2-midend.p4 @@ -79,7 +79,11 @@ control ingress(inout headers hdr, inout metadata user_meta, in psa_ingress_inpu @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("ingress.execute") action execute_1() { - user_meta.data = (err_0 ? user_meta.data : 16w1); + if (err_0) { + ; + } else { + user_meta.data = 16w1; + } } @name("ingress.tbl") table tbl_0 { key = { diff --git a/testdata/p4_16_samples_outputs/psa-dpdk-flatten-local-struct-midend.p4 b/testdata/p4_16_samples_outputs/psa-dpdk-flatten-local-struct-midend.p4 index ab5efbcecf1..aa34a103a32 100644 --- a/testdata/p4_16_samples_outputs/psa-dpdk-flatten-local-struct-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-dpdk-flatten-local-struct-midend.p4 @@ -76,8 +76,14 @@ control packet_deparser(packet_out packet, out empty_metadata_t clone_i2e_meta, } control ingress(inout headers_t headers, inout local_metadata_t local_metadata1, in psa_ingress_input_metadata_t standard_metadata, inout psa_ingress_output_metadata_t ostd) { + host_info_rx_bytes_t2 host_info_rx_bytes_0_flex_up_flex_up1; @name("ingress.action1") action action1(@name("field") bit<16> field, @name("field1") bit<16> field1) { - headers.outer_ethernet.ether_type = (field == 16w1 ? field : field1); + if (field == 16w1) { + host_info_rx_bytes_0_flex_up_flex_up1.flex_0 = field; + } else { + host_info_rx_bytes_0_flex_up_flex_up1.flex_0 = field1; + } + headers.outer_ethernet.ether_type = host_info_rx_bytes_0_flex_up_flex_up1.flex_0; } @name("ingress.drop") action drop_1() { ostd.egress_port = 32w4; diff --git a/testdata/p4_16_samples_outputs/psa-dpdk-hdr-field-non-align-midend.p4 b/testdata/p4_16_samples_outputs/psa-dpdk-hdr-field-non-align-midend.p4 index 33503ab5e90..f3ce6095074 100644 --- a/testdata/p4_16_samples_outputs/psa-dpdk-hdr-field-non-align-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-dpdk-hdr-field-non-align-midend.p4 @@ -35,10 +35,12 @@ control MyIngressControl(inout headers_t hdr, inout user_meta_data_t m, in psa_i @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("MyIngressControl.macswp") action macswp() { - m.x2 = (m.flg == 8w0x2 ? hdr.ethernet.x2 : m.x2); - m.addr = (m.flg == 8w0x2 ? hdr.ethernet.dst_addr : m.addr); - hdr.ethernet.dst_addr = (m.flg == 8w0x2 ? hdr.ethernet.src_addr : hdr.ethernet.dst_addr); - hdr.ethernet.src_addr = (m.flg == 8w0x2 ? m.addr : hdr.ethernet.src_addr); + if (m.flg == 8w0x2) { + m.x2 = hdr.ethernet.x2; + m.addr = hdr.ethernet.dst_addr; + hdr.ethernet.dst_addr = hdr.ethernet.src_addr; + hdr.ethernet.src_addr = m.addr; + } } @name("MyIngressControl.stub") table stub_0 { actions = { diff --git a/testdata/p4_16_samples_outputs/psa-dpdk-large-header-fields-midend.p4 b/testdata/p4_16_samples_outputs/psa-dpdk-large-header-fields-midend.p4 index 16bfd94fbfd..9de20038784 100644 --- a/testdata/p4_16_samples_outputs/psa-dpdk-large-header-fields-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-dpdk-large-header-fields-midend.p4 @@ -37,13 +37,14 @@ control MyIngressControl(inout headers_t hdr, inout user_meta_data_t m, in psa_i @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("MyIngressControl.MyIngressControl.macswp") action macswp() { - m.k1 = (flg == 8w0x2 ? m.k2 : m.k1); - m.x2 = (flg == 8w0x2 ? hdr.ethernet.x0 : m.x2); - hdr.ethernet.x0 = (flg == 8w0x2 ? m.x2 : hdr.ethernet.x0); - m.x2 = (flg == 8w0x2 ? (bit<8>)(hdr.ethernet.ether_type >> 2) : m.x2); - m.addr = (flg == 8w0x2 ? hdr.ethernet.dst_addr : m.addr); - hdr.ethernet.dst_addr = (flg == 8w0x2 ? hdr.ethernet.src_addr : hdr.ethernet.dst_addr); - hdr.ethernet.src_addr = (flg == 8w0x2 ? m.addr : hdr.ethernet.src_addr); + if (flg == 8w0x2) { + m.k1 = m.k2; + m.x2 = hdr.ethernet.x0; + m.x2 = (bit<8>)(hdr.ethernet.ether_type >> 2); + m.addr = hdr.ethernet.dst_addr; + hdr.ethernet.dst_addr = hdr.ethernet.src_addr; + hdr.ethernet.src_addr = m.addr; + } } @name("MyIngressControl.MyIngressControl.stub") table stub { key = { diff --git a/testdata/p4_16_samples_outputs/psa-dpdk-large-struct-fields-midend.p4 b/testdata/p4_16_samples_outputs/psa-dpdk-large-struct-fields-midend.p4 index 649c26ca5b1..c968f655eb0 100644 --- a/testdata/p4_16_samples_outputs/psa-dpdk-large-struct-fields-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-dpdk-large-struct-fields-midend.p4 @@ -35,13 +35,14 @@ control MyIngressControl(inout headers_t hdr, inout user_meta_data_t m, in psa_i @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("MyIngressControl.MyIngressControl.macswp") action macswp() { - m.k1 = (flg == 8w0x2 ? m.k2 : m.k1); - m.x2 = (flg == 8w0x2 ? hdr.ethernet.x0 : m.x2); - hdr.ethernet.x0 = (flg == 8w0x2 ? m.x2 : hdr.ethernet.x0); - m.x2 = (flg == 8w0x2 ? (bit<8>)(hdr.ethernet.ether_type >> 2) : m.x2); - m.addr = (flg == 8w0x2 ? hdr.ethernet.dst_addr : m.addr); - hdr.ethernet.dst_addr = (flg == 8w0x2 ? hdr.ethernet.src_addr : hdr.ethernet.dst_addr); - hdr.ethernet.src_addr = (flg == 8w0x2 ? m.addr : hdr.ethernet.src_addr); + if (flg == 8w0x2) { + m.k1 = m.k2; + m.x2 = hdr.ethernet.x0; + m.x2 = (bit<8>)(hdr.ethernet.ether_type >> 2); + m.addr = hdr.ethernet.dst_addr; + hdr.ethernet.dst_addr = hdr.ethernet.src_addr; + hdr.ethernet.src_addr = m.addr; + } } @name("MyIngressControl.MyIngressControl.stub") table stub { key = { diff --git a/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-01-midend.p4 b/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-01-midend.p4 index 97dcc471543..fff91bcc555 100644 --- a/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-01-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-01-midend.p4 @@ -32,9 +32,11 @@ control MyIngressControl(inout headers_t hdr, inout user_meta_data_t m, in psa_i hdr.ethernet.src_addr = m.addr; } @name("MyIngressControl.macswp") action macswp(@name("tmp1") bit<32> tmp1, @name("tmp2") bit<32> tmp2) { - m.addr = (tmp1 == 32w0x1 && tmp2 == 32w0x2 ? hdr.ethernet.dst_addr : m.addr); - hdr.ethernet.dst_addr = (tmp1 == 32w0x1 && tmp2 == 32w0x2 ? hdr.ethernet.src_addr : hdr.ethernet.dst_addr); - hdr.ethernet.src_addr = (tmp1 == 32w0x1 && tmp2 == 32w0x2 ? m.addr : hdr.ethernet.src_addr); + if (tmp1 == 32w0x1 && tmp2 == 32w0x2) { + m.addr = hdr.ethernet.dst_addr; + hdr.ethernet.dst_addr = hdr.ethernet.src_addr; + hdr.ethernet.src_addr = m.addr; + } } @name("MyIngressControl.stub") table stub_0 { actions = { diff --git a/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-02-midend.p4 b/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-02-midend.p4 index 6113bba526d..6fcc75062b2 100644 --- a/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-02-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-02-midend.p4 @@ -32,9 +32,11 @@ control MyIngressControl(inout headers_t hdr, inout user_meta_data_t m, in psa_i hdr.ethernet.src_addr = m.addr; } @name("MyIngressControl.macswp") action macswp(@name("tmp1") bit<32> tmp1, @name("tmp2") bit<32> tmp2) { - m.addr = (tmp1 == 32w0x1 && tmp2 == 32w0x2 ? hdr.ethernet.dst_addr : m.addr); - hdr.ethernet.dst_addr = (tmp1 == 32w0x1 && tmp2 == 32w0x2 ? hdr.ethernet.src_addr : hdr.ethernet.dst_addr); - hdr.ethernet.src_addr = (tmp1 == 32w0x1 && tmp2 == 32w0x2 ? m.addr : hdr.ethernet.src_addr); + if (tmp1 == 32w0x1 && tmp2 == 32w0x2) { + m.addr = hdr.ethernet.dst_addr; + hdr.ethernet.dst_addr = hdr.ethernet.src_addr; + hdr.ethernet.src_addr = m.addr; + } } @name("MyIngressControl.stub") table stub_0 { actions = { diff --git a/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-05-midend.p4 b/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-05-midend.p4 index 7044bfa3a7c..40b23e5c8b8 100644 --- a/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-05-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-05-midend.p4 @@ -34,9 +34,11 @@ control MyIngressControl(inout headers_t hdr, inout user_meta_data_t m, in psa_i hdr.ethernet.src_addr = m.addr; } @name("MyIngressControl.macswp") action macswp(@name("tmp1") bit<32> tmp1, @name("tmp2") bit<32> tmp2) { - m.addr = (tmp1 == 32w0x1 && tmp2 == 32w0x2 ? hdr.ethernet.dst_addr : m.addr); - hdr.ethernet.dst_addr = (tmp1 == 32w0x1 && tmp2 == 32w0x2 ? hdr.ethernet.src_addr : hdr.ethernet.dst_addr); - hdr.ethernet.src_addr = (tmp1 == 32w0x1 && tmp2 == 32w0x2 ? m.addr : hdr.ethernet.src_addr); + if (tmp1 == 32w0x1 && tmp2 == 32w0x2) { + m.addr = hdr.ethernet.dst_addr; + hdr.ethernet.dst_addr = hdr.ethernet.src_addr; + hdr.ethernet.src_addr = m.addr; + } } @name("MyIngressControl.stub") table stub_0 { actions = { diff --git a/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-06-midend.p4 b/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-06-midend.p4 index 6cf4335267c..06f1f2fc4d9 100644 --- a/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-06-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-06-midend.p4 @@ -34,9 +34,11 @@ control MyIngressControl(inout headers_t hdr, inout user_meta_data_t m, in psa_i hdr.ethernet.src_addr = m.addr; } @name("MyIngressControl.macswp") action macswp(@name("tmp1") bit<32> tmp1, @name("tmp2") bit<32> tmp2) { - m.addr = (tmp1 == 32w0x1 && tmp2 == 32w0x2 ? hdr.ethernet.dst_addr : m.addr); - hdr.ethernet.dst_addr = (tmp1 == 32w0x1 && tmp2 == 32w0x2 ? hdr.ethernet.src_addr : hdr.ethernet.dst_addr); - hdr.ethernet.src_addr = (tmp1 == 32w0x1 && tmp2 == 32w0x2 ? m.addr : hdr.ethernet.src_addr); + if (tmp1 == 32w0x1 && tmp2 == 32w0x2) { + m.addr = hdr.ethernet.dst_addr; + hdr.ethernet.dst_addr = hdr.ethernet.src_addr; + hdr.ethernet.src_addr = m.addr; + } } @name("MyIngressControl.stub") table stub_0 { actions = { diff --git a/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-07-midend.p4 b/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-07-midend.p4 index 43e38cc193c..67d970edb75 100644 --- a/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-07-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-07-midend.p4 @@ -34,9 +34,11 @@ control MyIngressControl(inout headers_t hdr, inout user_meta_data_t m, in psa_i hdr.ethernet.src_addr = m.addr; } @name("MyIngressControl.macswp") action macswp(@name("tmp1") bit<32> tmp1, @name("tmp2") bit<32> tmp2) { - m.addr = (tmp1 == 32w0x1 && tmp2 == 32w0x2 ? hdr.ethernet.dst_addr : m.addr); - hdr.ethernet.dst_addr = (tmp1 == 32w0x1 && tmp2 == 32w0x2 ? hdr.ethernet.src_addr : hdr.ethernet.dst_addr); - hdr.ethernet.src_addr = (tmp1 == 32w0x1 && tmp2 == 32w0x2 ? m.addr : hdr.ethernet.src_addr); + if (tmp1 == 32w0x1 && tmp2 == 32w0x2) { + m.addr = hdr.ethernet.dst_addr; + hdr.ethernet.dst_addr = hdr.ethernet.src_addr; + hdr.ethernet.src_addr = m.addr; + } } @name("MyIngressControl.stub") table stub_0 { actions = { diff --git a/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-08-midend.p4 b/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-08-midend.p4 index a87287134df..07f35d05afc 100644 --- a/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-08-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-08-midend.p4 @@ -34,9 +34,11 @@ control MyIngressControl(inout headers_t hdr, inout user_meta_data_t m, in psa_i hdr.ethernet.src_addr = m.addr; } @name("MyIngressControl.macswp") action macswp(@name("tmp2") bit<32> tmp2) { - m.addr = (m.flag == 32w0x1 && tmp2 == 32w0x2 ? hdr.ethernet.dst_addr : m.addr); - hdr.ethernet.dst_addr = (m.flag == 32w0x1 && tmp2 == 32w0x2 ? hdr.ethernet.src_addr : hdr.ethernet.dst_addr); - hdr.ethernet.src_addr = (m.flag == 32w0x1 && tmp2 == 32w0x2 ? m.addr : hdr.ethernet.src_addr); + if (m.flag == 32w0x1 && tmp2 == 32w0x2) { + m.addr = hdr.ethernet.dst_addr; + hdr.ethernet.dst_addr = hdr.ethernet.src_addr; + hdr.ethernet.src_addr = m.addr; + } } @name("MyIngressControl.stub") table stub_0 { actions = { diff --git a/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-09-midend.p4 b/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-09-midend.p4 index 3b8dbc137c8..5c701f0cb29 100644 --- a/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-09-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-dpdk-non-zero-arg-default-action-09-midend.p4 @@ -32,9 +32,11 @@ control MyIngressControl(inout headers_t hdr, inout user_meta_data_t m, in psa_i hdr.ethernet.src_addr = m.addr; } @name("MyIngressControl.macswp") action macswp(@name("tmp1") bit<32> tmp1, @name("tmp2") bool tmp2) { - m.addr = (tmp1 == 32w0x1 && tmp2 ? hdr.ethernet.dst_addr : m.addr); - hdr.ethernet.dst_addr = (tmp1 == 32w0x1 && tmp2 ? hdr.ethernet.src_addr : hdr.ethernet.dst_addr); - hdr.ethernet.src_addr = (tmp1 == 32w0x1 && tmp2 ? m.addr : hdr.ethernet.src_addr); + if (tmp1 == 32w0x1 && tmp2) { + m.addr = hdr.ethernet.dst_addr; + hdr.ethernet.dst_addr = hdr.ethernet.src_addr; + hdr.ethernet.src_addr = m.addr; + } } @name("MyIngressControl.stub") table stub_0 { actions = { diff --git a/testdata/p4_16_samples_outputs/psa-dpdk-struct-field-midend.p4 b/testdata/p4_16_samples_outputs/psa-dpdk-struct-field-midend.p4 index aedd7b1f840..653ba3b36bb 100644 --- a/testdata/p4_16_samples_outputs/psa-dpdk-struct-field-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-dpdk-struct-field-midend.p4 @@ -30,9 +30,11 @@ control MyIngressControl(inout headers_t hdr, inout user_meta_data_t m, in psa_i @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("MyIngressControl.macswp") action macswp() { - m.addr = (flg_0 == 80w0x2 ? hdr.ethernet.dst_addr : m.addr); - hdr.ethernet.dst_addr = (flg_0 == 80w0x2 ? hdr.ethernet.src_addr : hdr.ethernet.dst_addr); - hdr.ethernet.src_addr = (flg_0 == 80w0x2 ? m.addr : hdr.ethernet.src_addr); + if (flg_0 == 80w0x2) { + m.addr = hdr.ethernet.dst_addr; + hdr.ethernet.dst_addr = hdr.ethernet.src_addr; + hdr.ethernet.src_addr = m.addr; + } } @name("MyIngressControl.stub") table stub_0 { actions = { diff --git a/testdata/p4_16_samples_outputs/psa-dpdk-tmp-mask-align-midend.p4 b/testdata/p4_16_samples_outputs/psa-dpdk-tmp-mask-align-midend.p4 index 2f74f0cc4b2..1613d01b838 100644 --- a/testdata/p4_16_samples_outputs/psa-dpdk-tmp-mask-align-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-dpdk-tmp-mask-align-midend.p4 @@ -79,7 +79,11 @@ control ingress(inout headers hdr, inout metadata user_meta, in psa_ingress_inpu @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("ingress.execute") action execute_1() { - user_meta.data = (err_0 ? user_meta.data : 16w1); + if (err_0) { + ; + } else { + user_meta.data = 16w1; + } } @name("ingress.tbl") table tbl_0 { key = { diff --git a/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_1-midend.p4 b/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_1-midend.p4 index 3a956fe15c7..037f60d5ea3 100644 --- a/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_1-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_1-midend.p4 @@ -59,6 +59,7 @@ parser IngressParserImpl(packet_in buffer, out headers hdr, inout metadata_t use control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_input_metadata_t istd, inout psa_ingress_output_metadata_t ostd) { @name("ingress.color_out") PSA_MeterColor_t color_out_0; @name("ingress.color_in") PSA_MeterColor_t color_in_0; + @name("ingress.tmp") bit<32> tmp; @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("ingress.counter0") Counter, bit<12>>(32w1024, PSA_CounterType_t.PACKETS_AND_BYTES) counter0_0; @@ -69,13 +70,24 @@ control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_in @name("ingress.execute") action execute_1(@name("index") bit<12> index_1) { hdr.ipv4.ihl = 4w5; color_out_0 = meter0_0.dpdk_execute(index_1, color_in_0, (bit<32>)hdr.ipv4.totalLen); - user_meta.port_out = (color_out_0 == PSA_MeterColor_t.GREEN ? 32w1 : 32w0); - reg_0.write(index_1, (color_out_0 == PSA_MeterColor_t.GREEN ? 32w1 : 32w0)); - hdr.ipv4.ihl = 4w5; - hdr.ipv4.ihl = (hdr.ipv4.version == 4w6 ? 4w6 : 4w5); + if (color_out_0 == PSA_MeterColor_t.GREEN) { + tmp = 32w1; + } else { + tmp = 32w0; + } + user_meta.port_out = tmp; + reg_0.write(index_1, tmp); + if (hdr.ipv4.hdrChecksum[5:0] == 6w6) { + hdr.ipv4.ihl = 4w5; + } + if (hdr.ipv4.version == 4w6) { + hdr.ipv4.ihl = 4w6; + } } @name("ingress.test") action test() { - hdr.ipv4.hdrChecksum[3:0] = (hdr.ipv4.version == 4w4 ? hdr.ipv4.version + 4w5 : hdr.ipv4.hdrChecksum[3:0]); + if (hdr.ipv4.version == 4w4) { + hdr.ipv4.hdrChecksum[3:0] = hdr.ipv4.version + 4w5; + } } @name("ingress.tbl") table tbl_0 { key = { diff --git a/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_2-midend.p4 b/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_2-midend.p4 index c9085cce92b..5cb2c99a595 100644 --- a/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_2-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_2-midend.p4 @@ -58,6 +58,7 @@ parser IngressParserImpl(packet_in buffer, out headers hdr, inout metadata_t use control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_input_metadata_t istd, inout psa_ingress_output_metadata_t ostd) { @name("ingress.color_out") PSA_MeterColor_t color_out_0; @name("ingress.color_in") PSA_MeterColor_t color_in_0; + @name("ingress.tmp") bit<32> tmp; @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("ingress.counter0") Counter, bit<12>>(32w1024, PSA_CounterType_t.PACKETS_AND_BYTES) counter0_0; @@ -68,13 +69,24 @@ control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_in @name("ingress.execute") action execute_1(@name("index") bit<12> index_1) { hdr.ipv4.ihl = 4w5; color_out_0 = meter0_0.dpdk_execute(index_1, color_in_0, (bit<32>)hdr.ipv4.totalLen); - user_meta.port_out = (color_out_0 == PSA_MeterColor_t.GREEN ? 32w1 : 32w0); - reg_0.write(index_1, (color_out_0 == PSA_MeterColor_t.GREEN ? 32w1 : 32w0)); - hdr.ipv4.ihl = 4w5; - hdr.ipv4.ihl = (hdr.ipv4.version == 4w6 ? 4w6 : 4w5); + if (color_out_0 == PSA_MeterColor_t.GREEN) { + tmp = 32w1; + } else { + tmp = 32w0; + } + user_meta.port_out = tmp; + reg_0.write(index_1, tmp); + if (hdr.ipv4.hdrChecksum[5:0] == 6w6) { + hdr.ipv4.ihl = 4w5; + } + if (hdr.ipv4.version == 4w6) { + hdr.ipv4.ihl = 4w6; + } } @name("ingress.test") action test() { - hdr.ipv4.hdrChecksum[3:0] = (hdr.ipv4.version == 4w4 ? hdr.ipv4.version + 4w5 : hdr.ipv4.hdrChecksum[3:0]); + if (hdr.ipv4.version == 4w4) { + hdr.ipv4.hdrChecksum[3:0] = hdr.ipv4.version + 4w5; + } } @name("ingress.tbl") table tbl_0 { key = { diff --git a/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_3-midend.p4 b/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_3-midend.p4 index 332d08fc8f8..c4c70bc5ad0 100644 --- a/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_3-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_3-midend.p4 @@ -58,6 +58,7 @@ parser IngressParserImpl(packet_in buffer, out headers hdr, inout metadata_t use control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_input_metadata_t istd, inout psa_ingress_output_metadata_t ostd) { @name("ingress.color_out") PSA_MeterColor_t color_out_0; @name("ingress.color_in") PSA_MeterColor_t color_in_0; + @name("ingress.tmp") bit<32> tmp; @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("ingress.counter0") Counter, bit<12>>(32w1024, PSA_CounterType_t.PACKETS_AND_BYTES) counter0_0; @@ -68,13 +69,24 @@ control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_in @name("ingress.execute") action execute_1(@name("index") bit<12> index_1) { hdr.ipv4.ihl = 4w5; color_out_0 = meter0_0.dpdk_execute(index_1, color_in_0, (bit<32>)hdr.ipv4.totalLen); - user_meta.port_out = (color_out_0 == PSA_MeterColor_t.GREEN ? 32w1 : 32w0); - reg_0.write(index_1, (color_out_0 == PSA_MeterColor_t.GREEN ? 32w1 : 32w0)); - hdr.ipv4.ihl = 4w5; - hdr.ipv4.ihl = (hdr.ipv4.version == 4w6 ? 4w6 : 4w5); + if (color_out_0 == PSA_MeterColor_t.GREEN) { + tmp = 32w1; + } else { + tmp = 32w0; + } + user_meta.port_out = tmp; + reg_0.write(index_1, tmp); + if (hdr.ipv4.hdrChecksum[5:0] == 6w6) { + hdr.ipv4.ihl = 4w5; + } + if (hdr.ipv4.version == 4w6) { + hdr.ipv4.ihl = 4w6; + } } @name("ingress.test") action test() { - hdr.ipv4.hdrChecksum[3:0] = (hdr.ipv4.version == 4w4 ? hdr.ipv4.version + 4w5 : hdr.ipv4.hdrChecksum[3:0]); + if (hdr.ipv4.version == 4w4) { + hdr.ipv4.hdrChecksum[3:0] = hdr.ipv4.version + 4w5; + } } @name("ingress.tbl") table tbl_0 { key = { diff --git a/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_5-midend.p4 b/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_5-midend.p4 index 8791f351c02..93540452699 100644 --- a/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_5-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_5-midend.p4 @@ -59,6 +59,7 @@ parser IngressParserImpl(packet_in buffer, out headers hdr, inout metadata_t use control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_input_metadata_t istd, inout psa_ingress_output_metadata_t ostd) { @name("ingress.color_out") PSA_MeterColor_t color_out_0; @name("ingress.color_in") PSA_MeterColor_t color_in_0; + @name("ingress.tmp") bit<32> tmp; @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("ingress.counter0") Counter, bit<12>>(32w1024, PSA_CounterType_t.PACKETS_AND_BYTES) counter0_0; @@ -69,13 +70,24 @@ control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_in @name("ingress.execute") action execute_1(@name("index") bit<12> index_1) { hdr.ipv4.ihl = 4w5; color_out_0 = meter0_0.dpdk_execute(index_1, color_in_0, (bit<32>)hdr.ipv4.totalLen); - user_meta.port_out = (color_out_0 == PSA_MeterColor_t.GREEN ? 32w1 : 32w0); - reg_0.write(index_1, (color_out_0 == PSA_MeterColor_t.GREEN ? 32w1 : 32w0)); - hdr.ipv4.ihl = 4w5; - hdr.ipv4.ihl = (hdr.ipv4.version == 4w6 ? 4w6 : 4w5); + if (color_out_0 == PSA_MeterColor_t.GREEN) { + tmp = 32w1; + } else { + tmp = 32w0; + } + user_meta.port_out = tmp; + reg_0.write(index_1, tmp); + if (hdr.ipv4.hdrChecksum[5:0] == 6w6) { + hdr.ipv4.ihl = 4w5; + } + if (hdr.ipv4.version == 4w6) { + hdr.ipv4.ihl = 4w6; + } } @name("ingress.test") action test() { - hdr.ipv4.hdrChecksum[3:0] = (hdr.ipv4.version == 4w4 ? hdr.ipv4.version + 4w5 : hdr.ipv4.hdrChecksum[3:0]); + if (hdr.ipv4.version == 4w4) { + hdr.ipv4.hdrChecksum[3:0] = hdr.ipv4.version + 4w5; + } } @name("ingress.tbl") table tbl_0 { key = { diff --git a/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_6-midend.p4 b/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_6-midend.p4 index ddc08bfa5b2..7f7ab9447d0 100644 --- a/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_6-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_6-midend.p4 @@ -67,6 +67,7 @@ parser IngressParserImpl(packet_in buffer, out headers hdr, inout metadata_t use control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_input_metadata_t istd, inout psa_ingress_output_metadata_t ostd) { @name("ingress.color_out") PSA_MeterColor_t color_out_0; @name("ingress.color_in") PSA_MeterColor_t color_in_0; + @name("ingress.tmp") bit<32> tmp; @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("ingress.counter0") Counter, bit<12>>(32w1024, PSA_CounterType_t.PACKETS_AND_BYTES) counter0_0; @@ -77,16 +78,28 @@ control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_in @name("ingress.execute") action execute_1(@name("index") bit<12> index_1) { hdr.ipv4._ihl1 = 4w5; color_out_0 = meter0_0.dpdk_execute(index_1, color_in_0, (bit<32>)hdr.ipv4._totalLen3); - user_meta.port_out = (color_out_0 == PSA_MeterColor_t.GREEN ? 32w1 : 32w0); - reg_0.write(index_1, (color_out_0 == PSA_MeterColor_t.GREEN ? 32w1 : 32w0)); - hdr.ipv4._ihl1 = (hdr.ipv4._version0 == 4w6 ? 4w6 : 4w5); - hdr.ipv4._s1_f112 = (user_meta.temp == 4w6 ? 4w7 : hdr.ipv4._s1_f112); - hdr.ipv4._s1_f213 = (user_meta.temp == 4w6 ? 4w8 : hdr.ipv4._s1_f213); - hdr.ipv4._s1_f112 = 4w7; - hdr.ipv4._s1_f213 = (user_meta.temp == 4w6 ? 4w8 : 4w9); + if (color_out_0 == PSA_MeterColor_t.GREEN) { + tmp = 32w1; + } else { + tmp = 32w0; + } + user_meta.port_out = tmp; + reg_0.write(index_1, tmp); + if (hdr.ipv4._version0 == 4w6) { + hdr.ipv4._ihl1 = 4w6; + } + if (user_meta.temp == 4w6) { + hdr.ipv4._s1_f112 = 4w7; + hdr.ipv4._s1_f213 = 4w8; + } else { + hdr.ipv4._s1_f112 = 4w7; + hdr.ipv4._s1_f213 = 4w9; + } } @name("ingress.test") action test() { - hdr.ipv4._hdrChecksum9[3:0] = (hdr.ipv4._version0 == 4w4 ? hdr.ipv4._version0 + 4w5 : hdr.ipv4._hdrChecksum9[3:0]); + if (hdr.ipv4._version0 == 4w4) { + hdr.ipv4._hdrChecksum9[3:0] = hdr.ipv4._version0 + 4w5; + } } @name("ingress.tbl") table tbl_0 { key = { diff --git a/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_7-midend.p4 b/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_7-midend.p4 index 936bd1478e7..26a6ff69263 100644 --- a/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_7-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_7-midend.p4 @@ -74,6 +74,7 @@ parser IngressParserImpl(packet_in buffer, out headers hdr, inout metadata_t use control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_input_metadata_t istd, inout psa_ingress_output_metadata_t ostd) { @name("ingress.color_out") PSA_MeterColor_t color_out_0; @name("ingress.color_in") PSA_MeterColor_t color_in_0; + @name("ingress.tmp") bit<32> tmp; @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("ingress.counter0") Counter, bit<12>>(32w1024, PSA_CounterType_t.PACKETS_AND_BYTES) counter0_0; @@ -84,20 +85,32 @@ control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_in @name("ingress.execute") action execute_1(@name("index") bit<12> index_1) { hdr.ipv4._ihl1 = 4w5; color_out_0 = meter0_0.dpdk_execute(index_1, color_in_0, (bit<32>)hdr.ipv4._totalLen3); - user_meta.port_out = (color_out_0 == PSA_MeterColor_t.GREEN ? 32w1 : 32w0); - reg_0.write(index_1, (color_out_0 == PSA_MeterColor_t.GREEN ? 32w1 : 32w0)); - hdr.ipv4._ihl1 = (hdr.ipv4._version0 == 4w6 ? 4w6 : 4w5); - hdr.ipv4._s1_f112 = (user_meta.temp == 4w6 ? 3w2 : hdr.ipv4._s1_f112); - hdr.ipv4._s1_f213 = (user_meta.temp == 4w6 ? 5w3 : hdr.ipv4._s1_f213); - hdr.ipv4._s2_f114 = (user_meta.temp == 4w6 ? 5w2 : hdr.ipv4._s2_f114); - hdr.ipv4._s2_f215 = (user_meta.temp == 4w6 ? 3w3 : hdr.ipv4._s2_f215); - hdr.ipv4._s1_f112 = (user_meta.temp == 4w6 ? 3w2 : 3w3); - hdr.ipv4._s1_f213 = (user_meta.temp == 4w6 ? 5w3 : 5w2); - hdr.ipv4._s2_f114 = (user_meta.temp == 4w6 ? 5w2 : 5w3); - hdr.ipv4._s2_f215 = (user_meta.temp == 4w6 ? 3w3 : 3w2); + if (color_out_0 == PSA_MeterColor_t.GREEN) { + tmp = 32w1; + } else { + tmp = 32w0; + } + user_meta.port_out = tmp; + reg_0.write(index_1, tmp); + if (hdr.ipv4._version0 == 4w6) { + hdr.ipv4._ihl1 = 4w6; + } + if (user_meta.temp == 4w6) { + hdr.ipv4._s1_f112 = 3w2; + hdr.ipv4._s1_f213 = 5w3; + hdr.ipv4._s2_f114 = 5w2; + hdr.ipv4._s2_f215 = 3w3; + } else { + hdr.ipv4._s1_f112 = 3w3; + hdr.ipv4._s1_f213 = 5w2; + hdr.ipv4._s2_f114 = 5w3; + hdr.ipv4._s2_f215 = 3w2; + } } @name("ingress.test") action test() { - hdr.ipv4._hdrChecksum9[3:0] = (hdr.ipv4._version0 == 4w4 ? hdr.ipv4._version0 + 4w5 : hdr.ipv4._hdrChecksum9[3:0]); + if (hdr.ipv4._version0 == 4w4) { + hdr.ipv4._hdrChecksum9[3:0] = hdr.ipv4._version0 + 4w5; + } } @name("ingress.tbl") table tbl_0 { key = { diff --git a/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_8-midend.p4 b/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_8-midend.p4 index bcc0cfd9c1e..dd97f96e6a1 100644 --- a/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_8-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_8-midend.p4 @@ -74,6 +74,7 @@ parser IngressParserImpl(packet_in buffer, out headers hdr, inout metadata_t use control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_input_metadata_t istd, inout psa_ingress_output_metadata_t ostd) { @name("ingress.color_out") PSA_MeterColor_t color_out_0; @name("ingress.color_in") PSA_MeterColor_t color_in_0; + @name("ingress.tmp") bit<32> tmp; @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("ingress.counter0") Counter, bit<12>>(32w1024, PSA_CounterType_t.PACKETS_AND_BYTES) counter0_0; @@ -84,20 +85,32 @@ control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_in @name("ingress.execute") action execute_1(@name("index") bit<12> index_1) { hdr.ipv4._ihl1 = 4w5; color_out_0 = meter0_0.dpdk_execute(index_1, color_in_0, (bit<32>)hdr.ipv4._totalLen3); - user_meta.port_out = (color_out_0 == PSA_MeterColor_t.GREEN ? 32w1 : 32w0); - reg_0.write(index_1, (color_out_0 == PSA_MeterColor_t.GREEN ? 32w1 : 32w0)); - hdr.ipv4._ihl1 = (hdr.ipv4._version0 == 4w6 ? 4w6 : 4w5); - hdr.ipv4._s1_f112 = (user_meta.temp == 4w6 ? 8w2 : hdr.ipv4._s1_f112); - hdr.ipv4._s1_f213 = (user_meta.temp == 4w6 ? 3w3 : hdr.ipv4._s1_f213); - hdr.ipv4._s2_f114 = (user_meta.temp == 4w6 ? 5w2 : hdr.ipv4._s2_f114); - hdr.ipv4._s2_f215 = (user_meta.temp == 4w6 ? 8w3 : hdr.ipv4._s2_f215); - hdr.ipv4._s1_f112 = (user_meta.temp == 4w6 ? 8w2 : 8w3); - hdr.ipv4._s1_f213 = (user_meta.temp == 4w6 ? 3w3 : 3w2); - hdr.ipv4._s2_f114 = (user_meta.temp == 4w6 ? 5w2 : 5w3); - hdr.ipv4._s2_f215 = (user_meta.temp == 4w6 ? 8w3 : 8w2); + if (color_out_0 == PSA_MeterColor_t.GREEN) { + tmp = 32w1; + } else { + tmp = 32w0; + } + user_meta.port_out = tmp; + reg_0.write(index_1, tmp); + if (hdr.ipv4._version0 == 4w6) { + hdr.ipv4._ihl1 = 4w6; + } + if (user_meta.temp == 4w6) { + hdr.ipv4._s1_f112 = 8w2; + hdr.ipv4._s1_f213 = 3w3; + hdr.ipv4._s2_f114 = 5w2; + hdr.ipv4._s2_f215 = 8w3; + } else { + hdr.ipv4._s1_f112 = 8w3; + hdr.ipv4._s1_f213 = 3w2; + hdr.ipv4._s2_f114 = 5w3; + hdr.ipv4._s2_f215 = 8w2; + } } @name("ingress.test") action test() { - hdr.ipv4._hdrChecksum9[3:0] = (hdr.ipv4._version0 == 4w4 ? hdr.ipv4._version0 + 4w5 : hdr.ipv4._hdrChecksum9[3:0]); + if (hdr.ipv4._version0 == 4w4) { + hdr.ipv4._hdrChecksum9[3:0] = hdr.ipv4._version0 + 4w5; + } } @name("ingress.tbl") table tbl_0 { key = { diff --git a/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_9-midend.p4 b/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_9-midend.p4 index 4d100c1838e..4ffd180369b 100644 --- a/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_9-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-example-dpdk-byte-alignment_9-midend.p4 @@ -58,6 +58,7 @@ parser IngressParserImpl(packet_in buffer, out headers hdr, inout metadata_t use control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_input_metadata_t istd, inout psa_ingress_output_metadata_t ostd) { @name("ingress.color_out") PSA_MeterColor_t color_out_0; @name("ingress.color_in") PSA_MeterColor_t color_in_0; + @name("ingress.tmp") bit<32> tmp; @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("ingress.counter0") Counter, bit<12>>(32w1024, PSA_CounterType_t.PACKETS_AND_BYTES) counter0_0; @@ -68,13 +69,24 @@ control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_in @name("ingress.execute") action execute_1(@name("index") bit<12> index_1) { hdr.ipv4.ihl = 4w5; color_out_0 = meter0_0.dpdk_execute(index_1, color_in_0, (bit<32>)hdr.ipv4.totalLen); - user_meta.port_out = (color_out_0 == PSA_MeterColor_t.GREEN ? 32w1 : 32w0); - reg_0.write(index_1, (color_out_0 == PSA_MeterColor_t.GREEN ? 32w1 : 32w0)); - hdr.ipv4.ihl = 4w5; - hdr.ipv4.ihl = (hdr.ipv4.version == 4w6 ? 4w6 : 4w5); + if (color_out_0 == PSA_MeterColor_t.GREEN) { + tmp = 32w1; + } else { + tmp = 32w0; + } + user_meta.port_out = tmp; + reg_0.write(index_1, tmp); + if (hdr.ipv4.hdrChecksum[5:0] == 6w6) { + hdr.ipv4.ihl = 4w5; + } + if (hdr.ipv4.version == 4w6) { + hdr.ipv4.ihl = 4w6; + } } @name("ingress.test") action test() { - hdr.ipv4.hdrChecksum[3:0] = (hdr.ipv4.version == 4w4 ? hdr.ipv4.version + 4w5 : hdr.ipv4.hdrChecksum[3:0]); + if (hdr.ipv4.version == 4w4) { + hdr.ipv4.hdrChecksum[3:0] = hdr.ipv4.version + 4w5; + } } @name("ingress.tbl") table tbl_0 { key = { diff --git a/testdata/p4_16_samples_outputs/psa-example-dpdk-directmeter-midend.p4 b/testdata/p4_16_samples_outputs/psa-example-dpdk-directmeter-midend.p4 index bb573eccc7b..c6ff75d4b4e 100644 --- a/testdata/p4_16_samples_outputs/psa-example-dpdk-directmeter-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-example-dpdk-directmeter-midend.p4 @@ -35,12 +35,18 @@ parser MyEP(packet_in buffer, out EMPTY a, inout metadata_t b, in psa_egress_par control MyIC(inout headers_t hdr, inout metadata_t b, in psa_ingress_input_metadata_t c, inout psa_ingress_output_metadata_t d) { @name("MyIC.color_out") PSA_MeterColor_t color_out_0; @name("MyIC.color_in") PSA_MeterColor_t color_in_0; + @name("MyIC.tmp") bit<32> tmp; @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("MyIC.meter0") DirectMeter(PSA_MeterType_t.PACKETS) meter0_0; @name("MyIC.execute_meter") action execute_meter() { color_out_0 = meter0_0.dpdk_execute(color_in_0, 32w1024); - b.port_out = (color_out_0 == PSA_MeterColor_t.GREEN ? 32w1 : 32w0); + if (color_out_0 == PSA_MeterColor_t.GREEN) { + tmp = 32w1; + } else { + tmp = 32w0; + } + b.port_out = tmp; } @name("MyIC.tbl") table tbl_0 { key = { diff --git a/testdata/p4_16_samples_outputs/psa-example-dpdk-externs-midend.p4 b/testdata/p4_16_samples_outputs/psa-example-dpdk-externs-midend.p4 index d483c814fba..feb72a587af 100644 --- a/testdata/p4_16_samples_outputs/psa-example-dpdk-externs-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-example-dpdk-externs-midend.p4 @@ -52,6 +52,7 @@ parser IngressParserImpl(packet_in buffer, out headers hdr, inout metadata_t use control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_input_metadata_t istd, inout psa_ingress_output_metadata_t ostd) { @name("ingress.color_out") PSA_MeterColor_t color_out_0; @name("ingress.color_in") PSA_MeterColor_t color_in_0; + @name("ingress.tmp") bit<32> tmp; @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("ingress.counter0") Counter, bit<12>>(32w1024, PSA_CounterType_t.PACKETS_AND_BYTES) counter0_0; @@ -61,8 +62,13 @@ control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_in @name("ingress.meter0") Meter>(32w1024, PSA_MeterType_t.BYTES) meter0_0; @name("ingress.execute") action execute_1(@name("index") bit<12> index_1) { color_out_0 = meter0_0.dpdk_execute(index_1, color_in_0, (bit<32>)hdr.ipv4.totalLen); - user_meta.port_out = (color_out_0 == PSA_MeterColor_t.GREEN ? 32w1 : 32w0); - reg_0.write(index_1, (color_out_0 == PSA_MeterColor_t.GREEN ? 32w1 : 32w0)); + if (color_out_0 == PSA_MeterColor_t.GREEN) { + tmp = 32w1; + } else { + tmp = 32w0; + } + user_meta.port_out = tmp; + reg_0.write(index_1, tmp); } @name("ingress.tbl") table tbl_0 { key = { diff --git a/testdata/p4_16_samples_outputs/psa-example-dpdk-meter-execute-err-midend.p4 b/testdata/p4_16_samples_outputs/psa-example-dpdk-meter-execute-err-midend.p4 index c2e3c14fd5d..a491bf448f2 100644 --- a/testdata/p4_16_samples_outputs/psa-example-dpdk-meter-execute-err-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-example-dpdk-meter-execute-err-midend.p4 @@ -59,6 +59,7 @@ parser IngressParserImpl(packet_in buffer, out headers hdr, inout metadata_t use control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_input_metadata_t istd, inout psa_ingress_output_metadata_t ostd) { @name("ingress.color_out") PSA_MeterColor_t color_out_0; @name("ingress.color_in") PSA_MeterColor_t color_in_0; + @name("ingress.tmp") bit<32> tmp; @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("ingress.counter0") Counter, bit<12>>(32w1024, PSA_CounterType_t.PACKETS_AND_BYTES) counter0_0; @@ -69,13 +70,24 @@ control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_in @name("ingress.execute") action execute_1(@name("index") bit<12> index_1) { hdr.ipv4.ihl = 4w5; color_out_0 = meter0_0.execute(index_1, color_in_0); - user_meta.port_out = (color_out_0 == PSA_MeterColor_t.GREEN ? 32w1 : 32w0); - reg_0.write(index_1, (color_out_0 == PSA_MeterColor_t.GREEN ? 32w1 : 32w0)); - hdr.ipv4.ihl = 4w5; - hdr.ipv4.ihl = (hdr.ipv4.version == 4w6 ? 4w6 : 4w5); + if (color_out_0 == PSA_MeterColor_t.GREEN) { + tmp = 32w1; + } else { + tmp = 32w0; + } + user_meta.port_out = tmp; + reg_0.write(index_1, tmp); + if (hdr.ipv4.hdrChecksum[5:0] == 6w6) { + hdr.ipv4.ihl = 4w5; + } + if (hdr.ipv4.version == 4w6) { + hdr.ipv4.ihl = 4w6; + } } @name("ingress.test") action test() { - hdr.ipv4.hdrChecksum[3:0] = (hdr.ipv4.version == 4w4 ? hdr.ipv4.version + 4w5 : hdr.ipv4.hdrChecksum[3:0]); + if (hdr.ipv4.version == 4w4) { + hdr.ipv4.hdrChecksum[3:0] = hdr.ipv4.version + 4w5; + } } @name("ingress.tbl") table tbl_0 { key = { diff --git a/testdata/p4_16_samples_outputs/psa-example-dpdk-meter-midend.p4 b/testdata/p4_16_samples_outputs/psa-example-dpdk-meter-midend.p4 index a2afb313b98..7b9fcf7b7ba 100644 --- a/testdata/p4_16_samples_outputs/psa-example-dpdk-meter-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-example-dpdk-meter-midend.p4 @@ -51,12 +51,18 @@ parser IngressParserImpl(packet_in buffer, out headers hdr, inout metadata_t use control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_input_metadata_t istd, inout psa_ingress_output_metadata_t ostd) { @name("ingress.color_out") PSA_MeterColor_t color_out_0; + @name("ingress.tmp") bit<32> tmp; @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("ingress.meter0") Meter>(32w1024, PSA_MeterType_t.BYTES) meter0_0; @name("ingress.execute") action execute_1(@name("index") bit<12> index_1) { color_out_0 = meter0_0.dpdk_execute(index_1, (bit<32>)hdr.ipv4.totalLen); - user_meta.port_out = (color_out_0 == PSA_MeterColor_t.GREEN ? 32w1 : 32w0); + if (color_out_0 == PSA_MeterColor_t.GREEN) { + tmp = 32w1; + } else { + tmp = 32w0; + } + user_meta.port_out = tmp; } @name("ingress.tbl") table tbl_0 { key = { diff --git a/testdata/p4_16_samples_outputs/psa-example-dpdk-meter1-midend.p4 b/testdata/p4_16_samples_outputs/psa-example-dpdk-meter1-midend.p4 index 64b4dfa352d..a66e0c6cf9e 100644 --- a/testdata/p4_16_samples_outputs/psa-example-dpdk-meter1-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-example-dpdk-meter1-midend.p4 @@ -52,12 +52,18 @@ parser IngressParserImpl(packet_in buffer, out headers hdr, inout metadata_t use control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_input_metadata_t istd, inout psa_ingress_output_metadata_t ostd) { @name("ingress.color_out") PSA_MeterColor_t color_out_0; @name("ingress.color_in") PSA_MeterColor_t color_in_0; + @name("ingress.tmp") bit<32> tmp; @noWarn("unused") @name(".NoAction") action NoAction_1() { } @name("ingress.meter0") Meter>(32w1024, PSA_MeterType_t.PACKETS) meter0_0; @name("ingress.execute") action execute_1(@name("index") bit<12> index_1) { color_out_0 = meter0_0.dpdk_execute(index_1, color_in_0, (bit<32>)hdr.ipv4.totalLen); - user_meta.port_out = (color_out_0 == PSA_MeterColor_t.GREEN ? 32w1 : 32w0); + if (color_out_0 == PSA_MeterColor_t.GREEN) { + tmp = 32w1; + } else { + tmp = 32w0; + } + user_meta.port_out = tmp; } @name("ingress.tbl") table tbl_0 { key = { diff --git a/testdata/p4_16_samples_outputs/psa-subtract-inst1-midend.p4 b/testdata/p4_16_samples_outputs/psa-subtract-inst1-midend.p4 index 36d4dbdeeca..fd5abb473ef 100644 --- a/testdata/p4_16_samples_outputs/psa-subtract-inst1-midend.p4 +++ b/testdata/p4_16_samples_outputs/psa-subtract-inst1-midend.p4 @@ -48,11 +48,13 @@ control MyIngressControl(inout headers_t hdrs, inout user_meta_data_t meta, in p @name("MyIngressControl.var4") int<33> var4_0; @name("MyIngressControl.var5") int<33> var5_0; @name("MyIngressControl.nonDefAct") action nonDefAct() { - meta.depth3 = (var4_0 == 33s3 && var5_0 == 33s1 ? meta.depth3 + 5w29 : meta.depth3); - meta.depth4 = (var4_0 == 33s3 && var5_0 == 33s1 ? var1_0 + var2_0 : meta.depth4); - meta.depth5 = (var4_0 == 33s3 && var5_0 == 33s1 ? var1_0 ^ 5w2 : meta.depth5); - meta.depth6 = (var4_0 == 33s3 && var5_0 == 33s1 ? var2_0 + 5w31 : meta.depth6); - meta.depth7 = (var4_0 == 33s3 && var5_0 == 33s1 ? var2_0 + 5w3 : meta.depth7); + if (var4_0 == 33s3 && var5_0 == 33s1) { + meta.depth3 = meta.depth3 + 5w29; + meta.depth4 = var1_0 + var2_0; + meta.depth5 = var1_0 ^ 5w2; + meta.depth6 = var2_0 + 5w31; + meta.depth7 = var2_0 + 5w3; + } } @name("MyIngressControl.stub") table stub_0 { actions = { diff --git a/testdata/p4_16_samples_outputs/xor_test-midend.p4 b/testdata/p4_16_samples_outputs/xor_test-midend.p4 index 46ca7e614db..3e1bf99c1f7 100644 --- a/testdata/p4_16_samples_outputs/xor_test-midend.p4 +++ b/testdata/p4_16_samples_outputs/xor_test-midend.p4 @@ -63,21 +63,25 @@ control MyVerifyChecksum(inout headers hdr, inout metadata meta) { } control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - bool cond_0; @noWarn("unused") @name(".NoAction") action NoAction_1() { } @noWarn("unused") @name(".NoAction") action NoAction_2() { } @name("MyIngress.forward_and_do_something") action forward_and_do_something(@name("port") bit<9> port) { standard_metadata.egress_spec = port; - meta.before1 = (hdr.ipv4.isValid() ? hdr.ipv4.srcAddr : meta.before1); - hdr.ipv4.srcAddr = (hdr.ipv4.isValid() ? hdr.ipv4.srcAddr ^ 32w0x12345678 : hdr.ipv4.srcAddr); - meta.after1 = (hdr.ipv4.isValid() ? hdr.ipv4.srcAddr : meta.after1); - cond_0 = hdr.ethernet.isValid(); - hdr.ipv4.protocol = (hdr.ethernet.isValid() ? (hdr.ethernet.isValid() ? hdr.ipv4.protocol ^ 8w1 : hdr.ipv4.protocol) : hdr.ipv4.protocol); - meta.before2 = (cond_0 ? hdr.ipv4.dstAddr : meta.before2); - hdr.ipv4.dstAddr = (cond_0 ? hdr.ipv4.dstAddr ^ 32w0x12345678 : hdr.ipv4.dstAddr); - meta.after2 = (cond_0 ? hdr.ipv4.dstAddr : meta.after2); + if (hdr.ipv4.isValid()) { + meta.before1 = hdr.ipv4.srcAddr; + hdr.ipv4.srcAddr = hdr.ipv4.srcAddr ^ 32w0x12345678; + meta.after1 = hdr.ipv4.srcAddr; + } + if (hdr.ethernet.isValid()) { + if (hdr.ethernet.isValid()) { + hdr.ipv4.protocol = hdr.ipv4.protocol ^ 8w1; + } + meta.before2 = hdr.ipv4.dstAddr; + hdr.ipv4.dstAddr = hdr.ipv4.dstAddr ^ 32w0x12345678; + meta.after2 = hdr.ipv4.dstAddr; + } meta.before3 = hdr.ipv4.srcAddr; hdr.ipv4.srcAddr = hdr.ipv4.srcAddr ^ 32w0x12345678; meta.after3 = hdr.ipv4.srcAddr;