From 2be448f018e88095a13e8a68e1c7cc1641038cd8 Mon Sep 17 00:00:00 2001 From: Mihai Budiu Date: Mon, 6 Dec 2021 16:31:14 -0800 Subject: [PATCH] Rebased version of #1698 (#2902) Added v1model operations of resubmit_preserving_field_list (and also recirculate and clone). --- backends/bmv2/CMakeLists.txt | 13 - backends/bmv2/common/JsonObjects.cpp | 2 +- backends/bmv2/common/annotations.h | 1 + backends/bmv2/common/backend.h | 12 +- backends/bmv2/common/extern.cpp | 27 +- backends/bmv2/common/header.cpp | 12 +- backends/bmv2/common/helpers.cpp | 131 ++++++- backends/bmv2/common/helpers.h | 8 + backends/bmv2/common/programStructure.h | 8 +- backends/bmv2/psa_switch/psaSwitch.cpp | 3 +- backends/bmv2/simple_switch/simpleSwitch.cpp | 353 ++++++++++-------- backends/bmv2/simple_switch/simpleSwitch.h | 8 +- frontends/p4/fromv1.0/converters.cpp | 47 ++- frontends/p4/fromv1.0/converters.h | 14 +- frontends/p4/fromv1.0/programStructure.cpp | 148 ++++++-- frontends/p4/fromv1.0/programStructure.h | 11 + frontends/p4/fromv1.0/v1model.h | 6 +- frontends/p4/parseAnnotations.cpp | 2 + frontends/p4/typeChecking/typeChecker.cpp | 3 + ir/base.def | 8 + ir/type.cpp | 1 + midend/eliminateSerEnums.cpp | 5 +- midend/flattenInterfaceStructs.cpp | 17 +- midend/flattenInterfaceStructs.h | 1 + p4include/v1model.p4 | 87 ++--- .../p4_14_errors_outputs/issue747.p4-stderr | 5 +- testdata/p4_14_samples_outputs/acl1-midend.p4 | 12 + .../copy_to_cpu-first.p4 | 11 +- .../copy_to_cpu-frontend.p4 | 11 +- .../copy_to_cpu-midend.p4 | 11 +- testdata/p4_14_samples_outputs/copy_to_cpu.p4 | 11 +- .../p414-special-ops-2-bmv2-first.p4 | 24 +- .../p414-special-ops-2-bmv2-frontend.p4 | 24 +- .../p414-special-ops-2-bmv2-midend.p4 | 23 +- .../p414-special-ops-2-bmv2.p4 | 24 +- .../p414-special-ops-3-bmv2-first.p4 | 23 +- .../p414-special-ops-3-bmv2-frontend.p4 | 23 +- .../p414-special-ops-3-bmv2-midend.p4 | 22 +- .../p414-special-ops-3-bmv2.p4 | 23 +- .../p414-special-ops-first.p4 | 23 +- .../p414-special-ops-frontend.p4 | 23 +- .../p414-special-ops-midend.p4 | 22 +- .../p4_14_samples_outputs/p414-special-ops.p4 | 23 +- .../packet_redirect-first.p4 | 21 +- .../packet_redirect-frontend.p4 | 21 +- .../packet_redirect-midend.p4 | 20 +- .../p4_14_samples_outputs/packet_redirect.p4 | 21 +- .../p4_14_samples_outputs/resubmit-first.p4 | 7 +- .../resubmit-frontend.p4 | 7 +- .../p4_14_samples_outputs/resubmit-midend.p4 | 9 +- testdata/p4_14_samples_outputs/resubmit.p4 | 7 +- .../p4_14_samples_outputs/simple_nat-first.p4 | 17 +- .../simple_nat-frontend.p4 | 17 +- .../simple_nat-midend.p4 | 27 +- testdata/p4_14_samples_outputs/simple_nat.p4 | 17 +- .../switch_20160512/switch-first.p4 | 200 +++++----- .../switch_20160512/switch-frontend.p4 | 204 +++++----- .../switch_20160512/switch-midend.p4 | 221 ++++++----- .../switch_20160512/switch.p4 | 200 +++++----- .../issue1557-bmv2.p4-stderr | 2 +- .../p4_16_errors_outputs/issue513.p4-stderr | 2 +- testdata/p4_16_samples/issue1001-1-bmv2.p4 | 33 ++ testdata/p4_16_samples/issue1001-bmv2.p4 | 4 +- testdata/p4_16_samples/issue1043-bmv2.p4 | 2 +- testdata/p4_16_samples/issue1642-bmv2.p4 | 27 +- testdata/p4_16_samples/issue1653-bmv2.p4 | 3 +- .../p4_16_samples/issue1653-complex-bmv2.p4 | 3 +- testdata/p4_16_samples/issue1660-bmv2.p4 | 3 +- testdata/p4_16_samples/issue1765-1-bmv2.p4 | 9 +- testdata/p4_16_samples/issue383-bmv2.p4 | 35 +- testdata/p4_16_samples/issue562-bmv2.p4 | 5 +- .../p4_16_samples/v1model-special-ops-bmv2.p4 | 12 +- .../invalid-hdr-warnings3.p4 | 1 + .../issue1001-1-bmv2-first.p4 | 50 +++ .../issue1001-1-bmv2-frontend.p4 | 50 +++ .../issue1001-1-bmv2-midend.p4 | 55 +++ .../p4_16_samples_outputs/issue1001-1-bmv2.p4 | 50 +++ .../issue1001-1-bmv2.p4-stderr | 0 .../issue1001-1-bmv2.p4.entries.txt | 0 .../issue1001-1-bmv2.p4.p4info.txt | 5 + .../issue1001-bmv2-first.p4 | 5 +- .../issue1001-bmv2-frontend.p4 | 5 +- .../issue1001-bmv2-midend.p4 | 5 +- .../p4_16_samples_outputs/issue1001-bmv2.p4 | 5 +- .../issue1001-bmv2.p4-stderr | 3 - .../issue1043-bmv2-first.p4 | 2 +- .../issue1043-bmv2-frontend.p4 | 2 +- .../issue1043-bmv2-midend.p4 | 2 +- .../p4_16_samples_outputs/issue1043-bmv2.p4 | 2 +- .../p4_16_samples_outputs/issue1541.p4-stderr | 2 +- .../issue1642-bmv2-first.p4 | 4 +- .../issue1642-bmv2-frontend.p4 | 4 +- .../issue1642-bmv2-midend.p4 | 17 +- .../p4_16_samples_outputs/issue1642-bmv2.p4 | 4 +- .../issue1653-bmv2-first.p4 | 3 +- .../issue1653-bmv2-frontend.p4 | 3 +- .../issue1653-bmv2-midend.p4 | 3 +- .../p4_16_samples_outputs/issue1653-bmv2.p4 | 3 +- .../issue1653-bmv2.p4-stderr | 2 +- .../issue1653-complex-bmv2-first.p4 | 4 +- .../issue1653-complex-bmv2-frontend.p4 | 4 +- .../issue1653-complex-bmv2-midend.p4 | 35 +- .../issue1653-complex-bmv2.p4 | 4 +- .../issue1653-complex-bmv2.p4-stderr | 6 +- .../issue1660-bmv2-first.p4 | 4 +- .../issue1660-bmv2-frontend.p4 | 6 +- .../issue1660-bmv2-midend.p4 | 16 +- .../p4_16_samples_outputs/issue1660-bmv2.p4 | 4 +- .../issue1765-1-bmv2-first.p4 | 10 +- .../issue1765-1-bmv2-frontend.p4 | 14 +- .../issue1765-1-bmv2-midend.p4 | 24 +- .../p4_16_samples_outputs/issue1765-1-bmv2.p4 | 10 +- .../issue1765-1-bmv2.p4-stderr | 8 +- .../issue2176-bmv2.p4-stderr | 4 +- .../issue383-bmv2-first.p4 | 4 +- .../issue383-bmv2-frontend.p4 | 4 +- .../issue383-bmv2-midend.p4 | 27 +- .../p4_16_samples_outputs/issue383-bmv2.p4 | 4 +- .../issue383-bmv2.p4-stderr | 4 +- .../issue562-bmv2-first.p4 | 4 +- .../issue562-bmv2-frontend.p4 | 4 +- .../issue562-bmv2-midend.p4 | 17 +- .../p4_16_samples_outputs/issue562-bmv2.p4 | 4 +- .../p4_16_samples_outputs/issue841.p4-stderr | 2 +- .../methodArgDontcare.p4 | 2 +- ...ey-consolidation-mixed-keys-4.p4.bfrt.json | 2 +- .../v1model-special-ops-bmv2-first.p4 | 9 +- .../v1model-special-ops-bmv2-frontend.p4 | 9 +- .../v1model-special-ops-bmv2-midend.p4 | 18 +- .../v1model-special-ops-bmv2.p4 | 9 +- 130 files changed, 1871 insertions(+), 1114 deletions(-) create mode 100644 testdata/p4_16_samples/issue1001-1-bmv2.p4 create mode 100644 testdata/p4_16_samples_outputs/issue1001-1-bmv2-first.p4 create mode 100644 testdata/p4_16_samples_outputs/issue1001-1-bmv2-frontend.p4 create mode 100644 testdata/p4_16_samples_outputs/issue1001-1-bmv2-midend.p4 create mode 100644 testdata/p4_16_samples_outputs/issue1001-1-bmv2.p4 create mode 100644 testdata/p4_16_samples_outputs/issue1001-1-bmv2.p4-stderr create mode 100644 testdata/p4_16_samples_outputs/issue1001-1-bmv2.p4.entries.txt create mode 100644 testdata/p4_16_samples_outputs/issue1001-1-bmv2.p4.p4info.txt diff --git a/backends/bmv2/CMakeLists.txt b/backends/bmv2/CMakeLists.txt index 6ce93f7f881..ceb0d590999 100644 --- a/backends/bmv2/CMakeLists.txt +++ b/backends/bmv2/CMakeLists.txt @@ -158,19 +158,6 @@ set (XFAIL_TESTS testdata/p4_14_samples/issue60.p4 # compiler claims (incorrectly?) that c2 has mulitple successors, so is not supported testdata/p4_14_samples/issue-1426.p4 - # As of 2019-Feb-04 latest p4c code, this program fails due to the - # root cause of both issues #1694 and #1669. I have tested it with - # the proposed fix for issue #1694 that is on PR #1704, and while - # that does make the produced BMv2 JSON file able to cause packets - # to be recirculated, resubmitted, etc. it still has the bug of not - # preserving the metadata specified in the program's field_lists, so - # the STF tests fail because of issue #1669. As of this writing, - # these programs rely for - # successful execution on the preservation of metadata across - # resubmit, recirculate, and/or clone operations. - testdata/p4_14_samples/p414-special-ops.p4 - testdata/p4_14_samples/p414-special-ops-2-bmv2.p4 - testdata/p4_14_samples/p414-special-ops-3-bmv2.p4 # This test uses a feature currently unsupported in the BMv2 back-end. testdata/p4_16_samples/issue907-bmv2.p4 # This test uses a table graph that is not implementable in BMv2 diff --git a/backends/bmv2/common/JsonObjects.cpp b/backends/bmv2/common/JsonObjects.cpp index 6f498346a33..5585588e3ef 100644 --- a/backends/bmv2/common/JsonObjects.cpp +++ b/backends/bmv2/common/JsonObjects.cpp @@ -231,7 +231,7 @@ unsigned JsonObjects::add_metadata(const cstring& type, const cstring& name) { auto header = new Util::JsonObject(); unsigned id = BMV2::nextId("headers"); - LOG1("add metadata header id " << id); + LOG3("add metadata header id " << id); header->emplace("name", name); header->emplace("id", id); header->emplace("header_type", type); diff --git a/backends/bmv2/common/annotations.h b/backends/bmv2/common/annotations.h index 8308af6c494..4636921733b 100644 --- a/backends/bmv2/common/annotations.h +++ b/backends/bmv2/common/annotations.h @@ -29,6 +29,7 @@ class ParseAnnotations : public P4::ParseAnnotations { public: ParseAnnotations() : P4::ParseAnnotations("BMV2", false, { PARSE_EMPTY("metadata"), + PARSE_EXPRESSION_LIST("field_list"), PARSE("alias", StringLiteral), PARSE("priority", Constant) }) { } diff --git a/backends/bmv2/common/backend.h b/backends/bmv2/common/backend.h index 6305e9ba038..cb0631e4138 100644 --- a/backends/bmv2/common/backend.h +++ b/backends/bmv2/common/backend.h @@ -122,6 +122,7 @@ class RenameUserMetadata : public Transform { // Used as a prefix for the fields of the userMetadata structure // and also as a name for the userMetadata type clone. cstring namePrefix; + bool renamed = false; public: RenameUserMetadata(P4::ReferenceMap* refMap, @@ -131,11 +132,13 @@ class RenameUserMetadata : public Transform { const IR::Node* postorder(IR::Type_Struct* type) override { // Clone the user metadata type - if (userMetaType != getOriginal()) + auto orig = getOriginal(); + if (userMetaType->name != orig->name) return type; auto vec = new IR::IndexedVector(); - LOG2("Creating clone" << getOriginal()); + LOG2("Creating clone of " << orig); + renamed = true; auto clone = type->clone(); clone->name = namePrefix; vec->push_back(clone); @@ -180,6 +183,11 @@ class RenameUserMetadata : public Transform { LOG2("Replacing reference with " << type); return type; } + + void end_apply(const IR::Node*) override { + BUG_CHECK(renamed, "Could not identify user metadata type declaration %1%", + userMetaType); + } }; } // namespace BMV2 diff --git a/backends/bmv2/common/extern.cpp b/backends/bmv2/common/extern.cpp index 8aeec93d4cb..1e0520a61c6 100644 --- a/backends/bmv2/common/extern.cpp +++ b/backends/bmv2/common/extern.cpp @@ -221,29 +221,10 @@ ExternConverter::createCalculation(ConversionContext* ctxt, if (sourcePositionNode != nullptr) calc->emplace_non_null("source_info", sourcePositionNode->sourceInfoJsonObj()); calc->emplace("algo", algo); - if (!fields->is()) { - // expand it into a list - auto list = new IR::ListExpression({}); - auto type = ctxt->typeMap->getType(fields, true); - if (!type->is()) { - modelError("%1%: expected a struct", fields); - return calcName; - } - if (auto se = fields->to()) { - for (auto f : se->components) { - auto e = f->expression; - list->push_back(e); - } - } else { - for (auto f : type->to()->fields) { - auto e = new IR::Member(fields, f->name); - auto ftype = ctxt->typeMap->getType(f); - ctxt->typeMap->setType(e, ftype); - list->push_back(e); - } - } - fields = list; - ctxt->typeMap->setType(fields, type); + fields = convertToList(fields, ctxt->typeMap); + if (!fields) { + modelError("%1%: expected a struct", fields); + return calcName; } auto jright = ctxt->conv->convertWithConstantWidths(fields); if (withPayload) { diff --git a/backends/bmv2/common/header.cpp b/backends/bmv2/common/header.cpp index 13af9fd83fa..03f23b7a792 100644 --- a/backends/bmv2/common/header.cpp +++ b/backends/bmv2/common/header.cpp @@ -39,7 +39,7 @@ HeaderConverter::HeaderConverter(ConversionContext* ctxt, cstring scalarsName) * @param meta this boolean indicates if the struct is a metadata or header. */ void HeaderConverter::addTypesAndInstances(const IR::Type_StructLike* type, bool meta) { - LOG1("Adding " << type); + LOG2("Adding " << type); for (auto f : type->fields) { auto ft = ctxt->typeMap->getType(f, true); if (ft->is()) { @@ -85,7 +85,7 @@ void HeaderConverter::addTypesAndInstances(const IR::Type_StructLike* type, bool } } else if (ft->is()) { // Done elsewhere - LOG1("stack generation done elsewhere"); + LOG3("stack generation done elsewhere"); continue; } else { // Treat this field like a scalar local variable @@ -141,7 +141,7 @@ Util::JsonArray* HeaderConverter::addHeaderUnionFields( } void HeaderConverter::addHeaderStacks(const IR::Type_Struct* headersStruct) { - LOG1("Creating stack " << headersStruct); + LOG2("Creating stack " << headersStruct); for (auto f : headersStruct->fields) { auto ft = ctxt->typeMap->getType(f, true); auto stack = ft->to(); @@ -290,7 +290,7 @@ void HeaderConverter::addHeaderType(const IR::Type_StructLike *st) { } ctxt->json->add_header_type(name, fields, max_length_bytes); - LOG1("... creating aliases for metadata fields " << st); + LOG2("... creating aliases for metadata fields " << st); for (auto f : st->fields) { if (auto aliasAnnotation = f->getAnnotation("alias")) { auto container = new Util::JsonArray(); @@ -328,7 +328,7 @@ Visitor::profile_t HeaderConverter::init_apply(const IR::Node* node) { // bit, bool, error are packed into scalars type, // varbit, struct and stack introduce new header types for (auto v : ctxt->structure->variables) { - LOG1("variable " << v); + LOG2("variable " << v); auto type = ctxt->typeMap->getType(v, true); if (auto st = type->to()) { auto metadata_type = st->controlPlaneName(); @@ -443,7 +443,7 @@ void HeaderConverter::end_apply(const IR::Node*) { */ bool HeaderConverter::preorder(const IR::Parameter* param) { LOG3("convert param " << param); - //// keep track of which headers we've already generated the ctxt->json for + // keep track of which headers we've already generated in ctxt->json auto ft = ctxt->typeMap->getType(param->getNode(), true); if (ft->is()) { auto st = ft->to(); diff --git a/backends/bmv2/common/helpers.cpp b/backends/bmv2/common/helpers.cpp index d2842d35277..66d7298f004 100644 --- a/backends/bmv2/common/helpers.cpp +++ b/backends/bmv2/common/helpers.cpp @@ -78,6 +78,135 @@ unsigned nextId(cstring group) { return counters[group]++; } -} // namespace BMV2 +void +ConversionContext::addToFieldList(const IR::Expression* expr, Util::JsonArray* fl) { + if (auto le = expr->to()) { + for (auto e : le->components) { + addToFieldList(e, fl); + } + return; + } else if (auto si = expr->to()) { + for (auto e : si->components) { + addToFieldList(e->expression, fl); + } + return; + } + + auto type = typeMap->getType(expr, true); + if (type->is()) { + // recursively add all fields + auto st = type->to(); + for (auto f : st->fields) { + auto member = new IR::Member(expr, f->name); + typeMap->setType(member, typeMap->getType(f, true)); + addToFieldList(member, fl); + } + return; + } + + bool simple = conv->simpleExpressionsOnly; + conv->simpleExpressionsOnly = true; // we do not want casts d2b in field_lists + auto j = conv->convert(expr); + conv->simpleExpressionsOnly = simple; // restore state + if (auto jo = j->to()) { + if (auto t = jo->get("type")) { + if (auto type = t->to()) { + if (*type == "runtime_data") { + // Can't have runtime_data in field lists -- need hexstr instead + auto val = jo->get("value")->to(); + j = jo = new Util::JsonObject(); + jo->emplace("type", "hexstr"); + jo->emplace("value", stringRepr(val->getValue())); + } + } + } + } + fl->append(j); +} + +int +ConversionContext::createFieldList( + const IR::Expression* expr, cstring listName, bool learn) { + cstring group; + auto fl = new Util::JsonObject(); + if (learn) { + group = "learn_lists"; + json->learn_lists->append(fl); + } else { + group = "field_lists"; + json->field_lists->append(fl); + } + int id = nextId(group); + fl->emplace("id", id); + fl->emplace("name", listName); + fl->emplace_non_null("source_info", expr->sourceInfoJsonObj()); + auto elements = mkArrayField(fl, "elements"); + addToFieldList(expr, elements); + return id; +} +void +ConversionContext::modelError(const char* format, const IR::Node* node) { + ::error(format, node); + ::error("Are you using an up-to-date v1model.p4?"); +} + +cstring +ConversionContext::createCalculation(cstring algo, const IR::Expression* fields, + Util::JsonArray* calculations, bool withPayload, + const IR::Node* sourcePositionNode = nullptr) { + cstring calcName = refMap->newName("calc_"); + auto calc = new Util::JsonObject(); + calc->emplace("name", calcName); + calc->emplace("id", nextId("calculations")); + if (sourcePositionNode != nullptr) + calc->emplace_non_null("source_info", sourcePositionNode->sourceInfoJsonObj()); + calc->emplace("algo", algo); + fields = convertToList(fields, typeMap); + if (!fields) { + modelError("%1%: expected a struct", fields); + return calcName; + } + auto jright = conv->convertWithConstantWidths(fields); + if (withPayload) { + auto array = jright->to(); + BUG_CHECK(array, "expected a JSON array"); + auto payload = new Util::JsonObject(); + payload->emplace("type", "payload"); + payload->emplace("value", (Util::IJson*)nullptr); + array->append(payload); + } + calc->emplace("input", jright); + calculations->append(calc); + return calcName; +} +/// Converts expr into a ListExpression or returns nullptr if not +/// possible +const IR::ListExpression* convertToList(const IR::Expression* expr, P4::TypeMap* typeMap) { + if (auto l = expr->to()) + return l; + + // expand it into a list + auto list = new IR::ListExpression({}); + auto type = typeMap->getType(expr, true); + auto st = type->to(); + if (!st) { + return nullptr; + } + if (auto se = expr->to()) { + for (auto f : se->components) + list->push_back(f->expression); + } else { + for (auto f : st->fields) { + auto e = new IR::Member(expr, f->name); + auto ftype = typeMap->getType(f); + typeMap->setType(e, ftype); + list->push_back(e); + } + } + typeMap->setType(list, type); + return list; +} + +} // namespace BMV2 diff --git a/backends/bmv2/common/helpers.h b/backends/bmv2/common/helpers.h index ebcaaa05d8d..0d0107d50f9 100644 --- a/backends/bmv2/common/helpers.h +++ b/backends/bmv2/common/helpers.h @@ -324,6 +324,12 @@ struct ConversionContext { ExpressionConverter* conv, JsonObjects* json) : refMap(refMap), typeMap(typeMap), toplevel(toplevel), blockConverted(BlockConverted::None), structure(structure), conv(conv), json(json) { } + + void addToFieldList(const IR::Expression* expr, Util::JsonArray* fl); + int createFieldList(const IR::Expression* expr, cstring listName, bool learn = false); + cstring createCalculation(cstring algo, const IR::Expression* fields, + Util::JsonArray* calculations, bool usePayload, const IR::Node* node); + static void modelError(const char* format, const IR::Node* place); }; Util::IJson* nodeName(const CFG::Node* node); @@ -333,6 +339,8 @@ Util::JsonObject* mkPrimitive(cstring name, Util::JsonArray* appendTo); Util::JsonObject* mkPrimitive(cstring name); cstring stringRepr(big_int value, unsigned bytes = 0); unsigned nextId(cstring group); +/// Converts expr into a ListExpression or returns nullptr if not possible +const IR::ListExpression* convertToList(const IR::Expression* expr, P4::TypeMap* typeMap); } // namespace BMV2 diff --git a/backends/bmv2/common/programStructure.h b/backends/bmv2/common/programStructure.h index c0821ba7240..e38efe8616e 100644 --- a/backends/bmv2/common/programStructure.h +++ b/backends/bmv2/common/programStructure.h @@ -54,13 +54,13 @@ class ProgramStructure { // in the scalarsName metadata object, so we may need to rename // these fields. This map holds the new names. std::map scalarMetadataFields; - // All the direct meters. + /// All the direct meters. DirectMeterMap directMeterMap; - // All the direct counters. + /// All the direct counters. ordered_map directCounterMap; - // All match kinds + /// All match kinds std::set match_kinds; - // map IR node to compile-time allocated resource blocks. + /// map IR node to compile-time allocated resource blocks. ResourceMap resourceMap; ProgramStructure() {} diff --git a/backends/bmv2/psa_switch/psaSwitch.cpp b/backends/bmv2/psa_switch/psaSwitch.cpp index a50d4b54ff4..0b8289bea85 100644 --- a/backends/bmv2/psa_switch/psaSwitch.cpp +++ b/backends/bmv2/psa_switch/psaSwitch.cpp @@ -939,8 +939,7 @@ Util::IJson* ExternConverter_Digest::convertExternObject( listName = st->controlPlaneName(); } } - int id = createFieldList(ctxt, mc->arguments->at(0)->expression, "learn_lists", - listName, ctxt->json->learn_lists); + int id = ctxt->createFieldList(mc->arguments->at(0)->expression, listName, true); auto cst = new IR::Constant(id); ctxt->typeMap->setType(cst, IR::Type_Bits::get(32)); auto jcst = ctxt->conv->convert(cst); diff --git a/backends/bmv2/simple_switch/simpleSwitch.cpp b/backends/bmv2/simple_switch/simpleSwitch.cpp index bd475180f5e..f939cdd0e47 100644 --- a/backends/bmv2/simple_switch/simpleSwitch.cpp +++ b/backends/bmv2/simple_switch/simpleSwitch.cpp @@ -94,11 +94,14 @@ bool ParseV1Architecture::preorder(const IR::PackageBlock* main) { } ExternConverter_clone ExternConverter_clone::singleton; -ExternConverter_clone3 ExternConverter_clone3::singleton; +ExternConverter_clone_preserving_field_list + ExternConverter_clone_preserving_field_list::singleton; ExternConverter_hash ExternConverter_hash::singleton; ExternConverter_digest ExternConverter_digest::singleton; -ExternConverter_resubmit ExternConverter_resubmit::singleton; -ExternConverter_recirculate ExternConverter_recirculate::singleton; +ExternConverter_resubmit_preserving_field_list + ExternConverter_resubmit_preserving_field_list::singleton; +ExternConverter_recirculate_preserving_field_list + ExternConverter_recirculate_preserving_field_list::singleton; ExternConverter_mark_to_drop ExternConverter_mark_to_drop::singleton; ExternConverter_random ExternConverter_random::singleton; ExternConverter_truncate ExternConverter_truncate::singleton; @@ -112,8 +115,8 @@ ExternConverter_action_selector ExternConverter_action_selector::singleton; ExternConverter_log_msg ExternConverter_log_msg::singleton; Util::IJson* ExternConverter_clone::convertExternFunction( - UNUSED ConversionContext* ctxt, UNUSED const P4::ExternFunction* ef, - UNUSED const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl* s, + ConversionContext* ctxt, UNUSED const P4::ExternFunction* ef, + const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl* s, UNUSED const bool emitExterns) { int id = -1; if (mc->arguments->size() != 2) { @@ -122,7 +125,7 @@ Util::IJson* ExternConverter_clone::convertExternFunction( } cstring name = ctxt->refMap->newName("fl"); auto emptylist = new IR::ListExpression({}); - id = createFieldList(ctxt, emptylist, "field_lists", name, ctxt->json->field_lists); + id = ctxt->createFieldList(emptylist, name); auto cloneType = mc->arguments->at(0); auto ei = P4::EnumInstance::resolve(cloneType->expression, ctxt->typeMap); @@ -160,19 +163,40 @@ Util::IJson* ExternConverter_clone::convertExternFunction( return primitive; } -Util::IJson* ExternConverter_clone3::convertExternFunction( +// Returns the id of the Json field list called "field_list". +static unsigned getFieldListById(ConversionContext* ctxt, unsigned index) { + cstring search = cstring("field_list") + Util::toString(index); + int id = -1; + for (auto it : *ctxt->json->field_lists) { + auto j = it->to(); + CHECK_NULL(j); + auto name = j->get("name")->to()->getString(); + if (name == search) { + id = j->get("id")->to()->getInt(); + break; + } + } + if (id == -1) { + ::warning(ErrorType::WARN_INVALID, + "no user metadata fields tagged with @field_list(%1%)", + index); + // Create an empty list. + cstring name = ctxt->refMap->newName("empty"); + id = ctxt->createFieldList(new IR::ListExpression({}), name); + } + return (unsigned)id; +} + +Util::IJson* ExternConverter_clone_preserving_field_list::convertExternFunction( ConversionContext* ctxt, UNUSED const P4::ExternFunction* ef, - UNUSED const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl* s, + const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl* s, UNUSED const bool emitExterns) { - (void) v1model.clone.clone3.name; int id = -1; if (mc->arguments->size() != 3) { modelError("Expected 3 arguments for %1%", mc); return nullptr; } - cstring name = ctxt->refMap->newName("fl"); - id = createFieldList(ctxt, mc->arguments->at(2)->expression, "field_lists", name, - ctxt->json->field_lists); + auto cloneType = mc->arguments->at(0); auto ei = P4::EnumInstance::resolve(cloneType->expression, ctxt->typeMap); if (ei == nullptr) { @@ -183,13 +207,13 @@ Util::IJson* ExternConverter_clone3::convertExternFunction( if (ei->name == "I2E") { prim = "clone_ingress_pkt_to_egress"; if (ctxt->blockConverted != BlockConverted::Ingress) { - ::error("'clone3(I2E, ...) not invoked in ingress %1%", mc); + ::error("'clone_preserving_field_list(I2E, ...) not invoked in ingress %1%", mc); return nullptr; } } else { prim = "clone_egress_pkt_to_egress"; if (ctxt->blockConverted != BlockConverted::Egress) { - ::error("'clone3(E2E, ...) not invoked in egress %1%", mc); + ::error("'clone_preserving_field_list(E2E, ...) not invoked in egress %1%", mc); return nullptr; } } @@ -199,24 +223,24 @@ Util::IJson* ExternConverter_clone3::convertExternFunction( primitive->emplace_non_null("source_info", mc->sourceInfoJsonObj()); parameters->append(session); - if (id >= 0) { - auto cst = new IR::Constant(id); - ctxt->typeMap->setType(cst, IR::Type_Bits::get(32)); - auto jcst = ctxt->conv->convert(cst); - parameters->append(jcst); - - // clone with a non-empty field list is not correctly implemented; give a warning - auto arr = ctxt->json->get_field_list_contents(id); - if (arr != nullptr && !arr->empty()) - ::warning(ErrorType::WARN_UNSUPPORTED, - "%1%: clone with non-empty argument not supported", mc); + auto fl = mc->arguments->at(2); + auto cst = fl->expression->to(); + if (cst == nullptr) { + modelError("%1%: Expected a constant", fl); + return nullptr; } + + id = getFieldListById(ctxt, cst->asUnsigned()); + cst = new IR::Constant(id); + ctxt->typeMap->setType(cst, IR::Type_Bits::get(32)); + auto jcst = ctxt->conv->convert(cst); + parameters->append(jcst); return primitive; } Util::IJson* ExternConverter_hash::convertExternFunction( - UNUSED ConversionContext* ctxt, UNUSED const P4::ExternFunction* ef, - UNUSED const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl* s, + ConversionContext* ctxt, UNUSED const P4::ExternFunction* ef, + const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl* s, UNUSED const bool emitExterns) { static std::set supportedHashAlgorithms = { v1model.algorithm.crc32.name, v1model.algorithm.crc32_custom.name, @@ -244,7 +268,7 @@ Util::IJson* ExternConverter_hash::convertExternFunction( return nullptr; } auto fields = mc->arguments->at(3); - auto calcName = createCalculation(ctxt, ei->name, fields->expression, ctxt->json->calculations, + auto calcName = ctxt->createCalculation(ei->name, fields->expression, ctxt->json->calculations, false, nullptr); calculation->emplace("type", "calculation"); calculation->emplace("value", calcName); @@ -255,8 +279,8 @@ Util::IJson* ExternConverter_hash::convertExternFunction( } Util::IJson* ExternConverter_digest::convertExternFunction( - UNUSED ConversionContext* ctxt, UNUSED const P4::ExternFunction* ef, - UNUSED const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl* s, + ConversionContext* ctxt, UNUSED const P4::ExternFunction* ef, + const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl* s, UNUSED const bool emitExterns) { if (mc->arguments->size() != 2) { modelError("Expected 2 arguments for %1%", mc); @@ -283,8 +307,7 @@ Util::IJson* ExternConverter_digest::convertExternFunction( listName = st->controlPlaneName(); } } - int id = createFieldList(ctxt, mc->arguments->at(1)->expression, "learn_lists", - listName, ctxt->json->learn_lists); + int id = ctxt->createFieldList(mc->arguments->at(1)->expression, listName, true); auto cst = new IR::Constant(id); ctxt->typeMap->setType(cst, IR::Type_Bits::get(32)); auto jcst = ctxt->conv->convert(cst); @@ -292,100 +315,70 @@ Util::IJson* ExternConverter_digest::convertExternFunction( return primitive; } -Util::IJson* ExternConverter_resubmit::convertExternFunction( +Util::IJson* ExternConverter_resubmit_preserving_field_list::convertExternFunction( ConversionContext* ctxt, UNUSED const P4::ExternFunction* ef, - UNUSED const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl* s, + const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl* s, UNUSED const bool emitExterns) { if (ctxt->blockConverted != BlockConverted::Ingress) { ::error("'resubmit' can only be invoked in ingress %1%", mc); return nullptr; } - if (mc->arguments->size() != 1) { - modelError("Expected 1 argument for %1%", mc); - return nullptr; - } - auto primitive = mkPrimitive("resubmit"); - auto parameters = mkParameters(primitive); - primitive->emplace_non_null("source_info", mc->sourceInfoJsonObj()); - cstring listName = "resubmit"; - // If we are supplied a type argument that is a named type use - // that for the list name. - if (mc->typeArguments->size() == 1) { - auto typeArg = mc->typeArguments->at(0); - if (typeArg->is()) { - auto origType = ctxt->refMap->getDeclaration( - typeArg->to()->path, true); - if (!origType->is()) { - modelError("%1%: expected a struct type", origType->getNode()); - return nullptr; - } - auto st = origType->to(); - listName = st->controlPlaneName(); + if (mc->arguments->size() == 1) { + auto primitive = mkPrimitive("resubmit"); + auto parameters = mkParameters(primitive); + primitive->emplace_non_null("source_info", mc->sourceInfoJsonObj()); + auto arg = mc->arguments->at(0); + auto cst = arg->expression->to(); + if (cst == nullptr) { + modelError("%1%: expected a constant", arg); + return nullptr; } + unsigned index = cst->asUnsigned(); + int id = getFieldListById(ctxt, index); + cst = new IR::Constant(id); + ctxt->typeMap->setType(cst, IR::Type_Bits::get(32)); + auto jcst = ctxt->conv->convert(cst); + parameters->append(jcst); + return primitive; } - int id = createFieldList(ctxt, mc->arguments->at(0)->expression, "field_lists", - listName, ctxt->json->field_lists); - // resubmit with a non-empty field list is not correctly implemented; give a warning - auto arr = ctxt->json->get_field_list_contents(id); - if (arr != nullptr && !arr->empty()) - ::warning(ErrorType::WARN_UNSUPPORTED, - "%1%: resubmit with non-empty argument not supported", mc); - auto cst = new IR::Constant(id); - ctxt->typeMap->setType(cst, IR::Type_Bits::get(32)); - auto jcst = ctxt->conv->convert(cst); - parameters->append(jcst); - return primitive; + modelError("Expected 0 or 1 arguments for %1%", mc); + return nullptr; } -Util::IJson* ExternConverter_recirculate::convertExternFunction( +Util::IJson* ExternConverter_recirculate_preserving_field_list::convertExternFunction( ConversionContext* ctxt, UNUSED const P4::ExternFunction* ef, - UNUSED const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl* s, + const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl* s, UNUSED const bool emitExterns) { if (ctxt->blockConverted != BlockConverted::Egress) { ::error("'resubmit' can only be invoked in egress %1%", mc); return nullptr; } - if (mc->arguments->size() != 1) { + if (mc->arguments->size() == 1) { + auto primitive = mkPrimitive("recirculate"); + auto parameters = mkParameters(primitive); + primitive->emplace_non_null("source_info", mc->sourceInfoJsonObj()); + auto arg = mc->arguments->at(0); + auto cst = arg->expression->to(); + if (cst == nullptr) { + modelError("%1%: must be a constant", arg); + return nullptr; + } + unsigned index = cst->asUnsigned(); + int id = getFieldListById(ctxt, index); + cst = new IR::Constant(id); + ctxt->typeMap->setType(cst, IR::Type_Bits::get(32)); + auto jcst = ctxt->conv->convert(cst); + parameters->append(jcst); + return primitive; + } else { modelError("Expected 1 argument for %1%", mc); return nullptr; } - auto primitive = mkPrimitive("recirculate"); - auto parameters = mkParameters(primitive); - primitive->emplace_non_null("source_info", mc->sourceInfoJsonObj()); - cstring listName = "recirculate"; - // If we are supplied a type argument that is a named type use - // that for the list name. - if (mc->typeArguments->size() == 1) { - auto typeArg = mc->typeArguments->at(0); - if (typeArg->is()) { - auto origType = ctxt->refMap->getDeclaration( - typeArg->to()->path, true); - if (!origType->is()) { - modelError("%1%: expected a struct type", origType->getNode()); - return nullptr; - } - auto st = origType->to(); - listName = st->controlPlaneName(); - } - } - int id = createFieldList(ctxt, mc->arguments->at(0)->expression, "field_lists", - listName, ctxt->json->field_lists); - // recirculate with a non-empty field list is not correctly implemented; give a warning - auto arr = ctxt->json->get_field_list_contents(id); - if (arr != nullptr && !arr->empty()) - ::warning(ErrorType::WARN_UNSUPPORTED, - "%1%: recirculate with non-empty argument not supported", mc); - - auto cst = new IR::Constant(id); - ctxt->typeMap->setType(cst, IR::Type_Bits::get(32)); - auto jcst = ctxt->conv->convert(cst); - parameters->append(jcst); - return primitive; } Util::IJson* ExternConverter_mark_to_drop::convertExternFunction( - UNUSED ConversionContext* ctxt, UNUSED const P4::ExternFunction* ef, - UNUSED const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl* s, + ConversionContext* ctxt, UNUSED const P4::ExternFunction* ef, + const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl* s, UNUSED const bool emitExterns) { if (mc->arguments->size() != 1) { modelError("Expected 1 argument for %1%", mc); @@ -400,8 +393,8 @@ Util::IJson* ExternConverter_mark_to_drop::convertExternFunction( } Util::IJson* ExternConverter_random::convertExternFunction( - UNUSED ConversionContext* ctxt, UNUSED const P4::ExternFunction* ef, - UNUSED const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl* s, + ConversionContext* ctxt, UNUSED const P4::ExternFunction* ef, + const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl* s, UNUSED const bool emitExterns) { if (mc->arguments->size() != 3) { modelError("Expected 3 arguments for %1%", mc); @@ -422,7 +415,7 @@ Util::IJson* ExternConverter_random::convertExternFunction( Util::IJson* ExternConverter_truncate::convertExternFunction( UNUSED ConversionContext* ctxt, UNUSED const P4::ExternFunction* ef, - UNUSED const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl* s, + const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl* s, UNUSED const bool emitExterns) { if (mc->arguments->size() != 1) { modelError("Expected 1 arguments for %1%", mc); @@ -437,8 +430,8 @@ Util::IJson* ExternConverter_truncate::convertExternFunction( } Util::IJson* ExternConverter_counter::convertExternObject( - UNUSED ConversionContext* ctxt, UNUSED const P4::ExternMethod* em, - UNUSED const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl *s, + ConversionContext* ctxt, const P4::ExternMethod* em, + const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl *s, UNUSED const bool& emitExterns) { if (mc->arguments->size() != 1) { modelError("Expected 1 argument for %1%", mc); @@ -457,8 +450,8 @@ Util::IJson* ExternConverter_counter::convertExternObject( } void ExternConverter_counter::convertExternInstance( - UNUSED ConversionContext* ctxt, UNUSED const IR::Declaration* c, - UNUSED const IR::ExternBlock* eb, UNUSED const bool& emitExterns) { + ConversionContext* ctxt, const IR::Declaration* c, + const IR::ExternBlock* eb, UNUSED const bool& emitExterns) { auto inst = c->to(); cstring name = inst->controlPlaneName(); auto jctr = new Util::JsonObject(); @@ -477,8 +470,8 @@ void ExternConverter_counter::convertExternInstance( } Util::IJson* ExternConverter_meter::convertExternObject( - UNUSED ConversionContext* ctxt, UNUSED const P4::ExternMethod* em, - UNUSED const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl *s, + ConversionContext* ctxt, const P4::ExternMethod* em, + const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl *s, UNUSED const bool& emitExterns) { if (mc->arguments->size() != 2) { modelError("Expected 2 arguments for %1%", mc); @@ -499,8 +492,8 @@ Util::IJson* ExternConverter_meter::convertExternObject( } void ExternConverter_meter::convertExternInstance( - UNUSED ConversionContext* ctxt, UNUSED const IR::Declaration* c, - UNUSED const IR::ExternBlock* eb, UNUSED const bool& emitExterns) { + ConversionContext* ctxt, const IR::Declaration* c, + const IR::ExternBlock* eb, UNUSED const bool& emitExterns) { auto inst = c->to(); cstring name = inst->controlPlaneName(); auto jmtr = new Util::JsonObject(); @@ -536,8 +529,8 @@ void ExternConverter_meter::convertExternInstance( } Util::IJson* ExternConverter_register::convertExternObject( - UNUSED ConversionContext* ctxt, UNUSED const P4::ExternMethod* em, - UNUSED const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl *s, + ConversionContext* ctxt, const P4::ExternMethod* em, + const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl *s, UNUSED const bool& emitExterns) { if (mc->arguments->size() != 2) { modelError("Expected 2 arguments for %1%", mc); @@ -572,8 +565,8 @@ Util::IJson* ExternConverter_register::convertExternObject( } void ExternConverter_register::convertExternInstance( - UNUSED ConversionContext* ctxt, UNUSED const IR::Declaration* c, - UNUSED const IR::ExternBlock* eb, UNUSED const bool& emitExterns) { + ConversionContext* ctxt, const IR::Declaration* c, + const IR::ExternBlock* eb, UNUSED const bool& emitExterns) { auto inst = c->to(); cstring name = inst->controlPlaneName(); auto jreg = new Util::JsonObject(); @@ -617,7 +610,7 @@ void ExternConverter_register::convertExternInstance( Util::IJson* ExternConverter_direct_counter::convertExternObject( UNUSED ConversionContext* ctxt, UNUSED const P4::ExternMethod* em, - UNUSED const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl *s, + const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl *s, UNUSED const bool& emitExterns) { if (mc->arguments->size() != 0) { modelError("Expected 0 argument for %1%", mc); @@ -628,8 +621,8 @@ Util::IJson* ExternConverter_direct_counter::convertExternObject( } void ExternConverter_direct_counter::convertExternInstance( - UNUSED ConversionContext* ctxt, UNUSED const IR::Declaration* c, - UNUSED const IR::ExternBlock* eb, UNUSED const bool& emitExterns) { + ConversionContext* ctxt, const IR::Declaration* c, + const IR::ExternBlock* eb, UNUSED const bool& emitExterns) { auto inst = c->to(); cstring name = inst->controlPlaneName(); auto it = ctxt->structure->directCounterMap.find(name); @@ -647,8 +640,8 @@ void ExternConverter_direct_counter::convertExternInstance( } Util::IJson* ExternConverter_direct_meter::convertExternObject( - UNUSED ConversionContext* ctxt, UNUSED const P4::ExternMethod* em, - UNUSED const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl *s, + ConversionContext* ctxt, const P4::ExternMethod* em, + const IR::MethodCallExpression* mc, UNUSED const IR::StatOrDecl *s, UNUSED const bool& emitExterns) { if (mc->arguments->size() != 1) { modelError("Expected 1 argument for %1%", mc); @@ -661,8 +654,8 @@ Util::IJson* ExternConverter_direct_meter::convertExternObject( } void ExternConverter_direct_meter::convertExternInstance( - UNUSED ConversionContext* ctxt, UNUSED const IR::Declaration* c, - UNUSED const IR::ExternBlock* eb, UNUSED const bool& emitExterns) { + ConversionContext* ctxt, const IR::Declaration* c, + const IR::ExternBlock* eb, UNUSED const bool& emitExterns) { auto inst = c->to(); cstring name = inst->controlPlaneName(); auto info = ctxt->structure->directMeterMap.getInfo(c); @@ -720,8 +713,8 @@ void ExternConverter_direct_meter::convertExternInstance( } void ExternConverter_action_profile::convertExternInstance( - UNUSED ConversionContext* ctxt, UNUSED const IR::Declaration* c, - UNUSED const IR::ExternBlock* eb, UNUSED const bool& emitExterns) { + ConversionContext* ctxt, const IR::Declaration* c, + const IR::ExternBlock* eb, UNUSED const bool& emitExterns) { auto inst = c->to(); cstring name = inst->controlPlaneName(); // Might call this multiple times if the selector/profile is used more than @@ -779,8 +772,8 @@ void ExternConverter_action_profile::convertExternInstance( // action selector conversion is the same as action profile void ExternConverter_action_selector::convertExternInstance( - UNUSED ConversionContext* ctxt, UNUSED const IR::Declaration* c, - UNUSED const IR::ExternBlock* eb, UNUSED const bool& emitExterns) { + ConversionContext* ctxt, const IR::Declaration* c, + const IR::ExternBlock* eb, UNUSED const bool& emitExterns) { auto inst = c->to(); cstring name = inst->controlPlaneName(); // Might call this multiple times if the selector/profile is used more than @@ -836,36 +829,6 @@ void ExternConverter_action_selector::convertExternInstance( ctxt->action_profiles->append(action_profile); } -namespace { -/// Converts expr into a ListExpression or returns nullptr if not -/// possible -static const IR::ListExpression* convertToList(const IR::Expression* expr, P4::TypeMap* typeMap) { - if (auto l = expr->to()) - return l; - - // expand it into a list - auto list = new IR::ListExpression({}); - auto type = typeMap->getType(expr, true); - auto st = type->to(); - if (!st) { - return nullptr; - } - if (auto se = expr->to()) { - for (auto f : se->components) - list->push_back(f->expression); - } else { - for (auto f : st->fields) { - auto e = new IR::Member(expr, f->name); - auto ftype = typeMap->getType(f); - typeMap->setType(e, ftype); - list->push_back(e); - } - } - typeMap->setType(list, type); - return list; -} -} // namespace - Util::IJson* ExternConverter_log_msg::convertExternFunction( ConversionContext* ctxt, UNUSED const P4::ExternFunction* ef, const IR::MethodCallExpression* mc, const IR::StatOrDecl* s, @@ -1036,6 +999,72 @@ void SimpleSwitchBackend::createActions(ConversionContext* ctxt, V1ProgramStruct } } +void +SimpleSwitchBackend::createRecirculateFieldsList( + ConversionContext* ctxt, const IR::ToplevelBlock* tlb, cstring scalarName) { + auto main = tlb->getMain(); + CHECK_NULL(main); + + // Find the user metadata declaration. + // Validation has already been done, so we use BUG instead of error. + auto parser = main->findParameterValue(v1model.sw.parser.name)->to(); + CHECK_NULL(parser); + auto params = parser->container->getApplyParameters(); + BUG_CHECK(params->size() == 4, "%1%: expected 4 parameters", parser); + auto metaParam = params->parameters.at(2); + auto paramType = ctxt->typeMap->getType(metaParam, true); + auto userMetaType = paramType->to(); + LOG2("User metadata type is " << userMetaType); + + /// metadata fields may be annotated with e.g., + /// @field_list(0, 1, 4) + /// Such a field will be added to fieldLists with indexes 0, 1 and 4. + /// These fields lists will be named "field_list0", "field_list1", etc. + std::map fieldLists; + + LOG2("Scanning user metadata fields for annotations"); + for (auto f : userMetaType->fields) { + LOG3("Scanning field " << f); + auto anno = f->getAnnotations()->getSingle("field_list"); + if (anno == nullptr) + continue; + + for (auto e : anno->expr) { + auto cst = e->to(); + if (cst == nullptr) { + ::error("%1%: Annotation must be a constant integer", e); + continue; + } + + unsigned index = cst->asUnsigned(); + Util::JsonArray* elements; + auto fl = ::get(fieldLists, index); + if (fl == nullptr) { + fl = new Util::JsonObject(); + ctxt->json->field_lists->append(fl); + fieldLists.emplace(index, fl); + int id = nextId("field_lists"); + fl->emplace("id", id); + cstring listName = cstring("field_list") + Util::toString(index); + fl->emplace("name", listName); + elements = mkArrayField(fl, "elements"); + } else { + elements = fl->get("elements")->to(); + CHECK_NULL(elements); + } + + auto field = new Util::JsonObject(); + field->emplace("type", "field"); + auto value = new Util::JsonArray(); + value->append(scalarName); + auto name = ::get(ctxt->structure->scalarMetadataFields, f); + value->append(name); + field->emplace("value", value); + elements->append(field); + } + } +} + void SimpleSwitchBackend::convert(const IR::ToplevelBlock* tlb) { structure = new V1ProgramStructure(); @@ -1191,13 +1220,13 @@ SimpleSwitchBackend::convert(const IR::ToplevelBlock* tlb) { cstring scalarsName = refMap->newName("scalars"); // This visitor is used in multiple passes to convert expression to json conv = new SimpleSwitchExpressionConverter(refMap, typeMap, structure, scalarsName); - auto ctxt = new ConversionContext(refMap, typeMap, toplevel, structure, conv, json); - auto hconv = new HeaderConverter(ctxt, scalarsName); program->apply(*hconv); ctxt->blockConverted = BlockConverted::Parser; + createRecirculateFieldsList(ctxt, toplevel, scalarsName); + auto pconv = new ParserConverter(ctxt); structure->parser->apply(*pconv); diff --git a/backends/bmv2/simple_switch/simpleSwitch.h b/backends/bmv2/simple_switch/simpleSwitch.h index 8e793c20a43..eae8c0b7d2d 100644 --- a/backends/bmv2/simple_switch/simpleSwitch.h +++ b/backends/bmv2/simple_switch/simpleSwitch.h @@ -148,6 +148,8 @@ class SimpleSwitchBackend : public Backend { ExpressionConverter* conv = nullptr; protected: + void createRecirculateFieldsList(ConversionContext* ctxt, const IR::ToplevelBlock* tlb, + cstring scalarName); cstring createCalculation(cstring algo, const IR::Expression* fields, Util::JsonArray* calculations, bool usePayload, const IR::Node* node); @@ -165,11 +167,11 @@ class SimpleSwitchBackend : public Backend { }; EXTERN_CONVERTER_W_FUNCTION(clone) -EXTERN_CONVERTER_W_FUNCTION_AND_MODEL(clone3, P4V1::V1Model, v1model) +EXTERN_CONVERTER_W_FUNCTION_AND_MODEL(clone_preserving_field_list, P4V1::V1Model, v1model) EXTERN_CONVERTER_W_FUNCTION_AND_MODEL(hash, P4V1::V1Model, v1model) EXTERN_CONVERTER_W_FUNCTION(digest) -EXTERN_CONVERTER_W_FUNCTION(resubmit) -EXTERN_CONVERTER_W_FUNCTION(recirculate) +EXTERN_CONVERTER_W_FUNCTION(resubmit_preserving_field_list) +EXTERN_CONVERTER_W_FUNCTION(recirculate_preserving_field_list) EXTERN_CONVERTER_W_FUNCTION(mark_to_drop) EXTERN_CONVERTER_W_FUNCTION(log_msg) EXTERN_CONVERTER_W_FUNCTION_AND_MODEL(random, P4V1::V1Model, v1model) diff --git a/frontends/p4/fromv1.0/converters.cpp b/frontends/p4/fromv1.0/converters.cpp index 71b538a2b3a..14e258a0278 100644 --- a/frontends/p4/fromv1.0/converters.cpp +++ b/frontends/p4/fromv1.0/converters.cpp @@ -454,10 +454,13 @@ class ValidateLenExpr : public Inspector { } // namespace const IR::StructField *TypeConverter::postorder(IR::StructField *field) { - if (!field->type->is()) return field; + auto type = findContext(); + if (type == nullptr) + return field; + // given a struct with length and max_length, the // varbit field size is max_length * 8 - struct_size - if (auto type = findContext()) { + if (field->type->is()) { if (auto len = type->getAnnotation("length")) { if (len->expr.size() == 1) { auto lenexpr = len->expr[0]; @@ -472,6 +475,9 @@ const IR::StructField *TypeConverter::postorder(IR::StructField *field) { } } } + if (auto vec = structure->listIndexes(type->name.name, field->name.name)) + field->annotations = field->annotations->add( + new IR::Annotation("field_list", *vec)); return field; } @@ -629,6 +635,42 @@ ProgramStructure *(*Converter::createProgramStructure)() = defaultCreateProgramS ConversionContext *(*Converter::createConversionContext)() = defaultCreateConversionContext; namespace { +/// This visitor finds all field lists that participate in +/// recirculation, resubmission, and cloning +class FindRecirculated : public Inspector { + ProgramStructure* structure; + + void add(const IR::Primitive* primitive, unsigned operand) { + auto expression = primitive->operands.at(operand); + if (!expression->is()) { + ::error("%1%: expected a field list", expression); + return; + } + auto nr = expression->to(); + auto fl = structure->field_lists.get(nr->path->name); + if (fl == nullptr) { + ::error("%1%: Expected a field list", expression); + return; + } + LOG3("Recirculated " << nr->path->name); + structure->allFieldLists.emplace(fl); + } + + public: + explicit FindRecirculated(ProgramStructure* structure): structure(structure) + { CHECK_NULL(structure); setName("FindRecirculated"); } + + void postorder(const IR::Primitive* primitive) override { + if (primitive->name == "recirculate") { + add(primitive, 0); + } else if (primitive->name == "resubmit") { + add(primitive, 0); + } else if (primitive->name.startsWith("clone") && primitive->operands.size() == 2) { + add(primitive, 1); + } + } +}; + class RemoveLengthAnnotations: public Transform { const IR::Node* postorder(IR::Annotation* annotation) override { if (annotation->name == "length") @@ -653,6 +695,7 @@ Converter::Converter() { passes.emplace_back(new TypeCheck()); // Convert passes.emplace_back(new DiscoverStructure(structure)); + passes.emplace_back(new FindRecirculated(structure)); passes.emplace_back(new ComputeCallGraph(structure)); passes.emplace_back(new ComputeTableCallGraph(structure)); passes.emplace_back(new Rewriter(structure)); diff --git a/frontends/p4/fromv1.0/converters.h b/frontends/p4/fromv1.0/converters.h index 2c9087d909d..cd5e4f0d079 100644 --- a/frontends/p4/fromv1.0/converters.h +++ b/frontends/p4/fromv1.0/converters.h @@ -148,14 +148,14 @@ class PrimitiveConverter { * next highest will be run, etc. The macro invocation is followed by the body of the * converter function. */ -#define CONVERT_PRIMITIVE(NAME, ...) \ - class PrimitiveConverter_##NAME##_##__VA_ARGS__ : public PrimitiveConverter { \ +#define CONVERT_PRIMITIVE(NAME) \ + class PrimitiveConverter_##NAME : public PrimitiveConverter { \ const IR::Statement *convert(ProgramStructure *, const IR::Primitive *) override; \ - PrimitiveConverter_##NAME##_##__VA_ARGS__() \ - : PrimitiveConverter(#NAME, __VA_ARGS__ + 0) {} \ - static PrimitiveConverter_##NAME##_##__VA_ARGS__ singleton; \ - } PrimitiveConverter_##NAME##_##__VA_ARGS__::singleton; \ - const IR::Statement *PrimitiveConverter_##NAME##_##__VA_ARGS__::convert( \ + PrimitiveConverter_##NAME() \ + : PrimitiveConverter(#NAME, 0) {} \ + static PrimitiveConverter_##NAME singleton; \ + } PrimitiveConverter_##NAME::singleton; \ + const IR::Statement *PrimitiveConverter_##NAME::convert( \ ProgramStructure *structure, const IR::Primitive *primitive) /////////////////////////////////////////////////////////////// diff --git a/frontends/p4/fromv1.0/programStructure.cpp b/frontends/p4/fromv1.0/programStructure.cpp index 87f4828b48b..6e0901dc213 100644 --- a/frontends/p4/fromv1.0/programStructure.cpp +++ b/frontends/p4/fromv1.0/programStructure.cpp @@ -36,6 +36,19 @@ limitations under the License. namespace P4V1 { +static const IR::IDeclaration* getFirstDeclaration( + const IR::Vector* nodes, + cstring name) { + for (auto node : *nodes) { + auto decl = node->to(); + if (decl == nullptr) + continue; + if (decl->getName() == name) + return decl; + } + return nullptr; +} + ProgramStructure::ProgramStructure() : v1model(P4V1::V1Model::instance), p4lib(P4::P4CoreLibrary::instance), types(&allNames), metadata(&allNames), headers(&allNames), stacks(&allNames), @@ -102,6 +115,62 @@ void ProgramStructure::checkHeaderType(const IR::Type_StructLike* hdr, bool meta } } +bool ProgramStructure::isFieldInList(cstring type, cstring field, const IR::FieldList* fl) const { + LOG3("Checking " << type << "." << field << " in " << fl); + for (auto e : fl->fields) { + if (auto mem = e->to()) { + auto expr = mem->expr; + auto mfield = mem->member; + if (mfield != field) + continue; + CHECK_NULL(expr->type); + auto etype = expr->type->to(); + if (etype != nullptr && etype->name == type) + return true; + } else if (auto path = e->to()) { + auto l = field_lists.get(path->path->name); + BUG_CHECK(l != nullptr, "%1%: unexpected expression in field list", e); + return isFieldInList(type, field, l); + } else if (auto chr = e->to()) { + auto htype = chr->ref->type; + CHECK_NULL(htype); + if (htype->name != type) + continue; + for (auto f : htype->fields) { + if (f->name == field) + return true; + } + } else { + BUG("%1%: unexpected expression in field list", e); + } + } + return false; +} + +const IR::Vector* ProgramStructure::listIndexes(cstring type, cstring field) const { + IR::Vector* result = nullptr; + for (auto f : allFieldLists) { + if (isFieldInList(type, field, f)) { + if (result == nullptr) + result = new IR::Vector(); + result->push_back( + new IR::Member(new IR::TypeNameExpression(fieldListsEnum), f->name)); + } + } + return result; +} + +const IR::Expression* ProgramStructure::listIndex(const IR::Expression* expression) const { + auto pe = expression->to(); + if (pe == nullptr) { + ::error("%1%: Expected a field list", expression); + return 0; + } + + return new IR::Cast(IR::Type_Bits::get(8), + new IR::Member(new IR::TypeNameExpression(fieldListsEnum), pe->path->name)); +} + cstring ProgramStructure::createType(const IR::Type_StructLike* type, bool header, std::unordered_set *converted) { if (converted->count(type)) @@ -127,6 +196,19 @@ cstring ProgramStructure::createType(const IR::Type_StructLike* type, bool heade } void ProgramStructure::createTypes() { + if (allFieldLists.size()) { + // An enum containing the recirculated/cloned/resubmitted field lists + fieldListsEnum = makeUniqueName("FieldLists"); + auto members = new IR::IndexedVector(); + unsigned index = 0; + for (auto fl : allFieldLists) { + auto me = new IR::SerEnumMember(fl->srcInfo, fl->name, new IR::Constant(index++)); + members->push_back(me); + } + auto fieldLists = new IR::Type_SerEnum(fieldListsEnum, IR::Type_Bits::get(8), *members); + declarations->push_back(fieldLists); + } + std::unordered_set converted; // Metadata first for (auto it : metadata) { @@ -182,14 +264,14 @@ void ProgramStructure::createTypes() { const IR::Type_Struct* ProgramStructure::createFieldListType(const IR::Expression* expression) { if (!expression->is()) { - ::error(ErrorType::ERR_EXPECTED, "%1%: expected a field list", expression); - return nullptr; + ::error(ErrorType::ERR_EXPECTED, "%1%: expected a field list", expression); + return nullptr; } auto nr = expression->to(); auto fl = field_lists.get(nr->path->name); if (fl == nullptr) { - ::error(ErrorType::ERR_EXPECTED, "%1%: Expected a field list", expression); - return nullptr; + ::error(ErrorType::ERR_EXPECTED, "%1%: Expected a field list", expression); + return nullptr; } auto name = makeUniqueName(nr->path->name); @@ -276,7 +358,8 @@ void ProgramStructure::createExterns() { if (auto et = ExternConverter::cvtExternType(this, it.first, it.second)) { if (et != it.first) extern_remap[it.first] = et; - declarations->push_back(et); } } + if (et != getFirstDeclaration(declarations, et->name)) + declarations->push_back(et); } } } const IR::Expression* ProgramStructure::paramReference(const IR::Parameter* param) { @@ -1117,14 +1200,14 @@ const IR::Expression* ProgramStructure::convertFieldList(const IR::Expression* e ExpressionConverter conv(this); if (!expression->is()) { - ::error(ErrorType::ERR_EXPECTED, "%1%: expected a field list", expression); - return expression; + ::error(ErrorType::ERR_EXPECTED, "%1%: expected a field list", expression); + return expression; } auto nr = expression->to(); auto fl = field_lists.get(nr->path->name); if (fl == nullptr) { - ::error(ErrorType::ERR_EXPECTED, "%1%: Expected a field list", expression); - return expression; + ::error(ErrorType::ERR_EXPECTED, "%1%: Expected a field list", expression); + return expression; } auto result = conv.convert(fl); return result; @@ -1551,11 +1634,10 @@ CONVERT_PRIMITIVE(modify_field_rng_uniform) { CONVERT_PRIMITIVE(recirculate) { ExpressionConverter conv(structure); OPS_CK(primitive, 1); - auto right = structure->convertFieldList(primitive->operands.at(0)); - if (right == nullptr) - return nullptr; auto args = new IR::Vector(); - args->push_back(new IR::Argument(right)); + auto fieldList = primitive->operands.at(0); + if (auto expr = structure->listIndex(fieldList)) + args->push_back(new IR::Argument(expr)); auto path = new IR::PathExpression(structure->v1model.recirculate.Id()); auto mc = new IR::MethodCallExpression(primitive->srcInfo, path, args); return new IR::MethodCallStatement(mc->srcInfo, mc); @@ -1563,7 +1645,8 @@ CONVERT_PRIMITIVE(recirculate) { static const IR::Statement * convertClone(ProgramStructure *structure, const IR::Primitive *primitive, Model::Elem kind) { - BUG_CHECK(primitive->operands.size() == 1 || primitive->operands.size() == 2, + unsigned opcount = primitive->operands.size(); + BUG_CHECK(opcount == 1 || opcount == 2, "Expected 1 or 2 operands for %1%", primitive); ExpressionConverter conv(structure); auto session = conv.convert(primitive->operands.at(0)); @@ -1576,14 +1659,14 @@ convertClone(ProgramStructure *structure, const IR::Primitive *primitive, Model: args->push_back( new IR::Argument(new IR::Cast(primitive->operands.at(0)->srcInfo, structure->v1model.clone.sessionType, session))); - if (primitive->operands.size() == 2) { - auto list = structure->convertFieldList(primitive->operands.at(1)); - if (list != nullptr) - args->push_back(new IR::Argument(list)); - } - auto id = primitive->operands.size() == 2 ? structure->v1model.clone.clone3.Id() - : structure->v1model.clone.Id(); + auto id = opcount == 2 ? structure->v1model.clone.clone3.Id() + : structure->v1model.clone.Id(); + if (opcount == 2) { + auto fl = primitive->operands.at(1); + if (auto expr = structure->listIndex(fl)) + args->push_back(new IR::Argument(expr)); + } auto clone = new IR::PathExpression(id); auto mc = new IR::MethodCallExpression(primitive->srcInfo, clone, args); return new IR::MethodCallStatement(mc->srcInfo, mc); @@ -1600,14 +1683,18 @@ CONVERT_PRIMITIVE(clone_i2e) { CONVERT_PRIMITIVE(resubmit) { ExpressionConverter conv(structure); - BUG_CHECK(primitive->operands.size() <= 1, "Expected 0 or 1 operands for %1%", primitive); - const IR::Expression *list; - if (primitive->operands.size() > 0) - list = structure->convertFieldList(primitive->operands.at(0)); - else - list = new IR::ListExpression({}); - return new IR::MethodCallStatement(primitive->srcInfo, structure->v1model.resubmit.Id(), - { new IR::Argument(list) }); + unsigned opcount = primitive->operands.size(); + BUG_CHECK(opcount <= 1, "Expected 0 or 1 operands for %1%", primitive); + auto args = new IR::Vector(); + if (opcount == 1) { + auto fl = primitive->operands.at(0); + if (auto expr = structure->listIndex(fl)) + args->push_back(new IR::Argument(expr)); + } + return new IR::MethodCallStatement(primitive->srcInfo, + new IR::MethodCallExpression(primitive->srcInfo, + new IR::PathExpression(structure->v1model.resubmit.Id()), + args)); } CONVERT_PRIMITIVE(execute_meter) { @@ -2588,9 +2675,12 @@ void ProgramStructure::populateOutputNames() { "mark_to_drop", "hash", "resubmit", + "resubmit_preserving_field_list", "recirculate", + "recirculate_preserving_field_list", "clone", "clone3", + "clone_preserving_field_list", "truncate", "V1Switch", // other v1model names diff --git a/frontends/p4/fromv1.0/programStructure.h b/frontends/p4/fromv1.0/programStructure.h index ad318eb0412..aaca72fdc91 100644 --- a/frontends/p4/fromv1.0/programStructure.h +++ b/frontends/p4/fromv1.0/programStructure.h @@ -154,6 +154,8 @@ class ProgramStructure { std::map directMeters; std::map meterMap; std::map counterMap; + /// Field lists that appear in the program. + ordered_set allFieldLists; std::map tableMapping; std::map tableInvocation; @@ -172,6 +174,8 @@ class ProgramStructure { std::map extractsSynthesized; std::map parserEntryPoints; + /// Name of the serializable enum that holds one id for each field list. + cstring fieldListsEnum; // P4-14 struct/header type can be converted to three types // of struct/header in P4-16. @@ -292,6 +296,13 @@ class ProgramStructure { void tablesReferred(const IR::V1Control* control, std::vector &out); bool isHeader(const IR::ConcreteHeaderRef* nhr) const; cstring makeUniqueName(cstring base); + bool isFieldInList(cstring type, cstring field, const IR::FieldList* fl) const; + /// A vector with indexes of the field lists that contain this field. + /// Returns nullptr if the field does not appear in any list. + virtual const IR::Vector* listIndexes(cstring type, cstring field) const; + /// Given an expression which is supposed to be a field list + /// return a constant representing its value in the fieldListsEnum. + const IR::Expression* listIndex(const IR::Expression* fl) const; const IR::Type* explodeType(const std::vector &fieldTypes); const IR::Expression* explodeLabel(const IR::Constant* value, const IR::Constant* mask, diff --git a/frontends/p4/fromv1.0/v1model.h b/frontends/p4/fromv1.0/v1model.h index 0ae649a52d2..4d70f658ffe 100644 --- a/frontends/p4/fromv1.0/v1model.h +++ b/frontends/p4/fromv1.0/v1model.h @@ -202,7 +202,7 @@ struct Hash_Model : public ::Model::Elem { }; struct Cloner_Model : public ::Model::Extern_Model { - Cloner_Model() : Extern_Model("clone"), clone3("clone3"), cloneType(), + Cloner_Model() : Extern_Model("clone"), clone3("clone_preserving_field_list"), cloneType(), sessionType(IR::Type_Bits::get(32)) {} ::Model::Elem clone3; CloneType_Model cloneType; @@ -250,13 +250,13 @@ class V1Model : public ::Model::Model { egress("egress", headersType, metadataType, standardMetadataType), ingress("ingress", headersType, metadataType, standardMetadataType), sw(), counterOrMeter("$"), counter(), meter(), random(), action_profile(), - action_selector(), clone(), resubmit("resubmit"), + action_selector(), clone(), resubmit("resubmit_preserving_field_list"), tableAttributes(), rangeMatchType("range"), optionalMatchType("optional"), selectorMatchType("selector"), verify("verifyChecksum", headersType), compute("computeChecksum", headersType), digest_receiver(), hash(), algorithm(), registers(), drop("mark_to_drop"), - recirculate("recirculate"), verify_checksum("verify_checksum"), + recirculate("recirculate_preserving_field_list"), verify_checksum("verify_checksum"), update_checksum("update_checksum"), verify_checksum_with_payload("verify_checksum_with_payload"), update_checksum_with_payload("update_checksum_with_payload"), diff --git a/frontends/p4/parseAnnotations.cpp b/frontends/p4/parseAnnotations.cpp index 7137b356631..9ff300db499 100644 --- a/frontends/p4/parseAnnotations.cpp +++ b/frontends/p4/parseAnnotations.cpp @@ -43,6 +43,8 @@ ParseAnnotations::HandlerMap ParseAnnotations::standardHandlers() { // @synchronous has a list of method names PARSE_EXPRESSION_LIST(IR::Annotation::synchronousAnnotation), + // @field_list also has a list of expressions + PARSE_EXPRESSION_LIST(IR::Annotation::fieldListAnnotation), // @match has an expression argument PARSE(IR::Annotation::matchAnnotation, Expression), diff --git a/frontends/p4/typeChecking/typeChecker.cpp b/frontends/p4/typeChecking/typeChecker.cpp index 2964d7622b2..875316d7c64 100644 --- a/frontends/p4/typeChecking/typeChecker.cpp +++ b/frontends/p4/typeChecking/typeChecker.cpp @@ -2625,6 +2625,9 @@ const IR::Node* TypeInference::postorder(IR::PathExpression* expression) { return expression; } } + } else if (decl->is() || decl->is()) { + setCompileTimeConstant(expression); + setCompileTimeConstant(getOriginal()); } if (decl->is()) { diff --git a/ir/base.def b/ir/base.def index 437b2fbe420..09671d8aa8f 100644 --- a/ir/base.def +++ b/ir/base.def @@ -283,6 +283,7 @@ class Annotation { static const cstring noSideEffectsAnnotation; /// extern function/method annotation. static const cstring noWarnAnnotation; /// noWarn annotation. static const cstring matchAnnotation; /// Match annotation (for value sets). + static const cstring fieldListAnnotation; /// Used for recirculate, etc. toString{ return cstring("@") + name; } validate{ BUG_CHECK(!name.name.isNullOrEmpty(), "empty annotation name"); @@ -341,6 +342,13 @@ class Annotations { // already present. Annotations addAnnotationIfNew(cstring name, Expression expr, bool structured = false) const { return getSingle(name) ? this : addAnnotation(name, expr, structured); } + Annotations append(Annotations other) { + if (other == nullptr) + return this; + for (auto a : other->annotations) + add(a); + return this; + } // If annotations with the same name are already present, remove them. // Add this annotation. Annotations addOrReplace(cstring name, Expression expr, bool structured = false) const { diff --git a/ir/type.cpp b/ir/type.cpp index dc087f310f9..86c4702bd86 100644 --- a/ir/type.cpp +++ b/ir/type.cpp @@ -50,6 +50,7 @@ const cstring IR::Annotation::pureAnnotation = "pure"; const cstring IR::Annotation::noSideEffectsAnnotation = "noSideEffects"; const cstring IR::Annotation::noWarnAnnotation = "noWarn"; const cstring IR::Annotation::matchAnnotation = "match"; +const cstring IR::Annotation::fieldListAnnotation = "field_list"; int Type_Declaration::nextId = 0; int Type_InfInt::nextId = 0; diff --git a/midend/eliminateSerEnums.cpp b/midend/eliminateSerEnums.cpp index 22583fb31f6..aed91624f81 100644 --- a/midend/eliminateSerEnums.cpp +++ b/midend/eliminateSerEnums.cpp @@ -34,6 +34,7 @@ const IR::Node* DoEliminateSerEnums::postorder(IR::Type_Name* type) { // This will be resolved by the caller. return type; auto enumType = canontype->to(); + LOG2("Replacing " << type << " with " << enumType->type); return enumType->type; } @@ -41,8 +42,10 @@ const IR::Node* DoEliminateSerEnums::postorder(IR::Type_Name* type) { const IR::Node* DoEliminateSerEnums::postorder(IR::Member* expression) { auto ei = EnumInstance::resolve(getOriginal(), typeMap); if (!ei) return expression; - if (auto sei = ei->to()) + if (auto sei = ei->to()) { + LOG2("Replacing " << expression << " with " << sei->value); return sei->value; + } return expression; } diff --git a/midend/flattenInterfaceStructs.cpp b/midend/flattenInterfaceStructs.cpp index e0d481bc2be..e6cb493d0a1 100644 --- a/midend/flattenInterfaceStructs.cpp +++ b/midend/flattenInterfaceStructs.cpp @@ -21,23 +21,32 @@ namespace P4 { void StructTypeReplacement::flatten(const P4::TypeMap* typeMap, cstring prefix, const IR::Type* type, + const IR::Annotations* annotations, // from parent IR::IndexedVector *fields) { + // Drop name annotations + IR::Annotations::Filter f = + [](const IR::Annotation* a) { return a->name != IR::Annotation::nameAnnotation; }; + annotations = annotations->where(f); if (auto st = type->to()) { structFieldMap.emplace(prefix, st); - for (auto f : st->fields) - flatten(typeMap, prefix + "." + f->name, f->type, fields); + for (auto f : st->fields) { + auto na = new IR::Annotations(); + na->append(annotations); + na->append(f->annotations); + flatten(typeMap, prefix + "." + f->name, f->type, na, fields); + } return; } cstring fieldName = prefix.replace(".", "_") + cstring::to_cstring(fieldNameRemap.size()); fieldNameRemap.emplace(prefix, fieldName); - fields->push_back(new IR::StructField(IR::ID(fieldName), type->getP4Type())); + fields->push_back(new IR::StructField(IR::ID(fieldName), annotations, type->getP4Type())); } StructTypeReplacement::StructTypeReplacement( const P4::TypeMap* typeMap, const IR::Type_Struct* type) { auto vec = new IR::IndexedVector(); - flatten(typeMap, "", type, vec); + flatten(typeMap, "", type, type->annotations, vec); replacementType = new IR::Type_Struct(type->name, IR::Annotations::empty, *vec); } diff --git a/midend/flattenInterfaceStructs.h b/midend/flattenInterfaceStructs.h index cda1088c51c..0ecf2bf9059 100644 --- a/midend/flattenInterfaceStructs.h +++ b/midend/flattenInterfaceStructs.h @@ -72,6 +72,7 @@ struct StructTypeReplacement : public IHasDbPrint { void flatten(const P4::TypeMap* typeMap, cstring prefix, const IR::Type* type, + const IR::Annotations* annotations, IR::IndexedVector *fields); /// Returns a StructExpression suitable for diff --git a/p4include/v1model.p4 b/p4include/v1model.p4 index ef6683844c9..9a02a056a3e 100644 --- a/p4include/v1model.p4 +++ b/p4include/v1model.p4 @@ -21,15 +21,6 @@ limitations under the License. * * https://github.com/p4lang/behavioral-model/blob/main/docs/simple_switch.md * - * Note 2: There were several discussions among P4 working group - * members in early 2019 regarding exactly how resubmit, recirculate, - * and clone3 operations can be called anywhere in their respective - * controls, but the values of the fields to be preserved is the value - * they have when that control is finished executing. That is how - * these operations are defined in P4_14. See - * https://github.com/p4lang/behavioral-model/blob/main/docs/simple_switch.md#restrictions-on-recirculate-resubmit-and-clone-operations - * for more details on the current state of affairs. - * * Note 3: There are at least some P4_14 implementations where * invoking a generate_digest operation on a field_list will create a * message to the control plane that contains the values of those @@ -537,8 +528,19 @@ extern void verify_checksum_with_payload(in bool condition, in T data, in extern void update_checksum_with_payload(in bool condition, in T data, inout O checksum, HashAlgorithm algo); /*** - * Calling resubmit during execution of the ingress control will, - * under certain documented conditions, cause the packet to be + * clone is in most ways identical to the clone_preserving_field_list operation, with the + * only difference being that it never preserves any user-defined + * metadata fields with the cloned packet. It is equivalent to + * calling clone_preserving_field_list with the same type and session parameter values, + * with empty data. + */ +extern void clone(in CloneType type, in bit<32> session); + +@deprecated("Please use 'resubmit_preserving_field_list' instead") +extern void resubmit(in T data); +/*** + * Calling resubmit_preserving_field_list during execution of the ingress + * control will cause the packet to be * resubmitted, i.e. it will begin processing again with the parser, * with the contents of the packet exactly as they were when it last * began parsing. The only difference is in the value of the @@ -546,10 +548,8 @@ extern void update_checksum_with_payload(in bool condition, in T data, ino * metadata fields that the resubmit operation causes to be * preserved. * - * The value of the user-defined metadata fields that are preserved in - * resubmitted packets is the value they have at the end of ingress - * processing, not their values at the time the resubmit call is made. - * See Note 2 for issues with this. + * The user metadata fields that are tagged with @field_list(index) will + * be sent to the parser together with the packet. * * Calling resubmit is only supported in the ingress control. There * is no way to undo its effects once it has been called. If resubmit @@ -557,12 +557,27 @@ extern void update_checksum_with_payload(in bool condition, in T data, ino * control, only one packet is resubmitted, and only the data from the * last such call is preserved. See the v1model architecture * documentation (Note 1) for more details. + * + * For example, the user metadata fields can be annotated as follows: + * struct UM { + * @field_list(1) + * bit<32> x; + * @field_list(1, 2) + * bit<32> y; + * bit<32> z; + * } + * + * Calling resubmit_preserving_field_list(1) will resubmit the packet + * and preserve fields x and y of the user metadata. Calling + * resubmit_preserving_field_list(2) will only preserve field y. */ -extern void resubmit(in T data); +extern void resubmit_preserving_field_list(bit<8> index); +@deprecated("Please use 'recirculate_preserving_field_list' instead") +extern void recirculate(in T data); /*** - * Calling recirculate during execution of the egress control will, - * under certain documented conditions, cause the packet to be + * Calling recirculate_preserving_field_list during execution of the + * egress control will cause the packet to be * recirculated, i.e. it will begin processing again with the parser, * with the contents of the packet as they are created by the * deparser. Recirculated packets can be distinguished from new @@ -570,10 +585,8 @@ extern void resubmit(in T data); * instance_type field. The caller may request that some user-defined * metadata fields be preserved with the recirculated packet. * - * The value of the user-defined metadata fields that are preserved in - * recirculated packets is the value they have at the end of egress - * processing, not their values at the time the recirculate call is - * made. See Note 2 for issues with this. + * The user metadata fields that are tagged with @field_list(index) will be + * sent to the parser together with the packet. * * Calling recirculate is only supported in the egress control. There * is no way to undo its effects once it has been called. If @@ -582,19 +595,13 @@ extern void resubmit(in T data); * data from the last such call is preserved. See the v1model * architecture documentation (Note 1) for more details. */ -extern void recirculate(in T data); +extern void recirculate_preserving_field_list(bit<8> index); -/*** - * clone is in most ways identical to the clone3 operation, with the - * only difference being that it never preserves any user-defined - * metadata fields with the cloned packet. It is equivalent to - * calling clone3 with the same type and session parameter values, - * with empty data. - */ -extern void clone(in CloneType type, in bit<32> session); +@deprecated("Please use 'clone_preserving_field_list' instead") +extern void clone3(in CloneType type, in bit<32> session, in T data); /*** - * Calling clone3 during execution of the ingress or egress control + * Calling clone_preserving_field_list during execution of the ingress or egress control * will cause the packet to be cloned, sometimes also called * mirroring, i.e. zero or more copies of the packet are made, and * each will later begin egress processing as an independent packet @@ -613,24 +620,20 @@ extern void clone(in CloneType type, in bit<32> session); * Cloned packets can be distinguished from others by the value of the * standard_metadata instance_type field. * - * The caller may request that some user-defined metadata field values - * from the original packet should be preserved with the cloned - * packet(s). The value of the user-defined metadata fields that are - * preserved with cloned packets is the value they have at the end of - * ingress or egress processing, not their values at the time the - * clone3 call is made. See Note 2 for issues with this. + * The user metadata fields that are tagged with @field_list(index) will be + * sent to the parser together with a clone of the packet. * - * If clone3 is called during ingress processing, the first parameter - * must be CloneType.I2E. If clone3 is called during egress + * If clone_preserving_field_list is called during ingress processing, the first parameter + * must be CloneType.I2E. If clone_preserving_field_list is called during egress * processing, the first parameter must be CloneType.E2E. * * There is no way to undo its effects once it has been called. If - * there are multiple calls to clone3 and/or clone during a single + * there are multiple calls to clone_preserving_field_list and/or clone during a single * execution of the same ingress (or egress) control, only the last * clone session and data are used. See the v1model architecture * documentation (Note 1) for more details. */ -extern void clone3(in CloneType type, in bit<32> session, in T data); +extern void clone_preserving_field_list(in CloneType type, in bit<32> session, bit<8> index); extern void truncate(in bit<32> length); diff --git a/testdata/p4_14_errors_outputs/issue747.p4-stderr b/testdata/p4_14_errors_outputs/issue747.p4-stderr index 460bccc9086..728c666d47b 100644 --- a/testdata/p4_14_errors_outputs/issue747.p4-stderr +++ b/testdata/p4_14_errors_outputs/issue747.p4-stderr @@ -1,7 +1,4 @@ -issue747.p4(31): [--Wwarn=type-inference] warning: Could not infer type for local_port, using bit<8> -action local_recirc(local_port) { - ^^^^^^^^^^ -issue747.p4(31): [--Werror=expected] error: local_port: expected a field list +issue747.p4(31): [--Werror=legacy] error: local_port: expected a field list action local_recirc(local_port) { ^^^^^^^^^^ [--Werror=overlimit] error: 1 errors encountered, aborting compilation diff --git a/testdata/p4_14_samples_outputs/acl1-midend.p4 b/testdata/p4_14_samples_outputs/acl1-midend.p4 index 90098be9f9d..533f6f26030 100644 --- a/testdata/p4_14_samples_outputs/acl1-midend.p4 +++ b/testdata/p4_14_samples_outputs/acl1-midend.p4 @@ -134,16 +134,27 @@ header data_t { } struct metadata { + @pa_solitary("ingress", "acl_metadata.if_label") bit<1> _acl_metadata_acl_deny0; + @pa_solitary("ingress", "acl_metadata.if_label") bit<1> _acl_metadata_racl_deny1; + @pa_solitary("ingress", "acl_metadata.if_label") bit<16> _acl_metadata_acl_nexthop2; + @pa_solitary("ingress", "acl_metadata.if_label") bit<16> _acl_metadata_racl_nexthop3; + @pa_solitary("ingress", "acl_metadata.if_label") bit<1> _acl_metadata_acl_nexthop_type4; + @pa_solitary("ingress", "acl_metadata.if_label") bit<1> _acl_metadata_racl_nexthop_type5; + @pa_solitary("ingress", "acl_metadata.if_label") bit<1> _acl_metadata_acl_redirect6; + @pa_solitary("ingress", "acl_metadata.if_label") bit<1> _acl_metadata_racl_redirect7; + @pa_solitary("ingress", "acl_metadata.if_label") bit<15> _acl_metadata_if_label8; + @pa_solitary("ingress", "acl_metadata.if_label") bit<16> _acl_metadata_bd_label9; + @pa_solitary("ingress", "acl_metadata.if_label") bit<10> _acl_metadata_mirror_session_id10; bit<3> _fabric_metadata_packetType11; bit<1> _fabric_metadata_fabric_header_present12; @@ -206,6 +217,7 @@ struct metadata { bit<1> _l3_metadata_routed69; bit<1> _l3_metadata_outer_routed70; bit<8> _l3_metadata_mtu_index71; + @saturating bit<16> _l3_metadata_l3_mtu_check72; bit<1> _security_metadata_storm_control_color73; bit<1> _security_metadata_ipsg_enabled74; diff --git a/testdata/p4_14_samples_outputs/copy_to_cpu-first.p4 b/testdata/p4_14_samples_outputs/copy_to_cpu-first.p4 index 83ad8efe2c4..eb1ff388134 100644 --- a/testdata/p4_14_samples_outputs/copy_to_cpu-first.p4 +++ b/testdata/p4_14_samples_outputs/copy_to_cpu-first.p4 @@ -2,6 +2,10 @@ #define V1MODEL_VERSION 20200408 #include +enum bit<8> FieldLists { + copy_to_cpu_fields = 8w0 +} + struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; @@ -22,9 +26,9 @@ struct metadata { } struct headers { - @name(".cpu_header") + @name(".cpu_header") cpu_header_t cpu_header; - @name(".ethernet") + @name(".ethernet") ethernet_t ethernet; } @@ -73,7 +77,7 @@ 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(".do_copy_to_cpu") action do_copy_to_cpu() { - clone3>(CloneType.I2E, 32w250, { standard_metadata }); + clone_preserving_field_list(CloneType.I2E, 32w250, (bit<8>)FieldLists.copy_to_cpu_fields); } @name(".copy_to_cpu") table copy_to_cpu { actions = { @@ -106,4 +110,3 @@ control computeChecksum(inout headers hdr, inout metadata meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_14_samples_outputs/copy_to_cpu-frontend.p4 b/testdata/p4_14_samples_outputs/copy_to_cpu-frontend.p4 index 24b0ace251c..222306c199e 100644 --- a/testdata/p4_14_samples_outputs/copy_to_cpu-frontend.p4 +++ b/testdata/p4_14_samples_outputs/copy_to_cpu-frontend.p4 @@ -2,6 +2,10 @@ #define V1MODEL_VERSION 20200408 #include +enum bit<8> FieldLists { + copy_to_cpu_fields = 8w0 +} + struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; @@ -22,9 +26,9 @@ struct metadata { } struct headers { - @name(".cpu_header") + @name(".cpu_header") cpu_header_t cpu_header; - @name(".ethernet") + @name(".ethernet") ethernet_t ethernet; } @@ -81,7 +85,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ @noWarn("unused") @name(".NoAction") action NoAction_3() { } @name(".do_copy_to_cpu") action do_copy_to_cpu() { - clone3>(CloneType.I2E, 32w250, { standard_metadata }); + clone_preserving_field_list(CloneType.I2E, 32w250, (bit<8>)FieldLists.copy_to_cpu_fields); } @name(".copy_to_cpu") table copy_to_cpu_0 { actions = { @@ -114,4 +118,3 @@ control computeChecksum(inout headers hdr, inout metadata meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_14_samples_outputs/copy_to_cpu-midend.p4 b/testdata/p4_14_samples_outputs/copy_to_cpu-midend.p4 index 04721e8a62c..267e8139fa2 100644 --- a/testdata/p4_14_samples_outputs/copy_to_cpu-midend.p4 +++ b/testdata/p4_14_samples_outputs/copy_to_cpu-midend.p4 @@ -22,9 +22,9 @@ struct metadata { } struct headers { - @name(".cpu_header") + @name(".cpu_header") cpu_header_t cpu_header; - @name(".ethernet") + @name(".ethernet") ethernet_t ethernet; } @@ -75,15 +75,11 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } } -struct tuple_0 { - standard_metadata_t f0; -} - control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @noWarn("unused") @name(".NoAction") action NoAction_3() { } @name(".do_copy_to_cpu") action do_copy_to_cpu() { - clone3(CloneType.I2E, 32w250, (tuple_0){f0 = standard_metadata}); + clone_preserving_field_list(CloneType.I2E, 32w250, 8w0); } @name(".copy_to_cpu") table copy_to_cpu_0 { actions = { @@ -116,4 +112,3 @@ control computeChecksum(inout headers hdr, inout metadata meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_14_samples_outputs/copy_to_cpu.p4 b/testdata/p4_14_samples_outputs/copy_to_cpu.p4 index b076eba7f32..d593e93990e 100644 --- a/testdata/p4_14_samples_outputs/copy_to_cpu.p4 +++ b/testdata/p4_14_samples_outputs/copy_to_cpu.p4 @@ -2,6 +2,10 @@ #define V1MODEL_VERSION 20200408 #include +enum bit<8> FieldLists { + copy_to_cpu_fields = 0 +} + struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; @@ -22,9 +26,9 @@ struct metadata { } struct headers { - @name(".cpu_header") + @name(".cpu_header") cpu_header_t cpu_header; - @name(".ethernet") + @name(".ethernet") ethernet_t ethernet; } @@ -71,7 +75,7 @@ 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(".do_copy_to_cpu") action do_copy_to_cpu() { - clone3(CloneType.I2E, (bit<32>)32w250, { standard_metadata }); + clone_preserving_field_list(CloneType.I2E, (bit<32>)32w250, (bit<8>)FieldLists.copy_to_cpu_fields); } @name(".copy_to_cpu") table copy_to_cpu { actions = { @@ -102,4 +106,3 @@ control computeChecksum(inout headers hdr, inout metadata meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_14_samples_outputs/p414-special-ops-2-bmv2-first.p4 b/testdata/p4_14_samples_outputs/p414-special-ops-2-bmv2-first.p4 index 75916e6520b..1a42a30740f 100644 --- a/testdata/p4_14_samples_outputs/p414-special-ops-2-bmv2-first.p4 +++ b/testdata/p4_14_samples_outputs/p414-special-ops-2-bmv2-first.p4 @@ -2,6 +2,12 @@ #define V1MODEL_VERSION 20200408 #include +enum bit<8> FieldLists { + clone_e2e_FL = 8w0, + recirculate_FL = 8w1, + resubmit_FL = 8w2 +} + struct intrinsic_metadata_t { bit<48> ingress_global_timestamp; bit<48> egress_global_timestamp; @@ -10,10 +16,15 @@ struct intrinsic_metadata_t { } struct mymeta_t { + @field_list(FieldLists.clone_e2e_FL, FieldLists.recirculate_FL, FieldLists.resubmit_FL) bit<8> resubmit_count; + @field_list(FieldLists.clone_e2e_FL, FieldLists.recirculate_FL, FieldLists.resubmit_FL) bit<8> recirculate_count; + @field_list(FieldLists.clone_e2e_FL, FieldLists.recirculate_FL, FieldLists.resubmit_FL) bit<8> clone_e2e_count; + @field_list(FieldLists.clone_e2e_FL, FieldLists.recirculate_FL, FieldLists.resubmit_FL) bit<8> last_ing_instance_type; + @field_list(FieldLists.clone_e2e_FL, FieldLists.recirculate_FL, FieldLists.resubmit_FL) bit<8> f1; } @@ -28,14 +39,14 @@ header ethernet_t { } struct metadata { - @name(".mymeta") + @name(".mymeta") mymeta_t mymeta; - @name(".temporaries") + @name(".temporaries") temporaries_t temporaries; } struct headers { - @name(".ethernet") + @name(".ethernet") ethernet_t ethernet; } @@ -54,13 +65,13 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t hdr.ethernet.srcAddr = hdr.ethernet.srcAddr + 48w281474976710633; meta.mymeta.f1 = meta.mymeta.f1 + 8w23; meta.mymeta.clone_e2e_count = meta.mymeta.clone_e2e_count + 8w1; - clone3>(CloneType.E2E, 32w1, { meta.mymeta }); + clone_preserving_field_list(CloneType.E2E, 32w1, (bit<8>)FieldLists.clone_e2e_FL); } @name(".do_recirculate") action do_recirculate() { hdr.ethernet.srcAddr = hdr.ethernet.srcAddr + 48w281474976710637; meta.mymeta.f1 = meta.mymeta.f1 + 8w19; meta.mymeta.recirculate_count = meta.mymeta.recirculate_count + 8w1; - recirculate>({ meta.mymeta }); + recirculate_preserving_field_list((bit<8>)FieldLists.recirculate_FL); } @name("._nop") action _nop() { } @@ -218,7 +229,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ hdr.ethernet.srcAddr = hdr.ethernet.srcAddr + 48w281474976710639; meta.mymeta.f1 = meta.mymeta.f1 + 8w17; meta.mymeta.resubmit_count = meta.mymeta.resubmit_count + 8w1; - resubmit>({ meta.mymeta }); + resubmit_preserving_field_list((bit<8>)FieldLists.resubmit_FL); } @name("._nop") action _nop() { } @@ -346,4 +357,3 @@ control computeChecksum(inout headers hdr, inout metadata meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_14_samples_outputs/p414-special-ops-2-bmv2-frontend.p4 b/testdata/p4_14_samples_outputs/p414-special-ops-2-bmv2-frontend.p4 index b7cfb6fd700..7d83a585fc7 100644 --- a/testdata/p4_14_samples_outputs/p414-special-ops-2-bmv2-frontend.p4 +++ b/testdata/p4_14_samples_outputs/p414-special-ops-2-bmv2-frontend.p4 @@ -2,6 +2,12 @@ #define V1MODEL_VERSION 20200408 #include +enum bit<8> FieldLists { + clone_e2e_FL = 8w0, + recirculate_FL = 8w1, + resubmit_FL = 8w2 +} + struct intrinsic_metadata_t { bit<48> ingress_global_timestamp; bit<48> egress_global_timestamp; @@ -10,10 +16,15 @@ struct intrinsic_metadata_t { } struct mymeta_t { + @field_list(FieldLists.clone_e2e_FL, FieldLists.recirculate_FL, FieldLists.resubmit_FL) bit<8> resubmit_count; + @field_list(FieldLists.clone_e2e_FL, FieldLists.recirculate_FL, FieldLists.resubmit_FL) bit<8> recirculate_count; + @field_list(FieldLists.clone_e2e_FL, FieldLists.recirculate_FL, FieldLists.resubmit_FL) bit<8> clone_e2e_count; + @field_list(FieldLists.clone_e2e_FL, FieldLists.recirculate_FL, FieldLists.resubmit_FL) bit<8> last_ing_instance_type; + @field_list(FieldLists.clone_e2e_FL, FieldLists.recirculate_FL, FieldLists.resubmit_FL) bit<8> f1; } @@ -28,14 +39,14 @@ header ethernet_t { } struct metadata { - @name(".mymeta") + @name(".mymeta") mymeta_t mymeta; - @name(".temporaries") + @name(".temporaries") temporaries_t temporaries; } struct headers { - @name(".ethernet") + @name(".ethernet") ethernet_t ethernet; } @@ -54,13 +65,13 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t hdr.ethernet.srcAddr = hdr.ethernet.srcAddr + 48w281474976710633; meta.mymeta.f1 = meta.mymeta.f1 + 8w23; meta.mymeta.clone_e2e_count = meta.mymeta.clone_e2e_count + 8w1; - clone3>(CloneType.E2E, 32w1, { meta.mymeta }); + clone_preserving_field_list(CloneType.E2E, 32w1, (bit<8>)FieldLists.clone_e2e_FL); } @name(".do_recirculate") action do_recirculate() { hdr.ethernet.srcAddr = hdr.ethernet.srcAddr + 48w281474976710637; meta.mymeta.f1 = meta.mymeta.f1 + 8w19; meta.mymeta.recirculate_count = meta.mymeta.recirculate_count + 8w1; - recirculate>({ meta.mymeta }); + recirculate_preserving_field_list((bit<8>)FieldLists.recirculate_FL); } @name("._nop") action _nop() { } @@ -247,7 +258,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ hdr.ethernet.srcAddr = hdr.ethernet.srcAddr + 48w281474976710639; meta.mymeta.f1 = meta.mymeta.f1 + 8w17; meta.mymeta.resubmit_count = meta.mymeta.resubmit_count + 8w1; - resubmit>({ meta.mymeta }); + resubmit_preserving_field_list((bit<8>)FieldLists.resubmit_FL); } @name("._nop") action _nop_3() { } @@ -377,4 +388,3 @@ control computeChecksum(inout headers hdr, inout metadata meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_14_samples_outputs/p414-special-ops-2-bmv2-midend.p4 b/testdata/p4_14_samples_outputs/p414-special-ops-2-bmv2-midend.p4 index b45208f4797..a5c7299cfc0 100644 --- a/testdata/p4_14_samples_outputs/p414-special-ops-2-bmv2-midend.p4 +++ b/testdata/p4_14_samples_outputs/p414-special-ops-2-bmv2-midend.p4 @@ -10,10 +10,15 @@ struct intrinsic_metadata_t { } struct mymeta_t { + @field_list(8w0, 8w1, 8w2) bit<8> resubmit_count; + @field_list(8w0, 8w1, 8w2) bit<8> recirculate_count; + @field_list(8w0, 8w1, 8w2) bit<8> clone_e2e_count; + @field_list(8w0, 8w1, 8w2) bit<8> last_ing_instance_type; + @field_list(8w0, 8w1, 8w2) bit<8> f1; } @@ -28,16 +33,21 @@ header ethernet_t { } struct metadata { + @field_list(8w0, 8w1, 8w2) bit<8> _mymeta_resubmit_count0; + @field_list(8w0, 8w1, 8w2) bit<8> _mymeta_recirculate_count1; + @field_list(8w0, 8w1, 8w2) bit<8> _mymeta_clone_e2e_count2; + @field_list(8w0, 8w1, 8w2) bit<8> _mymeta_last_ing_instance_type3; + @field_list(8w0, 8w1, 8w2) bit<8> _mymeta_f14; bit<48> _temporaries_temp15; } struct headers { - @name(".ethernet") + @name(".ethernet") ethernet_t ethernet; } @@ -51,22 +61,18 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout } } -struct tuple_0 { - mymeta_t f0; -} - control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name(".do_clone_e2e") action do_clone_e2e() { hdr.ethernet.srcAddr = hdr.ethernet.srcAddr + 48w281474976710633; meta._mymeta_f14 = meta._mymeta_f14 + 8w23; meta._mymeta_clone_e2e_count2 = meta._mymeta_clone_e2e_count2 + 8w1; - clone3(CloneType.E2E, 32w1, (tuple_0){f0 = (mymeta_t){resubmit_count = meta._mymeta_resubmit_count0,recirculate_count = meta._mymeta_recirculate_count1,clone_e2e_count = meta._mymeta_clone_e2e_count2,last_ing_instance_type = meta._mymeta_last_ing_instance_type3,f1 = meta._mymeta_f14}}); + clone_preserving_field_list(CloneType.E2E, 32w1, 8w0); } @name(".do_recirculate") action do_recirculate() { hdr.ethernet.srcAddr = hdr.ethernet.srcAddr + 48w281474976710637; meta._mymeta_f14 = meta._mymeta_f14 + 8w19; meta._mymeta_recirculate_count1 = meta._mymeta_recirculate_count1 + 8w1; - recirculate((tuple_0){f0 = (mymeta_t){resubmit_count = meta._mymeta_resubmit_count0,recirculate_count = meta._mymeta_recirculate_count1,clone_e2e_count = meta._mymeta_clone_e2e_count2,last_ing_instance_type = meta._mymeta_last_ing_instance_type3,f1 = meta._mymeta_f14}}); + recirculate_preserving_field_list(8w1); } @name("._nop") action _nop() { } @@ -253,7 +259,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ hdr.ethernet.srcAddr = hdr.ethernet.srcAddr + 48w281474976710639; meta._mymeta_f14 = meta._mymeta_f14 + 8w17; meta._mymeta_resubmit_count0 = meta._mymeta_resubmit_count0 + 8w1; - resubmit((tuple_0){f0 = (mymeta_t){resubmit_count = meta._mymeta_resubmit_count0,recirculate_count = meta._mymeta_recirculate_count1,clone_e2e_count = meta._mymeta_clone_e2e_count2,last_ing_instance_type = meta._mymeta_last_ing_instance_type3,f1 = meta._mymeta_f14}}); + resubmit_preserving_field_list(8w2); } @name("._nop") action _nop_3() { } @@ -383,4 +389,3 @@ control computeChecksum(inout headers hdr, inout metadata meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_14_samples_outputs/p414-special-ops-2-bmv2.p4 b/testdata/p4_14_samples_outputs/p414-special-ops-2-bmv2.p4 index e1d344a3774..b64ea1cf64d 100644 --- a/testdata/p4_14_samples_outputs/p414-special-ops-2-bmv2.p4 +++ b/testdata/p4_14_samples_outputs/p414-special-ops-2-bmv2.p4 @@ -2,6 +2,12 @@ #define V1MODEL_VERSION 20200408 #include +enum bit<8> FieldLists { + clone_e2e_FL = 0, + recirculate_FL = 1, + resubmit_FL = 2 +} + struct intrinsic_metadata_t { bit<48> ingress_global_timestamp; bit<48> egress_global_timestamp; @@ -10,10 +16,15 @@ struct intrinsic_metadata_t { } struct mymeta_t { + @field_list(FieldLists.clone_e2e_FL, FieldLists.recirculate_FL, FieldLists.resubmit_FL) bit<8> resubmit_count; + @field_list(FieldLists.clone_e2e_FL, FieldLists.recirculate_FL, FieldLists.resubmit_FL) bit<8> recirculate_count; + @field_list(FieldLists.clone_e2e_FL, FieldLists.recirculate_FL, FieldLists.resubmit_FL) bit<8> clone_e2e_count; + @field_list(FieldLists.clone_e2e_FL, FieldLists.recirculate_FL, FieldLists.resubmit_FL) bit<8> last_ing_instance_type; + @field_list(FieldLists.clone_e2e_FL, FieldLists.recirculate_FL, FieldLists.resubmit_FL) bit<8> f1; } @@ -28,14 +39,14 @@ header ethernet_t { } struct metadata { - @name(".mymeta") + @name(".mymeta") mymeta_t mymeta; - @name(".temporaries") + @name(".temporaries") temporaries_t temporaries; } struct headers { - @name(".ethernet") + @name(".ethernet") ethernet_t ethernet; } @@ -54,13 +65,13 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t hdr.ethernet.srcAddr = hdr.ethernet.srcAddr - 48w23; meta.mymeta.f1 = meta.mymeta.f1 + 8w23; meta.mymeta.clone_e2e_count = meta.mymeta.clone_e2e_count + 8w1; - clone3(CloneType.E2E, (bit<32>)32w1, { meta.mymeta }); + clone_preserving_field_list(CloneType.E2E, (bit<32>)32w1, (bit<8>)FieldLists.clone_e2e_FL); } @name(".do_recirculate") action do_recirculate() { hdr.ethernet.srcAddr = hdr.ethernet.srcAddr - 48w19; meta.mymeta.f1 = meta.mymeta.f1 + 8w19; meta.mymeta.recirculate_count = meta.mymeta.recirculate_count + 8w1; - recirculate({ meta.mymeta }); + recirculate_preserving_field_list((bit<8>)FieldLists.recirculate_FL); } @name("._nop") action _nop() { } @@ -222,7 +233,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ hdr.ethernet.srcAddr = hdr.ethernet.srcAddr - 48w17; meta.mymeta.f1 = meta.mymeta.f1 + 8w17; meta.mymeta.resubmit_count = meta.mymeta.resubmit_count + 8w1; - resubmit({ meta.mymeta }); + resubmit_preserving_field_list((bit<8>)FieldLists.resubmit_FL); } @name("._nop") action _nop() { } @@ -350,4 +361,3 @@ control computeChecksum(inout headers hdr, inout metadata meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_14_samples_outputs/p414-special-ops-3-bmv2-first.p4 b/testdata/p4_14_samples_outputs/p414-special-ops-3-bmv2-first.p4 index 3992a53e044..d011952d283 100644 --- a/testdata/p4_14_samples_outputs/p414-special-ops-3-bmv2-first.p4 +++ b/testdata/p4_14_samples_outputs/p414-special-ops-3-bmv2-first.p4 @@ -2,6 +2,12 @@ #define V1MODEL_VERSION 20200408 #include +enum bit<8> FieldLists { + clone_e2e_FL = 8w0, + recirculate_FL = 8w1, + resubmit_FL = 8w2 +} + struct intrinsic_metadata_t { bit<48> ingress_global_timestamp; bit<48> egress_global_timestamp; @@ -10,10 +16,14 @@ struct intrinsic_metadata_t { } struct mymeta_t { + @field_list(FieldLists.resubmit_FL) bit<8> resubmit_count; + @field_list(FieldLists.recirculate_FL) bit<8> recirculate_count; + @field_list(FieldLists.clone_e2e_FL) bit<8> clone_e2e_count; bit<8> last_ing_instance_type; + @field_list(FieldLists.clone_e2e_FL, FieldLists.recirculate_FL, FieldLists.resubmit_FL) bit<8> f1; } @@ -28,14 +38,14 @@ header ethernet_t { } struct metadata { - @name(".mymeta") + @name(".mymeta") mymeta_t mymeta; - @name(".temporaries") + @name(".temporaries") temporaries_t temporaries; } struct headers { - @name(".ethernet") + @name(".ethernet") ethernet_t ethernet; } @@ -54,13 +64,13 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t hdr.ethernet.srcAddr = hdr.ethernet.srcAddr + 48w281474976710633; meta.mymeta.f1 = meta.mymeta.f1 + 8w23; meta.mymeta.clone_e2e_count = meta.mymeta.clone_e2e_count + 8w1; - clone3, bit<8>>>(CloneType.E2E, 32w1, { meta.mymeta.clone_e2e_count, meta.mymeta.f1 }); + clone_preserving_field_list(CloneType.E2E, 32w1, (bit<8>)FieldLists.clone_e2e_FL); } @name(".do_recirculate") action do_recirculate() { hdr.ethernet.srcAddr = hdr.ethernet.srcAddr + 48w281474976710637; meta.mymeta.f1 = meta.mymeta.f1 + 8w19; meta.mymeta.recirculate_count = meta.mymeta.recirculate_count + 8w1; - recirculate, bit<8>>>({ meta.mymeta.recirculate_count, meta.mymeta.f1 }); + recirculate_preserving_field_list((bit<8>)FieldLists.recirculate_FL); } @name("._nop") action _nop() { } @@ -231,7 +241,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ hdr.ethernet.srcAddr = hdr.ethernet.srcAddr + 48w281474976710639; meta.mymeta.f1 = meta.mymeta.f1 + 8w17; meta.mymeta.resubmit_count = meta.mymeta.resubmit_count + 8w1; - resubmit, bit<8>>>({ meta.mymeta.resubmit_count, meta.mymeta.f1 }); + resubmit_preserving_field_list((bit<8>)FieldLists.resubmit_FL); } @name("._nop") action _nop() { } @@ -371,4 +381,3 @@ control computeChecksum(inout headers hdr, inout metadata meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_14_samples_outputs/p414-special-ops-3-bmv2-frontend.p4 b/testdata/p4_14_samples_outputs/p414-special-ops-3-bmv2-frontend.p4 index 2b4f23f3897..b9dce8aaf69 100644 --- a/testdata/p4_14_samples_outputs/p414-special-ops-3-bmv2-frontend.p4 +++ b/testdata/p4_14_samples_outputs/p414-special-ops-3-bmv2-frontend.p4 @@ -2,6 +2,12 @@ #define V1MODEL_VERSION 20200408 #include +enum bit<8> FieldLists { + clone_e2e_FL = 8w0, + recirculate_FL = 8w1, + resubmit_FL = 8w2 +} + struct intrinsic_metadata_t { bit<48> ingress_global_timestamp; bit<48> egress_global_timestamp; @@ -10,10 +16,14 @@ struct intrinsic_metadata_t { } struct mymeta_t { + @field_list(FieldLists.resubmit_FL) bit<8> resubmit_count; + @field_list(FieldLists.recirculate_FL) bit<8> recirculate_count; + @field_list(FieldLists.clone_e2e_FL) bit<8> clone_e2e_count; bit<8> last_ing_instance_type; + @field_list(FieldLists.clone_e2e_FL, FieldLists.recirculate_FL, FieldLists.resubmit_FL) bit<8> f1; } @@ -28,14 +38,14 @@ header ethernet_t { } struct metadata { - @name(".mymeta") + @name(".mymeta") mymeta_t mymeta; - @name(".temporaries") + @name(".temporaries") temporaries_t temporaries; } struct headers { - @name(".ethernet") + @name(".ethernet") ethernet_t ethernet; } @@ -54,13 +64,13 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t hdr.ethernet.srcAddr = hdr.ethernet.srcAddr + 48w281474976710633; meta.mymeta.f1 = meta.mymeta.f1 + 8w23; meta.mymeta.clone_e2e_count = meta.mymeta.clone_e2e_count + 8w1; - clone3, bit<8>>>(CloneType.E2E, 32w1, { meta.mymeta.clone_e2e_count, meta.mymeta.f1 }); + clone_preserving_field_list(CloneType.E2E, 32w1, (bit<8>)FieldLists.clone_e2e_FL); } @name(".do_recirculate") action do_recirculate() { hdr.ethernet.srcAddr = hdr.ethernet.srcAddr + 48w281474976710637; meta.mymeta.f1 = meta.mymeta.f1 + 8w19; meta.mymeta.recirculate_count = meta.mymeta.recirculate_count + 8w1; - recirculate, bit<8>>>({ meta.mymeta.recirculate_count, meta.mymeta.f1 }); + recirculate_preserving_field_list((bit<8>)FieldLists.recirculate_FL); } @name("._nop") action _nop() { } @@ -260,7 +270,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ hdr.ethernet.srcAddr = hdr.ethernet.srcAddr + 48w281474976710639; meta.mymeta.f1 = meta.mymeta.f1 + 8w17; meta.mymeta.resubmit_count = meta.mymeta.resubmit_count + 8w1; - resubmit, bit<8>>>({ meta.mymeta.resubmit_count, meta.mymeta.f1 }); + resubmit_preserving_field_list((bit<8>)FieldLists.resubmit_FL); } @name("._nop") action _nop_3() { } @@ -402,4 +412,3 @@ control computeChecksum(inout headers hdr, inout metadata meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_14_samples_outputs/p414-special-ops-3-bmv2-midend.p4 b/testdata/p4_14_samples_outputs/p414-special-ops-3-bmv2-midend.p4 index 7b2007b5093..fd86c9750ab 100644 --- a/testdata/p4_14_samples_outputs/p414-special-ops-3-bmv2-midend.p4 +++ b/testdata/p4_14_samples_outputs/p414-special-ops-3-bmv2-midend.p4 @@ -10,10 +10,14 @@ struct intrinsic_metadata_t { } struct mymeta_t { + @field_list(8w2) bit<8> resubmit_count; + @field_list(8w1) bit<8> recirculate_count; + @field_list(8w0) bit<8> clone_e2e_count; bit<8> last_ing_instance_type; + @field_list(8w0, 8w1, 8w2) bit<8> f1; } @@ -28,16 +32,20 @@ header ethernet_t { } struct metadata { + @field_list(8w2) bit<8> _mymeta_resubmit_count0; + @field_list(8w1) bit<8> _mymeta_recirculate_count1; + @field_list(8w0) bit<8> _mymeta_clone_e2e_count2; bit<8> _mymeta_last_ing_instance_type3; + @field_list(8w0, 8w1, 8w2) bit<8> _mymeta_f14; bit<48> _temporaries_temp15; } struct headers { - @name(".ethernet") + @name(".ethernet") ethernet_t ethernet; } @@ -51,23 +59,18 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout } } -struct tuple_0 { - bit<8> f0; - bit<8> f1; -} - control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name(".do_clone_e2e") action do_clone_e2e() { hdr.ethernet.srcAddr = hdr.ethernet.srcAddr + 48w281474976710633; meta._mymeta_f14 = meta._mymeta_f14 + 8w23; meta._mymeta_clone_e2e_count2 = meta._mymeta_clone_e2e_count2 + 8w1; - clone3(CloneType.E2E, 32w1, (tuple_0){f0 = meta._mymeta_clone_e2e_count2,f1 = meta._mymeta_f14}); + clone_preserving_field_list(CloneType.E2E, 32w1, 8w0); } @name(".do_recirculate") action do_recirculate() { hdr.ethernet.srcAddr = hdr.ethernet.srcAddr + 48w281474976710637; meta._mymeta_f14 = meta._mymeta_f14 + 8w19; meta._mymeta_recirculate_count1 = meta._mymeta_recirculate_count1 + 8w1; - recirculate((tuple_0){f0 = meta._mymeta_recirculate_count1,f1 = meta._mymeta_f14}); + recirculate_preserving_field_list(8w1); } @name("._nop") action _nop() { } @@ -267,7 +270,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ hdr.ethernet.srcAddr = hdr.ethernet.srcAddr + 48w281474976710639; meta._mymeta_f14 = meta._mymeta_f14 + 8w17; meta._mymeta_resubmit_count0 = meta._mymeta_resubmit_count0 + 8w1; - resubmit((tuple_0){f0 = meta._mymeta_resubmit_count0,f1 = meta._mymeta_f14}); + resubmit_preserving_field_list(8w2); } @name("._nop") action _nop_3() { } @@ -409,4 +412,3 @@ control computeChecksum(inout headers hdr, inout metadata meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_14_samples_outputs/p414-special-ops-3-bmv2.p4 b/testdata/p4_14_samples_outputs/p414-special-ops-3-bmv2.p4 index 4f714c0809a..031587a112c 100644 --- a/testdata/p4_14_samples_outputs/p414-special-ops-3-bmv2.p4 +++ b/testdata/p4_14_samples_outputs/p414-special-ops-3-bmv2.p4 @@ -2,6 +2,12 @@ #define V1MODEL_VERSION 20200408 #include +enum bit<8> FieldLists { + clone_e2e_FL = 0, + recirculate_FL = 1, + resubmit_FL = 2 +} + struct intrinsic_metadata_t { bit<48> ingress_global_timestamp; bit<48> egress_global_timestamp; @@ -10,10 +16,14 @@ struct intrinsic_metadata_t { } struct mymeta_t { + @field_list(FieldLists.resubmit_FL) bit<8> resubmit_count; + @field_list(FieldLists.recirculate_FL) bit<8> recirculate_count; + @field_list(FieldLists.clone_e2e_FL) bit<8> clone_e2e_count; bit<8> last_ing_instance_type; + @field_list(FieldLists.clone_e2e_FL, FieldLists.recirculate_FL, FieldLists.resubmit_FL) bit<8> f1; } @@ -28,14 +38,14 @@ header ethernet_t { } struct metadata { - @name(".mymeta") + @name(".mymeta") mymeta_t mymeta; - @name(".temporaries") + @name(".temporaries") temporaries_t temporaries; } struct headers { - @name(".ethernet") + @name(".ethernet") ethernet_t ethernet; } @@ -54,13 +64,13 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t hdr.ethernet.srcAddr = hdr.ethernet.srcAddr - 48w23; meta.mymeta.f1 = meta.mymeta.f1 + 8w23; meta.mymeta.clone_e2e_count = meta.mymeta.clone_e2e_count + 8w1; - clone3(CloneType.E2E, (bit<32>)32w1, { meta.mymeta.clone_e2e_count, meta.mymeta.f1 }); + clone_preserving_field_list(CloneType.E2E, (bit<32>)32w1, (bit<8>)FieldLists.clone_e2e_FL); } @name(".do_recirculate") action do_recirculate() { hdr.ethernet.srcAddr = hdr.ethernet.srcAddr - 48w19; meta.mymeta.f1 = meta.mymeta.f1 + 8w19; meta.mymeta.recirculate_count = meta.mymeta.recirculate_count + 8w1; - recirculate({ meta.mymeta.recirculate_count, meta.mymeta.f1 }); + recirculate_preserving_field_list((bit<8>)FieldLists.recirculate_FL); } @name("._nop") action _nop() { } @@ -235,7 +245,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ hdr.ethernet.srcAddr = hdr.ethernet.srcAddr - 48w17; meta.mymeta.f1 = meta.mymeta.f1 + 8w17; meta.mymeta.resubmit_count = meta.mymeta.resubmit_count + 8w1; - resubmit({ meta.mymeta.resubmit_count, meta.mymeta.f1 }); + resubmit_preserving_field_list((bit<8>)FieldLists.resubmit_FL); } @name("._nop") action _nop() { } @@ -375,4 +385,3 @@ control computeChecksum(inout headers hdr, inout metadata meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_14_samples_outputs/p414-special-ops-first.p4 b/testdata/p4_14_samples_outputs/p414-special-ops-first.p4 index 296b63682e3..377848928ec 100644 --- a/testdata/p4_14_samples_outputs/p414-special-ops-first.p4 +++ b/testdata/p4_14_samples_outputs/p414-special-ops-first.p4 @@ -2,6 +2,12 @@ #define V1MODEL_VERSION 20200408 #include +enum bit<8> FieldLists { + clone_e2e_FL = 8w0, + recirculate_FL = 8w1, + resubmit_FL = 8w2 +} + struct intrinsic_metadata_t { bit<48> ingress_global_timestamp; bit<48> egress_global_timestamp; @@ -10,10 +16,14 @@ struct intrinsic_metadata_t { } struct mymeta_t { + @field_list(FieldLists.resubmit_FL) bit<8> resubmit_count; + @field_list(FieldLists.recirculate_FL) bit<8> recirculate_count; + @field_list(FieldLists.clone_e2e_FL) bit<8> clone_e2e_count; bit<8> last_ing_instance_type; + @field_list(FieldLists.clone_e2e_FL, FieldLists.recirculate_FL, FieldLists.resubmit_FL) bit<8> f1; } @@ -28,14 +38,14 @@ header ethernet_t { } struct metadata { - @name(".mymeta") + @name(".mymeta") mymeta_t mymeta; - @name(".temporaries") + @name(".temporaries") temporaries_t temporaries; } struct headers { - @name(".ethernet") + @name(".ethernet") ethernet_t ethernet; } @@ -54,13 +64,13 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t hdr.ethernet.srcAddr = hdr.ethernet.srcAddr + 48w281474976710633; meta.mymeta.f1 = meta.mymeta.f1 + 8w23; meta.mymeta.clone_e2e_count = meta.mymeta.clone_e2e_count + 8w1; - clone3, bit<8>>>(CloneType.E2E, 32w1, { meta.mymeta.clone_e2e_count, meta.mymeta.f1 }); + clone_preserving_field_list(CloneType.E2E, 32w1, (bit<8>)FieldLists.clone_e2e_FL); } @name(".do_recirculate") action do_recirculate() { hdr.ethernet.srcAddr = hdr.ethernet.srcAddr + 48w281474976710637; meta.mymeta.f1 = meta.mymeta.f1 + 8w19; meta.mymeta.recirculate_count = meta.mymeta.recirculate_count + 8w1; - recirculate, bit<8>>>({ meta.mymeta.recirculate_count, meta.mymeta.f1 }); + recirculate_preserving_field_list((bit<8>)FieldLists.recirculate_FL); } @name("._nop") action _nop() { } @@ -218,7 +228,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ hdr.ethernet.srcAddr = hdr.ethernet.srcAddr + 48w281474976710639; meta.mymeta.f1 = meta.mymeta.f1 + 8w17; meta.mymeta.resubmit_count = meta.mymeta.resubmit_count + 8w1; - resubmit, bit<8>>>({ meta.mymeta.resubmit_count, meta.mymeta.f1 }); + resubmit_preserving_field_list((bit<8>)FieldLists.resubmit_FL); } @name("._nop") action _nop() { } @@ -346,4 +356,3 @@ control computeChecksum(inout headers hdr, inout metadata meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_14_samples_outputs/p414-special-ops-frontend.p4 b/testdata/p4_14_samples_outputs/p414-special-ops-frontend.p4 index ab18d484045..bd8ecec07c6 100644 --- a/testdata/p4_14_samples_outputs/p414-special-ops-frontend.p4 +++ b/testdata/p4_14_samples_outputs/p414-special-ops-frontend.p4 @@ -2,6 +2,12 @@ #define V1MODEL_VERSION 20200408 #include +enum bit<8> FieldLists { + clone_e2e_FL = 8w0, + recirculate_FL = 8w1, + resubmit_FL = 8w2 +} + struct intrinsic_metadata_t { bit<48> ingress_global_timestamp; bit<48> egress_global_timestamp; @@ -10,10 +16,14 @@ struct intrinsic_metadata_t { } struct mymeta_t { + @field_list(FieldLists.resubmit_FL) bit<8> resubmit_count; + @field_list(FieldLists.recirculate_FL) bit<8> recirculate_count; + @field_list(FieldLists.clone_e2e_FL) bit<8> clone_e2e_count; bit<8> last_ing_instance_type; + @field_list(FieldLists.clone_e2e_FL, FieldLists.recirculate_FL, FieldLists.resubmit_FL) bit<8> f1; } @@ -28,14 +38,14 @@ header ethernet_t { } struct metadata { - @name(".mymeta") + @name(".mymeta") mymeta_t mymeta; - @name(".temporaries") + @name(".temporaries") temporaries_t temporaries; } struct headers { - @name(".ethernet") + @name(".ethernet") ethernet_t ethernet; } @@ -54,13 +64,13 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t hdr.ethernet.srcAddr = hdr.ethernet.srcAddr + 48w281474976710633; meta.mymeta.f1 = meta.mymeta.f1 + 8w23; meta.mymeta.clone_e2e_count = meta.mymeta.clone_e2e_count + 8w1; - clone3, bit<8>>>(CloneType.E2E, 32w1, { meta.mymeta.clone_e2e_count, meta.mymeta.f1 }); + clone_preserving_field_list(CloneType.E2E, 32w1, (bit<8>)FieldLists.clone_e2e_FL); } @name(".do_recirculate") action do_recirculate() { hdr.ethernet.srcAddr = hdr.ethernet.srcAddr + 48w281474976710637; meta.mymeta.f1 = meta.mymeta.f1 + 8w19; meta.mymeta.recirculate_count = meta.mymeta.recirculate_count + 8w1; - recirculate, bit<8>>>({ meta.mymeta.recirculate_count, meta.mymeta.f1 }); + recirculate_preserving_field_list((bit<8>)FieldLists.recirculate_FL); } @name("._nop") action _nop() { } @@ -247,7 +257,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ hdr.ethernet.srcAddr = hdr.ethernet.srcAddr + 48w281474976710639; meta.mymeta.f1 = meta.mymeta.f1 + 8w17; meta.mymeta.resubmit_count = meta.mymeta.resubmit_count + 8w1; - resubmit, bit<8>>>({ meta.mymeta.resubmit_count, meta.mymeta.f1 }); + resubmit_preserving_field_list((bit<8>)FieldLists.resubmit_FL); } @name("._nop") action _nop_3() { } @@ -377,4 +387,3 @@ control computeChecksum(inout headers hdr, inout metadata meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_14_samples_outputs/p414-special-ops-midend.p4 b/testdata/p4_14_samples_outputs/p414-special-ops-midend.p4 index 41fda9fc3c2..6dfcc70babb 100644 --- a/testdata/p4_14_samples_outputs/p414-special-ops-midend.p4 +++ b/testdata/p4_14_samples_outputs/p414-special-ops-midend.p4 @@ -10,10 +10,14 @@ struct intrinsic_metadata_t { } struct mymeta_t { + @field_list(8w2) bit<8> resubmit_count; + @field_list(8w1) bit<8> recirculate_count; + @field_list(8w0) bit<8> clone_e2e_count; bit<8> last_ing_instance_type; + @field_list(8w0, 8w1, 8w2) bit<8> f1; } @@ -28,16 +32,20 @@ header ethernet_t { } struct metadata { + @field_list(8w2) bit<8> _mymeta_resubmit_count0; + @field_list(8w1) bit<8> _mymeta_recirculate_count1; + @field_list(8w0) bit<8> _mymeta_clone_e2e_count2; bit<8> _mymeta_last_ing_instance_type3; + @field_list(8w0, 8w1, 8w2) bit<8> _mymeta_f14; bit<48> _temporaries_temp15; } struct headers { - @name(".ethernet") + @name(".ethernet") ethernet_t ethernet; } @@ -51,23 +59,18 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout } } -struct tuple_0 { - bit<8> f0; - bit<8> f1; -} - control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name(".do_clone_e2e") action do_clone_e2e() { hdr.ethernet.srcAddr = hdr.ethernet.srcAddr + 48w281474976710633; meta._mymeta_f14 = meta._mymeta_f14 + 8w23; meta._mymeta_clone_e2e_count2 = meta._mymeta_clone_e2e_count2 + 8w1; - clone3(CloneType.E2E, 32w1, (tuple_0){f0 = meta._mymeta_clone_e2e_count2,f1 = meta._mymeta_f14}); + clone_preserving_field_list(CloneType.E2E, 32w1, 8w0); } @name(".do_recirculate") action do_recirculate() { hdr.ethernet.srcAddr = hdr.ethernet.srcAddr + 48w281474976710637; meta._mymeta_f14 = meta._mymeta_f14 + 8w19; meta._mymeta_recirculate_count1 = meta._mymeta_recirculate_count1 + 8w1; - recirculate((tuple_0){f0 = meta._mymeta_recirculate_count1,f1 = meta._mymeta_f14}); + recirculate_preserving_field_list(8w1); } @name("._nop") action _nop() { } @@ -254,7 +257,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ hdr.ethernet.srcAddr = hdr.ethernet.srcAddr + 48w281474976710639; meta._mymeta_f14 = meta._mymeta_f14 + 8w17; meta._mymeta_resubmit_count0 = meta._mymeta_resubmit_count0 + 8w1; - resubmit((tuple_0){f0 = meta._mymeta_resubmit_count0,f1 = meta._mymeta_f14}); + resubmit_preserving_field_list(8w2); } @name("._nop") action _nop_3() { } @@ -384,4 +387,3 @@ control computeChecksum(inout headers hdr, inout metadata meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_14_samples_outputs/p414-special-ops.p4 b/testdata/p4_14_samples_outputs/p414-special-ops.p4 index 777dd682b61..8cef4098714 100644 --- a/testdata/p4_14_samples_outputs/p414-special-ops.p4 +++ b/testdata/p4_14_samples_outputs/p414-special-ops.p4 @@ -2,6 +2,12 @@ #define V1MODEL_VERSION 20200408 #include +enum bit<8> FieldLists { + clone_e2e_FL = 0, + recirculate_FL = 1, + resubmit_FL = 2 +} + struct intrinsic_metadata_t { bit<48> ingress_global_timestamp; bit<48> egress_global_timestamp; @@ -10,10 +16,14 @@ struct intrinsic_metadata_t { } struct mymeta_t { + @field_list(FieldLists.resubmit_FL) bit<8> resubmit_count; + @field_list(FieldLists.recirculate_FL) bit<8> recirculate_count; + @field_list(FieldLists.clone_e2e_FL) bit<8> clone_e2e_count; bit<8> last_ing_instance_type; + @field_list(FieldLists.clone_e2e_FL, FieldLists.recirculate_FL, FieldLists.resubmit_FL) bit<8> f1; } @@ -28,14 +38,14 @@ header ethernet_t { } struct metadata { - @name(".mymeta") + @name(".mymeta") mymeta_t mymeta; - @name(".temporaries") + @name(".temporaries") temporaries_t temporaries; } struct headers { - @name(".ethernet") + @name(".ethernet") ethernet_t ethernet; } @@ -54,13 +64,13 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t hdr.ethernet.srcAddr = hdr.ethernet.srcAddr - 48w23; meta.mymeta.f1 = meta.mymeta.f1 + 8w23; meta.mymeta.clone_e2e_count = meta.mymeta.clone_e2e_count + 8w1; - clone3(CloneType.E2E, (bit<32>)32w1, { meta.mymeta.clone_e2e_count, meta.mymeta.f1 }); + clone_preserving_field_list(CloneType.E2E, (bit<32>)32w1, (bit<8>)FieldLists.clone_e2e_FL); } @name(".do_recirculate") action do_recirculate() { hdr.ethernet.srcAddr = hdr.ethernet.srcAddr - 48w19; meta.mymeta.f1 = meta.mymeta.f1 + 8w19; meta.mymeta.recirculate_count = meta.mymeta.recirculate_count + 8w1; - recirculate({ meta.mymeta.recirculate_count, meta.mymeta.f1 }); + recirculate_preserving_field_list((bit<8>)FieldLists.recirculate_FL); } @name("._nop") action _nop() { } @@ -222,7 +232,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ hdr.ethernet.srcAddr = hdr.ethernet.srcAddr - 48w17; meta.mymeta.f1 = meta.mymeta.f1 + 8w17; meta.mymeta.resubmit_count = meta.mymeta.resubmit_count + 8w1; - resubmit({ meta.mymeta.resubmit_count, meta.mymeta.f1 }); + resubmit_preserving_field_list((bit<8>)FieldLists.resubmit_FL); } @name("._nop") action _nop() { } @@ -350,4 +360,3 @@ control computeChecksum(inout headers hdr, inout metadata meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_14_samples_outputs/packet_redirect-first.p4 b/testdata/p4_14_samples_outputs/packet_redirect-first.p4 index b7dff2ae776..0efa358d4e2 100644 --- a/testdata/p4_14_samples_outputs/packet_redirect-first.p4 +++ b/testdata/p4_14_samples_outputs/packet_redirect-first.p4 @@ -2,6 +2,10 @@ #define V1MODEL_VERSION 20200408 #include +enum bit<8> FieldLists { + redirect_FL = 8w0 +} + struct intrinsic_metadata_t { bit<16> mcast_grp; bit<4> egress_rid; @@ -9,7 +13,9 @@ struct intrinsic_metadata_t { } struct metaA_t { + @field_list(FieldLists.redirect_FL) bit<8> f1; + @field_list(FieldLists.redirect_FL) bit<8> f2; } @@ -24,14 +30,14 @@ header hdrA_t { } struct metadata { - @name(".metaA") + @name(".metaA") metaA_t metaA; - @name(".metaB") + @name(".metaB") metaB_t metaB; } struct headers { - @name(".hdrA") + @name(".hdrA") hdrA_t hdrA; } @@ -46,10 +52,10 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t @name("._nop") action _nop() { } @name("._recirculate") action _recirculate() { - recirculate>({ standard_metadata, meta.metaA }); + recirculate_preserving_field_list((bit<8>)FieldLists.redirect_FL); } @name("._clone_e2e") action _clone_e2e(bit<32> mirror_id) { - clone3>(CloneType.E2E, mirror_id, { standard_metadata, meta.metaA }); + clone_preserving_field_list(CloneType.E2E, mirror_id, (bit<8>)FieldLists.redirect_FL); } @name(".t_egress") table t_egress { actions = { @@ -81,10 +87,10 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ standard_metadata.mcast_grp = mgrp; } @name("._resubmit") action _resubmit() { - resubmit>({ standard_metadata, meta.metaA }); + resubmit_preserving_field_list((bit<8>)FieldLists.redirect_FL); } @name("._clone_i2e") action _clone_i2e(bit<32> mirror_id) { - clone3>(CloneType.I2E, mirror_id, { standard_metadata, meta.metaA }); + clone_preserving_field_list(CloneType.I2E, mirror_id, (bit<8>)FieldLists.redirect_FL); } @name(".t_ingress_1") table t_ingress_1 { actions = { @@ -137,4 +143,3 @@ control computeChecksum(inout headers hdr, inout metadata meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_14_samples_outputs/packet_redirect-frontend.p4 b/testdata/p4_14_samples_outputs/packet_redirect-frontend.p4 index 4e07d9280e2..65a6aad4903 100644 --- a/testdata/p4_14_samples_outputs/packet_redirect-frontend.p4 +++ b/testdata/p4_14_samples_outputs/packet_redirect-frontend.p4 @@ -2,6 +2,10 @@ #define V1MODEL_VERSION 20200408 #include +enum bit<8> FieldLists { + redirect_FL = 8w0 +} + struct intrinsic_metadata_t { bit<16> mcast_grp; bit<4> egress_rid; @@ -9,7 +13,9 @@ struct intrinsic_metadata_t { } struct metaA_t { + @field_list(FieldLists.redirect_FL) bit<8> f1; + @field_list(FieldLists.redirect_FL) bit<8> f2; } @@ -24,14 +30,14 @@ header hdrA_t { } struct metadata { - @name(".metaA") + @name(".metaA") metaA_t metaA; - @name(".metaB") + @name(".metaB") metaB_t metaB; } struct headers { - @name(".hdrA") + @name(".hdrA") hdrA_t hdrA; } @@ -48,10 +54,10 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t @name("._nop") action _nop() { } @name("._recirculate") action _recirculate() { - recirculate>({ standard_metadata, meta.metaA }); + recirculate_preserving_field_list((bit<8>)FieldLists.redirect_FL); } @name("._clone_e2e") action _clone_e2e(@name("mirror_id") bit<32> mirror_id) { - clone3>(CloneType.E2E, mirror_id, { standard_metadata, meta.metaA }); + clone_preserving_field_list(CloneType.E2E, mirror_id, (bit<8>)FieldLists.redirect_FL); } @name(".t_egress") table t_egress_0 { actions = { @@ -89,10 +95,10 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ standard_metadata.mcast_grp = mgrp; } @name("._resubmit") action _resubmit() { - resubmit>({ standard_metadata, meta.metaA }); + resubmit_preserving_field_list((bit<8>)FieldLists.redirect_FL); } @name("._clone_i2e") action _clone_i2e(@name("mirror_id") bit<32> mirror_id_2) { - clone3>(CloneType.I2E, mirror_id_2, { standard_metadata, meta.metaA }); + clone_preserving_field_list(CloneType.I2E, mirror_id_2, (bit<8>)FieldLists.redirect_FL); } @name(".t_ingress_1") table t_ingress { actions = { @@ -145,4 +151,3 @@ control computeChecksum(inout headers hdr, inout metadata meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_14_samples_outputs/packet_redirect-midend.p4 b/testdata/p4_14_samples_outputs/packet_redirect-midend.p4 index cf7478723cc..153ab27d883 100644 --- a/testdata/p4_14_samples_outputs/packet_redirect-midend.p4 +++ b/testdata/p4_14_samples_outputs/packet_redirect-midend.p4 @@ -9,7 +9,9 @@ struct intrinsic_metadata_t { } struct metaA_t { + @field_list(8w0) bit<8> f1; + @field_list(8w0) bit<8> f2; } @@ -24,14 +26,16 @@ header hdrA_t { } struct metadata { + @field_list(8w0) bit<8> _metaA_f10; + @field_list(8w0) bit<8> _metaA_f21; bit<8> _metaB_f12; bit<8> _metaB_f23; } struct headers { - @name(".hdrA") + @name(".hdrA") hdrA_t hdrA; } @@ -42,21 +46,16 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout } } -struct tuple_0 { - standard_metadata_t f0; - metaA_t f1; -} - control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @noWarn("unused") @name(".NoAction") action NoAction_2() { } @name("._nop") action _nop() { } @name("._recirculate") action _recirculate() { - recirculate((tuple_0){f0 = standard_metadata,f1 = (metaA_t){f1 = meta._metaA_f10,f2 = meta._metaA_f21}}); + recirculate_preserving_field_list(8w0); } @name("._clone_e2e") action _clone_e2e(@name("mirror_id") bit<32> mirror_id) { - clone3(CloneType.E2E, mirror_id, (tuple_0){f0 = standard_metadata,f1 = (metaA_t){f1 = meta._metaA_f10,f2 = meta._metaA_f21}}); + clone_preserving_field_list(CloneType.E2E, mirror_id, 8w0); } @name(".t_egress") table t_egress_0 { actions = { @@ -94,10 +93,10 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ standard_metadata.mcast_grp = mgrp; } @name("._resubmit") action _resubmit() { - resubmit((tuple_0){f0 = standard_metadata,f1 = (metaA_t){f1 = meta._metaA_f10,f2 = meta._metaA_f21}}); + resubmit_preserving_field_list(8w0); } @name("._clone_i2e") action _clone_i2e(@name("mirror_id") bit<32> mirror_id_2) { - clone3(CloneType.I2E, mirror_id_2, (tuple_0){f0 = standard_metadata,f1 = (metaA_t){f1 = meta._metaA_f10,f2 = meta._metaA_f21}}); + clone_preserving_field_list(CloneType.I2E, mirror_id_2, 8w0); } @name(".t_ingress_1") table t_ingress { actions = { @@ -150,4 +149,3 @@ control computeChecksum(inout headers hdr, inout metadata meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_14_samples_outputs/packet_redirect.p4 b/testdata/p4_14_samples_outputs/packet_redirect.p4 index cdecf1846ed..57c191464a4 100644 --- a/testdata/p4_14_samples_outputs/packet_redirect.p4 +++ b/testdata/p4_14_samples_outputs/packet_redirect.p4 @@ -2,6 +2,10 @@ #define V1MODEL_VERSION 20200408 #include +enum bit<8> FieldLists { + redirect_FL = 0 +} + struct intrinsic_metadata_t { bit<16> mcast_grp; bit<4> egress_rid; @@ -9,7 +13,9 @@ struct intrinsic_metadata_t { } struct metaA_t { + @field_list(FieldLists.redirect_FL) bit<8> f1; + @field_list(FieldLists.redirect_FL) bit<8> f2; } @@ -24,14 +30,14 @@ header hdrA_t { } struct metadata { - @name(".metaA") + @name(".metaA") metaA_t metaA; - @name(".metaB") + @name(".metaB") metaB_t metaB; } struct headers { - @name(".hdrA") + @name(".hdrA") hdrA_t hdrA; } @@ -46,10 +52,10 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t @name("._nop") action _nop() { } @name("._recirculate") action _recirculate() { - recirculate({ standard_metadata, meta.metaA }); + recirculate_preserving_field_list((bit<8>)FieldLists.redirect_FL); } @name("._clone_e2e") action _clone_e2e(bit<32> mirror_id) { - clone3(CloneType.E2E, (bit<32>)mirror_id, { standard_metadata, meta.metaA }); + clone_preserving_field_list(CloneType.E2E, (bit<32>)mirror_id, (bit<8>)FieldLists.redirect_FL); } @name(".t_egress") table t_egress { actions = { @@ -79,10 +85,10 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ standard_metadata.mcast_grp = mgrp; } @name("._resubmit") action _resubmit() { - resubmit({ standard_metadata, meta.metaA }); + resubmit_preserving_field_list((bit<8>)FieldLists.redirect_FL); } @name("._clone_i2e") action _clone_i2e(bit<32> mirror_id) { - clone3(CloneType.I2E, (bit<32>)mirror_id, { standard_metadata, meta.metaA }); + clone_preserving_field_list(CloneType.I2E, (bit<32>)mirror_id, (bit<8>)FieldLists.redirect_FL); } @name(".t_ingress_1") table t_ingress_1 { actions = { @@ -131,4 +137,3 @@ control computeChecksum(inout headers hdr, inout metadata meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_14_samples_outputs/resubmit-first.p4 b/testdata/p4_14_samples_outputs/resubmit-first.p4 index 17fcdc18135..7fad2ed29ed 100644 --- a/testdata/p4_14_samples_outputs/resubmit-first.p4 +++ b/testdata/p4_14_samples_outputs/resubmit-first.p4 @@ -2,12 +2,17 @@ #define V1MODEL_VERSION 20200408 #include +enum bit<8> FieldLists { + resubmit_FL = 8w0 +} + struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; } struct mymeta_t { + @field_list(FieldLists.resubmit_FL) bit<8> f1; } @@ -50,7 +55,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } @name("._resubmit") action _resubmit() { meta.mymeta.f1 = 8w1; - resubmit>({ standard_metadata, meta.mymeta }); + resubmit_preserving_field_list((bit<8>)FieldLists.resubmit_FL); } @name(".t_ingress_1") table t_ingress_1 { actions = { diff --git a/testdata/p4_14_samples_outputs/resubmit-frontend.p4 b/testdata/p4_14_samples_outputs/resubmit-frontend.p4 index 1c42a332ee2..02a382f5cd6 100644 --- a/testdata/p4_14_samples_outputs/resubmit-frontend.p4 +++ b/testdata/p4_14_samples_outputs/resubmit-frontend.p4 @@ -2,12 +2,17 @@ #define V1MODEL_VERSION 20200408 #include +enum bit<8> FieldLists { + resubmit_FL = 8w0 +} + struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; } struct mymeta_t { + @field_list(FieldLists.resubmit_FL) bit<8> f1; } @@ -56,7 +61,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } @name("._resubmit") action _resubmit() { meta.mymeta.f1 = 8w1; - resubmit>({ standard_metadata, meta.mymeta }); + resubmit_preserving_field_list((bit<8>)FieldLists.resubmit_FL); } @name(".t_ingress_1") table t_ingress { actions = { diff --git a/testdata/p4_14_samples_outputs/resubmit-midend.p4 b/testdata/p4_14_samples_outputs/resubmit-midend.p4 index 222bb6c0a21..bdc242f73f8 100644 --- a/testdata/p4_14_samples_outputs/resubmit-midend.p4 +++ b/testdata/p4_14_samples_outputs/resubmit-midend.p4 @@ -8,6 +8,7 @@ struct intrinsic_metadata_t { } struct mymeta_t { + @field_list(8w0) bit<8> f1; } @@ -18,6 +19,7 @@ header ethernet_t { } struct metadata { + @field_list(8w0) bit<8> _mymeta_f10; } @@ -41,11 +43,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } } -struct tuple_0 { - standard_metadata_t f0; - mymeta_t f1; -} - control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @noWarn("unused") @name(".NoAction") action NoAction_1() { } @@ -60,7 +57,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } @name("._resubmit") action _resubmit() { meta._mymeta_f10 = 8w1; - resubmit((tuple_0){f0 = standard_metadata,f1 = (mymeta_t){f1 = 8w1}}); + resubmit_preserving_field_list(8w0); } @name(".t_ingress_1") table t_ingress { actions = { diff --git a/testdata/p4_14_samples_outputs/resubmit.p4 b/testdata/p4_14_samples_outputs/resubmit.p4 index caf543277b4..91ef7319be3 100644 --- a/testdata/p4_14_samples_outputs/resubmit.p4 +++ b/testdata/p4_14_samples_outputs/resubmit.p4 @@ -2,12 +2,17 @@ #define V1MODEL_VERSION 20200408 #include +enum bit<8> FieldLists { + resubmit_FL = 0 +} + struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; } struct mymeta_t { + @field_list(FieldLists.resubmit_FL) bit<8> f1; } @@ -50,7 +55,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } @name("._resubmit") action _resubmit() { meta.mymeta.f1 = 8w1; - resubmit({ standard_metadata, meta.mymeta }); + resubmit_preserving_field_list((bit<8>)FieldLists.resubmit_FL); } @name(".t_ingress_1") table t_ingress_1 { actions = { diff --git a/testdata/p4_14_samples_outputs/simple_nat-first.p4 b/testdata/p4_14_samples_outputs/simple_nat-first.p4 index 81f4d09f08f..a0764431d9b 100644 --- a/testdata/p4_14_samples_outputs/simple_nat-first.p4 +++ b/testdata/p4_14_samples_outputs/simple_nat-first.p4 @@ -2,6 +2,10 @@ #define V1MODEL_VERSION 20200408 #include +enum bit<8> FieldLists { + copy_to_cpu_fields = 8w0 +} + struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; @@ -63,18 +67,18 @@ header tcp_t { } struct metadata { - @name(".meta") + @name(".meta") meta_t meta; } struct headers { - @name(".cpu_header") + @name(".cpu_header") cpu_header_t cpu_header; - @name(".ethernet") + @name(".ethernet") ethernet_t ethernet; - @name(".ipv4") + @name(".ipv4") ipv4_t ipv4; - @name(".tcp") + @name(".tcp") tcp_t tcp; } @@ -181,7 +185,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ hdr.ipv4.ttl = hdr.ipv4.ttl + 8w255; } @name(".nat_miss_int_to_ext") action nat_miss_int_to_ext() { - clone3>(CloneType.I2E, 32w250, { standard_metadata }); + clone_preserving_field_list(CloneType.I2E, 32w250, (bit<8>)FieldLists.copy_to_cpu_fields); } @name(".nat_miss_ext_to_int") action nat_miss_ext_to_int() { meta.meta.do_forward = 1w0; @@ -291,4 +295,3 @@ control computeChecksum(inout headers hdr, inout metadata meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_14_samples_outputs/simple_nat-frontend.p4 b/testdata/p4_14_samples_outputs/simple_nat-frontend.p4 index b7b10219fdc..9115443aa44 100644 --- a/testdata/p4_14_samples_outputs/simple_nat-frontend.p4 +++ b/testdata/p4_14_samples_outputs/simple_nat-frontend.p4 @@ -2,6 +2,10 @@ #define V1MODEL_VERSION 20200408 #include +enum bit<8> FieldLists { + copy_to_cpu_fields = 8w0 +} + struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; @@ -63,18 +67,18 @@ header tcp_t { } struct metadata { - @name(".meta") + @name(".meta") meta_t meta; } struct headers { - @name(".cpu_header") + @name(".cpu_header") cpu_header_t cpu_header; - @name(".ethernet") + @name(".ethernet") ethernet_t ethernet; - @name(".ipv4") + @name(".ipv4") ipv4_t ipv4; - @name(".tcp") + @name(".tcp") tcp_t tcp; } @@ -206,7 +210,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ hdr.ipv4.ttl = hdr.ipv4.ttl + 8w255; } @name(".nat_miss_int_to_ext") action nat_miss_int_to_ext() { - clone3>(CloneType.I2E, 32w250, { standard_metadata }); + clone_preserving_field_list(CloneType.I2E, 32w250, (bit<8>)FieldLists.copy_to_cpu_fields); } @name(".nat_miss_ext_to_int") action nat_miss_ext_to_int() { meta.meta.do_forward = 1w0; @@ -316,4 +320,3 @@ control computeChecksum(inout headers hdr, inout metadata meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_14_samples_outputs/simple_nat-midend.p4 b/testdata/p4_14_samples_outputs/simple_nat-midend.p4 index 820deef3db1..d7d2b3e64fc 100644 --- a/testdata/p4_14_samples_outputs/simple_nat-midend.p4 +++ b/testdata/p4_14_samples_outputs/simple_nat-midend.p4 @@ -77,13 +77,13 @@ struct metadata { } struct headers { - @name(".cpu_header") + @name(".cpu_header") cpu_header_t cpu_header; - @name(".ethernet") + @name(".ethernet") ethernet_t ethernet; - @name(".ipv4") + @name(".ipv4") ipv4_t ipv4; - @name(".tcp") + @name(".tcp") tcp_t tcp; } @@ -178,10 +178,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } } -struct tuple_0 { - standard_metadata_t f0; -} - control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @noWarn("unused") @name(".NoAction") action NoAction_4() { } @@ -217,7 +213,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ hdr.ipv4.ttl = hdr.ipv4.ttl + 8w255; } @name(".nat_miss_int_to_ext") action nat_miss_int_to_ext() { - clone3(CloneType.I2E, 32w250, (tuple_0){f0 = standard_metadata}); + clone_preserving_field_list(CloneType.I2E, 32w250, 8w0); } @name(".nat_miss_ext_to_int") action nat_miss_ext_to_int() { meta._meta_do_forward0 = 1w0; @@ -312,7 +308,7 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct tuple_1 { +struct tuple_0 { bit<4> f0; bit<4> f1; bit<8> f2; @@ -326,7 +322,7 @@ struct tuple_1 { bit<32> f10; } -struct tuple_2 { +struct tuple_1 { bit<32> f0; bit<32> f1; bit<8> f2; @@ -345,17 +341,16 @@ struct tuple_2 { control verifyChecksum(inout headers hdr, inout metadata meta) { apply { - verify_checksum>(true, (tuple_1){f0 = hdr.ipv4.version,f1 = hdr.ipv4.ihl,f2 = hdr.ipv4.diffserv,f3 = hdr.ipv4.totalLen,f4 = hdr.ipv4.identification,f5 = hdr.ipv4.flags,f6 = hdr.ipv4.fragOffset,f7 = hdr.ipv4.ttl,f8 = hdr.ipv4.protocol,f9 = hdr.ipv4.srcAddr,f10 = hdr.ipv4.dstAddr}, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); - verify_checksum_with_payload>(hdr.tcp.isValid(), (tuple_2){f0 = hdr.ipv4.srcAddr,f1 = hdr.ipv4.dstAddr,f2 = 8w0,f3 = hdr.ipv4.protocol,f4 = meta._meta_tcpLength9,f5 = hdr.tcp.srcPort,f6 = hdr.tcp.dstPort,f7 = hdr.tcp.seqNo,f8 = hdr.tcp.ackNo,f9 = hdr.tcp.dataOffset,f10 = hdr.tcp.res,f11 = hdr.tcp.flags,f12 = hdr.tcp.window,f13 = hdr.tcp.urgentPtr}, hdr.tcp.checksum, HashAlgorithm.csum16); + verify_checksum>(true, (tuple_0){f0 = hdr.ipv4.version,f1 = hdr.ipv4.ihl,f2 = hdr.ipv4.diffserv,f3 = hdr.ipv4.totalLen,f4 = hdr.ipv4.identification,f5 = hdr.ipv4.flags,f6 = hdr.ipv4.fragOffset,f7 = hdr.ipv4.ttl,f8 = hdr.ipv4.protocol,f9 = hdr.ipv4.srcAddr,f10 = hdr.ipv4.dstAddr}, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); + verify_checksum_with_payload>(hdr.tcp.isValid(), (tuple_1){f0 = hdr.ipv4.srcAddr,f1 = hdr.ipv4.dstAddr,f2 = 8w0,f3 = hdr.ipv4.protocol,f4 = meta._meta_tcpLength9,f5 = hdr.tcp.srcPort,f6 = hdr.tcp.dstPort,f7 = hdr.tcp.seqNo,f8 = hdr.tcp.ackNo,f9 = hdr.tcp.dataOffset,f10 = hdr.tcp.res,f11 = hdr.tcp.flags,f12 = hdr.tcp.window,f13 = hdr.tcp.urgentPtr}, hdr.tcp.checksum, HashAlgorithm.csum16); } } control computeChecksum(inout headers hdr, inout metadata meta) { apply { - update_checksum>(true, (tuple_1){f0 = hdr.ipv4.version,f1 = hdr.ipv4.ihl,f2 = hdr.ipv4.diffserv,f3 = hdr.ipv4.totalLen,f4 = hdr.ipv4.identification,f5 = hdr.ipv4.flags,f6 = hdr.ipv4.fragOffset,f7 = hdr.ipv4.ttl,f8 = hdr.ipv4.protocol,f9 = hdr.ipv4.srcAddr,f10 = hdr.ipv4.dstAddr}, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); - update_checksum_with_payload>(hdr.tcp.isValid(), (tuple_2){f0 = hdr.ipv4.srcAddr,f1 = hdr.ipv4.dstAddr,f2 = 8w0,f3 = hdr.ipv4.protocol,f4 = meta._meta_tcpLength9,f5 = hdr.tcp.srcPort,f6 = hdr.tcp.dstPort,f7 = hdr.tcp.seqNo,f8 = hdr.tcp.ackNo,f9 = hdr.tcp.dataOffset,f10 = hdr.tcp.res,f11 = hdr.tcp.flags,f12 = hdr.tcp.window,f13 = hdr.tcp.urgentPtr}, hdr.tcp.checksum, HashAlgorithm.csum16); + update_checksum>(true, (tuple_0){f0 = hdr.ipv4.version,f1 = hdr.ipv4.ihl,f2 = hdr.ipv4.diffserv,f3 = hdr.ipv4.totalLen,f4 = hdr.ipv4.identification,f5 = hdr.ipv4.flags,f6 = hdr.ipv4.fragOffset,f7 = hdr.ipv4.ttl,f8 = hdr.ipv4.protocol,f9 = hdr.ipv4.srcAddr,f10 = hdr.ipv4.dstAddr}, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); + update_checksum_with_payload>(hdr.tcp.isValid(), (tuple_1){f0 = hdr.ipv4.srcAddr,f1 = hdr.ipv4.dstAddr,f2 = 8w0,f3 = hdr.ipv4.protocol,f4 = meta._meta_tcpLength9,f5 = hdr.tcp.srcPort,f6 = hdr.tcp.dstPort,f7 = hdr.tcp.seqNo,f8 = hdr.tcp.ackNo,f9 = hdr.tcp.dataOffset,f10 = hdr.tcp.res,f11 = hdr.tcp.flags,f12 = hdr.tcp.window,f13 = hdr.tcp.urgentPtr}, hdr.tcp.checksum, HashAlgorithm.csum16); } } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_14_samples_outputs/simple_nat.p4 b/testdata/p4_14_samples_outputs/simple_nat.p4 index 54cec7446e9..5108e7cc524 100644 --- a/testdata/p4_14_samples_outputs/simple_nat.p4 +++ b/testdata/p4_14_samples_outputs/simple_nat.p4 @@ -2,6 +2,10 @@ #define V1MODEL_VERSION 20200408 #include +enum bit<8> FieldLists { + copy_to_cpu_fields = 0 +} + struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; @@ -63,18 +67,18 @@ header tcp_t { } struct metadata { - @name(".meta") + @name(".meta") meta_t meta; } struct headers { - @name(".cpu_header") + @name(".cpu_header") cpu_header_t cpu_header; - @name(".ethernet") + @name(".ethernet") ethernet_t ethernet; - @name(".ipv4") + @name(".ipv4") ipv4_t ipv4; - @name(".tcp") + @name(".tcp") tcp_t tcp; } @@ -177,7 +181,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ hdr.ipv4.ttl = hdr.ipv4.ttl - 8w1; } @name(".nat_miss_int_to_ext") action nat_miss_int_to_ext() { - clone3(CloneType.I2E, (bit<32>)32w250, { standard_metadata }); + clone_preserving_field_list(CloneType.I2E, (bit<32>)32w250, (bit<8>)FieldLists.copy_to_cpu_fields); } @name(".nat_miss_ext_to_int") action nat_miss_ext_to_int() { meta.meta.do_forward = 1w0; @@ -279,4 +283,3 @@ control computeChecksum(inout headers hdr, inout metadata meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_14_samples_outputs/switch_20160512/switch-first.p4 b/testdata/p4_14_samples_outputs/switch_20160512/switch-first.p4 index 17bfb1e3582..540fd030179 100644 --- a/testdata/p4_14_samples_outputs/switch_20160512/switch-first.p4 +++ b/testdata/p4_14_samples_outputs/switch_20160512/switch-first.p4 @@ -2,6 +2,15 @@ #define V1MODEL_VERSION 20200408 #include +enum bit<8> FieldLists { + i2e_mirror_info = 8w0, + cpu_info = 8w1, + e2e_mirror_info = 8w2, + int_i2e_mirror_info = 8w3, + mirror_info = 8w4, + sflow_cpu_info = 8w5 +} + struct acl_metadata_t { bit<1> acl_deny; bit<1> acl_copy; @@ -40,6 +49,7 @@ struct egress_metadata_t { struct fabric_metadata_t { bit<3> packetType; bit<1> fabric_header_present; + @field_list(FieldLists.cpu_info, FieldLists.sflow_cpu_info) bit<16> reason_code; bit<8> dst_device; bit<16> dst_port; @@ -56,22 +66,28 @@ struct hash_metadata_t { } struct i2e_metadata_t { + @field_list(FieldLists.i2e_mirror_info, FieldLists.e2e_mirror_info) bit<32> ingress_tstamp; + @field_list(FieldLists.i2e_mirror_info, FieldLists.e2e_mirror_info, FieldLists.int_i2e_mirror_info) bit<16> mirror_session_id; } struct ingress_metadata_t { + @field_list(FieldLists.cpu_info, FieldLists.sflow_cpu_info) bit<9> ingress_port; + @field_list(FieldLists.cpu_info, FieldLists.mirror_info, FieldLists.sflow_cpu_info) bit<16> ifindex; bit<16> egress_ifindex; bit<2> port_type; bit<16> outer_bd; + @field_list(FieldLists.cpu_info, FieldLists.sflow_cpu_info) bit<16> bd; bit<1> drop_flag; + @field_list(FieldLists.mirror_info) bit<8> drop_reason; bit<1> control_frame; bit<16> bypass_lookups; - @saturating + @saturating bit<32> sflow_take_sample; } @@ -85,6 +101,7 @@ struct int_metadata_t { } struct int_metadata_i2e_t { + @field_list(FieldLists.int_i2e_mirror_info) bit<1> sink; bit<1> source; } @@ -155,7 +172,7 @@ struct l3_metadata_t { bit<1> outer_routed; bit<8> mtu_index; bit<1> l3_copy; - @saturating + @saturating bit<16> l3_mtu_check; } @@ -640,166 +657,166 @@ header vlan_tag_t { } struct metadata { - @name(".acl_metadata") + @name(".acl_metadata") acl_metadata_t acl_metadata; - @name(".egress_filter_metadata") + @name(".egress_filter_metadata") egress_filter_metadata_t egress_filter_metadata; - @name(".egress_metadata") + @name(".egress_metadata") egress_metadata_t egress_metadata; - @name(".fabric_metadata") + @name(".fabric_metadata") fabric_metadata_t fabric_metadata; - @name(".global_config_metadata") + @name(".global_config_metadata") global_config_metadata_t global_config_metadata; - @name(".hash_metadata") + @name(".hash_metadata") hash_metadata_t hash_metadata; - @name(".i2e_metadata") + @name(".i2e_metadata") i2e_metadata_t i2e_metadata; - @name(".ingress_metadata") + @name(".ingress_metadata") ingress_metadata_t ingress_metadata; - @name(".int_metadata") + @name(".int_metadata") int_metadata_t int_metadata; - @name(".int_metadata_i2e") + @name(".int_metadata_i2e") int_metadata_i2e_t int_metadata_i2e; - @name(".ipv4_metadata") + @name(".ipv4_metadata") ipv4_metadata_t ipv4_metadata; - @name(".ipv6_metadata") + @name(".ipv6_metadata") ipv6_metadata_t ipv6_metadata; - @name(".l2_metadata") + @name(".l2_metadata") l2_metadata_t l2_metadata; - @name(".l3_metadata") + @name(".l3_metadata") l3_metadata_t l3_metadata; - @name(".meter_metadata") + @name(".meter_metadata") meter_metadata_t meter_metadata; - @name(".multicast_metadata") + @name(".multicast_metadata") multicast_metadata_t multicast_metadata; - @name(".nexthop_metadata") + @name(".nexthop_metadata") nexthop_metadata_t nexthop_metadata; - @name(".qos_metadata") + @name(".qos_metadata") qos_metadata_t qos_metadata; - @name(".security_metadata") + @name(".security_metadata") security_metadata_t security_metadata; - @name(".sflow_metadata") + @name(".sflow_metadata") sflow_meta_t sflow_metadata; - @name(".tunnel_metadata") + @name(".tunnel_metadata") tunnel_metadata_t tunnel_metadata; } struct headers { - @name(".arp_rarp") + @name(".arp_rarp") arp_rarp_t arp_rarp; - @name(".arp_rarp_ipv4") + @name(".arp_rarp_ipv4") arp_rarp_ipv4_t arp_rarp_ipv4; - @name(".bfd") + @name(".bfd") bfd_t bfd; - @name(".eompls") + @name(".eompls") eompls_t eompls; - @name(".erspan_t3_header") + @name(".erspan_t3_header") erspan_header_t3_t_0 erspan_t3_header; - @name(".ethernet") + @name(".ethernet") ethernet_t ethernet; - @name(".fabric_header") + @name(".fabric_header") fabric_header_t fabric_header; - @name(".fabric_header_cpu") + @name(".fabric_header_cpu") fabric_header_cpu_t fabric_header_cpu; - @name(".fabric_header_mirror") + @name(".fabric_header_mirror") fabric_header_mirror_t fabric_header_mirror; - @name(".fabric_header_multicast") + @name(".fabric_header_multicast") fabric_header_multicast_t fabric_header_multicast; - @name(".fabric_header_sflow") + @name(".fabric_header_sflow") fabric_header_sflow_t fabric_header_sflow; - @name(".fabric_header_unicast") + @name(".fabric_header_unicast") fabric_header_unicast_t fabric_header_unicast; - @name(".fabric_payload_header") + @name(".fabric_payload_header") fabric_payload_header_t fabric_payload_header; - @name(".fcoe") + @name(".fcoe") fcoe_header_t fcoe; - @name(".genv") + @name(".genv") genv_t genv; - @name(".gre") + @name(".gre") gre_t gre; - @name(".icmp") + @name(".icmp") icmp_t icmp; - @name(".inner_ethernet") + @name(".inner_ethernet") ethernet_t inner_ethernet; - @name(".inner_icmp") + @name(".inner_icmp") icmp_t inner_icmp; - @name(".inner_ipv4") + @name(".inner_ipv4") ipv4_t inner_ipv4; - @name(".inner_ipv6") + @name(".inner_ipv6") ipv6_t inner_ipv6; - @name(".inner_sctp") + @name(".inner_sctp") sctp_t inner_sctp; - @name(".inner_tcp") + @name(".inner_tcp") tcp_t inner_tcp; - @name(".inner_udp") + @name(".inner_udp") udp_t inner_udp; - @name(".int_egress_port_id_header") + @name(".int_egress_port_id_header") int_egress_port_id_header_t int_egress_port_id_header; - @name(".int_egress_port_tx_utilization_header") + @name(".int_egress_port_tx_utilization_header") int_egress_port_tx_utilization_header_t int_egress_port_tx_utilization_header; - @name(".int_header") + @name(".int_header") int_header_t int_header; - @name(".int_hop_latency_header") + @name(".int_hop_latency_header") int_hop_latency_header_t int_hop_latency_header; - @name(".int_ingress_port_id_header") + @name(".int_ingress_port_id_header") int_ingress_port_id_header_t int_ingress_port_id_header; - @name(".int_ingress_tstamp_header") + @name(".int_ingress_tstamp_header") int_ingress_tstamp_header_t int_ingress_tstamp_header; - @name(".int_q_congestion_header") + @name(".int_q_congestion_header") int_q_congestion_header_t int_q_congestion_header; - @name(".int_q_occupancy_header") + @name(".int_q_occupancy_header") int_q_occupancy_header_t int_q_occupancy_header; - @name(".int_switch_id_header") + @name(".int_switch_id_header") int_switch_id_header_t int_switch_id_header; - @name(".ipv4") + @name(".ipv4") ipv4_t ipv4; - @name(".ipv6") + @name(".ipv6") ipv6_t ipv6; - @name(".lisp") + @name(".lisp") lisp_t lisp; - @name(".llc_header") + @name(".llc_header") llc_header_t llc_header; - @name(".nsh") + @name(".nsh") nsh_t nsh; - @name(".nsh_context") + @name(".nsh_context") nsh_context_t nsh_context; - @name(".nvgre") + @name(".nvgre") nvgre_t nvgre; - @name(".outer_udp") + @name(".outer_udp") udp_t outer_udp; - @name(".roce") + @name(".roce") roce_header_t roce; - @name(".roce_v2") + @name(".roce_v2") roce_v2_header_t roce_v2; - @name(".sctp") + @name(".sctp") sctp_t sctp; - @name(".sflow") + @name(".sflow") sflow_hdr_t sflow; - @name(".sflow_raw_hdr_record") + @name(".sflow_raw_hdr_record") sflow_raw_hdr_record_t sflow_raw_hdr_record; - @name(".sflow_sample") + @name(".sflow_sample") sflow_sample_t sflow_sample; - @name(".snap_header") + @name(".snap_header") snap_header_t snap_header; - @name(".tcp") + @name(".tcp") tcp_t tcp; - @name(".trill") + @name(".trill") trill_t trill; - @name(".udp") + @name(".udp") udp_t udp; - @name(".vntag") + @name(".vntag") vntag_t vntag; - @name(".vxlan") + @name(".vxlan") vxlan_t vxlan; - @name(".vxlan_gpe") + @name(".vxlan_gpe") vxlan_gpe_t vxlan_gpe; - @name(".vxlan_gpe_int_header") + @name(".vxlan_gpe_int_header") vxlan_gpe_int_header_t vxlan_gpe_int_header; - @name(".int_val") + @name(".int_val") int_value_t[24] int_val; - @name(".mpls") + @name(".mpls") mpls_t[3] mpls; - @name(".vlan_tag_") + @name(".vlan_tag_") vlan_tag_t[2] vlan_tag_; } @@ -2961,7 +2978,7 @@ control process_egress_acl(inout headers hdr, inout metadata meta, inout standar } @name(".egress_mirror") action egress_mirror(bit<32> session_id) { meta.i2e_metadata.mirror_session_id = (bit<16>)session_id; - clone3, bit<16>>>(CloneType.E2E, session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); + clone_preserving_field_list(CloneType.E2E, session_id, (bit<8>)FieldLists.e2e_mirror_info); } @name(".egress_mirror_drop") action egress_mirror_drop(bit<32> session_id) { egress_mirror(session_id); @@ -2969,7 +2986,7 @@ control process_egress_acl(inout headers hdr, inout metadata meta, inout standar } @name(".egress_copy_to_cpu") action egress_copy_to_cpu(bit<16> reason_code) { meta.fabric_metadata.reason_code = reason_code; - clone3, bit<16>, bit<16>, bit<9>>>(CloneType.E2E, 32w250, { meta.ingress_metadata.bd, meta.ingress_metadata.ifindex, meta.fabric_metadata.reason_code, meta.ingress_metadata.ingress_port }); + clone_preserving_field_list(CloneType.E2E, 32w250, (bit<8>)FieldLists.cpu_info); } @name(".egress_redirect_to_cpu") action egress_redirect_to_cpu(bit<16> reason_code) { egress_copy_to_cpu(reason_code); @@ -3493,7 +3510,7 @@ control process_int_endpoint(inout headers hdr, inout metadata meta, inout stand @name(".int_sink") action int_sink(bit<32> mirror_id) { meta.int_metadata_i2e.sink = 1w1; meta.i2e_metadata.mirror_session_id = (bit<16>)mirror_id; - clone3, bit<16>>>(CloneType.I2E, mirror_id, { meta.int_metadata_i2e.sink, meta.i2e_metadata.mirror_session_id }); + clone_preserving_field_list(CloneType.I2E, mirror_id, (bit<8>)FieldLists.int_i2e_mirror_info); hdr.int_header.setInvalid(); hdr.int_val[0].setInvalid(); hdr.int_val[1].setInvalid(); @@ -4284,7 +4301,7 @@ control process_ingress_sflow(inout headers hdr, inout metadata meta, inout stan @name(".sflow_ing_pkt_to_cpu") action sflow_ing_pkt_to_cpu(bit<32> sflow_i2e_mirror_id, bit<16> reason_code) { meta.fabric_metadata.reason_code = reason_code; meta.i2e_metadata.mirror_session_id = (bit<16>)sflow_i2e_mirror_id; - clone3, bit<16>, bit<16>, bit<9>>, bit<16>, bit<16>>>(CloneType.I2E, sflow_i2e_mirror_id, { { meta.ingress_metadata.bd, meta.ingress_metadata.ifindex, meta.fabric_metadata.reason_code, meta.ingress_metadata.ingress_port }, meta.sflow_metadata.sflow_session_id, meta.i2e_metadata.mirror_session_id }); + clone_preserving_field_list(CloneType.I2E, sflow_i2e_mirror_id, (bit<8>)FieldLists.sflow_cpu_info); } @name(".sflow_ing_session_enable") action sflow_ing_session_enable(bit<32> rate_thr, bit<16> session_id) { meta.ingress_metadata.sflow_take_sample = rate_thr |+| meta.ingress_metadata.sflow_take_sample; @@ -4297,7 +4314,7 @@ control process_ingress_sflow(inout headers hdr, inout metadata meta, inout stan sflow_ingress_session_pkt_counter.count(); meta.fabric_metadata.reason_code = reason_code; meta.i2e_metadata.mirror_session_id = (bit<16>)sflow_i2e_mirror_id; - clone3, bit<16>, bit<16>, bit<9>>, bit<16>, bit<16>>>(CloneType.I2E, sflow_i2e_mirror_id, { { meta.ingress_metadata.bd, meta.ingress_metadata.ifindex, meta.fabric_metadata.reason_code, meta.ingress_metadata.ingress_port }, meta.sflow_metadata.sflow_session_id, meta.i2e_metadata.mirror_session_id }); + clone_preserving_field_list(CloneType.I2E, sflow_i2e_mirror_id, (bit<8>)FieldLists.sflow_cpu_info); } @name(".sflow_ing_take_sample") table sflow_ing_take_sample { actions = { @@ -4515,7 +4532,7 @@ control process_mac_acl(inout headers hdr, inout metadata meta, inout standard_m @name(".acl_mirror") action acl_mirror(bit<32> session_id, bit<14> acl_stats_index, bit<16> acl_meter_index) { meta.i2e_metadata.mirror_session_id = (bit<16>)session_id; meta.i2e_metadata.ingress_tstamp = (bit<32>)standard_metadata.ingress_global_timestamp; - clone3, bit<16>>>(CloneType.I2E, session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); + clone_preserving_field_list(CloneType.I2E, session_id, (bit<8>)FieldLists.i2e_mirror_info); meta.acl_metadata.acl_stats_index = acl_stats_index; meta.meter_metadata.meter_index = acl_meter_index; } @@ -4583,7 +4600,7 @@ control process_ip_acl(inout headers hdr, inout metadata meta, inout standard_me @name(".acl_mirror") action acl_mirror(bit<32> session_id, bit<14> acl_stats_index, bit<16> acl_meter_index) { meta.i2e_metadata.mirror_session_id = (bit<16>)session_id; meta.i2e_metadata.ingress_tstamp = (bit<32>)standard_metadata.ingress_global_timestamp; - clone3, bit<16>>>(CloneType.I2E, session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); + clone_preserving_field_list(CloneType.I2E, session_id, (bit<8>)FieldLists.i2e_mirror_info); meta.acl_metadata.acl_stats_index = acl_stats_index; meta.meter_metadata.meter_index = acl_meter_index; } @@ -5834,7 +5851,7 @@ control process_system_acl(inout headers hdr, inout metadata meta, inout standar } @name(".copy_to_cpu_with_reason") action copy_to_cpu_with_reason(bit<16> reason_code) { meta.fabric_metadata.reason_code = reason_code; - clone3, bit<16>, bit<16>, bit<9>>>(CloneType.I2E, 32w250, { meta.ingress_metadata.bd, meta.ingress_metadata.ifindex, meta.fabric_metadata.reason_code, meta.ingress_metadata.ingress_port }); + clone_preserving_field_list(CloneType.I2E, 32w250, (bit<8>)FieldLists.cpu_info); } @name(".redirect_to_cpu") action redirect_to_cpu(bit<16> reason_code) { copy_to_cpu_with_reason(reason_code); @@ -5842,7 +5859,7 @@ control process_system_acl(inout headers hdr, inout metadata meta, inout standar meta.fabric_metadata.dst_device = 8w0; } @name(".copy_to_cpu") action copy_to_cpu() { - clone3, bit<16>, bit<16>, bit<9>>>(CloneType.I2E, 32w250, { meta.ingress_metadata.bd, meta.ingress_metadata.ifindex, meta.fabric_metadata.reason_code, meta.ingress_metadata.ingress_port }); + clone_preserving_field_list(CloneType.I2E, 32w250, (bit<8>)FieldLists.cpu_info); } @name(".drop_packet") action drop_packet() { mark_to_drop(standard_metadata); @@ -5852,7 +5869,7 @@ control process_system_acl(inout headers hdr, inout metadata meta, inout standar mark_to_drop(standard_metadata); } @name(".negative_mirror") action negative_mirror(bit<32> session_id) { - clone3, bit<8>>>(CloneType.I2E, session_id, { meta.ingress_metadata.ifindex, meta.ingress_metadata.drop_reason }); + clone_preserving_field_list(CloneType.I2E, session_id, (bit<8>)FieldLists.mirror_info); mark_to_drop(standard_metadata); } @name(".drop_stats") table drop_stats_0 { @@ -6103,4 +6120,3 @@ control computeChecksum(inout headers hdr, inout metadata meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_14_samples_outputs/switch_20160512/switch-frontend.p4 b/testdata/p4_14_samples_outputs/switch_20160512/switch-frontend.p4 index 869f00ef257..a03dfc942d7 100644 --- a/testdata/p4_14_samples_outputs/switch_20160512/switch-frontend.p4 +++ b/testdata/p4_14_samples_outputs/switch_20160512/switch-frontend.p4 @@ -2,6 +2,15 @@ #define V1MODEL_VERSION 20200408 #include +enum bit<8> FieldLists { + i2e_mirror_info = 8w0, + cpu_info = 8w1, + e2e_mirror_info = 8w2, + int_i2e_mirror_info = 8w3, + mirror_info = 8w4, + sflow_cpu_info = 8w5 +} + struct acl_metadata_t { bit<1> acl_deny; bit<1> acl_copy; @@ -40,6 +49,7 @@ struct egress_metadata_t { struct fabric_metadata_t { bit<3> packetType; bit<1> fabric_header_present; + @field_list(FieldLists.cpu_info, FieldLists.sflow_cpu_info) bit<16> reason_code; bit<8> dst_device; bit<16> dst_port; @@ -56,22 +66,28 @@ struct hash_metadata_t { } struct i2e_metadata_t { + @field_list(FieldLists.i2e_mirror_info, FieldLists.e2e_mirror_info) bit<32> ingress_tstamp; + @field_list(FieldLists.i2e_mirror_info, FieldLists.e2e_mirror_info, FieldLists.int_i2e_mirror_info) bit<16> mirror_session_id; } struct ingress_metadata_t { + @field_list(FieldLists.cpu_info, FieldLists.sflow_cpu_info) bit<9> ingress_port; + @field_list(FieldLists.cpu_info, FieldLists.mirror_info, FieldLists.sflow_cpu_info) bit<16> ifindex; bit<16> egress_ifindex; bit<2> port_type; bit<16> outer_bd; + @field_list(FieldLists.cpu_info, FieldLists.sflow_cpu_info) bit<16> bd; bit<1> drop_flag; + @field_list(FieldLists.mirror_info) bit<8> drop_reason; bit<1> control_frame; bit<16> bypass_lookups; - @saturating + @saturating bit<32> sflow_take_sample; } @@ -85,6 +101,7 @@ struct int_metadata_t { } struct int_metadata_i2e_t { + @field_list(FieldLists.int_i2e_mirror_info) bit<1> sink; bit<1> source; } @@ -155,7 +172,7 @@ struct l3_metadata_t { bit<1> outer_routed; bit<8> mtu_index; bit<1> l3_copy; - @saturating + @saturating bit<16> l3_mtu_check; } @@ -640,166 +657,166 @@ header vlan_tag_t { } struct metadata { - @name(".acl_metadata") + @name(".acl_metadata") acl_metadata_t acl_metadata; - @name(".egress_filter_metadata") + @name(".egress_filter_metadata") egress_filter_metadata_t egress_filter_metadata; - @name(".egress_metadata") + @name(".egress_metadata") egress_metadata_t egress_metadata; - @name(".fabric_metadata") + @name(".fabric_metadata") fabric_metadata_t fabric_metadata; - @name(".global_config_metadata") + @name(".global_config_metadata") global_config_metadata_t global_config_metadata; - @name(".hash_metadata") + @name(".hash_metadata") hash_metadata_t hash_metadata; - @name(".i2e_metadata") + @name(".i2e_metadata") i2e_metadata_t i2e_metadata; - @name(".ingress_metadata") + @name(".ingress_metadata") ingress_metadata_t ingress_metadata; - @name(".int_metadata") + @name(".int_metadata") int_metadata_t int_metadata; - @name(".int_metadata_i2e") + @name(".int_metadata_i2e") int_metadata_i2e_t int_metadata_i2e; - @name(".ipv4_metadata") + @name(".ipv4_metadata") ipv4_metadata_t ipv4_metadata; - @name(".ipv6_metadata") + @name(".ipv6_metadata") ipv6_metadata_t ipv6_metadata; - @name(".l2_metadata") + @name(".l2_metadata") l2_metadata_t l2_metadata; - @name(".l3_metadata") + @name(".l3_metadata") l3_metadata_t l3_metadata; - @name(".meter_metadata") + @name(".meter_metadata") meter_metadata_t meter_metadata; - @name(".multicast_metadata") + @name(".multicast_metadata") multicast_metadata_t multicast_metadata; - @name(".nexthop_metadata") + @name(".nexthop_metadata") nexthop_metadata_t nexthop_metadata; - @name(".qos_metadata") + @name(".qos_metadata") qos_metadata_t qos_metadata; - @name(".security_metadata") + @name(".security_metadata") security_metadata_t security_metadata; - @name(".sflow_metadata") + @name(".sflow_metadata") sflow_meta_t sflow_metadata; - @name(".tunnel_metadata") + @name(".tunnel_metadata") tunnel_metadata_t tunnel_metadata; } struct headers { - @name(".arp_rarp") + @name(".arp_rarp") arp_rarp_t arp_rarp; - @name(".arp_rarp_ipv4") + @name(".arp_rarp_ipv4") arp_rarp_ipv4_t arp_rarp_ipv4; - @name(".bfd") + @name(".bfd") bfd_t bfd; - @name(".eompls") + @name(".eompls") eompls_t eompls; - @name(".erspan_t3_header") + @name(".erspan_t3_header") erspan_header_t3_t_0 erspan_t3_header; - @name(".ethernet") + @name(".ethernet") ethernet_t ethernet; - @name(".fabric_header") + @name(".fabric_header") fabric_header_t fabric_header; - @name(".fabric_header_cpu") + @name(".fabric_header_cpu") fabric_header_cpu_t fabric_header_cpu; - @name(".fabric_header_mirror") + @name(".fabric_header_mirror") fabric_header_mirror_t fabric_header_mirror; - @name(".fabric_header_multicast") + @name(".fabric_header_multicast") fabric_header_multicast_t fabric_header_multicast; - @name(".fabric_header_sflow") + @name(".fabric_header_sflow") fabric_header_sflow_t fabric_header_sflow; - @name(".fabric_header_unicast") + @name(".fabric_header_unicast") fabric_header_unicast_t fabric_header_unicast; - @name(".fabric_payload_header") + @name(".fabric_payload_header") fabric_payload_header_t fabric_payload_header; - @name(".fcoe") + @name(".fcoe") fcoe_header_t fcoe; - @name(".genv") + @name(".genv") genv_t genv; - @name(".gre") + @name(".gre") gre_t gre; - @name(".icmp") + @name(".icmp") icmp_t icmp; - @name(".inner_ethernet") + @name(".inner_ethernet") ethernet_t inner_ethernet; - @name(".inner_icmp") + @name(".inner_icmp") icmp_t inner_icmp; - @name(".inner_ipv4") + @name(".inner_ipv4") ipv4_t inner_ipv4; - @name(".inner_ipv6") + @name(".inner_ipv6") ipv6_t inner_ipv6; - @name(".inner_sctp") + @name(".inner_sctp") sctp_t inner_sctp; - @name(".inner_tcp") + @name(".inner_tcp") tcp_t inner_tcp; - @name(".inner_udp") + @name(".inner_udp") udp_t inner_udp; - @name(".int_egress_port_id_header") + @name(".int_egress_port_id_header") int_egress_port_id_header_t int_egress_port_id_header; - @name(".int_egress_port_tx_utilization_header") + @name(".int_egress_port_tx_utilization_header") int_egress_port_tx_utilization_header_t int_egress_port_tx_utilization_header; - @name(".int_header") + @name(".int_header") int_header_t int_header; - @name(".int_hop_latency_header") + @name(".int_hop_latency_header") int_hop_latency_header_t int_hop_latency_header; - @name(".int_ingress_port_id_header") + @name(".int_ingress_port_id_header") int_ingress_port_id_header_t int_ingress_port_id_header; - @name(".int_ingress_tstamp_header") + @name(".int_ingress_tstamp_header") int_ingress_tstamp_header_t int_ingress_tstamp_header; - @name(".int_q_congestion_header") + @name(".int_q_congestion_header") int_q_congestion_header_t int_q_congestion_header; - @name(".int_q_occupancy_header") + @name(".int_q_occupancy_header") int_q_occupancy_header_t int_q_occupancy_header; - @name(".int_switch_id_header") + @name(".int_switch_id_header") int_switch_id_header_t int_switch_id_header; - @name(".ipv4") + @name(".ipv4") ipv4_t ipv4; - @name(".ipv6") + @name(".ipv6") ipv6_t ipv6; - @name(".lisp") + @name(".lisp") lisp_t lisp; - @name(".llc_header") + @name(".llc_header") llc_header_t llc_header; - @name(".nsh") + @name(".nsh") nsh_t nsh; - @name(".nsh_context") + @name(".nsh_context") nsh_context_t nsh_context; - @name(".nvgre") + @name(".nvgre") nvgre_t nvgre; - @name(".outer_udp") + @name(".outer_udp") udp_t outer_udp; - @name(".roce") + @name(".roce") roce_header_t roce; - @name(".roce_v2") + @name(".roce_v2") roce_v2_header_t roce_v2; - @name(".sctp") + @name(".sctp") sctp_t sctp; - @name(".sflow") + @name(".sflow") sflow_hdr_t sflow; - @name(".sflow_raw_hdr_record") + @name(".sflow_raw_hdr_record") sflow_raw_hdr_record_t sflow_raw_hdr_record; - @name(".sflow_sample") + @name(".sflow_sample") sflow_sample_t sflow_sample; - @name(".snap_header") + @name(".snap_header") snap_header_t snap_header; - @name(".tcp") + @name(".tcp") tcp_t tcp; - @name(".trill") + @name(".trill") trill_t trill; - @name(".udp") + @name(".udp") udp_t udp; - @name(".vntag") + @name(".vntag") vntag_t vntag; - @name(".vxlan") + @name(".vxlan") vxlan_t vxlan; - @name(".vxlan_gpe") + @name(".vxlan_gpe") vxlan_gpe_t vxlan_gpe; - @name(".vxlan_gpe_int_header") + @name(".vxlan_gpe_int_header") vxlan_gpe_int_header_t vxlan_gpe_int_header; - @name(".int_val") + @name(".int_val") int_value_t[24] int_val; - @name(".mpls") + @name(".mpls") mpls_t[3] mpls; - @name(".vlan_tag_") + @name(".vlan_tag_") vlan_tag_t[2] vlan_tag_; } @@ -3028,16 +3045,16 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } @name(".egress_mirror") action _egress_mirror_0(@name("session_id") bit<32> session_id) { meta.i2e_metadata.mirror_session_id = (bit<16>)session_id; - clone3, bit<16>>>(CloneType.E2E, session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); + clone_preserving_field_list(CloneType.E2E, session_id, (bit<8>)FieldLists.e2e_mirror_info); } @name(".egress_mirror_drop") action _egress_mirror_drop_0(@name("session_id") bit<32> session_id_6) { meta.i2e_metadata.mirror_session_id = (bit<16>)session_id_6; - clone3, bit<16>>>(CloneType.E2E, session_id_6, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); + clone_preserving_field_list(CloneType.E2E, session_id_6, (bit<8>)FieldLists.e2e_mirror_info); mark_to_drop(standard_metadata); } @name(".egress_redirect_to_cpu") action _egress_redirect_to_cpu_0(@name("reason_code") bit<16> reason_code_0) { meta.fabric_metadata.reason_code = reason_code_0; - clone3, bit<16>, bit<16>, bit<9>>>(CloneType.E2E, 32w250, { meta.ingress_metadata.bd, meta.ingress_metadata.ifindex, meta.fabric_metadata.reason_code, meta.ingress_metadata.ingress_port }); + clone_preserving_field_list(CloneType.E2E, 32w250, (bit<8>)FieldLists.cpu_info); mark_to_drop(standard_metadata); } @name(".egress_acl") table _egress_acl { @@ -3637,7 +3654,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ meta.int_metadata.insert_byte_cnt = meta.int_metadata.gpe_int_hdr_len << 2; meta.int_metadata_i2e.sink = 1w1; meta.i2e_metadata.mirror_session_id = (bit<16>)mirror_id; - clone3, bit<16>>>(CloneType.I2E, mirror_id, { meta.int_metadata_i2e.sink, meta.i2e_metadata.mirror_session_id }); + clone_preserving_field_list(CloneType.I2E, mirror_id, (bit<8>)FieldLists.int_i2e_mirror_info); hdr.int_header.setInvalid(); hdr.int_val[0].setInvalid(); hdr.int_val[1].setInvalid(); @@ -4327,7 +4344,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ _sflow_ingress_session_pkt_counter.count(); meta.fabric_metadata.reason_code = reason_code_5; meta.i2e_metadata.mirror_session_id = (bit<16>)sflow_i2e_mirror_id; - clone3, bit<16>, bit<16>, bit<9>>, bit<16>, bit<16>>>(CloneType.I2E, sflow_i2e_mirror_id, { { meta.ingress_metadata.bd, meta.ingress_metadata.ifindex, meta.fabric_metadata.reason_code, meta.ingress_metadata.ingress_port }, meta.sflow_metadata.sflow_session_id, meta.i2e_metadata.mirror_session_id }); + clone_preserving_field_list(CloneType.I2E, sflow_i2e_mirror_id, (bit<8>)FieldLists.sflow_cpu_info); } @name(".sflow_ing_take_sample") table _sflow_ing_take_sample { actions = { @@ -4511,7 +4528,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ @name(".acl_mirror") action _acl_mirror_1(@name("session_id") bit<32> session_id_8, @name("acl_stats_index") bit<14> acl_stats_index_20, @name("acl_meter_index") bit<16> acl_meter_index_11) { meta.i2e_metadata.mirror_session_id = (bit<16>)session_id_8; meta.i2e_metadata.ingress_tstamp = (bit<32>)standard_metadata.ingress_global_timestamp; - clone3, bit<16>>>(CloneType.I2E, session_id_8, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); + clone_preserving_field_list(CloneType.I2E, session_id_8, (bit<8>)FieldLists.i2e_mirror_info); meta.acl_metadata.acl_stats_index = acl_stats_index_20; meta.meter_metadata.meter_index = acl_meter_index_11; } @@ -4586,14 +4603,14 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ @name(".acl_mirror") action _acl_mirror_2(@name("session_id") bit<32> session_id_9, @name("acl_stats_index") bit<14> acl_stats_index_27, @name("acl_meter_index") bit<16> acl_meter_index_18) { meta.i2e_metadata.mirror_session_id = (bit<16>)session_id_9; meta.i2e_metadata.ingress_tstamp = (bit<32>)standard_metadata.ingress_global_timestamp; - clone3, bit<16>>>(CloneType.I2E, session_id_9, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); + clone_preserving_field_list(CloneType.I2E, session_id_9, (bit<8>)FieldLists.i2e_mirror_info); meta.acl_metadata.acl_stats_index = acl_stats_index_27; meta.meter_metadata.meter_index = acl_meter_index_18; } @name(".acl_mirror") action _acl_mirror_3(@name("session_id") bit<32> session_id_10, @name("acl_stats_index") bit<14> acl_stats_index_28, @name("acl_meter_index") bit<16> acl_meter_index_19) { meta.i2e_metadata.mirror_session_id = (bit<16>)session_id_10; meta.i2e_metadata.ingress_tstamp = (bit<32>)standard_metadata.ingress_global_timestamp; - clone3, bit<16>>>(CloneType.I2E, session_id_10, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); + clone_preserving_field_list(CloneType.I2E, session_id_10, (bit<8>)FieldLists.i2e_mirror_info); meta.acl_metadata.acl_stats_index = acl_stats_index_28; meta.meter_metadata.meter_index = acl_meter_index_19; } @@ -5587,16 +5604,16 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } @name(".copy_to_cpu_with_reason") action _copy_to_cpu_with_reason_0(@name("reason_code") bit<16> reason_code_6) { meta.fabric_metadata.reason_code = reason_code_6; - clone3, bit<16>, bit<16>, bit<9>>>(CloneType.I2E, 32w250, { meta.ingress_metadata.bd, meta.ingress_metadata.ifindex, meta.fabric_metadata.reason_code, meta.ingress_metadata.ingress_port }); + clone_preserving_field_list(CloneType.I2E, 32w250, (bit<8>)FieldLists.cpu_info); } @name(".redirect_to_cpu") action _redirect_to_cpu_0(@name("reason_code") bit<16> reason_code_7) { meta.fabric_metadata.reason_code = reason_code_7; - clone3, bit<16>, bit<16>, bit<9>>>(CloneType.I2E, 32w250, { meta.ingress_metadata.bd, meta.ingress_metadata.ifindex, meta.fabric_metadata.reason_code, meta.ingress_metadata.ingress_port }); + clone_preserving_field_list(CloneType.I2E, 32w250, (bit<8>)FieldLists.cpu_info); mark_to_drop(standard_metadata); meta.fabric_metadata.dst_device = 8w0; } @name(".copy_to_cpu") action _copy_to_cpu_0() { - clone3, bit<16>, bit<16>, bit<9>>>(CloneType.I2E, 32w250, { meta.ingress_metadata.bd, meta.ingress_metadata.ifindex, meta.fabric_metadata.reason_code, meta.ingress_metadata.ingress_port }); + clone_preserving_field_list(CloneType.I2E, 32w250, (bit<8>)FieldLists.cpu_info); } @name(".drop_packet") action _drop_packet_0() { mark_to_drop(standard_metadata); @@ -5606,7 +5623,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ mark_to_drop(standard_metadata); } @name(".negative_mirror") action _negative_mirror_0(@name("session_id") bit<32> session_id_11) { - clone3, bit<8>>>(CloneType.I2E, session_id_11, { meta.ingress_metadata.ifindex, meta.ingress_metadata.drop_reason }); + clone_preserving_field_list(CloneType.I2E, session_id_11, (bit<8>)FieldLists.mirror_info); mark_to_drop(standard_metadata); } @name(".drop_stats") table _drop_stats { @@ -5992,4 +6009,3 @@ control computeChecksum(inout headers hdr, inout metadata meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_14_samples_outputs/switch_20160512/switch-midend.p4 b/testdata/p4_14_samples_outputs/switch_20160512/switch-midend.p4 index 66779a31b42..a05580d4dec 100644 --- a/testdata/p4_14_samples_outputs/switch_20160512/switch-midend.p4 +++ b/testdata/p4_14_samples_outputs/switch_20160512/switch-midend.p4 @@ -40,6 +40,7 @@ struct egress_metadata_t { struct fabric_metadata_t { bit<3> packetType; bit<1> fabric_header_present; + @field_list(8w1, 8w5) bit<16> reason_code; bit<8> dst_device; bit<16> dst_port; @@ -56,22 +57,28 @@ struct hash_metadata_t { } struct i2e_metadata_t { + @field_list(8w0, 8w2) bit<32> ingress_tstamp; + @field_list(8w0, 8w2, 8w3) bit<16> mirror_session_id; } struct ingress_metadata_t { + @field_list(8w1, 8w5) bit<9> ingress_port; + @field_list(8w1, 8w4, 8w5) bit<16> ifindex; bit<16> egress_ifindex; bit<2> port_type; bit<16> outer_bd; + @field_list(8w1, 8w5) bit<16> bd; bit<1> drop_flag; + @field_list(8w4) bit<8> drop_reason; bit<1> control_frame; bit<16> bypass_lookups; - @saturating + @saturating bit<32> sflow_take_sample; } @@ -85,6 +92,7 @@ struct int_metadata_t { } struct int_metadata_i2e_t { + @field_list(8w3) bit<1> sink; bit<1> source; } @@ -155,7 +163,7 @@ struct l3_metadata_t { bit<1> outer_routed; bit<8> mtu_index; bit<1> l3_copy; - @saturating + @saturating bit<16> l3_mtu_check; } @@ -668,6 +676,7 @@ struct metadata { bit<16> _egress_metadata_ifindex25; bit<3> _fabric_metadata_packetType26; bit<1> _fabric_metadata_fabric_header_present27; + @field_list(8w1, 8w5) bit<16> _fabric_metadata_reason_code28; bit<8> _fabric_metadata_dst_device29; bit<16> _fabric_metadata_dst_port30; @@ -675,18 +684,25 @@ struct metadata { bit<16> _hash_metadata_hash132; bit<16> _hash_metadata_hash233; bit<16> _hash_metadata_entropy_hash34; + @field_list(8w0, 8w2) bit<32> _i2e_metadata_ingress_tstamp35; + @field_list(8w0, 8w2, 8w3) bit<16> _i2e_metadata_mirror_session_id36; + @field_list(8w1, 8w5) bit<9> _ingress_metadata_ingress_port37; + @field_list(8w1, 8w4, 8w5) bit<16> _ingress_metadata_ifindex38; bit<16> _ingress_metadata_egress_ifindex39; bit<2> _ingress_metadata_port_type40; bit<16> _ingress_metadata_outer_bd41; + @field_list(8w1, 8w5) bit<16> _ingress_metadata_bd42; bit<1> _ingress_metadata_drop_flag43; + @field_list(8w4) bit<8> _ingress_metadata_drop_reason44; bit<1> _ingress_metadata_control_frame45; bit<16> _ingress_metadata_bypass_lookups46; + @saturating bit<32> _ingress_metadata_sflow_take_sample47; bit<32> _int_metadata_switch_id48; bit<8> _int_metadata_insert_cnt49; @@ -694,6 +710,7 @@ struct metadata { bit<16> _int_metadata_gpe_int_hdr_len51; bit<8> _int_metadata_gpe_int_hdr_len852; bit<16> _int_metadata_instruction_cnt53; + @field_list(8w3) bit<1> _int_metadata_i2e_sink54; bit<1> _int_metadata_i2e_source55; bit<32> _ipv4_metadata_lkp_ipv4_sa56; @@ -745,6 +762,7 @@ struct metadata { bit<1> _l3_metadata_outer_routed102; bit<8> _l3_metadata_mtu_index103; bit<1> _l3_metadata_l3_copy104; + @saturating bit<16> _l3_metadata_l3_mtu_check105; bit<2> _meter_metadata_meter_color106; bit<16> _meter_metadata_meter_index107; @@ -797,121 +815,121 @@ struct metadata { } struct headers { - @name(".arp_rarp") + @name(".arp_rarp") arp_rarp_t arp_rarp; - @name(".arp_rarp_ipv4") + @name(".arp_rarp_ipv4") arp_rarp_ipv4_t arp_rarp_ipv4; - @name(".bfd") + @name(".bfd") bfd_t bfd; - @name(".eompls") + @name(".eompls") eompls_t eompls; - @name(".erspan_t3_header") + @name(".erspan_t3_header") erspan_header_t3_t_0 erspan_t3_header; - @name(".ethernet") + @name(".ethernet") ethernet_t ethernet; - @name(".fabric_header") + @name(".fabric_header") fabric_header_t fabric_header; - @name(".fabric_header_cpu") + @name(".fabric_header_cpu") fabric_header_cpu_t fabric_header_cpu; - @name(".fabric_header_mirror") + @name(".fabric_header_mirror") fabric_header_mirror_t fabric_header_mirror; - @name(".fabric_header_multicast") + @name(".fabric_header_multicast") fabric_header_multicast_t fabric_header_multicast; - @name(".fabric_header_sflow") + @name(".fabric_header_sflow") fabric_header_sflow_t fabric_header_sflow; - @name(".fabric_header_unicast") + @name(".fabric_header_unicast") fabric_header_unicast_t fabric_header_unicast; - @name(".fabric_payload_header") + @name(".fabric_payload_header") fabric_payload_header_t fabric_payload_header; - @name(".fcoe") + @name(".fcoe") fcoe_header_t fcoe; - @name(".genv") + @name(".genv") genv_t genv; - @name(".gre") + @name(".gre") gre_t gre; - @name(".icmp") + @name(".icmp") icmp_t icmp; - @name(".inner_ethernet") + @name(".inner_ethernet") ethernet_t inner_ethernet; - @name(".inner_icmp") + @name(".inner_icmp") icmp_t inner_icmp; - @name(".inner_ipv4") + @name(".inner_ipv4") ipv4_t inner_ipv4; - @name(".inner_ipv6") + @name(".inner_ipv6") ipv6_t inner_ipv6; - @name(".inner_sctp") + @name(".inner_sctp") sctp_t inner_sctp; - @name(".inner_tcp") + @name(".inner_tcp") tcp_t inner_tcp; - @name(".inner_udp") + @name(".inner_udp") udp_t inner_udp; - @name(".int_egress_port_id_header") + @name(".int_egress_port_id_header") int_egress_port_id_header_t int_egress_port_id_header; - @name(".int_egress_port_tx_utilization_header") + @name(".int_egress_port_tx_utilization_header") int_egress_port_tx_utilization_header_t int_egress_port_tx_utilization_header; - @name(".int_header") + @name(".int_header") int_header_t int_header; - @name(".int_hop_latency_header") + @name(".int_hop_latency_header") int_hop_latency_header_t int_hop_latency_header; - @name(".int_ingress_port_id_header") + @name(".int_ingress_port_id_header") int_ingress_port_id_header_t int_ingress_port_id_header; - @name(".int_ingress_tstamp_header") + @name(".int_ingress_tstamp_header") int_ingress_tstamp_header_t int_ingress_tstamp_header; - @name(".int_q_congestion_header") + @name(".int_q_congestion_header") int_q_congestion_header_t int_q_congestion_header; - @name(".int_q_occupancy_header") + @name(".int_q_occupancy_header") int_q_occupancy_header_t int_q_occupancy_header; - @name(".int_switch_id_header") + @name(".int_switch_id_header") int_switch_id_header_t int_switch_id_header; - @name(".ipv4") + @name(".ipv4") ipv4_t ipv4; - @name(".ipv6") + @name(".ipv6") ipv6_t ipv6; - @name(".lisp") + @name(".lisp") lisp_t lisp; - @name(".llc_header") + @name(".llc_header") llc_header_t llc_header; - @name(".nsh") + @name(".nsh") nsh_t nsh; - @name(".nsh_context") + @name(".nsh_context") nsh_context_t nsh_context; - @name(".nvgre") + @name(".nvgre") nvgre_t nvgre; - @name(".outer_udp") + @name(".outer_udp") udp_t outer_udp; - @name(".roce") + @name(".roce") roce_header_t roce; - @name(".roce_v2") + @name(".roce_v2") roce_v2_header_t roce_v2; - @name(".sctp") + @name(".sctp") sctp_t sctp; - @name(".sflow") + @name(".sflow") sflow_hdr_t sflow; - @name(".sflow_raw_hdr_record") + @name(".sflow_raw_hdr_record") sflow_raw_hdr_record_t sflow_raw_hdr_record; - @name(".sflow_sample") + @name(".sflow_sample") sflow_sample_t sflow_sample; - @name(".snap_header") + @name(".snap_header") snap_header_t snap_header; - @name(".tcp") + @name(".tcp") tcp_t tcp; - @name(".trill") + @name(".trill") trill_t trill; - @name(".udp") + @name(".udp") udp_t udp; - @name(".vntag") + @name(".vntag") vntag_t vntag; - @name(".vxlan") + @name(".vxlan") vxlan_t vxlan; - @name(".vxlan_gpe") + @name(".vxlan_gpe") vxlan_gpe_t vxlan_gpe; - @name(".vxlan_gpe_int_header") + @name(".vxlan_gpe_int_header") vxlan_gpe_int_header_t vxlan_gpe_int_header; - @name(".int_val") + @name(".int_val") int_value_t[24] int_val; - @name(".mpls") + @name(".mpls") mpls_t[3] mpls; - @name(".vlan_tag_") + @name(".vlan_tag_") vlan_tag_t[2] vlan_tag_; } @@ -1314,18 +1332,6 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout @name(".lag_action_profile") @mode("fair") action_selector(HashAlgorithm.identity, 32w1024, 32w8) lag_action_profile; -struct tuple_0 { - bit<32> f0; - bit<16> f1; -} - -struct tuple_1 { - bit<16> f0; - bit<16> f1; - bit<16> f2; - bit<9> f3; -} - control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @noWarn("unused") @name(".NoAction") action NoAction_2() { } @@ -3143,16 +3149,16 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } @name(".egress_mirror") action _egress_mirror_0(@name("session_id") bit<32> session_id) { meta._i2e_metadata_mirror_session_id36 = (bit<16>)session_id; - clone3(CloneType.E2E, session_id, (tuple_0){f0 = meta._i2e_metadata_ingress_tstamp35,f1 = (bit<16>)session_id}); + clone_preserving_field_list(CloneType.E2E, session_id, 8w2); } @name(".egress_mirror_drop") action _egress_mirror_drop_0(@name("session_id") bit<32> session_id_6) { meta._i2e_metadata_mirror_session_id36 = (bit<16>)session_id_6; - clone3(CloneType.E2E, session_id_6, (tuple_0){f0 = meta._i2e_metadata_ingress_tstamp35,f1 = (bit<16>)session_id_6}); + clone_preserving_field_list(CloneType.E2E, session_id_6, 8w2); mark_to_drop(standard_metadata); } @name(".egress_redirect_to_cpu") action _egress_redirect_to_cpu_0(@name("reason_code") bit<16> reason_code_0) { meta._fabric_metadata_reason_code28 = reason_code_0; - clone3(CloneType.E2E, 32w250, (tuple_1){f0 = meta._ingress_metadata_bd42,f1 = meta._ingress_metadata_ifindex38,f2 = reason_code_0,f3 = meta._ingress_metadata_ingress_port37}); + clone_preserving_field_list(CloneType.E2E, 32w250, 8w1); mark_to_drop(standard_metadata); } @name(".egress_acl") table _egress_acl { @@ -3267,18 +3273,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t @name(".drop_stats_2") counter>(32w1024, CounterType.packets) drop_stats_2; -struct tuple_2 { - bit<1> f0; - bit<16> f1; -} - -struct tuple_3 { - tuple_1 f0; - bit<16> f1; - bit<16> f2; -} - -struct tuple_4 { +struct tuple_0 { bit<32> f0; bit<32> f1; bit<8> f2; @@ -3286,7 +3281,7 @@ struct tuple_4 { bit<16> f4; } -struct tuple_5 { +struct tuple_1 { bit<48> f0; bit<48> f1; bit<32> f2; @@ -3296,7 +3291,7 @@ struct tuple_5 { bit<16> f6; } -struct tuple_6 { +struct tuple_2 { bit<128> f0; bit<128> f1; bit<8> f2; @@ -3304,7 +3299,7 @@ struct tuple_6 { bit<16> f4; } -struct tuple_7 { +struct tuple_3 { bit<48> f0; bit<48> f1; bit<128> f2; @@ -3314,18 +3309,13 @@ struct tuple_7 { bit<16> f6; } -struct tuple_8 { +struct tuple_4 { bit<16> f0; bit<48> f1; bit<48> f2; bit<16> f3; } -struct tuple_9 { - bit<16> f0; - bit<8> f1; -} - control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @noWarn("unused") @name(".NoAction") action NoAction_37() { } @@ -3811,7 +3801,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ meta._int_metadata_insert_byte_cnt50 = meta._int_metadata_gpe_int_hdr_len51 << 2; meta._int_metadata_i2e_sink54 = 1w1; meta._i2e_metadata_mirror_session_id36 = (bit<16>)mirror_id; - clone3(CloneType.I2E, mirror_id, (tuple_2){f0 = 1w1,f1 = (bit<16>)mirror_id}); + clone_preserving_field_list(CloneType.I2E, mirror_id, 8w3); hdr.int_header.setInvalid(); hdr.int_val[0].setInvalid(); hdr.int_val[1].setInvalid(); @@ -4501,7 +4491,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ _sflow_ingress_session_pkt_counter.count(); meta._fabric_metadata_reason_code28 = reason_code_5; meta._i2e_metadata_mirror_session_id36 = (bit<16>)sflow_i2e_mirror_id; - clone3(CloneType.I2E, sflow_i2e_mirror_id, (tuple_3){f0 = (tuple_1){f0 = meta._ingress_metadata_bd42,f1 = meta._ingress_metadata_ifindex38,f2 = reason_code_5,f3 = meta._ingress_metadata_ingress_port37},f1 = meta._sflow_metadata_sflow_session_id136,f2 = (bit<16>)sflow_i2e_mirror_id}); + clone_preserving_field_list(CloneType.I2E, sflow_i2e_mirror_id, 8w5); } @name(".sflow_ing_take_sample") table _sflow_ing_take_sample { actions = { @@ -4685,7 +4675,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ @name(".acl_mirror") action _acl_mirror_1(@name("session_id") bit<32> session_id_8, @name("acl_stats_index") bit<14> acl_stats_index_20, @name("acl_meter_index") bit<16> acl_meter_index_11) { meta._i2e_metadata_mirror_session_id36 = (bit<16>)session_id_8; meta._i2e_metadata_ingress_tstamp35 = (bit<32>)standard_metadata.ingress_global_timestamp; - clone3(CloneType.I2E, session_id_8, (tuple_0){f0 = (bit<32>)standard_metadata.ingress_global_timestamp,f1 = (bit<16>)session_id_8}); + clone_preserving_field_list(CloneType.I2E, session_id_8, 8w0); meta._acl_metadata_acl_stats_index11 = acl_stats_index_20; meta._meter_metadata_meter_index107 = acl_meter_index_11; } @@ -4760,14 +4750,14 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ @name(".acl_mirror") action _acl_mirror_2(@name("session_id") bit<32> session_id_9, @name("acl_stats_index") bit<14> acl_stats_index_27, @name("acl_meter_index") bit<16> acl_meter_index_18) { meta._i2e_metadata_mirror_session_id36 = (bit<16>)session_id_9; meta._i2e_metadata_ingress_tstamp35 = (bit<32>)standard_metadata.ingress_global_timestamp; - clone3(CloneType.I2E, session_id_9, (tuple_0){f0 = (bit<32>)standard_metadata.ingress_global_timestamp,f1 = (bit<16>)session_id_9}); + clone_preserving_field_list(CloneType.I2E, session_id_9, 8w0); meta._acl_metadata_acl_stats_index11 = acl_stats_index_27; meta._meter_metadata_meter_index107 = acl_meter_index_18; } @name(".acl_mirror") action _acl_mirror_3(@name("session_id") bit<32> session_id_10, @name("acl_stats_index") bit<14> acl_stats_index_28, @name("acl_meter_index") bit<16> acl_meter_index_19) { meta._i2e_metadata_mirror_session_id36 = (bit<16>)session_id_10; meta._i2e_metadata_ingress_tstamp35 = (bit<32>)standard_metadata.ingress_global_timestamp; - clone3(CloneType.I2E, session_id_10, (tuple_0){f0 = (bit<32>)standard_metadata.ingress_global_timestamp,f1 = (bit<16>)session_id_10}); + clone_preserving_field_list(CloneType.I2E, session_id_10, 8w0); meta._acl_metadata_acl_stats_index11 = acl_stats_index_28; meta._meter_metadata_meter_index107 = acl_meter_index_19; } @@ -5403,15 +5393,15 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ default_action = NoAction_97(); } @name(".compute_lkp_ipv4_hash") action _compute_lkp_ipv4_hash_0() { - hash, bit<16>, tuple_4, bit<32>>(meta._hash_metadata_hash132, HashAlgorithm.crc16, 16w0, (tuple_4){f0 = meta._ipv4_metadata_lkp_ipv4_sa56,f1 = meta._ipv4_metadata_lkp_ipv4_da57,f2 = meta._l3_metadata_lkp_ip_proto82,f3 = meta._l3_metadata_lkp_l4_sport85,f4 = meta._l3_metadata_lkp_l4_dport86}, 32w65536); - hash, bit<16>, tuple_5, bit<32>>(meta._hash_metadata_hash233, HashAlgorithm.crc16, 16w0, (tuple_5){f0 = meta._l2_metadata_lkp_mac_sa65,f1 = meta._l2_metadata_lkp_mac_da66,f2 = meta._ipv4_metadata_lkp_ipv4_sa56,f3 = meta._ipv4_metadata_lkp_ipv4_da57,f4 = meta._l3_metadata_lkp_ip_proto82,f5 = meta._l3_metadata_lkp_l4_sport85,f6 = meta._l3_metadata_lkp_l4_dport86}, 32w65536); + hash, bit<16>, tuple_0, bit<32>>(meta._hash_metadata_hash132, HashAlgorithm.crc16, 16w0, (tuple_0){f0 = meta._ipv4_metadata_lkp_ipv4_sa56,f1 = meta._ipv4_metadata_lkp_ipv4_da57,f2 = meta._l3_metadata_lkp_ip_proto82,f3 = meta._l3_metadata_lkp_l4_sport85,f4 = meta._l3_metadata_lkp_l4_dport86}, 32w65536); + hash, bit<16>, tuple_1, bit<32>>(meta._hash_metadata_hash233, HashAlgorithm.crc16, 16w0, (tuple_1){f0 = meta._l2_metadata_lkp_mac_sa65,f1 = meta._l2_metadata_lkp_mac_da66,f2 = meta._ipv4_metadata_lkp_ipv4_sa56,f3 = meta._ipv4_metadata_lkp_ipv4_da57,f4 = meta._l3_metadata_lkp_ip_proto82,f5 = meta._l3_metadata_lkp_l4_sport85,f6 = meta._l3_metadata_lkp_l4_dport86}, 32w65536); } @name(".compute_lkp_ipv6_hash") action _compute_lkp_ipv6_hash_0() { - hash, bit<16>, tuple_6, bit<32>>(meta._hash_metadata_hash132, HashAlgorithm.crc16, 16w0, (tuple_6){f0 = meta._ipv6_metadata_lkp_ipv6_sa60,f1 = meta._ipv6_metadata_lkp_ipv6_da61,f2 = meta._l3_metadata_lkp_ip_proto82,f3 = meta._l3_metadata_lkp_l4_sport85,f4 = meta._l3_metadata_lkp_l4_dport86}, 32w65536); - hash, bit<16>, tuple_7, bit<32>>(meta._hash_metadata_hash233, HashAlgorithm.crc16, 16w0, (tuple_7){f0 = meta._l2_metadata_lkp_mac_sa65,f1 = meta._l2_metadata_lkp_mac_da66,f2 = meta._ipv6_metadata_lkp_ipv6_sa60,f3 = meta._ipv6_metadata_lkp_ipv6_da61,f4 = meta._l3_metadata_lkp_ip_proto82,f5 = meta._l3_metadata_lkp_l4_sport85,f6 = meta._l3_metadata_lkp_l4_dport86}, 32w65536); + hash, bit<16>, tuple_2, bit<32>>(meta._hash_metadata_hash132, HashAlgorithm.crc16, 16w0, (tuple_2){f0 = meta._ipv6_metadata_lkp_ipv6_sa60,f1 = meta._ipv6_metadata_lkp_ipv6_da61,f2 = meta._l3_metadata_lkp_ip_proto82,f3 = meta._l3_metadata_lkp_l4_sport85,f4 = meta._l3_metadata_lkp_l4_dport86}, 32w65536); + hash, bit<16>, tuple_3, bit<32>>(meta._hash_metadata_hash233, HashAlgorithm.crc16, 16w0, (tuple_3){f0 = meta._l2_metadata_lkp_mac_sa65,f1 = meta._l2_metadata_lkp_mac_da66,f2 = meta._ipv6_metadata_lkp_ipv6_sa60,f3 = meta._ipv6_metadata_lkp_ipv6_da61,f4 = meta._l3_metadata_lkp_ip_proto82,f5 = meta._l3_metadata_lkp_l4_sport85,f6 = meta._l3_metadata_lkp_l4_dport86}, 32w65536); } @name(".compute_lkp_non_ip_hash") action _compute_lkp_non_ip_hash_0() { - hash, bit<16>, tuple_8, bit<32>>(meta._hash_metadata_hash233, HashAlgorithm.crc16, 16w0, (tuple_8){f0 = meta._ingress_metadata_ifindex38,f1 = meta._l2_metadata_lkp_mac_sa65,f2 = meta._l2_metadata_lkp_mac_da66,f3 = meta._l2_metadata_lkp_mac_type68}, 32w65536); + hash, bit<16>, tuple_4, bit<32>>(meta._hash_metadata_hash233, HashAlgorithm.crc16, 16w0, (tuple_4){f0 = meta._ingress_metadata_ifindex38,f1 = meta._l2_metadata_lkp_mac_sa65,f2 = meta._l2_metadata_lkp_mac_da66,f3 = meta._l2_metadata_lkp_mac_type68}, 32w65536); } @name(".computed_two_hashes") action _computed_two_hashes_0() { meta._hash_metadata_entropy_hash34 = meta._hash_metadata_hash233; @@ -5761,16 +5751,16 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } @name(".copy_to_cpu_with_reason") action _copy_to_cpu_with_reason_0(@name("reason_code") bit<16> reason_code_6) { meta._fabric_metadata_reason_code28 = reason_code_6; - clone3(CloneType.I2E, 32w250, (tuple_1){f0 = meta._ingress_metadata_bd42,f1 = meta._ingress_metadata_ifindex38,f2 = reason_code_6,f3 = meta._ingress_metadata_ingress_port37}); + clone_preserving_field_list(CloneType.I2E, 32w250, 8w1); } @name(".redirect_to_cpu") action _redirect_to_cpu_0(@name("reason_code") bit<16> reason_code_7) { meta._fabric_metadata_reason_code28 = reason_code_7; - clone3(CloneType.I2E, 32w250, (tuple_1){f0 = meta._ingress_metadata_bd42,f1 = meta._ingress_metadata_ifindex38,f2 = reason_code_7,f3 = meta._ingress_metadata_ingress_port37}); + clone_preserving_field_list(CloneType.I2E, 32w250, 8w1); mark_to_drop(standard_metadata); meta._fabric_metadata_dst_device29 = 8w0; } @name(".copy_to_cpu") action _copy_to_cpu_0() { - clone3(CloneType.I2E, 32w250, (tuple_1){f0 = meta._ingress_metadata_bd42,f1 = meta._ingress_metadata_ifindex38,f2 = meta._fabric_metadata_reason_code28,f3 = meta._ingress_metadata_ingress_port37}); + clone_preserving_field_list(CloneType.I2E, 32w250, 8w1); } @name(".drop_packet") action _drop_packet_0() { mark_to_drop(standard_metadata); @@ -5780,7 +5770,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ mark_to_drop(standard_metadata); } @name(".negative_mirror") action _negative_mirror_0(@name("session_id") bit<32> session_id_11) { - clone3(CloneType.I2E, session_id_11, (tuple_9){f0 = meta._ingress_metadata_ifindex38,f1 = meta._ingress_metadata_drop_reason44}); + clone_preserving_field_list(CloneType.I2E, session_id_11, 8w4); mark_to_drop(standard_metadata); } @name(".drop_stats") table _drop_stats { @@ -6176,7 +6166,7 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct tuple_10 { +struct tuple_5 { bit<4> f0; bit<4> f1; bit<8> f2; @@ -6192,17 +6182,16 @@ struct tuple_10 { control verifyChecksum(inout headers hdr, inout metadata meta) { apply { - verify_checksum>(hdr.inner_ipv4.ihl == 4w5, (tuple_10){f0 = hdr.inner_ipv4.version,f1 = hdr.inner_ipv4.ihl,f2 = hdr.inner_ipv4.diffserv,f3 = hdr.inner_ipv4.totalLen,f4 = hdr.inner_ipv4.identification,f5 = hdr.inner_ipv4.flags,f6 = hdr.inner_ipv4.fragOffset,f7 = hdr.inner_ipv4.ttl,f8 = hdr.inner_ipv4.protocol,f9 = hdr.inner_ipv4.srcAddr,f10 = hdr.inner_ipv4.dstAddr}, hdr.inner_ipv4.hdrChecksum, HashAlgorithm.csum16); - verify_checksum>(hdr.ipv4.ihl == 4w5, (tuple_10){f0 = hdr.ipv4.version,f1 = hdr.ipv4.ihl,f2 = hdr.ipv4.diffserv,f3 = hdr.ipv4.totalLen,f4 = hdr.ipv4.identification,f5 = hdr.ipv4.flags,f6 = hdr.ipv4.fragOffset,f7 = hdr.ipv4.ttl,f8 = hdr.ipv4.protocol,f9 = hdr.ipv4.srcAddr,f10 = hdr.ipv4.dstAddr}, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); + verify_checksum>(hdr.inner_ipv4.ihl == 4w5, (tuple_5){f0 = hdr.inner_ipv4.version,f1 = hdr.inner_ipv4.ihl,f2 = hdr.inner_ipv4.diffserv,f3 = hdr.inner_ipv4.totalLen,f4 = hdr.inner_ipv4.identification,f5 = hdr.inner_ipv4.flags,f6 = hdr.inner_ipv4.fragOffset,f7 = hdr.inner_ipv4.ttl,f8 = hdr.inner_ipv4.protocol,f9 = hdr.inner_ipv4.srcAddr,f10 = hdr.inner_ipv4.dstAddr}, hdr.inner_ipv4.hdrChecksum, HashAlgorithm.csum16); + verify_checksum>(hdr.ipv4.ihl == 4w5, (tuple_5){f0 = hdr.ipv4.version,f1 = hdr.ipv4.ihl,f2 = hdr.ipv4.diffserv,f3 = hdr.ipv4.totalLen,f4 = hdr.ipv4.identification,f5 = hdr.ipv4.flags,f6 = hdr.ipv4.fragOffset,f7 = hdr.ipv4.ttl,f8 = hdr.ipv4.protocol,f9 = hdr.ipv4.srcAddr,f10 = hdr.ipv4.dstAddr}, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); } } control computeChecksum(inout headers hdr, inout metadata meta) { apply { - update_checksum>(hdr.inner_ipv4.ihl == 4w5, (tuple_10){f0 = hdr.inner_ipv4.version,f1 = hdr.inner_ipv4.ihl,f2 = hdr.inner_ipv4.diffserv,f3 = hdr.inner_ipv4.totalLen,f4 = hdr.inner_ipv4.identification,f5 = hdr.inner_ipv4.flags,f6 = hdr.inner_ipv4.fragOffset,f7 = hdr.inner_ipv4.ttl,f8 = hdr.inner_ipv4.protocol,f9 = hdr.inner_ipv4.srcAddr,f10 = hdr.inner_ipv4.dstAddr}, hdr.inner_ipv4.hdrChecksum, HashAlgorithm.csum16); - update_checksum>(hdr.ipv4.ihl == 4w5, (tuple_10){f0 = hdr.ipv4.version,f1 = hdr.ipv4.ihl,f2 = hdr.ipv4.diffserv,f3 = hdr.ipv4.totalLen,f4 = hdr.ipv4.identification,f5 = hdr.ipv4.flags,f6 = hdr.ipv4.fragOffset,f7 = hdr.ipv4.ttl,f8 = hdr.ipv4.protocol,f9 = hdr.ipv4.srcAddr,f10 = hdr.ipv4.dstAddr}, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); + update_checksum>(hdr.inner_ipv4.ihl == 4w5, (tuple_5){f0 = hdr.inner_ipv4.version,f1 = hdr.inner_ipv4.ihl,f2 = hdr.inner_ipv4.diffserv,f3 = hdr.inner_ipv4.totalLen,f4 = hdr.inner_ipv4.identification,f5 = hdr.inner_ipv4.flags,f6 = hdr.inner_ipv4.fragOffset,f7 = hdr.inner_ipv4.ttl,f8 = hdr.inner_ipv4.protocol,f9 = hdr.inner_ipv4.srcAddr,f10 = hdr.inner_ipv4.dstAddr}, hdr.inner_ipv4.hdrChecksum, HashAlgorithm.csum16); + update_checksum>(hdr.ipv4.ihl == 4w5, (tuple_5){f0 = hdr.ipv4.version,f1 = hdr.ipv4.ihl,f2 = hdr.ipv4.diffserv,f3 = hdr.ipv4.totalLen,f4 = hdr.ipv4.identification,f5 = hdr.ipv4.flags,f6 = hdr.ipv4.fragOffset,f7 = hdr.ipv4.ttl,f8 = hdr.ipv4.protocol,f9 = hdr.ipv4.srcAddr,f10 = hdr.ipv4.dstAddr}, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); } } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_14_samples_outputs/switch_20160512/switch.p4 b/testdata/p4_14_samples_outputs/switch_20160512/switch.p4 index 7ae9e18b784..44152b60a48 100644 --- a/testdata/p4_14_samples_outputs/switch_20160512/switch.p4 +++ b/testdata/p4_14_samples_outputs/switch_20160512/switch.p4 @@ -2,6 +2,15 @@ #define V1MODEL_VERSION 20200408 #include +enum bit<8> FieldLists { + i2e_mirror_info = 0, + cpu_info = 1, + e2e_mirror_info = 2, + int_i2e_mirror_info = 3, + mirror_info = 4, + sflow_cpu_info = 5 +} + struct acl_metadata_t { bit<1> acl_deny; bit<1> acl_copy; @@ -40,6 +49,7 @@ struct egress_metadata_t { struct fabric_metadata_t { bit<3> packetType; bit<1> fabric_header_present; + @field_list(FieldLists.cpu_info, FieldLists.sflow_cpu_info) bit<16> reason_code; bit<8> dst_device; bit<16> dst_port; @@ -56,22 +66,28 @@ struct hash_metadata_t { } struct i2e_metadata_t { + @field_list(FieldLists.i2e_mirror_info, FieldLists.e2e_mirror_info) bit<32> ingress_tstamp; + @field_list(FieldLists.i2e_mirror_info, FieldLists.e2e_mirror_info, FieldLists.int_i2e_mirror_info) bit<16> mirror_session_id; } struct ingress_metadata_t { + @field_list(FieldLists.cpu_info, FieldLists.sflow_cpu_info) bit<9> ingress_port; + @field_list(FieldLists.cpu_info, FieldLists.mirror_info, FieldLists.sflow_cpu_info) bit<16> ifindex; bit<16> egress_ifindex; bit<2> port_type; bit<16> outer_bd; + @field_list(FieldLists.cpu_info, FieldLists.sflow_cpu_info) bit<16> bd; bit<1> drop_flag; + @field_list(FieldLists.mirror_info) bit<8> drop_reason; bit<1> control_frame; bit<16> bypass_lookups; - @saturating + @saturating bit<32> sflow_take_sample; } @@ -85,6 +101,7 @@ struct int_metadata_t { } struct int_metadata_i2e_t { + @field_list(FieldLists.int_i2e_mirror_info) bit<1> sink; bit<1> source; } @@ -155,7 +172,7 @@ struct l3_metadata_t { bit<1> outer_routed; bit<8> mtu_index; bit<1> l3_copy; - @saturating + @saturating bit<16> l3_mtu_check; } @@ -640,166 +657,166 @@ header vlan_tag_t { } struct metadata { - @name(".acl_metadata") + @name(".acl_metadata") acl_metadata_t acl_metadata; - @name(".egress_filter_metadata") + @name(".egress_filter_metadata") egress_filter_metadata_t egress_filter_metadata; - @name(".egress_metadata") + @name(".egress_metadata") egress_metadata_t egress_metadata; - @name(".fabric_metadata") + @name(".fabric_metadata") fabric_metadata_t fabric_metadata; - @name(".global_config_metadata") + @name(".global_config_metadata") global_config_metadata_t global_config_metadata; - @name(".hash_metadata") + @name(".hash_metadata") hash_metadata_t hash_metadata; - @name(".i2e_metadata") + @name(".i2e_metadata") i2e_metadata_t i2e_metadata; - @name(".ingress_metadata") + @name(".ingress_metadata") ingress_metadata_t ingress_metadata; - @name(".int_metadata") + @name(".int_metadata") int_metadata_t int_metadata; - @name(".int_metadata_i2e") + @name(".int_metadata_i2e") int_metadata_i2e_t int_metadata_i2e; - @name(".ipv4_metadata") + @name(".ipv4_metadata") ipv4_metadata_t ipv4_metadata; - @name(".ipv6_metadata") + @name(".ipv6_metadata") ipv6_metadata_t ipv6_metadata; - @name(".l2_metadata") + @name(".l2_metadata") l2_metadata_t l2_metadata; - @name(".l3_metadata") + @name(".l3_metadata") l3_metadata_t l3_metadata; - @name(".meter_metadata") + @name(".meter_metadata") meter_metadata_t meter_metadata; - @name(".multicast_metadata") + @name(".multicast_metadata") multicast_metadata_t multicast_metadata; - @name(".nexthop_metadata") + @name(".nexthop_metadata") nexthop_metadata_t nexthop_metadata; - @name(".qos_metadata") + @name(".qos_metadata") qos_metadata_t qos_metadata; - @name(".security_metadata") + @name(".security_metadata") security_metadata_t security_metadata; - @name(".sflow_metadata") + @name(".sflow_metadata") sflow_meta_t sflow_metadata; - @name(".tunnel_metadata") + @name(".tunnel_metadata") tunnel_metadata_t tunnel_metadata; } struct headers { - @name(".arp_rarp") + @name(".arp_rarp") arp_rarp_t arp_rarp; - @name(".arp_rarp_ipv4") + @name(".arp_rarp_ipv4") arp_rarp_ipv4_t arp_rarp_ipv4; - @name(".bfd") + @name(".bfd") bfd_t bfd; - @name(".eompls") + @name(".eompls") eompls_t eompls; - @name(".erspan_t3_header") + @name(".erspan_t3_header") erspan_header_t3_t_0 erspan_t3_header; - @name(".ethernet") + @name(".ethernet") ethernet_t ethernet; - @name(".fabric_header") + @name(".fabric_header") fabric_header_t fabric_header; - @name(".fabric_header_cpu") + @name(".fabric_header_cpu") fabric_header_cpu_t fabric_header_cpu; - @name(".fabric_header_mirror") + @name(".fabric_header_mirror") fabric_header_mirror_t fabric_header_mirror; - @name(".fabric_header_multicast") + @name(".fabric_header_multicast") fabric_header_multicast_t fabric_header_multicast; - @name(".fabric_header_sflow") + @name(".fabric_header_sflow") fabric_header_sflow_t fabric_header_sflow; - @name(".fabric_header_unicast") + @name(".fabric_header_unicast") fabric_header_unicast_t fabric_header_unicast; - @name(".fabric_payload_header") + @name(".fabric_payload_header") fabric_payload_header_t fabric_payload_header; - @name(".fcoe") + @name(".fcoe") fcoe_header_t fcoe; - @name(".genv") + @name(".genv") genv_t genv; - @name(".gre") + @name(".gre") gre_t gre; - @name(".icmp") + @name(".icmp") icmp_t icmp; - @name(".inner_ethernet") + @name(".inner_ethernet") ethernet_t inner_ethernet; - @name(".inner_icmp") + @name(".inner_icmp") icmp_t inner_icmp; - @name(".inner_ipv4") + @name(".inner_ipv4") ipv4_t inner_ipv4; - @name(".inner_ipv6") + @name(".inner_ipv6") ipv6_t inner_ipv6; - @name(".inner_sctp") + @name(".inner_sctp") sctp_t inner_sctp; - @name(".inner_tcp") + @name(".inner_tcp") tcp_t inner_tcp; - @name(".inner_udp") + @name(".inner_udp") udp_t inner_udp; - @name(".int_egress_port_id_header") + @name(".int_egress_port_id_header") int_egress_port_id_header_t int_egress_port_id_header; - @name(".int_egress_port_tx_utilization_header") + @name(".int_egress_port_tx_utilization_header") int_egress_port_tx_utilization_header_t int_egress_port_tx_utilization_header; - @name(".int_header") + @name(".int_header") int_header_t int_header; - @name(".int_hop_latency_header") + @name(".int_hop_latency_header") int_hop_latency_header_t int_hop_latency_header; - @name(".int_ingress_port_id_header") + @name(".int_ingress_port_id_header") int_ingress_port_id_header_t int_ingress_port_id_header; - @name(".int_ingress_tstamp_header") + @name(".int_ingress_tstamp_header") int_ingress_tstamp_header_t int_ingress_tstamp_header; - @name(".int_q_congestion_header") + @name(".int_q_congestion_header") int_q_congestion_header_t int_q_congestion_header; - @name(".int_q_occupancy_header") + @name(".int_q_occupancy_header") int_q_occupancy_header_t int_q_occupancy_header; - @name(".int_switch_id_header") + @name(".int_switch_id_header") int_switch_id_header_t int_switch_id_header; - @name(".ipv4") + @name(".ipv4") ipv4_t ipv4; - @name(".ipv6") + @name(".ipv6") ipv6_t ipv6; - @name(".lisp") + @name(".lisp") lisp_t lisp; - @name(".llc_header") + @name(".llc_header") llc_header_t llc_header; - @name(".nsh") + @name(".nsh") nsh_t nsh; - @name(".nsh_context") + @name(".nsh_context") nsh_context_t nsh_context; - @name(".nvgre") + @name(".nvgre") nvgre_t nvgre; - @name(".outer_udp") + @name(".outer_udp") udp_t outer_udp; - @name(".roce") + @name(".roce") roce_header_t roce; - @name(".roce_v2") + @name(".roce_v2") roce_v2_header_t roce_v2; - @name(".sctp") + @name(".sctp") sctp_t sctp; - @name(".sflow") + @name(".sflow") sflow_hdr_t sflow; - @name(".sflow_raw_hdr_record") + @name(".sflow_raw_hdr_record") sflow_raw_hdr_record_t sflow_raw_hdr_record; - @name(".sflow_sample") + @name(".sflow_sample") sflow_sample_t sflow_sample; - @name(".snap_header") + @name(".snap_header") snap_header_t snap_header; - @name(".tcp") + @name(".tcp") tcp_t tcp; - @name(".trill") + @name(".trill") trill_t trill; - @name(".udp") + @name(".udp") udp_t udp; - @name(".vntag") + @name(".vntag") vntag_t vntag; - @name(".vxlan") + @name(".vxlan") vxlan_t vxlan; - @name(".vxlan_gpe") + @name(".vxlan_gpe") vxlan_gpe_t vxlan_gpe; - @name(".vxlan_gpe_int_header") + @name(".vxlan_gpe_int_header") vxlan_gpe_int_header_t vxlan_gpe_int_header; - @name(".int_val") + @name(".int_val") int_value_t[24] int_val; - @name(".mpls") + @name(".mpls") mpls_t[3] mpls; - @name(".vlan_tag_") + @name(".vlan_tag_") vlan_tag_t[2] vlan_tag_; } @@ -2907,7 +2924,7 @@ control process_egress_acl(inout headers hdr, inout metadata meta, inout standar } @name(".egress_mirror") action egress_mirror(bit<32> session_id) { meta.i2e_metadata.mirror_session_id = (bit<16>)session_id; - clone3(CloneType.E2E, (bit<32>)session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); + clone_preserving_field_list(CloneType.E2E, (bit<32>)session_id, (bit<8>)FieldLists.e2e_mirror_info); } @name(".egress_mirror_drop") action egress_mirror_drop(bit<32> session_id) { egress_mirror(session_id); @@ -2915,7 +2932,7 @@ control process_egress_acl(inout headers hdr, inout metadata meta, inout standar } @name(".egress_copy_to_cpu") action egress_copy_to_cpu(bit<16> reason_code) { meta.fabric_metadata.reason_code = reason_code; - clone3(CloneType.E2E, (bit<32>)32w250, { meta.ingress_metadata.bd, meta.ingress_metadata.ifindex, meta.fabric_metadata.reason_code, meta.ingress_metadata.ingress_port }); + clone_preserving_field_list(CloneType.E2E, (bit<32>)32w250, (bit<8>)FieldLists.cpu_info); } @name(".egress_redirect_to_cpu") action egress_redirect_to_cpu(bit<16> reason_code) { egress_copy_to_cpu(reason_code); @@ -3411,7 +3428,7 @@ control process_int_endpoint(inout headers hdr, inout metadata meta, inout stand @name(".int_sink") action int_sink(bit<32> mirror_id) { meta.int_metadata_i2e.sink = 1w1; meta.i2e_metadata.mirror_session_id = (bit<16>)mirror_id; - clone3(CloneType.I2E, (bit<32>)mirror_id, { meta.int_metadata_i2e.sink, meta.i2e_metadata.mirror_session_id }); + clone_preserving_field_list(CloneType.I2E, (bit<32>)mirror_id, (bit<8>)FieldLists.int_i2e_mirror_info); hdr.int_header.setInvalid(); hdr.int_val[0].setInvalid(); hdr.int_val[1].setInvalid(); @@ -4160,7 +4177,7 @@ control process_ingress_sflow(inout headers hdr, inout metadata meta, inout stan @name(".sflow_ing_pkt_to_cpu") action sflow_ing_pkt_to_cpu(bit<32> sflow_i2e_mirror_id, bit<16> reason_code) { meta.fabric_metadata.reason_code = reason_code; meta.i2e_metadata.mirror_session_id = (bit<16>)sflow_i2e_mirror_id; - clone3(CloneType.I2E, (bit<32>)sflow_i2e_mirror_id, { { meta.ingress_metadata.bd, meta.ingress_metadata.ifindex, meta.fabric_metadata.reason_code, meta.ingress_metadata.ingress_port }, meta.sflow_metadata.sflow_session_id, meta.i2e_metadata.mirror_session_id }); + clone_preserving_field_list(CloneType.I2E, (bit<32>)sflow_i2e_mirror_id, (bit<8>)FieldLists.sflow_cpu_info); } @name(".sflow_ing_session_enable") action sflow_ing_session_enable(bit<32> rate_thr, bit<16> session_id) { meta.ingress_metadata.sflow_take_sample = rate_thr |+| meta.ingress_metadata.sflow_take_sample; @@ -4173,7 +4190,7 @@ control process_ingress_sflow(inout headers hdr, inout metadata meta, inout stan sflow_ingress_session_pkt_counter.count(); meta.fabric_metadata.reason_code = reason_code; meta.i2e_metadata.mirror_session_id = (bit<16>)sflow_i2e_mirror_id; - clone3(CloneType.I2E, (bit<32>)sflow_i2e_mirror_id, { { meta.ingress_metadata.bd, meta.ingress_metadata.ifindex, meta.fabric_metadata.reason_code, meta.ingress_metadata.ingress_port }, meta.sflow_metadata.sflow_session_id, meta.i2e_metadata.mirror_session_id }); + clone_preserving_field_list(CloneType.I2E, (bit<32>)sflow_i2e_mirror_id, (bit<8>)FieldLists.sflow_cpu_info); } @name(".sflow_ing_take_sample") table sflow_ing_take_sample { actions = { @@ -4379,7 +4396,7 @@ control process_mac_acl(inout headers hdr, inout metadata meta, inout standard_m @name(".acl_mirror") action acl_mirror(bit<32> session_id, bit<14> acl_stats_index, bit<16> acl_meter_index) { meta.i2e_metadata.mirror_session_id = (bit<16>)session_id; meta.i2e_metadata.ingress_tstamp = (bit<32>)standard_metadata.ingress_global_timestamp; - clone3(CloneType.I2E, (bit<32>)session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); + clone_preserving_field_list(CloneType.I2E, (bit<32>)session_id, (bit<8>)FieldLists.i2e_mirror_info); meta.acl_metadata.acl_stats_index = acl_stats_index; meta.meter_metadata.meter_index = acl_meter_index; } @@ -4445,7 +4462,7 @@ control process_ip_acl(inout headers hdr, inout metadata meta, inout standard_me @name(".acl_mirror") action acl_mirror(bit<32> session_id, bit<14> acl_stats_index, bit<16> acl_meter_index) { meta.i2e_metadata.mirror_session_id = (bit<16>)session_id; meta.i2e_metadata.ingress_tstamp = (bit<32>)standard_metadata.ingress_global_timestamp; - clone3(CloneType.I2E, (bit<32>)session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); + clone_preserving_field_list(CloneType.I2E, (bit<32>)session_id, (bit<8>)FieldLists.i2e_mirror_info); meta.acl_metadata.acl_stats_index = acl_stats_index; meta.meter_metadata.meter_index = acl_meter_index; } @@ -5610,7 +5627,7 @@ control process_system_acl(inout headers hdr, inout metadata meta, inout standar } @name(".copy_to_cpu_with_reason") action copy_to_cpu_with_reason(bit<16> reason_code) { meta.fabric_metadata.reason_code = reason_code; - clone3(CloneType.I2E, (bit<32>)32w250, { meta.ingress_metadata.bd, meta.ingress_metadata.ifindex, meta.fabric_metadata.reason_code, meta.ingress_metadata.ingress_port }); + clone_preserving_field_list(CloneType.I2E, (bit<32>)32w250, (bit<8>)FieldLists.cpu_info); } @name(".redirect_to_cpu") action redirect_to_cpu(bit<16> reason_code) { copy_to_cpu_with_reason(reason_code); @@ -5618,7 +5635,7 @@ control process_system_acl(inout headers hdr, inout metadata meta, inout standar meta.fabric_metadata.dst_device = 8w0; } @name(".copy_to_cpu") action copy_to_cpu() { - clone3(CloneType.I2E, (bit<32>)32w250, { meta.ingress_metadata.bd, meta.ingress_metadata.ifindex, meta.fabric_metadata.reason_code, meta.ingress_metadata.ingress_port }); + clone_preserving_field_list(CloneType.I2E, (bit<32>)32w250, (bit<8>)FieldLists.cpu_info); } @name(".drop_packet") action drop_packet() { mark_to_drop(standard_metadata); @@ -5628,7 +5645,7 @@ control process_system_acl(inout headers hdr, inout metadata meta, inout standar mark_to_drop(standard_metadata); } @name(".negative_mirror") action negative_mirror(bit<32> session_id) { - clone3(CloneType.I2E, (bit<32>)session_id, { meta.ingress_metadata.ifindex, meta.ingress_metadata.drop_reason }); + clone_preserving_field_list(CloneType.I2E, (bit<32>)session_id, (bit<8>)FieldLists.mirror_info); mark_to_drop(standard_metadata); } @name(".drop_stats") table drop_stats_0 { @@ -5873,4 +5890,3 @@ control computeChecksum(inout headers hdr, inout metadata meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_16_errors_outputs/issue1557-bmv2.p4-stderr b/testdata/p4_16_errors_outputs/issue1557-bmv2.p4-stderr index bd5628c07d0..2ab466cbd08 100644 --- a/testdata/p4_16_errors_outputs/issue1557-bmv2.p4-stderr +++ b/testdata/p4_16_errors_outputs/issue1557-bmv2.p4-stderr @@ -1,7 +1,7 @@ issue1557-bmv2.p4(17): [--Werror=type-error] error: Field drop is not a member of structure struct standard_metadata action drop() { smeta.drop = 1; } ^^^^ -v1model.p4(73) +v1model.p4(64) struct standard_metadata_t { ^^^^^^^^^^^^^^^^^^^ issue1557-bmv2.p4(19): [--Werror=type-error] error: idx: parameter should be assigned in call rewrite diff --git a/testdata/p4_16_errors_outputs/issue513.p4-stderr b/testdata/p4_16_errors_outputs/issue513.p4-stderr index b251bb67af4..894c8e4e166 100644 --- a/testdata/p4_16_errors_outputs/issue513.p4-stderr +++ b/testdata/p4_16_errors_outputs/issue513.p4-stderr @@ -1,7 +1,7 @@ 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(415) +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 diff --git a/testdata/p4_16_samples/issue1001-1-bmv2.p4 b/testdata/p4_16_samples/issue1001-1-bmv2.p4 new file mode 100644 index 00000000000..c6eadd3291a --- /dev/null +++ b/testdata/p4_16_samples/issue1001-1-bmv2.p4 @@ -0,0 +1,33 @@ +#include +#include + +struct Headers {} + +enum bit<8> PreservedFieldList { + Field = 8w1 +} + +struct Meta { + @field_list(PreservedFieldList.Field) + bit<1> b; +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + m.b = m.b + 1; + transition accept; + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + clone_preserving_field_list(CloneType.I2E, 32w64, PreservedFieldList.Field); + } +} + +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 b, in Headers h) { apply {} } + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/p4_16_samples/issue1001-bmv2.p4 b/testdata/p4_16_samples/issue1001-bmv2.p4 index 196eb962daa..4aff2655c9c 100644 --- a/testdata/p4_16_samples/issue1001-bmv2.p4 +++ b/testdata/p4_16_samples/issue1001-bmv2.p4 @@ -4,6 +4,7 @@ struct Headers {} struct Meta { + @field_list(0) bit<1> b; } @@ -15,9 +16,8 @@ parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) } control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - Meta x; apply { - clone3(CloneType.I2E, 32w64, x); + clone_preserving_field_list(CloneType.I2E, 32w64, 0); } } diff --git a/testdata/p4_16_samples/issue1043-bmv2.p4 b/testdata/p4_16_samples/issue1043-bmv2.p4 index ec45fb242a2..bbe35d09830 100644 --- a/testdata/p4_16_samples/issue1043-bmv2.p4 +++ b/testdata/p4_16_samples/issue1043-bmv2.p4 @@ -30,7 +30,7 @@ control deparser(packet_out b, in Headers h) { control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { apply { - resubmit(m); + resubmit_preserving_field_list(0); sm.egress_spec = 0; } } diff --git a/testdata/p4_16_samples/issue1642-bmv2.p4 b/testdata/p4_16_samples/issue1642-bmv2.p4 index 1fc01da9229..2065c7866d3 100644 --- a/testdata/p4_16_samples/issue1642-bmv2.p4 +++ b/testdata/p4_16_samples/issue1642-bmv2.p4 @@ -5,28 +5,29 @@ header short { } struct alt_t { - bit<1> valid; - bit<7> port; + bit<1> valid; + bit<7> port; }; struct row_t { - alt_t alt0; - alt_t alt1; + alt_t alt0; + alt_t alt1; }; struct parsed_packet_t {}; struct local_metadata_t { short s; + @field_list(0) row_t row; }; parser parse(packet_in pk, out parsed_packet_t hdr, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - state start { - transition accept; - } + state start { + transition accept; + } } control ingress(inout parsed_packet_t hdr, @@ -38,28 +39,28 @@ control ingress(inout parsed_packet_t hdr, local_metadata.row.alt0 = local_metadata.row.alt1; local_metadata.row.alt0.valid = 1; local_metadata.row.alt1.port = local_metadata.row.alt1.port + 1; - clone3(CloneType.I2E, 0, local_metadata.row); + clone_preserving_field_list(CloneType.I2E, 0, 0); } } control egress(inout parsed_packet_t hdr, inout local_metadata_t local_metadata, - inout standard_metadata_t standard_metadata) { - apply { } + inout standard_metadata_t standard_metadata) { + apply { } } control deparser(packet_out b, in parsed_packet_t hdr) { - apply { } + apply { } } control verifyChecksum(inout parsed_packet_t hdr, inout local_metadata_t local_metadata) { - apply { } + apply { } } control compute_checksum(inout parsed_packet_t hdr, inout local_metadata_t local_metadata) { - apply { } + apply { } } V1Switch(parse(), verifyChecksum(), ingress(), egress(), diff --git a/testdata/p4_16_samples/issue1653-bmv2.p4 b/testdata/p4_16_samples/issue1653-bmv2.p4 index 002d907d7b6..c8f387e1c17 100644 --- a/testdata/p4_16_samples/issue1653-bmv2.p4 +++ b/testdata/p4_16_samples/issue1653-bmv2.p4 @@ -43,10 +43,9 @@ control ingress(inout parsed_packet_t h, inout local_metadata_t local_metadata, bitvec_hdr bh; apply { - // Copy another header's data to local variable. bh.x = h.bvh0.x; - clone3(CloneType.I2E, 0, h); + clone_preserving_field_list(CloneType.I2E, 0, 0); } } diff --git a/testdata/p4_16_samples/issue1653-complex-bmv2.p4 b/testdata/p4_16_samples/issue1653-complex-bmv2.p4 index e1a227c2152..25019e36b16 100644 --- a/testdata/p4_16_samples/issue1653-complex-bmv2.p4 +++ b/testdata/p4_16_samples/issue1653-complex-bmv2.p4 @@ -44,6 +44,7 @@ header bitvec_hdr { } struct local_metadata_t { + @field_list(0) row_t row0; row_t row1; bitvec_hdr bvh0; @@ -95,7 +96,7 @@ control ingress(inout parsed_packet_t h, h.bvh0.row.alt1.type = bh.row.alt1.type; local_metadata.row0.alt0.useHash = true; - clone3(CloneType.I2E, 0, local_metadata.row0); + clone_preserving_field_list(CloneType.I2E, 0, 0); } } diff --git a/testdata/p4_16_samples/issue1660-bmv2.p4 b/testdata/p4_16_samples/issue1660-bmv2.p4 index 45b0518daec..3ca84cd167c 100644 --- a/testdata/p4_16_samples/issue1660-bmv2.p4 +++ b/testdata/p4_16_samples/issue1660-bmv2.p4 @@ -1,6 +1,7 @@ #include struct HasBool { + @field_list(0) bool x; } @@ -19,7 +20,7 @@ control ingress(inout parsed_packet_t h, inout local_metadata_t local_metadata, apply { HasBool b; b.x = true; - clone3(CloneType.I2E, 0, b); + clone_preserving_field_list(CloneType.I2E, 0, 0); } } diff --git a/testdata/p4_16_samples/issue1765-1-bmv2.p4 b/testdata/p4_16_samples/issue1765-1-bmv2.p4 index ed650dafb71..16d94d9bea6 100644 --- a/testdata/p4_16_samples/issue1765-1-bmv2.p4 +++ b/testdata/p4_16_samples/issue1765-1-bmv2.p4 @@ -115,10 +115,15 @@ struct headers { } struct metadata { + @field_list(0) port_t ingress_port; + @field_list(0) task_t task; + @field_list(0) bit<16> tcp_length; + @field_list(0) bit<32> cast_length; + @field_list(0) bit<1> do_cksum; } @@ -203,12 +208,12 @@ control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadat action controller_debug() { meta.task = TASK_DEBUG; meta.ingress_port = standard_metadata.ingress_port; - clone3(CloneType.I2E, 100, meta); + clone_preserving_field_list(CloneType.I2E, 100, 0); } action controller_reply(task_t task) { meta.task = task; meta.ingress_port = standard_metadata.ingress_port; - clone3(CloneType.I2E, 100, meta); + clone_preserving_field_list(CloneType.I2E, 100, 0); } action multicast_pkg(mcast_t mcast_grp) { standard_metadata.mcast_grp = mcast_grp; diff --git a/testdata/p4_16_samples/issue383-bmv2.p4 b/testdata/p4_16_samples/issue383-bmv2.p4 index cc5f8586ed0..94fe476fcd1 100644 --- a/testdata/p4_16_samples/issue383-bmv2.p4 +++ b/testdata/p4_16_samples/issue383-bmv2.p4 @@ -18,30 +18,31 @@ limitations under the License. #include struct alt_t { - bit<1> valid; - bit<7> port; + bit<1> valid; + bit<7> port; }; @MNK_annotation("(test flatten)") struct row_t { - alt_t alt0; - alt_t alt1; + alt_t alt0; + alt_t alt1; }; header bitvec_hdr { - row_t row; + row_t row; } struct col_t { - bitvec_hdr bvh; + bitvec_hdr bvh; } struct local_metadata_t { - row_t row0; - row_t row1; - col_t col; - bitvec_hdr bvh0; - bitvec_hdr bvh1; + @field_list(0) + row_t row0; + row_t row1; + col_t col; + bitvec_hdr bvh0; + bitvec_hdr bvh1; }; struct parsed_packet_t { @@ -50,11 +51,11 @@ struct parsed_packet_t { }; struct tst_t { - row_t row0; - row_t row1; - col_t col; - bitvec_hdr bvh0; - bitvec_hdr bvh1; + row_t row0; + row_t row1; + col_t col; + bitvec_hdr bvh0; + bitvec_hdr bvh1; } parser parse(packet_in pk, out parsed_packet_t h, @@ -105,7 +106,7 @@ control ingress(inout parsed_packet_t h, local_metadata.row0.alt0 = local_metadata.row1.alt1; local_metadata.row1.alt0.valid = 1; local_metadata.row1.alt1.port = local_metadata.row0.alt1.port + 1; - clone3(CloneType.I2E, 0, local_metadata.row0); + clone_preserving_field_list(CloneType.I2E, 0, 0); /* Cast support is TODO for bmv2. diff --git a/testdata/p4_16_samples/issue562-bmv2.p4 b/testdata/p4_16_samples/issue562-bmv2.p4 index 36ff7baae99..52c60c0de69 100644 --- a/testdata/p4_16_samples/issue562-bmv2.p4 +++ b/testdata/p4_16_samples/issue562-bmv2.p4 @@ -13,7 +13,8 @@ struct row_t { struct parsed_packet_t {}; struct local_metadata_t { - row_t row; + @field_list(0) + row_t row; }; parser parse(packet_in pk, out parsed_packet_t hdr, @@ -31,7 +32,7 @@ control ingress(inout parsed_packet_t hdr, local_metadata.row.alt0 = local_metadata.row.alt1; local_metadata.row.alt0.valid = 1; local_metadata.row.alt1.port = local_metadata.row.alt1.port + 1; - clone3(CloneType.I2E, 0, local_metadata.row); + clone_preserving_field_list(CloneType.I2E, 0, 0); } } diff --git a/testdata/p4_16_samples/v1model-special-ops-bmv2.p4 b/testdata/p4_16_samples/v1model-special-ops-bmv2.p4 index 604a6eb5d3c..0527382fd29 100644 --- a/testdata/p4_16_samples/v1model-special-ops-bmv2.p4 +++ b/testdata/p4_16_samples/v1model-special-ops-bmv2.p4 @@ -229,7 +229,7 @@ control ingress(inout headers_t hdr, // If you give an entire struct, it includes all fields inside // of that struct. - resubmit({}); + resubmit_preserving_field_list(0); } action do_clone_i2e(bit<32> l2ptr) { // BMv2 simple_switch can have multiple different clone @@ -239,12 +239,12 @@ control ingress(inout headers_t hdr, // that. A 'mirroring session' and 'clone session' are simply // two different names for the same thing. - // The 3rd argument to clone3() is similar to the only + // The 3rd argument to clone() is similar to the only // argument to the resubmit() call. See the notes for the - // resubmit() call above. clone() is the same as clone3(), + // resubmit() call above. clone() is the same as clone(), // except there are only 2 parameters, and thus no metadata // field values are preserved in the cloned packet. - clone3(CloneType.I2E, I2E_CLONE_SESSION_ID, {}); + clone_preserving_field_list(CloneType.I2E, I2E_CLONE_SESSION_ID, 0); meta.fwd.l2ptr = l2ptr; } table ipv4_da_lpm { @@ -354,13 +354,13 @@ control egress(inout headers_t hdr, // See the resubmit() call above for comments about the // parameter to recirculate(), which has the same form as for // resubmit. - recirculate({}); + recirculate_preserving_field_list(0); } action do_clone_e2e(bit<48> smac) { hdr.ethernet.srcAddr = smac; // See the resubmit() call for notes on the 3rd argument, // which is similar to the only argument to resubmit(). - clone3(CloneType.E2E, E2E_CLONE_SESSION_ID, {}); + clone_preserving_field_list(CloneType.E2E, E2E_CLONE_SESSION_ID, 0); } table send_frame { key = { diff --git a/testdata/p4_16_samples_outputs/invalid-hdr-warnings3.p4 b/testdata/p4_16_samples_outputs/invalid-hdr-warnings3.p4 index febf7e422bd..77b63dc504f 100644 --- a/testdata/p4_16_samples_outputs/invalid-hdr-warnings3.p4 +++ b/testdata/p4_16_samples_outputs/invalid-hdr-warnings3.p4 @@ -77,3 +77,4 @@ control ComputeChecksumI(inout H hdr, inout M meta) { } V1Switch(ParserI(), VerifyChecksumI(), IngressI(), EgressI(), ComputeChecksumI(), DeparserI()) main; + diff --git a/testdata/p4_16_samples_outputs/issue1001-1-bmv2-first.p4 b/testdata/p4_16_samples_outputs/issue1001-1-bmv2-first.p4 new file mode 100644 index 00000000000..5eb2e13827d --- /dev/null +++ b/testdata/p4_16_samples_outputs/issue1001-1-bmv2-first.p4 @@ -0,0 +1,50 @@ +#include +#define V1MODEL_VERSION 20180101 +#include + +struct Headers { +} + +enum bit<8> PreservedFieldList { + Field = 8w1 +} + +struct Meta { + @field_list(PreservedFieldList.Field) + bit<1> b; +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + m.b = m.b + 1w1; + transition accept; + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + clone_preserving_field_list(CloneType.I2E, 32w64, PreservedFieldList.Field); + } +} + +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 b, in Headers h) { + apply { + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/p4_16_samples_outputs/issue1001-1-bmv2-frontend.p4 b/testdata/p4_16_samples_outputs/issue1001-1-bmv2-frontend.p4 new file mode 100644 index 00000000000..5eb2e13827d --- /dev/null +++ b/testdata/p4_16_samples_outputs/issue1001-1-bmv2-frontend.p4 @@ -0,0 +1,50 @@ +#include +#define V1MODEL_VERSION 20180101 +#include + +struct Headers { +} + +enum bit<8> PreservedFieldList { + Field = 8w1 +} + +struct Meta { + @field_list(PreservedFieldList.Field) + bit<1> b; +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + m.b = m.b + 1w1; + transition accept; + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + clone_preserving_field_list(CloneType.I2E, 32w64, PreservedFieldList.Field); + } +} + +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 b, in Headers h) { + apply { + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/p4_16_samples_outputs/issue1001-1-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/issue1001-1-bmv2-midend.p4 new file mode 100644 index 00000000000..0deb85b6b39 --- /dev/null +++ b/testdata/p4_16_samples_outputs/issue1001-1-bmv2-midend.p4 @@ -0,0 +1,55 @@ +#include +#define V1MODEL_VERSION 20180101 +#include + +struct Headers { +} + +struct Meta { + @field_list(8w1) + bit<1> b; +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + m.b = m.b + 1w1; + transition accept; + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + @hidden action issue10011bmv2l24() { + clone_preserving_field_list(CloneType.I2E, 32w64, 8w1); + } + @hidden table tbl_issue10011bmv2l24 { + actions = { + issue10011bmv2l24(); + } + const default_action = issue10011bmv2l24(); + } + apply { + tbl_issue10011bmv2l24.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 b, in Headers h) { + apply { + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/p4_16_samples_outputs/issue1001-1-bmv2.p4 b/testdata/p4_16_samples_outputs/issue1001-1-bmv2.p4 new file mode 100644 index 00000000000..8fb43025974 --- /dev/null +++ b/testdata/p4_16_samples_outputs/issue1001-1-bmv2.p4 @@ -0,0 +1,50 @@ +#include +#define V1MODEL_VERSION 20180101 +#include + +struct Headers { +} + +enum bit<8> PreservedFieldList { + Field = 8w1 +} + +struct Meta { + @field_list(PreservedFieldList.Field) + bit<1> b; +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + m.b = m.b + 1; + transition accept; + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + clone_preserving_field_list(CloneType.I2E, 32w64, PreservedFieldList.Field); + } +} + +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 b, in Headers h) { + apply { + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/p4_16_samples_outputs/issue1001-1-bmv2.p4-stderr b/testdata/p4_16_samples_outputs/issue1001-1-bmv2.p4-stderr new file mode 100644 index 00000000000..e69de29bb2d diff --git a/testdata/p4_16_samples_outputs/issue1001-1-bmv2.p4.entries.txt b/testdata/p4_16_samples_outputs/issue1001-1-bmv2.p4.entries.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/testdata/p4_16_samples_outputs/issue1001-1-bmv2.p4.p4info.txt b/testdata/p4_16_samples_outputs/issue1001-1-bmv2.p4.p4info.txt new file mode 100644 index 00000000000..e162b5de6ac --- /dev/null +++ b/testdata/p4_16_samples_outputs/issue1001-1-bmv2.p4.p4info.txt @@ -0,0 +1,5 @@ +pkg_info { + arch: "v1model" +} +type_info { +} diff --git a/testdata/p4_16_samples_outputs/issue1001-bmv2-first.p4 b/testdata/p4_16_samples_outputs/issue1001-bmv2-first.p4 index f83d89d33cf..937ff870422 100644 --- a/testdata/p4_16_samples_outputs/issue1001-bmv2-first.p4 +++ b/testdata/p4_16_samples_outputs/issue1001-bmv2-first.p4 @@ -6,6 +6,7 @@ struct Headers { } struct Meta { + @field_list(0) bit<1> b; } @@ -17,9 +18,8 @@ parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) } control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - Meta x; apply { - clone3(CloneType.I2E, 32w64, x); + clone_preserving_field_list(CloneType.I2E, 32w64, 8w0); } } @@ -44,4 +44,3 @@ control deparser(packet_out b, in Headers h) { } V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue1001-bmv2-frontend.p4 b/testdata/p4_16_samples_outputs/issue1001-bmv2-frontend.p4 index 3a118c9aa4c..937ff870422 100644 --- a/testdata/p4_16_samples_outputs/issue1001-bmv2-frontend.p4 +++ b/testdata/p4_16_samples_outputs/issue1001-bmv2-frontend.p4 @@ -6,6 +6,7 @@ struct Headers { } struct Meta { + @field_list(0) bit<1> b; } @@ -17,9 +18,8 @@ parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) } control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - @name("ingress.x") Meta x_0; apply { - clone3(CloneType.I2E, 32w64, x_0); + clone_preserving_field_list(CloneType.I2E, 32w64, 8w0); } } @@ -44,4 +44,3 @@ control deparser(packet_out b, in Headers h) { } V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue1001-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/issue1001-bmv2-midend.p4 index 7cc1f314621..6c9807e4071 100644 --- a/testdata/p4_16_samples_outputs/issue1001-bmv2-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue1001-bmv2-midend.p4 @@ -6,6 +6,7 @@ struct Headers { } struct Meta { + @field_list(0) bit<1> b; } @@ -17,9 +18,8 @@ parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) } control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - @name("ingress.x") Meta x_0; @hidden action issue1001bmv2l20() { - clone3(CloneType.I2E, 32w64, x_0); + clone_preserving_field_list(CloneType.I2E, 32w64, 8w0); } @hidden table tbl_issue1001bmv2l20 { actions = { @@ -53,4 +53,3 @@ control deparser(packet_out b, in Headers h) { } V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue1001-bmv2.p4 b/testdata/p4_16_samples_outputs/issue1001-bmv2.p4 index b099b8c153c..2a703619e0b 100644 --- a/testdata/p4_16_samples_outputs/issue1001-bmv2.p4 +++ b/testdata/p4_16_samples_outputs/issue1001-bmv2.p4 @@ -6,6 +6,7 @@ struct Headers { } struct Meta { + @field_list(0) bit<1> b; } @@ -17,9 +18,8 @@ parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) } control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - Meta x; apply { - clone3(CloneType.I2E, 32w64, x); + clone_preserving_field_list(CloneType.I2E, 32w64, 0); } } @@ -44,4 +44,3 @@ control deparser(packet_out b, in Headers h) { } V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue1001-bmv2.p4-stderr b/testdata/p4_16_samples_outputs/issue1001-bmv2.p4-stderr index 247e78e8d95..e69de29bb2d 100644 --- a/testdata/p4_16_samples_outputs/issue1001-bmv2.p4-stderr +++ b/testdata/p4_16_samples_outputs/issue1001-bmv2.p4-stderr @@ -1,3 +0,0 @@ -issue1001-bmv2.p4(20): [--Wwarn=uninitialized_use] warning: x may not be completely initialized - clone3(CloneType.I2E, 32w64, x); - ^ diff --git a/testdata/p4_16_samples_outputs/issue1043-bmv2-first.p4 b/testdata/p4_16_samples_outputs/issue1043-bmv2-first.p4 index 0ff12e06cf3..1bede1b35ee 100644 --- a/testdata/p4_16_samples_outputs/issue1043-bmv2-first.p4 +++ b/testdata/p4_16_samples_outputs/issue1043-bmv2-first.p4 @@ -44,7 +44,7 @@ control deparser(packet_out b, in Headers h) { control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { apply { - resubmit(m); + resubmit_preserving_field_list(8w0); sm.egress_spec = 9w0; } } diff --git a/testdata/p4_16_samples_outputs/issue1043-bmv2-frontend.p4 b/testdata/p4_16_samples_outputs/issue1043-bmv2-frontend.p4 index 0ff12e06cf3..1bede1b35ee 100644 --- a/testdata/p4_16_samples_outputs/issue1043-bmv2-frontend.p4 +++ b/testdata/p4_16_samples_outputs/issue1043-bmv2-frontend.p4 @@ -44,7 +44,7 @@ control deparser(packet_out b, in Headers h) { control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { apply { - resubmit(m); + resubmit_preserving_field_list(8w0); sm.egress_spec = 9w0; } } diff --git a/testdata/p4_16_samples_outputs/issue1043-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/issue1043-bmv2-midend.p4 index c5e2e3fb08d..5003ec9eb5f 100644 --- a/testdata/p4_16_samples_outputs/issue1043-bmv2-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue1043-bmv2-midend.p4 @@ -44,7 +44,7 @@ control deparser(packet_out b, in Headers h) { control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { @hidden action issue1043bmv2l33() { - resubmit(m); + resubmit_preserving_field_list(8w0); sm.egress_spec = 9w0; } @hidden table tbl_issue1043bmv2l33 { diff --git a/testdata/p4_16_samples_outputs/issue1043-bmv2.p4 b/testdata/p4_16_samples_outputs/issue1043-bmv2.p4 index 79f5eb05f0c..b64649fb04c 100644 --- a/testdata/p4_16_samples_outputs/issue1043-bmv2.p4 +++ b/testdata/p4_16_samples_outputs/issue1043-bmv2.p4 @@ -44,7 +44,7 @@ control deparser(packet_out b, in Headers h) { control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { apply { - resubmit(m); + resubmit_preserving_field_list(0); sm.egress_spec = 0; } } diff --git a/testdata/p4_16_samples_outputs/issue1541.p4-stderr b/testdata/p4_16_samples_outputs/issue1541.p4-stderr index 390ca819c54..f6eceba50a9 100644 --- a/testdata/p4_16_samples_outputs/issue1541.p4-stderr +++ b/testdata/p4_16_samples_outputs/issue1541.p4-stderr @@ -1,6 +1,6 @@ issue1541.p4(25): [--Wwarn=shadow] warning: 'hash' shadows 'hash' action hash() { ^^^^ -v1model.p4(453) +v1model.p4(444) extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); ^^^^ diff --git a/testdata/p4_16_samples_outputs/issue1642-bmv2-first.p4 b/testdata/p4_16_samples_outputs/issue1642-bmv2-first.p4 index d230d08731d..00661351a5e 100644 --- a/testdata/p4_16_samples_outputs/issue1642-bmv2-first.p4 +++ b/testdata/p4_16_samples_outputs/issue1642-bmv2-first.p4 @@ -21,6 +21,7 @@ struct parsed_packet_t { struct local_metadata_t { short s; + @field_list(0) row_t row; } @@ -37,7 +38,7 @@ control ingress(inout parsed_packet_t hdr, inout local_metadata_t local_metadata local_metadata.row.alt0 = local_metadata.row.alt1; local_metadata.row.alt0.valid = 1w1; local_metadata.row.alt1.port = local_metadata.row.alt1.port + 7w1; - clone3(CloneType.I2E, 32w0, local_metadata.row); + clone_preserving_field_list(CloneType.I2E, 32w0, 8w0); } } @@ -62,4 +63,3 @@ control compute_checksum(inout parsed_packet_t hdr, inout local_metadata_t local } V1Switch(parse(), verifyChecksum(), ingress(), egress(), compute_checksum(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue1642-bmv2-frontend.p4 b/testdata/p4_16_samples_outputs/issue1642-bmv2-frontend.p4 index d230d08731d..00661351a5e 100644 --- a/testdata/p4_16_samples_outputs/issue1642-bmv2-frontend.p4 +++ b/testdata/p4_16_samples_outputs/issue1642-bmv2-frontend.p4 @@ -21,6 +21,7 @@ struct parsed_packet_t { struct local_metadata_t { short s; + @field_list(0) row_t row; } @@ -37,7 +38,7 @@ control ingress(inout parsed_packet_t hdr, inout local_metadata_t local_metadata local_metadata.row.alt0 = local_metadata.row.alt1; local_metadata.row.alt0.valid = 1w1; local_metadata.row.alt1.port = local_metadata.row.alt1.port + 7w1; - clone3(CloneType.I2E, 32w0, local_metadata.row); + clone_preserving_field_list(CloneType.I2E, 32w0, 8w0); } } @@ -62,4 +63,3 @@ control compute_checksum(inout parsed_packet_t hdr, inout local_metadata_t local } V1Switch(parse(), verifyChecksum(), ingress(), egress(), compute_checksum(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue1642-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/issue1642-bmv2-midend.p4 index eaee0068af3..e0282a43397 100644 --- a/testdata/p4_16_samples_outputs/issue1642-bmv2-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue1642-bmv2-midend.p4 @@ -21,9 +21,13 @@ struct parsed_packet_t { struct local_metadata_t { short _s0; + @field_list(0) bit<1> _row_alt0_valid1; + @field_list(0) bit<7> _row_alt0_port2; + @field_list(0) bit<1> _row_alt1_valid3; + @field_list(0) bit<7> _row_alt1_port4; } @@ -34,23 +38,23 @@ parser parse(packet_in pk, out parsed_packet_t hdr, inout local_metadata_t local } control ingress(inout parsed_packet_t hdr, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - @hidden action issue1642bmv2l36() { + @hidden action issue1642bmv2l37() { local_metadata._s0.setValid(); local_metadata._s0.f = 32w0; local_metadata._row_alt0_valid1 = local_metadata._row_alt1_valid3; local_metadata._row_alt0_port2 = local_metadata._row_alt1_port4; local_metadata._row_alt0_valid1 = 1w1; local_metadata._row_alt1_port4 = local_metadata._row_alt1_port4 + 7w1; - clone3(CloneType.I2E, 32w0, (row_t){alt0 = (alt_t){valid = 1w1,port = local_metadata._row_alt0_port2},alt1 = (alt_t){valid = local_metadata._row_alt1_valid3,port = local_metadata._row_alt1_port4}}); + clone_preserving_field_list(CloneType.I2E, 32w0, 8w0); } - @hidden table tbl_issue1642bmv2l36 { + @hidden table tbl_issue1642bmv2l37 { actions = { - issue1642bmv2l36(); + issue1642bmv2l37(); } - const default_action = issue1642bmv2l36(); + const default_action = issue1642bmv2l37(); } apply { - tbl_issue1642bmv2l36.apply(); + tbl_issue1642bmv2l37.apply(); } } @@ -75,4 +79,3 @@ control compute_checksum(inout parsed_packet_t hdr, inout local_metadata_t local } V1Switch(parse(), verifyChecksum(), ingress(), egress(), compute_checksum(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue1642-bmv2.p4 b/testdata/p4_16_samples_outputs/issue1642-bmv2.p4 index 80a1b3cc946..2c5fe737a9f 100644 --- a/testdata/p4_16_samples_outputs/issue1642-bmv2.p4 +++ b/testdata/p4_16_samples_outputs/issue1642-bmv2.p4 @@ -21,6 +21,7 @@ struct parsed_packet_t { struct local_metadata_t { short s; + @field_list(0) row_t row; } @@ -37,7 +38,7 @@ control ingress(inout parsed_packet_t hdr, inout local_metadata_t local_metadata local_metadata.row.alt0 = local_metadata.row.alt1; local_metadata.row.alt0.valid = 1; local_metadata.row.alt1.port = local_metadata.row.alt1.port + 1; - clone3(CloneType.I2E, 0, local_metadata.row); + clone_preserving_field_list(CloneType.I2E, 0, 0); } } @@ -62,4 +63,3 @@ control compute_checksum(inout parsed_packet_t hdr, inout local_metadata_t local } V1Switch(parse(), verifyChecksum(), ingress(), egress(), compute_checksum(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue1653-bmv2-first.p4 b/testdata/p4_16_samples_outputs/issue1653-bmv2-first.p4 index 6fe26c972de..fbdffd0e297 100644 --- a/testdata/p4_16_samples_outputs/issue1653-bmv2-first.p4 +++ b/testdata/p4_16_samples_outputs/issue1653-bmv2-first.p4 @@ -26,7 +26,7 @@ control ingress(inout parsed_packet_t h, inout local_metadata_t local_metadata, bitvec_hdr bh; apply { bh.x = h.bvh0.x; - clone3(CloneType.I2E, 32w0, h); + clone_preserving_field_list(CloneType.I2E, 32w0, 8w0); } } @@ -51,4 +51,3 @@ control compute_checksum(inout parsed_packet_t hdr, inout local_metadata_t local } V1Switch(parse(), verifyChecksum(), ingress(), egress(), compute_checksum(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue1653-bmv2-frontend.p4 b/testdata/p4_16_samples_outputs/issue1653-bmv2-frontend.p4 index 28eda3de6a0..f9e1c2c61d7 100644 --- a/testdata/p4_16_samples_outputs/issue1653-bmv2-frontend.p4 +++ b/testdata/p4_16_samples_outputs/issue1653-bmv2-frontend.p4 @@ -26,7 +26,7 @@ control ingress(inout parsed_packet_t h, inout local_metadata_t local_metadata, @name("ingress.bh") bitvec_hdr bh_0; apply { bh_0.setInvalid(); - clone3(CloneType.I2E, 32w0, h); + clone_preserving_field_list(CloneType.I2E, 32w0, 8w0); } } @@ -51,4 +51,3 @@ control compute_checksum(inout parsed_packet_t hdr, inout local_metadata_t local } V1Switch(parse(), verifyChecksum(), ingress(), egress(), compute_checksum(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue1653-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/issue1653-bmv2-midend.p4 index fd97fa379a4..86b5cf3134b 100644 --- a/testdata/p4_16_samples_outputs/issue1653-bmv2-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue1653-bmv2-midend.p4 @@ -26,7 +26,7 @@ control ingress(inout parsed_packet_t h, inout local_metadata_t local_metadata, @name("ingress.bh") bitvec_hdr bh_0; @hidden action issue1653bmv2l43() { bh_0.setInvalid(); - clone3(CloneType.I2E, 32w0, h); + clone_preserving_field_list(CloneType.I2E, 32w0, 8w0); } @hidden table tbl_issue1653bmv2l43 { actions = { @@ -60,4 +60,3 @@ control compute_checksum(inout parsed_packet_t hdr, inout local_metadata_t local } V1Switch(parse(), verifyChecksum(), ingress(), egress(), compute_checksum(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue1653-bmv2.p4 b/testdata/p4_16_samples_outputs/issue1653-bmv2.p4 index 21b514c01b3..a263d52d617 100644 --- a/testdata/p4_16_samples_outputs/issue1653-bmv2.p4 +++ b/testdata/p4_16_samples_outputs/issue1653-bmv2.p4 @@ -26,7 +26,7 @@ control ingress(inout parsed_packet_t h, inout local_metadata_t local_metadata, bitvec_hdr bh; apply { bh.x = h.bvh0.x; - clone3(CloneType.I2E, 0, h); + clone_preserving_field_list(CloneType.I2E, 0, 0); } } @@ -51,4 +51,3 @@ control compute_checksum(inout parsed_packet_t hdr, inout local_metadata_t local } V1Switch(parse(), verifyChecksum(), ingress(), egress(), compute_checksum(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue1653-bmv2.p4-stderr b/testdata/p4_16_samples_outputs/issue1653-bmv2.p4-stderr index 631674926c3..7ea4a2dfc07 100644 --- a/testdata/p4_16_samples_outputs/issue1653-bmv2.p4-stderr +++ b/testdata/p4_16_samples_outputs/issue1653-bmv2.p4-stderr @@ -1,3 +1,3 @@ -issue1653-bmv2.p4(48): [--Wwarn=invalid_header] warning: accessing a field of an invalid header bh +issue1653-bmv2.p4(47): [--Wwarn=invalid_header] warning: accessing a field of an invalid header bh bh.x = h.bvh0.x; ^^ diff --git a/testdata/p4_16_samples_outputs/issue1653-complex-bmv2-first.p4 b/testdata/p4_16_samples_outputs/issue1653-complex-bmv2-first.p4 index 359f0f78d7d..a1bebbde925 100644 --- a/testdata/p4_16_samples_outputs/issue1653-complex-bmv2-first.p4 +++ b/testdata/p4_16_samples_outputs/issue1653-complex-bmv2-first.p4 @@ -31,6 +31,7 @@ header bitvec_hdr { } struct local_metadata_t { + @field_list(0) row_t row0; row_t row1; bitvec_hdr bvh0; @@ -73,7 +74,7 @@ control ingress(inout parsed_packet_t h, inout local_metadata_t local_metadata, bh.row.alt1.type = EthTypes.IPv4; h.bvh0.row.alt1.type = bh.row.alt1.type; local_metadata.row0.alt0.useHash = true; - clone3(CloneType.I2E, 32w0, local_metadata.row0); + clone_preserving_field_list(CloneType.I2E, 32w0, 8w0); } } @@ -100,4 +101,3 @@ control compute_checksum(inout parsed_packet_t hdr, inout local_metadata_t local } V1Switch(parse(), verifyChecksum(), ingress(), egress(), compute_checksum(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue1653-complex-bmv2-frontend.p4 b/testdata/p4_16_samples_outputs/issue1653-complex-bmv2-frontend.p4 index cb96370af09..62b9ecb0c98 100644 --- a/testdata/p4_16_samples_outputs/issue1653-complex-bmv2-frontend.p4 +++ b/testdata/p4_16_samples_outputs/issue1653-complex-bmv2-frontend.p4 @@ -31,6 +31,7 @@ header bitvec_hdr { } struct local_metadata_t { + @field_list(0) row_t row0; row_t row1; bitvec_hdr bvh0; @@ -75,7 +76,7 @@ control ingress(inout parsed_packet_t h, inout local_metadata_t local_metadata, bh_0.row.alt1.type = EthTypes.IPv4; h.bvh0.row.alt1.type = bh_0.row.alt1.type; local_metadata.row0.alt0.useHash = true; - clone3(CloneType.I2E, 32w0, local_metadata.row0); + clone_preserving_field_list(CloneType.I2E, 32w0, 8w0); } } @@ -102,4 +103,3 @@ control compute_checksum(inout parsed_packet_t hdr, inout local_metadata_t local } V1Switch(parse(), verifyChecksum(), ingress(), egress(), compute_checksum(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue1653-complex-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/issue1653-complex-bmv2-midend.p4 index 42bf7d66efe..8195e38f4e7 100644 --- a/testdata/p4_16_samples_outputs/issue1653-complex-bmv2-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue1653-complex-bmv2-midend.p4 @@ -32,17 +32,29 @@ header bitvec_hdr { } struct local_metadata_t { + @field_list(0) bit<1> _row0_alt0_valid0; + @field_list(0) bit<7> _row0_alt0_port1; + @field_list(0) int<8> _row0_alt0_hashRes2; + @field_list(0) bool _row0_alt0_useHash3; + @field_list(0) bit<16> _row0_alt0_type4; + @field_list(0) bit<7> _row0_alt0_pad5; + @field_list(0) bit<1> _row0_alt1_valid6; + @field_list(0) bit<7> _row0_alt1_port7; + @field_list(0) int<8> _row0_alt1_hashRes8; + @field_list(0) bool _row0_alt1_useHash9; + @field_list(0) bit<16> _row0_alt1_type10; + @field_list(0) bit<7> _row0_alt1_pad11; bit<1> _row1_alt0_valid12; bit<7> _row1_alt0_port13; @@ -92,31 +104,31 @@ control ingress(inout parsed_packet_t h, inout local_metadata_t local_metadata, } default_action = NoAction_1(); } - @hidden action issue1653complexbmv2l71() { + @hidden action issue1653complexbmv2l72() { bh_0.setInvalid(); } - @hidden action issue1653complexbmv2l94() { + @hidden action issue1653complexbmv2l95() { bh_0._row_alt1_type10 = 16w0x800; h.bvh0._row_alt1_type10 = 16w0x800; local_metadata._row0_alt0_useHash3 = true; - clone3(CloneType.I2E, 32w0, (row_t){alt0 = (alt_t){valid = local_metadata._row0_alt0_valid0,port = local_metadata._row0_alt0_port1,hashRes = local_metadata._row0_alt0_hashRes2,useHash = true,type = local_metadata._row0_alt0_type4,pad = local_metadata._row0_alt0_pad5},alt1 = (alt_t){valid = local_metadata._row0_alt1_valid6,port = local_metadata._row0_alt1_port7,hashRes = local_metadata._row0_alt1_hashRes8,useHash = local_metadata._row0_alt1_useHash9,type = local_metadata._row0_alt1_type10,pad = local_metadata._row0_alt1_pad11}}); + clone_preserving_field_list(CloneType.I2E, 32w0, 8w0); } - @hidden table tbl_issue1653complexbmv2l71 { + @hidden table tbl_issue1653complexbmv2l72 { actions = { - issue1653complexbmv2l71(); + issue1653complexbmv2l72(); } - const default_action = issue1653complexbmv2l71(); + const default_action = issue1653complexbmv2l72(); } - @hidden table tbl_issue1653complexbmv2l94 { + @hidden table tbl_issue1653complexbmv2l95 { actions = { - issue1653complexbmv2l94(); + issue1653complexbmv2l95(); } - const default_action = issue1653complexbmv2l94(); + const default_action = issue1653complexbmv2l95(); } apply { - tbl_issue1653complexbmv2l71.apply(); + tbl_issue1653complexbmv2l72.apply(); tns_0.apply(); - tbl_issue1653complexbmv2l94.apply(); + tbl_issue1653complexbmv2l95.apply(); } } @@ -143,4 +155,3 @@ control compute_checksum(inout parsed_packet_t hdr, inout local_metadata_t local } V1Switch(parse(), verifyChecksum(), ingress(), egress(), compute_checksum(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue1653-complex-bmv2.p4 b/testdata/p4_16_samples_outputs/issue1653-complex-bmv2.p4 index ae02076e466..4910a097ecf 100644 --- a/testdata/p4_16_samples_outputs/issue1653-complex-bmv2.p4 +++ b/testdata/p4_16_samples_outputs/issue1653-complex-bmv2.p4 @@ -31,6 +31,7 @@ header bitvec_hdr { } struct local_metadata_t { + @field_list(0) row_t row0; row_t row1; bitvec_hdr bvh0; @@ -71,7 +72,7 @@ control ingress(inout parsed_packet_t h, inout local_metadata_t local_metadata, bh.row.alt1.type = EthTypes.IPv4; h.bvh0.row.alt1.type = bh.row.alt1.type; local_metadata.row0.alt0.useHash = true; - clone3(CloneType.I2E, 0, local_metadata.row0); + clone_preserving_field_list(CloneType.I2E, 0, 0); } } @@ -98,4 +99,3 @@ control compute_checksum(inout parsed_packet_t hdr, inout local_metadata_t local } V1Switch(parse(), verifyChecksum(), ingress(), egress(), compute_checksum(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue1653-complex-bmv2.p4-stderr b/testdata/p4_16_samples_outputs/issue1653-complex-bmv2.p4-stderr index fd1359c4c35..15ee836f8a8 100644 --- a/testdata/p4_16_samples_outputs/issue1653-complex-bmv2.p4-stderr +++ b/testdata/p4_16_samples_outputs/issue1653-complex-bmv2.p4-stderr @@ -1,9 +1,9 @@ -issue1653-complex-bmv2.p4(93): [--Wwarn=invalid_header] warning: accessing a field of an invalid header bh +issue1653-complex-bmv2.p4(94): [--Wwarn=invalid_header] warning: accessing a field of an invalid header bh bh.row.alt0.useHash = h.bvh0.row.alt0.useHash; ^^ -issue1653-complex-bmv2.p4(94): [--Wwarn=invalid_header] warning: accessing a field of an invalid header bh +issue1653-complex-bmv2.p4(95): [--Wwarn=invalid_header] warning: accessing a field of an invalid header bh bh.row.alt1.type = EthTypes.IPv4; ^^ -issue1653-complex-bmv2.p4(95): [--Wwarn=invalid_header] warning: accessing a field of an invalid header bh +issue1653-complex-bmv2.p4(96): [--Wwarn=invalid_header] warning: accessing a field of an invalid header bh h.bvh0.row.alt1.type = bh.row.alt1.type; ^^ diff --git a/testdata/p4_16_samples_outputs/issue1660-bmv2-first.p4 b/testdata/p4_16_samples_outputs/issue1660-bmv2-first.p4 index 3c07f326139..4c722510391 100644 --- a/testdata/p4_16_samples_outputs/issue1660-bmv2-first.p4 +++ b/testdata/p4_16_samples_outputs/issue1660-bmv2-first.p4 @@ -3,6 +3,7 @@ #include struct HasBool { + @field_list(0) bool x; } @@ -22,7 +23,7 @@ control ingress(inout parsed_packet_t h, inout local_metadata_t local_metadata, apply { HasBool b; b.x = true; - clone3(CloneType.I2E, 32w0, b); + clone_preserving_field_list(CloneType.I2E, 32w0, 8w0); } } @@ -47,4 +48,3 @@ control compute_checksum(inout parsed_packet_t hdr, inout local_metadata_t local } V1Switch(parse(), verifyChecksum(), ingress(), egress(), compute_checksum(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue1660-bmv2-frontend.p4 b/testdata/p4_16_samples_outputs/issue1660-bmv2-frontend.p4 index 3e49150e906..3787f931978 100644 --- a/testdata/p4_16_samples_outputs/issue1660-bmv2-frontend.p4 +++ b/testdata/p4_16_samples_outputs/issue1660-bmv2-frontend.p4 @@ -3,6 +3,7 @@ #include struct HasBool { + @field_list(0) bool x; } @@ -19,10 +20,8 @@ parser parse(packet_in pk, out parsed_packet_t h, inout local_metadata_t local_m } control ingress(inout parsed_packet_t h, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - @name("ingress.b") HasBool b_0; apply { - b_0.x = true; - clone3(CloneType.I2E, 32w0, b_0); + clone_preserving_field_list(CloneType.I2E, 32w0, 8w0); } } @@ -47,4 +46,3 @@ control compute_checksum(inout parsed_packet_t hdr, inout local_metadata_t local } V1Switch(parse(), verifyChecksum(), ingress(), egress(), compute_checksum(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue1660-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/issue1660-bmv2-midend.p4 index bb4ae3fbe25..14310cac4e6 100644 --- a/testdata/p4_16_samples_outputs/issue1660-bmv2-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue1660-bmv2-midend.p4 @@ -3,6 +3,7 @@ #include struct HasBool { + @field_list(0) bool x; } @@ -19,19 +20,17 @@ parser parse(packet_in pk, out parsed_packet_t h, inout local_metadata_t local_m } control ingress(inout parsed_packet_t h, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - @name("ingress.b") HasBool b_0; - @hidden action issue1660bmv2l21() { - b_0.x = true; - clone3(CloneType.I2E, 32w0, b_0); + @hidden action issue1660bmv2l23() { + clone_preserving_field_list(CloneType.I2E, 32w0, 8w0); } - @hidden table tbl_issue1660bmv2l21 { + @hidden table tbl_issue1660bmv2l23 { actions = { - issue1660bmv2l21(); + issue1660bmv2l23(); } - const default_action = issue1660bmv2l21(); + const default_action = issue1660bmv2l23(); } apply { - tbl_issue1660bmv2l21.apply(); + tbl_issue1660bmv2l23.apply(); } } @@ -56,4 +55,3 @@ control compute_checksum(inout parsed_packet_t hdr, inout local_metadata_t local } V1Switch(parse(), verifyChecksum(), ingress(), egress(), compute_checksum(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue1660-bmv2.p4 b/testdata/p4_16_samples_outputs/issue1660-bmv2.p4 index 83b4ecd2a3b..5c3a015f06c 100644 --- a/testdata/p4_16_samples_outputs/issue1660-bmv2.p4 +++ b/testdata/p4_16_samples_outputs/issue1660-bmv2.p4 @@ -3,6 +3,7 @@ #include struct HasBool { + @field_list(0) bool x; } @@ -22,7 +23,7 @@ control ingress(inout parsed_packet_t h, inout local_metadata_t local_metadata, apply { HasBool b; b.x = true; - clone3(CloneType.I2E, 0, b); + clone_preserving_field_list(CloneType.I2E, 0, 0); } } @@ -47,4 +48,3 @@ control compute_checksum(inout parsed_packet_t hdr, inout local_metadata_t local } V1Switch(parse(), verifyChecksum(), ingress(), egress(), compute_checksum(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue1765-1-bmv2-first.p4 b/testdata/p4_16_samples_outputs/issue1765-1-bmv2-first.p4 index 6613a6c6dde..f36ae63ac26 100644 --- a/testdata/p4_16_samples_outputs/issue1765-1-bmv2-first.p4 +++ b/testdata/p4_16_samples_outputs/issue1765-1-bmv2-first.p4 @@ -116,10 +116,15 @@ struct headers { } struct metadata { + @field_list(0) port_t ingress_port; + @field_list(0) task_t task; + @field_list(0) bit<16> tcp_length; + @field_list(0) bit<32> cast_length; + @field_list(0) bit<1> do_cksum; } @@ -204,12 +209,12 @@ control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadat action controller_debug() { meta.task = 16w3; meta.ingress_port = standard_metadata.ingress_port; - clone3(CloneType.I2E, 32w100, meta); + clone_preserving_field_list(CloneType.I2E, 32w100, 8w0); } action controller_reply(task_t task) { meta.task = task; meta.ingress_port = standard_metadata.ingress_port; - clone3(CloneType.I2E, 32w100, meta); + clone_preserving_field_list(CloneType.I2E, 32w100, 8w0); } action multicast_pkg(mcast_t mcast_grp) { standard_metadata.mcast_grp = mcast_grp; @@ -351,4 +356,3 @@ control MyEgress(inout headers hdr, inout metadata meta, inout standard_metadata } V1Switch(MyParser(), MyVerifyChecksum(), MyIngress(), MyEgress(), MyComputeChecksum(), MyDeparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue1765-1-bmv2-frontend.p4 b/testdata/p4_16_samples_outputs/issue1765-1-bmv2-frontend.p4 index 5d2761f958d..cf8e9ba0979 100644 --- a/testdata/p4_16_samples_outputs/issue1765-1-bmv2-frontend.p4 +++ b/testdata/p4_16_samples_outputs/issue1765-1-bmv2-frontend.p4 @@ -98,10 +98,15 @@ struct headers { } struct metadata { + @field_list(0) port_t ingress_port; + @field_list(0) task_t task; + @field_list(0) bit<16> tcp_length; + @field_list(0) bit<32> cast_length; + @field_list(0) bit<1> do_cksum; } @@ -194,22 +199,22 @@ control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadat @name("MyIngress.controller_debug") action controller_debug() { meta.task = 16w3; meta.ingress_port = standard_metadata.ingress_port; - clone3(CloneType.I2E, 32w100, meta); + clone_preserving_field_list(CloneType.I2E, 32w100, 8w0); } @name("MyIngress.controller_debug") action controller_debug_1() { meta.task = 16w3; meta.ingress_port = standard_metadata.ingress_port; - clone3(CloneType.I2E, 32w100, meta); + clone_preserving_field_list(CloneType.I2E, 32w100, 8w0); } @name("MyIngress.controller_reply") action controller_reply(@name("task") task_t task_1) { meta.task = task_1; meta.ingress_port = standard_metadata.ingress_port; - clone3(CloneType.I2E, 32w100, meta); + clone_preserving_field_list(CloneType.I2E, 32w100, 8w0); } @name("MyIngress.controller_reply") action controller_reply_1(@name("task") task_t task_2) { meta.task = task_2; meta.ingress_port = standard_metadata.ingress_port; - clone3(CloneType.I2E, 32w100, meta); + clone_preserving_field_list(CloneType.I2E, 32w100, 8w0); } @name("MyIngress.icmp6_echo_reply") action icmp6_echo_reply() { mac_tmp_0 = hdr.ethernet.dst_addr; @@ -282,4 +287,3 @@ control MyEgress(inout headers hdr, inout metadata meta, inout standard_metadata } V1Switch(MyParser(), MyVerifyChecksum(), MyIngress(), MyEgress(), MyComputeChecksum(), MyDeparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue1765-1-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/issue1765-1-bmv2-midend.p4 index 05aadd0b011..e7a0423bb4d 100644 --- a/testdata/p4_16_samples_outputs/issue1765-1-bmv2-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue1765-1-bmv2-midend.p4 @@ -98,10 +98,15 @@ struct headers { } struct metadata { + @field_list(0) port_t ingress_port; + @field_list(0) task_t task; + @field_list(0) bit<16> tcp_length; + @field_list(0) bit<32> cast_length; + @field_list(0) bit<1> do_cksum; } @@ -202,22 +207,22 @@ control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadat @name("MyIngress.controller_debug") action controller_debug() { meta.task = 16w3; meta.ingress_port = standard_metadata.ingress_port; - clone3(CloneType.I2E, 32w100, meta); + clone_preserving_field_list(CloneType.I2E, 32w100, 8w0); } @name("MyIngress.controller_debug") action controller_debug_1() { meta.task = 16w3; meta.ingress_port = standard_metadata.ingress_port; - clone3(CloneType.I2E, 32w100, meta); + clone_preserving_field_list(CloneType.I2E, 32w100, 8w0); } @name("MyIngress.controller_reply") action controller_reply(@name("task") task_t task_1) { meta.task = task_1; meta.ingress_port = standard_metadata.ingress_port; - clone3(CloneType.I2E, 32w100, meta); + clone_preserving_field_list(CloneType.I2E, 32w100, 8w0); } @name("MyIngress.controller_reply") action controller_reply_1(@name("task") task_t task_2) { meta.task = task_2; meta.ingress_port = standard_metadata.ingress_port; - clone3(CloneType.I2E, 32w100, meta); + clone_preserving_field_list(CloneType.I2E, 32w100, 8w0); } @name("MyIngress.icmp6_echo_reply") action icmp6_echo_reply() { mac_tmp_0 = hdr.ethernet.dst_addr; @@ -278,25 +283,24 @@ control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadat } control MyEgress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @hidden action issue17651bmv2l343() { + @hidden action issue17651bmv2l348() { hdr.cpu.setValid(); hdr.cpu.task = meta.task; hdr.cpu.ethertype = hdr.ethernet.ethertype; hdr.cpu.ingress_port = (bit<16>)meta.ingress_port; hdr.ethernet.ethertype = 16w0x4242; } - @hidden table tbl_issue17651bmv2l343 { + @hidden table tbl_issue17651bmv2l348 { actions = { - issue17651bmv2l343(); + issue17651bmv2l348(); } - const default_action = issue17651bmv2l343(); + const default_action = issue17651bmv2l348(); } apply { if (standard_metadata.instance_type == 32w1) { - tbl_issue17651bmv2l343.apply(); + tbl_issue17651bmv2l348.apply(); } } } V1Switch(MyParser(), MyVerifyChecksum(), MyIngress(), MyEgress(), MyComputeChecksum(), MyDeparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue1765-1-bmv2.p4 b/testdata/p4_16_samples_outputs/issue1765-1-bmv2.p4 index fe5751c7981..00e74ff9e17 100644 --- a/testdata/p4_16_samples_outputs/issue1765-1-bmv2.p4 +++ b/testdata/p4_16_samples_outputs/issue1765-1-bmv2.p4 @@ -116,10 +116,15 @@ struct headers { } struct metadata { + @field_list(0) port_t ingress_port; + @field_list(0) task_t task; + @field_list(0) bit<16> tcp_length; + @field_list(0) bit<32> cast_length; + @field_list(0) bit<1> do_cksum; } @@ -204,12 +209,12 @@ control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadat action controller_debug() { meta.task = TASK_DEBUG; meta.ingress_port = standard_metadata.ingress_port; - clone3(CloneType.I2E, 100, meta); + clone_preserving_field_list(CloneType.I2E, 100, 0); } action controller_reply(task_t task) { meta.task = task; meta.ingress_port = standard_metadata.ingress_port; - clone3(CloneType.I2E, 100, meta); + clone_preserving_field_list(CloneType.I2E, 100, 0); } action multicast_pkg(mcast_t mcast_grp) { standard_metadata.mcast_grp = mcast_grp; @@ -351,4 +356,3 @@ control MyEgress(inout headers hdr, inout metadata meta, inout standard_metadata } V1Switch(MyParser(), MyVerifyChecksum(), MyIngress(), MyEgress(), MyComputeChecksum(), MyDeparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue1765-1-bmv2.p4-stderr b/testdata/p4_16_samples_outputs/issue1765-1-bmv2.p4-stderr index 8553db45cd4..417498608ae 100644 --- a/testdata/p4_16_samples_outputs/issue1765-1-bmv2.p4-stderr +++ b/testdata/p4_16_samples_outputs/issue1765-1-bmv2.p4-stderr @@ -1,12 +1,12 @@ -issue1765-1-bmv2.p4(232): [--Wwarn=unused] warning: Table ndp_answer is not used; removing +issue1765-1-bmv2.p4(237): [--Wwarn=unused] warning: Table ndp_answer is not used; removing table ndp_answer { ^^^^^^^^^^ -issue1765-1-bmv2.p4(245): [--Wwarn=unused] warning: Table port2mcast is not used; removing +issue1765-1-bmv2.p4(250): [--Wwarn=unused] warning: Table port2mcast is not used; removing table port2mcast { ^^^^^^^^^^ -issue1765-1-bmv2.p4(257): [--Wwarn=unused] warning: Table addr2mcast is not used; removing +issue1765-1-bmv2.p4(262): [--Wwarn=unused] warning: Table addr2mcast is not used; removing table addr2mcast { ^^^^^^^^^^ -issue1765-1-bmv2.p4(269): [--Wwarn=unused] warning: Table ndp is not used; removing +issue1765-1-bmv2.p4(274): [--Wwarn=unused] warning: Table ndp is not used; removing table ndp { ^^^ diff --git a/testdata/p4_16_samples_outputs/issue2176-bmv2.p4-stderr b/testdata/p4_16_samples_outputs/issue2176-bmv2.p4-stderr index 42fe707d841..1f0b2e631ea 100644 --- a/testdata/p4_16_samples_outputs/issue2176-bmv2.p4-stderr +++ b/testdata/p4_16_samples_outputs/issue2176-bmv2.p4-stderr @@ -3,7 +3,7 @@ issue2176-bmv2.p4(43): [--Wwarn=ordering] warning: h.h.b: 'out' argument has fie ^^^^^ issue2176-bmv2.p4(43) do_action_2(h.h.b, h.h.b, h.h.b); - ^^^^^ + ^^^^^ issue2176-bmv2.p4(43): [--Wwarn=ordering] warning: h.h.b: 'out' argument has fields in common with h.h.b do_action_2(h.h.b, h.h.b, h.h.b); ^^^^^ @@ -15,4 +15,4 @@ issue2176-bmv2.p4(43): [--Wwarn=ordering] warning: h.h.b: 'out' argument has fie ^^^^^ issue2176-bmv2.p4(43) do_action_2(h.h.b, h.h.b, h.h.b); - ^^^^^ + ^^^^^ diff --git a/testdata/p4_16_samples_outputs/issue383-bmv2-first.p4 b/testdata/p4_16_samples_outputs/issue383-bmv2-first.p4 index 343463724db..4c42a4ece67 100644 --- a/testdata/p4_16_samples_outputs/issue383-bmv2-first.p4 +++ b/testdata/p4_16_samples_outputs/issue383-bmv2-first.p4 @@ -21,6 +21,7 @@ struct col_t { } struct local_metadata_t { + @field_list(0) row_t row0; row_t row1; col_t col; @@ -79,7 +80,7 @@ control ingress(inout parsed_packet_t h, inout local_metadata_t local_metadata, local_metadata.row0.alt0 = local_metadata.row1.alt1; local_metadata.row1.alt0.valid = 1w1; local_metadata.row1.alt1.port = local_metadata.row0.alt1.port + 7w1; - clone3(CloneType.I2E, 32w0, local_metadata.row0); + clone_preserving_field_list(CloneType.I2E, 32w0, 8w0); } } @@ -106,4 +107,3 @@ control compute_checksum(inout parsed_packet_t hdr, inout local_metadata_t local } V1Switch(parse(), verifyChecksum(), ingress(), egress(), compute_checksum(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue383-bmv2-frontend.p4 b/testdata/p4_16_samples_outputs/issue383-bmv2-frontend.p4 index 4d22b4fe2c6..d91b4999752 100644 --- a/testdata/p4_16_samples_outputs/issue383-bmv2-frontend.p4 +++ b/testdata/p4_16_samples_outputs/issue383-bmv2-frontend.p4 @@ -21,6 +21,7 @@ struct col_t { } struct local_metadata_t { + @field_list(0) row_t row0; row_t row1; col_t col; @@ -79,7 +80,7 @@ control ingress(inout parsed_packet_t h, inout local_metadata_t local_metadata, local_metadata.row0.alt0 = local_metadata.row1.alt1; local_metadata.row1.alt0.valid = 1w1; local_metadata.row1.alt1.port = local_metadata.row0.alt1.port + 7w1; - clone3(CloneType.I2E, 32w0, local_metadata.row0); + clone_preserving_field_list(CloneType.I2E, 32w0, 8w0); } } @@ -106,4 +107,3 @@ control compute_checksum(inout parsed_packet_t hdr, inout local_metadata_t local } V1Switch(parse(), verifyChecksum(), ingress(), egress(), compute_checksum(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue383-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/issue383-bmv2-midend.p4 index c90ed32c679..4a305851a40 100644 --- a/testdata/p4_16_samples_outputs/issue383-bmv2-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue383-bmv2-midend.p4 @@ -24,9 +24,13 @@ struct col_t { } struct local_metadata_t { + @field_list(0) bit<1> _row0_alt0_valid0; + @field_list(0) bit<7> _row0_alt0_port1; + @field_list(0) bit<1> _row0_alt1_valid2; + @field_list(0) bit<7> _row0_alt1_port3; bit<1> _row1_alt0_valid4; bit<7> _row1_alt0_port5; @@ -80,36 +84,36 @@ control ingress(inout parsed_packet_t h, inout local_metadata_t local_metadata, } default_action = NoAction_1(); } - @hidden action issue383bmv2l74() { + @hidden action issue383bmv2l75() { s_0_col_bvh.setInvalid(); s_0_bvh0.setInvalid(); s_0_bvh1.setInvalid(); bh_0.setInvalid(); } - @hidden action issue383bmv2l104() { + @hidden action issue383bmv2l105() { local_metadata._col_bvh8._row_alt0_valid0 = 1w0; local_metadata._row0_alt0_valid0 = local_metadata._row1_alt1_valid6; local_metadata._row0_alt0_port1 = local_metadata._row1_alt1_port7; local_metadata._row1_alt0_valid4 = 1w1; local_metadata._row1_alt1_port7 = local_metadata._row0_alt1_port3 + 7w1; - clone3(CloneType.I2E, 32w0, (row_t){alt0 = (alt_t){valid = local_metadata._row1_alt1_valid6,port = local_metadata._row0_alt0_port1},alt1 = (alt_t){valid = local_metadata._row0_alt1_valid2,port = local_metadata._row0_alt1_port3}}); + clone_preserving_field_list(CloneType.I2E, 32w0, 8w0); } - @hidden table tbl_issue383bmv2l74 { + @hidden table tbl_issue383bmv2l75 { actions = { - issue383bmv2l74(); + issue383bmv2l75(); } - const default_action = issue383bmv2l74(); + const default_action = issue383bmv2l75(); } - @hidden table tbl_issue383bmv2l104 { + @hidden table tbl_issue383bmv2l105 { actions = { - issue383bmv2l104(); + issue383bmv2l105(); } - const default_action = issue383bmv2l104(); + const default_action = issue383bmv2l105(); } apply { - tbl_issue383bmv2l74.apply(); + tbl_issue383bmv2l75.apply(); tns_0.apply(); - tbl_issue383bmv2l104.apply(); + tbl_issue383bmv2l105.apply(); } } @@ -136,4 +140,3 @@ control compute_checksum(inout parsed_packet_t hdr, inout local_metadata_t local } V1Switch(parse(), verifyChecksum(), ingress(), egress(), compute_checksum(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue383-bmv2.p4 b/testdata/p4_16_samples_outputs/issue383-bmv2.p4 index a3f50979fdf..f46de800606 100644 --- a/testdata/p4_16_samples_outputs/issue383-bmv2.p4 +++ b/testdata/p4_16_samples_outputs/issue383-bmv2.p4 @@ -21,6 +21,7 @@ struct col_t { } struct local_metadata_t { + @field_list(0) row_t row0; row_t row1; col_t col; @@ -77,7 +78,7 @@ control ingress(inout parsed_packet_t h, inout local_metadata_t local_metadata, local_metadata.row0.alt0 = local_metadata.row1.alt1; local_metadata.row1.alt0.valid = 1; local_metadata.row1.alt1.port = local_metadata.row0.alt1.port + 1; - clone3(CloneType.I2E, 0, local_metadata.row0); + clone_preserving_field_list(CloneType.I2E, 0, 0); } } @@ -104,4 +105,3 @@ control compute_checksum(inout parsed_packet_t hdr, inout local_metadata_t local } V1Switch(parse(), verifyChecksum(), ingress(), egress(), compute_checksum(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue383-bmv2.p4-stderr b/testdata/p4_16_samples_outputs/issue383-bmv2.p4-stderr index 475cef84962..78fb65501fd 100644 --- a/testdata/p4_16_samples_outputs/issue383-bmv2.p4-stderr +++ b/testdata/p4_16_samples_outputs/issue383-bmv2.p4-stderr @@ -1,6 +1,6 @@ -issue383-bmv2.p4(97): [--Wwarn=invalid_header] warning: accessing a field of an invalid header bh +issue383-bmv2.p4(98): [--Wwarn=invalid_header] warning: accessing a field of an invalid header bh bh.row.alt0.valid = h.bvh0.row.alt0.valid; ^^ -issue383-bmv2.p4(102): [--Wwarn=invalid_header] warning: accessing a field of an invalid header s.col.bvh +issue383-bmv2.p4(103): [--Wwarn=invalid_header] warning: accessing a field of an invalid header s.col.bvh s.col.bvh.row.alt0.valid = 0; ^^^^^^^^^ diff --git a/testdata/p4_16_samples_outputs/issue562-bmv2-first.p4 b/testdata/p4_16_samples_outputs/issue562-bmv2-first.p4 index fd249eab87d..b6780d46394 100644 --- a/testdata/p4_16_samples_outputs/issue562-bmv2-first.p4 +++ b/testdata/p4_16_samples_outputs/issue562-bmv2-first.p4 @@ -16,6 +16,7 @@ struct parsed_packet_t { } struct local_metadata_t { + @field_list(0) row_t row; } @@ -30,7 +31,7 @@ control ingress(inout parsed_packet_t hdr, inout local_metadata_t local_metadata local_metadata.row.alt0 = local_metadata.row.alt1; local_metadata.row.alt0.valid = 1w1; local_metadata.row.alt1.port = local_metadata.row.alt1.port + 7w1; - clone3(CloneType.I2E, 32w0, local_metadata.row); + clone_preserving_field_list(CloneType.I2E, 32w0, 8w0); } } @@ -55,4 +56,3 @@ control compute_checksum(inout parsed_packet_t hdr, inout local_metadata_t local } V1Switch(parse(), verifyChecksum(), ingress(), egress(), compute_checksum(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue562-bmv2-frontend.p4 b/testdata/p4_16_samples_outputs/issue562-bmv2-frontend.p4 index fd249eab87d..b6780d46394 100644 --- a/testdata/p4_16_samples_outputs/issue562-bmv2-frontend.p4 +++ b/testdata/p4_16_samples_outputs/issue562-bmv2-frontend.p4 @@ -16,6 +16,7 @@ struct parsed_packet_t { } struct local_metadata_t { + @field_list(0) row_t row; } @@ -30,7 +31,7 @@ control ingress(inout parsed_packet_t hdr, inout local_metadata_t local_metadata local_metadata.row.alt0 = local_metadata.row.alt1; local_metadata.row.alt0.valid = 1w1; local_metadata.row.alt1.port = local_metadata.row.alt1.port + 7w1; - clone3(CloneType.I2E, 32w0, local_metadata.row); + clone_preserving_field_list(CloneType.I2E, 32w0, 8w0); } } @@ -55,4 +56,3 @@ control compute_checksum(inout parsed_packet_t hdr, inout local_metadata_t local } V1Switch(parse(), verifyChecksum(), ingress(), egress(), compute_checksum(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue562-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/issue562-bmv2-midend.p4 index 1605cf03d3c..f7c0d8cc7a4 100644 --- a/testdata/p4_16_samples_outputs/issue562-bmv2-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue562-bmv2-midend.p4 @@ -16,9 +16,13 @@ struct parsed_packet_t { } struct local_metadata_t { + @field_list(0) bit<1> _row_alt0_valid0; + @field_list(0) bit<7> _row_alt0_port1; + @field_list(0) bit<1> _row_alt1_valid2; + @field_list(0) bit<7> _row_alt1_port3; } @@ -29,21 +33,21 @@ parser parse(packet_in pk, out parsed_packet_t hdr, inout local_metadata_t local } control ingress(inout parsed_packet_t hdr, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - @hidden action issue562bmv2l31() { + @hidden action issue562bmv2l32() { local_metadata._row_alt0_valid0 = local_metadata._row_alt1_valid2; local_metadata._row_alt0_port1 = local_metadata._row_alt1_port3; local_metadata._row_alt0_valid0 = 1w1; local_metadata._row_alt1_port3 = local_metadata._row_alt1_port3 + 7w1; - clone3(CloneType.I2E, 32w0, (row_t){alt0 = (alt_t){valid = 1w1,port = local_metadata._row_alt0_port1},alt1 = (alt_t){valid = local_metadata._row_alt1_valid2,port = local_metadata._row_alt1_port3}}); + clone_preserving_field_list(CloneType.I2E, 32w0, 8w0); } - @hidden table tbl_issue562bmv2l31 { + @hidden table tbl_issue562bmv2l32 { actions = { - issue562bmv2l31(); + issue562bmv2l32(); } - const default_action = issue562bmv2l31(); + const default_action = issue562bmv2l32(); } apply { - tbl_issue562bmv2l31.apply(); + tbl_issue562bmv2l32.apply(); } } @@ -68,4 +72,3 @@ control compute_checksum(inout parsed_packet_t hdr, inout local_metadata_t local } V1Switch(parse(), verifyChecksum(), ingress(), egress(), compute_checksum(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue562-bmv2.p4 b/testdata/p4_16_samples_outputs/issue562-bmv2.p4 index b9b29b68cec..0a36f96579f 100644 --- a/testdata/p4_16_samples_outputs/issue562-bmv2.p4 +++ b/testdata/p4_16_samples_outputs/issue562-bmv2.p4 @@ -16,6 +16,7 @@ struct parsed_packet_t { } struct local_metadata_t { + @field_list(0) row_t row; } @@ -30,7 +31,7 @@ control ingress(inout parsed_packet_t hdr, inout local_metadata_t local_metadata local_metadata.row.alt0 = local_metadata.row.alt1; local_metadata.row.alt0.valid = 1; local_metadata.row.alt1.port = local_metadata.row.alt1.port + 1; - clone3(CloneType.I2E, 0, local_metadata.row); + clone_preserving_field_list(CloneType.I2E, 0, 0); } } @@ -55,4 +56,3 @@ control compute_checksum(inout parsed_packet_t hdr, inout local_metadata_t local } V1Switch(parse(), verifyChecksum(), ingress(), egress(), compute_checksum(), deparser()) main; - diff --git a/testdata/p4_16_samples_outputs/issue841.p4-stderr b/testdata/p4_16_samples_outputs/issue841.p4-stderr index 78807545244..238152c222c 100644 --- a/testdata/p4_16_samples_outputs/issue841.p4-stderr +++ b/testdata/p4_16_samples_outputs/issue841.p4-stderr @@ -1,6 +1,6 @@ issue841.p4(39): [--Wwarn=deprecated] warning: Checksum16: Using deprecated feature Checksum16. Please use verify_checksum/update_checksum instead. Checksum16() checksum; ^^^^^^^^^^ -v1model.p4(465) +v1model.p4(456) extern Checksum16 { ^^^^^^^^^^ diff --git a/testdata/p4_16_samples_outputs/methodArgDontcare.p4 b/testdata/p4_16_samples_outputs/methodArgDontcare.p4 index 35a1243e420..7c1247d49de 100644 --- a/testdata/p4_16_samples_outputs/methodArgDontcare.p4 +++ b/testdata/p4_16_samples_outputs/methodArgDontcare.p4 @@ -12,5 +12,5 @@ control c() { control proto(); package top(proto p); - top(c()) main; + diff --git a/testdata/p4_16_samples_outputs/psa-dpdk-table-key-consolidation-mixed-keys-4.p4.bfrt.json b/testdata/p4_16_samples_outputs/psa-dpdk-table-key-consolidation-mixed-keys-4.p4.bfrt.json index 1214883be65..0fa762318d9 100644 --- a/testdata/p4_16_samples_outputs/psa-dpdk-table-key-consolidation-mixed-keys-4.p4.bfrt.json +++ b/testdata/p4_16_samples_outputs/psa-dpdk-table-key-consolidation-mixed-keys-4.p4.bfrt.json @@ -57,4 +57,4 @@ } ], "learn_filters" : [] -} \ No newline at end of file +} diff --git a/testdata/p4_16_samples_outputs/v1model-special-ops-bmv2-first.p4 b/testdata/p4_16_samples_outputs/v1model-special-ops-bmv2-first.p4 index ef2d39e1f69..bfca126cbac 100644 --- a/testdata/p4_16_samples_outputs/v1model-special-ops-bmv2-first.p4 +++ b/testdata/p4_16_samples_outputs/v1model-special-ops-bmv2-first.p4 @@ -91,10 +91,10 @@ control ingress(inout headers_t hdr, inout meta_t meta, inout standard_metadata_ } action do_resubmit(bit<32> new_ipv4_dstAddr) { hdr.ipv4.dstAddr = new_ipv4_dstAddr; - resubmit>({ }); + resubmit_preserving_field_list(8w0); } action do_clone_i2e(bit<32> l2ptr) { - clone3>(CloneType.I2E, 32w5, { }); + clone_preserving_field_list(CloneType.I2E, 32w5, 8w0); meta.fwd.l2ptr = l2ptr; } table ipv4_da_lpm { @@ -162,11 +162,11 @@ control egress(inout headers_t hdr, inout meta_t meta, inout standard_metadata_t } action do_recirculate(bit<32> new_ipv4_dstAddr) { hdr.ipv4.dstAddr = new_ipv4_dstAddr; - recirculate>({ }); + recirculate_preserving_field_list(8w0); } action do_clone_e2e(bit<48> smac) { hdr.ethernet.srcAddr = smac; - clone3>(CloneType.E2E, 32w11, { }); + clone_preserving_field_list(CloneType.E2E, 32w11, 8w0); } table send_frame { key = { @@ -219,4 +219,3 @@ control computeChecksum(inout headers_t hdr, inout meta_t meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_16_samples_outputs/v1model-special-ops-bmv2-frontend.p4 b/testdata/p4_16_samples_outputs/v1model-special-ops-bmv2-frontend.p4 index fbec61c1991..1252d863dc1 100644 --- a/testdata/p4_16_samples_outputs/v1model-special-ops-bmv2-frontend.p4 +++ b/testdata/p4_16_samples_outputs/v1model-special-ops-bmv2-frontend.p4 @@ -83,10 +83,10 @@ control ingress(inout headers_t hdr, inout meta_t meta, inout standard_metadata_ } @name("ingress.do_resubmit") action do_resubmit(@name("new_ipv4_dstAddr") bit<32> new_ipv4_dstAddr) { hdr.ipv4.dstAddr = new_ipv4_dstAddr; - resubmit>({ }); + resubmit_preserving_field_list(8w0); } @name("ingress.do_clone_i2e") action do_clone_i2e(@name("l2ptr") bit<32> l2ptr_3) { - clone3>(CloneType.I2E, 32w5, { }); + clone_preserving_field_list(CloneType.I2E, 32w5, 8w0); meta.fwd.l2ptr = l2ptr_3; } @name("ingress.ipv4_da_lpm") table ipv4_da_lpm_0 { @@ -172,11 +172,11 @@ control egress(inout headers_t hdr, inout meta_t meta, inout standard_metadata_t } @name("egress.do_recirculate") action do_recirculate(@name("new_ipv4_dstAddr") bit<32> new_ipv4_dstAddr_2) { hdr.ipv4.dstAddr = new_ipv4_dstAddr_2; - recirculate>({ }); + recirculate_preserving_field_list(8w0); } @name("egress.do_clone_e2e") action do_clone_e2e(@name("smac") bit<48> smac_2) { hdr.ethernet.srcAddr = smac_2; - clone3>(CloneType.E2E, 32w11, { }); + clone_preserving_field_list(CloneType.E2E, 32w11, 8w0); } @name("egress.send_frame") table send_frame_0 { key = { @@ -229,4 +229,3 @@ control computeChecksum(inout headers_t hdr, inout meta_t meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_16_samples_outputs/v1model-special-ops-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/v1model-special-ops-bmv2-midend.p4 index 41a3646b0fc..91505d559d0 100644 --- a/testdata/p4_16_samples_outputs/v1model-special-ops-bmv2-midend.p4 +++ b/testdata/p4_16_samples_outputs/v1model-special-ops-bmv2-midend.p4 @@ -58,9 +58,6 @@ parser ParserImpl(packet_in packet, out headers_t hdr, inout meta_t meta, inout } } -struct tuple_0 { -} - control ingress(inout headers_t hdr, inout meta_t meta, inout standard_metadata_t standard_metadata) { @name("ingress.smeta") standard_metadata_t smeta_0; @name("ingress.smeta") standard_metadata_t smeta_3; @@ -142,10 +139,10 @@ control ingress(inout headers_t hdr, inout meta_t meta, inout standard_metadata_ } @name("ingress.do_resubmit") action do_resubmit(@name("new_ipv4_dstAddr") bit<32> new_ipv4_dstAddr) { hdr.ipv4.dstAddr = new_ipv4_dstAddr; - resubmit((tuple_0){}); + resubmit_preserving_field_list(8w0); } @name("ingress.do_clone_i2e") action do_clone_i2e(@name("l2ptr") bit<32> l2ptr_3) { - clone3(CloneType.I2E, 32w5, (tuple_0){}); + clone_preserving_field_list(CloneType.I2E, 32w5, 8w0); meta._fwd_l2ptr0 = l2ptr_3; } @name("ingress.ipv4_da_lpm") table ipv4_da_lpm_0 { @@ -269,11 +266,11 @@ control egress(inout headers_t hdr, inout meta_t meta, inout standard_metadata_t } @name("egress.do_recirculate") action do_recirculate(@name("new_ipv4_dstAddr") bit<32> new_ipv4_dstAddr_2) { hdr.ipv4.dstAddr = new_ipv4_dstAddr_2; - recirculate((tuple_0){}); + recirculate_preserving_field_list(8w0); } @name("egress.do_clone_e2e") action do_clone_e2e(@name("smac") bit<48> smac_2) { hdr.ethernet.srcAddr = smac_2; - clone3(CloneType.E2E, 32w11, (tuple_0){}); + clone_preserving_field_list(CloneType.E2E, 32w11, 8w0); } @name("egress.send_frame") table send_frame_0 { key = { @@ -331,7 +328,7 @@ control DeparserImpl(packet_out packet, in headers_t hdr) { } } -struct tuple_1 { +struct tuple_0 { bit<4> f0; bit<4> f1; bit<8> f2; @@ -347,15 +344,14 @@ struct tuple_1 { control verifyChecksum(inout headers_t hdr, inout meta_t meta) { apply { - verify_checksum>(hdr.ipv4.isValid() && hdr.ipv4.ihl == 4w5, (tuple_1){f0 = hdr.ipv4.version,f1 = hdr.ipv4.ihl,f2 = hdr.ipv4.diffserv,f3 = hdr.ipv4.totalLen,f4 = hdr.ipv4.identification,f5 = hdr.ipv4.flags,f6 = hdr.ipv4.fragOffset,f7 = hdr.ipv4.ttl,f8 = hdr.ipv4.protocol,f9 = hdr.ipv4.srcAddr,f10 = hdr.ipv4.dstAddr}, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); + verify_checksum>(hdr.ipv4.isValid() && hdr.ipv4.ihl == 4w5, (tuple_0){f0 = hdr.ipv4.version,f1 = hdr.ipv4.ihl,f2 = hdr.ipv4.diffserv,f3 = hdr.ipv4.totalLen,f4 = hdr.ipv4.identification,f5 = hdr.ipv4.flags,f6 = hdr.ipv4.fragOffset,f7 = hdr.ipv4.ttl,f8 = hdr.ipv4.protocol,f9 = hdr.ipv4.srcAddr,f10 = hdr.ipv4.dstAddr}, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); } } control computeChecksum(inout headers_t hdr, inout meta_t meta) { apply { - update_checksum>(hdr.ipv4.isValid() && hdr.ipv4.ihl == 4w5, (tuple_1){f0 = hdr.ipv4.version,f1 = hdr.ipv4.ihl,f2 = hdr.ipv4.diffserv,f3 = hdr.ipv4.totalLen,f4 = hdr.ipv4.identification,f5 = hdr.ipv4.flags,f6 = hdr.ipv4.fragOffset,f7 = hdr.ipv4.ttl,f8 = hdr.ipv4.protocol,f9 = hdr.ipv4.srcAddr,f10 = hdr.ipv4.dstAddr}, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); + update_checksum>(hdr.ipv4.isValid() && hdr.ipv4.ihl == 4w5, (tuple_0){f0 = hdr.ipv4.version,f1 = hdr.ipv4.ihl,f2 = hdr.ipv4.diffserv,f3 = hdr.ipv4.totalLen,f4 = hdr.ipv4.identification,f5 = hdr.ipv4.flags,f6 = hdr.ipv4.fragOffset,f7 = hdr.ipv4.ttl,f8 = hdr.ipv4.protocol,f9 = hdr.ipv4.srcAddr,f10 = hdr.ipv4.dstAddr}, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); } } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; - diff --git a/testdata/p4_16_samples_outputs/v1model-special-ops-bmv2.p4 b/testdata/p4_16_samples_outputs/v1model-special-ops-bmv2.p4 index 9d32d331068..d2d398d580d 100644 --- a/testdata/p4_16_samples_outputs/v1model-special-ops-bmv2.p4 +++ b/testdata/p4_16_samples_outputs/v1model-special-ops-bmv2.p4 @@ -91,10 +91,10 @@ control ingress(inout headers_t hdr, inout meta_t meta, inout standard_metadata_ } action do_resubmit(bit<32> new_ipv4_dstAddr) { hdr.ipv4.dstAddr = new_ipv4_dstAddr; - resubmit({ }); + resubmit_preserving_field_list(0); } action do_clone_i2e(bit<32> l2ptr) { - clone3(CloneType.I2E, I2E_CLONE_SESSION_ID, { }); + clone_preserving_field_list(CloneType.I2E, I2E_CLONE_SESSION_ID, 0); meta.fwd.l2ptr = l2ptr; } table ipv4_da_lpm { @@ -160,11 +160,11 @@ control egress(inout headers_t hdr, inout meta_t meta, inout standard_metadata_t } action do_recirculate(bit<32> new_ipv4_dstAddr) { hdr.ipv4.dstAddr = new_ipv4_dstAddr; - recirculate({ }); + recirculate_preserving_field_list(0); } action do_clone_e2e(bit<48> smac) { hdr.ethernet.srcAddr = smac; - clone3(CloneType.E2E, E2E_CLONE_SESSION_ID, { }); + clone_preserving_field_list(CloneType.E2E, E2E_CLONE_SESSION_ID, 0); } table send_frame { key = { @@ -217,4 +217,3 @@ control computeChecksum(inout headers_t hdr, inout meta_t meta) { } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; -