diff --git a/backends/bmv2/CMakeLists.txt b/backends/bmv2/CMakeLists.txt index 45d037df59a..e8be14445e1 100644 --- a/backends/bmv2/CMakeLists.txt +++ b/backends/bmv2/CMakeLists.txt @@ -145,17 +145,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, - # this program is the _only_ p4c test program that relies for its - # successful execution on the preservation of metadata across - # resubmit, recirculate, and/or clone operations. - testdata/p4_14_samples/p414-special-ops-2-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 bb9edfd0e72..695ca8ae52d 100644 --- a/backends/bmv2/common/JsonObjects.cpp +++ b/backends/bmv2/common/JsonObjects.cpp @@ -229,7 +229,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/header.cpp b/backends/bmv2/common/header.cpp index b2e7a0c2169..5418d2b1b3a 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()) { @@ -84,7 +84,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 @@ -140,7 +140,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(); @@ -287,7 +287,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(); @@ -324,7 +324,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(); @@ -439,7 +439,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 46b911cf83d..8f23a4318d0 100644 --- a/backends/bmv2/common/helpers.cpp +++ b/backends/bmv2/common/helpers.cpp @@ -82,6 +82,119 @@ 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); + if (!fields->is()) { + // expand it into a list + auto list = new IR::ListExpression({}); + auto type = typeMap->getType(fields, true); + if (!type->is()) { + modelError("%1%: expected a struct", fields); + return calcName; + } + for (auto f : type->to()->fields) { + auto e = new IR::Member(fields, f->name); + auto ftype = typeMap->getType(f); + typeMap->setType(e, ftype); + list->push_back(e); + } + fields = list; + typeMap->setType(fields, type); + } + 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; +} + +} // namespace BMV2 diff --git a/backends/bmv2/common/helpers.h b/backends/bmv2/common/helpers.h index 3ea609914c6..1843cc461e3 100644 --- a/backends/bmv2/common/helpers.h +++ b/backends/bmv2/common/helpers.h @@ -91,6 +91,12 @@ struct ConversionContext { ExpressionConverter* conv, JsonObjects* json) : refMap(refMap), typeMap(typeMap), toplevel(toplevel), 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); }; using BlockTypeMap = std::map; diff --git a/backends/bmv2/common/programStructure.h b/backends/bmv2/common/programStructure.h index 6fb97902b70..2b8d38eb206 100644 --- a/backends/bmv2/common/programStructure.h +++ b/backends/bmv2/common/programStructure.h @@ -44,13 +44,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 02ecd570f26..f6cf1353f68 100644 --- a/backends/bmv2/psa_switch/psaSwitch.cpp +++ b/backends/bmv2/psa_switch/psaSwitch.cpp @@ -455,8 +455,6 @@ void PsaSwitchBackend::convert(const IR::ToplevelBlock* tlb) { auto evaluator = new P4::EvaluatorPass(refMap, typeMap); auto program = tlb->getProgram(); PassManager simplify = { - /* TODO */ - // new RenameUserMetadata(refMap, userMetaType, userMetaName), new P4::ClearTypeMap(typeMap), // because the user metadata type has changed // new P4::SynthesizeActions(refMap, typeMap, new SkipControls(&non_pipeline_controls)), new P4::MoveActionsToTables(refMap, typeMap), @@ -535,7 +533,7 @@ Util::IJson* ExternConverter_Counter::convertExternObject( UNUSED 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); + ConversionContext::modelError("Expected 1 argument for %1%", mc); return nullptr; } auto primitive = mkPrimitive("_" + em->originalExternType->name + @@ -556,7 +554,7 @@ Util::IJson* ExternConverter_DirectCounter::convertExternObject( UNUSED 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); + ConversionContext::modelError("Expected 0 argument for %1%", mc); return nullptr; } // Do not generate any code for this operation @@ -568,7 +566,7 @@ Util::IJson* ExternConverter_Meter::convertExternObject( UNUSED 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); + ConversionContext::modelError("Expected 2 arguments for %1%", mc); return nullptr; } auto primitive = mkPrimitive("execute_meter"); @@ -590,7 +588,7 @@ Util::IJson* ExternConverter_DirectMeter::convertExternObject( UNUSED 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); + ConversionContext::modelError("Expected 1 argument for %1%", mc); return nullptr; } auto dest = mc->arguments->at(0); @@ -604,7 +602,7 @@ Util::IJson* ExternConverter_Register::convertExternObject( UNUSED 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); + ConversionContext::modelError("Expected 2 arguments for %1%", mc); return nullptr; } auto reg = new Util::JsonObject(); @@ -641,7 +639,7 @@ Util::IJson* ExternConverter_Random::convertExternObject( UNUSED 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); + ConversionContext::modelError("Expected 3 arguments for %1%", mc); return nullptr; } auto primitive = @@ -663,7 +661,7 @@ Util::IJson* ExternConverter_Digest::convertExternObject( UNUSED 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); + ConversionContext::modelError("Expected 1 arguments for %1%", mc); return nullptr; } auto primitive = mkPrimitive("generate_digest"); @@ -678,15 +676,14 @@ Util::IJson* ExternConverter_Digest::convertExternObject( auto origType = ctxt->refMap->getDeclaration( typeArg->to()->path, true); if (!origType->is()) { - modelError("%1%: expected a struct type", origType->getNode()); + ConversionContext::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, "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); @@ -721,7 +718,7 @@ void ExternConverter_Counter::convertExternInstance( auto sz = eb->findParameterValue("n_counters"); CHECK_NULL(sz); if (!sz->is()) { - modelError("%1%: expected a constant", sz->getNode()); + ConversionContext::modelError("%1%: expected a constant", sz->getNode()); return; } jctr->emplace("size", sz->to()->value); @@ -830,7 +827,7 @@ void ExternConverter_Meter::convertExternInstance( auto sz = eb->findParameterValue("n_meters"); CHECK_NULL(sz); if (!sz->is()) { - modelError("%1%: expected a constant", sz->getNode()); + ConversionContext::modelError("%1%: expected a constant", sz->getNode()); return; } jmtr->emplace("size", sz->to()->value); @@ -838,7 +835,7 @@ void ExternConverter_Meter::convertExternInstance( auto mkind = eb->findParameterValue("type"); CHECK_NULL(mkind); if (!mkind->is()) { - modelError("%1%: expected a member", mkind->getNode()); + ConversionContext::modelError("%1%: expected a member", mkind->getNode()); return; } cstring mkind_name = mkind->to()->name; @@ -872,7 +869,7 @@ void ExternConverter_DirectMeter::convertExternInstance( auto mkind = eb->findParameterValue("type"); CHECK_NULL(mkind); if (!mkind->is()) { - modelError("%1%: expected a member", mkind->getNode()); + ConversionContext::modelError("%1%: expected a member", mkind->getNode()); return; } cstring mkind_name = mkind->to()->name; @@ -882,7 +879,7 @@ void ExternConverter_DirectMeter::convertExternInstance( } else if (mkind_name == "BYTES") { type = "bytes"; } else { - modelError("%1%: unexpected meter type", mkind->getNode()); + ConversionContext::modelError("%1%: unexpected meter type", mkind->getNode()); return; } jmtr->emplace("type", type); @@ -906,19 +903,19 @@ void ExternConverter_Register::convertExternInstance( auto sz = eb->findParameterValue("size"); CHECK_NULL(sz); if (!sz->is()) { - modelError("%1%: expected a constant", sz->getNode()); + ConversionContext::modelError("%1%: expected a constant", sz->getNode()); return; } if (sz->to()->value == 0) error(ErrorType::ERR_UNSUPPORTED, "direct registers", inst); jreg->emplace("size", sz->to()->value); if (!eb->instanceType->is()) { - modelError("%1%: Expected a generic specialized type", eb->instanceType); + ConversionContext::modelError("%1%: Expected a generic specialized type", eb->instanceType); return; } auto st = eb->instanceType->to(); if (st->arguments->size() != 1) { - modelError("%1%: expected 1 type argument", st); + ConversionContext::modelError("%1%: expected 1 type argument", st); return; } auto regType = st->arguments->at(0); @@ -987,7 +984,7 @@ void ExternConverter_ActionSelector::convertExternInstance( auto hash = eb->findParameterValue("algo"); if (!hash->is()) { - modelError("%1%: expected a member", hash->getNode()); + ConversionContext::modelError("%1%: expected a member", hash->getNode()); return; } auto algo = ExternConverter::convertHashAlgorithm(hash->to()->name); diff --git a/backends/bmv2/simple_switch/simpleSwitch.cpp b/backends/bmv2/simple_switch/simpleSwitch.cpp index 3c0cc1acc64..06280fdb73c 100644 --- a/backends/bmv2/simple_switch/simpleSwitch.cpp +++ b/backends/bmv2/simple_switch/simpleSwitch.cpp @@ -109,22 +109,22 @@ ExternConverter_action_profile ExternConverter_action_profile::singleton; ExternConverter_action_selector ExternConverter_action_selector::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) { - modelError("Expected 2 arguments for %1%", mc); + ConversionContext::modelError("Expected 2 arguments for %1%", mc); return nullptr; } 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); if (ei == nullptr) { - modelError("%1%: must be a constant on this target", cloneType); + ConversionContext::modelError("%1%: must be a constant on this target", cloneType); return nullptr; } cstring prim = ei->name == "I2E" ? "clone_ingress_pkt_to_egress" : @@ -144,23 +144,45 @@ Util::IJson* ExternConverter_clone::convertExternFunction( return primitive; } +// 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_clone3::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) { (void) v1model.clone.clone3.name; int id = -1; if (mc->arguments->size() != 3) { - modelError("Expected 3 arguments for %1%", mc); + ConversionContext::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) { - modelError("%1%: must be a constant on this target", cloneType); + ConversionContext::modelError("%1%: must be a constant on this target", cloneType); return nullptr; } cstring prim = ei->name == "I2E" ? "clone_ingress_pkt_to_egress" : @@ -171,18 +193,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); + auto fl = mc->arguments->at(2); + auto cst = fl->expression->to(); + if (cst == nullptr) { + ConversionContext::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, @@ -192,7 +220,7 @@ Util::IJson* ExternConverter_hash::convertExternFunction( }; if (mc->arguments->size() != 5) { - modelError("Expected 5 arguments for %1%", mc); + ConversionContext::modelError("Expected 5 arguments for %1%", mc); return nullptr; } auto primitive = mkPrimitive("modify_field_with_hash_based_offset"); @@ -210,7 +238,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); @@ -221,11 +249,11 @@ 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); + ConversionContext::modelError("Expected 2 arguments for %1%", mc); return nullptr; } auto primitive = mkPrimitive("generate_digest"); @@ -242,15 +270,14 @@ Util::IJson* ExternConverter_digest::convertExternFunction( auto origType = ctxt->refMap->getDeclaration( typeArg->to()->path, true); if (!origType->is()) { - modelError("%1%: expected a struct type", origType->getNode()); + ConversionContext::modelError("%1%: expected a struct type", origType->getNode()); return nullptr; } auto st = origType->to(); 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); @@ -259,80 +286,60 @@ Util::IJson* ExternConverter_digest::convertExternFunction( } Util::IJson* ExternConverter_resubmit::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); - 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) { + ConversionContext::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); - 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; + ConversionContext::modelError("Expected 0 or 1 arguments for %1%", mc); + return nullptr; } Util::IJson* ExternConverter_recirculate::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); - 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(); + 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) { + ConversionContext::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; } - int id = createFieldList(ctxt, mc->arguments->at(0)->expression, "field_lists", - listName, ctxt->json->field_lists); - 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; + ConversionContext::modelError("Expected 1 argument for %1%", mc); + return nullptr; } 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, + 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); @@ -347,11 +354,11 @@ 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); + ConversionContext::modelError("Expected 3 arguments for %1%", mc); return nullptr; } auto primitive = @@ -369,10 +376,10 @@ 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); + ConversionContext::modelError("Expected 1 arguments for %1%", mc); return nullptr; } auto primitive = mkPrimitive(v1model.truncate.name); @@ -384,11 +391,11 @@ 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); + ConversionContext::modelError("Expected 1 argument for %1%", mc); return nullptr; } auto primitive = mkPrimitive("count"); @@ -404,8 +411,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(); @@ -415,7 +422,7 @@ void ExternConverter_counter::convertExternInstance( auto sz = eb->findParameterValue(v1model.counter.sizeParam.name); CHECK_NULL(sz); if (!sz->is()) { - modelError("%1%: expected a constant", sz->getNode()); + ConversionContext::modelError("%1%: expected a constant", sz->getNode()); return; } jctr->emplace("size", sz->to()->value); @@ -424,11 +431,11 @@ 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); + ConversionContext::modelError("Expected 2 arguments for %1%", mc); return nullptr; } auto primitive = mkPrimitive("execute_meter"); @@ -446,8 +453,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(); @@ -458,7 +465,7 @@ void ExternConverter_meter::convertExternInstance( auto sz = eb->findParameterValue(v1model.meter.sizeParam.name); CHECK_NULL(sz); if (!sz->is()) { - modelError("%1%: expected a constant", sz->getNode()); + ConversionContext::modelError("%1%: expected a constant", sz->getNode()); return; } jmtr->emplace("size", sz->to()->value); @@ -466,7 +473,7 @@ void ExternConverter_meter::convertExternInstance( auto mkind = eb->findParameterValue(v1model.meter.typeParam.name); CHECK_NULL(mkind); if (!mkind->is()) { - modelError("%1%: expected a member", mkind->getNode()); + ConversionContext::modelError("%1%: expected a member", mkind->getNode()); return; } cstring mkind_name = mkind->to()->name; @@ -482,11 +489,11 @@ 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); + ConversionContext::modelError("Expected 2 arguments for %1%", mc); return nullptr; } auto reg = new Util::JsonObject(); @@ -518,8 +525,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(); @@ -529,19 +536,19 @@ void ExternConverter_register::convertExternInstance( auto sz = eb->findParameterValue(v1model.registers.sizeParam.name); CHECK_NULL(sz); if (!sz->is()) { - modelError("%1%: expected a constant", sz->getNode()); + ConversionContext::modelError("%1%: expected a constant", sz->getNode()); return; } if (sz->to()->value == 0) error("%1%: direct registers are not supported in bmv2", inst); jreg->emplace("size", sz->to()->value); if (!eb->instanceType->is()) { - modelError("%1%: Expected a generic specialized type", eb->instanceType); + ConversionContext::modelError("%1%: Expected a generic specialized type", eb->instanceType); return; } auto st = eb->instanceType->to(); if (st->arguments->size() != 1) { - modelError("%1%: expected 1 type argument", st); + ConversionContext::modelError("%1%: expected 1 type argument", st); return; } auto regType = st->arguments->at(0); @@ -560,10 +567,10 @@ 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); + ConversionContext::modelError("Expected 0 argument for %1%", mc); return nullptr; } // Do not generate any code for this operation @@ -571,8 +578,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); @@ -590,11 +597,11 @@ 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); + ConversionContext::modelError("Expected 1 argument for %1%", mc); return nullptr; } auto dest = mc->arguments->at(0); @@ -604,8 +611,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); @@ -640,7 +647,7 @@ void ExternConverter_direct_meter::convertExternInstance( auto mkind = eb->findParameterValue(v1model.directMeter.typeParam.name); CHECK_NULL(mkind); if (!mkind->is()) { - modelError("%1%: expected a member", mkind->getNode()); + ConversionContext::modelError("%1%: expected a member", mkind->getNode()); return; } cstring mkind_name = mkind->to()->name; @@ -650,7 +657,7 @@ void ExternConverter_direct_meter::convertExternInstance( } else if (mkind_name == v1model.meter.meterType.bytes.name) { type = "bytes"; } else { - modelError("%1%: unexpected meter type", mkind->getNode()); + ConversionContext::modelError("%1%: unexpected meter type", mkind->getNode()); return; } jmtr->emplace("type", type); @@ -663,8 +670,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 @@ -693,7 +700,7 @@ void ExternConverter_action_profile::convertExternInstance( auto hash = eb->findParameterValue( v1model.action_selector.algorithmParam.name); if (!hash->is()) { - modelError("%1%: expected a member", hash->getNode()); + ConversionContext::modelError("%1%: expected a member", hash->getNode()); return; } auto algo = ExternConverter::convertHashAlgorithm(hash->to()->name); @@ -719,8 +726,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 @@ -749,7 +756,7 @@ void ExternConverter_action_selector::convertExternInstance( auto hash = eb->findParameterValue( v1model.action_selector.algorithmParam.name); if (!hash->is()) { - modelError("%1%: expected a member", hash->getNode()); + ConversionContext::modelError("%1%: expected a member", hash->getNode()); return; } auto algo = ExternConverter::convertHashAlgorithm(hash->to()->name); @@ -775,8 +782,7 @@ void ExternConverter_action_selector::convertExternInstance( void SimpleSwitchBackend::modelError(const char* format, const IR::Node* node) const { - ::error(format, node); - ::error("Are you using an up-to-date v1model.p4?"); + ConversionContext::modelError(format, node); } cstring @@ -795,7 +801,7 @@ SimpleSwitchBackend::createCalculation(cstring algo, const IR::Expression* field auto list = new IR::ListExpression({}); auto type = typeMap->getType(fields, true); if (!type->is()) { - modelError("%1%: expected a struct", fields); + ConversionContext::modelError("%1%: expected a struct", fields); return calcName; } for (auto f : type->to()->fields) { @@ -860,7 +866,7 @@ SimpleSwitchBackend::convertChecksum(const IR::BlockStatement *block, Util::Json functionName == v1model.update_checksum_with_payload.name))) { bool usePayload = functionName.endsWith("_with_payload"); if (mi->expr->arguments->size() != 4) { - modelError("%1%: Expected 4 arguments", mc); + ConversionContext::modelError("%1%: Expected 4 arguments", mc); return; } auto cksum = new Util::JsonObject(); @@ -906,6 +912,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(); @@ -931,7 +1003,7 @@ SimpleSwitchBackend::convert(const IR::ToplevelBlock* tlb) { auto parser = main->findParameterValue(v1model.sw.parser.name); if (parser == nullptr) return; if (!parser->is()) { - modelError("%1%: main package match the expected model", main); + ConversionContext::modelError("%1%: main package match the expected model", main); return; } auto params = parser->to()->container->getApplyParameters(); @@ -1052,12 +1124,12 @@ 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); + createRecirculateFieldsList(ctxt, toplevel, scalarsName); + auto pconv = new ParserConverter(ctxt); structure->parser->apply(*pconv); @@ -1074,7 +1146,6 @@ SimpleSwitchBackend::convert(const IR::ToplevelBlock* tlb) { convertChecksum(structure->compute_checksum->body, json->checksums, json->calculations, false); - convertChecksum(structure->verify_checksum->body, json->checksums, json->calculations, true); diff --git a/backends/bmv2/simple_switch/simpleSwitch.h b/backends/bmv2/simple_switch/simpleSwitch.h index 47591f48eb5..5959e7ec05b 100644 --- a/backends/bmv2/simple_switch/simpleSwitch.h +++ b/backends/bmv2/simple_switch/simpleSwitch.h @@ -131,6 +131,8 @@ class SimpleSwitchBackend : public Backend { V1ProgramStructure* structure; 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); diff --git a/frontends/p4/fromv1.0/converters.cpp b/frontends/p4/fromv1.0/converters.cpp index 08ee02db2cf..0452bd99900 100644 --- a/frontends/p4/fromv1.0/converters.cpp +++ b/frontends/p4/fromv1.0/converters.cpp @@ -421,10 +421,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]; @@ -438,6 +441,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; } @@ -808,6 +814,42 @@ class ComputeTableCallGraph : public Inspector { } }; +/// 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 Rewriter : public Transform { ProgramStructure* structure; public: @@ -1365,6 +1407,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 659aead76c7..313e94b0baa 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) // Is fed a P4-14 program and outputs an equivalent P4-16 program diff --git a/frontends/p4/fromv1.0/programStructure.cpp b/frontends/p4/fromv1.0/programStructure.cpp index 279e59fa0ff..77ee2671209 100644 --- a/frontends/p4/fromv1.0/programStructure.cpp +++ b/frontends/p4/fromv1.0/programStructure.cpp @@ -34,6 +34,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), @@ -101,6 +114,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)) @@ -126,6 +195,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) { @@ -177,14 +259,14 @@ void ProgramStructure::createTypes() { const IR::Type_Struct* ProgramStructure::createFieldListType(const IR::Expression* expression) { if (!expression->is()) { - ::error("%1%: expected a field list", expression); - return nullptr; + ::error("%1%: expected a field list", expression); + return nullptr; } auto nr = expression->to(); auto fl = field_lists.get(nr->path->name); if (fl == nullptr) { - ::error("%1%: Expected a field list", expression); - return nullptr; + ::error("%1%: Expected a field list", expression); + return nullptr; } auto name = makeUniqueName(nr->path->name); @@ -269,7 +351,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) { @@ -1056,14 +1139,14 @@ const IR::Expression* ProgramStructure::convertFieldList(const IR::Expression* e ExpressionConverter conv(this); if (!expression->is()) { - ::error("%1%: expected a field list", expression); - return expression; + ::error("%1%: expected a field list", expression); + return expression; } auto nr = expression->to(); auto fl = field_lists.get(nr->path->name); if (fl == nullptr) { - ::error("%1%: Expected a field list", expression); - return expression; + ::error("%1%: Expected a field list", expression); + return expression; } auto result = conv.convert(fl); return result; @@ -1489,11 +1572,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); @@ -1501,7 +1583,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)); @@ -1514,14 +1597,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); @@ -1538,14 +1621,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) { @@ -2082,7 +2169,8 @@ ProgramStructure::convertControl(const IR::V1Control* control, cstring newName) for (auto c : registersToDo) { auto reg = registers.get(c); auto r = convert(reg, registers.get(reg)); - declarations->push_back(r); + if (getFirstDeclaration(declarations, r->name) == nullptr) + declarations->push_back(r); } for (auto c : externsToDo) { diff --git a/frontends/p4/fromv1.0/programStructure.h b/frontends/p4/fromv1.0/programStructure.h index 5a62d8072b3..65f5b295b38 100644 --- a/frontends/p4/fromv1.0/programStructure.h +++ b/frontends/p4/fromv1.0/programStructure.h @@ -132,6 +132,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; @@ -150,6 +152,8 @@ class ProgramStructure { std::map extractsSynthesized; std::map parserEntryPoints; + /// Name of the serializable enum that holds one id for each field list. + cstring fieldListsEnum; struct ConversionContext { const IR::Expression* header; @@ -253,6 +257,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::V1Control* ingress; IR::ID ingressReference; diff --git a/frontends/p4/parseAnnotations.cpp b/frontends/p4/parseAnnotations.cpp index b094641029d..04f261d5d5a 100644 --- a/frontends/p4/parseAnnotations.cpp +++ b/frontends/p4/parseAnnotations.cpp @@ -82,6 +82,7 @@ bool ParseAnnotations::parseKvList(IR::Annotation* annotation) { } void ParseAnnotations::postorder(IR::Annotation* annotation) { + LOG2("Scanning annotation " << annotation); if (!annotation->needsParsing) { return; } @@ -101,6 +102,7 @@ void ParseAnnotations::postorder(IR::Annotation* annotation) { return; } + LOG2("Parsing annotation " << annotation); annotation->needsParsing = !handlers[name](annotation); } diff --git a/frontends/p4/typeChecking/typeChecker.cpp b/frontends/p4/typeChecking/typeChecker.cpp index f99af5b2c71..b2a09f97d56 100644 --- a/frontends/p4/typeChecking/typeChecker.cpp +++ b/frontends/p4/typeChecking/typeChecker.cpp @@ -2264,6 +2264,9 @@ const IR::Node* TypeInference::postorder(IR::PathExpression* expression) { typeError("%1%: Recursive action call", expression); return expression; } + } else if (decl->is() || decl->is()) { + setCompileTimeConstant(expression); + setCompileTimeConstant(getOriginal()); } if (decl->is()) { diff --git a/frontends/p4/typeChecking/typeUnification.cpp b/frontends/p4/typeChecking/typeUnification.cpp index 3d5ba20ddbd..f808fd9db34 100644 --- a/frontends/p4/typeChecking/typeUnification.cpp +++ b/frontends/p4/typeChecking/typeUnification.cpp @@ -42,7 +42,8 @@ bool TypeUnification::unifyCall(const IR::Node* errorPosition, if (src->typeArguments->size() != 0) { if (dest->typeParameters->size() != src->typeArguments->size()) { - ::error("%1% has %2% type parameters, but is invoked with %3% type arguments", + ::error(ErrorType::ERR_TYPE_ERROR, + "%1% has %2% type parameters, but is invoked with %3% type arguments", errorPosition, (dest->typeParameters ? dest->typeParameters->size() : 0), src->typeArguments->size()); return false; @@ -57,7 +58,8 @@ bool TypeUnification::unifyCall(const IR::Node* errorPosition, if (dest->parameters->size() < src->arguments->size()) { if (reportErrors) - ::error("%1%: Passing %2% arguments when %3% expected", + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: Passing %2% arguments when %3% expected", errorPosition, src->arguments->size(), dest->parameters->size()); return false; } @@ -77,13 +79,15 @@ bool TypeUnification::unifyCall(const IR::Node* errorPosition, param = dest->parameters->getParameter(argName); if (param == nullptr) { if (reportErrors) - ::error("%1%: No parameter named %2%", errorPosition, arg->name); + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: No parameter named %2%", errorPosition, arg->name); return false; } } else { if (paramIt == dest->parameters->end()) { if (reportErrors) - ::error("%1%: Too many arguments for call", errorPosition); + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: Too many arguments for call", errorPosition); return false; } param = *paramIt; @@ -96,25 +100,27 @@ bool TypeUnification::unifyCall(const IR::Node* errorPosition, if (arg->type->is() && param->direction != IR::Direction::Out) { if (reportErrors) - ::error("%1%: don't care argument only allowed for out parameters", arg->srcInfo); + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: don't care argument only allowed for out parameters", arg->srcInfo); return false; } if ((param->direction == IR::Direction::Out || param->direction == IR::Direction::InOut) && (!arg->leftValue)) { if (reportErrors) - ::error("%1%: Read-only value used for out/inout parameter %2%", - arg->srcInfo, param); + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: Read-only value used for out/inout parameter %2%", arg, param); return false; } else if (param->direction == IR::Direction::None && !arg->compileTimeConstant) { if (reportErrors) - ::error("%1%: not a compile-time constant when binding to %2%", - arg->srcInfo, param); + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: not a compile-time constant when binding to %2%", arg, param); return false; } if (param->direction != IR::Direction::None && param->type->is()) { if (optarg) continue; - ::error("%1%: extern values cannot be passed in/out/inout", param); + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: extern values cannot be passed in/out/inout", param); return false; } @@ -128,7 +134,8 @@ bool TypeUnification::unifyCall(const IR::Node* errorPosition, bool opt = p.second->isOptional() || p.second->defaultValue != nullptr; if (opt) continue; if (reportErrors) - ::error("%1%: No argument for parameter %2%", errorPosition, p.second); + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: No argument for parameter %2%", errorPosition, p.second); return false; } @@ -152,7 +159,8 @@ bool TypeUnification::unifyFunctions(const IR::Node* errorPosition, if ((src->returnType == nullptr) != (dest->returnType == nullptr)) { if (reportErrors) - ::error("%1%: Cannot unify functions with different return types" + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: Cannot unify functions with different return types" " %2% and %3%", errorPosition, dest, src); return false; } @@ -167,12 +175,14 @@ bool TypeUnification::unifyFunctions(const IR::Node* errorPosition, if (dit->defaultValue != nullptr) continue; if (reportErrors) - ::error("%1%: Cannot unify functions with different number of arguments: " + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: Cannot unify functions with different number of arguments: " "%2% to %3%", errorPosition, src, dest); return false; } if ((*sit)->direction != dit->direction) { if (reportErrors) - ::error("%1%: Cannot unify parameter %2% with %3% " + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: Cannot unify parameter %2% with %3% " "because they have different directions", errorPosition, *sit, dit); return false; @@ -188,7 +198,8 @@ bool TypeUnification::unifyFunctions(const IR::Node* errorPosition, ++sit; continue; } if (reportErrors) - ::error("%1%: Cannot unify functions with different number of arguments: " + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: Cannot unify functions with different number of arguments: " "%2% to %3%", errorPosition, src, dest); return false; } return true; @@ -203,7 +214,8 @@ bool TypeUnification::unifyBlocks(const IR::Node* errorPosition, LOG3("Unifying blocks " << dest << " with " << src); if (typeid(*dest) != typeid(*src)) { if (reportErrors) - ::error("%1%: Cannot unify %2% to %3%", + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: Cannot unify %2% to %3%", errorPosition, src->toString(), dest->toString()); return false; } @@ -218,7 +230,8 @@ bool TypeUnification::unifyBlocks(const IR::Node* errorPosition, auto srcPackage = src->to(); if (destPackage->name != srcPackage->name) { if (reportErrors) - ::error("%1%: Cannot unify %2% to %3%", + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: Cannot unify %2% to %3%", errorPosition, src->toString(), dest->toString()); return false; } @@ -234,7 +247,8 @@ bool TypeUnification::unifyBlocks(const IR::Node* errorPosition, bool success = unifyFunctions(errorPosition, destapply, srcapply, reportErrors); return success; } - ::error("%1%: Cannot unify %2% to %3%", + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: Cannot unify %2% to %3%", errorPosition, src->toString(), dest->toString()); return false; } @@ -266,7 +280,8 @@ bool TypeUnification::unify(const IR::Node* errorPosition, if (dest->is()) { if (!src->is()) { if (reportErrors) - ::error("%1%: Cannot unify %2% to %3%", + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: Cannot unify %2% to %3%", errorPosition, dest->toString(), src->toString()); return false; } @@ -282,7 +297,8 @@ bool TypeUnification::unify(const IR::Node* errorPosition, return unifyFunctions(errorPosition, destt, srcf, reportErrors); if (reportErrors) - ::error("%1%: Cannot unify non-function type %2% to function type %3%", + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: Cannot unify non-function type %2% to function type %3%", errorPosition, src->toString(), dest->toString()); return false; } else if (dest->is()) { @@ -292,14 +308,16 @@ bool TypeUnification::unify(const IR::Node* errorPosition, } if (!src->is()) { if (reportErrors) - ::error("%1%: Cannot unify tuple type %2% with non tuple-type %3%", + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: Cannot unify tuple type %2% with non tuple-type %3%", errorPosition, dest->toString(), src->toString()); return false; } auto td = dest->to(); auto ts = src->to(); if (td->components.size() != ts->components.size()) { - ::error("%1%: Cannot match tuples with different sizes %2% vs %3%", + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: Cannot match tuples with different sizes %2% vs %3%", errorPosition, td->components.size(), ts->components.size()); return false; } @@ -317,7 +335,8 @@ bool TypeUnification::unify(const IR::Node* errorPosition, if (auto tpl = src->to()) { if (strct->fields.size() != tpl->components.size()) { if (reportErrors) - ::error("%1%: Number of fields %2% in initializer different " + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: Number of fields %2% in initializer different " "than number of fields in structure %3%: %4% to %5%", errorPosition, tpl->components.size(), strct->fields.size(), tpl, strct); @@ -340,7 +359,8 @@ bool TypeUnification::unify(const IR::Node* errorPosition, // corresponding field of the destination, e.g., a struct containing tuples. if (strct->fields.size() != st->fields.size()) { if (reportErrors) - ::error("%1%: Number of fields %2% in initializer different " + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: Number of fields %2% in initializer different " "than number of fields in structure %3%: %4% to %5%", errorPosition, st->fields.size(), strct->fields.size(), st, strct); @@ -350,7 +370,8 @@ bool TypeUnification::unify(const IR::Node* errorPosition, for (const IR::StructField* f : strct->fields) { auto stField = st->getField(f->name); if (stField == nullptr) { - ::error("%1%: No initializer for field %2%", errorPosition, f); + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: No initializer for field %2%", errorPosition, f); return false; } bool success = unify(errorPosition, f->type, stField->type, reportErrors); @@ -361,7 +382,8 @@ bool TypeUnification::unify(const IR::Node* errorPosition, } if (reportErrors) - ::error("%1%: Cannot unify %2% to %3%", + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: Cannot unify %2% to %3%", errorPosition, src->toString(), dest->toString()); return false; } else if (dest->is()) { @@ -372,7 +394,8 @@ bool TypeUnification::unify(const IR::Node* errorPosition, } if (!src->is()) { if (reportErrors) - ::error("%1%: Cannot unify %2% to %3%", + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: Cannot unify %2% to %3%", errorPosition, src->toString(), dest->toString()); return false; } @@ -380,7 +403,8 @@ bool TypeUnification::unify(const IR::Node* errorPosition, bool success = (*src) == (*dest); if (!success) { if (reportErrors) - ::error("%1%: Cannot unify %2% to %3%", + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: Cannot unify %2% to %3%", errorPosition, src->toString(), dest->toString()); return false; } @@ -390,7 +414,8 @@ bool TypeUnification::unify(const IR::Node* errorPosition, bool canUnify = typeid(dest) == typeid(src) && dest->to()->name == src->to()->name; if (!canUnify && reportErrors) - ::error("%1%: Cannot unify %2% to %3%", + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: Cannot unify %2% to %3%", errorPosition, src->toString(), dest->toString()); return canUnify; } else if (dest->is() && src->is()) { @@ -398,7 +423,8 @@ bool TypeUnification::unify(const IR::Node* errorPosition, auto sstack = src->to(); if (dstack->getSize() != sstack->getSize()) { if (reportErrors) - ::error("%1%: cannot unify stacks with different sized %2% and %3%", + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: cannot unify stacks with different sized %2% and %3%", errorPosition, dstack, sstack); return false; } @@ -407,7 +433,8 @@ bool TypeUnification::unify(const IR::Node* errorPosition, } if (reportErrors) - ::error("%1%: Cannot unify %2% to %3%", errorPosition, src, dest); + ::error(ErrorType::ERR_TYPE_ERROR, + "%1%: Cannot unify %2% to %3%", errorPosition, src, dest); return false; } diff --git a/ir/base.def b/ir/base.def index ef5af68847d..b7c08dc347b 100644 --- a/ir/base.def +++ b/ir/base.def @@ -291,6 +291,13 @@ class Annotations { // already present. Annotations addAnnotationIfNew(cstring name, Expression expr) const { return getSingle(name) ? this : addAnnotation(name, expr); } + 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) const { diff --git a/midend/eliminateSerEnums.cpp b/midend/eliminateSerEnums.cpp index 022550e0fa9..364fd1fe30d 100644 --- a/midend/eliminateSerEnums.cpp +++ b/midend/eliminateSerEnums.cpp @@ -32,6 +32,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; } @@ -39,8 +40,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 b6892db3d57..ad801534d05 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 bdf8d8d07bb..d73f85abf86 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 StructInitializerExpression suitable for diff --git a/p4include/v1model.p4 b/p4include/v1model.p4 index 28139eb1aae..6e4a266cde0 100644 --- a/p4include/v1model.p4 +++ b/p4include/v1model.p4 @@ -391,10 +391,18 @@ The payload is defined as "all bytes of the packet which were not parsed by the */ extern void update_checksum_with_payload(in bool condition, in T data, inout O checksum, HashAlgorithm algo); -extern void resubmit(in T data); -extern void recirculate(in T data); +/// The user metadata fields that are tagged with @field_list(index) will +/// be sent to the parser together with the packet. +/// May be only invoked in Ingress. Egress is not executed. +extern void resubmit(bit<8> index); +/// The user metadata fields that are tagged with @field_list(index) will be +/// sent to the parser together with the packet. +/// May only be invoked in Egress. +extern void recirculate(bit<8> index); extern void clone(in CloneType type, in bit<32> session); -extern void clone3(in CloneType type, in bit<32> session, in T data); +/// The user metadata fields that are tagged with @field_list(index) will be +/// sent to the parser together with a clone of the packet. +extern void clone3(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 801853bdd2d..adf0db3d341 100644 --- a/testdata/p4_14_errors_outputs/issue747.p4-stderr +++ b/testdata/p4_14_errors_outputs/issue747.p4-stderr @@ -1,6 +1,3 @@ -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=legacy] error: local_port: expected a field list action local_recirc(local_port) { ^^^^^^^^^^ diff --git a/testdata/p4_14_samples_outputs/acl1-midend.p4 b/testdata/p4_14_samples_outputs/acl1-midend.p4 index 1038b28e209..3f861dc84fb 100644 --- a/testdata/p4_14_samples_outputs/acl1-midend.p4 +++ b/testdata/p4_14_samples_outputs/acl1-midend.p4 @@ -133,16 +133,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; @@ -205,6 +216,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 2a0a8198df1..3d7c08c6dcc 100644 --- a/testdata/p4_14_samples_outputs/copy_to_cpu-first.p4 +++ b/testdata/p4_14_samples_outputs/copy_to_cpu-first.p4 @@ -1,6 +1,10 @@ #include #include +enum bit<8> FieldLists { + copy_to_cpu_fields = 8w0 +} + struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; @@ -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 }); + clone3(CloneType.I2E, 32w250, (bit<8>)FieldLists.copy_to_cpu_fields); } @name(".copy_to_cpu") table copy_to_cpu { actions = { 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 600acd8a8af..daba7492bdc 100644 --- a/testdata/p4_14_samples_outputs/copy_to_cpu-frontend.p4 +++ b/testdata/p4_14_samples_outputs/copy_to_cpu-frontend.p4 @@ -1,6 +1,10 @@ #include #include +enum bit<8> FieldLists { + copy_to_cpu_fields = 8w0 +} + struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; @@ -79,7 +83,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ @name(".NoAction") action NoAction_1() { } @name(".do_copy_to_cpu") action do_copy_to_cpu() { - clone3>(CloneType.I2E, 32w250, { standard_metadata }); + clone3(CloneType.I2E, 32w250, (bit<8>)FieldLists.copy_to_cpu_fields); } @name(".copy_to_cpu") table copy_to_cpu_0 { actions = { 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 7bddb184028..f5199408b10 100644 --- a/testdata/p4_14_samples_outputs/copy_to_cpu-midend.p4 +++ b/testdata/p4_14_samples_outputs/copy_to_cpu-midend.p4 @@ -75,15 +75,11 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } } -struct tuple_0 { - standard_metadata_t field; -} - control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name(".NoAction") action NoAction_1() { } @name(".do_copy_to_cpu") action do_copy_to_cpu() { - clone3(CloneType.I2E, 32w250, { standard_metadata }); + clone3(CloneType.I2E, 32w250, 8w0); } @name(".copy_to_cpu") table copy_to_cpu_0 { actions = { diff --git a/testdata/p4_14_samples_outputs/copy_to_cpu.p4 b/testdata/p4_14_samples_outputs/copy_to_cpu.p4 index c1bd20a6b5e..4ea009c2305 100644 --- a/testdata/p4_14_samples_outputs/copy_to_cpu.p4 +++ b/testdata/p4_14_samples_outputs/copy_to_cpu.p4 @@ -1,6 +1,10 @@ #include #include +enum bit<8> FieldLists { + copy_to_cpu_fields = 0 +} + struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; @@ -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 }); + clone3(CloneType.I2E, (bit<32>)32w250, (bit<8>)FieldLists.copy_to_cpu_fields); } @name(".copy_to_cpu") table copy_to_cpu { actions = { 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 42e7a5beebb..43ba6fae7b0 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 @@ -1,6 +1,12 @@ #include #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; @@ -12,10 +18,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; } @@ -56,13 +67,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 }); + clone3(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((bit<8>)FieldLists.recirculate_FL); } @name("._nop") action _nop() { } @@ -225,7 +236,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((bit<8>)FieldLists.resubmit_FL); } @name("._nop") action _nop() { } 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 bbf8b110440..1db089c364b 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 @@ -1,6 +1,12 @@ #include #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; @@ -12,10 +18,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; } @@ -56,13 +67,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 }); + clone3(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((bit<8>)FieldLists.recirculate_FL); } @name("._nop") action _nop() { } @@ -254,7 +265,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((bit<8>)FieldLists.resubmit_FL); } @name("._nop") action _nop_5() { } 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 1570dc977fb..87a730032b8 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 @@ -12,10 +12,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; } @@ -30,10 +35,15 @@ 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; } @@ -53,22 +63,18 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout } } -struct tuple_0 { - mymeta_t field; -} - 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, { {meta._mymeta_resubmit_count0,meta._mymeta_recirculate_count1,meta._mymeta_clone_e2e_count2,meta._mymeta_last_ing_instance_type3,meta._mymeta_f14} }); + clone3(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({ {meta._mymeta_resubmit_count0,meta._mymeta_recirculate_count1,meta._mymeta_clone_e2e_count2,meta._mymeta_last_ing_instance_type3,meta._mymeta_f14} }); + recirculate(8w1); } @name("._nop") action _nop() { } @@ -260,7 +266,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({ {meta._mymeta_resubmit_count0,meta._mymeta_recirculate_count1,meta._mymeta_clone_e2e_count2,meta._mymeta_last_ing_instance_type3,meta._mymeta_f14} }); + resubmit(8w2); } @name("._nop") action _nop_5() { } 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 b5d6038cba3..5dd2974200a 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 @@ -1,6 +1,12 @@ #include #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; @@ -12,10 +18,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; } @@ -56,13 +67,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 }); + clone3(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((bit<8>)FieldLists.recirculate_FL); } @name("._nop") action _nop() { } @@ -235,7 +246,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((bit<8>)FieldLists.resubmit_FL); } @name("._nop") action _nop() { } 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 cb03f800886..ebfb9348900 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 @@ -1,6 +1,12 @@ #include #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; @@ -12,10 +18,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; } @@ -56,13 +66,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 }); + clone3(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((bit<8>)FieldLists.recirculate_FL); } @name("._nop") action _nop() { } @@ -238,7 +248,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((bit<8>)FieldLists.resubmit_FL); } @name("._nop") action _nop() { } 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 120818f1d4c..b099d9066c8 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 @@ -1,6 +1,12 @@ #include #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; @@ -12,10 +18,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; } @@ -56,13 +66,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 }); + clone3(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((bit<8>)FieldLists.recirculate_FL); } @name("._nop") action _nop() { } @@ -267,7 +277,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((bit<8>)FieldLists.resubmit_FL); } @name("._nop") action _nop_5() { } 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 07556c8d2e5..f7e0c2af093 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 @@ -12,10 +12,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; } @@ -30,10 +34,14 @@ 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; } @@ -53,23 +61,18 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout } } -struct tuple_0 { - bit<8> field; - bit<8> field_0; -} - 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, { meta._mymeta_clone_e2e_count2, meta._mymeta_f14 }); + clone3(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({ meta._mymeta_recirculate_count1, meta._mymeta_f14 }); + recirculate(8w1); } @name("._nop") action _nop() { } @@ -274,7 +277,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({ meta._mymeta_resubmit_count0, meta._mymeta_f14 }); + resubmit(8w2); } @name("._nop") action _nop_5() { } 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 b9d4214ac71..15a6a6af9fe 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 @@ -1,6 +1,12 @@ #include #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; @@ -12,10 +18,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; } @@ -56,13 +66,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 }); + clone3(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((bit<8>)FieldLists.recirculate_FL); } @name("._nop") action _nop() { } @@ -248,7 +258,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((bit<8>)FieldLists.resubmit_FL); } @name("._nop") action _nop() { } 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 17251b69add..e8e95e3a07b 100644 --- a/testdata/p4_14_samples_outputs/p414-special-ops-first.p4 +++ b/testdata/p4_14_samples_outputs/p414-special-ops-first.p4 @@ -1,6 +1,12 @@ #include #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; @@ -12,10 +18,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; } @@ -56,13 +66,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 }); + clone3(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((bit<8>)FieldLists.recirculate_FL); } @name("._nop") action _nop() { } @@ -225,7 +235,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((bit<8>)FieldLists.resubmit_FL); } @name("._nop") action _nop() { } 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 7c5561af57f..d024c0bf2f2 100644 --- a/testdata/p4_14_samples_outputs/p414-special-ops-frontend.p4 +++ b/testdata/p4_14_samples_outputs/p414-special-ops-frontend.p4 @@ -1,6 +1,12 @@ #include #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; @@ -12,10 +18,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; } @@ -56,13 +66,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 }); + clone3(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((bit<8>)FieldLists.recirculate_FL); } @name("._nop") action _nop() { } @@ -254,7 +264,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((bit<8>)FieldLists.resubmit_FL); } @name("._nop") action _nop_5() { } 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 d0d55727b8c..e682adbdcd9 100644 --- a/testdata/p4_14_samples_outputs/p414-special-ops-midend.p4 +++ b/testdata/p4_14_samples_outputs/p414-special-ops-midend.p4 @@ -12,10 +12,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; } @@ -30,10 +34,14 @@ 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; } @@ -53,23 +61,18 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout } } -struct tuple_0 { - bit<8> field; - bit<8> field_0; -} - 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, { meta._mymeta_clone_e2e_count2, meta._mymeta_f14 }); + clone3(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({ meta._mymeta_recirculate_count1, meta._mymeta_f14 }); + recirculate(8w1); } @name("._nop") action _nop() { } @@ -261,7 +264,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({ meta._mymeta_resubmit_count0, meta._mymeta_f14 }); + resubmit(8w2); } @name("._nop") action _nop_5() { } diff --git a/testdata/p4_14_samples_outputs/p414-special-ops.p4 b/testdata/p4_14_samples_outputs/p414-special-ops.p4 index c01878371a0..034c67f808d 100644 --- a/testdata/p4_14_samples_outputs/p414-special-ops.p4 +++ b/testdata/p4_14_samples_outputs/p414-special-ops.p4 @@ -1,6 +1,12 @@ #include #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; @@ -12,10 +18,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; } @@ -56,13 +66,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 }); + clone3(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((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((bit<8>)FieldLists.resubmit_FL); } @name("._nop") action _nop() { } diff --git a/testdata/p4_14_samples_outputs/packet_redirect-first.p4 b/testdata/p4_14_samples_outputs/packet_redirect-first.p4 index 6636a367850..56a9d1e9010 100644 --- a/testdata/p4_14_samples_outputs/packet_redirect-first.p4 +++ b/testdata/p4_14_samples_outputs/packet_redirect-first.p4 @@ -1,6 +1,10 @@ #include #include +enum bit<8> FieldLists { + redirect_FL = 8w0 +} + struct intrinsic_metadata_t { bit<16> mcast_grp; bit<4> egress_rid; @@ -11,7 +15,9 @@ struct intrinsic_metadata_t { } struct metaA_t { + @field_list(FieldLists.redirect_FL) bit<8> f1; + @field_list(FieldLists.redirect_FL) bit<8> f2; } @@ -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((bit<8>)FieldLists.redirect_FL); } @name("._clone_e2e") action _clone_e2e(bit<32> mirror_id) { - clone3>(CloneType.E2E, mirror_id, { standard_metadata, meta.metaA }); + clone3(CloneType.E2E, mirror_id, (bit<8>)FieldLists.redirect_FL); } @name(".t_egress") table t_egress { actions = { @@ -83,10 +89,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((bit<8>)FieldLists.redirect_FL); } @name("._clone_i2e") action _clone_i2e(bit<32> mirror_id) { - clone3>(CloneType.I2E, mirror_id, { standard_metadata, meta.metaA }); + clone3(CloneType.I2E, mirror_id, (bit<8>)FieldLists.redirect_FL); } @name(".t_ingress_1") table t_ingress_1 { actions = { diff --git a/testdata/p4_14_samples_outputs/packet_redirect-frontend.p4 b/testdata/p4_14_samples_outputs/packet_redirect-frontend.p4 index 9b8c26a88b3..7a4f7d529d9 100644 --- a/testdata/p4_14_samples_outputs/packet_redirect-frontend.p4 +++ b/testdata/p4_14_samples_outputs/packet_redirect-frontend.p4 @@ -1,6 +1,10 @@ #include #include +enum bit<8> FieldLists { + redirect_FL = 8w0 +} + struct intrinsic_metadata_t { bit<16> mcast_grp; bit<4> egress_rid; @@ -11,7 +15,9 @@ struct intrinsic_metadata_t { } struct metaA_t { + @field_list(FieldLists.redirect_FL) bit<8> f1; + @field_list(FieldLists.redirect_FL) bit<8> f2; } @@ -50,10 +56,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((bit<8>)FieldLists.redirect_FL); } @name("._clone_e2e") action _clone_e2e(bit<32> mirror_id) { - clone3>(CloneType.E2E, mirror_id, { standard_metadata, meta.metaA }); + clone3(CloneType.E2E, mirror_id, (bit<8>)FieldLists.redirect_FL); } @name(".t_egress") table t_egress_0 { actions = { @@ -91,10 +97,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((bit<8>)FieldLists.redirect_FL); } @name("._clone_i2e") action _clone_i2e(bit<32> mirror_id) { - clone3>(CloneType.I2E, mirror_id, { standard_metadata, meta.metaA }); + clone3(CloneType.I2E, mirror_id, (bit<8>)FieldLists.redirect_FL); } @name(".t_ingress_1") table t_ingress { actions = { diff --git a/testdata/p4_14_samples_outputs/packet_redirect-midend.p4 b/testdata/p4_14_samples_outputs/packet_redirect-midend.p4 index d688fc95e47..e7ccd7d9e60 100644 --- a/testdata/p4_14_samples_outputs/packet_redirect-midend.p4 +++ b/testdata/p4_14_samples_outputs/packet_redirect-midend.p4 @@ -11,7 +11,9 @@ struct intrinsic_metadata_t { } struct metaA_t { + @field_list(8w0) bit<8> f1; + @field_list(8w0) bit<8> f2; } @@ -26,7 +28,9 @@ 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; @@ -44,21 +48,16 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout } } -struct tuple_0 { - standard_metadata_t field; - metaA_t field_0; -} - control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name(".NoAction") action NoAction_0() { } @name("._nop") action _nop() { } @name("._recirculate") action _recirculate() { - recirculate({ standard_metadata, {meta._metaA_f10,meta._metaA_f21} }); + recirculate(8w0); } @name("._clone_e2e") action _clone_e2e(bit<32> mirror_id) { - clone3(CloneType.E2E, mirror_id, { standard_metadata, {meta._metaA_f10,meta._metaA_f21} }); + clone3(CloneType.E2E, mirror_id, 8w0); } @name(".t_egress") table t_egress_0 { actions = { @@ -96,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_f10,meta._metaA_f21} }); + resubmit(8w0); } @name("._clone_i2e") action _clone_i2e(bit<32> mirror_id) { - clone3(CloneType.I2E, mirror_id, { standard_metadata, {meta._metaA_f10,meta._metaA_f21} }); + clone3(CloneType.I2E, mirror_id, 8w0); } @name(".t_ingress_1") table t_ingress { actions = { diff --git a/testdata/p4_14_samples_outputs/packet_redirect.p4 b/testdata/p4_14_samples_outputs/packet_redirect.p4 index 1f09eaf6ef3..0f218c474ff 100644 --- a/testdata/p4_14_samples_outputs/packet_redirect.p4 +++ b/testdata/p4_14_samples_outputs/packet_redirect.p4 @@ -1,6 +1,10 @@ #include #include +enum bit<8> FieldLists { + redirect_FL = 0 +} + struct intrinsic_metadata_t { bit<16> mcast_grp; bit<4> egress_rid; @@ -11,7 +15,9 @@ struct intrinsic_metadata_t { } struct metaA_t { + @field_list(FieldLists.redirect_FL) bit<8> f1; + @field_list(FieldLists.redirect_FL) bit<8> f2; } @@ -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((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 }); + clone3(CloneType.E2E, (bit<32>)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((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 }); + clone3(CloneType.I2E, (bit<32>)mirror_id, (bit<8>)FieldLists.redirect_FL); } @name(".t_ingress_1") table t_ingress_1 { actions = { diff --git a/testdata/p4_14_samples_outputs/resubmit-first.p4 b/testdata/p4_14_samples_outputs/resubmit-first.p4 index b85090ed67a..e87770933c4 100644 --- a/testdata/p4_14_samples_outputs/resubmit-first.p4 +++ b/testdata/p4_14_samples_outputs/resubmit-first.p4 @@ -1,6 +1,10 @@ #include #include +enum bit<8> FieldLists { + resubmit_FL = 8w0 +} + struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; @@ -9,6 +13,7 @@ struct intrinsic_metadata_t { } struct mymeta_t { + @field_list(FieldLists.resubmit_FL) bit<8> f1; } @@ -51,7 +56,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((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 3cefe0e0985..3121cd2efe8 100644 --- a/testdata/p4_14_samples_outputs/resubmit-frontend.p4 +++ b/testdata/p4_14_samples_outputs/resubmit-frontend.p4 @@ -1,6 +1,10 @@ #include #include +enum bit<8> FieldLists { + resubmit_FL = 8w0 +} + struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; @@ -9,6 +13,7 @@ struct intrinsic_metadata_t { } struct mymeta_t { + @field_list(FieldLists.resubmit_FL) bit<8> f1; } @@ -57,7 +62,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((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 bb860fbe60c..c154893daac 100644 --- a/testdata/p4_14_samples_outputs/resubmit-midend.p4 +++ b/testdata/p4_14_samples_outputs/resubmit-midend.p4 @@ -9,6 +9,7 @@ struct intrinsic_metadata_t { } struct mymeta_t { + @field_list(8w0) bit<8> f1; } @@ -19,6 +20,7 @@ header ethernet_t { } struct metadata { + @field_list(8w0) bit<8> _mymeta_f10; } @@ -42,11 +44,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } } -struct tuple_0 { - standard_metadata_t field; - mymeta_t field_0; -} - control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name(".NoAction") action NoAction_0() { } @@ -61,7 +58,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } @name("._resubmit") action _resubmit() { meta._mymeta_f10 = 8w1; - resubmit({ standard_metadata, {8w1} }); + resubmit(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 beaa0c0cdac..e765d4a7d02 100644 --- a/testdata/p4_14_samples_outputs/resubmit.p4 +++ b/testdata/p4_14_samples_outputs/resubmit.p4 @@ -1,6 +1,10 @@ #include #include +enum bit<8> FieldLists { + resubmit_FL = 0 +} + struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; @@ -9,6 +13,7 @@ struct intrinsic_metadata_t { } struct mymeta_t { + @field_list(FieldLists.resubmit_FL) bit<8> f1; } @@ -51,7 +56,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((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 b4da98e0b09..de587086f5d 100644 --- a/testdata/p4_14_samples_outputs/simple_nat-first.p4 +++ b/testdata/p4_14_samples_outputs/simple_nat-first.p4 @@ -1,6 +1,10 @@ #include #include +enum bit<8> FieldLists { + copy_to_cpu_fields = 8w0 +} + struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; @@ -180,7 +184,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 }); + clone3(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; diff --git a/testdata/p4_14_samples_outputs/simple_nat-frontend.p4 b/testdata/p4_14_samples_outputs/simple_nat-frontend.p4 index 5c6afc2f8c9..b11678d7827 100644 --- a/testdata/p4_14_samples_outputs/simple_nat-frontend.p4 +++ b/testdata/p4_14_samples_outputs/simple_nat-frontend.p4 @@ -1,6 +1,10 @@ #include #include +enum bit<8> FieldLists { + copy_to_cpu_fields = 8w0 +} + struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; @@ -203,7 +207,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 }); + clone3(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; diff --git a/testdata/p4_14_samples_outputs/simple_nat-midend.p4 b/testdata/p4_14_samples_outputs/simple_nat-midend.p4 index c0b99b45ab4..d6c8a2a5fe6 100644 --- a/testdata/p4_14_samples_outputs/simple_nat-midend.p4 +++ b/testdata/p4_14_samples_outputs/simple_nat-midend.p4 @@ -177,10 +177,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } } -struct tuple_0 { - standard_metadata_t field; -} - control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name(".NoAction") action NoAction_8() { } @@ -216,7 +212,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 }); + clone3(CloneType.I2E, 32w250, 8w0); } @name(".nat_miss_ext_to_int") action nat_miss_ext_to_int() { meta._meta_do_forward0 = 1w0; @@ -311,48 +307,48 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct tuple_1 { +struct tuple_0 { + bit<4> field; bit<4> field_0; - bit<4> field_1; - bit<8> field_2; + bit<8> field_1; + bit<16> field_2; bit<16> field_3; - bit<16> field_4; - bit<3> field_5; - bit<13> field_6; + bit<3> field_4; + bit<13> field_5; + bit<8> field_6; bit<8> field_7; - bit<8> field_8; + bit<32> field_8; bit<32> field_9; - bit<32> field_10; } -struct tuple_2 { +struct tuple_1 { + bit<32> field_10; bit<32> field_11; - bit<32> field_12; + bit<8> field_12; bit<8> field_13; - bit<8> field_14; + bit<16> field_14; bit<16> field_15; bit<16> field_16; - bit<16> field_17; + bit<32> field_17; bit<32> field_18; - bit<32> field_19; + bit<4> field_19; bit<4> field_20; - bit<4> field_21; - bit<8> field_22; + bit<8> field_21; + bit<16> field_22; bit<16> field_23; - bit<16> field_24; } control verifyChecksum(inout headers hdr, inout metadata meta) { apply { - verify_checksum>(true, { hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.totalLen, hdr.ipv4.identification, hdr.ipv4.flags, hdr.ipv4.fragOffset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); - verify_checksum_with_payload>(hdr.tcp.isValid(), { hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, 8w0, hdr.ipv4.protocol, meta._meta_tcpLength9, hdr.tcp.srcPort, hdr.tcp.dstPort, hdr.tcp.seqNo, hdr.tcp.ackNo, hdr.tcp.dataOffset, hdr.tcp.res, hdr.tcp.flags, hdr.tcp.window, hdr.tcp.urgentPtr }, hdr.tcp.checksum, HashAlgorithm.csum16); + verify_checksum>(true, { hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.totalLen, hdr.ipv4.identification, hdr.ipv4.flags, hdr.ipv4.fragOffset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); + verify_checksum_with_payload>(hdr.tcp.isValid(), { hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, 8w0, hdr.ipv4.protocol, meta._meta_tcpLength9, hdr.tcp.srcPort, hdr.tcp.dstPort, hdr.tcp.seqNo, hdr.tcp.ackNo, hdr.tcp.dataOffset, hdr.tcp.res, hdr.tcp.flags, hdr.tcp.window, hdr.tcp.urgentPtr }, hdr.tcp.checksum, HashAlgorithm.csum16); } } control computeChecksum(inout headers hdr, inout metadata meta) { apply { - update_checksum>(true, { hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.totalLen, hdr.ipv4.identification, hdr.ipv4.flags, hdr.ipv4.fragOffset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); - update_checksum_with_payload>(hdr.tcp.isValid(), { hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, 8w0, hdr.ipv4.protocol, meta._meta_tcpLength9, hdr.tcp.srcPort, hdr.tcp.dstPort, hdr.tcp.seqNo, hdr.tcp.ackNo, hdr.tcp.dataOffset, hdr.tcp.res, hdr.tcp.flags, hdr.tcp.window, hdr.tcp.urgentPtr }, hdr.tcp.checksum, HashAlgorithm.csum16); + update_checksum>(true, { hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.totalLen, hdr.ipv4.identification, hdr.ipv4.flags, hdr.ipv4.fragOffset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); + update_checksum_with_payload>(hdr.tcp.isValid(), { hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, 8w0, hdr.ipv4.protocol, meta._meta_tcpLength9, hdr.tcp.srcPort, hdr.tcp.dstPort, hdr.tcp.seqNo, hdr.tcp.ackNo, hdr.tcp.dataOffset, hdr.tcp.res, hdr.tcp.flags, hdr.tcp.window, hdr.tcp.urgentPtr }, hdr.tcp.checksum, HashAlgorithm.csum16); } } diff --git a/testdata/p4_14_samples_outputs/simple_nat.p4 b/testdata/p4_14_samples_outputs/simple_nat.p4 index 19ac3e03128..b0c1dc66704 100644 --- a/testdata/p4_14_samples_outputs/simple_nat.p4 +++ b/testdata/p4_14_samples_outputs/simple_nat.p4 @@ -1,6 +1,10 @@ #include #include +enum bit<8> FieldLists { + copy_to_cpu_fields = 0 +} + struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; @@ -178,7 +182,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 }); + clone3(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; 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 133d01fd16e..52044810af0 100644 --- a/testdata/p4_14_samples_outputs/switch_20160512/switch-first.p4 +++ b/testdata/p4_14_samples_outputs/switch_20160512/switch-first.p4 @@ -1,6 +1,15 @@ #include #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; @@ -39,6 +48,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; @@ -55,18 +65,24 @@ 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; @@ -84,6 +100,7 @@ struct int_metadata_t { } struct int_metadata_i2e_t { + @field_list(FieldLists.int_i2e_mirror_info) bit<1> sink; bit<1> source; } @@ -2955,7 +2972,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 }); + clone3(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); @@ -2963,7 +2980,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 }); + clone3(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); @@ -3481,7 +3498,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 }); + clone3(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(); @@ -4265,7 +4282,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 }); + clone3(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; @@ -4278,7 +4295,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 }); + clone3(CloneType.I2E, sflow_i2e_mirror_id, (bit<8>)FieldLists.sflow_cpu_info); } @name(".sflow_ing_take_sample") table sflow_ing_take_sample { actions = { @@ -4491,7 +4508,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 }); + clone3(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; } @@ -4558,7 +4575,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 }); + clone3(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; } @@ -5784,7 +5801,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 }); + clone3(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); @@ -5792,7 +5809,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 }); + clone3(CloneType.I2E, 32w250, (bit<8>)FieldLists.cpu_info); } @name(".drop_packet") action drop_packet() { mark_to_drop(standard_metadata); @@ -5802,7 +5819,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 }); + clone3(CloneType.I2E, session_id, (bit<8>)FieldLists.mirror_info); mark_to_drop(standard_metadata); } @name(".drop_stats") table drop_stats_0 { 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 cf2bb9f1e9c..5608a702d88 100644 --- a/testdata/p4_14_samples_outputs/switch_20160512/switch-frontend.p4 +++ b/testdata/p4_14_samples_outputs/switch_20160512/switch-frontend.p4 @@ -1,6 +1,15 @@ #include #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; @@ -39,6 +48,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; @@ -55,18 +65,24 @@ 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; @@ -84,6 +100,7 @@ struct int_metadata_t { } struct int_metadata_i2e_t { + @field_list(FieldLists.int_i2e_mirror_info) bit<1> sink; bit<1> source; } @@ -3027,16 +3044,16 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } @name(".egress_mirror") action _egress_mirror_0(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 }); + clone3(CloneType.E2E, session_id, (bit<8>)FieldLists.e2e_mirror_info); } @name(".egress_mirror_drop") action _egress_mirror_drop_0(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 }); + clone3(CloneType.E2E, session_id, (bit<8>)FieldLists.e2e_mirror_info); mark_to_drop(standard_metadata); } @name(".egress_redirect_to_cpu") action _egress_redirect_to_cpu_0(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 }); + clone3(CloneType.E2E, 32w250, (bit<8>)FieldLists.cpu_info); mark_to_drop(standard_metadata); } @name(".egress_acl") table _egress_acl { @@ -3616,7 +3633,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 }); + clone3(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(); @@ -4306,7 +4323,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; 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 }); + clone3(CloneType.I2E, sflow_i2e_mirror_id, (bit<8>)FieldLists.sflow_cpu_info); } @name(".sflow_ing_take_sample") table _sflow_ing_take_sample { actions = { @@ -4491,7 +4508,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ @name(".acl_mirror") action _acl_mirror_1(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 }); + clone3(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; } @@ -4566,14 +4583,14 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ @name(".acl_mirror") action _acl_mirror_2(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 }); + clone3(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; } @name(".acl_mirror") action _acl_mirror_4(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 }); + clone3(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; } @@ -5571,16 +5588,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(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 }); + clone3(CloneType.I2E, 32w250, (bit<8>)FieldLists.cpu_info); } @name(".redirect_to_cpu") action _redirect_to_cpu_0(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 }); + clone3(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 }); + clone3(CloneType.I2E, 32w250, (bit<8>)FieldLists.cpu_info); } @name(".drop_packet") action _drop_packet_0() { mark_to_drop(standard_metadata); @@ -5590,7 +5607,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ mark_to_drop(standard_metadata); } @name(".negative_mirror") action _negative_mirror_0(bit<32> session_id) { - clone3, bit<8>>>(CloneType.I2E, session_id, { meta.ingress_metadata.ifindex, meta.ingress_metadata.drop_reason }); + clone3(CloneType.I2E, session_id, (bit<8>)FieldLists.mirror_info); mark_to_drop(standard_metadata); } @name(".drop_stats") table _drop_stats_1 { 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 6a75c842736..4c245a841d4 100644 --- a/testdata/p4_14_samples_outputs/switch_20160512/switch-midend.p4 +++ b/testdata/p4_14_samples_outputs/switch_20160512/switch-midend.p4 @@ -39,6 +39,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; @@ -55,18 +56,24 @@ 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; @@ -84,6 +91,7 @@ struct int_metadata_t { } struct int_metadata_i2e_t { + @field_list(8w3) bit<1> sink; bit<1> source; } @@ -669,6 +677,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; @@ -676,18 +685,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; @@ -695,6 +711,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; @@ -746,6 +763,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; @@ -1315,18 +1333,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> field; - bit<16> field_0; -} - -struct tuple_1 { - bit<16> field_1; - bit<16> field_2; - bit<16> field_3; - bit<9> field_4; -} - control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name(".NoAction") action NoAction_0() { } @@ -3144,16 +3150,16 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } @name(".egress_mirror") action _egress_mirror_0(bit<32> session_id) { meta._i2e_metadata_mirror_session_id36 = (bit<16>)session_id; - clone3(CloneType.E2E, session_id, { meta._i2e_metadata_ingress_tstamp35, (bit<16>)session_id }); + clone3(CloneType.E2E, session_id, 8w2); } @name(".egress_mirror_drop") action _egress_mirror_drop_0(bit<32> session_id) { meta._i2e_metadata_mirror_session_id36 = (bit<16>)session_id; - clone3(CloneType.E2E, session_id, { meta._i2e_metadata_ingress_tstamp35, (bit<16>)session_id }); + clone3(CloneType.E2E, session_id, 8w2); mark_to_drop(standard_metadata); } @name(".egress_redirect_to_cpu") action _egress_redirect_to_cpu_0(bit<16> reason_code) { meta._fabric_metadata_reason_code28 = reason_code; - clone3(CloneType.E2E, 32w250, { meta._ingress_metadata_bd42, meta._ingress_metadata_ifindex38, reason_code, meta._ingress_metadata_ingress_port37 }); + clone3(CloneType.E2E, 32w250, 8w1); mark_to_drop(standard_metadata); } @name(".egress_acl") table _egress_acl { @@ -3248,63 +3254,47 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t bit<16> ifindex; } -struct tuple_2 { - bit<1> field_5; - bit<16> field_6; +struct tuple_0 { + bit<32> field; + bit<32> field_0; + bit<8> field_1; + bit<16> field_2; + bit<16> field_3; } -struct tuple_3 { - tuple_1 field_7; - bit<16> field_8; +struct tuple_1 { + bit<48> field_4; + bit<48> field_5; + bit<32> field_6; + bit<32> field_7; + bit<8> field_8; bit<16> field_9; + bit<16> field_10; } -struct tuple_4 { - bit<32> field_10; - bit<32> field_11; - bit<8> field_12; - bit<16> field_13; - bit<16> field_14; -} - -struct tuple_5 { - bit<48> field_15; - bit<48> field_16; - bit<32> field_17; - bit<32> field_18; - bit<8> field_19; - bit<16> field_20; - bit<16> field_21; -} - -struct tuple_6 { - bit<128> field_22; - bit<128> field_23; - bit<8> field_24; - bit<16> field_25; - bit<16> field_26; -} - -struct tuple_7 { - bit<48> field_27; - bit<48> field_28; - bit<128> field_29; - bit<128> field_30; - bit<8> field_31; - bit<16> field_32; - bit<16> field_33; +struct tuple_2 { + bit<128> field_11; + bit<128> field_12; + bit<8> field_13; + bit<16> field_14; + bit<16> field_15; } -struct tuple_8 { - bit<16> field_34; - bit<48> field_35; - bit<48> field_36; - bit<16> field_37; +struct tuple_3 { + bit<48> field_16; + bit<48> field_17; + bit<128> field_18; + bit<128> field_19; + bit<8> field_20; + bit<16> field_21; + bit<16> field_22; } -struct tuple_9 { - bit<16> field_38; - bit<8> field_39; +struct tuple_4 { + bit<16> field_23; + bit<48> field_24; + bit<48> field_25; + bit<16> field_26; } control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @@ -3792,7 +3782,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, { 1w1, (bit<16>)mirror_id }); + clone3(CloneType.I2E, mirror_id, 8w3); hdr.int_header.setInvalid(); hdr.int_val[0].setInvalid(); hdr.int_val[1].setInvalid(); @@ -4482,7 +4472,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; meta._i2e_metadata_mirror_session_id36 = (bit<16>)sflow_i2e_mirror_id; - clone3(CloneType.I2E, sflow_i2e_mirror_id, { { meta._ingress_metadata_bd42, meta._ingress_metadata_ifindex38, reason_code, meta._ingress_metadata_ingress_port37 }, meta._sflow_metadata_sflow_session_id136, (bit<16>)sflow_i2e_mirror_id }); + clone3(CloneType.I2E, sflow_i2e_mirror_id, 8w5); } @name(".sflow_ing_take_sample") table _sflow_ing_take_sample { actions = { @@ -4667,7 +4657,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ @name(".acl_mirror") action _acl_mirror_1(bit<32> session_id, bit<14> acl_stats_index, bit<16> acl_meter_index) { meta._i2e_metadata_mirror_session_id36 = (bit<16>)session_id; meta._i2e_metadata_ingress_tstamp35 = (bit<32>)standard_metadata.ingress_global_timestamp; - clone3(CloneType.I2E, session_id, { (bit<32>)standard_metadata.ingress_global_timestamp, (bit<16>)session_id }); + clone3(CloneType.I2E, session_id, 8w0); meta._acl_metadata_acl_stats_index11 = acl_stats_index; meta._meter_metadata_meter_index107 = acl_meter_index; } @@ -4742,14 +4732,14 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ @name(".acl_mirror") action _acl_mirror_2(bit<32> session_id, bit<14> acl_stats_index, bit<16> acl_meter_index) { meta._i2e_metadata_mirror_session_id36 = (bit<16>)session_id; meta._i2e_metadata_ingress_tstamp35 = (bit<32>)standard_metadata.ingress_global_timestamp; - clone3(CloneType.I2E, session_id, { (bit<32>)standard_metadata.ingress_global_timestamp, (bit<16>)session_id }); + clone3(CloneType.I2E, session_id, 8w0); meta._acl_metadata_acl_stats_index11 = acl_stats_index; meta._meter_metadata_meter_index107 = acl_meter_index; } @name(".acl_mirror") action _acl_mirror_4(bit<32> session_id, bit<14> acl_stats_index, bit<16> acl_meter_index) { meta._i2e_metadata_mirror_session_id36 = (bit<16>)session_id; meta._i2e_metadata_ingress_tstamp35 = (bit<32>)standard_metadata.ingress_global_timestamp; - clone3(CloneType.I2E, session_id, { (bit<32>)standard_metadata.ingress_global_timestamp, (bit<16>)session_id }); + clone3(CloneType.I2E, session_id, 8w0); meta._acl_metadata_acl_stats_index11 = acl_stats_index; meta._meter_metadata_meter_index107 = acl_meter_index; } @@ -5385,15 +5375,15 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ default_action = NoAction_208(); } @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, { meta._ipv4_metadata_lkp_ipv4_sa56, meta._ipv4_metadata_lkp_ipv4_da57, meta._l3_metadata_lkp_ip_proto82, meta._l3_metadata_lkp_l4_sport85, meta._l3_metadata_lkp_l4_dport86 }, 32w65536); - hash, bit<16>, tuple_5, bit<32>>(meta._hash_metadata_hash233, HashAlgorithm.crc16, 16w0, { meta._l2_metadata_lkp_mac_sa65, meta._l2_metadata_lkp_mac_da66, meta._ipv4_metadata_lkp_ipv4_sa56, meta._ipv4_metadata_lkp_ipv4_da57, meta._l3_metadata_lkp_ip_proto82, meta._l3_metadata_lkp_l4_sport85, meta._l3_metadata_lkp_l4_dport86 }, 32w65536); + hash, bit<16>, tuple_0, bit<32>>(meta._hash_metadata_hash132, HashAlgorithm.crc16, 16w0, { meta._ipv4_metadata_lkp_ipv4_sa56, meta._ipv4_metadata_lkp_ipv4_da57, meta._l3_metadata_lkp_ip_proto82, meta._l3_metadata_lkp_l4_sport85, meta._l3_metadata_lkp_l4_dport86 }, 32w65536); + hash, bit<16>, tuple_1, bit<32>>(meta._hash_metadata_hash233, HashAlgorithm.crc16, 16w0, { meta._l2_metadata_lkp_mac_sa65, meta._l2_metadata_lkp_mac_da66, meta._ipv4_metadata_lkp_ipv4_sa56, meta._ipv4_metadata_lkp_ipv4_da57, meta._l3_metadata_lkp_ip_proto82, meta._l3_metadata_lkp_l4_sport85, 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, { meta._ipv6_metadata_lkp_ipv6_sa60, meta._ipv6_metadata_lkp_ipv6_da61, meta._l3_metadata_lkp_ip_proto82, meta._l3_metadata_lkp_l4_sport85, meta._l3_metadata_lkp_l4_dport86 }, 32w65536); - hash, bit<16>, tuple_7, bit<32>>(meta._hash_metadata_hash233, HashAlgorithm.crc16, 16w0, { meta._l2_metadata_lkp_mac_sa65, meta._l2_metadata_lkp_mac_da66, meta._ipv6_metadata_lkp_ipv6_sa60, meta._ipv6_metadata_lkp_ipv6_da61, meta._l3_metadata_lkp_ip_proto82, meta._l3_metadata_lkp_l4_sport85, meta._l3_metadata_lkp_l4_dport86 }, 32w65536); + hash, bit<16>, tuple_2, bit<32>>(meta._hash_metadata_hash132, HashAlgorithm.crc16, 16w0, { meta._ipv6_metadata_lkp_ipv6_sa60, meta._ipv6_metadata_lkp_ipv6_da61, meta._l3_metadata_lkp_ip_proto82, meta._l3_metadata_lkp_l4_sport85, meta._l3_metadata_lkp_l4_dport86 }, 32w65536); + hash, bit<16>, tuple_3, bit<32>>(meta._hash_metadata_hash233, HashAlgorithm.crc16, 16w0, { meta._l2_metadata_lkp_mac_sa65, meta._l2_metadata_lkp_mac_da66, meta._ipv6_metadata_lkp_ipv6_sa60, meta._ipv6_metadata_lkp_ipv6_da61, meta._l3_metadata_lkp_ip_proto82, meta._l3_metadata_lkp_l4_sport85, 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, { meta._ingress_metadata_ifindex38, meta._l2_metadata_lkp_mac_sa65, meta._l2_metadata_lkp_mac_da66, meta._l2_metadata_lkp_mac_type68 }, 32w65536); + hash, bit<16>, tuple_4, bit<32>>(meta._hash_metadata_hash233, HashAlgorithm.crc16, 16w0, { meta._ingress_metadata_ifindex38, meta._l2_metadata_lkp_mac_sa65, meta._l2_metadata_lkp_mac_da66, 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; @@ -5747,16 +5737,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(bit<16> reason_code) { meta._fabric_metadata_reason_code28 = reason_code; - clone3(CloneType.I2E, 32w250, { meta._ingress_metadata_bd42, meta._ingress_metadata_ifindex38, reason_code, meta._ingress_metadata_ingress_port37 }); + clone3(CloneType.I2E, 32w250, 8w1); } @name(".redirect_to_cpu") action _redirect_to_cpu_0(bit<16> reason_code) { meta._fabric_metadata_reason_code28 = reason_code; - clone3(CloneType.I2E, 32w250, { meta._ingress_metadata_bd42, meta._ingress_metadata_ifindex38, reason_code, meta._ingress_metadata_ingress_port37 }); + clone3(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, { meta._ingress_metadata_bd42, meta._ingress_metadata_ifindex38, meta._fabric_metadata_reason_code28, meta._ingress_metadata_ingress_port37 }); + clone3(CloneType.I2E, 32w250, 8w1); } @name(".drop_packet") action _drop_packet_0() { mark_to_drop(standard_metadata); @@ -5766,7 +5756,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ mark_to_drop(standard_metadata); } @name(".negative_mirror") action _negative_mirror_0(bit<32> session_id) { - clone3(CloneType.I2E, session_id, { meta._ingress_metadata_ifindex38, meta._ingress_metadata_drop_reason44 }); + clone3(CloneType.I2E, session_id, 8w4); mark_to_drop(standard_metadata); } @name(".drop_stats") table _drop_stats_1 { @@ -6128,31 +6118,31 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct tuple_10 { - bit<4> field_40; - bit<4> field_41; - bit<8> field_42; - bit<16> field_43; - bit<16> field_44; - bit<3> field_45; - bit<13> field_46; - bit<8> field_47; - bit<8> field_48; - bit<32> field_49; - bit<32> field_50; +struct tuple_5 { + bit<4> field_27; + bit<4> field_28; + bit<8> field_29; + bit<16> field_30; + bit<16> field_31; + bit<3> field_32; + bit<13> field_33; + bit<8> field_34; + bit<8> field_35; + bit<32> field_36; + bit<32> field_37; } control verifyChecksum(inout headers hdr, inout metadata meta) { apply { - verify_checksum>(hdr.inner_ipv4.ihl == 4w5, { hdr.inner_ipv4.version, hdr.inner_ipv4.ihl, hdr.inner_ipv4.diffserv, hdr.inner_ipv4.totalLen, hdr.inner_ipv4.identification, hdr.inner_ipv4.flags, hdr.inner_ipv4.fragOffset, hdr.inner_ipv4.ttl, hdr.inner_ipv4.protocol, hdr.inner_ipv4.srcAddr, hdr.inner_ipv4.dstAddr }, hdr.inner_ipv4.hdrChecksum, HashAlgorithm.csum16); - verify_checksum>(hdr.ipv4.ihl == 4w5, { hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.totalLen, hdr.ipv4.identification, hdr.ipv4.flags, hdr.ipv4.fragOffset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); + verify_checksum>(hdr.inner_ipv4.ihl == 4w5, { hdr.inner_ipv4.version, hdr.inner_ipv4.ihl, hdr.inner_ipv4.diffserv, hdr.inner_ipv4.totalLen, hdr.inner_ipv4.identification, hdr.inner_ipv4.flags, hdr.inner_ipv4.fragOffset, hdr.inner_ipv4.ttl, hdr.inner_ipv4.protocol, hdr.inner_ipv4.srcAddr, hdr.inner_ipv4.dstAddr }, hdr.inner_ipv4.hdrChecksum, HashAlgorithm.csum16); + verify_checksum>(hdr.ipv4.ihl == 4w5, { hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.totalLen, hdr.ipv4.identification, hdr.ipv4.flags, hdr.ipv4.fragOffset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); } } control computeChecksum(inout headers hdr, inout metadata meta) { apply { - update_checksum>(hdr.inner_ipv4.ihl == 4w5, { hdr.inner_ipv4.version, hdr.inner_ipv4.ihl, hdr.inner_ipv4.diffserv, hdr.inner_ipv4.totalLen, hdr.inner_ipv4.identification, hdr.inner_ipv4.flags, hdr.inner_ipv4.fragOffset, hdr.inner_ipv4.ttl, hdr.inner_ipv4.protocol, hdr.inner_ipv4.srcAddr, hdr.inner_ipv4.dstAddr }, hdr.inner_ipv4.hdrChecksum, HashAlgorithm.csum16); - update_checksum>(hdr.ipv4.ihl == 4w5, { hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.totalLen, hdr.ipv4.identification, hdr.ipv4.flags, hdr.ipv4.fragOffset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); + update_checksum>(hdr.inner_ipv4.ihl == 4w5, { hdr.inner_ipv4.version, hdr.inner_ipv4.ihl, hdr.inner_ipv4.diffserv, hdr.inner_ipv4.totalLen, hdr.inner_ipv4.identification, hdr.inner_ipv4.flags, hdr.inner_ipv4.fragOffset, hdr.inner_ipv4.ttl, hdr.inner_ipv4.protocol, hdr.inner_ipv4.srcAddr, hdr.inner_ipv4.dstAddr }, hdr.inner_ipv4.hdrChecksum, HashAlgorithm.csum16); + update_checksum>(hdr.ipv4.ihl == 4w5, { hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.totalLen, hdr.ipv4.identification, hdr.ipv4.flags, hdr.ipv4.fragOffset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); } } diff --git a/testdata/p4_14_samples_outputs/switch_20160512/switch.p4 b/testdata/p4_14_samples_outputs/switch_20160512/switch.p4 index cf45ebb16b8..e8bd90a9295 100644 --- a/testdata/p4_14_samples_outputs/switch_20160512/switch.p4 +++ b/testdata/p4_14_samples_outputs/switch_20160512/switch.p4 @@ -1,6 +1,15 @@ #include #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; @@ -39,6 +48,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; @@ -55,18 +65,24 @@ 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; @@ -84,6 +100,7 @@ struct int_metadata_t { } struct int_metadata_i2e_t { + @field_list(FieldLists.int_i2e_mirror_info) bit<1> sink; bit<1> source; } @@ -2910,7 +2927,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 }); + clone3(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); @@ -2918,7 +2935,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 }); + clone3(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); @@ -3420,7 +3437,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 }); + clone3(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(); @@ -4180,7 +4197,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 }); + clone3(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; @@ -4193,7 +4210,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 }); + clone3(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 = { @@ -4398,7 +4415,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 }); + clone3(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; } @@ -4464,7 +4481,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 }); + clone3(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; } @@ -5638,7 +5655,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 }); + clone3(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); @@ -5646,7 +5663,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 }); + clone3(CloneType.I2E, (bit<32>)32w250, (bit<8>)FieldLists.cpu_info); } @name(".drop_packet") action drop_packet() { mark_to_drop(standard_metadata); @@ -5656,7 +5673,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 }); + clone3(CloneType.I2E, (bit<32>)session_id, (bit<8>)FieldLists.mirror_info); mark_to_drop(standard_metadata); } @name(".drop_stats") table drop_stats_0 { diff --git a/testdata/p4_16_errors_outputs/constructor3_e.p4-stderr b/testdata/p4_16_errors_outputs/constructor3_e.p4-stderr index f762335c741..fd16b040660 100644 --- a/testdata/p4_16_errors_outputs/constructor3_e.p4-stderr +++ b/testdata/p4_16_errors_outputs/constructor3_e.p4-stderr @@ -1,3 +1,3 @@ -constructor3_e.p4(22): [--Werror=legacy] error: e: Cannot unify bool to bit<1> +constructor3_e.p4(22): [--Werror=type-error] error: e: Cannot unify bool to bit<1> E(true) e; ^ diff --git a/testdata/p4_16_errors_outputs/factory-err2.p4-stderr b/testdata/p4_16_errors_outputs/factory-err2.p4-stderr index fb989b560e0..41177c520a4 100644 --- a/testdata/p4_16_errors_outputs/factory-err2.p4-stderr +++ b/testdata/p4_16_errors_outputs/factory-err2.p4-stderr @@ -1,4 +1,4 @@ -factory-err2.p4(31): error: : not a compile-time constant when binding to a +factory-err2.p4(31): [--Werror=type-error] error: ArgumentInfo: not a compile-time constant when binding to a c1>(createWidget(hdr.f1, hdr.f2)) c; // factory args must be constants ^^^^^^ factory-err2.p4(20) diff --git a/testdata/p4_16_errors_outputs/function1_e.p4-stderr b/testdata/p4_16_errors_outputs/function1_e.p4-stderr index e42cdb567e1..18105ec87c8 100644 --- a/testdata/p4_16_errors_outputs/function1_e.p4-stderr +++ b/testdata/p4_16_errors_outputs/function1_e.p4-stderr @@ -1,4 +1,4 @@ -function1_e.p4(21): error: : Read-only value used for out/inout parameter x +function1_e.p4(21): [--Werror=type-error] error: ArgumentInfo: Read-only value used for out/inout parameter x f(1w1 & 1w0); // non lvalue passed to out parameter ^^^^^^^^^ function1_e.p4(16) diff --git a/testdata/p4_16_errors_outputs/function_e.p4-stderr b/testdata/p4_16_errors_outputs/function_e.p4-stderr index d818142b12c..44149d77251 100644 --- a/testdata/p4_16_errors_outputs/function_e.p4-stderr +++ b/testdata/p4_16_errors_outputs/function_e.p4-stderr @@ -1,15 +1,15 @@ -function_e.p4(22): [--Werror=legacy] error: f: No argument for parameter x +function_e.p4(22): [--Werror=type-error] error: f: No argument for parameter x f(); // not enough arguments ^^^ function_e.p4(16) extern void f(in bit x); ^ -function_e.p4(23): [--Werror=legacy] error: f: Passing 2 arguments when 1 expected +function_e.p4(23): [--Werror=type-error] error: f: Passing 2 arguments when 1 expected f(1w1, 1w0); // too many arguments ^^^^^^^^^^^ -function_e.p4(24): [--Werror=legacy] error: f has 0 type parameters, but is invoked with 1 type arguments +function_e.p4(24): [--Werror=type-error] error: f has 0 type parameters, but is invoked with 1 type arguments f(1w0); // too many type arguments ^^^^^^^^^^^ -function_e.p4(25): [--Werror=legacy] error: g has 1 type parameters, but is invoked with 2 type arguments +function_e.p4(25): [--Werror=type-error] error: g has 1 type parameters, but is invoked with 2 type arguments g(); // too many type arguments ^^^^^^^^^^^^^ diff --git a/testdata/p4_16_errors_outputs/implicit.p4-stderr b/testdata/p4_16_errors_outputs/implicit.p4-stderr index 06c6aa894d1..d2b4d2c3148 100644 --- a/testdata/p4_16_errors_outputs/implicit.p4-stderr +++ b/testdata/p4_16_errors_outputs/implicit.p4-stderr @@ -1,3 +1,3 @@ -implicit.p4(19): [--Werror=legacy] error: b: Cannot unify int<32> to bit<32> +implicit.p4(19): [--Werror=type-error] error: b: Cannot unify int<32> to bit<32> bit<32> b = 32s1; ^^^^^^^^^^^^^^^^^ diff --git a/testdata/p4_16_errors_outputs/issue1006-1.p4-stderr b/testdata/p4_16_errors_outputs/issue1006-1.p4-stderr index e956cdc615c..4ebf657551d 100644 --- a/testdata/p4_16_errors_outputs/issue1006-1.p4-stderr +++ b/testdata/p4_16_errors_outputs/issue1006-1.p4-stderr @@ -1,3 +1,3 @@ -issue1006-1.p4(14): [--Werror=legacy] error: reg2: Cannot unify bit<16> to bit<8> +issue1006-1.p4(14): [--Werror=type-error] error: reg2: Cannot unify bit<16> to bit<8> R>(16w1) reg2; ^^^^ diff --git a/testdata/p4_16_errors_outputs/issue401.p4-stderr b/testdata/p4_16_errors_outputs/issue401.p4-stderr index cd3994d699c..8e386820c29 100644 --- a/testdata/p4_16_errors_outputs/issue401.p4-stderr +++ b/testdata/p4_16_errors_outputs/issue401.p4-stderr @@ -1,4 +1,4 @@ -issue401.p4(42): [--Werror=legacy] error: cast: Cannot unify Tuple(1) to bit<1> +issue401.p4(42): [--Werror=type-error] error: cast: Cannot unify Tuple(1) to bit<1> bit<1> b = (bit<1>) { 0 }; ^^^^^^^^^^^^^^ issue401.p4(42): [--Werror=type-error] error: cast: Illegal cast from Tuple(1) to bit<1> diff --git a/testdata/p4_16_errors_outputs/issue561-1.p4-stderr b/testdata/p4_16_errors_outputs/issue561-1.p4-stderr index e7cd876b9ee..578516f8f1e 100644 --- a/testdata/p4_16_errors_outputs/issue561-1.p4-stderr +++ b/testdata/p4_16_errors_outputs/issue561-1.p4-stderr @@ -1,4 +1,4 @@ -issue561-1.p4(29): [--Werror=legacy] error: u: Cannot unify Tuple(2) to header_union U +issue561-1.p4(29): [--Werror=type-error] error: u: Cannot unify Tuple(2) to header_union U U u = { { 10 }, { 20 } }; // illegal to initialize unions ^^^^^^^^^^^^^^^^^^^^^^^^^ issue561-1.p4(29) diff --git a/testdata/p4_16_errors_outputs/issue774-1.p4-stderr b/testdata/p4_16_errors_outputs/issue774-1.p4-stderr index ee6f38a2ab9..9c5332099eb 100644 --- a/testdata/p4_16_errors_outputs/issue774-1.p4-stderr +++ b/testdata/p4_16_errors_outputs/issue774-1.p4-stderr @@ -1,3 +1,3 @@ -issue774-1.p4(7): error: : don't care argument only allowed for out parameters +issue774-1.p4(7): [--Werror=type-error] error: : don't care argument only allowed for out parameters f(_); ^ diff --git a/testdata/p4_16_errors_outputs/issue803-1.p4-stderr b/testdata/p4_16_errors_outputs/issue803-1.p4-stderr index 8d92a95effc..87f62733fe4 100644 --- a/testdata/p4_16_errors_outputs/issue803-1.p4-stderr +++ b/testdata/p4_16_errors_outputs/issue803-1.p4-stderr @@ -1,3 +1,3 @@ -issue803-1.p4(14): [--Werror=legacy] error: ig1: Passing 1 arguments when 0 expected +issue803-1.p4(14): [--Werror=type-error] error: ig1: Passing 1 arguments when 0 expected Ingress(ing_parse()) ig1; ^^^ diff --git a/testdata/p4_16_errors_outputs/module_e.p4-stderr b/testdata/p4_16_errors_outputs/module_e.p4-stderr index 0e5b727aae5..9954d985c16 100644 --- a/testdata/p4_16_errors_outputs/module_e.p4-stderr +++ b/testdata/p4_16_errors_outputs/module_e.p4-stderr @@ -1,4 +1,4 @@ -module_e.p4(25): [--Werror=legacy] error: main: Cannot unify parameter x with filter because they have different directions +module_e.p4(25): [--Werror=type-error] error: main: Cannot unify parameter x with filter because they have different directions top(g()) main; ^^^^ module_e.p4(20) diff --git a/testdata/p4_16_errors_outputs/mux_e.p4-stderr b/testdata/p4_16_errors_outputs/mux_e.p4-stderr index caf755fd375..3b42e2d3dea 100644 --- a/testdata/p4_16_errors_outputs/mux_e.p4-stderr +++ b/testdata/p4_16_errors_outputs/mux_e.p4-stderr @@ -1,4 +1,4 @@ [--Werror=type-error] error: Selector of ?: must be bool, not bit<1> -mux_e.p4(25): [--Werror=legacy] error: ?:: Cannot unify bool to bit<1> +mux_e.p4(25): [--Werror=type-error] error: ?:: Cannot unify bool to bit<1> d = d ? a : d; // wrong types a <-> d ^^^^^^^^^ diff --git a/testdata/p4_16_errors_outputs/named-fail1.p4-stderr b/testdata/p4_16_errors_outputs/named-fail1.p4-stderr index ff95461852b..652cd80b9f2 100644 --- a/testdata/p4_16_errors_outputs/named-fail1.p4-stderr +++ b/testdata/p4_16_errors_outputs/named-fail1.p4-stderr @@ -1,4 +1,4 @@ -named-fail1.p4(8): [--Werror=legacy] error: f: No parameter named z +named-fail1.p4(8): [--Werror=type-error] error: f: No parameter named z f(z = b, y = b); // No such parameter ^^^^^^^^^^^^^^^ named-fail1.p4(8) diff --git a/testdata/p4_16_errors_outputs/newtype-err.p4-stderr b/testdata/p4_16_errors_outputs/newtype-err.p4-stderr index 6d811835e69..41ef56dae9a 100644 --- a/testdata/p4_16_errors_outputs/newtype-err.p4-stderr +++ b/testdata/p4_16_errors_outputs/newtype-err.p4-stderr @@ -1,4 +1,4 @@ -newtype-err.p4(10): [--Werror=legacy] error: AssignmentStatement: Cannot unify bit<32> to N32 +newtype-err.p4(10): [--Werror=type-error] error: AssignmentStatement: Cannot unify bit<32> to N32 n = b + b; ^ newtype-err.p4(2) @@ -7,6 +7,6 @@ type bit<32> N32; newtype-err.p4(11): [--Werror=type-error] error: +: cannot be applied to n of type N32 n1 = n + 0; ^ -newtype-err.p4(12): [--Werror=legacy] error: AssignmentStatement: Cannot unify N32 to bit<32> +newtype-err.p4(12): [--Werror=type-error] error: AssignmentStatement: Cannot unify N32 to bit<32> x = n; ^ diff --git a/testdata/p4_16_errors_outputs/psa-meter2.p4-stderr b/testdata/p4_16_errors_outputs/psa-meter2.p4-stderr index 215d75f18ce..319085b7068 100644 --- a/testdata/p4_16_errors_outputs/psa-meter2.p4-stderr +++ b/testdata/p4_16_errors_outputs/psa-meter2.p4-stderr @@ -1,4 +1,4 @@ -psa-meter2.p4(53): [--Werror=legacy] error: cast: Cannot unify PSA_MeterColor_t to bit<16> +psa-meter2.p4(53): [--Werror=type-error] error: cast: Cannot unify PSA_MeterColor_t to bit<16> b.data = (bit<16>)meter0.execute(index, PSA_MeterColor_t.GREEN); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ psa-meter2.p4(53): [--Werror=type-error] error: cast: Illegal cast from PSA_MeterColor_t to bit<16> diff --git a/testdata/p4_16_errors_outputs/signs.p4-stderr b/testdata/p4_16_errors_outputs/signs.p4-stderr index 8f186d06924..eb848bfb486 100644 --- a/testdata/p4_16_errors_outputs/signs.p4-stderr +++ b/testdata/p4_16_errors_outputs/signs.p4-stderr @@ -4,7 +4,7 @@ signs.p4(17): [--Wwarn=shadow] warning: a shadows a signs.p4(16) action a() { ^ -signs.p4(18): [--Werror=legacy] error: b: Cannot unify bit<8> to int<8> +signs.p4(18): [--Werror=type-error] error: b: Cannot unify bit<8> to int<8> int<8> b = 8w0; ^^^^^^^^^^^^^^^ signs.p4(19): [--Werror=type-error] error: -: Cannot operate on values with different signs diff --git a/testdata/p4_16_errors_outputs/stack2.p4-stderr b/testdata/p4_16_errors_outputs/stack2.p4-stderr index 4ef21b68fcc..4d463652265 100644 --- a/testdata/p4_16_errors_outputs/stack2.p4-stderr +++ b/testdata/p4_16_errors_outputs/stack2.p4-stderr @@ -1,4 +1,4 @@ -stack2.p4(24): [--Werror=legacy] error: AssignmentStatement: cannot unify stacks with different sized header h[] and header h[] +stack2.p4(24): [--Werror=type-error] error: AssignmentStatement: cannot unify stacks with different sized header h[] and header h[] stack1 = stack2; // assignment between different stacks ^ stack2.p4(21) diff --git a/testdata/p4_16_errors_outputs/table-entries-exact.p4-stderr b/testdata/p4_16_errors_outputs/table-entries-exact.p4-stderr index 1e1587f7b7e..ab1298327c5 100644 --- a/testdata/p4_16_errors_outputs/table-entries-exact.p4-stderr +++ b/testdata/p4_16_errors_outputs/table-entries-exact.p4-stderr @@ -1,3 +1,3 @@ -table-entries-exact.p4(72): [--Werror=legacy] error: Entry: Cannot match tuples with different sizes 1 vs 2 +table-entries-exact.p4(72): [--Werror=type-error] error: Entry: Cannot match tuples with different sizes 1 vs 2 (0x1111 &&& 0xF, 0x1 ) : a(); // invalid exact key ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/testdata/p4_16_errors_outputs/table-entries-lpm.p4-stderr b/testdata/p4_16_errors_outputs/table-entries-lpm.p4-stderr index ae85091aad7..003c7a54a30 100644 --- a/testdata/p4_16_errors_outputs/table-entries-lpm.p4-stderr +++ b/testdata/p4_16_errors_outputs/table-entries-lpm.p4-stderr @@ -1,3 +1,3 @@ -table-entries-lpm.p4(72): [--Werror=legacy] error: Entry: Cannot match tuples with different sizes 1 vs 2 +table-entries-lpm.p4(72): [--Werror=type-error] error: Entry: Cannot match tuples with different sizes 1 vs 2 (0x1, 0x11 &&& 0xF0): a(); // invalid keyset ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/testdata/p4_16_errors_outputs/table-entries-range.p4-stderr b/testdata/p4_16_errors_outputs/table-entries-range.p4-stderr index 3263c67d827..b1ec080fa60 100644 --- a/testdata/p4_16_errors_outputs/table-entries-range.p4-stderr +++ b/testdata/p4_16_errors_outputs/table-entries-range.p4-stderr @@ -1,3 +1,3 @@ -table-entries-range.p4(71): [--Werror=legacy] error: Entry: Cannot match tuples with different sizes 1 vs 2 +table-entries-range.p4(71): [--Werror=type-error] error: Entry: Cannot match tuples with different sizes 1 vs 2 (0x18, 0xF) : a_with_control_params(24); // not a range ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/testdata/p4_16_errors_outputs/typecheck_e.p4-stderr b/testdata/p4_16_errors_outputs/typecheck_e.p4-stderr index efa0e65a1e6..1596ed17c98 100644 --- a/testdata/p4_16_errors_outputs/typecheck_e.p4-stderr +++ b/testdata/p4_16_errors_outputs/typecheck_e.p4-stderr @@ -1,3 +1,3 @@ -typecheck_e.p4(21): [--Werror=legacy] error: f: Cannot unify T to int<32> +typecheck_e.p4(21): [--Werror=type-error] error: f: Cannot unify T to int<32> f(x); ^^^^ diff --git a/testdata/p4_16_errors_outputs/virtual1.p4-stderr b/testdata/p4_16_errors_outputs/virtual1.p4-stderr index ac949ea4ca1..524d6354256 100644 --- a/testdata/p4_16_errors_outputs/virtual1.p4-stderr +++ b/testdata/p4_16_errors_outputs/virtual1.p4-stderr @@ -1,6 +1,6 @@ -virtual1.p4(23): [--Werror=legacy] error: return +: Cannot unify bit<16> to bool +virtual1.p4(23): [--Werror=type-error] error: return +: Cannot unify bit<16> to bool return (ix + 1); ^^^^^^ -virtual1.p4(21): [--Werror=legacy] error: cntr: Cannot unify bool to bit<16> +virtual1.p4(21): [--Werror=type-error] error: cntr: Cannot unify bool to bit<16> Virtual() cntr = { ^^^^ diff --git a/testdata/p4_16_errors_outputs/virtual2.p4-stderr b/testdata/p4_16_errors_outputs/virtual2.p4-stderr index 5f406a711a1..e0ea1e02543 100644 --- a/testdata/p4_16_errors_outputs/virtual2.p4-stderr +++ b/testdata/p4_16_errors_outputs/virtual2.p4-stderr @@ -1,6 +1,6 @@ virtual2.p4(23): [--Werror=type-error] error: return +: return expression in function with void return return (ix + 1); ^^^^^^ -virtual2.p4(21): [--Werror=legacy] error: cntr: Cannot unify void to bit<16> +virtual2.p4(21): [--Werror=type-error] error: cntr: Cannot unify void to bit<16> Virtual() cntr = { ^^^^ diff --git a/testdata/p4_16_samples/issue1001-bmv2.p4 b/testdata/p4_16_samples/issue1001-bmv2.p4 index 196eb962daa..930fd5cc743 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); + clone3(CloneType.I2E, 32w64, 0); } } diff --git a/testdata/p4_16_samples/issue1043-bmv2.p4 b/testdata/p4_16_samples/issue1043-bmv2.p4 index ec45fb242a2..2bcf76bd4fb 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(0); sm.egress_spec = 0; } } diff --git a/testdata/p4_16_samples/issue1642-bmv2.p4 b/testdata/p4_16_samples/issue1642-bmv2.p4 index 43907d1872a..7af3fce0c27 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); + clone3(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 verify_checksum(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(), verify_checksum(), ingress(), egress(), diff --git a/testdata/p4_16_samples/issue1653-bmv2.p4 b/testdata/p4_16_samples/issue1653-bmv2.p4 index edf65b05411..747e54d03c6 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); + clone3(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 fcdfaa56710..c5d79272c14 100644 --- a/testdata/p4_16_samples/issue1653-complex-bmv2.p4 +++ b/testdata/p4_16_samples/issue1653-complex-bmv2.p4 @@ -31,7 +31,7 @@ struct alt_t { int<8> hashRes; bool useHash; EthTypes type; - bit<7> pad; + bit<7> pad; }; struct row_t { @@ -44,6 +44,7 @@ header bitvec_hdr { } struct local_metadata_t { + @field_list(0) row_t row0; row_t row1; bitvec_hdr bvh0; @@ -52,7 +53,7 @@ struct local_metadata_t { struct parsed_packet_t { bitvec_hdr bvh0; - bitvec_hdr bvh1; + bitvec_hdr bvh1; }; parser parse(packet_in pk, out parsed_packet_t h, @@ -72,9 +73,9 @@ control ingress(inout parsed_packet_t h, action do_act() { h.bvh1.row.alt1.valid = 0; - local_metadata.row0.alt0.valid = 0; + local_metadata.row0.alt0.valid = 0; } - + table tns { key = { h.bvh1.row.alt1.valid : exact; @@ -84,7 +85,7 @@ control ingress(inout parsed_packet_t h, do_act; } } - + apply { tns.apply(); @@ -92,10 +93,10 @@ control ingress(inout parsed_packet_t h, // Copy another header's data to local variable. bh.row.alt0.useHash = h.bvh0.row.alt0.useHash; bh.row.alt1.type = EthTypes.IPv4; - h.bvh0.row.alt1.type = bh.row.alt1.type; + h.bvh0.row.alt1.type = bh.row.alt1.type; local_metadata.row0.alt0.useHash = true; - clone3(CloneType.I2E, 0, local_metadata.row0); + clone3(CloneType.I2E, 0, 0); } } @@ -108,7 +109,7 @@ control egress(inout parsed_packet_t hdr, control deparser(packet_out b, in parsed_packet_t h) { apply { b.emit(h.bvh0); - b.emit(h.bvh1); + b.emit(h.bvh1); } } @@ -124,4 +125,3 @@ control compute_checksum(inout parsed_packet_t hdr, V1Switch(parse(), verify_checksum(), ingress(), egress(), compute_checksum(), deparser()) main; - diff --git a/testdata/p4_16_samples/issue1660-bmv2.p4 b/testdata/p4_16_samples/issue1660-bmv2.p4 index e069e09a459..6de29baa844 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); + clone3(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..3f3e26cf18a 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); + clone3(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); + clone3(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 3e3591370e6..514ccb18c99 100644 --- a/testdata/p4_16_samples/issue383-bmv2.p4 +++ b/testdata/p4_16_samples/issue383-bmv2.p4 @@ -18,43 +18,44 @@ 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 { bitvec_hdr bvh0; - bitvec_hdr bvh1; + bitvec_hdr bvh1; }; 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, @@ -76,9 +77,9 @@ control ingress(inout parsed_packet_t h, action do_act() { h.bvh1.row.alt1.valid = 0; - local_metadata.col.bvh.row.alt0.valid = 0; + local_metadata.col.bvh.row.alt0.valid = 0; } - + table tns { key = { h.bvh1.row.alt1.valid : exact; @@ -88,7 +89,7 @@ control ingress(inout parsed_packet_t h, do_act; } } - + apply { tns.apply(); @@ -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); + clone3(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 2609e27debe..b00cefdf905 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); + clone3(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 80ca6693e38..dea593c68b0 100644 --- a/testdata/p4_16_samples/v1model-special-ops-bmv2.p4 +++ b/testdata/p4_16_samples/v1model-special-ops-bmv2.p4 @@ -233,7 +233,7 @@ control ingress(inout headers_t hdr, // If you give an entire struct, it includes all fields inside // of that struct. - resubmit({}); + resubmit(0); } action do_clone_i2e(bit<32> l2ptr) { // BMv2 simple_switch can have multiple different clone @@ -248,7 +248,7 @@ control ingress(inout headers_t hdr, // resubmit() call above. clone() is the same as clone3(), // 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, {}); + clone3(CloneType.I2E, I2E_CLONE_SESSION_ID, 0); meta.fwd.l2ptr = l2ptr; } table ipv4_da_lpm { @@ -358,13 +358,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(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, {}); + clone3(CloneType.E2E, E2E_CLONE_SESSION_ID, 0); } table send_frame { key = { diff --git a/testdata/p4_16_samples_outputs/issue1001-bmv2-first.p4 b/testdata/p4_16_samples_outputs/issue1001-bmv2-first.p4 index 83f2a0fdfdc..ae9f8c31c28 100644 --- a/testdata/p4_16_samples_outputs/issue1001-bmv2-first.p4 +++ b/testdata/p4_16_samples_outputs/issue1001-bmv2-first.p4 @@ -5,6 +5,7 @@ struct Headers { } struct Meta { + @field_list(0) bit<1> b; } @@ -16,9 +17,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); + clone3(CloneType.I2E, 32w64, 8w0); } } diff --git a/testdata/p4_16_samples_outputs/issue1001-bmv2-frontend.p4 b/testdata/p4_16_samples_outputs/issue1001-bmv2-frontend.p4 index f16b5dddf59..ae9f8c31c28 100644 --- a/testdata/p4_16_samples_outputs/issue1001-bmv2-frontend.p4 +++ b/testdata/p4_16_samples_outputs/issue1001-bmv2-frontend.p4 @@ -5,6 +5,7 @@ struct Headers { } struct Meta { + @field_list(0) bit<1> b; } @@ -16,9 +17,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_0; apply { - clone3(CloneType.I2E, 32w64, x_0); + clone3(CloneType.I2E, 32w64, 8w0); } } diff --git a/testdata/p4_16_samples_outputs/issue1001-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/issue1001-bmv2-midend.p4 index a712cdf8a7e..fd671e45117 100644 --- a/testdata/p4_16_samples_outputs/issue1001-bmv2-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue1001-bmv2-midend.p4 @@ -5,6 +5,7 @@ struct Headers { } struct Meta { + @field_list(0) bit<1> b; } @@ -16,9 +17,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_0; @hidden action act() { - clone3(CloneType.I2E, 32w64, x_0); + clone3(CloneType.I2E, 32w64, 8w0); } @hidden table tbl_act { actions = { diff --git a/testdata/p4_16_samples_outputs/issue1001-bmv2.p4 b/testdata/p4_16_samples_outputs/issue1001-bmv2.p4 index 48ce9746054..b73096e9a39 100644 --- a/testdata/p4_16_samples_outputs/issue1001-bmv2.p4 +++ b/testdata/p4_16_samples_outputs/issue1001-bmv2.p4 @@ -5,6 +5,7 @@ struct Headers { } struct Meta { + @field_list(0) bit<1> b; } @@ -16,9 +17,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); + clone3(CloneType.I2E, 32w64, 0); } } 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 eadb9a7236e..7c0dcb18929 100644 --- a/testdata/p4_16_samples_outputs/issue1043-bmv2-first.p4 +++ b/testdata/p4_16_samples_outputs/issue1043-bmv2-first.p4 @@ -43,7 +43,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(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 eadb9a7236e..7c0dcb18929 100644 --- a/testdata/p4_16_samples_outputs/issue1043-bmv2-frontend.p4 +++ b/testdata/p4_16_samples_outputs/issue1043-bmv2-frontend.p4 @@ -43,7 +43,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(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 7e023408fb6..830bcfa3746 100644 --- a/testdata/p4_16_samples_outputs/issue1043-bmv2-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue1043-bmv2-midend.p4 @@ -43,7 +43,7 @@ control deparser(packet_out b, in Headers h) { control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { @hidden action act() { - resubmit(m); + resubmit(8w0); sm.egress_spec = 9w0; } @hidden table tbl_act { diff --git a/testdata/p4_16_samples_outputs/issue1043-bmv2.p4 b/testdata/p4_16_samples_outputs/issue1043-bmv2.p4 index fccadacb866..b733facb4ad 100644 --- a/testdata/p4_16_samples_outputs/issue1043-bmv2.p4 +++ b/testdata/p4_16_samples_outputs/issue1043-bmv2.p4 @@ -43,7 +43,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(0); sm.egress_spec = 0; } } diff --git a/testdata/p4_16_samples_outputs/issue1642-bmv2-first.p4 b/testdata/p4_16_samples_outputs/issue1642-bmv2-first.p4 index 60390af15fd..4f420a66fb0 100644 --- a/testdata/p4_16_samples_outputs/issue1642-bmv2-first.p4 +++ b/testdata/p4_16_samples_outputs/issue1642-bmv2-first.p4 @@ -20,6 +20,7 @@ struct parsed_packet_t { struct local_metadata_t { short s; + @field_list(0) row_t row; } @@ -36,7 +37,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); + clone3(CloneType.I2E, 32w0, 8w0); } } diff --git a/testdata/p4_16_samples_outputs/issue1642-bmv2-frontend.p4 b/testdata/p4_16_samples_outputs/issue1642-bmv2-frontend.p4 index 60390af15fd..4f420a66fb0 100644 --- a/testdata/p4_16_samples_outputs/issue1642-bmv2-frontend.p4 +++ b/testdata/p4_16_samples_outputs/issue1642-bmv2-frontend.p4 @@ -20,6 +20,7 @@ struct parsed_packet_t { struct local_metadata_t { short s; + @field_list(0) row_t row; } @@ -36,7 +37,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); + clone3(CloneType.I2E, 32w0, 8w0); } } diff --git a/testdata/p4_16_samples_outputs/issue1642-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/issue1642-bmv2-midend.p4 index a6225ed8906..99d58880331 100644 --- a/testdata/p4_16_samples_outputs/issue1642-bmv2-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue1642-bmv2-midend.p4 @@ -20,9 +20,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; } @@ -40,7 +44,7 @@ control ingress(inout parsed_packet_t hdr, inout local_metadata_t local_metadata 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, {{1w1,local_metadata._row_alt0_port2},{local_metadata._row_alt1_valid3,local_metadata._row_alt1_port4}}); + clone3(CloneType.I2E, 32w0, 8w0); } @hidden table tbl_act { actions = { diff --git a/testdata/p4_16_samples_outputs/issue1642-bmv2.p4 b/testdata/p4_16_samples_outputs/issue1642-bmv2.p4 index 48cd3cc18fb..a7eec78f797 100644 --- a/testdata/p4_16_samples_outputs/issue1642-bmv2.p4 +++ b/testdata/p4_16_samples_outputs/issue1642-bmv2.p4 @@ -20,6 +20,7 @@ struct parsed_packet_t { struct local_metadata_t { short s; + @field_list(0) row_t row; } @@ -36,7 +37,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); + clone3(CloneType.I2E, 0, 0); } } diff --git a/testdata/p4_16_samples_outputs/issue1653-bmv2-first.p4 b/testdata/p4_16_samples_outputs/issue1653-bmv2-first.p4 index 50851c6b346..ad517ee85ec 100644 --- a/testdata/p4_16_samples_outputs/issue1653-bmv2-first.p4 +++ b/testdata/p4_16_samples_outputs/issue1653-bmv2-first.p4 @@ -25,7 +25,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); + clone3(CloneType.I2E, 32w0, 8w0); } } diff --git a/testdata/p4_16_samples_outputs/issue1653-bmv2-frontend.p4 b/testdata/p4_16_samples_outputs/issue1653-bmv2-frontend.p4 index 259c94900f2..e6eea8459fe 100644 --- a/testdata/p4_16_samples_outputs/issue1653-bmv2-frontend.p4 +++ b/testdata/p4_16_samples_outputs/issue1653-bmv2-frontend.p4 @@ -23,7 +23,7 @@ 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) { apply { - clone3(CloneType.I2E, 32w0, h); + clone3(CloneType.I2E, 32w0, 8w0); } } diff --git a/testdata/p4_16_samples_outputs/issue1653-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/issue1653-bmv2-midend.p4 index 5f21c4b9981..2ed58b8770f 100644 --- a/testdata/p4_16_samples_outputs/issue1653-bmv2-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue1653-bmv2-midend.p4 @@ -23,7 +23,7 @@ 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) { @hidden action act() { - clone3(CloneType.I2E, 32w0, h); + clone3(CloneType.I2E, 32w0, 8w0); } @hidden table tbl_act { actions = { diff --git a/testdata/p4_16_samples_outputs/issue1653-bmv2.p4 b/testdata/p4_16_samples_outputs/issue1653-bmv2.p4 index 684eca9d106..ab61a27c35b 100644 --- a/testdata/p4_16_samples_outputs/issue1653-bmv2.p4 +++ b/testdata/p4_16_samples_outputs/issue1653-bmv2.p4 @@ -25,7 +25,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); + clone3(CloneType.I2E, 0, 0); } } 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 f1e187a1172..0b370be5e3c 100644 --- a/testdata/p4_16_samples_outputs/issue1653-complex-bmv2-first.p4 +++ b/testdata/p4_16_samples_outputs/issue1653-complex-bmv2-first.p4 @@ -30,6 +30,7 @@ header bitvec_hdr { } struct local_metadata_t { + @field_list(0) row_t row0; row_t row1; bitvec_hdr bvh0; @@ -72,7 +73,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); + clone3(CloneType.I2E, 32w0, 8w0); } } 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 e1608cb1485..9b49f7a5e95 100644 --- a/testdata/p4_16_samples_outputs/issue1653-complex-bmv2-frontend.p4 +++ b/testdata/p4_16_samples_outputs/issue1653-complex-bmv2-frontend.p4 @@ -30,6 +30,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_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); + clone3(CloneType.I2E, 32w0, 8w0); } } 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 f74eee8e54f..6e06432ba9d 100644 --- a/testdata/p4_16_samples_outputs/issue1653-complex-bmv2-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue1653-complex-bmv2-midend.p4 @@ -31,17 +31,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; @@ -93,7 +105,7 @@ control ingress(inout parsed_packet_t h, inout local_metadata_t local_metadata, @hidden action act() { h.bvh0._row_alt1_type10 = 16w0x800; local_metadata._row0_alt0_useHash3 = true; - clone3(CloneType.I2E, 32w0, {{local_metadata._row0_alt0_valid0,local_metadata._row0_alt0_port1,local_metadata._row0_alt0_hashRes2,true,local_metadata._row0_alt0_type4,local_metadata._row0_alt0_pad5},{local_metadata._row0_alt1_valid6,local_metadata._row0_alt1_port7,local_metadata._row0_alt1_hashRes8,local_metadata._row0_alt1_useHash9,local_metadata._row0_alt1_type10,local_metadata._row0_alt1_pad11}}); + clone3(CloneType.I2E, 32w0, 8w0); } @hidden table tbl_act { actions = { diff --git a/testdata/p4_16_samples_outputs/issue1653-complex-bmv2.p4 b/testdata/p4_16_samples_outputs/issue1653-complex-bmv2.p4 index fa8bfcf6b58..bce9940eb1b 100644 --- a/testdata/p4_16_samples_outputs/issue1653-complex-bmv2.p4 +++ b/testdata/p4_16_samples_outputs/issue1653-complex-bmv2.p4 @@ -30,6 +30,7 @@ header bitvec_hdr { } struct local_metadata_t { + @field_list(0) row_t row0; row_t row1; bitvec_hdr bvh0; @@ -70,7 +71,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); + clone3(CloneType.I2E, 0, 0); } } diff --git a/testdata/p4_16_samples_outputs/issue1660-bmv2-first.p4 b/testdata/p4_16_samples_outputs/issue1660-bmv2-first.p4 index 22f7af8f15b..b179445daf4 100644 --- a/testdata/p4_16_samples_outputs/issue1660-bmv2-first.p4 +++ b/testdata/p4_16_samples_outputs/issue1660-bmv2-first.p4 @@ -2,6 +2,7 @@ #include struct HasBool { + @field_list(0) bool x; } @@ -21,7 +22,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); + clone3(CloneType.I2E, 32w0, 8w0); } } diff --git a/testdata/p4_16_samples_outputs/issue1660-bmv2-frontend.p4 b/testdata/p4_16_samples_outputs/issue1660-bmv2-frontend.p4 index 96f66843065..1bdf059004a 100644 --- a/testdata/p4_16_samples_outputs/issue1660-bmv2-frontend.p4 +++ b/testdata/p4_16_samples_outputs/issue1660-bmv2-frontend.p4 @@ -2,6 +2,7 @@ #include struct HasBool { + @field_list(0) bool x; } @@ -18,10 +19,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) { - HasBool b_0; apply { - b_0.x = true; - clone3(CloneType.I2E, 32w0, b_0); + clone3(CloneType.I2E, 32w0, 8w0); } } diff --git a/testdata/p4_16_samples_outputs/issue1660-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/issue1660-bmv2-midend.p4 index 1d575d51c13..4b2468e989f 100644 --- a/testdata/p4_16_samples_outputs/issue1660-bmv2-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue1660-bmv2-midend.p4 @@ -2,6 +2,7 @@ #include struct HasBool { + @field_list(0) bool x; } @@ -18,10 +19,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) { - HasBool b_0; @hidden action act() { - b_0.x = true; - clone3(CloneType.I2E, 32w0, b_0); + clone3(CloneType.I2E, 32w0, 8w0); } @hidden table tbl_act { actions = { diff --git a/testdata/p4_16_samples_outputs/issue1660-bmv2.p4 b/testdata/p4_16_samples_outputs/issue1660-bmv2.p4 index e6e9bc1132c..9ea11a9baab 100644 --- a/testdata/p4_16_samples_outputs/issue1660-bmv2.p4 +++ b/testdata/p4_16_samples_outputs/issue1660-bmv2.p4 @@ -2,6 +2,7 @@ #include struct HasBool { + @field_list(0) bool x; } @@ -21,7 +22,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); + clone3(CloneType.I2E, 0, 0); } } 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 6189f409a03..a32aad9f0d8 100644 --- a/testdata/p4_16_samples_outputs/issue1765-1-bmv2-first.p4 +++ b/testdata/p4_16_samples_outputs/issue1765-1-bmv2-first.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 = 16w3; meta.ingress_port = standard_metadata.ingress_port; - clone3(CloneType.I2E, 32w100, meta); + clone3(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); + clone3(CloneType.I2E, 32w100, 8w0); } action multicast_pkg(mcast_t mcast_grp) { standard_metadata.mcast_grp = mcast_grp; 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 6f6af9801b7..8125969855d 100644 --- a/testdata/p4_16_samples_outputs/issue1765-1-bmv2-frontend.p4 +++ b/testdata/p4_16_samples_outputs/issue1765-1-bmv2-frontend.p4 @@ -97,10 +97,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; } @@ -193,22 +198,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); + clone3(CloneType.I2E, 32w100, 8w0); } @name("MyIngress.controller_debug") action controller_debug_2() { meta.task = 16w3; meta.ingress_port = standard_metadata.ingress_port; - clone3(CloneType.I2E, 32w100, meta); + clone3(CloneType.I2E, 32w100, 8w0); } @name("MyIngress.controller_reply") action controller_reply(task_t task) { meta.task = task; meta.ingress_port = standard_metadata.ingress_port; - clone3(CloneType.I2E, 32w100, meta); + clone3(CloneType.I2E, 32w100, 8w0); } @name("MyIngress.controller_reply") action controller_reply_2(task_t task) { meta.task = task; meta.ingress_port = standard_metadata.ingress_port; - clone3(CloneType.I2E, 32w100, meta); + clone3(CloneType.I2E, 32w100, 8w0); } @name("MyIngress.icmp6_echo_reply") action icmp6_echo_reply() { mac_tmp_0 = hdr.ethernet.dst_addr; 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 617f4ef8c0f..328f24d9fda 100644 --- a/testdata/p4_16_samples_outputs/issue1765-1-bmv2-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue1765-1-bmv2-midend.p4 @@ -97,10 +97,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; } @@ -201,22 +206,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); + clone3(CloneType.I2E, 32w100, 8w0); } @name("MyIngress.controller_debug") action controller_debug_2() { meta.task = 16w3; meta.ingress_port = standard_metadata.ingress_port; - clone3(CloneType.I2E, 32w100, meta); + clone3(CloneType.I2E, 32w100, 8w0); } @name("MyIngress.controller_reply") action controller_reply(task_t task) { meta.task = task; meta.ingress_port = standard_metadata.ingress_port; - clone3(CloneType.I2E, 32w100, meta); + clone3(CloneType.I2E, 32w100, 8w0); } @name("MyIngress.controller_reply") action controller_reply_2(task_t task) { meta.task = task; meta.ingress_port = standard_metadata.ingress_port; - clone3(CloneType.I2E, 32w100, meta); + clone3(CloneType.I2E, 32w100, 8w0); } @name("MyIngress.icmp6_echo_reply") action icmp6_echo_reply() { mac_tmp_0 = hdr.ethernet.dst_addr; diff --git a/testdata/p4_16_samples_outputs/issue1765-1-bmv2.p4 b/testdata/p4_16_samples_outputs/issue1765-1-bmv2.p4 index a294651e800..6483182f59e 100644 --- a/testdata/p4_16_samples_outputs/issue1765-1-bmv2.p4 +++ b/testdata/p4_16_samples_outputs/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); + clone3(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); + clone3(CloneType.I2E, 100, 0); } action multicast_pkg(mcast_t mcast_grp) { standard_metadata.mcast_grp = mcast_grp; 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/issue1897-bmv2-first.p4 b/testdata/p4_16_samples_outputs/issue1897-bmv2-first.p4 new file mode 100644 index 00000000000..fb6dbedaa9c --- /dev/null +++ b/testdata/p4_16_samples_outputs/issue1897-bmv2-first.p4 @@ -0,0 +1,85 @@ +#include +#include + +header addr_type_t { + bit<8> dstType; + bit<8> srcType; +} + +header addr_ipv4_t { + bit<32> addr; +} + +header addr_ipv6_t { + bit<128> addr; +} + +header_union addr_t { + addr_ipv4_t ipv4; + addr_ipv6_t ipv6; +} + +struct metadata { +} + +struct headers { + addr_type_t addr_type; + addr_t addr_dst; + addr_t addr_src; +} + +parser ProtAddrParser(packet_in packet, in bit<8> addrType, out addr_t addr) { + state start { + transition select(addrType) { + 8w0x1: ipv4; + 8w0x2: ipv6; + } + } + state ipv4 { + packet.extract(addr.ipv4); + transition accept; + } + state ipv6 { + packet.extract(addr.ipv6); + transition accept; + } +} + +parser ProtParser(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + ProtAddrParser() addrParser; + state start { + packet.extract(hdr.addr_type); + addrParser.apply(packet, hdr.addr_type.dstType, hdr.addr_dst); + addrParser.apply(packet, hdr.addr_type.srcType, hdr.addr_src); + transition accept; + } +} + +control ProtVerifyChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +control ProtIngress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ProtEgress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ProtComputeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +control ProtDeparser(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr); + } +} + +V1Switch(ProtParser(), ProtVerifyChecksum(), ProtIngress(), ProtEgress(), ProtComputeChecksum(), ProtDeparser()) main; + diff --git a/testdata/p4_16_samples_outputs/issue1897-bmv2-frontend.p4 b/testdata/p4_16_samples_outputs/issue1897-bmv2-frontend.p4 new file mode 100644 index 00000000000..4fd3dfb4549 --- /dev/null +++ b/testdata/p4_16_samples_outputs/issue1897-bmv2-frontend.p4 @@ -0,0 +1,109 @@ +#include +#include + +header addr_type_t { + bit<8> dstType; + bit<8> srcType; +} + +header addr_ipv4_t { + bit<32> addr; +} + +header addr_ipv6_t { + bit<128> addr; +} + +header_union addr_t { + addr_ipv4_t ipv4; + addr_ipv6_t ipv6; +} + +struct metadata { +} + +struct headers { + addr_type_t addr_type; + addr_t addr_dst; + addr_t addr_src; +} + +parser ProtParser(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + bit<8> addrType_0; + addr_t addr_0; + state start { + packet.extract(hdr.addr_type); + addrType_0 = hdr.addr_type.dstType; + addr_0.ipv4.setInvalid(); + addr_0.ipv6.setInvalid(); + transition ProtAddrParser_start; + } + state ProtAddrParser_start { + transition select(addrType_0) { + 8w0x1: ProtAddrParser_ipv4; + 8w0x2: ProtAddrParser_ipv6; + } + } + state ProtAddrParser_ipv4 { + packet.extract(addr_0.ipv4); + transition start_0; + } + state ProtAddrParser_ipv6 { + packet.extract(addr_0.ipv6); + transition start_0; + } + state start_0 { + hdr.addr_dst = addr_0; + addrType_0 = hdr.addr_type.srcType; + addr_0.ipv4.setInvalid(); + addr_0.ipv6.setInvalid(); + transition ProtAddrParser_start_0; + } + state ProtAddrParser_start_0 { + transition select(addrType_0) { + 8w0x1: ProtAddrParser_ipv4_0; + 8w0x2: ProtAddrParser_ipv6_0; + } + } + state ProtAddrParser_ipv4_0 { + packet.extract(addr_0.ipv4); + transition start_1; + } + state ProtAddrParser_ipv6_0 { + packet.extract(addr_0.ipv6); + transition start_1; + } + state start_1 { + hdr.addr_src = addr_0; + transition accept; + } +} + +control ProtVerifyChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +control ProtIngress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ProtEgress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ProtComputeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +control ProtDeparser(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr); + } +} + +V1Switch(ProtParser(), ProtVerifyChecksum(), ProtIngress(), ProtEgress(), ProtComputeChecksum(), ProtDeparser()) main; + diff --git a/testdata/p4_16_samples_outputs/issue1897-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/issue1897-bmv2-midend.p4 new file mode 100644 index 00000000000..189eae50869 --- /dev/null +++ b/testdata/p4_16_samples_outputs/issue1897-bmv2-midend.p4 @@ -0,0 +1,112 @@ +#include +#include + +header addr_type_t { + bit<8> dstType; + bit<8> srcType; +} + +header addr_ipv4_t { + bit<32> addr; +} + +header addr_ipv6_t { + bit<128> addr; +} + +header_union addr_t { + addr_ipv4_t ipv4; + addr_ipv6_t ipv6; +} + +struct metadata { +} + +struct headers { + addr_type_t addr_type; + addr_t addr_dst; + addr_t addr_src; +} + +parser ProtParser(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + addr_t addr_0; + state start { + packet.extract(hdr.addr_type); + addr_0.ipv4.setInvalid(); + addr_0.ipv6.setInvalid(); + transition select(hdr.addr_type.dstType) { + 8w0x1: ProtAddrParser_ipv4; + 8w0x2: ProtAddrParser_ipv6; + default: noMatch; + } + } + state ProtAddrParser_ipv4 { + packet.extract(addr_0.ipv4); + transition start_0; + } + state ProtAddrParser_ipv6 { + packet.extract(addr_0.ipv6); + transition start_0; + } + state start_0 { + hdr.addr_dst.ipv4 = addr_0.ipv4; + hdr.addr_dst.ipv6 = addr_0.ipv6; + addr_0.ipv4.setInvalid(); + addr_0.ipv6.setInvalid(); + transition select(hdr.addr_type.srcType) { + 8w0x1: ProtAddrParser_ipv4_0; + 8w0x2: ProtAddrParser_ipv6_0; + default: noMatch; + } + } + state ProtAddrParser_ipv4_0 { + packet.extract(addr_0.ipv4); + transition start_1; + } + state ProtAddrParser_ipv6_0 { + packet.extract(addr_0.ipv6); + transition start_1; + } + state start_1 { + hdr.addr_src.ipv4 = addr_0.ipv4; + hdr.addr_src.ipv6 = addr_0.ipv6; + transition accept; + } + state noMatch { + verify(false, error.NoMatch); + transition reject; + } +} + +control ProtVerifyChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +control ProtIngress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ProtEgress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ProtComputeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +control ProtDeparser(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.addr_type); + packet.emit(hdr.addr_dst.ipv4); + packet.emit(hdr.addr_dst.ipv6); + packet.emit(hdr.addr_src.ipv4); + packet.emit(hdr.addr_src.ipv6); + } +} + +V1Switch(ProtParser(), ProtVerifyChecksum(), ProtIngress(), ProtEgress(), ProtComputeChecksum(), ProtDeparser()) main; + diff --git a/testdata/p4_16_samples_outputs/issue1897-bmv2.p4 b/testdata/p4_16_samples_outputs/issue1897-bmv2.p4 new file mode 100644 index 00000000000..132772f925c --- /dev/null +++ b/testdata/p4_16_samples_outputs/issue1897-bmv2.p4 @@ -0,0 +1,85 @@ +#include +#include + +header addr_type_t { + bit<8> dstType; + bit<8> srcType; +} + +header addr_ipv4_t { + bit<32> addr; +} + +header addr_ipv6_t { + bit<128> addr; +} + +header_union addr_t { + addr_ipv4_t ipv4; + addr_ipv6_t ipv6; +} + +struct metadata { +} + +struct headers { + addr_type_t addr_type; + addr_t addr_dst; + addr_t addr_src; +} + +parser ProtAddrParser(packet_in packet, in bit<8> addrType, out addr_t addr) { + state start { + transition select(addrType) { + 0x1: ipv4; + 0x2: ipv6; + } + } + state ipv4 { + packet.extract(addr.ipv4); + transition accept; + } + state ipv6 { + packet.extract(addr.ipv6); + transition accept; + } +} + +parser ProtParser(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + ProtAddrParser() addrParser; + state start { + packet.extract(hdr.addr_type); + addrParser.apply(packet, hdr.addr_type.dstType, hdr.addr_dst); + addrParser.apply(packet, hdr.addr_type.srcType, hdr.addr_src); + transition accept; + } +} + +control ProtVerifyChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +control ProtIngress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ProtEgress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ProtComputeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +control ProtDeparser(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr); + } +} + +V1Switch(ProtParser(), ProtVerifyChecksum(), ProtIngress(), ProtEgress(), ProtComputeChecksum(), ProtDeparser()) main; + diff --git a/testdata/p4_16_samples_outputs/issue1897-bmv2.p4.entries.txt b/testdata/p4_16_samples_outputs/issue1897-bmv2.p4.entries.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/testdata/p4_16_samples_outputs/issue383-bmv2-first.p4 b/testdata/p4_16_samples_outputs/issue383-bmv2-first.p4 index 8be4d913fa6..5d71b3c9981 100644 --- a/testdata/p4_16_samples_outputs/issue383-bmv2-first.p4 +++ b/testdata/p4_16_samples_outputs/issue383-bmv2-first.p4 @@ -20,6 +20,7 @@ struct col_t { } struct local_metadata_t { + @field_list(0) row_t row0; row_t row1; col_t col; @@ -78,7 +79,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); + clone3(CloneType.I2E, 32w0, 8w0); } } diff --git a/testdata/p4_16_samples_outputs/issue383-bmv2-frontend.p4 b/testdata/p4_16_samples_outputs/issue383-bmv2-frontend.p4 index cbb27effce0..3dcfbcaa635 100644 --- a/testdata/p4_16_samples_outputs/issue383-bmv2-frontend.p4 +++ b/testdata/p4_16_samples_outputs/issue383-bmv2-frontend.p4 @@ -20,6 +20,7 @@ struct col_t { } struct local_metadata_t { + @field_list(0) row_t row0; row_t row1; col_t col; @@ -72,7 +73,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); + clone3(CloneType.I2E, 32w0, 8w0); } } diff --git a/testdata/p4_16_samples_outputs/issue383-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/issue383-bmv2-midend.p4 index 2c42b892b41..b3ca0f71b4d 100644 --- a/testdata/p4_16_samples_outputs/issue383-bmv2-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue383-bmv2-midend.p4 @@ -23,9 +23,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; @@ -81,7 +85,7 @@ control ingress(inout parsed_packet_t h, inout local_metadata_t local_metadata, 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, {{local_metadata._row1_alt1_valid6,local_metadata._row0_alt0_port1},{local_metadata._row0_alt1_valid2,local_metadata._row0_alt1_port3}}); + clone3(CloneType.I2E, 32w0, 8w0); } @hidden table tbl_act { actions = { diff --git a/testdata/p4_16_samples_outputs/issue383-bmv2.p4 b/testdata/p4_16_samples_outputs/issue383-bmv2.p4 index 5cb0d91c012..8cb74f7254b 100644 --- a/testdata/p4_16_samples_outputs/issue383-bmv2.p4 +++ b/testdata/p4_16_samples_outputs/issue383-bmv2.p4 @@ -20,6 +20,7 @@ struct col_t { } struct local_metadata_t { + @field_list(0) row_t row0; row_t row1; col_t col; @@ -76,7 +77,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); + clone3(CloneType.I2E, 0, 0); } } diff --git a/testdata/p4_16_samples_outputs/issue562-bmv2-first.p4 b/testdata/p4_16_samples_outputs/issue562-bmv2-first.p4 index 8c2f2a4e585..ff17b7ff3cf 100644 --- a/testdata/p4_16_samples_outputs/issue562-bmv2-first.p4 +++ b/testdata/p4_16_samples_outputs/issue562-bmv2-first.p4 @@ -15,6 +15,7 @@ struct parsed_packet_t { } struct local_metadata_t { + @field_list(0) row_t row; } @@ -29,7 +30,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); + clone3(CloneType.I2E, 32w0, 8w0); } } diff --git a/testdata/p4_16_samples_outputs/issue562-bmv2-frontend.p4 b/testdata/p4_16_samples_outputs/issue562-bmv2-frontend.p4 index 8c2f2a4e585..ff17b7ff3cf 100644 --- a/testdata/p4_16_samples_outputs/issue562-bmv2-frontend.p4 +++ b/testdata/p4_16_samples_outputs/issue562-bmv2-frontend.p4 @@ -15,6 +15,7 @@ struct parsed_packet_t { } struct local_metadata_t { + @field_list(0) row_t row; } @@ -29,7 +30,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); + clone3(CloneType.I2E, 32w0, 8w0); } } diff --git a/testdata/p4_16_samples_outputs/issue562-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/issue562-bmv2-midend.p4 index 779d2aa98e5..654fb68d83a 100644 --- a/testdata/p4_16_samples_outputs/issue562-bmv2-midend.p4 +++ b/testdata/p4_16_samples_outputs/issue562-bmv2-midend.p4 @@ -15,9 +15,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; } @@ -33,7 +37,7 @@ control ingress(inout parsed_packet_t hdr, inout local_metadata_t local_metadata 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, {{1w1,local_metadata._row_alt0_port1},{local_metadata._row_alt1_valid2,local_metadata._row_alt1_port3}}); + clone3(CloneType.I2E, 32w0, 8w0); } @hidden table tbl_act { actions = { diff --git a/testdata/p4_16_samples_outputs/issue562-bmv2.p4 b/testdata/p4_16_samples_outputs/issue562-bmv2.p4 index dad66b00000..60b1561a555 100644 --- a/testdata/p4_16_samples_outputs/issue562-bmv2.p4 +++ b/testdata/p4_16_samples_outputs/issue562-bmv2.p4 @@ -15,6 +15,7 @@ struct parsed_packet_t { } struct local_metadata_t { + @field_list(0) row_t row; } @@ -29,7 +30,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); + clone3(CloneType.I2E, 0, 0); } } diff --git a/testdata/p4_16_samples_outputs/psa-basic-counter-bmv2-first.p4 b/testdata/p4_16_samples_outputs/psa-basic-counter-bmv2-first.p4 new file mode 100644 index 00000000000..b8292f911d7 --- /dev/null +++ b/testdata/p4_16_samples_outputs/psa-basic-counter-bmv2-first.p4 @@ -0,0 +1,82 @@ +#include +#include + +typedef bit<48> EthernetAddress; +header ethernet_t { + EthernetAddress dstAddr; + EthernetAddress srcAddr; + bit<16> etherType; +} + +struct empty_metadata_t { +} + +struct metadata_t { +} + +struct headers_t { + ethernet_t ethernet; +} + +parser IngressParserImpl(packet_in pkt, out headers_t hdr, inout metadata_t user_meta, in psa_ingress_parser_input_metadata_t istd, in empty_metadata_t resubmit_meta, in empty_metadata_t recirculate_meta) { + state start { + pkt.extract(hdr.ethernet); + transition accept; + } +} + +control cIngress(inout headers_t hdr, inout metadata_t user_meta, in psa_ingress_input_metadata_t istd, inout psa_ingress_output_metadata_t ostd) { + Counter, bit<12>>(32w1024, PSA_CounterType_t.PACKETS) counter; + action execute() { + counter.count(12w256); + } + table tbl { + actions = { + execute(); + } + default_action = execute(); + } + apply { + send_to_port(ostd, (PortId_t)(PortIdUint_t)hdr.ethernet.dstAddr[1:0]); + tbl.apply(); + } +} + +parser EgressParserImpl(packet_in buffer, out headers_t hdr, inout metadata_t user_meta, in psa_egress_parser_input_metadata_t istd, in empty_metadata_t normal_meta, in empty_metadata_t clone_i2e_meta, in empty_metadata_t clone_e2e_meta) { + state start { + buffer.extract(hdr.ethernet); + transition accept; + } +} + +control cEgress(inout headers_t hdr, inout metadata_t user_meta, in psa_egress_input_metadata_t istd, inout psa_egress_output_metadata_t ostd) { + apply { + } +} + +control CommonDeparserImpl(packet_out packet, inout headers_t hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control IngressDeparserImpl(packet_out buffer, out empty_metadata_t clone_i2e_meta, out empty_metadata_t resubmit_meta, out empty_metadata_t normal_meta, inout headers_t hdr, in metadata_t meta, in psa_ingress_output_metadata_t istd) { + CommonDeparserImpl() cp; + apply { + cp.apply(buffer, hdr); + } +} + +control EgressDeparserImpl(packet_out buffer, out empty_metadata_t clone_e2e_meta, out empty_metadata_t recirculate_meta, inout headers_t hdr, in metadata_t meta, in psa_egress_output_metadata_t istd, in psa_egress_deparser_input_metadata_t edstd) { + CommonDeparserImpl() cp; + apply { + cp.apply(buffer, hdr); + } +} + +IngressPipeline(IngressParserImpl(), cIngress(), IngressDeparserImpl()) ip; + +EgressPipeline(EgressParserImpl(), cEgress(), EgressDeparserImpl()) ep; + +PSA_Switch(ip, PacketReplicationEngine(), ep, BufferingQueueingEngine()) main; + diff --git a/testdata/p4_16_samples_outputs/psa-basic-counter-bmv2-frontend.p4 b/testdata/p4_16_samples_outputs/psa-basic-counter-bmv2-frontend.p4 new file mode 100644 index 00000000000..b52f0580d51 --- /dev/null +++ b/testdata/p4_16_samples_outputs/psa-basic-counter-bmv2-frontend.p4 @@ -0,0 +1,79 @@ +#include +#include + +typedef bit<48> EthernetAddress; +header ethernet_t { + EthernetAddress dstAddr; + EthernetAddress srcAddr; + bit<16> etherType; +} + +struct empty_metadata_t { +} + +struct metadata_t { +} + +struct headers_t { + ethernet_t ethernet; +} + +parser IngressParserImpl(packet_in pkt, out headers_t hdr, inout metadata_t user_meta, in psa_ingress_parser_input_metadata_t istd, in empty_metadata_t resubmit_meta, in empty_metadata_t recirculate_meta) { + state start { + pkt.extract(hdr.ethernet); + transition accept; + } +} + +control cIngress(inout headers_t hdr, inout metadata_t user_meta, in psa_ingress_input_metadata_t istd, inout psa_ingress_output_metadata_t ostd) { + @name(".send_to_port") action send_to_port(inout psa_ingress_output_metadata_t meta_1, in PortId_t egress_port_1) { + meta_1.drop = false; + meta_1.multicast_group = (MulticastGroup_t)32w0; + meta_1.egress_port = egress_port_1; + } + @name("cIngress.counter") Counter, bit<12>>(32w1024, PSA_CounterType_t.PACKETS) counter_0; + @name("cIngress.execute") action execute_1() { + counter_0.count(12w256); + } + @name("cIngress.tbl") table tbl_0 { + actions = { + execute_1(); + } + default_action = execute_1(); + } + apply { + send_to_port(ostd, (PortId_t)(PortIdUint_t)hdr.ethernet.dstAddr[1:0]); + tbl_0.apply(); + } +} + +parser EgressParserImpl(packet_in buffer, out headers_t hdr, inout metadata_t user_meta, in psa_egress_parser_input_metadata_t istd, in empty_metadata_t normal_meta, in empty_metadata_t clone_i2e_meta, in empty_metadata_t clone_e2e_meta) { + state start { + buffer.extract(hdr.ethernet); + transition accept; + } +} + +control cEgress(inout headers_t hdr, inout metadata_t user_meta, in psa_egress_input_metadata_t istd, inout psa_egress_output_metadata_t ostd) { + apply { + } +} + +control IngressDeparserImpl(packet_out buffer, out empty_metadata_t clone_i2e_meta, out empty_metadata_t resubmit_meta, out empty_metadata_t normal_meta, inout headers_t hdr, in metadata_t meta, in psa_ingress_output_metadata_t istd) { + apply { + buffer.emit(hdr.ethernet); + } +} + +control EgressDeparserImpl(packet_out buffer, out empty_metadata_t clone_e2e_meta, out empty_metadata_t recirculate_meta, inout headers_t hdr, in metadata_t meta, in psa_egress_output_metadata_t istd, in psa_egress_deparser_input_metadata_t edstd) { + apply { + buffer.emit(hdr.ethernet); + } +} + +IngressPipeline(IngressParserImpl(), cIngress(), IngressDeparserImpl()) ip; + +EgressPipeline(EgressParserImpl(), cEgress(), EgressDeparserImpl()) ep; + +PSA_Switch(ip, PacketReplicationEngine(), ep, BufferingQueueingEngine()) main; + diff --git a/testdata/p4_16_samples_outputs/psa-basic-counter-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/psa-basic-counter-bmv2-midend.p4 new file mode 100644 index 00000000000..0b867af867b --- /dev/null +++ b/testdata/p4_16_samples_outputs/psa-basic-counter-bmv2-midend.p4 @@ -0,0 +1,103 @@ +#include +#include + +typedef bit<48> EthernetAddress; +header ethernet_t { + EthernetAddress dstAddr; + EthernetAddress srcAddr; + bit<16> etherType; +} + +struct empty_metadata_t { +} + +struct metadata_t { +} + +struct headers_t { + ethernet_t ethernet; +} + +parser IngressParserImpl(packet_in pkt, out headers_t hdr, inout metadata_t user_meta, in psa_ingress_parser_input_metadata_t istd, in empty_metadata_t resubmit_meta, in empty_metadata_t recirculate_meta) { + state start { + pkt.extract(hdr.ethernet); + transition accept; + } +} + +control cIngress(inout headers_t hdr, inout metadata_t user_meta, in psa_ingress_input_metadata_t istd, inout psa_ingress_output_metadata_t ostd) { + @name(".send_to_port") action send_to_port() { + ostd.drop = false; + ostd.multicast_group = 32w0; + ostd.egress_port = (PortIdUint_t)hdr.ethernet.dstAddr[1:0]; + } + @name("cIngress.counter") Counter, bit<12>>(32w1024, PSA_CounterType_t.PACKETS) counter_0; + @name("cIngress.execute") action execute_1() { + counter_0.count(12w256); + } + @name("cIngress.tbl") table tbl_0 { + actions = { + execute_1(); + } + default_action = execute_1(); + } + @hidden table tbl_send_to_port { + actions = { + send_to_port(); + } + const default_action = send_to_port(); + } + apply { + tbl_send_to_port.apply(); + tbl_0.apply(); + } +} + +parser EgressParserImpl(packet_in buffer, out headers_t hdr, inout metadata_t user_meta, in psa_egress_parser_input_metadata_t istd, in empty_metadata_t normal_meta, in empty_metadata_t clone_i2e_meta, in empty_metadata_t clone_e2e_meta) { + state start { + buffer.extract(hdr.ethernet); + transition accept; + } +} + +control cEgress(inout headers_t hdr, inout metadata_t user_meta, in psa_egress_input_metadata_t istd, inout psa_egress_output_metadata_t ostd) { + apply { + } +} + +control IngressDeparserImpl(packet_out buffer, out empty_metadata_t clone_i2e_meta, out empty_metadata_t resubmit_meta, out empty_metadata_t normal_meta, inout headers_t hdr, in metadata_t meta, in psa_ingress_output_metadata_t istd) { + @hidden action act() { + buffer.emit(hdr.ethernet); + } + @hidden table tbl_act { + actions = { + act(); + } + const default_action = act(); + } + apply { + tbl_act.apply(); + } +} + +control EgressDeparserImpl(packet_out buffer, out empty_metadata_t clone_e2e_meta, out empty_metadata_t recirculate_meta, inout headers_t hdr, in metadata_t meta, in psa_egress_output_metadata_t istd, in psa_egress_deparser_input_metadata_t edstd) { + @hidden action act_0() { + buffer.emit(hdr.ethernet); + } + @hidden table tbl_act_0 { + actions = { + act_0(); + } + const default_action = act_0(); + } + apply { + tbl_act_0.apply(); + } +} + +IngressPipeline(IngressParserImpl(), cIngress(), IngressDeparserImpl()) ip; + +EgressPipeline(EgressParserImpl(), cEgress(), EgressDeparserImpl()) ep; + +PSA_Switch(ip, PacketReplicationEngine(), ep, BufferingQueueingEngine()) main; + diff --git a/testdata/p4_16_samples_outputs/psa-basic-counter-bmv2.p4 b/testdata/p4_16_samples_outputs/psa-basic-counter-bmv2.p4 new file mode 100644 index 00000000000..8ad8a13e9af --- /dev/null +++ b/testdata/p4_16_samples_outputs/psa-basic-counter-bmv2.p4 @@ -0,0 +1,82 @@ +#include +#include + +typedef bit<48> EthernetAddress; +header ethernet_t { + EthernetAddress dstAddr; + EthernetAddress srcAddr; + bit<16> etherType; +} + +struct empty_metadata_t { +} + +struct metadata_t { +} + +struct headers_t { + ethernet_t ethernet; +} + +parser IngressParserImpl(packet_in pkt, out headers_t hdr, inout metadata_t user_meta, in psa_ingress_parser_input_metadata_t istd, in empty_metadata_t resubmit_meta, in empty_metadata_t recirculate_meta) { + state start { + pkt.extract(hdr.ethernet); + transition accept; + } +} + +control cIngress(inout headers_t hdr, inout metadata_t user_meta, in psa_ingress_input_metadata_t istd, inout psa_ingress_output_metadata_t ostd) { + Counter, bit<12>>(1024, PSA_CounterType_t.PACKETS) counter; + action execute() { + counter.count(256); + } + table tbl { + actions = { + execute; + } + default_action = execute; + } + apply { + send_to_port(ostd, (PortId_t)(PortIdUint_t)hdr.ethernet.dstAddr[1:0]); + tbl.apply(); + } +} + +parser EgressParserImpl(packet_in buffer, out headers_t hdr, inout metadata_t user_meta, in psa_egress_parser_input_metadata_t istd, in empty_metadata_t normal_meta, in empty_metadata_t clone_i2e_meta, in empty_metadata_t clone_e2e_meta) { + state start { + buffer.extract(hdr.ethernet); + transition accept; + } +} + +control cEgress(inout headers_t hdr, inout metadata_t user_meta, in psa_egress_input_metadata_t istd, inout psa_egress_output_metadata_t ostd) { + apply { + } +} + +control CommonDeparserImpl(packet_out packet, inout headers_t hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control IngressDeparserImpl(packet_out buffer, out empty_metadata_t clone_i2e_meta, out empty_metadata_t resubmit_meta, out empty_metadata_t normal_meta, inout headers_t hdr, in metadata_t meta, in psa_ingress_output_metadata_t istd) { + CommonDeparserImpl() cp; + apply { + cp.apply(buffer, hdr); + } +} + +control EgressDeparserImpl(packet_out buffer, out empty_metadata_t clone_e2e_meta, out empty_metadata_t recirculate_meta, inout headers_t hdr, in metadata_t meta, in psa_egress_output_metadata_t istd, in psa_egress_deparser_input_metadata_t edstd) { + CommonDeparserImpl() cp; + apply { + cp.apply(buffer, hdr); + } +} + +IngressPipeline(IngressParserImpl(), cIngress(), IngressDeparserImpl()) ip; + +EgressPipeline(EgressParserImpl(), cEgress(), EgressDeparserImpl()) ep; + +PSA_Switch(ip, PacketReplicationEngine(), ep, BufferingQueueingEngine()) main; + diff --git a/testdata/p4_16_samples_outputs/psa-basic-counter-bmv2.p4-stderr b/testdata/p4_16_samples_outputs/psa-basic-counter-bmv2.p4-stderr new file mode 100644 index 00000000000..e69de29bb2d diff --git a/testdata/p4_16_samples_outputs/psa-basic-counter-bmv2.p4.entries.txt b/testdata/p4_16_samples_outputs/psa-basic-counter-bmv2.p4.entries.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/testdata/p4_16_samples_outputs/psa-basic-counter-bmv2.p4.p4info.txt b/testdata/p4_16_samples_outputs/psa-basic-counter-bmv2.p4.p4info.txt new file mode 100644 index 00000000000..c53077fb34a --- /dev/null +++ b/testdata/p4_16_samples_outputs/psa-basic-counter-bmv2.p4.p4info.txt @@ -0,0 +1,42 @@ +pkg_info { + arch: "psa" +} +tables { + preamble { + id: 33578158 + name: "cIngress.tbl" + alias: "tbl" + } + action_refs { + id: 16801940 + } + size: 1024 + idle_timeout_behavior: NOTIFY_CONTROL +} +actions { + preamble { + id: 16833049 + name: "send_to_port" + alias: "send_to_port" + } +} +actions { + preamble { + id: 16801940 + name: "cIngress.execute" + alias: "execute" + } +} +counters { + preamble { + id: 301992253 + name: "cIngress.counter" + alias: "counter" + } + spec { + unit: PACKETS + } + size: 1024 +} +type_info { +} 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 9ee6b30998d..46698607ced 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 @@ -90,10 +90,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(8w0); } action do_clone_i2e(bit<32> l2ptr) { - clone3>(CloneType.I2E, 32w5, { }); + clone3(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(8w0); } action do_clone_e2e(bit<48> smac) { hdr.ethernet.srcAddr = smac; - clone3>(CloneType.E2E, 32w11, { }); + clone3(CloneType.E2E, 32w11, 8w0); } table send_frame { key = { 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 551ad5b1ac8..14895b66048 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 @@ -76,10 +76,10 @@ control ingress(inout headers_t hdr, inout meta_t meta, inout standard_metadata_ } @name("ingress.do_resubmit") action do_resubmit(bit<32> new_ipv4_dstAddr) { hdr.ipv4.dstAddr = new_ipv4_dstAddr; - resubmit>({ }); + resubmit(8w0); } @name("ingress.do_clone_i2e") action do_clone_i2e(bit<32> l2ptr) { - clone3>(CloneType.I2E, 32w5, { }); + clone3(CloneType.I2E, 32w5, 8w0); meta.fwd.l2ptr = l2ptr; } @name("ingress.ipv4_da_lpm") table ipv4_da_lpm_0 { @@ -163,11 +163,11 @@ control egress(inout headers_t hdr, inout meta_t meta, inout standard_metadata_t } @name("egress.do_recirculate") action do_recirculate(bit<32> new_ipv4_dstAddr) { hdr.ipv4.dstAddr = new_ipv4_dstAddr; - recirculate>({ }); + recirculate(8w0); } @name("egress.do_clone_e2e") action do_clone_e2e(bit<48> smac) { hdr.ethernet.srcAddr = smac; - clone3>(CloneType.E2E, 32w11, { }); + clone3(CloneType.E2E, 32w11, 8w0); } @name("egress.send_frame") table send_frame_0 { key = { 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 8cbe24c9ab7..8e507af9b0f 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 @@ -57,9 +57,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) { standard_metadata_t smeta; standard_metadata_t smeta_1; @@ -165,10 +162,10 @@ control ingress(inout headers_t hdr, inout meta_t meta, inout standard_metadata_ } @name("ingress.do_resubmit") action do_resubmit(bit<32> new_ipv4_dstAddr) { hdr.ipv4.dstAddr = new_ipv4_dstAddr; - resubmit({ }); + resubmit(8w0); } @name("ingress.do_clone_i2e") action do_clone_i2e(bit<32> l2ptr) { - clone3(CloneType.I2E, 32w5, { }); + clone3(CloneType.I2E, 32w5, 8w0); meta._fwd_l2ptr0 = l2ptr; } @name("ingress.ipv4_da_lpm") table ipv4_da_lpm_0 { @@ -305,11 +302,11 @@ control egress(inout headers_t hdr, inout meta_t meta, inout standard_metadata_t } @name("egress.do_recirculate") action do_recirculate(bit<32> new_ipv4_dstAddr) { hdr.ipv4.dstAddr = new_ipv4_dstAddr; - recirculate({ }); + recirculate(8w0); } @name("egress.do_clone_e2e") action do_clone_e2e(bit<48> smac) { hdr.ethernet.srcAddr = smac; - clone3(CloneType.E2E, 32w11, { }); + clone3(CloneType.E2E, 32w11, 8w0); } @name("egress.send_frame") table send_frame_0 { key = { @@ -369,7 +366,7 @@ control DeparserImpl(packet_out packet, in headers_t hdr) { } } -struct tuple_1 { +struct tuple_0 { bit<4> field; bit<4> field_0; bit<8> field_1; @@ -385,13 +382,13 @@ struct tuple_1 { control verifyChecksum(inout headers_t hdr, inout meta_t meta) { apply { - verify_checksum>(hdr.ipv4.isValid() && hdr.ipv4.ihl == 4w5, { hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.totalLen, hdr.ipv4.identification, hdr.ipv4.flags, hdr.ipv4.fragOffset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); + verify_checksum>(hdr.ipv4.isValid() && hdr.ipv4.ihl == 4w5, { hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.totalLen, hdr.ipv4.identification, hdr.ipv4.flags, hdr.ipv4.fragOffset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, 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, { hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.totalLen, hdr.ipv4.identification, hdr.ipv4.flags, hdr.ipv4.fragOffset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); + update_checksum>(hdr.ipv4.isValid() && hdr.ipv4.ihl == 4w5, { hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.totalLen, hdr.ipv4.identification, hdr.ipv4.flags, hdr.ipv4.fragOffset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); } } 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 2da45f33ac6..8e1fbec0794 100644 --- a/testdata/p4_16_samples_outputs/v1model-special-ops-bmv2.p4 +++ b/testdata/p4_16_samples_outputs/v1model-special-ops-bmv2.p4 @@ -90,10 +90,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(0); } action do_clone_i2e(bit<32> l2ptr) { - clone3(CloneType.I2E, I2E_CLONE_SESSION_ID, { }); + clone3(CloneType.I2E, I2E_CLONE_SESSION_ID, 0); 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(0); } action do_clone_e2e(bit<48> smac) { hdr.ethernet.srcAddr = smac; - clone3(CloneType.E2E, E2E_CLONE_SESSION_ID, { }); + clone3(CloneType.E2E, E2E_CLONE_SESSION_ID, 0); } table send_frame { key = {