Skip to content

Commit

Permalink
Always insert instantiation statement at the end of the local stateme…
Browse files Browse the repository at this point in the history
…nt list
  • Loading branch information
qobilidop committed Apr 3, 2023
1 parent 787e718 commit 6b4aa1c
Show file tree
Hide file tree
Showing 54 changed files with 1,689 additions and 1,552 deletions.
1 change: 1 addition & 0 deletions backends/p4tools/submodules/inja
Submodule inja added at d462b9
6 changes: 2 additions & 4 deletions frontends/p4/directCalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
namespace P4 {

const IR::Node *DoInstantiateCalls::postorder(IR::P4Parser *parser) {
insert.append(parser->parserLocals);
parser->parserLocals = insert;
parser->parserLocals.append(insert);
insert.clear();
return parser;
}

const IR::Node *DoInstantiateCalls::postorder(IR::P4Control *control) {
insert.append(control->controlLocals);
control->controlLocals = insert;
control->controlLocals.append(insert);
insert.clear();
return control;
}
Expand Down
1 change: 0 additions & 1 deletion testdata/p4_16_errors_outputs/list-error.p4
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ control c() {
control C();
package top(C _c);
top(c()) main;

3 changes: 0 additions & 3 deletions testdata/p4_16_errors_outputs/psa-meter2.p4
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,5 @@ control MyED(packet_out buffer, out EMPTY a, out EMPTY b, inout EMPTY c, in EMPT
}

IngressPipeline(MyIP(), MyIC(), MyID()) ip;

EgressPipeline(MyEP(), MyEC(), MyED()) ep;

PSA_Switch(ip, PacketReplicationEngine(), ep, BufferingQueueingEngine()) main;

37 changes: 37 additions & 0 deletions testdata/p4_16_samples/extern-inst-as-param.p4
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <core.p4>

extern MyCounter<I> {
MyCounter(bit<32> size);
void count(in I index);
}

typedef bit<10> my_counter_index_t;
typedef MyCounter<my_counter_index_t> my_counter_t;

control Inner(my_counter_t counter_set) {
action count(my_counter_index_t index) {
counter_set.count(index);
}

table counter_table {
actions = {
count;
}
}

apply {
counter_table.apply();
}
}

control Test() {
my_counter_t(1024) counter_set;

apply {
Inner.apply(counter_set);
}
}

control C();
package P(C _c);
P(Test()) main;
6 changes: 3 additions & 3 deletions testdata/p4_16_samples_outputs/dash/dash-pipeline-first.p4
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,6 @@ control acl(inout headers_t hdr, inout metadata_t meta, inout standard_metadata_
}

control outbound(inout headers_t hdr, inout metadata_t meta, inout standard_metadata_t standard_metadata) {
@name("acl") acl() acl_inst;
action route_vnet(bit<16> dst_vnet_id) {
meta.dst_vnet_id = dst_vnet_id;
}
Expand Down Expand Up @@ -488,6 +487,7 @@ control outbound(inout headers_t hdr, inout metadata_t meta, inout standard_meta
}
default_action = NoAction();
}
@name("acl") acl() acl_inst;
apply {
if (meta.conntrack_data.allow_out) {
;
Expand Down Expand Up @@ -560,8 +560,6 @@ control dash_compute_checksum(inout headers_t hdr, inout metadata_t meta) {
}

control dash_ingress(inout headers_t hdr, inout metadata_t meta, inout standard_metadata_t standard_metadata) {
@name("outbound") outbound() outbound_inst;
@name("inbound") inbound() inbound_inst;
action drop_action() {
mark_to_drop(standard_metadata);
}
Expand Down Expand Up @@ -730,6 +728,8 @@ control dash_ingress(inout headers_t hdr, inout metadata_t meta, inout standard_
}
default_action = NoAction();
}
@name("outbound") outbound() outbound_inst;
@name("inbound") inbound() inbound_inst;
apply {
standard_metadata.egress_spec = standard_metadata.ingress_port;
if (vip.apply().hit) {
Expand Down
488 changes: 244 additions & 244 deletions testdata/p4_16_samples_outputs/dash/dash-pipeline-frontend.p4

Large diffs are not rendered by default.

488 changes: 244 additions & 244 deletions testdata/p4_16_samples_outputs/dash/dash-pipeline-midend.p4

Large diffs are not rendered by default.

Loading

0 comments on commit 6b4aa1c

Please sign in to comment.