From 53f4bbcc0d68a97401a62d670f4906a74cec190a Mon Sep 17 00:00:00 2001 From: Chris Dodd Date: Wed, 11 Jun 2025 07:42:25 +0000 Subject: [PATCH] Check for out/inout bindings aliased with uses - pass that finds captured expressions in callable (symbols defined outside the callable) - modify some failing tests to not have the error Signed-off-by: Chris Dodd --- frontends/CMakeLists.txt | 2 + frontends/p4/checkArgAlias.cpp | 135 ++++++++++++++++++ frontends/p4/checkArgAlias.h | 96 +++++++++++++ frontends/p4/frontend.cpp | 2 + frontends/p4/methodInstance.h | 4 + ir/dbprint-p4.cpp | 5 +- .../gauntlet_hdr_out_in_action-bmv2.p4 | 0 .../gauntlet_indirect_hdr_assign_1-bmv2.p4 | 0 .../gauntlet_hdr_out_in_action-bmv2.p4 | 0 .../gauntlet_hdr_out_in_action-bmv2.p4-stderr | 9 ++ .../gauntlet_indirect_hdr_assign_1-bmv2.p4 | 0 ...ntlet_indirect_hdr_assign_1-bmv2.p4-stderr | 9 ++ .../p4_16_samples/gauntlet_action_mux-bmv2.p4 | 2 +- .../p4_16_samples/gauntlet_copy_out-bmv2.p4 | 2 +- .../gauntlet_hdr_out_in_action-bmv2.stf | 2 - .../gauntlet_indirect_hdr_assign_1-bmv2.stf | 2 - testdata/p4_16_samples/issue2289.p4 | 2 +- testdata/p4_16_samples/issue2375-1-bmv2.p4 | 2 +- testdata/p4_16_samples/issue2498-bmv2.p4 | 2 +- ...psa-dpdk-non-zero-arg-default-action-08.p4 | 2 +- testdata/p4_16_samples/nested_if_else.p4 | 4 +- .../nested_if_lvalue_dependencies.p4 | 4 +- testdata/p4_16_samples/nested_if_statement.p4 | 4 +- .../gauntlet_action_mux-bmv2-first.p4 | 2 +- .../gauntlet_action_mux-bmv2-frontend.p4 | 10 +- .../gauntlet_action_mux-bmv2-midend.p4 | 4 +- .../gauntlet_action_mux-bmv2.p4 | 2 +- .../gauntlet_action_mux-bmv2.p4-stderr | 4 +- .../gauntlet_copy_out-bmv2-first.p4 | 1 - .../gauntlet_copy_out-bmv2.p4 | 1 - .../gauntlet_hdr_out_in_action-bmv2-first.p4 | 64 --------- ...auntlet_hdr_out_in_action-bmv2-frontend.p4 | 62 -------- .../gauntlet_hdr_out_in_action-bmv2-midend.p4 | 69 --------- .../gauntlet_hdr_out_in_action-bmv2.p4-stderr | 6 - ...et_hdr_out_in_action-bmv2.p4.entries.txtpb | 3 - ...let_hdr_out_in_action-bmv2.p4.p4info.txtpb | 13 -- ...untlet_indirect_hdr_assign_1-bmv2-first.p4 | 58 -------- ...let_indirect_hdr_assign_1-bmv2-frontend.p4 | 57 -------- ...ntlet_indirect_hdr_assign_1-bmv2-midend.p4 | 60 -------- ...ntlet_indirect_hdr_assign_1-bmv2.p4-stderr | 3 - ...ndirect_hdr_assign_1-bmv2.p4.entries.txtpb | 3 - ...indirect_hdr_assign_1-bmv2.p4.p4info.txtpb | 13 -- .../p4_16_samples_outputs/issue2289-first.p4 | 2 +- .../issue2289-frontend.p4 | 11 ++ .../p4_16_samples_outputs/issue2289-midend.p4 | 3 +- testdata/p4_16_samples_outputs/issue2289.p4 | 2 +- .../p4_16_samples_outputs/issue2289.p4-stderr | 12 -- .../issue2375-1-bmv2-first.p4 | 2 +- .../p4_16_samples_outputs/issue2375-1-bmv2.p4 | 2 +- .../issue2375-1-bmv2.p4-stderr | 3 - .../issue2498-bmv2-first.p4 | 2 +- .../issue2498-bmv2-frontend.p4 | 2 +- .../issue2498-bmv2-midend.p4 | 11 +- .../p4_16_samples_outputs/issue2498-bmv2.p4 | 2 +- ...dk-non-zero-arg-default-action-08-first.p4 | 2 +- ...non-zero-arg-default-action-08-frontend.p4 | 2 +- ...k-non-zero-arg-default-action-08-midend.p4 | 3 +- ...psa-dpdk-non-zero-arg-default-action-08.p4 | 2 +- .../nested_if_else-first.p4 | 2 +- .../nested_if_else-frontend.p4 | 2 +- .../nested_if_else-midend.p4 | 2 +- .../p4_16_samples_outputs/nested_if_else.p4 | 2 +- .../nested_if_lvalue_dependencies-first.p4 | 2 +- .../nested_if_lvalue_dependencies-frontend.p4 | 2 +- .../nested_if_lvalue_dependencies-midend.p4 | 2 +- .../nested_if_lvalue_dependencies.p4 | 2 +- .../nested_if_statement-first.p4 | 2 +- .../nested_if_statement-frontend.p4 | 2 +- .../nested_if_statement-midend.p4 | 2 +- .../nested_if_statement.p4 | 2 +- 70 files changed, 327 insertions(+), 485 deletions(-) create mode 100644 frontends/p4/checkArgAlias.cpp create mode 100644 frontends/p4/checkArgAlias.h rename testdata/{p4_16_samples => p4_16_errors}/gauntlet_hdr_out_in_action-bmv2.p4 (100%) rename testdata/{p4_16_samples => p4_16_errors}/gauntlet_indirect_hdr_assign_1-bmv2.p4 (100%) rename testdata/{p4_16_samples_outputs => p4_16_errors_outputs}/gauntlet_hdr_out_in_action-bmv2.p4 (100%) create mode 100644 testdata/p4_16_errors_outputs/gauntlet_hdr_out_in_action-bmv2.p4-stderr rename testdata/{p4_16_samples_outputs => p4_16_errors_outputs}/gauntlet_indirect_hdr_assign_1-bmv2.p4 (100%) create mode 100644 testdata/p4_16_errors_outputs/gauntlet_indirect_hdr_assign_1-bmv2.p4-stderr delete mode 100644 testdata/p4_16_samples/gauntlet_hdr_out_in_action-bmv2.stf delete mode 100644 testdata/p4_16_samples/gauntlet_indirect_hdr_assign_1-bmv2.stf delete mode 100644 testdata/p4_16_samples_outputs/gauntlet_hdr_out_in_action-bmv2-first.p4 delete mode 100644 testdata/p4_16_samples_outputs/gauntlet_hdr_out_in_action-bmv2-frontend.p4 delete mode 100644 testdata/p4_16_samples_outputs/gauntlet_hdr_out_in_action-bmv2-midend.p4 delete mode 100644 testdata/p4_16_samples_outputs/gauntlet_hdr_out_in_action-bmv2.p4-stderr delete mode 100644 testdata/p4_16_samples_outputs/gauntlet_hdr_out_in_action-bmv2.p4.entries.txtpb delete mode 100644 testdata/p4_16_samples_outputs/gauntlet_hdr_out_in_action-bmv2.p4.p4info.txtpb delete mode 100644 testdata/p4_16_samples_outputs/gauntlet_indirect_hdr_assign_1-bmv2-first.p4 delete mode 100644 testdata/p4_16_samples_outputs/gauntlet_indirect_hdr_assign_1-bmv2-frontend.p4 delete mode 100644 testdata/p4_16_samples_outputs/gauntlet_indirect_hdr_assign_1-bmv2-midend.p4 delete mode 100644 testdata/p4_16_samples_outputs/gauntlet_indirect_hdr_assign_1-bmv2.p4-stderr delete mode 100644 testdata/p4_16_samples_outputs/gauntlet_indirect_hdr_assign_1-bmv2.p4.entries.txtpb delete mode 100644 testdata/p4_16_samples_outputs/gauntlet_indirect_hdr_assign_1-bmv2.p4.p4info.txtpb diff --git a/frontends/CMakeLists.txt b/frontends/CMakeLists.txt index 03d61bf3047..5eb5452ea93 100644 --- a/frontends/CMakeLists.txt +++ b/frontends/CMakeLists.txt @@ -15,6 +15,7 @@ set (P4_FRONTEND_SRCS p4/actionsInlining.cpp p4/callGraph.cpp + p4/checkArgAlias.cpp p4/checkConstants.cpp p4/checkCoreMethods.cpp p4/checkNamedArgs.cpp @@ -103,6 +104,7 @@ set (P4_FRONTEND_HDRS p4/actionsInlining.h p4/alias.h p4/callGraph.h + p4/checkArgAlias.h p4/checkConstants.h p4/checkCoreMethods.h p4/checkNamedArgs.h diff --git a/frontends/p4/checkArgAlias.cpp b/frontends/p4/checkArgAlias.cpp new file mode 100644 index 00000000000..73319630218 --- /dev/null +++ b/frontends/p4/checkArgAlias.cpp @@ -0,0 +1,135 @@ +/* +Copyright 2025 Nvidia, 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 "checkArgAlias.h" + +#include "methodInstance.h" + +namespace P4 { + +// find the enclosing 'location' expression from the current context. That +// is, any Member(s) or ArrayIndex(s) that are a parents of the current node. +const IR::Expression *CheckArgAlias::FindCaptures::getRefCtxt() { + auto *ctxt = getChildContext(); + for (; auto *p = ctxt->parent; ctxt = p) { + if (p->node->is()) continue; + if (p->node->is() && p->child_index == 0) continue; + break; + } + return ctxt->node->to(); +} + +bool CheckArgAlias::FindCaptures::preorder(const IR::PathExpression *pe) { + const Context *ctxt = nullptr; + auto last = visiting.end(); + --last; + while (auto scope = findOrigCtxt(ctxt)) { + auto rv = lookup(scope, pe->path->name, ResolutionType::Any); + if (!rv.empty()) break; + if (last->second == scope->getNode()) --last; + } + auto expr = getRefCtxt(); + for (++last; last < visiting.end(); ++last) { + LOG4(expr << " escapes from " << DBPrint::Brief << last->first); + result[last->first][pe->path->name].push_back(expr); + } + return true; +} + +bool CheckArgAlias::FindCaptures::preorder(const IR::IApply *ia) { + LOG3("CheckArgAlias::preorder(IA): " << DBPrint::Brief << ia); + auto *d = ia->to(); + visiting.push_back(std::make_pair(d, d->getNode())); + return true; +} + +bool CheckArgAlias::FindCaptures::preorder(const IR::IFunctional *fn) { + LOG3("CheckArgAlias::preorder(IF): " << DBPrint::Brief << fn); + auto *d = fn->to(); + visiting.push_back(std::make_pair(d, d->getNode())); + return true; +} + +const IR::Expression *CheckArgAlias::Check::baseExpr(const IR::Expression *e, int *depth) { + if (depth) ++*depth; + if (auto *mem = e->to()) return baseExpr(mem->expr, depth); + if (auto *ai = e->to()) return baseExpr(ai->left, depth); + return e; +} + +int CheckArgAlias::Check::baseExprDepth(const IR::Expression *e) { + int depth = 0; + baseExpr(e, &depth); + return depth; +} + +bool CheckArgAlias::Check::overlaps(const IR::Expression *e1, const IR::Expression *e2) { + while (auto *ai = e1->to()) e1 = ai->left; + while (auto *ai = e2->to()) e2 = ai->left; + auto *m1 = e1->to(); + auto *m2 = e2->to(); + if (m1 && m2) { + if (m1->expr->type == m2->expr->type) return m1->member == m2->member; + if (baseExprDepth(m1->expr) > baseExprDepth(m2->expr)) + return overlaps(m1->expr, e2); + else + return overlaps(e1, m2->expr); + } else if (m1) { + return overlaps(m1->expr, e2); + } else if (m2) { + return overlaps(e1, m2->expr); + } + BUG_CHECK(e1->is(), "'%1%' not a PathExpression", e1); + BUG_CHECK(e2->is(), "'%1%' not a PathExpression", e2); + BUG_CHECK(e1->equiv(*e2), "'%1%' and '%2%' are different", e1, e2); + return e1->equiv(*e2); +} + +bool CheckArgAlias::Check::preorder(const IR::MethodCallExpression *mce) { + LOG3("CheckArgAlias::Check::preorder(MCE): " << mce); + auto *mi = MethodInstance::resolve(mce, this, self.typeMap); + BUG_CHECK(mi, "MethodInstance::resolve failed"); + if (!self.captures.any(mi->callee())) return true; + auto arg = mi->expr->arguments->begin(); + auto *params = mi->actualMethodType->parameters; + for (auto it = params->begin(); it < params->end(); ++it, ++arg) { + if (arg == mi->expr->arguments->end()) { + // at the end of the argument list -- rest of params must be directionless + // and this must be an action call + BUG_CHECK(mi->is(), "not an action call?"); + break; + } + auto *param = *it; + if (param->direction == IR::Direction::None) continue; + if (param->direction == IR::Direction::In) continue; + auto *exp = (*arg)->expression; + while (auto *sl = exp->to()) exp = sl->e0; + auto *pe = baseExpr(exp)->to(); + BUG_CHECK(pe, "not a PathExpression"); + for (auto *cap : self.captures(mi->callee(), pe->path->name)) { + if (overlaps(exp, cap)) { + error(ErrorType::ERR_INVALID, "%1%%2% binds value accessed by callee %3%%4%", + param->direction == IR::Direction::InOut ? "inout argument" : "out argument", + (*arg)->srcInfo, mi->callee(), cap->srcInfo); + // only trigger once per call + return true; + } + } + } + return true; +} + +} // namespace P4 diff --git a/frontends/p4/checkArgAlias.h b/frontends/p4/checkArgAlias.h new file mode 100644 index 00000000000..3d8f43ff3d4 --- /dev/null +++ b/frontends/p4/checkArgAlias.h @@ -0,0 +1,96 @@ +/* +Copyright 2025 Nvidia, 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. +*/ + +#ifndef FRONTENDS_P4_CHECKARGALIAS_H_ +#define FRONTENDS_P4_CHECKARGALIAS_H_ + +#include "frontends/common/resolveReferences/resolveReferences.h" +#include "ir/ir.h" +#include "ir/pass_manager.h" +#include "typeChecking/typeChecker.h" +#include "typeMap.h" + +namespace P4 { + +class CheckArgAlias : public PassManager { + TypeMap *typeMap; + class FindCaptures : public Inspector, public ResolutionContext { + std::vector> visiting; + profile_t init_apply(const IR::Node *root) { + auto rv = Inspector::init_apply(root); + // initialize visiting stack with (just) sentinel value; + visiting.resize(1); + visiting.back().first = nullptr; + visiting.back().second = nullptr; + return rv; + } + + const IR::Expression *getRefCtxt(); + + bool preorder(const IR::PathExpression *); + bool preorder(const IR::Type_Name *) { return false; } + + bool preorder(const IR::IApply *); + bool preorder(const IR::IFunctional *); + + // FIXME -- would be nice if dynamic dispatch could handle this automatically + bool preorder(const IR::Node *n) { + if (auto *ia = n->to()) return preorder(ia); + if (auto *fn = n->to()) return preorder(fn); + return true; + } + void postorder(const IR::Node *n) { + if (!visiting.empty() && visiting.back().second == n) visiting.pop_back(); + } + + void end_apply(const IR::Node *) { BUG_CHECK(visiting.size() == 1, "failed to finish?"); } + void end_apply() { visiting.clear(); } + + using result_t = std::vector; + std::map> result; + + public: + const result_t &operator()(const IR::IDeclaration *d, cstring name) const { + static result_t empty; + auto i1 = result.find(d); + if (i1 == result.end()) return empty; + auto i2 = i1->second.find(name); + if (i2 == i1->second.end()) return empty; + return i2->second; + } + bool any(const IR::IDeclaration *d) const { return result.find(d) != result.end(); } + } captures; + + class Check : public Inspector, public ResolutionContext { + const CheckArgAlias &self; + const IR::Expression *baseExpr(const IR::Expression *, int * = nullptr); + int baseExprDepth(const IR::Expression *e); + bool overlaps(const IR::Expression *e1, const IR::Expression *e2); + bool preorder(const IR::MethodCallExpression *); + + public: + explicit Check(const CheckArgAlias &s) : self(s) {} + }; + + public: + explicit CheckArgAlias(TypeMap *tm) : typeMap(tm) { + addPasses({&captures, new ReadOnlyTypeInference(typeMap), new Check(*this)}); + } +}; + +} // namespace P4 + +#endif /* FRONTENDS_P4_CHECKARGALIAS_H_ */ diff --git a/frontends/p4/frontend.cpp b/frontends/p4/frontend.cpp index 08f64eff435..f3117037288 100644 --- a/frontends/p4/frontend.cpp +++ b/frontends/p4/frontend.cpp @@ -26,6 +26,7 @@ limitations under the License. #include "lib/nullstream.h" // Passes #include "actionsInlining.h" +#include "checkArgAlias.h" #include "checkConstants.h" #include "checkCoreMethods.h" #include "checkNamedArgs.h" @@ -232,6 +233,7 @@ const IR::P4Program *FrontEnd::run(const CompilerOptions &options, const IR::P4P }), new CheckCoreMethods(&typeMap), new StaticAssert(&typeMap), + new CheckArgAlias(&typeMap), }); metricsPassManager.addUnusedCode(passes, true); passes.addPasses({ diff --git a/frontends/p4/methodInstance.h b/frontends/p4/methodInstance.h index 2ddd0918225..9decda6ec60 100644 --- a/frontends/p4/methodInstance.h +++ b/frontends/p4/methodInstance.h @@ -84,6 +84,7 @@ class MethodInstance : public InstanceBase { with instantiated type parameters. */ const IR::Type_MethodBase *actualMethodType; virtual bool isApply() const { return false; } + virtual const IR::IDeclaration *callee() const { return object; } /** @param useExpressionType If true, the typeMap can be nullptr, * and then mce->type is used. For some technical reasons @@ -141,6 +142,7 @@ class ApplyMethod final : public MethodInstance { const IR::IApply *applyObject; bool isApply() const override { return true; } bool isTableApply() const { return object->is(); } + const IR::IDeclaration *callee() const override { return applyObject->to(); } DECLARE_TYPEINFO(ApplyMethod, MethodInstance); }; @@ -222,6 +224,7 @@ class ActionCall final : public MethodInstance { /// Generate a version of the action where the parameters in the /// substitution have been replaced with the arguments. const IR::P4Action *specialize(const DeclarationLookup *refMap) const; + const IR::IDeclaration *callee() const override { return action; } DECLARE_TYPEINFO(ActionCall, MethodInstance); }; @@ -244,6 +247,7 @@ class FunctionCall final : public MethodInstance { public: const IR::Function *function; + const IR::IDeclaration *callee() const override { return function; } DECLARE_TYPEINFO(FunctionCall, MethodInstance); }; diff --git a/ir/dbprint-p4.cpp b/ir/dbprint-p4.cpp index 4d3e42c172c..11a89b08b5f 100644 --- a/ir/dbprint-p4.cpp +++ b/ir/dbprint-p4.cpp @@ -138,7 +138,9 @@ void IR::ActionFunction::dbprint(std::ostream &out) const { } void IR::P4Action::dbprint(std::ostream &out) const { - out << annotations << "action " << name << "("; + out << annotations << "action " << name; + if (dbgetflags(out) & Brief) return; + out << "("; const char *sep = ""; for (auto arg : parameters->parameters) { out << sep << arg->direction << ' ' << arg->type << ' ' << arg->name; @@ -214,6 +216,7 @@ void IR::V1Control::dbprint(std::ostream &out) const { } void IR::P4Control::dbprint(std::ostream &out) const { out << "control " << name; + if (dbgetflags(out) & Brief) return; if (type->typeParameters && !type->typeParameters->empty()) out << type->typeParameters; if (type->applyParams) out << '(' << type->applyParams << ')'; if (constructorParams) out << '(' << constructorParams << ')'; diff --git a/testdata/p4_16_samples/gauntlet_hdr_out_in_action-bmv2.p4 b/testdata/p4_16_errors/gauntlet_hdr_out_in_action-bmv2.p4 similarity index 100% rename from testdata/p4_16_samples/gauntlet_hdr_out_in_action-bmv2.p4 rename to testdata/p4_16_errors/gauntlet_hdr_out_in_action-bmv2.p4 diff --git a/testdata/p4_16_samples/gauntlet_indirect_hdr_assign_1-bmv2.p4 b/testdata/p4_16_errors/gauntlet_indirect_hdr_assign_1-bmv2.p4 similarity index 100% rename from testdata/p4_16_samples/gauntlet_indirect_hdr_assign_1-bmv2.p4 rename to testdata/p4_16_errors/gauntlet_indirect_hdr_assign_1-bmv2.p4 diff --git a/testdata/p4_16_samples_outputs/gauntlet_hdr_out_in_action-bmv2.p4 b/testdata/p4_16_errors_outputs/gauntlet_hdr_out_in_action-bmv2.p4 similarity index 100% rename from testdata/p4_16_samples_outputs/gauntlet_hdr_out_in_action-bmv2.p4 rename to testdata/p4_16_errors_outputs/gauntlet_hdr_out_in_action-bmv2.p4 diff --git a/testdata/p4_16_errors_outputs/gauntlet_hdr_out_in_action-bmv2.p4-stderr b/testdata/p4_16_errors_outputs/gauntlet_hdr_out_in_action-bmv2.p4-stderr new file mode 100644 index 00000000000..385c7fcfb35 --- /dev/null +++ b/testdata/p4_16_errors_outputs/gauntlet_hdr_out_in_action-bmv2.p4-stderr @@ -0,0 +1,9 @@ +gauntlet_hdr_out_in_action-bmv2.p4(40): [--Werror=invalid] error: out argument binds value accessed by callee do_action + do_action(h.eth_hdr); + ^^^^^^^^^ +gauntlet_hdr_out_in_action-bmv2.p4(35) + action do_action(out ethernet_t val) { + ^^^^^^^^^ +gauntlet_hdr_out_in_action-bmv2.p4(36) + h.eth_hdr.dst_addr = 1; + ^^^^^^^^^^^^^^^^^^ diff --git a/testdata/p4_16_samples_outputs/gauntlet_indirect_hdr_assign_1-bmv2.p4 b/testdata/p4_16_errors_outputs/gauntlet_indirect_hdr_assign_1-bmv2.p4 similarity index 100% rename from testdata/p4_16_samples_outputs/gauntlet_indirect_hdr_assign_1-bmv2.p4 rename to testdata/p4_16_errors_outputs/gauntlet_indirect_hdr_assign_1-bmv2.p4 diff --git a/testdata/p4_16_errors_outputs/gauntlet_indirect_hdr_assign_1-bmv2.p4-stderr b/testdata/p4_16_errors_outputs/gauntlet_indirect_hdr_assign_1-bmv2.p4-stderr new file mode 100644 index 00000000000..1f1a3b890ac --- /dev/null +++ b/testdata/p4_16_errors_outputs/gauntlet_indirect_hdr_assign_1-bmv2.p4-stderr @@ -0,0 +1,9 @@ +gauntlet_indirect_hdr_assign_1-bmv2.p4(32): [--Werror=invalid] error: inout argument binds value accessed by callee do_action + do_action(h); + ^ +gauntlet_indirect_hdr_assign_1-bmv2.p4(27) + action do_action(inout Headers val) { + ^^^^^^^^^ +gauntlet_indirect_hdr_assign_1-bmv2.p4(28) + h.eth_hdr.eth_type = 2; + ^^^^^^^^^^^^^^^^^^ diff --git a/testdata/p4_16_samples/gauntlet_action_mux-bmv2.p4 b/testdata/p4_16_samples/gauntlet_action_mux-bmv2.p4 index 3f81856f8bd..74ab2a411d0 100644 --- a/testdata/p4_16_samples/gauntlet_action_mux-bmv2.p4 +++ b/testdata/p4_16_samples/gauntlet_action_mux-bmv2.p4 @@ -22,7 +22,7 @@ struct Meta { } control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - action do_thing(inout bit<8> val_0) { + action do_thing(in bit<8> val_0) { h.h.a = h.h.b >= 4 ? h.h.b : h.h.b + 1; } apply { diff --git a/testdata/p4_16_samples/gauntlet_copy_out-bmv2.p4 b/testdata/p4_16_samples/gauntlet_copy_out-bmv2.p4 index ae63184d857..07169b3e2b3 100644 --- a/testdata/p4_16_samples/gauntlet_copy_out-bmv2.p4 +++ b/testdata/p4_16_samples/gauntlet_copy_out-bmv2.p4 @@ -23,7 +23,7 @@ control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { bit<8> c = 8w12; action do_thing(inout bit<8> inout_c) { h.h.a = inout_c; - c = 8w24; + // c = 8w24; } apply { do_thing(c); diff --git a/testdata/p4_16_samples/gauntlet_hdr_out_in_action-bmv2.stf b/testdata/p4_16_samples/gauntlet_hdr_out_in_action-bmv2.stf deleted file mode 100644 index b7fa0918df8..00000000000 --- a/testdata/p4_16_samples/gauntlet_hdr_out_in_action-bmv2.stf +++ /dev/null @@ -1,2 +0,0 @@ -packet 0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -expect 0 00 diff --git a/testdata/p4_16_samples/gauntlet_indirect_hdr_assign_1-bmv2.stf b/testdata/p4_16_samples/gauntlet_indirect_hdr_assign_1-bmv2.stf deleted file mode 100644 index b86af9a11c3..00000000000 --- a/testdata/p4_16_samples/gauntlet_indirect_hdr_assign_1-bmv2.stf +++ /dev/null @@ -1,2 +0,0 @@ -packet 0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -expect 0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 diff --git a/testdata/p4_16_samples/issue2289.p4 b/testdata/p4_16_samples/issue2289.p4 index b846498be25..93b04643f4a 100644 --- a/testdata/p4_16_samples/issue2289.p4 +++ b/testdata/p4_16_samples/issue2289.p4 @@ -42,7 +42,7 @@ 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) { action simple_action(out bit<16> byaA) { - h.eth_hdr.eth_type = function_2(function_1()); + byaA = function_2(function_1()); } apply { function_1(); diff --git a/testdata/p4_16_samples/issue2375-1-bmv2.p4 b/testdata/p4_16_samples/issue2375-1-bmv2.p4 index ad7fdc18b8f..58f68847cf1 100644 --- a/testdata/p4_16_samples/issue2375-1-bmv2.p4 +++ b/testdata/p4_16_samples/issue2375-1-bmv2.p4 @@ -32,7 +32,7 @@ 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 tmp = false; action do_action(inout bool val) { - do_function(tmp); + do_function(val); } apply { diff --git a/testdata/p4_16_samples/issue2498-bmv2.p4 b/testdata/p4_16_samples/issue2498-bmv2.p4 index 76e3dc062f3..d43b99fdb1e 100644 --- a/testdata/p4_16_samples/issue2498-bmv2.p4 +++ b/testdata/p4_16_samples/issue2498-bmv2.p4 @@ -34,11 +34,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) { action slice_action(inout bit<1> sliced_val) { - h.h.a = 2; sliced_val = 1; } apply { + h.h.a = 2; slice_action(h.h.a[0:0]); } } diff --git a/testdata/p4_16_samples/m_psa-dpdk-non-zero-arg-default-action-08.p4 b/testdata/p4_16_samples/m_psa-dpdk-non-zero-arg-default-action-08.p4 index e680240c186..8df18cffafd 100644 --- a/testdata/p4_16_samples/m_psa-dpdk-non-zero-arg-default-action-08.p4 +++ b/testdata/p4_16_samples/m_psa-dpdk-non-zero-arg-default-action-08.p4 @@ -46,7 +46,7 @@ control MyIngressControl( hdr.ethernet.dst_addr = hdr.ethernet.src_addr; hdr.ethernet.src_addr = m.addr; } - action macswp(inout bit<48> tmp1, bit<32> tmp2) { + action macswp(in bit<48> tmp1, bit<32> tmp2) { if (tmp1 == 0x1 && tmp2 == 0x2) { m.addr = hdr.ethernet.dst_addr; hdr.ethernet.dst_addr = hdr.ethernet.src_addr; diff --git a/testdata/p4_16_samples/nested_if_else.p4 b/testdata/p4_16_samples/nested_if_else.p4 index 20ce2f51e98..b16f534a671 100644 --- a/testdata/p4_16_samples/nested_if_else.p4 +++ b/testdata/p4_16_samples/nested_if_else.p4 @@ -76,7 +76,7 @@ control MyIngress(inout headers hdr, value = 0; bit<16> x = hdr.ipv4.identification; bit<16> y = hdr.ipv4.hdrChecksum; - bit<16> z = hdr.ipv4.totalLen; + bit<16> z = hdr.ipv4.srcAddr[15:0]; c = hdr.ipv4.identification > 16w0; c1 = hdr.ipv4.identification > 16w1; c2 = hdr.ipv4.identification > 16w2; @@ -147,4 +147,4 @@ MyIngress(), MyEgress(), MyComputeChecksum(), MyDeparser() -) main; \ No newline at end of file +) main; diff --git a/testdata/p4_16_samples/nested_if_lvalue_dependencies.p4 b/testdata/p4_16_samples/nested_if_lvalue_dependencies.p4 index d48cc09903c..bd69e6f0124 100644 --- a/testdata/p4_16_samples/nested_if_lvalue_dependencies.p4 +++ b/testdata/p4_16_samples/nested_if_lvalue_dependencies.p4 @@ -73,7 +73,7 @@ control MyIngress(inout headers hdr, value = 0; bit<16> x = hdr.ipv4.identification; bit<16> y = hdr.ipv4.hdrChecksum; - bit<16> z = hdr.ipv4.totalLen; + bit<16> z = hdr.ipv4.srcAddr[15:0]; c = hdr.ipv4.identification > 16w0; @@ -139,4 +139,4 @@ MyIngress(), MyEgress(), MyComputeChecksum(), MyDeparser() -) main; \ No newline at end of file +) main; diff --git a/testdata/p4_16_samples/nested_if_statement.p4 b/testdata/p4_16_samples/nested_if_statement.p4 index bb14d004e40..f23017d3433 100644 --- a/testdata/p4_16_samples/nested_if_statement.p4 +++ b/testdata/p4_16_samples/nested_if_statement.p4 @@ -76,7 +76,7 @@ control MyIngress(inout headers hdr, value = 0; bit<16> x = hdr.ipv4.identification; bit<16> y = hdr.ipv4.hdrChecksum; - bit<16> z = hdr.ipv4.totalLen; + bit<16> z = hdr.ipv4.srcAddr[15:0]; c = hdr.ipv4.identification > 16w0; c1 = hdr.ipv4.identification > 16w1; @@ -148,4 +148,4 @@ MyIngress(), MyEgress(), MyComputeChecksum(), MyDeparser() -) main; \ No newline at end of file +) main; diff --git a/testdata/p4_16_samples_outputs/gauntlet_action_mux-bmv2-first.p4 b/testdata/p4_16_samples_outputs/gauntlet_action_mux-bmv2-first.p4 index a556b73c1d5..e129e09dadd 100644 --- a/testdata/p4_16_samples_outputs/gauntlet_action_mux-bmv2-first.p4 +++ b/testdata/p4_16_samples_outputs/gauntlet_action_mux-bmv2-first.p4 @@ -23,7 +23,7 @@ struct Meta { } control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - action do_thing(inout bit<8> val_0) { + action do_thing(in bit<8> val_0) { h.h.a = (h.h.b >= 8w4 ? h.h.b : h.h.b + 8w1); } apply { diff --git a/testdata/p4_16_samples_outputs/gauntlet_action_mux-bmv2-frontend.p4 b/testdata/p4_16_samples_outputs/gauntlet_action_mux-bmv2-frontend.p4 index 94296befb2d..51a47364072 100644 --- a/testdata/p4_16_samples_outputs/gauntlet_action_mux-bmv2-frontend.p4 +++ b/testdata/p4_16_samples_outputs/gauntlet_action_mux-bmv2-frontend.p4 @@ -24,21 +24,15 @@ struct Meta { control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { @name("ingress.tmp") bit<8> tmp; - @name("ingress.val_0") bit<8> val; - @name("ingress.val_0") bit<8> val_2; @name("ingress.do_thing") action do_thing() { - val = h.h.b; + } + @name("ingress.do_thing") action do_thing_1() { if (h.h.b >= 8w4) { tmp = h.h.b; } else { tmp = h.h.b + 8w1; } h.h.a = tmp; - h.h.b = val; - } - @name("ingress.do_thing") action do_thing_1() { - val_2 = h.h.a; - h.h.a = val_2; } apply { do_thing(); 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 831fc8f9fea..80a164dcbe6 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 @@ -25,6 +25,8 @@ 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() { + } + @name("ingress.do_thing") action do_thing_1() { if (h.h.b >= 8w4) { tmp = h.h.b; } else { @@ -32,8 +34,6 @@ control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { } h.h.a = tmp; } - @name("ingress.do_thing") action do_thing_1() { - } @hidden table tbl_do_thing { actions = { do_thing(); diff --git a/testdata/p4_16_samples_outputs/gauntlet_action_mux-bmv2.p4 b/testdata/p4_16_samples_outputs/gauntlet_action_mux-bmv2.p4 index 901ec741d3f..b7d29424044 100644 --- a/testdata/p4_16_samples_outputs/gauntlet_action_mux-bmv2.p4 +++ b/testdata/p4_16_samples_outputs/gauntlet_action_mux-bmv2.p4 @@ -23,7 +23,7 @@ struct Meta { } control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - action do_thing(inout bit<8> val_0) { + action do_thing(in bit<8> val_0) { h.h.a = (h.h.b >= 4 ? h.h.b : h.h.b + 1); } apply { diff --git a/testdata/p4_16_samples_outputs/gauntlet_action_mux-bmv2.p4-stderr b/testdata/p4_16_samples_outputs/gauntlet_action_mux-bmv2.p4-stderr index e14c7424d07..4ea4f01ce07 100644 --- a/testdata/p4_16_samples_outputs/gauntlet_action_mux-bmv2.p4-stderr +++ b/testdata/p4_16_samples_outputs/gauntlet_action_mux-bmv2.p4-stderr @@ -1,3 +1,3 @@ gauntlet_action_mux-bmv2.p4(25): [--Wwarn=unused] warning: 'val_0' is unused - action do_thing(inout bit<8> val_0) { - ^^^^^ + action do_thing(in bit<8> val_0) { + ^^^^^ diff --git a/testdata/p4_16_samples_outputs/gauntlet_copy_out-bmv2-first.p4 b/testdata/p4_16_samples_outputs/gauntlet_copy_out-bmv2-first.p4 index 60a3072eae1..1b4e53fc5c2 100644 --- a/testdata/p4_16_samples_outputs/gauntlet_copy_out-bmv2-first.p4 +++ b/testdata/p4_16_samples_outputs/gauntlet_copy_out-bmv2-first.p4 @@ -25,7 +25,6 @@ control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { bit<8> c = 8w12; action do_thing(inout bit<8> inout_c) { h.h.a = inout_c; - c = 8w24; } apply { do_thing(c); diff --git a/testdata/p4_16_samples_outputs/gauntlet_copy_out-bmv2.p4 b/testdata/p4_16_samples_outputs/gauntlet_copy_out-bmv2.p4 index c04344770cf..eaa7fa7f28c 100644 --- a/testdata/p4_16_samples_outputs/gauntlet_copy_out-bmv2.p4 +++ b/testdata/p4_16_samples_outputs/gauntlet_copy_out-bmv2.p4 @@ -25,7 +25,6 @@ control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { bit<8> c = 8w12; action do_thing(inout bit<8> inout_c) { h.h.a = inout_c; - c = 8w24; } apply { do_thing(c); diff --git a/testdata/p4_16_samples_outputs/gauntlet_hdr_out_in_action-bmv2-first.p4 b/testdata/p4_16_samples_outputs/gauntlet_hdr_out_in_action-bmv2-first.p4 deleted file mode 100644 index 3eea96ec0af..00000000000 --- a/testdata/p4_16_samples_outputs/gauntlet_hdr_out_in_action-bmv2-first.p4 +++ /dev/null @@ -1,64 +0,0 @@ -#include -#define V1MODEL_VERSION 20180101 -#include - -header ethernet_t { - bit<48> dst_addr; - bit<48> src_addr; - bit<16> eth_type; -} - -header H { - bit<8> a; -} - -struct Headers { - ethernet_t eth_hdr; - H h; -} - -struct Meta { -} - -parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t sm) { - state start { - transition parse_hdrs; - } - state parse_hdrs { - pkt.extract(hdr.eth_hdr); - pkt.extract(hdr.h); - transition accept; - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - action do_action(out ethernet_t val) { - h.eth_hdr.dst_addr = 48w1; - } - apply { - do_action(h.eth_hdr); - } -} - -control vrfy(inout Headers h, inout Meta m) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out pkt, in Headers h) { - apply { - pkt.emit(h); - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/p4_16_samples_outputs/gauntlet_hdr_out_in_action-bmv2-frontend.p4 b/testdata/p4_16_samples_outputs/gauntlet_hdr_out_in_action-bmv2-frontend.p4 deleted file mode 100644 index 9a62b11d99c..00000000000 --- a/testdata/p4_16_samples_outputs/gauntlet_hdr_out_in_action-bmv2-frontend.p4 +++ /dev/null @@ -1,62 +0,0 @@ -#include -#define V1MODEL_VERSION 20180101 -#include - -header ethernet_t { - bit<48> dst_addr; - bit<48> src_addr; - bit<16> eth_type; -} - -header H { - bit<8> a; -} - -struct Headers { - ethernet_t eth_hdr; - H h; -} - -struct Meta { -} - -parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t sm) { - state start { - pkt.extract(hdr.eth_hdr); - pkt.extract(hdr.h); - transition accept; - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - @name("ingress.val") ethernet_t val_0; - @name("ingress.do_action") action do_action() { - h.eth_hdr = val_0; - } - apply { - do_action(); - } -} - -control vrfy(inout Headers h, inout Meta m) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out pkt, in Headers h) { - apply { - pkt.emit(h); - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/p4_16_samples_outputs/gauntlet_hdr_out_in_action-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/gauntlet_hdr_out_in_action-bmv2-midend.p4 deleted file mode 100644 index 4942edc6ee9..00000000000 --- a/testdata/p4_16_samples_outputs/gauntlet_hdr_out_in_action-bmv2-midend.p4 +++ /dev/null @@ -1,69 +0,0 @@ -#include -#define V1MODEL_VERSION 20180101 -#include - -header ethernet_t { - bit<48> dst_addr; - bit<48> src_addr; - bit<16> eth_type; -} - -header H { - bit<8> a; -} - -struct Headers { - ethernet_t eth_hdr; - H h; -} - -struct Meta { -} - -parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t sm) { - state start { - pkt.extract(hdr.eth_hdr); - pkt.extract(hdr.h); - transition accept; - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - @name("ingress.val") ethernet_t val_0; - @name("ingress.do_action") action do_action() { - h.eth_hdr = val_0; - } - @hidden table tbl_do_action { - actions = { - do_action(); - } - const default_action = do_action(); - } - apply { - tbl_do_action.apply(); - } -} - -control vrfy(inout Headers h, inout Meta m) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out pkt, in Headers h) { - apply { - pkt.emit(h.eth_hdr); - pkt.emit(h.h); - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/p4_16_samples_outputs/gauntlet_hdr_out_in_action-bmv2.p4-stderr b/testdata/p4_16_samples_outputs/gauntlet_hdr_out_in_action-bmv2.p4-stderr deleted file mode 100644 index 4d95bc78fca..00000000000 --- a/testdata/p4_16_samples_outputs/gauntlet_hdr_out_in_action-bmv2.p4-stderr +++ /dev/null @@ -1,6 +0,0 @@ -gauntlet_hdr_out_in_action-bmv2.p4(35): [--Wwarn=unused] warning: 'val' is unused - action do_action(out ethernet_t val) { - ^^^ -gauntlet_hdr_out_in_action-bmv2.p4(35): [--Wwarn=uninitialized_use] warning: val.dst_addr may be uninitialized - action do_action(out ethernet_t val) { - ^^^ diff --git a/testdata/p4_16_samples_outputs/gauntlet_hdr_out_in_action-bmv2.p4.entries.txtpb b/testdata/p4_16_samples_outputs/gauntlet_hdr_out_in_action-bmv2.p4.entries.txtpb deleted file mode 100644 index 5cb9652623a..00000000000 --- a/testdata/p4_16_samples_outputs/gauntlet_hdr_out_in_action-bmv2.p4.entries.txtpb +++ /dev/null @@ -1,3 +0,0 @@ -# proto-file: p4/v1/p4runtime.proto -# proto-message: p4.v1.WriteRequest - diff --git a/testdata/p4_16_samples_outputs/gauntlet_hdr_out_in_action-bmv2.p4.p4info.txtpb b/testdata/p4_16_samples_outputs/gauntlet_hdr_out_in_action-bmv2.p4.p4info.txtpb deleted file mode 100644 index 4b0ff88b01a..00000000000 --- a/testdata/p4_16_samples_outputs/gauntlet_hdr_out_in_action-bmv2.p4.p4info.txtpb +++ /dev/null @@ -1,13 +0,0 @@ -# proto-file: p4/config/v1/p4info.proto -# proto-message: p4.config.v1.P4Info - -pkg_info { - arch: "v1model" -} -actions { - preamble { - id: 21566949 - name: "ingress.do_action" - alias: "do_action" - } -} diff --git a/testdata/p4_16_samples_outputs/gauntlet_indirect_hdr_assign_1-bmv2-first.p4 b/testdata/p4_16_samples_outputs/gauntlet_indirect_hdr_assign_1-bmv2-first.p4 deleted file mode 100644 index 60d7938dd95..00000000000 --- a/testdata/p4_16_samples_outputs/gauntlet_indirect_hdr_assign_1-bmv2-first.p4 +++ /dev/null @@ -1,58 +0,0 @@ -#include -#define V1MODEL_VERSION 20180101 -#include - -header ethernet_t { - bit<48> dst_addr; - bit<48> src_addr; - bit<16> eth_type; -} - -struct Headers { - ethernet_t eth_hdr; -} - -struct Meta { -} - -parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t sm) { - state start { - transition parse_hdrs; - } - state parse_hdrs { - pkt.extract(hdr.eth_hdr); - transition accept; - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - action do_action(inout Headers val) { - h.eth_hdr.eth_type = 16w2; - } - apply { - do_action(h); - } -} - -control vrfy(inout Headers h, inout Meta m) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out pkt, in Headers h) { - apply { - pkt.emit(h); - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/p4_16_samples_outputs/gauntlet_indirect_hdr_assign_1-bmv2-frontend.p4 b/testdata/p4_16_samples_outputs/gauntlet_indirect_hdr_assign_1-bmv2-frontend.p4 deleted file mode 100644 index 32093468029..00000000000 --- a/testdata/p4_16_samples_outputs/gauntlet_indirect_hdr_assign_1-bmv2-frontend.p4 +++ /dev/null @@ -1,57 +0,0 @@ -#include -#define V1MODEL_VERSION 20180101 -#include - -header ethernet_t { - bit<48> dst_addr; - bit<48> src_addr; - bit<16> eth_type; -} - -struct Headers { - ethernet_t eth_hdr; -} - -struct Meta { -} - -parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t sm) { - state start { - pkt.extract(hdr.eth_hdr); - transition accept; - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - @name("ingress.val") Headers val_0; - @name("ingress.do_action") action do_action() { - val_0 = h; - h = val_0; - } - apply { - do_action(); - } -} - -control vrfy(inout Headers h, inout Meta m) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out pkt, in Headers h) { - apply { - pkt.emit(h); - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/p4_16_samples_outputs/gauntlet_indirect_hdr_assign_1-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/gauntlet_indirect_hdr_assign_1-bmv2-midend.p4 deleted file mode 100644 index ba9246a2f41..00000000000 --- a/testdata/p4_16_samples_outputs/gauntlet_indirect_hdr_assign_1-bmv2-midend.p4 +++ /dev/null @@ -1,60 +0,0 @@ -#include -#define V1MODEL_VERSION 20180101 -#include - -header ethernet_t { - bit<48> dst_addr; - bit<48> src_addr; - bit<16> eth_type; -} - -struct Headers { - ethernet_t eth_hdr; -} - -struct Meta { -} - -parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t sm) { - state start { - pkt.extract(hdr.eth_hdr); - transition accept; - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - @name("ingress.do_action") action do_action() { - } - @hidden table tbl_do_action { - actions = { - do_action(); - } - const default_action = do_action(); - } - apply { - tbl_do_action.apply(); - } -} - -control vrfy(inout Headers h, inout Meta m) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out pkt, in Headers h) { - apply { - pkt.emit(h.eth_hdr); - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/p4_16_samples_outputs/gauntlet_indirect_hdr_assign_1-bmv2.p4-stderr b/testdata/p4_16_samples_outputs/gauntlet_indirect_hdr_assign_1-bmv2.p4-stderr deleted file mode 100644 index 5376c9cd576..00000000000 --- a/testdata/p4_16_samples_outputs/gauntlet_indirect_hdr_assign_1-bmv2.p4-stderr +++ /dev/null @@ -1,3 +0,0 @@ -gauntlet_indirect_hdr_assign_1-bmv2.p4(27): [--Wwarn=unused] warning: 'val' is unused - action do_action(inout Headers val) { - ^^^ diff --git a/testdata/p4_16_samples_outputs/gauntlet_indirect_hdr_assign_1-bmv2.p4.entries.txtpb b/testdata/p4_16_samples_outputs/gauntlet_indirect_hdr_assign_1-bmv2.p4.entries.txtpb deleted file mode 100644 index 5cb9652623a..00000000000 --- a/testdata/p4_16_samples_outputs/gauntlet_indirect_hdr_assign_1-bmv2.p4.entries.txtpb +++ /dev/null @@ -1,3 +0,0 @@ -# proto-file: p4/v1/p4runtime.proto -# proto-message: p4.v1.WriteRequest - diff --git a/testdata/p4_16_samples_outputs/gauntlet_indirect_hdr_assign_1-bmv2.p4.p4info.txtpb b/testdata/p4_16_samples_outputs/gauntlet_indirect_hdr_assign_1-bmv2.p4.p4info.txtpb deleted file mode 100644 index 4b0ff88b01a..00000000000 --- a/testdata/p4_16_samples_outputs/gauntlet_indirect_hdr_assign_1-bmv2.p4.p4info.txtpb +++ /dev/null @@ -1,13 +0,0 @@ -# proto-file: p4/config/v1/p4info.proto -# proto-message: p4.config.v1.P4Info - -pkg_info { - arch: "v1model" -} -actions { - preamble { - id: 21566949 - name: "ingress.do_action" - alias: "do_action" - } -} diff --git a/testdata/p4_16_samples_outputs/issue2289-first.p4 b/testdata/p4_16_samples_outputs/issue2289-first.p4 index 501c0d61f8d..15aefe3bb22 100644 --- a/testdata/p4_16_samples_outputs/issue2289-first.p4 +++ b/testdata/p4_16_samples_outputs/issue2289-first.p4 @@ -43,7 +43,7 @@ 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) { action simple_action(out bit<16> byaA) { - h.eth_hdr.eth_type = function_2(function_1()); + byaA = function_2(function_1()); } apply { function_1(); diff --git a/testdata/p4_16_samples_outputs/issue2289-frontend.p4 b/testdata/p4_16_samples_outputs/issue2289-frontend.p4 index 90060aeeff5..87bd9b1b9e3 100644 --- a/testdata/p4_16_samples_outputs/issue2289-frontend.p4 +++ b/testdata/p4_16_samples_outputs/issue2289-frontend.p4 @@ -32,7 +32,18 @@ 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.byaA") bit<16> byaA_0; + @name("ingress.retval_0") bit<16> retval_0; + @name("ingress.tmp") bit<16> tmp_0; + @name("ingress.retval") bit<16> retval_3; + @name("ingress.inlinedRetval") bit<16> inlinedRetval_4; + @name("ingress.inlinedRetval_1") bit<16> inlinedRetval_5; @name("ingress.simple_action") action simple_action() { + retval_3 = 16w1; + inlinedRetval_4 = retval_3; + tmp_0 = inlinedRetval_4; + retval_0 = tmp_0; + inlinedRetval_5 = retval_0; + byaA_0 = inlinedRetval_5; h.eth_hdr.eth_type = byaA_0; } apply { diff --git a/testdata/p4_16_samples_outputs/issue2289-midend.p4 b/testdata/p4_16_samples_outputs/issue2289-midend.p4 index da13719cf29..fd291ece4a7 100644 --- a/testdata/p4_16_samples_outputs/issue2289-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue2289-midend.p4 @@ -31,9 +31,8 @@ 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.byaA") bit<16> byaA_0; @name("ingress.simple_action") action simple_action() { - h.eth_hdr.eth_type = byaA_0; + h.eth_hdr.eth_type = 16w1; } @hidden table tbl_simple_action { actions = { diff --git a/testdata/p4_16_samples_outputs/issue2289.p4 b/testdata/p4_16_samples_outputs/issue2289.p4 index c2d32f9bfc4..12d1cd4bb88 100644 --- a/testdata/p4_16_samples_outputs/issue2289.p4 +++ b/testdata/p4_16_samples_outputs/issue2289.p4 @@ -43,7 +43,7 @@ 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) { action simple_action(out bit<16> byaA) { - h.eth_hdr.eth_type = function_2(function_1()); + byaA = function_2(function_1()); } apply { function_1(); diff --git a/testdata/p4_16_samples_outputs/issue2289.p4-stderr b/testdata/p4_16_samples_outputs/issue2289.p4-stderr index 278298d1076..e69de29bb2d 100644 --- a/testdata/p4_16_samples_outputs/issue2289.p4-stderr +++ b/testdata/p4_16_samples_outputs/issue2289.p4-stderr @@ -1,12 +0,0 @@ -issue2289.p4(44): [--Wwarn=unused] warning: 'byaA' is unused - action simple_action(out bit<16> byaA) { - ^^^^ -issue2289.p4(44): [--Wwarn=uninitialized_out_param] warning: out parameter 'byaA' may be uninitialized when 'simple_action' terminates - action simple_action(out bit<16> byaA) { - ^^^^ -issue2289.p4(44) - action simple_action(out bit<16> byaA) { - ^^^^^^^^^^^^^ -issue2289.p4(44): [--Wwarn=uninitialized_use] warning: byaA may be uninitialized - action simple_action(out bit<16> byaA) { - ^^^^ diff --git a/testdata/p4_16_samples_outputs/issue2375-1-bmv2-first.p4 b/testdata/p4_16_samples_outputs/issue2375-1-bmv2-first.p4 index 27a4d23b57f..97b043f79b8 100644 --- a/testdata/p4_16_samples_outputs/issue2375-1-bmv2-first.p4 +++ b/testdata/p4_16_samples_outputs/issue2375-1-bmv2-first.p4 @@ -31,7 +31,7 @@ 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 tmp = false; action do_action(inout bool val) { - do_function(tmp); + do_function(val); } apply { do_action(tmp); diff --git a/testdata/p4_16_samples_outputs/issue2375-1-bmv2.p4 b/testdata/p4_16_samples_outputs/issue2375-1-bmv2.p4 index e2214595318..8abc075c177 100644 --- a/testdata/p4_16_samples_outputs/issue2375-1-bmv2.p4 +++ b/testdata/p4_16_samples_outputs/issue2375-1-bmv2.p4 @@ -31,7 +31,7 @@ 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 tmp = false; action do_action(inout bool val) { - do_function(tmp); + do_function(val); } apply { do_action(tmp); diff --git a/testdata/p4_16_samples_outputs/issue2375-1-bmv2.p4-stderr b/testdata/p4_16_samples_outputs/issue2375-1-bmv2.p4-stderr index 3914fee1385..e69de29bb2d 100644 --- a/testdata/p4_16_samples_outputs/issue2375-1-bmv2.p4-stderr +++ b/testdata/p4_16_samples_outputs/issue2375-1-bmv2.p4-stderr @@ -1,3 +0,0 @@ -issue2375-1-bmv2.p4(34): [--Wwarn=unused] warning: 'val' is unused - action do_action(inout bool val) { - ^^^ diff --git a/testdata/p4_16_samples_outputs/issue2498-bmv2-first.p4 b/testdata/p4_16_samples_outputs/issue2498-bmv2-first.p4 index 77fa4388b8a..bb582a046ab 100644 --- a/testdata/p4_16_samples_outputs/issue2498-bmv2-first.p4 +++ b/testdata/p4_16_samples_outputs/issue2498-bmv2-first.p4 @@ -33,10 +33,10 @@ 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) { action slice_action(inout bit<1> sliced_val) { - h.h.a = 8w2; sliced_val = 1w1; } apply { + h.h.a = 8w2; slice_action(h.h.a[0:0]); } } diff --git a/testdata/p4_16_samples_outputs/issue2498-bmv2-frontend.p4 b/testdata/p4_16_samples_outputs/issue2498-bmv2-frontend.p4 index 39e2b3e1a07..58633d7e876 100644 --- a/testdata/p4_16_samples_outputs/issue2498-bmv2-frontend.p4 +++ b/testdata/p4_16_samples_outputs/issue2498-bmv2-frontend.p4 @@ -32,11 +32,11 @@ control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { @name("ingress.tmp") bit<1> tmp; @name("ingress.sliced_val") bit<1> sliced_val_0; @name("ingress.slice_action") action slice_action() { - h.h.a = 8w2; sliced_val_0 = 1w1; tmp = sliced_val_0; } apply { + h.h.a = 8w2; slice_action(); h.h.a[0:0] = tmp; } diff --git a/testdata/p4_16_samples_outputs/issue2498-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/issue2498-bmv2-midend.p4 index ac477cfab31..07b9e41c045 100644 --- a/testdata/p4_16_samples_outputs/issue2498-bmv2-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue2498-bmv2-midend.p4 @@ -31,12 +31,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.tmp") bit<1> tmp; @name("ingress.slice_action") action slice_action() { - h.h.a = 8w2; tmp = 1w1; } + @hidden action issue2498bmv2l41() { + h.h.a = 8w2; + } @hidden action act() { h.h.a[0:0] = tmp; } + @hidden table tbl_issue2498bmv2l41 { + actions = { + issue2498bmv2l41(); + } + const default_action = issue2498bmv2l41(); + } @hidden table tbl_slice_action { actions = { slice_action(); @@ -50,6 +58,7 @@ control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { const default_action = act(); } apply { + tbl_issue2498bmv2l41.apply(); tbl_slice_action.apply(); tbl_act.apply(); } diff --git a/testdata/p4_16_samples_outputs/issue2498-bmv2.p4 b/testdata/p4_16_samples_outputs/issue2498-bmv2.p4 index f1ebc908ff0..18881efcc86 100644 --- a/testdata/p4_16_samples_outputs/issue2498-bmv2.p4 +++ b/testdata/p4_16_samples_outputs/issue2498-bmv2.p4 @@ -33,10 +33,10 @@ 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) { action slice_action(inout bit<1> sliced_val) { - h.h.a = 2; sliced_val = 1; } apply { + h.h.a = 2; slice_action(h.h.a[0:0]); } } diff --git a/testdata/p4_16_samples_outputs/m_psa-dpdk-non-zero-arg-default-action-08-first.p4 b/testdata/p4_16_samples_outputs/m_psa-dpdk-non-zero-arg-default-action-08-first.p4 index 6a1b3a75d06..0090d2b6dda 100644 --- a/testdata/p4_16_samples_outputs/m_psa-dpdk-non-zero-arg-default-action-08-first.p4 +++ b/testdata/p4_16_samples_outputs/m_psa-dpdk-non-zero-arg-default-action-08-first.p4 @@ -31,7 +31,7 @@ control MyIngressControl(inout headers_t hdr, inout user_meta_data_t m, in psa_i hdr.ethernet.dst_addr = hdr.ethernet.src_addr; hdr.ethernet.src_addr = m.addr; } - action macswp(inout bit<48> tmp1, bit<32> tmp2) { + action macswp(in bit<48> tmp1, bit<32> tmp2) { if (tmp1 == 48w0x1 && tmp2 == 32w0x2) { m.addr = hdr.ethernet.dst_addr; hdr.ethernet.dst_addr = hdr.ethernet.src_addr; diff --git a/testdata/p4_16_samples_outputs/m_psa-dpdk-non-zero-arg-default-action-08-frontend.p4 b/testdata/p4_16_samples_outputs/m_psa-dpdk-non-zero-arg-default-action-08-frontend.p4 index 4d181bbb4ca..80bf4b5b407 100644 --- a/testdata/p4_16_samples_outputs/m_psa-dpdk-non-zero-arg-default-action-08-frontend.p4 +++ b/testdata/p4_16_samples_outputs/m_psa-dpdk-non-zero-arg-default-action-08-frontend.p4 @@ -36,9 +36,9 @@ control MyIngressControl(inout headers_t hdr, inout user_meta_data_t m, in psa_i tmp1_0 = hdr.ethernet.dst_addr; if (tmp1_0 == 48w0x1 && tmp2 == 32w0x2) { m.addr = hdr.ethernet.dst_addr; + hdr.ethernet.dst_addr = hdr.ethernet.src_addr; hdr.ethernet.src_addr = m.addr; } - hdr.ethernet.dst_addr = tmp1_0; } @name("MyIngressControl.stub") table stub_0 { actions = { 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 068be410389..ef9ed33a51d 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 @@ -34,7 +34,8 @@ control MyIngressControl(inout headers_t hdr, inout user_meta_data_t m, in psa_i @name("MyIngressControl.macswp") action macswp(@name("tmp2") bit<32> tmp2) { if (hdr.ethernet.dst_addr == 48w0x1 && tmp2 == 32w0x2) { m.addr = hdr.ethernet.dst_addr; - hdr.ethernet.src_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 { diff --git a/testdata/p4_16_samples_outputs/m_psa-dpdk-non-zero-arg-default-action-08.p4 b/testdata/p4_16_samples_outputs/m_psa-dpdk-non-zero-arg-default-action-08.p4 index 0969c1e0eeb..12d7ea8462e 100644 --- a/testdata/p4_16_samples_outputs/m_psa-dpdk-non-zero-arg-default-action-08.p4 +++ b/testdata/p4_16_samples_outputs/m_psa-dpdk-non-zero-arg-default-action-08.p4 @@ -31,7 +31,7 @@ control MyIngressControl(inout headers_t hdr, inout user_meta_data_t m, in psa_i hdr.ethernet.dst_addr = hdr.ethernet.src_addr; hdr.ethernet.src_addr = m.addr; } - action macswp(inout bit<48> tmp1, bit<32> tmp2) { + action macswp(in bit<48> tmp1, bit<32> tmp2) { if (tmp1 == 0x1 && tmp2 == 0x2) { m.addr = hdr.ethernet.dst_addr; hdr.ethernet.dst_addr = hdr.ethernet.src_addr; diff --git a/testdata/p4_16_samples_outputs/nested_if_else-first.p4 b/testdata/p4_16_samples_outputs/nested_if_else-first.p4 index 3371c929d06..1b89e287ebe 100644 --- a/testdata/p4_16_samples_outputs/nested_if_else-first.p4 +++ b/testdata/p4_16_samples_outputs/nested_if_else-first.p4 @@ -67,7 +67,7 @@ control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadat value = 16w0; bit<16> x = hdr.ipv4.identification; bit<16> y = hdr.ipv4.hdrChecksum; - bit<16> z = hdr.ipv4.totalLen; + bit<16> z = hdr.ipv4.srcAddr[15:0]; c = hdr.ipv4.identification > 16w0; c1 = hdr.ipv4.identification > 16w1; c2 = hdr.ipv4.identification > 16w2; diff --git a/testdata/p4_16_samples_outputs/nested_if_else-frontend.p4 b/testdata/p4_16_samples_outputs/nested_if_else-frontend.p4 index 60d82e2f937..67ec93fb92d 100644 --- a/testdata/p4_16_samples_outputs/nested_if_else-frontend.p4 +++ b/testdata/p4_16_samples_outputs/nested_if_else-frontend.p4 @@ -67,7 +67,7 @@ control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadat @name("MyIngress.ipv4_forward") action ipv4_forward() { x_0 = hdr.ipv4.identification; y_0 = hdr.ipv4.hdrChecksum; - z_0 = hdr.ipv4.totalLen; + z_0 = hdr.ipv4.srcAddr[15:0]; c_0 = hdr.ipv4.identification > 16w0; c1_0 = hdr.ipv4.identification > 16w1; c2_0 = hdr.ipv4.identification > 16w2; 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 c494e57ec84..80adb966607 100644 --- a/testdata/p4_16_samples_outputs/nested_if_else-midend.p4 +++ b/testdata/p4_16_samples_outputs/nested_if_else-midend.p4 @@ -71,7 +71,7 @@ control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadat } else { x_0 = hdr.ipv4.identification + 16w6; } - hdr.ipv4.totalLen = hdr.ipv4.totalLen + x_0 + hdr.ipv4.hdrChecksum; + hdr.ipv4.totalLen = hdr.ipv4.srcAddr[15:0] + x_0 + hdr.ipv4.hdrChecksum; } @name("MyIngress.drop") action drop() { } diff --git a/testdata/p4_16_samples_outputs/nested_if_else.p4 b/testdata/p4_16_samples_outputs/nested_if_else.p4 index 54eb8e95452..c950e7c9575 100644 --- a/testdata/p4_16_samples_outputs/nested_if_else.p4 +++ b/testdata/p4_16_samples_outputs/nested_if_else.p4 @@ -67,7 +67,7 @@ control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadat value = 0; bit<16> x = hdr.ipv4.identification; bit<16> y = hdr.ipv4.hdrChecksum; - bit<16> z = hdr.ipv4.totalLen; + bit<16> z = hdr.ipv4.srcAddr[15:0]; c = hdr.ipv4.identification > 16w0; c1 = hdr.ipv4.identification > 16w1; c2 = hdr.ipv4.identification > 16w2; diff --git a/testdata/p4_16_samples_outputs/nested_if_lvalue_dependencies-first.p4 b/testdata/p4_16_samples_outputs/nested_if_lvalue_dependencies-first.p4 index ac28bf7be5d..d13ea1b6a78 100644 --- a/testdata/p4_16_samples_outputs/nested_if_lvalue_dependencies-first.p4 +++ b/testdata/p4_16_samples_outputs/nested_if_lvalue_dependencies-first.p4 @@ -64,7 +64,7 @@ control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadat value = 16w0; bit<16> x = hdr.ipv4.identification; bit<16> y = hdr.ipv4.hdrChecksum; - bit<16> z = hdr.ipv4.totalLen; + bit<16> z = hdr.ipv4.srcAddr[15:0]; c = hdr.ipv4.identification > 16w0; if (c) { x = 16w1; diff --git a/testdata/p4_16_samples_outputs/nested_if_lvalue_dependencies-frontend.p4 b/testdata/p4_16_samples_outputs/nested_if_lvalue_dependencies-frontend.p4 index 14d8990daa7..8efe8381a9f 100644 --- a/testdata/p4_16_samples_outputs/nested_if_lvalue_dependencies-frontend.p4 +++ b/testdata/p4_16_samples_outputs/nested_if_lvalue_dependencies-frontend.p4 @@ -65,7 +65,7 @@ control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadat @name("MyIngress.ipv4_forward") action ipv4_forward() { x_0 = hdr.ipv4.identification; y_0 = hdr.ipv4.hdrChecksum; - z_0 = hdr.ipv4.totalLen; + z_0 = hdr.ipv4.srcAddr[15:0]; c_0 = hdr.ipv4.identification > 16w0; if (c_0) { x_0 = 16w1; 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 4ab1c567682..9c8a978a4e7 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 @@ -61,7 +61,7 @@ control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadat @name("MyIngress.ipv4_forward") action ipv4_forward() { x_0 = hdr.ipv4.identification; y_0 = hdr.ipv4.hdrChecksum; - z_0 = hdr.ipv4.totalLen; + z_0 = hdr.ipv4.srcAddr[15:0]; if (hdr.ipv4.identification > 16w0) { x_0 = 16w1; y_0 = 16w2; diff --git a/testdata/p4_16_samples_outputs/nested_if_lvalue_dependencies.p4 b/testdata/p4_16_samples_outputs/nested_if_lvalue_dependencies.p4 index db893803969..54955441e94 100644 --- a/testdata/p4_16_samples_outputs/nested_if_lvalue_dependencies.p4 +++ b/testdata/p4_16_samples_outputs/nested_if_lvalue_dependencies.p4 @@ -64,7 +64,7 @@ control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadat value = 0; bit<16> x = hdr.ipv4.identification; bit<16> y = hdr.ipv4.hdrChecksum; - bit<16> z = hdr.ipv4.totalLen; + bit<16> z = hdr.ipv4.srcAddr[15:0]; c = hdr.ipv4.identification > 16w0; if (c) { x = 1; diff --git a/testdata/p4_16_samples_outputs/nested_if_statement-first.p4 b/testdata/p4_16_samples_outputs/nested_if_statement-first.p4 index c0c14622d3a..eeda04978c6 100644 --- a/testdata/p4_16_samples_outputs/nested_if_statement-first.p4 +++ b/testdata/p4_16_samples_outputs/nested_if_statement-first.p4 @@ -67,7 +67,7 @@ control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadat value = 16w0; bit<16> x = hdr.ipv4.identification; bit<16> y = hdr.ipv4.hdrChecksum; - bit<16> z = hdr.ipv4.totalLen; + bit<16> z = hdr.ipv4.srcAddr[15:0]; c = hdr.ipv4.identification > 16w0; c1 = hdr.ipv4.identification > 16w1; c2 = hdr.ipv4.identification > 16w2; diff --git a/testdata/p4_16_samples_outputs/nested_if_statement-frontend.p4 b/testdata/p4_16_samples_outputs/nested_if_statement-frontend.p4 index 26beb2e2d84..77051c77526 100644 --- a/testdata/p4_16_samples_outputs/nested_if_statement-frontend.p4 +++ b/testdata/p4_16_samples_outputs/nested_if_statement-frontend.p4 @@ -67,7 +67,7 @@ control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadat } @name("MyIngress.ipv4_forward") action ipv4_forward() { y_0 = hdr.ipv4.hdrChecksum; - z_0 = hdr.ipv4.totalLen; + z_0 = hdr.ipv4.srcAddr[15:0]; c_0 = hdr.ipv4.identification > 16w0; c1_0 = hdr.ipv4.identification > 16w1; c2_0 = hdr.ipv4.identification > 16w2; 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 244da73b082..b7aa33641ae 100644 --- a/testdata/p4_16_samples_outputs/nested_if_statement-midend.p4 +++ b/testdata/p4_16_samples_outputs/nested_if_statement-midend.p4 @@ -68,7 +68,7 @@ control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadat } else { x_0 = 16w4; } - hdr.ipv4.totalLen = hdr.ipv4.totalLen + x_0 + hdr.ipv4.hdrChecksum; + hdr.ipv4.totalLen = hdr.ipv4.srcAddr[15:0] + x_0 + hdr.ipv4.hdrChecksum; } @name("MyIngress.drop") action drop() { } diff --git a/testdata/p4_16_samples_outputs/nested_if_statement.p4 b/testdata/p4_16_samples_outputs/nested_if_statement.p4 index 52f7e5c02bb..57ccc9e66e5 100644 --- a/testdata/p4_16_samples_outputs/nested_if_statement.p4 +++ b/testdata/p4_16_samples_outputs/nested_if_statement.p4 @@ -67,7 +67,7 @@ control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadat value = 0; bit<16> x = hdr.ipv4.identification; bit<16> y = hdr.ipv4.hdrChecksum; - bit<16> z = hdr.ipv4.totalLen; + bit<16> z = hdr.ipv4.srcAddr[15:0]; c = hdr.ipv4.identification > 16w0; c1 = hdr.ipv4.identification > 16w1; c2 = hdr.ipv4.identification > 16w2;