From fcb71b4b9be0fbfe9b7bfb00db23cf15b37f2b3e Mon Sep 17 00:00:00 2001 From: mbudiu-vmw Date: Thu, 29 Sep 2016 13:25:19 -0700 Subject: [PATCH 1/9] Fixed specialization to properly cope with parsers/controls passed as arguments --- backends/bmv2/Makefile.am | 4 +- backends/bmv2/jsonconverter.cpp | 5 +- backends/bmv2/run-bmv2-test.py | 3 - backends/p4test/midend.cpp | 2 +- frontends/p4/def_use.cpp | 3 +- frontends/p4/p4-parse.ypp | 8 +- frontends/p4/typeChecking/typeChecker.cpp | 17 +- frontends/p4/typeChecking/typeChecker.h | 2 +- ir/base.def | 2 +- ir/type.def | 1 + midend/specialize.cpp | 311 ++++++++++-------- midend/specialize.h | 93 ++++-- .../{packet_in-bmv2.p4 => parser-arg.p4} | 27 +- .../p4_16_errors_outputs/packet_in-bmv2.p4 | 17 + .../packet_in-bmv2.p4-stderr | 10 +- .../p4_16_errors_outputs/parser-arg-first.p4 | 20 ++ .../parser-arg-frontend.p4 | 20 ++ testdata/p4_16_errors_outputs/parser-arg.p4 | 20 ++ .../p4_16_errors_outputs/parser-arg.p4-stderr | 72 ++++ .../p4_16_errors_outputs/parser-arg1-first.p4 | 25 ++ .../parser-arg1-frontend.p4 | 25 ++ testdata/p4_16_errors_outputs/parser-arg1.p4 | 25 ++ .../parser-arg1.p4-stderr | 4 + testdata/p4_16_samples/parser-arg.p4 | 41 +++ testdata/p4_16_samples/value-sets.p4 | 67 ++++ .../p4_16_samples_outputs/functors-midend.p4 | 4 +- .../p4_16_samples_outputs/functors2-midend.p4 | 4 +- .../p4_16_samples_outputs/functors3-midend.p4 | 4 +- .../p4_16_samples_outputs/functors5-midend.p4 | 4 +- .../p4_16_samples_outputs/functors6-midend.p4 | 4 +- .../p4_16_samples_outputs/functors7-midend.p4 | 4 +- .../p4_16_samples_outputs/functors8-midend.p4 | 4 +- .../p4_16_samples_outputs/functors9-midend.p4 | 4 +- .../p4_16_samples_outputs/parser-arg-first.p4 | 25 ++ .../parser-arg-frontend.p4 | 25 ++ .../parser-arg-midend.p4 | 17 + testdata/p4_16_samples_outputs/parser-arg.p4 | 25 ++ .../parser-arg.p4-stderr | 0 .../p4_16_samples_outputs/value-sets-first.p4 | 55 ++++ .../value-sets-frontend.p4 | 58 ++++ .../value-sets-midend.p4 | 58 ++++ testdata/p4_16_samples_outputs/value-sets.p4 | 55 ++++ .../value-sets.p4-stderr | 0 43 files changed, 965 insertions(+), 209 deletions(-) rename testdata/p4_16_errors/{packet_in-bmv2.p4 => parser-arg.p4} (63%) create mode 100644 testdata/p4_16_errors_outputs/packet_in-bmv2.p4 create mode 100644 testdata/p4_16_errors_outputs/parser-arg-first.p4 create mode 100644 testdata/p4_16_errors_outputs/parser-arg-frontend.p4 create mode 100644 testdata/p4_16_errors_outputs/parser-arg.p4 create mode 100644 testdata/p4_16_errors_outputs/parser-arg.p4-stderr create mode 100644 testdata/p4_16_errors_outputs/parser-arg1-first.p4 create mode 100644 testdata/p4_16_errors_outputs/parser-arg1-frontend.p4 create mode 100644 testdata/p4_16_errors_outputs/parser-arg1.p4 create mode 100644 testdata/p4_16_errors_outputs/parser-arg1.p4-stderr create mode 100644 testdata/p4_16_samples/parser-arg.p4 create mode 100644 testdata/p4_16_samples/value-sets.p4 create mode 100644 testdata/p4_16_samples_outputs/parser-arg-first.p4 create mode 100644 testdata/p4_16_samples_outputs/parser-arg-frontend.p4 create mode 100644 testdata/p4_16_samples_outputs/parser-arg-midend.p4 create mode 100644 testdata/p4_16_samples_outputs/parser-arg.p4 create mode 100644 testdata/p4_16_samples_outputs/parser-arg.p4-stderr create mode 100644 testdata/p4_16_samples_outputs/value-sets-first.p4 create mode 100644 testdata/p4_16_samples_outputs/value-sets-frontend.p4 create mode 100644 testdata/p4_16_samples_outputs/value-sets-midend.p4 create mode 100644 testdata/p4_16_samples_outputs/value-sets.p4 create mode 100644 testdata/p4_16_samples_outputs/value-sets.p4-stderr diff --git a/backends/bmv2/Makefile.am b/backends/bmv2/Makefile.am index 0af57f08879..a71de5c1e37 100644 --- a/backends/bmv2/Makefile.am +++ b/backends/bmv2/Makefile.am @@ -41,7 +41,9 @@ ir_DEF_FILES += $(srcdir)/backends/bmv2/bmv2.def CLEANFILES += bmv2tests.mk -bmv2tests.mk: $(srcdir)/testdata/p4_16_samples/*-bmv2.p4 $(srcdir)/testdata/p4_14_samples/*.p4 \ +bmv2tests.mk: $(srcdir)/testdata/p4_16_samples/*-bmv2.p4 \ + $(srcdir)/testdata/p4_16_errors/*-bmv2.p4 \ + $(srcdir)/testdata/p4_14_samples/*.p4 \ $(srcdir)/testdata/p4_14_samples/switch_*/switch.p4 \ $(srcdir)/testdata/p4_16_samples $(srcdir)/testdata/p4_14_samples @$(GENTESTS) $(srcdir) bmv2 $(srcdir)/backends/bmv2/run-bmv2-test.py $^ >$@ diff --git a/backends/bmv2/jsonconverter.cpp b/backends/bmv2/jsonconverter.cpp index 6c29132d0c2..bc73a8eda97 100644 --- a/backends/bmv2/jsonconverter.cpp +++ b/backends/bmv2/jsonconverter.cpp @@ -1868,7 +1868,10 @@ void JsonConverter::addTypesAndInstances(const IR::Type_StructLike* type, bool m // Done elsewhere continue; } else { - BUG("%1%: Unexpected header type", ft); + if (!meta) + ::error("Type %1% should only contain headers or stacks", type); + else + BUG("%1%: Unhandled type for %2%", ft, f); } } } diff --git a/backends/bmv2/run-bmv2-test.py b/backends/bmv2/run-bmv2-test.py index e97626ebb90..ee8444cf33e 100755 --- a/backends/bmv2/run-bmv2-test.py +++ b/backends/bmv2/run-bmv2-test.py @@ -296,9 +296,6 @@ def process_file(options, argv): else: result = SUCCESS - #if result == SUCCESS: - # result = check_generated_files(options, tmpdir, expected_dirname); - if result == SUCCESS: result = run_model(options, tmpdir, jsonfile); diff --git a/backends/p4test/midend.cpp b/backends/p4test/midend.cpp index d1f057e2300..ae22162ff74 100644 --- a/backends/p4test/midend.cpp +++ b/backends/p4test/midend.cpp @@ -59,6 +59,7 @@ MidEnd::MidEnd(CompilerOptions& options) { new P4::MoveConstructors(&refMap), new P4::RemoveAllUnusedDeclarations(&refMap), new P4::ClearTypeMap(&typeMap), + new P4::SpecializeAll(&refMap, &typeMap), evaluator, new VisitFunctor([evaluator](const IR::Node *root) -> const IR::Node * { auto toplevel = evaluator->getToplevelBlock(); @@ -68,7 +69,6 @@ MidEnd::MidEnd(CompilerOptions& options) { return root; }), new P4::Inline(&refMap, &typeMap, evaluator), new P4::InlineActions(&refMap, &typeMap), - new P4::SpecializeAll(&refMap, &typeMap), // Parser loop unrolling: TODO // new P4::ParsersUnroll(true, &refMap, &typeMap), new P4::LocalizeAllActions(&refMap), diff --git a/frontends/p4/def_use.cpp b/frontends/p4/def_use.cpp index f4d1f73c3da..afe80842651 100644 --- a/frontends/p4/def_use.cpp +++ b/frontends/p4/def_use.cpp @@ -285,7 +285,8 @@ bool Definitions::operator==(const Definitions& other) const { ////////////////////////////////////////////////////////////////////////////////////////////// // ComputeWriteSet implementation -// This assumes that all variable declarations have been pushed to the top +// This assumes that all variable declarations have been pushed to the top. +// We could remove this constraint if we also scanned variable declaration initializers. void ComputeWriteSet::initialize(const IR::IApply* block, const IR::IndexedVector* locals, ProgramPoint startPoint) { diff --git a/frontends/p4/p4-parse.ypp b/frontends/p4/p4-parse.ypp index 0e6fc7829c7..260b3fd1133 100644 --- a/frontends/p4/p4-parse.ypp +++ b/frontends/p4/p4-parse.ypp @@ -137,7 +137,7 @@ static int yylex(); %type optAnnotations %type annotations %type annotation -%type parameterList nonEmptyParameterList optConstructorParameters +%type parameterList nonEmptyParameterList optCompileParameters %type argumentList nonEmptyArgList expressionList simpleExpressionList tupleKeysetExpression %type identifierList @@ -330,7 +330,7 @@ objDeclaration | instantiation { $$ = $1; } ; -optConstructorParameters +optCompileParameters : /* empty */ { $$ = new IR::IndexedVector(); } | '(' parameterList ')' { $$ = $2; } ; @@ -356,7 +356,7 @@ nonEmptyRelativePathPrefix /**************************** PARSER ******************************/ parserDeclaration - : parserTypeDeclaration optConstructorParameters + : parserTypeDeclaration optCompileParameters '{' parserLocalElements parserStates '}' { structure.pop(); auto pl = new IR::ParameterList(@2, $2); @@ -456,7 +456,7 @@ simpleKeysetExpression /*************************** CONTROL ************************/ controlDeclaration - : controlTypeDeclaration optConstructorParameters + : controlTypeDeclaration optCompileParameters '{' controlLocalDeclarations APPLY controlBody '}' { structure.pop(); auto pl = new IR::ParameterList(@2, $2); diff --git a/frontends/p4/typeChecking/typeChecker.cpp b/frontends/p4/typeChecking/typeChecker.cpp index 318477b0373..d7b1796b60e 100644 --- a/frontends/p4/typeChecking/typeChecker.cpp +++ b/frontends/p4/typeChecking/typeChecker.cpp @@ -218,15 +218,24 @@ const IR::TypeParameters* TypeInference::canonicalize(const IR::TypeParameters* return params; } -bool TypeInference::checkParameters(const IR::ParameterList* paramList) const { +bool TypeInference::checkParameters(const IR::ParameterList* paramList, bool forbidModules) const { for (auto p : *paramList->parameters) { + auto type = getType(p->type); if (p->direction != IR::Direction::None) { - auto type = getType(p->type); + CHECK_NULL(type); if (type->is()) { ::error("%1%: a parameter with an extern type cannot have a direction", p); return false; } } + if (forbidModules && (type->is() || + type->is() || + type->is() || + type->is() || + type->is())) { + ::error("%1%: parameter cannot have type %2%", p, type); + return false; + } } return true; } @@ -306,7 +315,7 @@ const IR::Type* TypeInference::canonicalize(const IR::Type* type) { auto tps = canonicalize(tp->typeParameters); if (pl == nullptr || tps == nullptr) return nullptr; - if (!checkParameters(pl)) + if (!checkParameters(pl, true)) return nullptr; if (pl != tp->applyParams || tps != tp->typeParameters) return new IR::Type_Parser(tp->srcInfo, tp->name, tp->annotations, tps, pl); @@ -317,7 +326,7 @@ const IR::Type* TypeInference::canonicalize(const IR::Type* type) { auto tps = canonicalize(tp->typeParameters); if (pl == nullptr || tps == nullptr) return nullptr; - if (!checkParameters(pl)) + if (!checkParameters(pl, true)) return nullptr; if (pl != tp->applyParams || tps != tp->typeParameters) return new IR::Type_Control(tp->srcInfo, tp->name, tp->annotations, tps, pl); diff --git a/frontends/p4/typeChecking/typeChecker.h b/frontends/p4/typeChecking/typeChecker.h index f78303f4ced..920ff4e310c 100644 --- a/frontends/p4/typeChecking/typeChecker.h +++ b/frontends/p4/typeChecking/typeChecker.h @@ -147,7 +147,7 @@ class TypeInference : public Transform { checkExternConstructor(const IR::Node* errorPosition, const IR::Type_Extern* ext, const IR::Vector *arguments); - bool checkParameters(const IR::ParameterList* paramList) const; + bool checkParameters(const IR::ParameterList* paramList, bool forbidModules = false) const; ////////////////////////////////////////////////////////////// diff --git a/ir/base.def b/ir/base.def index efa45e3c6bf..2719c93f052 100644 --- a/ir/base.def +++ b/ir/base.def @@ -58,7 +58,7 @@ interface ITypeVar { } // Implemented by P4Parser, P4Control and Type_Package -interface IContainer : IMayBeGenericType { +interface IContainer : IMayBeGenericType, IDeclaration { // The type of the constructor as a method virtual Type_Method getConstructorMethodType() const = 0; virtual ParameterList getConstructorParameters() const = 0; diff --git a/ir/type.def b/ir/type.def index ad888ecfa94..104dc4491de 100644 --- a/ir/type.def +++ b/ir/type.def @@ -98,6 +98,7 @@ class ParameterList : ISimpleNamespace { Util::Enumerator* getDeclarations() const override { return parameters->getDeclarations(); } size_t size() const { return parameters->size(); } + bool empty() const { return size() == 0; } IR::Parameter getParameter(cstring name) const { return parameters->getDeclaration(name); } IR::Parameter getParameter(unsigned index) const { diff --git a/midend/specialize.cpp b/midend/specialize.cpp index 81af029c160..dd80b1581e4 100644 --- a/midend/specialize.cpp +++ b/midend/specialize.cpp @@ -26,50 +26,113 @@ limitations under the License. namespace P4 { -std::vector* -SpecializationMap::getSpecializations(const IR::IContainer* decl) { - auto result = new std::vector(); - for (auto n : newName) { - auto invocation = n.first; - SpecializationInfo* si = nullptr; - if (invocation->is()) { - auto cce = invocation->to(); - auto cc = ConstructorCall::resolve(cce, refMap, typeMap); - auto ccc = cc->to(); - CHECK_NULL(ccc); - if (ccc->container != decl) - continue; - si = new SpecializationInfo(); - si->constructorArguments = cce->arguments; - si->typeArguments = ccc->typeArguments; - } else { - auto di = invocation->to(); - const IR::Type_Name* type; - const IR::Vector* typeArgs; - if (di->type->is()) { - auto ts = di->type->to(); - type = ts->baseType; - typeArgs = ts->arguments; - } else { - type = di->type->to(); - typeArgs = new IR::Vector(); - } - CHECK_NULL(type); - auto d = refMap->getDeclaration(type->path, true); - if (d->getNode() != decl->getNode()) - continue; - si = new SpecializationInfo(); - si->constructorArguments = di->arguments; - si->typeArguments = typeArgs; - } +const IR::Type_Declaration* SpecializationInfo::synthesize(ReferenceMap* refMap) const { + TypeVariableSubstitution tvs; + ParameterSubstitution subst; + + subst.populate(specialized->getConstructorParameters(), constructorArguments); + tvs.setBindings(invocation, specialized->getTypeParameters(), typeArguments); + SubstituteParameters sp(refMap, &subst, &tvs); + auto clone = specialized->getNode()->apply(sp); + CHECK_NULL(clone); + const IR::Type_Declaration* result = nullptr; + if (clone->is()) { + auto parser = clone->to(); + auto newtype = new IR::Type_Parser(name, parser->type->annotations, + new IR::TypeParameters(), + parser->type->applyParams); + declarations->append(*parser->parserLocals); + result = new IR::P4Parser(name, newtype, new IR::ParameterList(), + declarations, parser->states); + } else if (clone->is()) { + auto control = clone->to(); + auto newtype = new IR::Type_Control(name, control->type->annotations, + new IR::TypeParameters(), + control->type->applyParams); + declarations->append(*control->controlLocals); + result = new IR::P4Control(name, newtype, new IR::ParameterList(), + declarations, control->body); + + } else { + BUG("%1%: unexpected type", specialized); + } + LOG1("Created " << result); + return result; +} + +const IR::Expression* SpecializationMap::convertArgument( + const IR::Expression* arg, SpecializationInfo* spec) { + if (arg->is()) { + auto cce = arg->to(); + cstring nName = refMap->newName("inst"); + auto decl = new IR::Declaration_Instance( + Util::SourceInfo(), IR::ID(nName), IR::Annotations::empty, + cce->constructedType, cce->arguments, nullptr); + spec->declarations->push_back(decl); + auto path = new IR::PathExpression(IR::ID(nName)); + return path; + } else { + return arg; + } +} + +void SpecializationMap::addSpecialization( + const IR::ConstructorCallExpression* invocation, const IR::IContainer* cont, + const IR::Node* insertion) { + auto spec = new SpecializationInfo(invocation, cont, insertion); + auto declaration = cont->to(); + CHECK_NULL(declaration); + spec->name = refMap->newName(declaration->getName()); + auto cc = ConstructorCall::resolve(invocation, refMap, typeMap); + auto ccc = cc->to(); + CHECK_NULL(ccc); + spec->constructorArguments = new IR::Vector(); + for (auto ca : *invocation->arguments) { + auto arg = convertArgument(ca, spec); + spec->constructorArguments->push_back(arg); + } + spec->typeArguments = ccc->typeArguments; + specializations.emplace(invocation, spec); +} - if (si == nullptr) continue; - si->name = n.second; - si->invocation = invocation; - result->push_back(si); +void SpecializationMap::addSpecialization( + const IR::Declaration_Instance* invocation, const IR::IContainer* cont, + const IR::Node* insertion) { + auto spec = new SpecializationInfo(invocation, cont, insertion); + auto declaration = cont->to(); + CHECK_NULL(declaration); + spec->name = refMap->newName(declaration->getName()); + const IR::Type_Name* type; + const IR::Vector* typeArgs; + if (invocation->type->is()) { + auto ts = invocation->type->to(); + type = ts->baseType; + typeArgs = ts->arguments; + } else { + type = invocation->type->to(); + typeArgs = new IR::Vector(); + } + spec->typeArguments = typeArgs; + CHECK_NULL(type); + for (auto ca : *invocation->arguments) { + auto arg = convertArgument(ca, spec); + spec->constructorArguments->push_back(arg); + } + specializations.emplace(invocation, spec); +} + +IR::Vector* +SpecializationMap::getSpecializations(const IR::Node* insertionPoint) const { + IR::Vector* result = nullptr; + for (auto s : specializations) { + if (s.second->insertBefore == insertionPoint) { + if (result == nullptr) + result = new IR::Vector(); + auto node = s.second->synthesize(refMap); + LOG1("Will insert " << node << " before " << insertionPoint); + result->push_back(node); + } } - if (result->empty()) - return nullptr; return result; } @@ -107,40 +170,53 @@ bool FindSpecializations::isSimpleConstant(const IR::Expression* expr) const { return false; return true; } - auto ei = EnumInstance::resolve(expr, typeMap); + auto ei = EnumInstance::resolve(expr, specMap->typeMap); if (ei != nullptr) return true; + if (expr->is()) { + auto cce = expr->to(); + for (auto e : *cce->arguments) + if (!isSimpleConstant(e)) + return false; + return true; + } return false; } +bool FindSpecializations::noParameters(const IR::IContainer* container) { + return container->getTypeParameters()->empty() && + container->getConstructorParameters()->empty(); +} + +const IR::Node* FindSpecializations::findInsertionPoint() const { + // Find location where the specialization is to be inserted. + // This can be before a Parser, Control or a toplevel instance declaration + const IR::Node* insert = findContext(); + if (insert != nullptr) + return insert; + insert = findContext(); + if (insert != nullptr) + return insert; + insert = findContext(); + return insert; +} + void FindSpecializations::postorder(const IR::ConstructorCallExpression* expression) { if (expression->arguments->size() == 0 && !expression->constructedType->is()) return; // nothing to specialize - auto type = typeMap->getType(expression, true); - if (type->is()) { - auto ts = type->to(); - IsConcreteType ct(typeMap); - if (!ct.isConcrete(ts)) - return; // no point in specializing if arguments have type variables - type = ts->baseType; - } - if (type->is()) - type = type->to()->type; - else if (type->is()) - type = type->to()->type; - if (!type->is() && !type->is()) + auto cc = ConstructorCall::resolve(expression, specMap->refMap, specMap->typeMap); + if (!cc->is()) return; for (auto arg : *expression->arguments) { if (!isSimpleConstant(arg)) return; } - auto archtype = type->to(); - cstring newName = refMap->newName(archtype->getName()); - LOG1("Will specialize " << expression << " into " << newName); - specMap->newName.emplace(expression, newName); + auto insert = findInsertionPoint(); + auto decl = cc->to()->container; + specMap->addSpecialization(expression, decl, insert); } void FindSpecializations::postorder(const IR::Declaration_Instance* decl) { @@ -148,111 +224,74 @@ void FindSpecializations::postorder(const IR::Declaration_Instance* decl) { !decl->type->is()) return; - auto type = typeMap->getType(decl, true); + auto type = specMap->typeMap->getType(decl, true); if (type->is()) { auto ts = type->to(); - IsConcreteType ct(typeMap); + IsConcreteType ct(specMap->typeMap); if (!ct.isConcrete(ts)) return; // no point in specializing if arguments have type variables type = ts->baseType; } - if (!type->is() && !type->is()) - return; for (auto arg : *decl->arguments) { if (!isSimpleConstant(arg)) return; } - auto archtype = type->to(); - cstring newName = refMap->newName(archtype->getName()); - LOG1("Will specialize " << decl << " into " << newName); - specMap->newName.emplace(decl, newName); -} - -const IR::Node* Specialize::postorder(IR::P4Parser* parser) { - auto orig = getOriginal(); - auto specs = specMap->getSpecializations(orig); - if (specs == nullptr) - return parser; - - auto result = new IR::IndexedVector(); - for (auto s : *specs) { - TypeVariableSubstitution tvs; - ParameterSubstitution subst; - - subst.populate(parser->getConstructorParameters(), s->constructorArguments); - tvs.setBindings(s->invocation, parser->getTypeParameters(), s->typeArguments); - SubstituteParameters sp(refMap, &subst, &tvs); - auto clone = orig->apply(sp)->to(); - CHECK_NULL(clone); - auto newtype = new IR::Type_Parser(s->name, clone->type->annotations, - new IR::TypeParameters(), - clone->type->applyParams); - auto prs = new IR::P4Parser(s->name, newtype, new IR::ParameterList(), - clone->parserLocals, clone->states); - LOG1("Created " << prs << " for " << parser); - result->push_back(prs); + const IR::Type_Name *contDecl; + if (decl->type->is()) { + contDecl = decl->type->to(); + } else { + BUG_CHECK(decl->type->is(), "%1%: unexpected type", decl->type); + contDecl = decl->type->to()->baseType; } - result->push_back(parser); - return result; + auto cont = specMap->refMap->getDeclaration(contDecl->path, true); + if (!cont->is() && !cont->is()) + return; + auto insert = findInsertionPoint(); + if (insert == nullptr) + insert = decl; + specMap->addSpecialization(decl, cont->to(), insert); } -const IR::Node* Specialize::postorder(IR::P4Control* control) { - auto orig = getOriginal(); - auto specs = specMap->getSpecializations(orig); +const IR::Node* Specialize::instantiate(const IR::Node* node) { + auto specs = specMap->getSpecializations(getOriginal()); if (specs == nullptr) - return control; - - auto result = new IR::IndexedVector(); - for (auto s : *specs) { - TypeVariableSubstitution tvs; - ParameterSubstitution subst; - - subst.populate(control->getConstructorParameters(), s->constructorArguments); - tvs.setBindings(s->invocation, control->getTypeParameters(), s->typeArguments); - SubstituteParameters sp(refMap, &subst, &tvs); - auto clone = orig->apply(sp)->to(); - CHECK_NULL(clone); - auto newtype = new IR::Type_Control(s->name, clone->type->annotations, - new IR::TypeParameters(), - clone->type->applyParams); - auto ctrl = new IR::P4Control(s->name, newtype, new IR::ParameterList(), - clone->controlLocals, clone->body); - LOG1("Created " << ctrl << " for " << control); - result->push_back(ctrl); - } - result->push_back(control); // maybe it's still needed - return result; + return node; + LOG1(specs->size() << " instantiations before " << node); + specs->push_back(node); + return specs; } const IR::Node* Specialize::postorder(IR::ConstructorCallExpression* expression) { - if (!specMap->isSpecialized(getOriginal())) + auto name = specMap->getName(getOriginal()); + if (name.isNullOrEmpty()) return expression; - cstring newName = specMap->get(getOriginal()); - auto typeRef = new IR::Type_Name(IR::ID(newName)); + auto typeRef = new IR::Type_Name(IR::ID(name)); auto result = new IR::ConstructorCallExpression(typeRef, new IR::Vector()); LOG1("Replaced " << expression << " with " << result); return result; } const IR::Node* Specialize::postorder(IR::Declaration_Instance* decl) { - if (!specMap->isSpecialized(getOriginal())) - return decl; - cstring newName = specMap->get(getOriginal()); - auto typeRef = new IR::Type_Name(IR::ID(newName)); - auto result = new IR::Declaration_Instance( - decl->name, decl->annotations, typeRef, new IR::Vector(), - decl->initializer); - LOG1("Replaced " << decl << " with " << result); - return result; + // replace instance with invocation of new type + const IR::Node* replacement = decl; + auto name = specMap->getName(getOriginal()); + if (!name.isNullOrEmpty()) { + auto typeRef = new IR::Type_Name(IR::ID(name)); + replacement = new IR::Declaration_Instance( + decl->name, decl->annotations, typeRef, new IR::Vector(), + decl->initializer); + LOG1("Replaced " << decl << " with " << replacement); + } + + return instantiate(replacement); } -SpecializeAll::SpecializeAll(ReferenceMap* refMap, TypeMap* typeMap) : - PassRepeated({}) { +SpecializeAll::SpecializeAll(ReferenceMap* refMap, TypeMap* typeMap) : PassRepeated({}) { passes.emplace_back(new ConstantFolding(refMap, typeMap)); passes.emplace_back(new TypeChecking(refMap, typeMap)); - passes.emplace_back(new FindSpecializations(refMap, typeMap, &specMap)); - passes.emplace_back(new Specialize(refMap, &specMap)); + passes.emplace_back(new FindSpecializations(&specMap)); + passes.emplace_back(new Specialize(&specMap)); passes.emplace_back(new RemoveAllUnusedDeclarations(refMap)); specMap.refMap = refMap; specMap.typeMap = typeMap; diff --git a/midend/specialize.h b/midend/specialize.h index abf85626e4c..27931805cd9 100644 --- a/midend/specialize.h +++ b/midend/specialize.h @@ -34,54 +34,97 @@ namespace P4 { // A different specialization is made for each constructor invocation // and Declaration_Instance. +// Describes how a parser or control is specialized: struct SpecializationInfo { - const IR::Vector* typeArguments; - const IR::Vector* constructorArguments; - const IR::Node* invocation; + // Name to use for specialized object cstring name; + // Actual parser or control that is being specialized + const IR::IContainer* specialized; + // values to substitute for type arguments + const IR::Vector* typeArguments; + // values to substitute for constructor arguments + IR::Vector* constructorArguments; + // declarations to insert in the list of locals + IR::IndexedVector* declarations; + // Invocation which causes this specialization + const IR::Node* invocation; + // Where in the program should the specialization be inserted + const IR::Node* insertBefore; + + SpecializationInfo(const IR::Node* invocation, const IR::IContainer* cont, + const IR::Node* insertion) : + specialized(cont), typeArguments(nullptr), + constructorArguments(new IR::Vector()), + declarations(new IR::IndexedVector()), + invocation(invocation), insertBefore(insertion) + { CHECK_NULL(cont); CHECK_NULL(invocation); CHECK_NULL(insertion); } + const IR::Type_Declaration* synthesize(ReferenceMap* refMap) const; }; -struct SpecializationMap { +class SpecializationMap { + // map invocation to specialization + std::map specializations; + const IR::Expression* convertArgument(const IR::Expression* arg, SpecializationInfo* info); + + public: TypeMap* typeMap; ReferenceMap* refMap; - // For each ConstructorCallExpression or Declaration_Instance - // we allocate a new name - std::map newName; - std::vector* getSpecializations(const IR::IContainer* decl); - bool isSpecialized(const IR::Node* node) const - { CHECK_NULL(node); return newName.find(node) != newName.end(); } - cstring get(const IR::Node* node) const - { CHECK_NULL(node); return ::get(newName, node); } - void clear() { newName.clear(); } + void addSpecialization( + const IR::ConstructorCallExpression* invocation, + const IR::IContainer* container, // actual object specialized + const IR::Node* insertion); // where the specialization should be inserted + void addSpecialization( + const IR::Declaration_Instance* invocation, + const IR::IContainer* container, // actual object specialized + const IR::Node* insertion); // where the specialization should be inserted + IR::Vector* getSpecializations(const IR::Node* insertion) const; + cstring getName(const IR::Node* insertion) const { + auto s = ::get(specializations, insertion); + if (s == nullptr) + return nullptr; + return s->name; + } + void clear() { specializations.clear(); } }; class FindSpecializations : public Inspector { - ReferenceMap* refMap; - TypeMap* typeMap; SpecializationMap* specMap; + public: - FindSpecializations(ReferenceMap* refMap, TypeMap* typeMap, SpecializationMap* specMap) : - refMap(refMap), typeMap(typeMap), specMap(specMap) { - CHECK_NULL(refMap); CHECK_NULL(typeMap); CHECK_NULL(specMap); - setName("FindSpecializations"); } + explicit FindSpecializations(SpecializationMap* specMap) : specMap(specMap) { + CHECK_NULL(specMap); + setName("FindSpecializations"); + } + const IR::Node* findInsertionPoint() const; bool isSimpleConstant(const IR::Expression* expression) const; Visitor::profile_t init_apply(const IR::Node* node) override { specMap->clear(); return Inspector::init_apply(node); } + // True if this container does not have constructor or type + // parameters i.e., we can look inside for invocations to + // specialize. + bool noParameters(const IR::IContainer* container); + + bool preorder(const IR::P4Parser* parser) override + { return noParameters(parser); } + bool preorder(const IR::P4Control* control) override + { return noParameters(control); } void postorder(const IR::ConstructorCallExpression* expression) override; void postorder(const IR::Declaration_Instance* decl) override; }; class Specialize : public Transform { - ReferenceMap* refMap; SpecializationMap* specMap; + const IR::Node* instantiate(const IR::Node* node); public: - Specialize(ReferenceMap* refMap, SpecializationMap* specMap) : refMap(refMap), specMap(specMap) - { CHECK_NULL(refMap); CHECK_NULL(specMap); setName("Specialize"); } - const IR::Node* postorder(IR::P4Parser* parser) override; - const IR::Node* postorder(IR::P4Control* control) override; + explicit Specialize(SpecializationMap* specMap) : specMap(specMap) + { CHECK_NULL(specMap); setName("Specialize"); } + const IR::Node* postorder(IR::P4Parser* parser) override + { return instantiate(parser); } + const IR::Node* postorder(IR::P4Control* control) override + { return instantiate(control); } const IR::Node* postorder(IR::ConstructorCallExpression* expression) override; - const IR::Node* postorder(IR::Declaration_Instance* decl) override; + const IR::Node* postorder(IR::Declaration_Instance*) override; }; class SpecializeAll : public PassRepeated { diff --git a/testdata/p4_16_errors/packet_in-bmv2.p4 b/testdata/p4_16_errors/parser-arg.p4 similarity index 63% rename from testdata/p4_16_errors/packet_in-bmv2.p4 rename to testdata/p4_16_errors/parser-arg.p4 index b659d319434..430d773240b 100644 --- a/testdata/p4_16_errors/packet_in-bmv2.p4 +++ b/testdata/p4_16_errors/parser-arg.p4 @@ -14,20 +14,25 @@ See the License for the specific language governing permissions and limitations under the License. */ -header H { - bit<32> f; +parser Parser(); +parser MyParser(Parser p); +package Package(MyParser p1, MyParser p2); + +parser Parser1(Parser p) { + state start { + p.apply(); + transition accept; + } } -control c() { - packet_in() p; - H h; - - apply { - p.extract(h); +parser Parser2(Parser p) { + state start { + p.apply(); + transition accept; } } -control proto(); -package top(proto _p); +Parser1() p1; +Parser2() p2; -top(c()) main; +Package(p1,p2) main; diff --git a/testdata/p4_16_errors_outputs/packet_in-bmv2.p4 b/testdata/p4_16_errors_outputs/packet_in-bmv2.p4 new file mode 100644 index 00000000000..7a364084284 --- /dev/null +++ b/testdata/p4_16_errors_outputs/packet_in-bmv2.p4 @@ -0,0 +1,17 @@ +#include + +header H { + bit<32> f; +} + +control c() { + packet_in() p; + H h; + apply { + p.extract(h); + } +} + +control proto(); +package top(proto _p); +top(c()) main; diff --git a/testdata/p4_16_errors_outputs/packet_in-bmv2.p4-stderr b/testdata/p4_16_errors_outputs/packet_in-bmv2.p4-stderr index fecf38aa809..f8221bc0a3c 100644 --- a/testdata/p4_16_errors_outputs/packet_in-bmv2.p4-stderr +++ b/testdata/p4_16_errors_outputs/packet_in-bmv2.p4-stderr @@ -1,4 +1,6 @@ -../testdata/p4_16_errors/packet_in-bmv2.p4(22):syntax error, unexpected IDENTIFIER, expecting ACTION or CONST or TABLE - packet_in - ^ -error: 1 errors encountered, aborting compilation +../testdata/p4_16_errors/packet_in-bmv2.p4(24): error: p: type packet_in has no constructor with 0 arguments + packet_in() p; + ^ +/home/mbudiu/git/p4c/p4include/core.p4(40) +extern packet_in { + ^^^^^^^^^ diff --git a/testdata/p4_16_errors_outputs/parser-arg-first.p4 b/testdata/p4_16_errors_outputs/parser-arg-first.p4 new file mode 100644 index 00000000000..1db6fd198ce --- /dev/null +++ b/testdata/p4_16_errors_outputs/parser-arg-first.p4 @@ -0,0 +1,20 @@ +parser Parser(); +parser MyParser(Parser p); +package Package(MyParser p1, MyParser p2); +parser Parser1(Parser p) { + state start { + p.apply(); + transition accept; + } +} + +parser Parser2(Parser p) { + state start { + p.apply(); + transition accept; + } +} + +Parser1() p1; +Parser2() p2; +Package(p1, p2) main; diff --git a/testdata/p4_16_errors_outputs/parser-arg-frontend.p4 b/testdata/p4_16_errors_outputs/parser-arg-frontend.p4 new file mode 100644 index 00000000000..1db6fd198ce --- /dev/null +++ b/testdata/p4_16_errors_outputs/parser-arg-frontend.p4 @@ -0,0 +1,20 @@ +parser Parser(); +parser MyParser(Parser p); +package Package(MyParser p1, MyParser p2); +parser Parser1(Parser p) { + state start { + p.apply(); + transition accept; + } +} + +parser Parser2(Parser p) { + state start { + p.apply(); + transition accept; + } +} + +Parser1() p1; +Parser2() p2; +Package(p1, p2) main; diff --git a/testdata/p4_16_errors_outputs/parser-arg.p4 b/testdata/p4_16_errors_outputs/parser-arg.p4 new file mode 100644 index 00000000000..1db6fd198ce --- /dev/null +++ b/testdata/p4_16_errors_outputs/parser-arg.p4 @@ -0,0 +1,20 @@ +parser Parser(); +parser MyParser(Parser p); +package Package(MyParser p1, MyParser p2); +parser Parser1(Parser p) { + state start { + p.apply(); + transition accept; + } +} + +parser Parser2(Parser p) { + state start { + p.apply(); + transition accept; + } +} + +Parser1() p1; +Parser2() p2; +Package(p1, p2) main; diff --git a/testdata/p4_16_errors_outputs/parser-arg.p4-stderr b/testdata/p4_16_errors_outputs/parser-arg.p4-stderr new file mode 100644 index 00000000000..5ec20316d03 --- /dev/null +++ b/testdata/p4_16_errors_outputs/parser-arg.p4-stderr @@ -0,0 +1,72 @@ +../testdata/p4_16_errors/parser-arg.p4(18): error: p: parameter cannot have type parser Parser +parser MyParser(Parser p); + ^ +../testdata/p4_16_errors/parser-arg.p4(17) +parser Parser(); + ^^^^^^ +../testdata/p4_16_errors/parser-arg.p4(18): error: Could not find type of parser MyParser +parser MyParser(Parser p); + ^^^^^^^^ +../testdata/p4_16_errors/parser-arg.p4(19): error: Could not find type of MyParser +package Package(MyParser p1, MyParser p2); + ^^^^^^^^ +../testdata/p4_16_errors/parser-arg.p4(18): error: Could not find type of parser MyParser +parser MyParser(Parser p); + ^^^^^^^^ +../testdata/p4_16_errors/parser-arg.p4(19): error: Could not find type of MyParser +package Package(MyParser p1, MyParser p2); + ^^^^^^^^ +../testdata/p4_16_errors/parser-arg.p4(21): error: p: parameter cannot have type parser Parser +parser Parser1(Parser p) { + ^ +../testdata/p4_16_errors/parser-arg.p4(17) +parser Parser(); + ^^^^^^ +../testdata/p4_16_errors/parser-arg.p4(21): error: p: parameter cannot have type parser Parser +parser Parser1(Parser p) { + ^ +../testdata/p4_16_errors/parser-arg.p4(17) +parser Parser(); + ^^^^^^ +../testdata/p4_16_errors/parser-arg.p4(28): error: p: parameter cannot have type parser Parser +parser Parser2(Parser p) { + ^ +../testdata/p4_16_errors/parser-arg.p4(17) +parser Parser(); + ^^^^^^ +../testdata/p4_16_errors/parser-arg.p4(28): error: p: parameter cannot have type parser Parser +parser Parser2(Parser p) { + ^ +../testdata/p4_16_errors/parser-arg.p4(17) +parser Parser(); + ^^^^^^ +../testdata/p4_16_errors/parser-arg.p4(21): error: Could not find type of parser Parser1 +parser Parser1(Parser p) { + ^^^^^^^ +../testdata/p4_16_errors/parser-arg.p4(21): error: Could not find type of parser Parser1 +parser Parser1(Parser p) { + ^^^^^^^ +../testdata/p4_16_errors/parser-arg.p4(28): error: Could not find type of parser Parser2 +parser Parser2(Parser p) { + ^^^^^^^ +../testdata/p4_16_errors/parser-arg.p4(28): error: Could not find type of parser Parser2 +parser Parser2(Parser p) { + ^^^^^^^ +../testdata/p4_16_errors/parser-arg.p4(19): error: Could not find type of package Package +package Package(MyParser p1, MyParser p2); + ^^^^^^^ +../testdata/p4_16_errors/parser-arg.p4(35): error: Could not find type of p1 +Parser1() p1; + ^^ +../testdata/p4_16_errors/parser-arg.p4(36): error: Could not find type of p2 +Parser2() p2; + ^^ +../testdata/p4_16_errors/parser-arg.p4(19): error: Could not find type of package Package +package Package(MyParser p1, MyParser p2); + ^^^^^^^ +../testdata/p4_16_errors/parser-arg.p4(35): error: Could not find type of p1 +Parser1() p1; + ^^ +../testdata/p4_16_errors/parser-arg.p4(36): error: Could not find type of p2 +Parser2() p2; + ^^ diff --git a/testdata/p4_16_errors_outputs/parser-arg1-first.p4 b/testdata/p4_16_errors_outputs/parser-arg1-first.p4 new file mode 100644 index 00000000000..8a5a59b86fc --- /dev/null +++ b/testdata/p4_16_errors_outputs/parser-arg1-first.p4 @@ -0,0 +1,25 @@ +parser Parser(); +package Package(Parser p1, Parser p2); +parser Parser1()(Parser p) { + state start { + p.apply(); + transition accept; + } +} + +parser Parser2()(Parser p) { + state start { + p.apply(); + transition accept; + } +} + +parser Inside() { + state start { + transition accept; + } +} + +Parser1(Inside()) p1; +Parser2(Inside()) p2; +Package(p1, p2) main; diff --git a/testdata/p4_16_errors_outputs/parser-arg1-frontend.p4 b/testdata/p4_16_errors_outputs/parser-arg1-frontend.p4 new file mode 100644 index 00000000000..8a5a59b86fc --- /dev/null +++ b/testdata/p4_16_errors_outputs/parser-arg1-frontend.p4 @@ -0,0 +1,25 @@ +parser Parser(); +package Package(Parser p1, Parser p2); +parser Parser1()(Parser p) { + state start { + p.apply(); + transition accept; + } +} + +parser Parser2()(Parser p) { + state start { + p.apply(); + transition accept; + } +} + +parser Inside() { + state start { + transition accept; + } +} + +Parser1(Inside()) p1; +Parser2(Inside()) p2; +Package(p1, p2) main; diff --git a/testdata/p4_16_errors_outputs/parser-arg1.p4 b/testdata/p4_16_errors_outputs/parser-arg1.p4 new file mode 100644 index 00000000000..8a5a59b86fc --- /dev/null +++ b/testdata/p4_16_errors_outputs/parser-arg1.p4 @@ -0,0 +1,25 @@ +parser Parser(); +package Package(Parser p1, Parser p2); +parser Parser1()(Parser p) { + state start { + p.apply(); + transition accept; + } +} + +parser Parser2()(Parser p) { + state start { + p.apply(); + transition accept; + } +} + +parser Inside() { + state start { + transition accept; + } +} + +Parser1(Inside()) p1; +Parser2(Inside()) p2; +Package(p1, p2) main; diff --git a/testdata/p4_16_errors_outputs/parser-arg1.p4-stderr b/testdata/p4_16_errors_outputs/parser-arg1.p4-stderr new file mode 100644 index 00000000000..10b565f5f77 --- /dev/null +++ b/testdata/p4_16_errors_outputs/parser-arg1.p4-stderr @@ -0,0 +1,4 @@ +terminate called after throwing an instance of 'Util::CompilerBug' + what(): COMPILER BUG: ../midend/specialize.cpp:40 +Not handled + diff --git a/testdata/p4_16_samples/parser-arg.p4 b/testdata/p4_16_samples/parser-arg.p4 new file mode 100644 index 00000000000..abbb11266f7 --- /dev/null +++ b/testdata/p4_16_samples/parser-arg.p4 @@ -0,0 +1,41 @@ +/* +Copyright 2016 VMware, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +parser Parser(); +package Package(Parser p1, Parser p2); + +parser Parser1()(Parser p) { + state start { + p.apply(); + transition accept; + } +} + +parser Parser2()(Parser p) { + state start { + p.apply(); + transition accept; + } +} + +parser Inside() { + state start { transition accept; } +} + +Parser1(Inside()) p1; +Parser2(Inside()) p2; + +Package(p1,p2) main; diff --git a/testdata/p4_16_samples/value-sets.p4 b/testdata/p4_16_samples/value-sets.p4 new file mode 100644 index 00000000000..7fb5af71f7b --- /dev/null +++ b/testdata/p4_16_samples/value-sets.p4 @@ -0,0 +1,67 @@ +/* +Copyright 2016 VMware, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#include + +header Ethernet_h { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +struct Parsed_packet { + Ethernet_h ethernet; +} + +extern ValueSet { + ValueSet(bit<32> size); + bit<8> index(in bit<16> proto); +} + +#define ETH_KIND_TRILL 1 +#define ETH_KIND_TPID 2 + +parser TopParser(packet_in b, out Parsed_packet p) { + ValueSet(5) ethtype_kinds; + state start { + b.extract(p.ethernet); + transition select(p.ethernet.etherType) { + 16w0x0800: parse_ipv4; + 16w0x0806: parse_arp; + 16w0x86DD: parse_ipv6; + default: dispatch_value_sets; + } + } + + state dispatch_value_sets { + bit<6> set = ethtype_kinds.index(p.ethernet.etherType); + transition select(set) { + ETH_KIND_TRILL: parse_trill; + ETH_KIND_TPID: parse_vlan_tag; + } + } + + state parse_ipv4 { transition accept; } + state parse_arp { transition accept; } + state parse_ipv6 { transition accept; } + state parse_trill { transition accept; } + state parse_vlan_tag { transition accept; } +} + +parser proto(packet_in p, out T h); +package top(proto _p); + +top(TopParser()) main; diff --git a/testdata/p4_16_samples_outputs/functors-midend.p4 b/testdata/p4_16_samples_outputs/functors-midend.p4 index 9eb8ba43988..dd27150af9e 100644 --- a/testdata/p4_16_samples_outputs/functors-midend.p4 +++ b/testdata/p4_16_samples_outputs/functors-midend.p4 @@ -1,9 +1,9 @@ +parser nothing(); +package m(nothing n); parser p_0() { state start { transition accept; } } -parser nothing(); -package m(nothing n); m(p_0()) main; diff --git a/testdata/p4_16_samples_outputs/functors2-midend.p4 b/testdata/p4_16_samples_outputs/functors2-midend.p4 index 80a7acf75b3..23fa3e3d5d7 100644 --- a/testdata/p4_16_samples_outputs/functors2-midend.p4 +++ b/testdata/p4_16_samples_outputs/functors2-midend.p4 @@ -1,3 +1,5 @@ +parser simple(out bit<2> z); +package m(simple n); parser p2_0(out bit<2> z2) { @name("x1") bit<2> x1; @name("x2") bit<2> x2; @@ -25,6 +27,4 @@ parser p2_0(out bit<2> z2) { } } -parser simple(out bit<2> z); -package m(simple n); m(p2_0()) main; diff --git a/testdata/p4_16_samples_outputs/functors3-midend.p4 b/testdata/p4_16_samples_outputs/functors3-midend.p4 index 8eec7211945..36cbfa7a13c 100644 --- a/testdata/p4_16_samples_outputs/functors3-midend.p4 +++ b/testdata/p4_16_samples_outputs/functors3-midend.p4 @@ -1,3 +1,5 @@ +parser simple(out bit<1> z); +package m(simple n); parser p_0(out bit<1> z) { @name("z1_0") bit<1> z1; @name("tmp") bit<1> tmp_1; @@ -12,6 +14,4 @@ parser p_0(out bit<1> z) { } } -parser simple(out bit<1> z); -package m(simple n); m(p_0()) main; diff --git a/testdata/p4_16_samples_outputs/functors5-midend.p4 b/testdata/p4_16_samples_outputs/functors5-midend.p4 index 3b6c986bb6d..e97ee2a542d 100644 --- a/testdata/p4_16_samples_outputs/functors5-midend.p4 +++ b/testdata/p4_16_samples_outputs/functors5-midend.p4 @@ -1,3 +1,5 @@ +parser simple(out bit<2> w); +package m(simple n); parser p2_0(out bit<2> w) { @name("w_0") bit<2> w_1; state start { @@ -7,6 +9,4 @@ parser p2_0(out bit<2> w) { } } -parser simple(out bit<2> w); -package m(simple n); m(p2_0()) main; diff --git a/testdata/p4_16_samples_outputs/functors6-midend.p4 b/testdata/p4_16_samples_outputs/functors6-midend.p4 index c7354860da5..da2058b7539 100644 --- a/testdata/p4_16_samples_outputs/functors6-midend.p4 +++ b/testdata/p4_16_samples_outputs/functors6-midend.p4 @@ -1,9 +1,9 @@ +parser simple(in bit<2> a); +package m(simple n); parser p1_0(in bit<2> a) { state start { transition accept; } } -parser simple(in bit<2> a); -package m(simple n); m(p1_0()) main; diff --git a/testdata/p4_16_samples_outputs/functors7-midend.p4 b/testdata/p4_16_samples_outputs/functors7-midend.p4 index c7354860da5..da2058b7539 100644 --- a/testdata/p4_16_samples_outputs/functors7-midend.p4 +++ b/testdata/p4_16_samples_outputs/functors7-midend.p4 @@ -1,9 +1,9 @@ +parser simple(in bit<2> a); +package m(simple n); parser p1_0(in bit<2> a) { state start { transition accept; } } -parser simple(in bit<2> a); -package m(simple n); m(p1_0()) main; diff --git a/testdata/p4_16_samples_outputs/functors8-midend.p4 b/testdata/p4_16_samples_outputs/functors8-midend.p4 index 3d7ae752478..d076d13a0c6 100644 --- a/testdata/p4_16_samples_outputs/functors8-midend.p4 +++ b/testdata/p4_16_samples_outputs/functors8-midend.p4 @@ -3,6 +3,8 @@ extern e { T get(); } +parser simple(in bit<2> a); +package m(simple n); parser p1_0(in bit<2> a) { @name("w") bit<2> w; @name("tmp") bit<2> tmp_0; @@ -14,6 +16,4 @@ parser p1_0(in bit<2> a) { } } -parser simple(in bit<2> a); -package m(simple n); m(p1_0()) main; diff --git a/testdata/p4_16_samples_outputs/functors9-midend.p4 b/testdata/p4_16_samples_outputs/functors9-midend.p4 index 3d7ae752478..d076d13a0c6 100644 --- a/testdata/p4_16_samples_outputs/functors9-midend.p4 +++ b/testdata/p4_16_samples_outputs/functors9-midend.p4 @@ -3,6 +3,8 @@ extern e { T get(); } +parser simple(in bit<2> a); +package m(simple n); parser p1_0(in bit<2> a) { @name("w") bit<2> w; @name("tmp") bit<2> tmp_0; @@ -14,6 +16,4 @@ parser p1_0(in bit<2> a) { } } -parser simple(in bit<2> a); -package m(simple n); m(p1_0()) main; diff --git a/testdata/p4_16_samples_outputs/parser-arg-first.p4 b/testdata/p4_16_samples_outputs/parser-arg-first.p4 new file mode 100644 index 00000000000..8a5a59b86fc --- /dev/null +++ b/testdata/p4_16_samples_outputs/parser-arg-first.p4 @@ -0,0 +1,25 @@ +parser Parser(); +package Package(Parser p1, Parser p2); +parser Parser1()(Parser p) { + state start { + p.apply(); + transition accept; + } +} + +parser Parser2()(Parser p) { + state start { + p.apply(); + transition accept; + } +} + +parser Inside() { + state start { + transition accept; + } +} + +Parser1(Inside()) p1; +Parser2(Inside()) p2; +Package(p1, p2) main; diff --git a/testdata/p4_16_samples_outputs/parser-arg-frontend.p4 b/testdata/p4_16_samples_outputs/parser-arg-frontend.p4 new file mode 100644 index 00000000000..8a5a59b86fc --- /dev/null +++ b/testdata/p4_16_samples_outputs/parser-arg-frontend.p4 @@ -0,0 +1,25 @@ +parser Parser(); +package Package(Parser p1, Parser p2); +parser Parser1()(Parser p) { + state start { + p.apply(); + transition accept; + } +} + +parser Parser2()(Parser p) { + state start { + p.apply(); + transition accept; + } +} + +parser Inside() { + state start { + transition accept; + } +} + +Parser1(Inside()) p1; +Parser2(Inside()) p2; +Package(p1, p2) main; diff --git a/testdata/p4_16_samples_outputs/parser-arg-midend.p4 b/testdata/p4_16_samples_outputs/parser-arg-midend.p4 new file mode 100644 index 00000000000..ec3bf9d3de5 --- /dev/null +++ b/testdata/p4_16_samples_outputs/parser-arg-midend.p4 @@ -0,0 +1,17 @@ +parser Parser(); +package Package(Parser p1, Parser p2); +parser Parser1_0() { + state start { + transition accept; + } +} + +Parser1_0() p1; +parser Parser2_0() { + state start { + transition accept; + } +} + +Parser2_0() p2; +Package(p1, p2) main; diff --git a/testdata/p4_16_samples_outputs/parser-arg.p4 b/testdata/p4_16_samples_outputs/parser-arg.p4 new file mode 100644 index 00000000000..8a5a59b86fc --- /dev/null +++ b/testdata/p4_16_samples_outputs/parser-arg.p4 @@ -0,0 +1,25 @@ +parser Parser(); +package Package(Parser p1, Parser p2); +parser Parser1()(Parser p) { + state start { + p.apply(); + transition accept; + } +} + +parser Parser2()(Parser p) { + state start { + p.apply(); + transition accept; + } +} + +parser Inside() { + state start { + transition accept; + } +} + +Parser1(Inside()) p1; +Parser2(Inside()) p2; +Package(p1, p2) main; diff --git a/testdata/p4_16_samples_outputs/parser-arg.p4-stderr b/testdata/p4_16_samples_outputs/parser-arg.p4-stderr new file mode 100644 index 00000000000..e69de29bb2d diff --git a/testdata/p4_16_samples_outputs/value-sets-first.p4 b/testdata/p4_16_samples_outputs/value-sets-first.p4 new file mode 100644 index 00000000000..ef6f12b5213 --- /dev/null +++ b/testdata/p4_16_samples_outputs/value-sets-first.p4 @@ -0,0 +1,55 @@ +#include + +header Ethernet_h { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +struct Parsed_packet { + Ethernet_h ethernet; +} + +extern ValueSet { + ValueSet(bit<32> size); + bit<8> index(in bit<16> proto); +} + +parser TopParser(packet_in b, out Parsed_packet p) { + ValueSet(32w5) ethtype_kinds; + state start { + b.extract(p.ethernet); + transition select(p.ethernet.etherType) { + 16w0x800: parse_ipv4; + 16w0x806: parse_arp; + 16w0x86dd: parse_ipv6; + default: dispatch_value_sets; + } + } + state dispatch_value_sets { + bit<6> set = (bit<6>)ethtype_kinds.index(p.ethernet.etherType); + transition select(set) { + 6w1: parse_trill; + 6w2: parse_vlan_tag; + } + } + state parse_ipv4 { + transition accept; + } + state parse_arp { + transition accept; + } + state parse_ipv6 { + transition accept; + } + state parse_trill { + transition accept; + } + state parse_vlan_tag { + transition accept; + } +} + +parser proto(packet_in p, out T h); +package top(proto _p); +top(TopParser()) main; diff --git a/testdata/p4_16_samples_outputs/value-sets-frontend.p4 b/testdata/p4_16_samples_outputs/value-sets-frontend.p4 new file mode 100644 index 00000000000..f50c5e9c36f --- /dev/null +++ b/testdata/p4_16_samples_outputs/value-sets-frontend.p4 @@ -0,0 +1,58 @@ +#include + +header Ethernet_h { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +struct Parsed_packet { + Ethernet_h ethernet; +} + +extern ValueSet { + ValueSet(bit<32> size); + bit<8> index(in bit<16> proto); +} + +parser TopParser(packet_in b, out Parsed_packet p) { + @name("set") bit<6> set_0; + @name("ethtype_kinds") ValueSet(32w5) ethtype_kinds_0; + bit<8> tmp; + state start { + b.extract(p.ethernet); + transition select(p.ethernet.etherType) { + 16w0x800: parse_ipv4; + 16w0x806: parse_arp; + 16w0x86dd: parse_ipv6; + default: dispatch_value_sets; + } + } + state dispatch_value_sets { + tmp = ethtype_kinds_0.index(p.ethernet.etherType); + set_0 = (bit<6>)tmp; + transition select(set_0) { + 6w1: parse_trill; + 6w2: parse_vlan_tag; + } + } + state parse_ipv4 { + transition accept; + } + state parse_arp { + transition accept; + } + state parse_ipv6 { + transition accept; + } + state parse_trill { + transition accept; + } + state parse_vlan_tag { + transition accept; + } +} + +parser proto(packet_in p, out T h); +package top(proto _p); +top(TopParser()) main; diff --git a/testdata/p4_16_samples_outputs/value-sets-midend.p4 b/testdata/p4_16_samples_outputs/value-sets-midend.p4 new file mode 100644 index 00000000000..8f946ecbd4a --- /dev/null +++ b/testdata/p4_16_samples_outputs/value-sets-midend.p4 @@ -0,0 +1,58 @@ +#include + +header Ethernet_h { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +struct Parsed_packet { + Ethernet_h ethernet; +} + +extern ValueSet { + ValueSet(bit<32> size); + bit<8> index(in bit<16> proto); +} + +parser TopParser(packet_in b, out Parsed_packet p) { + @name("set") bit<6> set; + @name("tmp") bit<8> tmp_0; + @name("ethtype_kinds") ValueSet(32w5) ethtype_kinds; + state start { + b.extract(p.ethernet); + transition select(p.ethernet.etherType) { + 16w0x800: parse_ipv4; + 16w0x806: parse_arp; + 16w0x86dd: parse_ipv6; + default: dispatch_value_sets; + } + } + state dispatch_value_sets { + tmp_0 = ethtype_kinds.index(p.ethernet.etherType); + set = (bit<6>)tmp_0; + transition select(set) { + 6w1: parse_trill; + 6w2: parse_vlan_tag; + } + } + state parse_ipv4 { + transition accept; + } + state parse_arp { + transition accept; + } + state parse_ipv6 { + transition accept; + } + state parse_trill { + transition accept; + } + state parse_vlan_tag { + transition accept; + } +} + +parser proto(packet_in p, out T h); +package top(proto _p); +top(TopParser()) main; diff --git a/testdata/p4_16_samples_outputs/value-sets.p4 b/testdata/p4_16_samples_outputs/value-sets.p4 new file mode 100644 index 00000000000..5ecb3094fa1 --- /dev/null +++ b/testdata/p4_16_samples_outputs/value-sets.p4 @@ -0,0 +1,55 @@ +#include + +header Ethernet_h { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +struct Parsed_packet { + Ethernet_h ethernet; +} + +extern ValueSet { + ValueSet(bit<32> size); + bit<8> index(in bit<16> proto); +} + +parser TopParser(packet_in b, out Parsed_packet p) { + ValueSet(5) ethtype_kinds; + state start { + b.extract(p.ethernet); + transition select(p.ethernet.etherType) { + 16w0x800: parse_ipv4; + 16w0x806: parse_arp; + 16w0x86dd: parse_ipv6; + default: dispatch_value_sets; + } + } + state dispatch_value_sets { + bit<6> set = ethtype_kinds.index(p.ethernet.etherType); + transition select(set) { + 1: parse_trill; + 2: parse_vlan_tag; + } + } + state parse_ipv4 { + transition accept; + } + state parse_arp { + transition accept; + } + state parse_ipv6 { + transition accept; + } + state parse_trill { + transition accept; + } + state parse_vlan_tag { + transition accept; + } +} + +parser proto(packet_in p, out T h); +package top(proto _p); +top(TopParser()) main; diff --git a/testdata/p4_16_samples_outputs/value-sets.p4-stderr b/testdata/p4_16_samples_outputs/value-sets.p4-stderr new file mode 100644 index 00000000000..e69de29bb2d From 13df11a60a36ab882037531c7a1a221c8cb378d9 Mon Sep 17 00:00:00 2001 From: mbudiu-vmw Date: Thu, 29 Sep 2016 13:54:57 -0700 Subject: [PATCH 2/9] removed test by mistake --- frontends/p4/p4-parse.ypp | 8 ++--- testdata/p4_16_errors/packet_in-bmv2.p4 | 35 +++++++++++++++++++ .../p4_16_errors_outputs/parser-arg1-first.p4 | 25 ------------- .../parser-arg1-frontend.p4 | 25 ------------- testdata/p4_16_errors_outputs/parser-arg1.p4 | 25 ------------- .../parser-arg1.p4-stderr | 4 --- 6 files changed, 39 insertions(+), 83 deletions(-) create mode 100644 testdata/p4_16_errors/packet_in-bmv2.p4 delete mode 100644 testdata/p4_16_errors_outputs/parser-arg1-first.p4 delete mode 100644 testdata/p4_16_errors_outputs/parser-arg1-frontend.p4 delete mode 100644 testdata/p4_16_errors_outputs/parser-arg1.p4 delete mode 100644 testdata/p4_16_errors_outputs/parser-arg1.p4-stderr diff --git a/frontends/p4/p4-parse.ypp b/frontends/p4/p4-parse.ypp index 260b3fd1133..0e6fc7829c7 100644 --- a/frontends/p4/p4-parse.ypp +++ b/frontends/p4/p4-parse.ypp @@ -137,7 +137,7 @@ static int yylex(); %type optAnnotations %type annotations %type annotation -%type parameterList nonEmptyParameterList optCompileParameters +%type parameterList nonEmptyParameterList optConstructorParameters %type argumentList nonEmptyArgList expressionList simpleExpressionList tupleKeysetExpression %type identifierList @@ -330,7 +330,7 @@ objDeclaration | instantiation { $$ = $1; } ; -optCompileParameters +optConstructorParameters : /* empty */ { $$ = new IR::IndexedVector(); } | '(' parameterList ')' { $$ = $2; } ; @@ -356,7 +356,7 @@ nonEmptyRelativePathPrefix /**************************** PARSER ******************************/ parserDeclaration - : parserTypeDeclaration optCompileParameters + : parserTypeDeclaration optConstructorParameters '{' parserLocalElements parserStates '}' { structure.pop(); auto pl = new IR::ParameterList(@2, $2); @@ -456,7 +456,7 @@ simpleKeysetExpression /*************************** CONTROL ************************/ controlDeclaration - : controlTypeDeclaration optCompileParameters + : controlTypeDeclaration optConstructorParameters '{' controlLocalDeclarations APPLY controlBody '}' { structure.pop(); auto pl = new IR::ParameterList(@2, $2); diff --git a/testdata/p4_16_errors/packet_in-bmv2.p4 b/testdata/p4_16_errors/packet_in-bmv2.p4 new file mode 100644 index 00000000000..da26d584beb --- /dev/null +++ b/testdata/p4_16_errors/packet_in-bmv2.p4 @@ -0,0 +1,35 @@ +/* +Copyright 2016 VMware, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#include + +header H { + bit<32> f; +} + +control c() { + packet_in() p; + H h; + + apply { + p.extract(h); + } +} + +control proto(); +package top(proto _p); + +top(c()) main; diff --git a/testdata/p4_16_errors_outputs/parser-arg1-first.p4 b/testdata/p4_16_errors_outputs/parser-arg1-first.p4 deleted file mode 100644 index 8a5a59b86fc..00000000000 --- a/testdata/p4_16_errors_outputs/parser-arg1-first.p4 +++ /dev/null @@ -1,25 +0,0 @@ -parser Parser(); -package Package(Parser p1, Parser p2); -parser Parser1()(Parser p) { - state start { - p.apply(); - transition accept; - } -} - -parser Parser2()(Parser p) { - state start { - p.apply(); - transition accept; - } -} - -parser Inside() { - state start { - transition accept; - } -} - -Parser1(Inside()) p1; -Parser2(Inside()) p2; -Package(p1, p2) main; diff --git a/testdata/p4_16_errors_outputs/parser-arg1-frontend.p4 b/testdata/p4_16_errors_outputs/parser-arg1-frontend.p4 deleted file mode 100644 index 8a5a59b86fc..00000000000 --- a/testdata/p4_16_errors_outputs/parser-arg1-frontend.p4 +++ /dev/null @@ -1,25 +0,0 @@ -parser Parser(); -package Package(Parser p1, Parser p2); -parser Parser1()(Parser p) { - state start { - p.apply(); - transition accept; - } -} - -parser Parser2()(Parser p) { - state start { - p.apply(); - transition accept; - } -} - -parser Inside() { - state start { - transition accept; - } -} - -Parser1(Inside()) p1; -Parser2(Inside()) p2; -Package(p1, p2) main; diff --git a/testdata/p4_16_errors_outputs/parser-arg1.p4 b/testdata/p4_16_errors_outputs/parser-arg1.p4 deleted file mode 100644 index 8a5a59b86fc..00000000000 --- a/testdata/p4_16_errors_outputs/parser-arg1.p4 +++ /dev/null @@ -1,25 +0,0 @@ -parser Parser(); -package Package(Parser p1, Parser p2); -parser Parser1()(Parser p) { - state start { - p.apply(); - transition accept; - } -} - -parser Parser2()(Parser p) { - state start { - p.apply(); - transition accept; - } -} - -parser Inside() { - state start { - transition accept; - } -} - -Parser1(Inside()) p1; -Parser2(Inside()) p2; -Package(p1, p2) main; diff --git a/testdata/p4_16_errors_outputs/parser-arg1.p4-stderr b/testdata/p4_16_errors_outputs/parser-arg1.p4-stderr deleted file mode 100644 index 10b565f5f77..00000000000 --- a/testdata/p4_16_errors_outputs/parser-arg1.p4-stderr +++ /dev/null @@ -1,4 +0,0 @@ -terminate called after throwing an instance of 'Util::CompilerBug' - what(): COMPILER BUG: ../midend/specialize.cpp:40 -Not handled - From 3f144d19fc7dc942c032bef13f73f0ef3c239367 Mon Sep 17 00:00:00 2001 From: mbudiu-vmw Date: Thu, 29 Sep 2016 14:20:20 -0700 Subject: [PATCH 3/9] Fixes and tests for issue #94 --- backends/bmv2/jsonconverter.cpp | 6 ++ testdata/p4_16_errors/no-header-bmv2.p4 | 66 ++++++++++++++++++++++ testdata/p4_16_errors/no-header1-bmv2.p4 | 71 ++++++++++++++++++++++++ 3 files changed, 143 insertions(+) create mode 100644 testdata/p4_16_errors/no-header-bmv2.p4 create mode 100644 testdata/p4_16_errors/no-header1-bmv2.p4 diff --git a/backends/bmv2/jsonconverter.cpp b/backends/bmv2/jsonconverter.cpp index bc73a8eda97..40567579afc 100644 --- a/backends/bmv2/jsonconverter.cpp +++ b/backends/bmv2/jsonconverter.cpp @@ -1997,6 +1997,12 @@ Util::IJson* JsonConverter::convertParserStatement(const IR::StatOrDecl* stat) { result->emplace("op", "extract"); if (mce->arguments->size() == 1) { auto arg = mce->arguments->at(0); + auto argtype = typeMap->getType(arg, true); + if (!argtype->is()) { + ::error("%1%: extract only accepts arguments with header types, not %2%", + arg, argtype); + return result; + } auto param = new Util::JsonObject(); params->append(param); cstring type; diff --git a/testdata/p4_16_errors/no-header-bmv2.p4 b/testdata/p4_16_errors/no-header-bmv2.p4 new file mode 100644 index 00000000000..585e3b81981 --- /dev/null +++ b/testdata/p4_16_errors/no-header-bmv2.p4 @@ -0,0 +1,66 @@ +/* +Copyright 2016 VMware, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#include + +struct h { + bit<8> n; +} + +struct m { +} + +parser MyParser(packet_in b, + out h parsedHdr, + inout m meta, + inout standard_metadata_t standard_metadata) { + state start { + transition accept; + } +} + +control MyVerifyChecksum(in h hdr, + inout m meta, + inout standard_metadata_t standard_metadata) { + apply {} + +} +control MyIngress(inout h hdr, + inout m meta, + inout standard_metadata_t standard_metadata) { + apply {} +} +control MyEgress(inout h hdr, + inout m meta, + inout standard_metadata_t standard_metadata) { + apply {} +} + +control MyComputeChecksum(inout h hdr, + inout m meta, + inout standard_metadata_t standard_metadata) { + apply {} +} +control MyDeparser(packet_out b, in h hdr) { + apply {} +} + +V1Switch(MyParser(), + MyVerifyChecksum(), + MyIngress(), + MyEgress(), + MyComputeChecksum(), + MyDeparser()) main; \ No newline at end of file diff --git a/testdata/p4_16_errors/no-header1-bmv2.p4 b/testdata/p4_16_errors/no-header1-bmv2.p4 new file mode 100644 index 00000000000..8211988896c --- /dev/null +++ b/testdata/p4_16_errors/no-header1-bmv2.p4 @@ -0,0 +1,71 @@ +/* +Copyright 2016 VMware, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#include +#include + +struct H { }; +struct M { }; + +parser ParserI(packet_in b, out H parsedHdr, inout M meta, + inout standard_metadata_t standard_metadata) { + state start { + // here I am trying to extract a struct -> segmentation fault + b.extract(parsedHdr); + transition accept; + } +} + + +control VerifyChecksumI(in H hdr, + inout M meta, + inout standard_metadata_t standard_metadata) { + apply { } +} + + +control IngressI(inout H hdr, + inout M meta, + inout standard_metadata_t standard_metadata) { + apply { } +} + + +control EgressI(inout H hdr, + inout M meta, + inout standard_metadata_t standard_metadata) { + apply { } +} + + +control ComputeChecksumI(inout H hdr, + inout M meta, + inout standard_metadata_t standard_metadata) { + apply { } +} + + +control DeparserI(packet_out b, in H hdr) { + apply { } +} + + +V1Switch(ParserI(), + VerifyChecksumI(), + IngressI(), + EgressI(), + ComputeChecksumI(), + DeparserI()) main; From 9becfa820b9e491ddd67ef11e017f03eb4aaab92 Mon Sep 17 00:00:00 2001 From: mbudiu-vmw Date: Thu, 29 Sep 2016 14:57:05 -0700 Subject: [PATCH 4/9] fix for issue #91 --- backends/bmv2/Makefile.am | 2 +- docs/README.md | 1 + frontends/p4/p4-parse.ypp | 1 + frontends/p4/typeChecking/typeUnification.cpp | 2 +- .../no-header-bmv2.p4 | 0 .../no-header1-bmv2.p4 | 0 .../packet_in-bmv2.p4 | 0 .../p4_16_errors_outputs/packet_in-bmv2.p4 | 17 -------- .../packet_in-bmv2.p4-stderr | 6 --- testdata/p4_16_samples/default.p4 | 40 +++++++++++++++++++ .../p4_16_samples_outputs/default-first.p4 | 23 +++++++++++ .../p4_16_samples_outputs/default-frontend.p4 | 24 +++++++++++ .../p4_16_samples_outputs/default-midend.p4 | 24 +++++++++++ testdata/p4_16_samples_outputs/default.p4 | 23 +++++++++++ .../p4_16_samples_outputs/default.p4-stderr | 0 15 files changed, 138 insertions(+), 25 deletions(-) rename testdata/{p4_16_errors => p4_16_bmv_errors}/no-header-bmv2.p4 (100%) rename testdata/{p4_16_errors => p4_16_bmv_errors}/no-header1-bmv2.p4 (100%) rename testdata/{p4_16_errors => p4_16_bmv_errors}/packet_in-bmv2.p4 (100%) delete mode 100644 testdata/p4_16_errors_outputs/packet_in-bmv2.p4 delete mode 100644 testdata/p4_16_errors_outputs/packet_in-bmv2.p4-stderr create mode 100644 testdata/p4_16_samples/default.p4 create mode 100644 testdata/p4_16_samples_outputs/default-first.p4 create mode 100644 testdata/p4_16_samples_outputs/default-frontend.p4 create mode 100644 testdata/p4_16_samples_outputs/default-midend.p4 create mode 100644 testdata/p4_16_samples_outputs/default.p4 create mode 100644 testdata/p4_16_samples_outputs/default.p4-stderr diff --git a/backends/bmv2/Makefile.am b/backends/bmv2/Makefile.am index a71de5c1e37..1dc1d0e82fe 100644 --- a/backends/bmv2/Makefile.am +++ b/backends/bmv2/Makefile.am @@ -42,7 +42,7 @@ ir_DEF_FILES += $(srcdir)/backends/bmv2/bmv2.def CLEANFILES += bmv2tests.mk bmv2tests.mk: $(srcdir)/testdata/p4_16_samples/*-bmv2.p4 \ - $(srcdir)/testdata/p4_16_errors/*-bmv2.p4 \ + $(srcdir)/testdata/p4_16_bmv_errors/*-bmv2.p4 \ $(srcdir)/testdata/p4_14_samples/*.p4 \ $(srcdir)/testdata/p4_14_samples/switch_*/switch.p4 \ $(srcdir)/testdata/p4_16_samples $(srcdir)/testdata/p4_14_samples diff --git a/docs/README.md b/docs/README.md index 70f84668d43..d3f3a93c08f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -32,6 +32,7 @@ p4c ├── p4_16_errors -- P4_16 negative input test programs ├── p4_16_samples_outputs -- Expected outputs from P4_16 tests ├── p4_16_errors_outputs -- Expected outputs from P4_16 negative tests + ├── p4_16_bmv_errors -- P4_16 negative input tests for the bmv2 backend ├── v1_1_samples -- P4 v1.1 sample programs ├── p4_14_samples -- P4_14 input test programs ├── p4_14_samples_outputs -- Expected outputs from P4_14 tests diff --git a/frontends/p4/p4-parse.ypp b/frontends/p4/p4-parse.ypp index 0e6fc7829c7..4b3fe05bd14 100644 --- a/frontends/p4/p4-parse.ypp +++ b/frontends/p4/p4-parse.ypp @@ -451,6 +451,7 @@ simpleKeysetExpression : expression { $$ = $1; } | expression MASK expression { $$ = new IR::Mask(@1 + @3, $1, $3); } | expression RANGE expression { $$ = new IR::Range(@1 + @3, $1, $3); } + | DEFAULT { $$ = new IR::DefaultExpression(@1); } ; /*************************** CONTROL ************************/ diff --git a/frontends/p4/typeChecking/typeUnification.cpp b/frontends/p4/typeChecking/typeUnification.cpp index d6d005bfd0c..c7c2f20edf9 100644 --- a/frontends/p4/typeChecking/typeUnification.cpp +++ b/frontends/p4/typeChecking/typeUnification.cpp @@ -174,7 +174,7 @@ bool TypeUnification::unify(const IR::Node* errorPosition, if (src->is()) src = src->to()->substituted; - if (dest == IR::Type_Dontcare::get()) + if (src->is() || dest->is()) return true; if (dest->is()) { diff --git a/testdata/p4_16_errors/no-header-bmv2.p4 b/testdata/p4_16_bmv_errors/no-header-bmv2.p4 similarity index 100% rename from testdata/p4_16_errors/no-header-bmv2.p4 rename to testdata/p4_16_bmv_errors/no-header-bmv2.p4 diff --git a/testdata/p4_16_errors/no-header1-bmv2.p4 b/testdata/p4_16_bmv_errors/no-header1-bmv2.p4 similarity index 100% rename from testdata/p4_16_errors/no-header1-bmv2.p4 rename to testdata/p4_16_bmv_errors/no-header1-bmv2.p4 diff --git a/testdata/p4_16_errors/packet_in-bmv2.p4 b/testdata/p4_16_bmv_errors/packet_in-bmv2.p4 similarity index 100% rename from testdata/p4_16_errors/packet_in-bmv2.p4 rename to testdata/p4_16_bmv_errors/packet_in-bmv2.p4 diff --git a/testdata/p4_16_errors_outputs/packet_in-bmv2.p4 b/testdata/p4_16_errors_outputs/packet_in-bmv2.p4 deleted file mode 100644 index 7a364084284..00000000000 --- a/testdata/p4_16_errors_outputs/packet_in-bmv2.p4 +++ /dev/null @@ -1,17 +0,0 @@ -#include - -header H { - bit<32> f; -} - -control c() { - packet_in() p; - H h; - apply { - p.extract(h); - } -} - -control proto(); -package top(proto _p); -top(c()) main; diff --git a/testdata/p4_16_errors_outputs/packet_in-bmv2.p4-stderr b/testdata/p4_16_errors_outputs/packet_in-bmv2.p4-stderr deleted file mode 100644 index f8221bc0a3c..00000000000 --- a/testdata/p4_16_errors_outputs/packet_in-bmv2.p4-stderr +++ /dev/null @@ -1,6 +0,0 @@ -../testdata/p4_16_errors/packet_in-bmv2.p4(24): error: p: type packet_in has no constructor with 0 arguments - packet_in() p; - ^ -/home/mbudiu/git/p4c/p4include/core.p4(40) -extern packet_in { - ^^^^^^^^^ diff --git a/testdata/p4_16_samples/default.p4 b/testdata/p4_16_samples/default.p4 new file mode 100644 index 00000000000..f57701ac6c2 --- /dev/null +++ b/testdata/p4_16_samples/default.p4 @@ -0,0 +1,40 @@ +/* +Copyright 2016 VMware, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#include + +header Header { + bit<32> data; +} + +parser p0(packet_in p, out Header h) { + state start { + bool b = true; + p.extract(h); + transition select(h.data, b) { + (default, true): next; + (default, default): reject; + } + } + state next { + transition accept; + } +} + +parser proto(packet_in p, out Header h); +package top(proto _p); + +top(p0()) main; diff --git a/testdata/p4_16_samples_outputs/default-first.p4 b/testdata/p4_16_samples_outputs/default-first.p4 new file mode 100644 index 00000000000..e1b7b07ea3e --- /dev/null +++ b/testdata/p4_16_samples_outputs/default-first.p4 @@ -0,0 +1,23 @@ +#include + +header Header { + bit<32> data; +} + +parser p0(packet_in p, out Header h) { + state start { + bool b = true; + p.extract
(h); + transition select(h.data, b) { + (default, true): next; + (default, default): reject; + } + } + state next { + transition accept; + } +} + +parser proto(packet_in p, out Header h); +package top(proto _p); +top(p0()) main; diff --git a/testdata/p4_16_samples_outputs/default-frontend.p4 b/testdata/p4_16_samples_outputs/default-frontend.p4 new file mode 100644 index 00000000000..4ce671d001c --- /dev/null +++ b/testdata/p4_16_samples_outputs/default-frontend.p4 @@ -0,0 +1,24 @@ +#include + +header Header { + bit<32> data; +} + +parser p0(packet_in p, out Header h) { + @name("b") bool b_0; + state start { + b_0 = true; + p.extract
(h); + transition select(h.data, b_0) { + (default, true): next; + (default, default): reject; + } + } + state next { + transition accept; + } +} + +parser proto(packet_in p, out Header h); +package top(proto _p); +top(p0()) main; diff --git a/testdata/p4_16_samples_outputs/default-midend.p4 b/testdata/p4_16_samples_outputs/default-midend.p4 new file mode 100644 index 00000000000..17fbd8a8b90 --- /dev/null +++ b/testdata/p4_16_samples_outputs/default-midend.p4 @@ -0,0 +1,24 @@ +#include + +header Header { + bit<32> data; +} + +parser p0(packet_in p, out Header h) { + @name("b") bool b; + state start { + b = true; + p.extract
(h); + transition select(h.data, b) { + (default, true): next; + (default, default): reject; + } + } + state next { + transition accept; + } +} + +parser proto(packet_in p, out Header h); +package top(proto _p); +top(p0()) main; diff --git a/testdata/p4_16_samples_outputs/default.p4 b/testdata/p4_16_samples_outputs/default.p4 new file mode 100644 index 00000000000..e7ce1ccb5ee --- /dev/null +++ b/testdata/p4_16_samples_outputs/default.p4 @@ -0,0 +1,23 @@ +#include + +header Header { + bit<32> data; +} + +parser p0(packet_in p, out Header h) { + state start { + bool b = true; + p.extract(h); + transition select(h.data, b) { + (default, true): next; + (default, default): reject; + } + } + state next { + transition accept; + } +} + +parser proto(packet_in p, out Header h); +package top(proto _p); +top(p0()) main; diff --git a/testdata/p4_16_samples_outputs/default.p4-stderr b/testdata/p4_16_samples_outputs/default.p4-stderr new file mode 100644 index 00000000000..e69de29bb2d From 476353920b1f65ccdad57d79e4498f9f732421e0 Mon Sep 17 00:00:00 2001 From: mbudiu-vmw Date: Thu, 29 Sep 2016 17:29:01 -0700 Subject: [PATCH 5/9] Added 'tuple' to P4 grammar; fixed def-use analysis bug --- frontends/p4/def_use.cpp | 1 + frontends/p4/frontend.cpp | 2 +- frontends/p4/p4-lex.l | 1 + frontends/p4/p4-parse.ypp | 12 +- frontends/p4/toP4/toP4.cpp | 16 ++ frontends/p4/toP4/toP4.h | 3 +- frontends/p4/typeChecking/bindVariables.cpp | 22 +- frontends/p4/typeChecking/bindVariables.h | 7 +- ir/type.def | 2 +- .../basic_routing-first.p4 | 32 +-- .../basic_routing-frontend.p4 | 32 +-- .../basic_routing-midend.p4 | 32 +-- .../p4_14_samples_outputs/checksum1-first.p4 | 32 +-- .../checksum1-frontend.p4 | 32 +-- .../p4_14_samples_outputs/checksum1-midend.p4 | 32 +-- .../copy_to_cpu-first.p4 | 6 +- .../copy_to_cpu-frontend.p4 | 6 +- .../copy_to_cpu-midend.p4 | 6 +- .../flowlet_switching-first.p4 | 53 +---- .../flowlet_switching-frontend.p4 | 53 +---- .../flowlet_switching-midend.p4 | 53 +---- .../packet_redirect-first.p4 | 28 +-- .../packet_redirect-frontend.p4 | 28 +-- .../packet_redirect-midend.p4 | 28 +-- .../parser_dc_full-first.p4 | 64 +----- .../parser_dc_full-frontend.p4 | 64 +----- .../parser_dc_full-midend.p4 | 64 +----- .../port_vlan_mapping-first.p4 | 64 +----- .../port_vlan_mapping-frontend.p4 | 64 +----- .../port_vlan_mapping-midend.p4 | 64 +----- .../p4_14_samples_outputs/resubmit-first.p4 | 7 +- .../resubmit-frontend.p4 | 7 +- .../p4_14_samples_outputs/resubmit-midend.p4 | 7 +- .../p4_14_samples_outputs/sai_p4-first.p4 | 32 +-- .../p4_14_samples_outputs/sai_p4-frontend.p4 | 32 +-- .../p4_14_samples_outputs/sai_p4-midend.p4 | 32 +-- .../p4_14_samples_outputs/simple_nat-first.p4 | 76 +------ .../simple_nat-frontend.p4 | 76 +------ .../simple_nat-midend.p4 | 76 +------ .../simple_router-first.p4 | 32 +-- .../simple_router-frontend.p4 | 32 +-- .../simple_router-midend.p4 | 32 +-- .../switch_20160226/switch-first.p4 | 163 ++------------ .../switch_20160226/switch-frontend.p4 | 163 ++------------ .../switch_20160226/switch-midend.p4 | 169 ++------------- .../switch_20160512/switch-first.p4 | 194 ++--------------- .../switch_20160512/switch-frontend.p4 | 194 ++--------------- .../switch_20160512/switch-midend.p4 | 200 ++---------------- testdata/p4_16_errors/tuple-left.p4 | 28 +++ .../p4_16_errors_outputs/tuple-left.p4-stderr | 4 + testdata/p4_16_samples/tuple.p4 | 36 ++++ testdata/p4_16_samples/tuple1.p4 | 29 +++ testdata/p4_16_samples_outputs/tuple-first.p4 | 19 ++ .../p4_16_samples_outputs/tuple-frontend.p4 | 19 ++ .../p4_16_samples_outputs/tuple-midend.p4 | 28 +++ testdata/p4_16_samples_outputs/tuple.p4 | 19 ++ .../p4_16_samples_outputs/tuple.p4-stderr | 0 .../p4_16_samples_outputs/tuple1-first.p4 | 11 + .../p4_16_samples_outputs/tuple1-frontend.p4 | 12 ++ .../p4_16_samples_outputs/tuple1-midend.p4 | 21 ++ testdata/p4_16_samples_outputs/tuple1.p4 | 11 + .../p4_16_samples_outputs/tuple1.p4-stderr | 0 .../p4_16_samples_outputs/uninit.p4-stderr | 3 + 63 files changed, 474 insertions(+), 2193 deletions(-) create mode 100644 testdata/p4_16_errors/tuple-left.p4 create mode 100644 testdata/p4_16_errors_outputs/tuple-left.p4-stderr create mode 100644 testdata/p4_16_samples/tuple.p4 create mode 100644 testdata/p4_16_samples/tuple1.p4 create mode 100644 testdata/p4_16_samples_outputs/tuple-first.p4 create mode 100644 testdata/p4_16_samples_outputs/tuple-frontend.p4 create mode 100644 testdata/p4_16_samples_outputs/tuple-midend.p4 create mode 100644 testdata/p4_16_samples_outputs/tuple.p4 create mode 100644 testdata/p4_16_samples_outputs/tuple.p4-stderr create mode 100644 testdata/p4_16_samples_outputs/tuple1-first.p4 create mode 100644 testdata/p4_16_samples_outputs/tuple1-frontend.p4 create mode 100644 testdata/p4_16_samples_outputs/tuple1-midend.p4 create mode 100644 testdata/p4_16_samples_outputs/tuple1.p4 create mode 100644 testdata/p4_16_samples_outputs/tuple1.p4-stderr diff --git a/frontends/p4/def_use.cpp b/frontends/p4/def_use.cpp index afe80842651..1d96b6f58a6 100644 --- a/frontends/p4/def_use.cpp +++ b/frontends/p4/def_use.cpp @@ -591,6 +591,7 @@ bool ComputeWriteSet::preorder(const IR::P4Parser* parser) { // We need a new visitor to visit the state, // but we use the same data structures ProgramPoint pt(state); + currentDefinitions = definitions->get(pt); ComputeWriteSet cws(this, pt, currentDefinitions); (void)state->apply(cws); diff --git a/frontends/p4/frontend.cpp b/frontends/p4/frontend.cpp index 2f19cd434c5..bdae789d982 100644 --- a/frontends/p4/frontend.cpp +++ b/frontends/p4/frontend.cpp @@ -91,7 +91,7 @@ FrontEnd::run(const CompilerOptions &options, const IR::P4Program* program) { // explicit casts where implicit casts exist. new ResolveReferences(&refMap), new TypeInference(&refMap, &typeMap), - new BindTypeVariables(&refMap, &typeMap), + new BindTypeVariables(&typeMap), // Another round of constant folding, using type information. new ClearTypeMap(&typeMap), new ConstantFolding(&refMap, &typeMap), diff --git a/frontends/p4/p4-lex.l b/frontends/p4/p4-lex.l index c5a6cbccfbc..df52f4aaf1f 100644 --- a/frontends/p4/p4-lex.l +++ b/frontends/p4/p4-lex.l @@ -103,6 +103,7 @@ std::string stringLiteral; "this" { BEGIN(NORMAL); return THIS; } "transition" { BEGIN(NORMAL); return TRANSITION; } "true" { BEGIN(NORMAL); return TRUE; } +"tuple" { BEGIN(NORMAL); return TUPLE; } "typedef" { BEGIN(NORMAL); return TYPEDEF; } "varbit" { BEGIN(NORMAL); return VARBIT; } "void" { BEGIN(NORMAL); return VOID; } diff --git a/frontends/p4/p4-parse.ypp b/frontends/p4/p4-parse.ypp index 4b3fe05bd14..c2ed64f6cc0 100644 --- a/frontends/p4/p4-parse.ypp +++ b/frontends/p4/p4-parse.ypp @@ -119,7 +119,7 @@ static int yylex(); DEFAULT DONTCARE ELSE ENUM T_ERROR // There is an ERROR macro elsewhere EXIT EXTERN HEADER HEADER_UNION IF IN INOUT INT KEY MASK SELECT MATCH_KIND OUT PACKAGE PARSER RANGE RETURN STATE STRUCT SWITCH TABLE TRANSITION - TYPEDEF VARBIT VOID + TUPLE TYPEDEF VARBIT VOID %token IDENTIFIER TYPE NAMESPACE STRING_LITERAL %token INTEGER @@ -131,7 +131,7 @@ static int yylex(); keysetExpression selectExpression stateExpression optInitializer initializer argument simpleKeysetExpression transitionStatement switchLabel %type pathPrefix relativePathPrefix nonEmptyRelativePathPrefix -%type baseType typeOrVoid specializedType headerStackType typeRef typeArg +%type baseType typeOrVoid specializedType headerStackType typeRef tupleType typeArg %type typeName %type parameter %type optAnnotations @@ -431,8 +431,7 @@ selectCase ; keysetExpression - : DEFAULT { $$ = new IR::DefaultExpression(@1); } - | tupleKeysetExpression { $$ = new IR::ListExpression(@1, $1); } + : tupleKeysetExpression { $$ = new IR::ListExpression(@1, $1); } | simpleKeysetExpression { $$ = $1; } ; @@ -532,6 +531,7 @@ typeRef | typeName { $$ = $1; } | specializedType { $$ = $1; } | headerStackType { $$ = $1; } + | tupleType { $$ = $1; } ; typeName @@ -539,6 +539,10 @@ typeName | pathPrefix TYPE { $$ = new IR::Type_Name(@1, new IR::Path($1, IR::ID(@2, $2))); } ; +tupleType + : TUPLE '<' typeArgumentList '>' { $$ = new IR::Type_Tuple(@1+@4, $3); } + ; + headerStackType : typeName '[' expression ']' { $$ = new IR::Type_Stack(@1+@4, $1, $3); } ; diff --git a/frontends/p4/toP4/toP4.cpp b/frontends/p4/toP4/toP4.cpp index f4bfda69a68..f61ce697859 100644 --- a/frontends/p4/toP4/toP4.cpp +++ b/frontends/p4/toP4/toP4.cpp @@ -242,6 +242,22 @@ bool ToP4::preorder(const IR::Type_Typedef* t) { return false; } +bool ToP4::preorder(const IR::Type_Tuple* t) { + dump(1); + builder.append("tuple<"); + bool first = true; + for (auto a : *t->components) { + if (!first) + builder.append(", "); + first = false; + auto p4type = a->getP4Type(); + CHECK_NULL(p4type); + visit(p4type); + } + builder.append(">"); + return false; +} + bool ToP4::preorder(const IR::Type_Enum* t) { dump(1); builder.append("enum "); diff --git a/frontends/p4/toP4/toP4.h b/frontends/p4/toP4/toP4.h index 479ed84eba9..6f41541dd0f 100644 --- a/frontends/p4/toP4/toP4.h +++ b/frontends/p4/toP4/toP4.h @@ -1,5 +1,5 @@ /* -Copyright 2013-present Barefoot Networks, Inc. +Copyright 2013-present Barefoot Networks, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -134,6 +134,7 @@ class ToP4 : public Inspector { bool preorder(const IR::Type_Typedef* t) override; bool preorder(const IR::Type_Extern* t) override; bool preorder(const IR::Type_Unknown* t) override; + bool preorder(const IR::Type_Tuple* t) override; // declarations bool preorder(const IR::Declaration_Constant* cst) override; diff --git a/frontends/p4/typeChecking/bindVariables.cpp b/frontends/p4/typeChecking/bindVariables.cpp index 7946da6bec1..7a1a6027e33 100644 --- a/frontends/p4/typeChecking/bindVariables.cpp +++ b/frontends/p4/typeChecking/bindVariables.cpp @@ -10,25 +10,9 @@ const IR::Type* BindTypeVariables::getVarValue(const IR::Type_Var* var) const { } const IR::Type* BindTypeVariables::getP4Type(const IR::Type* type) const { - if (type->is()) { - auto fields = new IR::IndexedVector(); - auto tuple = type->to(); - for (auto f : *tuple->components) { - auto t = getP4Type(f); - cstring fname = refMap->newName("field"); - auto field = new IR::StructField(Util::SourceInfo(), fname, IR::Annotations::empty, t); - fields->push_back(field); - } - cstring name = refMap->newName("struct"); - auto strct = new IR::Type_Struct(Util::SourceInfo(), IR::ID(name), - IR::Annotations::empty, fields); - newTypes->push_back(strct); - return getP4Type(strct); - } else { - auto rtype = type->getP4Type(); - CHECK_NULL(rtype); - return rtype; - } + auto rtype = type->getP4Type(); + CHECK_NULL(rtype); + return rtype; } const IR::Node* BindTypeVariables::postorder(IR::Expression* expression) { diff --git a/frontends/p4/typeChecking/bindVariables.h b/frontends/p4/typeChecking/bindVariables.h index 3fc10ad801c..547705770e2 100644 --- a/frontends/p4/typeChecking/bindVariables.h +++ b/frontends/p4/typeChecking/bindVariables.h @@ -10,16 +10,15 @@ namespace P4 { // Insert explicit type specializations where they are missing class BindTypeVariables : public Transform { IR::IndexedVector *newTypes; - ReferenceMap *refMap; TypeMap *typeMap; const IR::Type* getP4Type(const IR::Type* type) const; const IR::Type* getVarValue(const IR::Type_Var* var) const; const IR::Node* insertTypes(const IR::Node* node); public: - explicit BindTypeVariables(ReferenceMap* refMap, TypeMap* typeMap) : - refMap(refMap), typeMap(typeMap) { - CHECK_NULL(refMap); CHECK_NULL(typeMap); + explicit BindTypeVariables(TypeMap* typeMap) : + typeMap(typeMap) { + CHECK_NULL(typeMap); setName("BindTypeVariables"); newTypes = new IR::IndexedVector(); } const IR::Node* postorder(IR::Expression* expression) override; diff --git a/ir/type.def b/ir/type.def index 104dc4491de..453eedf4e06 100644 --- a/ir/type.def +++ b/ir/type.def @@ -253,7 +253,7 @@ class Type_Tuple : Type { Vector components; toString{ return "Tuple(" + Util::toString(components->size()) + ")"; } validate{ components->check_null(); } - const Type* getP4Type() const override { return nullptr; } + const Type* getP4Type() const override { return this; } } // The type of an architectural block. diff --git a/testdata/p4_14_samples_outputs/basic_routing-first.p4 b/testdata/p4_14_samples_outputs/basic_routing-first.p4 index a4cef2c3268..1c6ed83b693 100644 --- a/testdata/p4_14_samples_outputs/basic_routing-first.p4 +++ b/testdata/p4_14_samples_outputs/basic_routing-first.p4 @@ -179,46 +179,18 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_0 { - bit<4> field; - bit<4> field_0; - bit<8> field_1; - bit<16> field_2; - bit<16> field_3; - bit<3> field_4; - bit<13> field_5; - bit<8> field_6; - bit<8> field_7; - bit<32> field_8; - bit<32> field_9; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { Checksum16() ipv4_checksum; apply { - if (hdr.ipv4.hdrChecksum == (ipv4_checksum.get({ 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 }))) + if (hdr.ipv4.hdrChecksum == (ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) mark_to_drop(); } } -struct struct_1 { - bit<4> field_10; - bit<4> field_11; - bit<8> field_12; - bit<16> field_13; - bit<16> field_14; - bit<3> field_15; - bit<13> field_16; - bit<8> field_17; - bit<8> field_18; - bit<32> field_19; - bit<32> field_20; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { Checksum16() ipv4_checksum; apply { - hdr.ipv4.hdrChecksum = ipv4_checksum.get({ 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 = ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } } diff --git a/testdata/p4_14_samples_outputs/basic_routing-frontend.p4 b/testdata/p4_14_samples_outputs/basic_routing-frontend.p4 index 154bc0d9ce0..6ea422a620b 100644 --- a/testdata/p4_14_samples_outputs/basic_routing-frontend.p4 +++ b/testdata/p4_14_samples_outputs/basic_routing-frontend.p4 @@ -179,46 +179,18 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_0 { - bit<4> field; - bit<4> field_0; - bit<8> field_1; - bit<16> field_2; - bit<16> field_3; - bit<3> field_4; - bit<13> field_5; - bit<8> field_6; - bit<8> field_7; - bit<32> field_8; - bit<32> field_9; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("ipv4_checksum") Checksum16() ipv4_checksum_0; apply { - if (hdr.ipv4.hdrChecksum == (ipv4_checksum_0.get({ 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 }))) + if (hdr.ipv4.hdrChecksum == (ipv4_checksum_0.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) mark_to_drop(); } } -struct struct_1 { - bit<4> field_10; - bit<4> field_11; - bit<8> field_12; - bit<16> field_13; - bit<16> field_14; - bit<3> field_15; - bit<13> field_16; - bit<8> field_17; - bit<8> field_18; - bit<32> field_19; - bit<32> field_20; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("ipv4_checksum") Checksum16() ipv4_checksum_1; apply { - hdr.ipv4.hdrChecksum = ipv4_checksum_1.get({ 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 = ipv4_checksum_1.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } } diff --git a/testdata/p4_14_samples_outputs/basic_routing-midend.p4 b/testdata/p4_14_samples_outputs/basic_routing-midend.p4 index 7c4a8a7bb31..465e42c0954 100644 --- a/testdata/p4_14_samples_outputs/basic_routing-midend.p4 +++ b/testdata/p4_14_samples_outputs/basic_routing-midend.p4 @@ -199,20 +199,6 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_0 { - bit<4> field; - bit<4> field_0; - bit<8> field_1; - bit<16> field_2; - bit<16> field_3; - bit<3> field_4; - bit<13> field_5; - bit<8> field_6; - bit<8> field_7; - bit<32> field_8; - bit<32> field_9; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("ipv4_checksum") Checksum16() ipv4_checksum; action act() { @@ -225,29 +211,15 @@ control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metad const default_action = act(); } apply { - if (hdr.ipv4.hdrChecksum == (ipv4_checksum.get({ 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 }))) + if (hdr.ipv4.hdrChecksum == (ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) tbl_act.apply(); } } -struct struct_1 { - bit<4> field_10; - bit<4> field_11; - bit<8> field_12; - bit<16> field_13; - bit<16> field_14; - bit<3> field_15; - bit<13> field_16; - bit<8> field_17; - bit<8> field_18; - bit<32> field_19; - bit<32> field_20; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("ipv4_checksum") Checksum16() ipv4_checksum_2; action act_0() { - hdr.ipv4.hdrChecksum = ipv4_checksum_2.get({ 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 = ipv4_checksum_2.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } table tbl_act_0() { actions = { diff --git a/testdata/p4_14_samples_outputs/checksum1-first.p4 b/testdata/p4_14_samples_outputs/checksum1-first.p4 index cda109a3945..3af92a135b7 100644 --- a/testdata/p4_14_samples_outputs/checksum1-first.p4 +++ b/testdata/p4_14_samples_outputs/checksum1-first.p4 @@ -116,46 +116,18 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_0 { - bit<4> field; - bit<4> field_0; - bit<8> field_1; - bit<16> field_2; - bit<16> field_3; - bit<3> field_4; - bit<13> field_5; - bit<8> field_6; - bit<8> field_7; - bit<32> field_8; - bit<32> field_9; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { Checksum16() ipv4_checksum; apply { - if (hdr.ipv4.hdrChecksum == (ipv4_checksum.get({ 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 }))) + if (hdr.ipv4.hdrChecksum == (ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) mark_to_drop(); } } -struct struct_1 { - bit<4> field_10; - bit<4> field_11; - bit<8> field_12; - bit<16> field_13; - bit<16> field_14; - bit<3> field_15; - bit<13> field_16; - bit<8> field_17; - bit<8> field_18; - bit<32> field_19; - bit<32> field_20; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { Checksum16() ipv4_checksum; apply { - hdr.ipv4.hdrChecksum = ipv4_checksum.get({ 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 = ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } } diff --git a/testdata/p4_14_samples_outputs/checksum1-frontend.p4 b/testdata/p4_14_samples_outputs/checksum1-frontend.p4 index d6496e864ac..e4570b1ccef 100644 --- a/testdata/p4_14_samples_outputs/checksum1-frontend.p4 +++ b/testdata/p4_14_samples_outputs/checksum1-frontend.p4 @@ -116,46 +116,18 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_0 { - bit<4> field; - bit<4> field_0; - bit<8> field_1; - bit<16> field_2; - bit<16> field_3; - bit<3> field_4; - bit<13> field_5; - bit<8> field_6; - bit<8> field_7; - bit<32> field_8; - bit<32> field_9; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("ipv4_checksum") Checksum16() ipv4_checksum_0; apply { - if (hdr.ipv4.hdrChecksum == (ipv4_checksum_0.get({ 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 }))) + if (hdr.ipv4.hdrChecksum == (ipv4_checksum_0.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) mark_to_drop(); } } -struct struct_1 { - bit<4> field_10; - bit<4> field_11; - bit<8> field_12; - bit<16> field_13; - bit<16> field_14; - bit<3> field_15; - bit<13> field_16; - bit<8> field_17; - bit<8> field_18; - bit<32> field_19; - bit<32> field_20; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("ipv4_checksum") Checksum16() ipv4_checksum_1; apply { - hdr.ipv4.hdrChecksum = ipv4_checksum_1.get({ 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 = ipv4_checksum_1.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } } diff --git a/testdata/p4_14_samples_outputs/checksum1-midend.p4 b/testdata/p4_14_samples_outputs/checksum1-midend.p4 index 5c57126afbf..90f0098ee23 100644 --- a/testdata/p4_14_samples_outputs/checksum1-midend.p4 +++ b/testdata/p4_14_samples_outputs/checksum1-midend.p4 @@ -120,20 +120,6 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_0 { - bit<4> field; - bit<4> field_0; - bit<8> field_1; - bit<16> field_2; - bit<16> field_3; - bit<3> field_4; - bit<13> field_5; - bit<8> field_6; - bit<8> field_7; - bit<32> field_8; - bit<32> field_9; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("ipv4_checksum") Checksum16() ipv4_checksum; action act() { @@ -146,29 +132,15 @@ control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metad const default_action = act(); } apply { - if (hdr.ipv4.hdrChecksum == (ipv4_checksum.get({ 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 }))) + if (hdr.ipv4.hdrChecksum == (ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) tbl_act.apply(); } } -struct struct_1 { - bit<4> field_10; - bit<4> field_11; - bit<8> field_12; - bit<16> field_13; - bit<16> field_14; - bit<3> field_15; - bit<13> field_16; - bit<8> field_17; - bit<8> field_18; - bit<32> field_19; - bit<32> field_20; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("ipv4_checksum") Checksum16() ipv4_checksum_2; action act_0() { - hdr.ipv4.hdrChecksum = ipv4_checksum_2.get({ 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 = ipv4_checksum_2.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } table tbl_act_0() { actions = { 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 8e45b0789ce..bcc3f00dcd5 100644 --- a/testdata/p4_14_samples_outputs/copy_to_cpu-first.p4 +++ b/testdata/p4_14_samples_outputs/copy_to_cpu-first.p4 @@ -74,13 +74,9 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } } -struct struct_0 { - standard_metadata_t field; -} - 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, { standard_metadata }); } @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 16d5a066770..6d330af0403 100644 --- a/testdata/p4_14_samples_outputs/copy_to_cpu-frontend.p4 +++ b/testdata/p4_14_samples_outputs/copy_to_cpu-frontend.p4 @@ -74,13 +74,9 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } } -struct struct_0 { - standard_metadata_t field; -} - control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("do_copy_to_cpu") action do_copy_to_cpu_0() { - clone3(CloneType.I2E, 32w250, { standard_metadata }); + clone3>(CloneType.I2E, 32w250, { standard_metadata }); } @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 29067e04399..0027e97235f 100644 --- a/testdata/p4_14_samples_outputs/copy_to_cpu-midend.p4 +++ b/testdata/p4_14_samples_outputs/copy_to_cpu-midend.p4 @@ -76,15 +76,11 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } } -struct struct_0 { - standard_metadata_t field; -} - control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("NoAction_3") action NoAction_0() { } @name("do_copy_to_cpu") action do_copy_to_cpu_0() { - clone3(CloneType.I2E, 32w250, { standard_metadata }); + clone3>(CloneType.I2E, 32w250, { standard_metadata }); } @name("copy_to_cpu") table copy_to_cpu() { actions = { diff --git a/testdata/p4_14_samples_outputs/flowlet_switching-first.p4 b/testdata/p4_14_samples_outputs/flowlet_switching-first.p4 index 731f01fac3f..515149b9181 100644 --- a/testdata/p4_14_samples_outputs/flowlet_switching-first.p4 +++ b/testdata/p4_14_samples_outputs/flowlet_switching-first.p4 @@ -116,23 +116,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } } -struct struct_0 { - bit<32> field; - bit<32> field_0; - bit<8> field_1; - bit<16> field_2; - bit<16> field_3; - bit<16> field_4; -} - -struct struct_1 { - bit<32> field_5; - bit<32> field_6; - bit<8> field_7; - bit<16> field_8; - bit<16> field_9; -} - control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("flowlet_id") register>(32w8192) flowlet_id; @name("flowlet_lasttime") register>(32w8192) flowlet_lasttime; @@ -140,7 +123,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ mark_to_drop(); } @name("set_ecmp_select") action set_ecmp_select(bit<8> ecmp_base, bit<8> ecmp_count) { - hash, bit<10>, struct_0, bit<20>>(meta.ingress_metadata.ecmp_offset, HashAlgorithm.crc16, (bit<10>)ecmp_base, { hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, hdr.ipv4.protocol, hdr.tcp.srcPort, hdr.tcp.dstPort, meta.ingress_metadata.flowlet_id }, (bit<20>)ecmp_count); + hash, bit<10>, tuple, bit<32>, bit<8>, bit<16>, bit<16>, bit<16>>, bit<20>>(meta.ingress_metadata.ecmp_offset, HashAlgorithm.crc16, (bit<10>)ecmp_base, { hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, hdr.ipv4.protocol, hdr.tcp.srcPort, hdr.tcp.dstPort, meta.ingress_metadata.flowlet_id }, (bit<20>)ecmp_count); } @name("set_nhop") action set_nhop(bit<32> nhop_ipv4, bit<9> port) { meta.ingress_metadata.nhop_ipv4 = nhop_ipv4; @@ -148,7 +131,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ hdr.ipv4.ttl = hdr.ipv4.ttl + 8w255; } @name("lookup_flowlet_map") action lookup_flowlet_map() { - hash, bit<13>, struct_1, bit<26>>(meta.ingress_metadata.flowlet_map_index, HashAlgorithm.crc16, 13w0, { hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, hdr.ipv4.protocol, hdr.tcp.srcPort, hdr.tcp.dstPort }, 26w13); + hash, bit<13>, tuple, bit<32>, bit<8>, bit<16>, bit<16>>, bit<26>>(meta.ingress_metadata.flowlet_map_index, HashAlgorithm.crc16, 13w0, { hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, hdr.ipv4.protocol, hdr.tcp.srcPort, hdr.tcp.dstPort }, 26w13); flowlet_id.read(meta.ingress_metadata.flowlet_id, (bit<32>)meta.ingress_metadata.flowlet_map_index); meta.ingress_metadata.flow_ipg = (bit<32>)meta.intrinsic_metadata.ingress_global_timestamp; flowlet_lasttime.read(meta.ingress_metadata.flowlet_lasttime, (bit<32>)meta.ingress_metadata.flowlet_map_index); @@ -230,46 +213,18 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_2 { - bit<4> field_10; - bit<4> field_11; - bit<8> field_12; - bit<16> field_13; - bit<16> field_14; - bit<3> field_15; - bit<13> field_16; - bit<8> field_17; - bit<8> field_18; - bit<32> field_19; - bit<32> field_20; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { Checksum16() ipv4_checksum; apply { - if (hdr.ipv4.hdrChecksum == (ipv4_checksum.get({ 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 }))) + if (hdr.ipv4.hdrChecksum == (ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) mark_to_drop(); } } -struct struct_3 { - bit<4> field_21; - bit<4> field_22; - bit<8> field_23; - bit<16> field_24; - bit<16> field_25; - bit<3> field_26; - bit<13> field_27; - bit<8> field_28; - bit<8> field_29; - bit<32> field_30; - bit<32> field_31; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { Checksum16() ipv4_checksum; apply { - hdr.ipv4.hdrChecksum = ipv4_checksum.get({ 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 = ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } } diff --git a/testdata/p4_14_samples_outputs/flowlet_switching-frontend.p4 b/testdata/p4_14_samples_outputs/flowlet_switching-frontend.p4 index 3f61453c501..fa2848eae81 100644 --- a/testdata/p4_14_samples_outputs/flowlet_switching-frontend.p4 +++ b/testdata/p4_14_samples_outputs/flowlet_switching-frontend.p4 @@ -116,23 +116,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } } -struct struct_0 { - bit<32> field; - bit<32> field_0; - bit<8> field_1; - bit<16> field_2; - bit<16> field_3; - bit<16> field_4; -} - -struct struct_1 { - bit<32> field_5; - bit<32> field_6; - bit<8> field_7; - bit<16> field_8; - bit<16> field_9; -} - control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("flowlet_id") register>(32w8192) flowlet_id_0; @name("flowlet_lasttime") register>(32w8192) flowlet_lasttime_0; @@ -140,7 +123,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ mark_to_drop(); } @name("set_ecmp_select") action set_ecmp_select_0(bit<8> ecmp_base, bit<8> ecmp_count) { - hash, bit<10>, struct_0, bit<20>>(meta.ingress_metadata.ecmp_offset, HashAlgorithm.crc16, (bit<10>)ecmp_base, { hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, hdr.ipv4.protocol, hdr.tcp.srcPort, hdr.tcp.dstPort, meta.ingress_metadata.flowlet_id }, (bit<20>)ecmp_count); + hash, bit<10>, tuple, bit<32>, bit<8>, bit<16>, bit<16>, bit<16>>, bit<20>>(meta.ingress_metadata.ecmp_offset, HashAlgorithm.crc16, (bit<10>)ecmp_base, { hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, hdr.ipv4.protocol, hdr.tcp.srcPort, hdr.tcp.dstPort, meta.ingress_metadata.flowlet_id }, (bit<20>)ecmp_count); } @name("set_nhop") action set_nhop_0(bit<32> nhop_ipv4, bit<9> port) { meta.ingress_metadata.nhop_ipv4 = nhop_ipv4; @@ -148,7 +131,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ hdr.ipv4.ttl = hdr.ipv4.ttl + 8w255; } @name("lookup_flowlet_map") action lookup_flowlet_map_0() { - hash, bit<13>, struct_1, bit<26>>(meta.ingress_metadata.flowlet_map_index, HashAlgorithm.crc16, 13w0, { hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, hdr.ipv4.protocol, hdr.tcp.srcPort, hdr.tcp.dstPort }, 26w13); + hash, bit<13>, tuple, bit<32>, bit<8>, bit<16>, bit<16>>, bit<26>>(meta.ingress_metadata.flowlet_map_index, HashAlgorithm.crc16, 13w0, { hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, hdr.ipv4.protocol, hdr.tcp.srcPort, hdr.tcp.dstPort }, 26w13); flowlet_id_0.read(meta.ingress_metadata.flowlet_id, (bit<32>)meta.ingress_metadata.flowlet_map_index); meta.ingress_metadata.flow_ipg = (bit<32>)meta.intrinsic_metadata.ingress_global_timestamp; flowlet_lasttime_0.read(meta.ingress_metadata.flowlet_lasttime, (bit<32>)meta.ingress_metadata.flowlet_map_index); @@ -230,46 +213,18 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_2 { - bit<4> field_10; - bit<4> field_11; - bit<8> field_12; - bit<16> field_13; - bit<16> field_14; - bit<3> field_15; - bit<13> field_16; - bit<8> field_17; - bit<8> field_18; - bit<32> field_19; - bit<32> field_20; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("ipv4_checksum") Checksum16() ipv4_checksum_0; apply { - if (hdr.ipv4.hdrChecksum == (ipv4_checksum_0.get({ 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 }))) + if (hdr.ipv4.hdrChecksum == (ipv4_checksum_0.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) mark_to_drop(); } } -struct struct_3 { - bit<4> field_21; - bit<4> field_22; - bit<8> field_23; - bit<16> field_24; - bit<16> field_25; - bit<3> field_26; - bit<13> field_27; - bit<8> field_28; - bit<8> field_29; - bit<32> field_30; - bit<32> field_31; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("ipv4_checksum") Checksum16() ipv4_checksum_1; apply { - hdr.ipv4.hdrChecksum = ipv4_checksum_1.get({ 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 = ipv4_checksum_1.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } } diff --git a/testdata/p4_14_samples_outputs/flowlet_switching-midend.p4 b/testdata/p4_14_samples_outputs/flowlet_switching-midend.p4 index 6138b62d34c..52ba1c5a2ef 100644 --- a/testdata/p4_14_samples_outputs/flowlet_switching-midend.p4 +++ b/testdata/p4_14_samples_outputs/flowlet_switching-midend.p4 @@ -118,23 +118,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } } -struct struct_0 { - bit<32> field; - bit<32> field_0; - bit<8> field_1; - bit<16> field_2; - bit<16> field_3; - bit<16> field_4; -} - -struct struct_1 { - bit<32> field_5; - bit<32> field_6; - bit<8> field_7; - bit<16> field_8; - bit<16> field_9; -} - control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("NoAction_3") action NoAction_0() { } @@ -158,7 +141,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ mark_to_drop(); } @name("set_ecmp_select") action set_ecmp_select_0(bit<8> ecmp_base, bit<8> ecmp_count) { - hash, bit<10>, struct_0, bit<20>>(meta.ingress_metadata.ecmp_offset, HashAlgorithm.crc16, (bit<10>)ecmp_base, { hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, hdr.ipv4.protocol, hdr.tcp.srcPort, hdr.tcp.dstPort, meta.ingress_metadata.flowlet_id }, (bit<20>)ecmp_count); + hash, bit<10>, tuple, bit<32>, bit<8>, bit<16>, bit<16>, bit<16>>, bit<20>>(meta.ingress_metadata.ecmp_offset, HashAlgorithm.crc16, (bit<10>)ecmp_base, { hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, hdr.ipv4.protocol, hdr.tcp.srcPort, hdr.tcp.dstPort, meta.ingress_metadata.flowlet_id }, (bit<20>)ecmp_count); } @name("set_nhop") action set_nhop_0(bit<32> nhop_ipv4, bit<9> port) { meta.ingress_metadata.nhop_ipv4 = nhop_ipv4; @@ -166,7 +149,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ hdr.ipv4.ttl = hdr.ipv4.ttl + 8w255; } @name("lookup_flowlet_map") action lookup_flowlet_map_0() { - hash, bit<13>, struct_1, bit<26>>(meta.ingress_metadata.flowlet_map_index, HashAlgorithm.crc16, 13w0, { hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, hdr.ipv4.protocol, hdr.tcp.srcPort, hdr.tcp.dstPort }, 26w13); + hash, bit<13>, tuple, bit<32>, bit<8>, bit<16>, bit<16>>, bit<26>>(meta.ingress_metadata.flowlet_map_index, HashAlgorithm.crc16, 13w0, { hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, hdr.ipv4.protocol, hdr.tcp.srcPort, hdr.tcp.dstPort }, 26w13); flowlet_id_1.read(meta.ingress_metadata.flowlet_id, (bit<32>)meta.ingress_metadata.flowlet_map_index); meta.ingress_metadata.flow_ipg = (bit<32>)meta.intrinsic_metadata.ingress_global_timestamp; flowlet_lasttime_1.read(meta.ingress_metadata.flowlet_lasttime, (bit<32>)meta.ingress_metadata.flowlet_map_index); @@ -248,20 +231,6 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_2 { - bit<4> field_10; - bit<4> field_11; - bit<8> field_12; - bit<16> field_13; - bit<16> field_14; - bit<3> field_15; - bit<13> field_16; - bit<8> field_17; - bit<8> field_18; - bit<32> field_19; - bit<32> field_20; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("ipv4_checksum") Checksum16() ipv4_checksum; action act() { @@ -274,29 +243,15 @@ control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metad const default_action = act(); } apply { - if (hdr.ipv4.hdrChecksum == (ipv4_checksum.get({ 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 }))) + if (hdr.ipv4.hdrChecksum == (ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) tbl_act.apply(); } } -struct struct_3 { - bit<4> field_21; - bit<4> field_22; - bit<8> field_23; - bit<16> field_24; - bit<16> field_25; - bit<3> field_26; - bit<13> field_27; - bit<8> field_28; - bit<8> field_29; - bit<32> field_30; - bit<32> field_31; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("ipv4_checksum") Checksum16() ipv4_checksum_2; action act_0() { - hdr.ipv4.hdrChecksum = ipv4_checksum_2.get({ 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 = ipv4_checksum_2.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } table tbl_act_0() { actions = { diff --git a/testdata/p4_14_samples_outputs/packet_redirect-first.p4 b/testdata/p4_14_samples_outputs/packet_redirect-first.p4 index df1f5b28ae5..cb18ef39b5b 100644 --- a/testdata/p4_14_samples_outputs/packet_redirect-first.p4 +++ b/testdata/p4_14_samples_outputs/packet_redirect-first.p4 @@ -47,24 +47,14 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout } } -struct struct_0 { - standard_metadata_t field; - metaA_t field_0; -} - -struct struct_1 { - standard_metadata_t field_1; - metaA_t field_2; -} - control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("_nop") action _nop() { } @name("_recirculate") action _recirculate() { - recirculate({ standard_metadata, meta.metaA }); + recirculate>({ standard_metadata, meta.metaA }); } @name("_clone_e2e") action _clone_e2e(bit<8> mirror_id) { - clone3(CloneType.E2E, (bit<32>)mirror_id, { standard_metadata, meta.metaA }); + clone3>(CloneType.E2E, (bit<32>)mirror_id, { standard_metadata, meta.metaA }); } @name("t_egress") table t_egress() { actions = { @@ -85,16 +75,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } } -struct struct_2 { - standard_metadata_t field_3; - metaA_t field_4; -} - -struct struct_3 { - standard_metadata_t field_5; - metaA_t field_6; -} - control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("_nop") action _nop() { } @@ -106,10 +86,10 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ meta.intrinsic_metadata.mcast_grp = mgrp; } @name("_resubmit") action _resubmit() { - resubmit({ standard_metadata, meta.metaA }); + resubmit>({ standard_metadata, meta.metaA }); } @name("_clone_i2e") action _clone_i2e(bit<8> mirror_id) { - clone3(CloneType.I2E, (bit<32>)mirror_id, { standard_metadata, meta.metaA }); + clone3>(CloneType.I2E, (bit<32>)mirror_id, { standard_metadata, meta.metaA }); } @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 9c9d21f2f28..377775d5791 100644 --- a/testdata/p4_14_samples_outputs/packet_redirect-frontend.p4 +++ b/testdata/p4_14_samples_outputs/packet_redirect-frontend.p4 @@ -47,24 +47,14 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout } } -struct struct_0 { - standard_metadata_t field; - metaA_t field_0; -} - -struct struct_1 { - standard_metadata_t field_1; - metaA_t field_2; -} - control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("_nop") action _nop_0() { } @name("_recirculate") action _recirculate_0() { - recirculate({ standard_metadata, meta.metaA }); + recirculate>({ standard_metadata, meta.metaA }); } @name("_clone_e2e") action _clone_e2e_0(bit<8> mirror_id) { - clone3(CloneType.E2E, (bit<32>)mirror_id, { standard_metadata, meta.metaA }); + clone3>(CloneType.E2E, (bit<32>)mirror_id, { standard_metadata, meta.metaA }); } @name("t_egress") table t_egress_0() { actions = { @@ -85,16 +75,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } } -struct struct_2 { - standard_metadata_t field_3; - metaA_t field_4; -} - -struct struct_3 { - standard_metadata_t field_5; - metaA_t field_6; -} - control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("_nop") action _nop_1() { } @@ -106,10 +86,10 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ meta.intrinsic_metadata.mcast_grp = mgrp; } @name("_resubmit") action _resubmit_0() { - resubmit({ standard_metadata, meta.metaA }); + resubmit>({ standard_metadata, meta.metaA }); } @name("_clone_i2e") action _clone_i2e_0(bit<8> mirror_id) { - clone3(CloneType.I2E, (bit<32>)mirror_id, { standard_metadata, meta.metaA }); + clone3>(CloneType.I2E, (bit<32>)mirror_id, { standard_metadata, meta.metaA }); } @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 bce41389178..4a277bb8ee2 100644 --- a/testdata/p4_14_samples_outputs/packet_redirect-midend.p4 +++ b/testdata/p4_14_samples_outputs/packet_redirect-midend.p4 @@ -47,26 +47,16 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout } } -struct struct_0 { - standard_metadata_t field; - metaA_t field_0; -} - -struct struct_1 { - standard_metadata_t field_1; - metaA_t field_2; -} - control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("NoAction_2") action NoAction() { } @name("_nop") action _nop_0() { } @name("_recirculate") action _recirculate_0() { - recirculate({ standard_metadata, meta.metaA }); + recirculate>({ standard_metadata, meta.metaA }); } @name("_clone_e2e") action _clone_e2e_0(bit<8> mirror_id) { - clone3(CloneType.E2E, (bit<32>)mirror_id, { standard_metadata, meta.metaA }); + clone3>(CloneType.E2E, (bit<32>)mirror_id, { standard_metadata, meta.metaA }); } @name("t_egress") table t_egress() { actions = { @@ -87,16 +77,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } } -struct struct_2 { - standard_metadata_t field_3; - metaA_t field_4; -} - -struct struct_3 { - standard_metadata_t field_5; - metaA_t field_6; -} - control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("NoAction_3") action NoAction_0() { } @@ -114,10 +94,10 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ meta.intrinsic_metadata.mcast_grp = mgrp; } @name("_resubmit") action _resubmit_0() { - resubmit({ standard_metadata, meta.metaA }); + resubmit>({ standard_metadata, meta.metaA }); } @name("_clone_i2e") action _clone_i2e_0(bit<8> mirror_id) { - clone3(CloneType.I2E, (bit<32>)mirror_id, { standard_metadata, meta.metaA }); + clone3>(CloneType.I2E, (bit<32>)mirror_id, { standard_metadata, meta.metaA }); } @name("t_ingress_1") table t_ingress_1() { actions = { diff --git a/testdata/p4_14_samples_outputs/parser_dc_full-first.p4 b/testdata/p4_14_samples_outputs/parser_dc_full-first.p4 index 2e8b278f315..725144db1e8 100644 --- a/testdata/p4_14_samples_outputs/parser_dc_full-first.p4 +++ b/testdata/p4_14_samples_outputs/parser_dc_full-first.p4 @@ -672,81 +672,25 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_0 { - bit<4> field; - bit<4> field_0; - bit<8> field_1; - bit<16> field_2; - bit<16> field_3; - bit<3> field_4; - bit<13> field_5; - bit<8> field_6; - bit<8> field_7; - bit<32> field_8; - bit<32> field_9; -} - -struct struct_1 { - bit<4> field_10; - bit<4> field_11; - bit<8> field_12; - bit<16> field_13; - bit<16> field_14; - bit<3> field_15; - bit<13> field_16; - bit<8> field_17; - bit<8> field_18; - bit<32> field_19; - bit<32> field_20; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { Checksum16() inner_ipv4_checksum; Checksum16() ipv4_checksum; apply { - if (hdr.ipv4.isValid() && hdr.inner_ipv4.hdrChecksum == (inner_ipv4_checksum.get({ 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 }))) + if (hdr.ipv4.isValid() && hdr.inner_ipv4.hdrChecksum == (inner_ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) mark_to_drop(); - if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.hdrChecksum == (ipv4_checksum.get({ 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 }))) + if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.hdrChecksum == (ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) mark_to_drop(); } } -struct struct_2 { - bit<4> field_21; - bit<4> field_22; - bit<8> field_23; - bit<16> field_24; - bit<16> field_25; - bit<3> field_26; - bit<13> field_27; - bit<8> field_28; - bit<8> field_29; - bit<32> field_30; - bit<32> field_31; -} - -struct struct_3 { - bit<4> field_32; - bit<4> field_33; - bit<8> field_34; - bit<16> field_35; - bit<16> field_36; - bit<3> field_37; - bit<13> field_38; - bit<8> field_39; - bit<8> field_40; - bit<32> field_41; - bit<32> field_42; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { Checksum16() inner_ipv4_checksum; Checksum16() ipv4_checksum; apply { if (hdr.ipv4.isValid()) - hdr.inner_ipv4.hdrChecksum = inner_ipv4_checksum.get({ 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 = inner_ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); if (hdr.ipv4.ihl == 4w5) - hdr.ipv4.hdrChecksum = ipv4_checksum.get({ 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 = ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } } diff --git a/testdata/p4_14_samples_outputs/parser_dc_full-frontend.p4 b/testdata/p4_14_samples_outputs/parser_dc_full-frontend.p4 index 95528054a54..991d1cbc6e8 100644 --- a/testdata/p4_14_samples_outputs/parser_dc_full-frontend.p4 +++ b/testdata/p4_14_samples_outputs/parser_dc_full-frontend.p4 @@ -664,81 +664,25 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_0 { - bit<4> field; - bit<4> field_0; - bit<8> field_1; - bit<16> field_2; - bit<16> field_3; - bit<3> field_4; - bit<13> field_5; - bit<8> field_6; - bit<8> field_7; - bit<32> field_8; - bit<32> field_9; -} - -struct struct_1 { - bit<4> field_10; - bit<4> field_11; - bit<8> field_12; - bit<16> field_13; - bit<16> field_14; - bit<3> field_15; - bit<13> field_16; - bit<8> field_17; - bit<8> field_18; - bit<32> field_19; - bit<32> field_20; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("inner_ipv4_checksum") Checksum16() inner_ipv4_checksum_0; @name("ipv4_checksum") Checksum16() ipv4_checksum_0; apply { - if (hdr.ipv4.isValid() && hdr.inner_ipv4.hdrChecksum == (inner_ipv4_checksum_0.get({ 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 }))) + if (hdr.ipv4.isValid() && hdr.inner_ipv4.hdrChecksum == (inner_ipv4_checksum_0.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) mark_to_drop(); - if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.hdrChecksum == (ipv4_checksum_0.get({ 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 }))) + if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.hdrChecksum == (ipv4_checksum_0.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) mark_to_drop(); } } -struct struct_2 { - bit<4> field_21; - bit<4> field_22; - bit<8> field_23; - bit<16> field_24; - bit<16> field_25; - bit<3> field_26; - bit<13> field_27; - bit<8> field_28; - bit<8> field_29; - bit<32> field_30; - bit<32> field_31; -} - -struct struct_3 { - bit<4> field_32; - bit<4> field_33; - bit<8> field_34; - bit<16> field_35; - bit<16> field_36; - bit<3> field_37; - bit<13> field_38; - bit<8> field_39; - bit<8> field_40; - bit<32> field_41; - bit<32> field_42; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("inner_ipv4_checksum") Checksum16() inner_ipv4_checksum_1; @name("ipv4_checksum") Checksum16() ipv4_checksum_1; apply { if (hdr.ipv4.isValid()) - hdr.inner_ipv4.hdrChecksum = inner_ipv4_checksum_1.get({ 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 = inner_ipv4_checksum_1.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); if (hdr.ipv4.ihl == 4w5) - hdr.ipv4.hdrChecksum = ipv4_checksum_1.get({ 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 = ipv4_checksum_1.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } } diff --git a/testdata/p4_14_samples_outputs/parser_dc_full-midend.p4 b/testdata/p4_14_samples_outputs/parser_dc_full-midend.p4 index d9c5a591305..72a72a3aeea 100644 --- a/testdata/p4_14_samples_outputs/parser_dc_full-midend.p4 +++ b/testdata/p4_14_samples_outputs/parser_dc_full-midend.p4 @@ -666,34 +666,6 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_0 { - bit<4> field; - bit<4> field_0; - bit<8> field_1; - bit<16> field_2; - bit<16> field_3; - bit<3> field_4; - bit<13> field_5; - bit<8> field_6; - bit<8> field_7; - bit<32> field_8; - bit<32> field_9; -} - -struct struct_1 { - bit<4> field_10; - bit<4> field_11; - bit<8> field_12; - bit<16> field_13; - bit<16> field_14; - bit<3> field_15; - bit<13> field_16; - bit<8> field_17; - bit<8> field_18; - bit<32> field_19; - bit<32> field_20; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("inner_ipv4_checksum") Checksum16() inner_ipv4_checksum; @name("ipv4_checksum") Checksum16() ipv4_checksum; @@ -716,49 +688,21 @@ control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metad const default_action = act_0(); } apply { - if (hdr.ipv4.isValid() && hdr.inner_ipv4.hdrChecksum == (inner_ipv4_checksum.get({ 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 }))) + if (hdr.ipv4.isValid() && hdr.inner_ipv4.hdrChecksum == (inner_ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) tbl_act.apply(); - if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.hdrChecksum == (ipv4_checksum.get({ 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 }))) + if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.hdrChecksum == (ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) tbl_act_0.apply(); } } -struct struct_2 { - bit<4> field_21; - bit<4> field_22; - bit<8> field_23; - bit<16> field_24; - bit<16> field_25; - bit<3> field_26; - bit<13> field_27; - bit<8> field_28; - bit<8> field_29; - bit<32> field_30; - bit<32> field_31; -} - -struct struct_3 { - bit<4> field_32; - bit<4> field_33; - bit<8> field_34; - bit<16> field_35; - bit<16> field_36; - bit<3> field_37; - bit<13> field_38; - bit<8> field_39; - bit<8> field_40; - bit<32> field_41; - bit<32> field_42; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("inner_ipv4_checksum") Checksum16() inner_ipv4_checksum_2; @name("ipv4_checksum") Checksum16() ipv4_checksum_2; action act_1() { - hdr.inner_ipv4.hdrChecksum = inner_ipv4_checksum_2.get({ 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 = inner_ipv4_checksum_2.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } action act_2() { - hdr.ipv4.hdrChecksum = ipv4_checksum_2.get({ 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 = ipv4_checksum_2.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } table tbl_act_1() { actions = { diff --git a/testdata/p4_14_samples_outputs/port_vlan_mapping-first.p4 b/testdata/p4_14_samples_outputs/port_vlan_mapping-first.p4 index f658f64311e..50c0d8ee2d4 100644 --- a/testdata/p4_14_samples_outputs/port_vlan_mapping-first.p4 +++ b/testdata/p4_14_samples_outputs/port_vlan_mapping-first.p4 @@ -906,81 +906,25 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_0 { - bit<4> field; - bit<4> field_0; - bit<8> field_1; - bit<16> field_2; - bit<16> field_3; - bit<3> field_4; - bit<13> field_5; - bit<8> field_6; - bit<8> field_7; - bit<32> field_8; - bit<32> field_9; -} - -struct struct_1 { - bit<4> field_10; - bit<4> field_11; - bit<8> field_12; - bit<16> field_13; - bit<16> field_14; - bit<3> field_15; - bit<13> field_16; - bit<8> field_17; - bit<8> field_18; - bit<32> field_19; - bit<32> field_20; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { Checksum16() inner_ipv4_checksum; Checksum16() ipv4_checksum; apply { - if (hdr.ipv4.isValid() && hdr.inner_ipv4.hdrChecksum == (inner_ipv4_checksum.get({ 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 }))) + if (hdr.ipv4.isValid() && hdr.inner_ipv4.hdrChecksum == (inner_ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) mark_to_drop(); - if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.hdrChecksum == (ipv4_checksum.get({ 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 }))) + if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.hdrChecksum == (ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) mark_to_drop(); } } -struct struct_2 { - bit<4> field_21; - bit<4> field_22; - bit<8> field_23; - bit<16> field_24; - bit<16> field_25; - bit<3> field_26; - bit<13> field_27; - bit<8> field_28; - bit<8> field_29; - bit<32> field_30; - bit<32> field_31; -} - -struct struct_3 { - bit<4> field_32; - bit<4> field_33; - bit<8> field_34; - bit<16> field_35; - bit<16> field_36; - bit<3> field_37; - bit<13> field_38; - bit<8> field_39; - bit<8> field_40; - bit<32> field_41; - bit<32> field_42; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { Checksum16() inner_ipv4_checksum; Checksum16() ipv4_checksum; apply { if (hdr.ipv4.isValid()) - hdr.inner_ipv4.hdrChecksum = inner_ipv4_checksum.get({ 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 = inner_ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); if (hdr.ipv4.ihl == 4w5) - hdr.ipv4.hdrChecksum = ipv4_checksum.get({ 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 = ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } } diff --git a/testdata/p4_14_samples_outputs/port_vlan_mapping-frontend.p4 b/testdata/p4_14_samples_outputs/port_vlan_mapping-frontend.p4 index c75bf93da45..739ce86d2bc 100644 --- a/testdata/p4_14_samples_outputs/port_vlan_mapping-frontend.p4 +++ b/testdata/p4_14_samples_outputs/port_vlan_mapping-frontend.p4 @@ -898,81 +898,25 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_0 { - bit<4> field; - bit<4> field_0; - bit<8> field_1; - bit<16> field_2; - bit<16> field_3; - bit<3> field_4; - bit<13> field_5; - bit<8> field_6; - bit<8> field_7; - bit<32> field_8; - bit<32> field_9; -} - -struct struct_1 { - bit<4> field_10; - bit<4> field_11; - bit<8> field_12; - bit<16> field_13; - bit<16> field_14; - bit<3> field_15; - bit<13> field_16; - bit<8> field_17; - bit<8> field_18; - bit<32> field_19; - bit<32> field_20; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("inner_ipv4_checksum") Checksum16() inner_ipv4_checksum_0; @name("ipv4_checksum") Checksum16() ipv4_checksum_0; apply { - if (hdr.ipv4.isValid() && hdr.inner_ipv4.hdrChecksum == (inner_ipv4_checksum_0.get({ 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 }))) + if (hdr.ipv4.isValid() && hdr.inner_ipv4.hdrChecksum == (inner_ipv4_checksum_0.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) mark_to_drop(); - if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.hdrChecksum == (ipv4_checksum_0.get({ 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 }))) + if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.hdrChecksum == (ipv4_checksum_0.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) mark_to_drop(); } } -struct struct_2 { - bit<4> field_21; - bit<4> field_22; - bit<8> field_23; - bit<16> field_24; - bit<16> field_25; - bit<3> field_26; - bit<13> field_27; - bit<8> field_28; - bit<8> field_29; - bit<32> field_30; - bit<32> field_31; -} - -struct struct_3 { - bit<4> field_32; - bit<4> field_33; - bit<8> field_34; - bit<16> field_35; - bit<16> field_36; - bit<3> field_37; - bit<13> field_38; - bit<8> field_39; - bit<8> field_40; - bit<32> field_41; - bit<32> field_42; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("inner_ipv4_checksum") Checksum16() inner_ipv4_checksum_1; @name("ipv4_checksum") Checksum16() ipv4_checksum_1; apply { if (hdr.ipv4.isValid()) - hdr.inner_ipv4.hdrChecksum = inner_ipv4_checksum_1.get({ 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 = inner_ipv4_checksum_1.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); if (hdr.ipv4.ihl == 4w5) - hdr.ipv4.hdrChecksum = ipv4_checksum_1.get({ 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 = ipv4_checksum_1.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } } diff --git a/testdata/p4_14_samples_outputs/port_vlan_mapping-midend.p4 b/testdata/p4_14_samples_outputs/port_vlan_mapping-midend.p4 index 0c49cad0e2c..af26d7b491d 100644 --- a/testdata/p4_14_samples_outputs/port_vlan_mapping-midend.p4 +++ b/testdata/p4_14_samples_outputs/port_vlan_mapping-midend.p4 @@ -900,34 +900,6 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_0 { - bit<4> field; - bit<4> field_0; - bit<8> field_1; - bit<16> field_2; - bit<16> field_3; - bit<3> field_4; - bit<13> field_5; - bit<8> field_6; - bit<8> field_7; - bit<32> field_8; - bit<32> field_9; -} - -struct struct_1 { - bit<4> field_10; - bit<4> field_11; - bit<8> field_12; - bit<16> field_13; - bit<16> field_14; - bit<3> field_15; - bit<13> field_16; - bit<8> field_17; - bit<8> field_18; - bit<32> field_19; - bit<32> field_20; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("inner_ipv4_checksum") Checksum16() inner_ipv4_checksum; @name("ipv4_checksum") Checksum16() ipv4_checksum; @@ -950,49 +922,21 @@ control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metad const default_action = act_0(); } apply { - if (hdr.ipv4.isValid() && hdr.inner_ipv4.hdrChecksum == (inner_ipv4_checksum.get({ 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 }))) + if (hdr.ipv4.isValid() && hdr.inner_ipv4.hdrChecksum == (inner_ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) tbl_act.apply(); - if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.hdrChecksum == (ipv4_checksum.get({ 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 }))) + if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.hdrChecksum == (ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) tbl_act_0.apply(); } } -struct struct_2 { - bit<4> field_21; - bit<4> field_22; - bit<8> field_23; - bit<16> field_24; - bit<16> field_25; - bit<3> field_26; - bit<13> field_27; - bit<8> field_28; - bit<8> field_29; - bit<32> field_30; - bit<32> field_31; -} - -struct struct_3 { - bit<4> field_32; - bit<4> field_33; - bit<8> field_34; - bit<16> field_35; - bit<16> field_36; - bit<3> field_37; - bit<13> field_38; - bit<8> field_39; - bit<8> field_40; - bit<32> field_41; - bit<32> field_42; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("inner_ipv4_checksum") Checksum16() inner_ipv4_checksum_2; @name("ipv4_checksum") Checksum16() ipv4_checksum_2; action act_1() { - hdr.inner_ipv4.hdrChecksum = inner_ipv4_checksum_2.get({ 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 = inner_ipv4_checksum_2.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } action act_2() { - hdr.ipv4.hdrChecksum = ipv4_checksum_2.get({ 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 = ipv4_checksum_2.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } table tbl_act_1() { actions = { diff --git a/testdata/p4_14_samples_outputs/resubmit-first.p4 b/testdata/p4_14_samples_outputs/resubmit-first.p4 index 0376bf9f78b..66f5605dc7a 100644 --- a/testdata/p4_14_samples_outputs/resubmit-first.p4 +++ b/testdata/p4_14_samples_outputs/resubmit-first.p4 @@ -46,11 +46,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } } -struct struct_0 { - standard_metadata_t field; - mymeta_t field_0; -} - control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("_nop") action _nop() { } @@ -59,7 +54,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>({ standard_metadata, meta.mymeta }); } @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 3698cdfcdf6..8f668bbaeab 100644 --- a/testdata/p4_14_samples_outputs/resubmit-frontend.p4 +++ b/testdata/p4_14_samples_outputs/resubmit-frontend.p4 @@ -46,11 +46,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } } -struct struct_0 { - standard_metadata_t field; - mymeta_t field_0; -} - control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("_nop") action _nop_0() { } @@ -59,7 +54,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } @name("_resubmit") action _resubmit_0() { meta.mymeta.f1 = 8w1; - resubmit({ standard_metadata, meta.mymeta }); + resubmit>({ standard_metadata, meta.mymeta }); } @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 2b8fef6c6b5..bf04a5a8d0a 100644 --- a/testdata/p4_14_samples_outputs/resubmit-midend.p4 +++ b/testdata/p4_14_samples_outputs/resubmit-midend.p4 @@ -46,11 +46,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } } -struct struct_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_1") action NoAction() { } @@ -65,7 +60,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } @name("_resubmit") action _resubmit_0() { meta.mymeta.f1 = 8w1; - resubmit({ standard_metadata, meta.mymeta }); + resubmit>({ standard_metadata, meta.mymeta }); } @name("t_ingress_1") table t_ingress_1() { actions = { diff --git a/testdata/p4_14_samples_outputs/sai_p4-first.p4 b/testdata/p4_14_samples_outputs/sai_p4-first.p4 index 1fc581b2007..e31e9f574dc 100644 --- a/testdata/p4_14_samples_outputs/sai_p4-first.p4 +++ b/testdata/p4_14_samples_outputs/sai_p4-first.p4 @@ -347,47 +347,19 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_0 { - bit<4> field; - bit<4> field_0; - bit<8> field_1; - bit<16> field_2; - bit<16> field_3; - bit<3> field_4; - bit<13> field_5; - bit<8> field_6; - bit<8> field_7; - bit<32> field_8; - bit<32> field_9; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { Checksum16() ipv4_checksum; apply { - if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.checksum == (ipv4_checksum.get({ hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.ipv4_length, hdr.ipv4.id, hdr.ipv4.flags, hdr.ipv4.offset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }))) + if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.checksum == (ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.ipv4_length, hdr.ipv4.id, hdr.ipv4.flags, hdr.ipv4.offset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }))) mark_to_drop(); } } -struct struct_1 { - bit<4> field_10; - bit<4> field_11; - bit<8> field_12; - bit<16> field_13; - bit<16> field_14; - bit<3> field_15; - bit<13> field_16; - bit<8> field_17; - bit<8> field_18; - bit<32> field_19; - bit<32> field_20; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { Checksum16() ipv4_checksum; apply { if (hdr.ipv4.ihl == 4w5) - hdr.ipv4.checksum = ipv4_checksum.get({ hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.ipv4_length, hdr.ipv4.id, hdr.ipv4.flags, hdr.ipv4.offset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }); + hdr.ipv4.checksum = ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.ipv4_length, hdr.ipv4.id, hdr.ipv4.flags, hdr.ipv4.offset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }); } } diff --git a/testdata/p4_14_samples_outputs/sai_p4-frontend.p4 b/testdata/p4_14_samples_outputs/sai_p4-frontend.p4 index 34380336da2..f777231b394 100644 --- a/testdata/p4_14_samples_outputs/sai_p4-frontend.p4 +++ b/testdata/p4_14_samples_outputs/sai_p4-frontend.p4 @@ -346,47 +346,19 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_0 { - bit<4> field; - bit<4> field_0; - bit<8> field_1; - bit<16> field_2; - bit<16> field_3; - bit<3> field_4; - bit<13> field_5; - bit<8> field_6; - bit<8> field_7; - bit<32> field_8; - bit<32> field_9; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("ipv4_checksum") Checksum16() ipv4_checksum_0; apply { - if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.checksum == (ipv4_checksum_0.get({ hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.ipv4_length, hdr.ipv4.id, hdr.ipv4.flags, hdr.ipv4.offset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }))) + if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.checksum == (ipv4_checksum_0.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.ipv4_length, hdr.ipv4.id, hdr.ipv4.flags, hdr.ipv4.offset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }))) mark_to_drop(); } } -struct struct_1 { - bit<4> field_10; - bit<4> field_11; - bit<8> field_12; - bit<16> field_13; - bit<16> field_14; - bit<3> field_15; - bit<13> field_16; - bit<8> field_17; - bit<8> field_18; - bit<32> field_19; - bit<32> field_20; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("ipv4_checksum") Checksum16() ipv4_checksum_1; apply { if (hdr.ipv4.ihl == 4w5) - hdr.ipv4.checksum = ipv4_checksum_1.get({ hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.ipv4_length, hdr.ipv4.id, hdr.ipv4.flags, hdr.ipv4.offset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }); + hdr.ipv4.checksum = ipv4_checksum_1.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.ipv4_length, hdr.ipv4.id, hdr.ipv4.flags, hdr.ipv4.offset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }); } } diff --git a/testdata/p4_14_samples_outputs/sai_p4-midend.p4 b/testdata/p4_14_samples_outputs/sai_p4-midend.p4 index bd5de0a2cad..a66ee6ef28b 100644 --- a/testdata/p4_14_samples_outputs/sai_p4-midend.p4 +++ b/testdata/p4_14_samples_outputs/sai_p4-midend.p4 @@ -363,20 +363,6 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_0 { - bit<4> field; - bit<4> field_0; - bit<8> field_1; - bit<16> field_2; - bit<16> field_3; - bit<3> field_4; - bit<13> field_5; - bit<8> field_6; - bit<8> field_7; - bit<32> field_8; - bit<32> field_9; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("ipv4_checksum") Checksum16() ipv4_checksum; action act() { @@ -389,29 +375,15 @@ control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metad const default_action = act(); } apply { - if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.checksum == (ipv4_checksum.get({ hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.ipv4_length, hdr.ipv4.id, hdr.ipv4.flags, hdr.ipv4.offset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }))) + if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.checksum == (ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.ipv4_length, hdr.ipv4.id, hdr.ipv4.flags, hdr.ipv4.offset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }))) tbl_act.apply(); } } -struct struct_1 { - bit<4> field_10; - bit<4> field_11; - bit<8> field_12; - bit<16> field_13; - bit<16> field_14; - bit<3> field_15; - bit<13> field_16; - bit<8> field_17; - bit<8> field_18; - bit<32> field_19; - bit<32> field_20; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("ipv4_checksum") Checksum16() ipv4_checksum_2; action act_0() { - hdr.ipv4.checksum = ipv4_checksum_2.get({ hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.ipv4_length, hdr.ipv4.id, hdr.ipv4.flags, hdr.ipv4.offset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }); + hdr.ipv4.checksum = ipv4_checksum_2.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.ipv4_length, hdr.ipv4.id, hdr.ipv4.flags, hdr.ipv4.offset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }); } table tbl_act_0() { actions = { diff --git a/testdata/p4_14_samples_outputs/simple_nat-first.p4 b/testdata/p4_14_samples_outputs/simple_nat-first.p4 index 64147cea474..1bb197e7937 100644 --- a/testdata/p4_14_samples_outputs/simple_nat-first.p4 +++ b/testdata/p4_14_samples_outputs/simple_nat-first.p4 @@ -165,10 +165,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } } -struct struct_0 { - standard_metadata_t field; -} - control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("set_dmac") action set_dmac(bit<48> dmac) { hdr.ethernet.dstAddr = dmac; @@ -187,7 +183,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, { standard_metadata }); } @name("nat_miss_ext_to_int") action nat_miss_ext_to_int() { meta.meta.do_forward = 1w0; @@ -282,86 +278,24 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_1 { - bit<4> field_0; - bit<4> field_1; - bit<8> field_2; - bit<16> field_3; - bit<16> field_4; - bit<3> field_5; - bit<13> field_6; - bit<8> field_7; - bit<8> field_8; - bit<32> field_9; - bit<32> field_10; -} - -struct struct_2 { - bit<32> field_11; - bit<32> field_12; - bit<8> field_13; - bit<8> field_14; - bit<16> field_15; - bit<16> field_16; - bit<16> field_17; - bit<32> field_18; - bit<32> field_19; - bit<4> field_20; - bit<4> field_21; - bit<8> field_22; - bit<16> field_23; - bit<16> field_24; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { Checksum16() ipv4_checksum; Checksum16() tcp_checksum; apply { - if (hdr.ipv4.hdrChecksum == (ipv4_checksum.get({ 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 }))) + if (hdr.ipv4.hdrChecksum == (ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) mark_to_drop(); - if (hdr.tcp.isValid() && hdr.tcp.checksum == (tcp_checksum.get({ hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, 8w0, hdr.ipv4.protocol, meta.meta.tcpLength, 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 }))) + if (hdr.tcp.isValid() && hdr.tcp.checksum == (tcp_checksum.get, bit<32>, bit<8>, bit<8>, bit<16>, bit<16>, bit<16>, bit<32>, bit<32>, bit<4>, bit<4>, bit<8>, bit<16>, bit<16>>>({ hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, 8w0, hdr.ipv4.protocol, meta.meta.tcpLength, 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 }))) mark_to_drop(); } } -struct struct_3 { - bit<4> field_25; - bit<4> field_26; - bit<8> field_27; - bit<16> field_28; - bit<16> field_29; - bit<3> field_30; - bit<13> field_31; - bit<8> field_32; - bit<8> field_33; - bit<32> field_34; - bit<32> field_35; -} - -struct struct_4 { - bit<32> field_36; - bit<32> field_37; - bit<8> field_38; - bit<8> field_39; - bit<16> field_40; - bit<16> field_41; - bit<16> field_42; - bit<32> field_43; - bit<32> field_44; - bit<4> field_45; - bit<4> field_46; - bit<8> field_47; - bit<16> field_48; - bit<16> field_49; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { Checksum16() ipv4_checksum; Checksum16() tcp_checksum; apply { - hdr.ipv4.hdrChecksum = ipv4_checksum.get({ 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 = ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); if (hdr.tcp.isValid()) - hdr.tcp.checksum = tcp_checksum.get({ hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, 8w0, hdr.ipv4.protocol, meta.meta.tcpLength, 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 = tcp_checksum.get, bit<32>, bit<8>, bit<8>, bit<16>, bit<16>, bit<16>, bit<32>, bit<32>, bit<4>, bit<4>, bit<8>, bit<16>, bit<16>>>({ hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, 8w0, hdr.ipv4.protocol, meta.meta.tcpLength, 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 }); } } diff --git a/testdata/p4_14_samples_outputs/simple_nat-frontend.p4 b/testdata/p4_14_samples_outputs/simple_nat-frontend.p4 index 44607e6a7de..3a2ea30d29d 100644 --- a/testdata/p4_14_samples_outputs/simple_nat-frontend.p4 +++ b/testdata/p4_14_samples_outputs/simple_nat-frontend.p4 @@ -165,10 +165,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } } -struct struct_0 { - standard_metadata_t field; -} - control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("set_dmac") action set_dmac_0(bit<48> dmac) { hdr.ethernet.dstAddr = dmac; @@ -187,7 +183,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_0() { - clone3(CloneType.I2E, 32w250, { standard_metadata }); + clone3>(CloneType.I2E, 32w250, { standard_metadata }); } @name("nat_miss_ext_to_int") action nat_miss_ext_to_int_0() { meta.meta.do_forward = 1w0; @@ -282,86 +278,24 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_1 { - bit<4> field_0; - bit<4> field_1; - bit<8> field_2; - bit<16> field_3; - bit<16> field_4; - bit<3> field_5; - bit<13> field_6; - bit<8> field_7; - bit<8> field_8; - bit<32> field_9; - bit<32> field_10; -} - -struct struct_2 { - bit<32> field_11; - bit<32> field_12; - bit<8> field_13; - bit<8> field_14; - bit<16> field_15; - bit<16> field_16; - bit<16> field_17; - bit<32> field_18; - bit<32> field_19; - bit<4> field_20; - bit<4> field_21; - bit<8> field_22; - bit<16> field_23; - bit<16> field_24; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("ipv4_checksum") Checksum16() ipv4_checksum_0; @name("tcp_checksum") Checksum16() tcp_checksum_0; apply { - if (hdr.ipv4.hdrChecksum == (ipv4_checksum_0.get({ 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 }))) + if (hdr.ipv4.hdrChecksum == (ipv4_checksum_0.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) mark_to_drop(); - if (hdr.tcp.isValid() && hdr.tcp.checksum == (tcp_checksum_0.get({ hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, 8w0, hdr.ipv4.protocol, meta.meta.tcpLength, 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 }))) + if (hdr.tcp.isValid() && hdr.tcp.checksum == (tcp_checksum_0.get, bit<32>, bit<8>, bit<8>, bit<16>, bit<16>, bit<16>, bit<32>, bit<32>, bit<4>, bit<4>, bit<8>, bit<16>, bit<16>>>({ hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, 8w0, hdr.ipv4.protocol, meta.meta.tcpLength, 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 }))) mark_to_drop(); } } -struct struct_3 { - bit<4> field_25; - bit<4> field_26; - bit<8> field_27; - bit<16> field_28; - bit<16> field_29; - bit<3> field_30; - bit<13> field_31; - bit<8> field_32; - bit<8> field_33; - bit<32> field_34; - bit<32> field_35; -} - -struct struct_4 { - bit<32> field_36; - bit<32> field_37; - bit<8> field_38; - bit<8> field_39; - bit<16> field_40; - bit<16> field_41; - bit<16> field_42; - bit<32> field_43; - bit<32> field_44; - bit<4> field_45; - bit<4> field_46; - bit<8> field_47; - bit<16> field_48; - bit<16> field_49; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("ipv4_checksum") Checksum16() ipv4_checksum_1; @name("tcp_checksum") Checksum16() tcp_checksum_1; apply { - hdr.ipv4.hdrChecksum = ipv4_checksum_1.get({ 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 = ipv4_checksum_1.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); if (hdr.tcp.isValid()) - hdr.tcp.checksum = tcp_checksum_1.get({ hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, 8w0, hdr.ipv4.protocol, meta.meta.tcpLength, 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 = tcp_checksum_1.get, bit<32>, bit<8>, bit<8>, bit<16>, bit<16>, bit<16>, bit<32>, bit<32>, bit<4>, bit<4>, bit<8>, bit<16>, bit<16>>>({ hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, 8w0, hdr.ipv4.protocol, meta.meta.tcpLength, 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 }); } } diff --git a/testdata/p4_14_samples_outputs/simple_nat-midend.p4 b/testdata/p4_14_samples_outputs/simple_nat-midend.p4 index 82fe2898d3c..a35a59d3714 100644 --- a/testdata/p4_14_samples_outputs/simple_nat-midend.p4 +++ b/testdata/p4_14_samples_outputs/simple_nat-midend.p4 @@ -169,10 +169,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } } -struct struct_0 { - standard_metadata_t field; -} - control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("NoAction_4") action NoAction_1() { } @@ -208,7 +204,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_0() { - clone3(CloneType.I2E, 32w250, { standard_metadata }); + clone3>(CloneType.I2E, 32w250, { standard_metadata }); } @name("nat_miss_ext_to_int") action nat_miss_ext_to_int_0() { meta.meta.do_forward = 1w0; @@ -303,37 +299,6 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_1 { - bit<4> field_0; - bit<4> field_1; - bit<8> field_2; - bit<16> field_3; - bit<16> field_4; - bit<3> field_5; - bit<13> field_6; - bit<8> field_7; - bit<8> field_8; - bit<32> field_9; - bit<32> field_10; -} - -struct struct_2 { - bit<32> field_11; - bit<32> field_12; - bit<8> field_13; - bit<8> field_14; - bit<16> field_15; - bit<16> field_16; - bit<16> field_17; - bit<32> field_18; - bit<32> field_19; - bit<4> field_20; - bit<4> field_21; - bit<8> field_22; - bit<16> field_23; - bit<16> field_24; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("ipv4_checksum") Checksum16() ipv4_checksum; @name("tcp_checksum") Checksum16() tcp_checksum; @@ -356,52 +321,21 @@ control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metad const default_action = act_0(); } apply { - if (hdr.ipv4.hdrChecksum == (ipv4_checksum.get({ 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 }))) + if (hdr.ipv4.hdrChecksum == (ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) tbl_act.apply(); - if (hdr.tcp.isValid() && hdr.tcp.checksum == (tcp_checksum.get({ hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, 8w0, hdr.ipv4.protocol, meta.meta.tcpLength, 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 }))) + if (hdr.tcp.isValid() && hdr.tcp.checksum == (tcp_checksum.get, bit<32>, bit<8>, bit<8>, bit<16>, bit<16>, bit<16>, bit<32>, bit<32>, bit<4>, bit<4>, bit<8>, bit<16>, bit<16>>>({ hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, 8w0, hdr.ipv4.protocol, meta.meta.tcpLength, 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 }))) tbl_act_0.apply(); } } -struct struct_3 { - bit<4> field_25; - bit<4> field_26; - bit<8> field_27; - bit<16> field_28; - bit<16> field_29; - bit<3> field_30; - bit<13> field_31; - bit<8> field_32; - bit<8> field_33; - bit<32> field_34; - bit<32> field_35; -} - -struct struct_4 { - bit<32> field_36; - bit<32> field_37; - bit<8> field_38; - bit<8> field_39; - bit<16> field_40; - bit<16> field_41; - bit<16> field_42; - bit<32> field_43; - bit<32> field_44; - bit<4> field_45; - bit<4> field_46; - bit<8> field_47; - bit<16> field_48; - bit<16> field_49; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("ipv4_checksum") Checksum16() ipv4_checksum_2; @name("tcp_checksum") Checksum16() tcp_checksum_2; action act_1() { - hdr.tcp.checksum = tcp_checksum_2.get({ hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, 8w0, hdr.ipv4.protocol, meta.meta.tcpLength, 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 = tcp_checksum_2.get, bit<32>, bit<8>, bit<8>, bit<16>, bit<16>, bit<16>, bit<32>, bit<32>, bit<4>, bit<4>, bit<8>, bit<16>, bit<16>>>({ hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, 8w0, hdr.ipv4.protocol, meta.meta.tcpLength, 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 }); } action act_2() { - hdr.ipv4.hdrChecksum = ipv4_checksum_2.get({ 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 = ipv4_checksum_2.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } table tbl_act_1() { actions = { diff --git a/testdata/p4_14_samples_outputs/simple_router-first.p4 b/testdata/p4_14_samples_outputs/simple_router-first.p4 index f5dcd9c427a..8f5559079c6 100644 --- a/testdata/p4_14_samples_outputs/simple_router-first.p4 +++ b/testdata/p4_14_samples_outputs/simple_router-first.p4 @@ -130,46 +130,18 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_0 { - bit<4> field; - bit<4> field_0; - bit<8> field_1; - bit<16> field_2; - bit<16> field_3; - bit<3> field_4; - bit<13> field_5; - bit<8> field_6; - bit<8> field_7; - bit<32> field_8; - bit<32> field_9; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { Checksum16() ipv4_checksum; apply { - if (hdr.ipv4.hdrChecksum == (ipv4_checksum.get({ 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 }))) + if (hdr.ipv4.hdrChecksum == (ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) mark_to_drop(); } } -struct struct_1 { - bit<4> field_10; - bit<4> field_11; - bit<8> field_12; - bit<16> field_13; - bit<16> field_14; - bit<3> field_15; - bit<13> field_16; - bit<8> field_17; - bit<8> field_18; - bit<32> field_19; - bit<32> field_20; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { Checksum16() ipv4_checksum; apply { - hdr.ipv4.hdrChecksum = ipv4_checksum.get({ 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 = ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } } diff --git a/testdata/p4_14_samples_outputs/simple_router-frontend.p4 b/testdata/p4_14_samples_outputs/simple_router-frontend.p4 index ef61e79e305..60999acec85 100644 --- a/testdata/p4_14_samples_outputs/simple_router-frontend.p4 +++ b/testdata/p4_14_samples_outputs/simple_router-frontend.p4 @@ -130,46 +130,18 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_0 { - bit<4> field; - bit<4> field_0; - bit<8> field_1; - bit<16> field_2; - bit<16> field_3; - bit<3> field_4; - bit<13> field_5; - bit<8> field_6; - bit<8> field_7; - bit<32> field_8; - bit<32> field_9; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("ipv4_checksum") Checksum16() ipv4_checksum_0; apply { - if (hdr.ipv4.hdrChecksum == (ipv4_checksum_0.get({ 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 }))) + if (hdr.ipv4.hdrChecksum == (ipv4_checksum_0.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) mark_to_drop(); } } -struct struct_1 { - bit<4> field_10; - bit<4> field_11; - bit<8> field_12; - bit<16> field_13; - bit<16> field_14; - bit<3> field_15; - bit<13> field_16; - bit<8> field_17; - bit<8> field_18; - bit<32> field_19; - bit<32> field_20; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("ipv4_checksum") Checksum16() ipv4_checksum_1; apply { - hdr.ipv4.hdrChecksum = ipv4_checksum_1.get({ 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 = ipv4_checksum_1.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } } diff --git a/testdata/p4_14_samples_outputs/simple_router-midend.p4 b/testdata/p4_14_samples_outputs/simple_router-midend.p4 index f825809360c..a53375507be 100644 --- a/testdata/p4_14_samples_outputs/simple_router-midend.p4 +++ b/testdata/p4_14_samples_outputs/simple_router-midend.p4 @@ -139,20 +139,6 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_0 { - bit<4> field; - bit<4> field_0; - bit<8> field_1; - bit<16> field_2; - bit<16> field_3; - bit<3> field_4; - bit<13> field_5; - bit<8> field_6; - bit<8> field_7; - bit<32> field_8; - bit<32> field_9; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("ipv4_checksum") Checksum16() ipv4_checksum; action act() { @@ -165,29 +151,15 @@ control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metad const default_action = act(); } apply { - if (hdr.ipv4.hdrChecksum == (ipv4_checksum.get({ 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 }))) + if (hdr.ipv4.hdrChecksum == (ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) tbl_act.apply(); } } -struct struct_1 { - bit<4> field_10; - bit<4> field_11; - bit<8> field_12; - bit<16> field_13; - bit<16> field_14; - bit<3> field_15; - bit<13> field_16; - bit<8> field_17; - bit<8> field_18; - bit<32> field_19; - bit<32> field_20; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("ipv4_checksum") Checksum16() ipv4_checksum_2; action act_0() { - hdr.ipv4.hdrChecksum = ipv4_checksum_2.get({ 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 = ipv4_checksum_2.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } table tbl_act_0() { actions = { diff --git a/testdata/p4_14_samples_outputs/switch_20160226/switch-first.p4 b/testdata/p4_14_samples_outputs/switch_20160226/switch-first.p4 index 0ecfce67755..777611c8cef 100644 --- a/testdata/p4_14_samples_outputs/switch_20160226/switch-first.p4 +++ b/testdata/p4_14_samples_outputs/switch_20160226/switch-first.p4 @@ -2745,24 +2745,12 @@ control process_egress_filter(inout headers hdr, inout metadata meta, inout stan } } -struct struct_0 { - bit<32> field; - bit<16> field_0; -} - -struct struct_1 { - bit<16> field_1; - bit<16> field_2; - bit<16> field_3; - bit<9> field_4; -} - control process_egress_acl(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("nop") action nop() { } @name("egress_mirror") action egress_mirror(bit<16> session_id) { meta.i2e_metadata.mirror_session_id = session_id; - clone3(CloneType.E2E, (bit<32>)session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); + clone3, bit<16>>>(CloneType.E2E, (bit<32>)session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); } @name("egress_mirror_drop") action egress_mirror_drop(bit<16> session_id) { egress_mirror(session_id); @@ -2770,7 +2758,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, 32w250, { meta.ingress_metadata.bd, meta.ingress_metadata.ifindex, meta.fabric_metadata.reason_code, meta.ingress_metadata.ingress_port }); + 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 }); } @name("egress_redirect_to_cpu") action egress_redirect_to_cpu(bit<16> reason_code) { egress_copy_to_cpu(reason_code); @@ -3746,11 +3734,6 @@ control process_mac(inout headers hdr, inout metadata meta, inout standard_metad } } -struct struct_2 { - bit<32> field_5; - bit<16> field_6; -} - control process_mac_acl(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("nop") action nop() { } @@ -3771,7 +3754,7 @@ control process_mac_acl(inout headers hdr, inout metadata meta, inout standard_m meta.i2e_metadata.mirror_session_id = session_id; meta.i2e_metadata.ingress_tstamp = (bit<32>)meta.intrinsic_metadata.ingress_global_tstamp; meta.ingress_metadata.enable_dod = 1w0; - clone3(CloneType.I2E, (bit<32>)session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); + clone3, bit<16>>>(CloneType.I2E, (bit<32>)session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); meta.acl_metadata.acl_stats_index = acl_stats_index; } @name("mac_acl") table mac_acl() { @@ -3798,11 +3781,6 @@ control process_mac_acl(inout headers hdr, inout metadata meta, inout standard_m } } -struct struct_3 { - bit<32> field_7; - bit<16> field_8; -} - control process_ip_acl(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("nop") action nop() { } @@ -3823,7 +3801,7 @@ control process_ip_acl(inout headers hdr, inout metadata meta, inout standard_me meta.i2e_metadata.mirror_session_id = session_id; meta.i2e_metadata.ingress_tstamp = (bit<32>)meta.intrinsic_metadata.ingress_global_tstamp; meta.ingress_metadata.enable_dod = 1w0; - clone3(CloneType.I2E, (bit<32>)session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); + clone3, bit<16>>>(CloneType.I2E, (bit<32>)session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); meta.acl_metadata.acl_stats_index = acl_stats_index; } @name("acl_dod_en") action acl_dod_en() { @@ -4406,60 +4384,17 @@ control process_ingress_fabric(inout headers hdr, inout metadata meta, inout sta } } -struct struct_4 { - bit<32> field_9; - bit<32> field_10; - bit<8> field_11; - bit<16> field_12; - bit<16> field_13; -} - -struct struct_5 { - bit<48> field_14; - bit<48> field_15; - bit<32> field_16; - bit<32> field_17; - bit<8> field_18; - bit<16> field_19; - bit<16> field_20; -} - -struct struct_6 { - bit<128> field_21; - bit<128> field_22; - bit<8> field_23; - bit<16> field_24; - bit<16> field_25; -} - -struct struct_7 { - bit<48> field_26; - bit<48> field_27; - bit<128> field_28; - bit<128> field_29; - bit<8> field_30; - bit<16> field_31; - bit<16> field_32; -} - -struct struct_8 { - bit<16> field_33; - bit<48> field_34; - bit<48> field_35; - bit<16> field_36; -} - control process_hashes(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("compute_lkp_ipv4_hash") action compute_lkp_ipv4_hash() { - hash, bit<16>, struct_4, bit<32>>(meta.hash_metadata.hash1, HashAlgorithm.crc16, 16w0, { meta.ipv4_metadata.lkp_ipv4_sa, meta.ipv4_metadata.lkp_ipv4_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); - hash, bit<16>, struct_5, bit<32>>(meta.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta.l2_metadata.lkp_mac_sa, meta.l2_metadata.lkp_mac_da, meta.ipv4_metadata.lkp_ipv4_sa, meta.ipv4_metadata.lkp_ipv4_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); + hash, bit<16>, tuple, bit<32>, bit<8>, bit<16>, bit<16>>, bit<32>>(meta.hash_metadata.hash1, HashAlgorithm.crc16, 16w0, { meta.ipv4_metadata.lkp_ipv4_sa, meta.ipv4_metadata.lkp_ipv4_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); + hash, bit<16>, tuple, bit<48>, bit<32>, bit<32>, bit<8>, bit<16>, bit<16>>, bit<32>>(meta.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta.l2_metadata.lkp_mac_sa, meta.l2_metadata.lkp_mac_da, meta.ipv4_metadata.lkp_ipv4_sa, meta.ipv4_metadata.lkp_ipv4_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); } @name("compute_lkp_ipv6_hash") action compute_lkp_ipv6_hash() { - hash, bit<16>, struct_6, bit<32>>(meta.hash_metadata.hash1, HashAlgorithm.crc16, 16w0, { meta.ipv6_metadata.lkp_ipv6_sa, meta.ipv6_metadata.lkp_ipv6_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); - hash, bit<16>, struct_7, bit<32>>(meta.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta.l2_metadata.lkp_mac_sa, meta.l2_metadata.lkp_mac_da, meta.ipv6_metadata.lkp_ipv6_sa, meta.ipv6_metadata.lkp_ipv6_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); + hash, bit<16>, tuple, bit<128>, bit<8>, bit<16>, bit<16>>, bit<32>>(meta.hash_metadata.hash1, HashAlgorithm.crc16, 16w0, { meta.ipv6_metadata.lkp_ipv6_sa, meta.ipv6_metadata.lkp_ipv6_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); + hash, bit<16>, tuple, bit<48>, bit<128>, bit<128>, bit<8>, bit<16>, bit<16>>, bit<32>>(meta.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta.l2_metadata.lkp_mac_sa, meta.l2_metadata.lkp_mac_da, meta.ipv6_metadata.lkp_ipv6_sa, meta.ipv6_metadata.lkp_ipv6_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); } @name("compute_lkp_non_ip_hash") action compute_lkp_non_ip_hash() { - hash, bit<16>, struct_8, bit<32>>(meta.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta.ingress_metadata.ifindex, meta.l2_metadata.lkp_mac_sa, meta.l2_metadata.lkp_mac_da, meta.l2_metadata.lkp_mac_type }, 32w65536); + hash, bit<16>, tuple, bit<48>, bit<48>, bit<16>>, bit<32>>(meta.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta.ingress_metadata.ifindex, meta.l2_metadata.lkp_mac_sa, meta.l2_metadata.lkp_mac_da, meta.l2_metadata.lkp_mac_type }, 32w65536); } @name("computed_two_hashes") action computed_two_hashes() { meta.intrinsic_metadata.mcast_hash = (bit<13>)meta.hash_metadata.hash1; @@ -4796,18 +4731,6 @@ control process_fabric_lag(inout headers hdr, inout metadata meta, inout standar } } -struct struct_9 { - bit<16> field_37; - bit<16> field_38; - bit<16> field_39; - bit<9> field_40; -} - -struct struct_10 { - bit<16> field_41; - bit<8> field_42; -} - control process_system_acl(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("drop_stats") counter(32w1024, CounterType.packets) drop_stats; @name("drop_stats_2") counter(32w1024, CounterType.packets) drop_stats_2; @@ -4818,7 +4741,7 @@ control process_system_acl(inout headers hdr, inout metadata meta, inout standar } @name("copy_to_cpu") action copy_to_cpu(bit<16> reason_code) { meta.fabric_metadata.reason_code = reason_code; - clone3(CloneType.I2E, 32w250, { meta.ingress_metadata.bd, meta.ingress_metadata.ifindex, meta.fabric_metadata.reason_code, meta.ingress_metadata.ingress_port }); + 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 }); } @name("redirect_to_cpu") action redirect_to_cpu(bit<16> reason_code) { copy_to_cpu(reason_code); @@ -4833,7 +4756,7 @@ control process_system_acl(inout headers hdr, inout metadata meta, inout standar mark_to_drop(); } @name("negative_mirror") action negative_mirror(bit<8> session_id) { - clone3(CloneType.I2E, (bit<32>)session_id, { meta.ingress_metadata.ifindex, meta.ingress_metadata.drop_reason }); + clone3, bit<8>>>(CloneType.I2E, (bit<32>)session_id, { meta.ingress_metadata.ifindex, meta.ingress_metadata.drop_reason }); mark_to_drop(); } @name("deflect_on_drop") action deflect_on_drop() { @@ -5053,81 +4976,25 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_11 { - bit<4> field_43; - bit<4> field_44; - bit<8> field_45; - bit<16> field_46; - bit<16> field_47; - bit<3> field_48; - bit<13> field_49; - bit<8> field_50; - bit<8> field_51; - bit<32> field_52; - bit<32> field_53; -} - -struct struct_12 { - bit<4> field_54; - bit<4> field_55; - bit<8> field_56; - bit<16> field_57; - bit<16> field_58; - bit<3> field_59; - bit<13> field_60; - bit<8> field_61; - bit<8> field_62; - bit<32> field_63; - bit<32> field_64; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { Checksum16() inner_ipv4_checksum; Checksum16() ipv4_checksum; apply { - if (hdr.inner_ipv4.ihl == 4w5 && hdr.inner_ipv4.hdrChecksum == (inner_ipv4_checksum.get({ 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 }))) + if (hdr.inner_ipv4.ihl == 4w5 && hdr.inner_ipv4.hdrChecksum == (inner_ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) mark_to_drop(); - if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.hdrChecksum == (ipv4_checksum.get({ 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 }))) + if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.hdrChecksum == (ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) mark_to_drop(); } } -struct struct_13 { - bit<4> field_65; - bit<4> field_66; - bit<8> field_67; - bit<16> field_68; - bit<16> field_69; - bit<3> field_70; - bit<13> field_71; - bit<8> field_72; - bit<8> field_73; - bit<32> field_74; - bit<32> field_75; -} - -struct struct_14 { - bit<4> field_76; - bit<4> field_77; - bit<8> field_78; - bit<16> field_79; - bit<16> field_80; - bit<3> field_81; - bit<13> field_82; - bit<8> field_83; - bit<8> field_84; - bit<32> field_85; - bit<32> field_86; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { Checksum16() inner_ipv4_checksum; Checksum16() ipv4_checksum; apply { if (hdr.inner_ipv4.ihl == 4w5) - hdr.inner_ipv4.hdrChecksum = inner_ipv4_checksum.get({ 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 = inner_ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); if (hdr.ipv4.ihl == 4w5) - hdr.ipv4.hdrChecksum = ipv4_checksum.get({ 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 = ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } } diff --git a/testdata/p4_14_samples_outputs/switch_20160226/switch-frontend.p4 b/testdata/p4_14_samples_outputs/switch_20160226/switch-frontend.p4 index 541e1eb48d9..fb48c51aca6 100644 --- a/testdata/p4_14_samples_outputs/switch_20160226/switch-frontend.p4 +++ b/testdata/p4_14_samples_outputs/switch_20160226/switch-frontend.p4 @@ -2653,24 +2653,12 @@ control process_egress_filter(inout headers hdr, inout metadata meta, inout stan } } -struct struct_0 { - bit<32> field; - bit<16> field_0; -} - -struct struct_1 { - bit<16> field_1; - bit<16> field_2; - bit<16> field_3; - bit<9> field_4; -} - control process_egress_acl(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("nop") action nop_8() { } @name("egress_mirror") action egress_mirror_0(bit<16> session_id) { meta.i2e_metadata.mirror_session_id = session_id; - clone3(CloneType.E2E, (bit<32>)session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); + clone3, bit<16>>>(CloneType.E2E, (bit<32>)session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); } @name("egress_mirror_drop") action egress_mirror_drop_0(bit<16> session_id) { egress_mirror_0(session_id); @@ -2678,7 +2666,7 @@ control process_egress_acl(inout headers hdr, inout metadata meta, inout standar } @name("egress_copy_to_cpu") action egress_copy_to_cpu_0(bit<16> reason_code) { meta.fabric_metadata.reason_code = reason_code; - clone3(CloneType.E2E, 32w250, { meta.ingress_metadata.bd, meta.ingress_metadata.ifindex, meta.fabric_metadata.reason_code, meta.ingress_metadata.ingress_port }); + 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 }); } @name("egress_redirect_to_cpu") action egress_redirect_to_cpu_0(bit<16> reason_code) { egress_copy_to_cpu_0(reason_code); @@ -3654,11 +3642,6 @@ control process_mac(inout headers hdr, inout metadata meta, inout standard_metad } } -struct struct_2 { - bit<32> field_5; - bit<16> field_6; -} - control process_mac_acl(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("nop") action nop_16() { } @@ -3679,7 +3662,7 @@ control process_mac_acl(inout headers hdr, inout metadata meta, inout standard_m meta.i2e_metadata.mirror_session_id = session_id; meta.i2e_metadata.ingress_tstamp = (bit<32>)meta.intrinsic_metadata.ingress_global_tstamp; meta.ingress_metadata.enable_dod = 1w0; - clone3(CloneType.I2E, (bit<32>)session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); + clone3, bit<16>>>(CloneType.I2E, (bit<32>)session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); meta.acl_metadata.acl_stats_index = acl_stats_index; } @name("mac_acl") table mac_acl_0() { @@ -3706,11 +3689,6 @@ control process_mac_acl(inout headers hdr, inout metadata meta, inout standard_m } } -struct struct_3 { - bit<32> field_7; - bit<16> field_8; -} - control process_ip_acl(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("nop") action nop_17() { } @@ -3731,7 +3709,7 @@ control process_ip_acl(inout headers hdr, inout metadata meta, inout standard_me meta.i2e_metadata.mirror_session_id = session_id; meta.i2e_metadata.ingress_tstamp = (bit<32>)meta.intrinsic_metadata.ingress_global_tstamp; meta.ingress_metadata.enable_dod = 1w0; - clone3(CloneType.I2E, (bit<32>)session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); + clone3, bit<16>>>(CloneType.I2E, (bit<32>)session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); meta.acl_metadata.acl_stats_index = acl_stats_index; } @name("acl_dod_en") action acl_dod_en_0() { @@ -4314,60 +4292,17 @@ control process_ingress_fabric(inout headers hdr, inout metadata meta, inout sta } } -struct struct_4 { - bit<32> field_9; - bit<32> field_10; - bit<8> field_11; - bit<16> field_12; - bit<16> field_13; -} - -struct struct_5 { - bit<48> field_14; - bit<48> field_15; - bit<32> field_16; - bit<32> field_17; - bit<8> field_18; - bit<16> field_19; - bit<16> field_20; -} - -struct struct_6 { - bit<128> field_21; - bit<128> field_22; - bit<8> field_23; - bit<16> field_24; - bit<16> field_25; -} - -struct struct_7 { - bit<48> field_26; - bit<48> field_27; - bit<128> field_28; - bit<128> field_29; - bit<8> field_30; - bit<16> field_31; - bit<16> field_32; -} - -struct struct_8 { - bit<16> field_33; - bit<48> field_34; - bit<48> field_35; - bit<16> field_36; -} - control process_hashes(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("compute_lkp_ipv4_hash") action compute_lkp_ipv4_hash_0() { - hash, bit<16>, struct_4, bit<32>>(meta.hash_metadata.hash1, HashAlgorithm.crc16, 16w0, { meta.ipv4_metadata.lkp_ipv4_sa, meta.ipv4_metadata.lkp_ipv4_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); - hash, bit<16>, struct_5, bit<32>>(meta.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta.l2_metadata.lkp_mac_sa, meta.l2_metadata.lkp_mac_da, meta.ipv4_metadata.lkp_ipv4_sa, meta.ipv4_metadata.lkp_ipv4_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); + hash, bit<16>, tuple, bit<32>, bit<8>, bit<16>, bit<16>>, bit<32>>(meta.hash_metadata.hash1, HashAlgorithm.crc16, 16w0, { meta.ipv4_metadata.lkp_ipv4_sa, meta.ipv4_metadata.lkp_ipv4_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); + hash, bit<16>, tuple, bit<48>, bit<32>, bit<32>, bit<8>, bit<16>, bit<16>>, bit<32>>(meta.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta.l2_metadata.lkp_mac_sa, meta.l2_metadata.lkp_mac_da, meta.ipv4_metadata.lkp_ipv4_sa, meta.ipv4_metadata.lkp_ipv4_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); } @name("compute_lkp_ipv6_hash") action compute_lkp_ipv6_hash_0() { - hash, bit<16>, struct_6, bit<32>>(meta.hash_metadata.hash1, HashAlgorithm.crc16, 16w0, { meta.ipv6_metadata.lkp_ipv6_sa, meta.ipv6_metadata.lkp_ipv6_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); - hash, bit<16>, struct_7, bit<32>>(meta.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta.l2_metadata.lkp_mac_sa, meta.l2_metadata.lkp_mac_da, meta.ipv6_metadata.lkp_ipv6_sa, meta.ipv6_metadata.lkp_ipv6_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); + hash, bit<16>, tuple, bit<128>, bit<8>, bit<16>, bit<16>>, bit<32>>(meta.hash_metadata.hash1, HashAlgorithm.crc16, 16w0, { meta.ipv6_metadata.lkp_ipv6_sa, meta.ipv6_metadata.lkp_ipv6_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); + hash, bit<16>, tuple, bit<48>, bit<128>, bit<128>, bit<8>, bit<16>, bit<16>>, bit<32>>(meta.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta.l2_metadata.lkp_mac_sa, meta.l2_metadata.lkp_mac_da, meta.ipv6_metadata.lkp_ipv6_sa, meta.ipv6_metadata.lkp_ipv6_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); } @name("compute_lkp_non_ip_hash") action compute_lkp_non_ip_hash_0() { - hash, bit<16>, struct_8, bit<32>>(meta.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta.ingress_metadata.ifindex, meta.l2_metadata.lkp_mac_sa, meta.l2_metadata.lkp_mac_da, meta.l2_metadata.lkp_mac_type }, 32w65536); + hash, bit<16>, tuple, bit<48>, bit<48>, bit<16>>, bit<32>>(meta.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta.ingress_metadata.ifindex, meta.l2_metadata.lkp_mac_sa, meta.l2_metadata.lkp_mac_da, meta.l2_metadata.lkp_mac_type }, 32w65536); } @name("computed_two_hashes") action computed_two_hashes_0() { meta.intrinsic_metadata.mcast_hash = (bit<13>)meta.hash_metadata.hash1; @@ -4704,18 +4639,6 @@ control process_fabric_lag(inout headers hdr, inout metadata meta, inout standar } } -struct struct_9 { - bit<16> field_37; - bit<16> field_38; - bit<16> field_39; - bit<9> field_40; -} - -struct struct_10 { - bit<16> field_41; - bit<8> field_42; -} - control process_system_acl(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("drop_stats") counter(32w1024, CounterType.packets) drop_stats_1; @name("drop_stats_2") counter(32w1024, CounterType.packets) drop_stats_3; @@ -4726,7 +4649,7 @@ control process_system_acl(inout headers hdr, inout metadata meta, inout standar } @name("copy_to_cpu") action copy_to_cpu_0(bit<16> reason_code) { meta.fabric_metadata.reason_code = reason_code; - clone3(CloneType.I2E, 32w250, { meta.ingress_metadata.bd, meta.ingress_metadata.ifindex, meta.fabric_metadata.reason_code, meta.ingress_metadata.ingress_port }); + 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 }); } @name("redirect_to_cpu") action redirect_to_cpu_0(bit<16> reason_code) { copy_to_cpu_0(reason_code); @@ -4741,7 +4664,7 @@ control process_system_acl(inout headers hdr, inout metadata meta, inout standar mark_to_drop(); } @name("negative_mirror") action negative_mirror_0(bit<8> session_id) { - clone3(CloneType.I2E, (bit<32>)session_id, { meta.ingress_metadata.ifindex, meta.ingress_metadata.drop_reason }); + clone3, bit<8>>>(CloneType.I2E, (bit<32>)session_id, { meta.ingress_metadata.ifindex, meta.ingress_metadata.drop_reason }); mark_to_drop(); } @name("deflect_on_drop") action deflect_on_drop_0() { @@ -4961,81 +4884,25 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_11 { - bit<4> field_43; - bit<4> field_44; - bit<8> field_45; - bit<16> field_46; - bit<16> field_47; - bit<3> field_48; - bit<13> field_49; - bit<8> field_50; - bit<8> field_51; - bit<32> field_52; - bit<32> field_53; -} - -struct struct_12 { - bit<4> field_54; - bit<4> field_55; - bit<8> field_56; - bit<16> field_57; - bit<16> field_58; - bit<3> field_59; - bit<13> field_60; - bit<8> field_61; - bit<8> field_62; - bit<32> field_63; - bit<32> field_64; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("inner_ipv4_checksum") Checksum16() inner_ipv4_checksum_0; @name("ipv4_checksum") Checksum16() ipv4_checksum_0; apply { - if (hdr.inner_ipv4.ihl == 4w5 && hdr.inner_ipv4.hdrChecksum == (inner_ipv4_checksum_0.get({ 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 }))) + if (hdr.inner_ipv4.ihl == 4w5 && hdr.inner_ipv4.hdrChecksum == (inner_ipv4_checksum_0.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) mark_to_drop(); - if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.hdrChecksum == (ipv4_checksum_0.get({ 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 }))) + if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.hdrChecksum == (ipv4_checksum_0.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) mark_to_drop(); } } -struct struct_13 { - bit<4> field_65; - bit<4> field_66; - bit<8> field_67; - bit<16> field_68; - bit<16> field_69; - bit<3> field_70; - bit<13> field_71; - bit<8> field_72; - bit<8> field_73; - bit<32> field_74; - bit<32> field_75; -} - -struct struct_14 { - bit<4> field_76; - bit<4> field_77; - bit<8> field_78; - bit<16> field_79; - bit<16> field_80; - bit<3> field_81; - bit<13> field_82; - bit<8> field_83; - bit<8> field_84; - bit<32> field_85; - bit<32> field_86; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("inner_ipv4_checksum") Checksum16() inner_ipv4_checksum_1; @name("ipv4_checksum") Checksum16() ipv4_checksum_1; apply { if (hdr.inner_ipv4.ihl == 4w5) - hdr.inner_ipv4.hdrChecksum = inner_ipv4_checksum_1.get({ 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 = inner_ipv4_checksum_1.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); if (hdr.ipv4.ihl == 4w5) - hdr.ipv4.hdrChecksum = ipv4_checksum_1.get({ 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 = ipv4_checksum_1.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } } diff --git a/testdata/p4_14_samples_outputs/switch_20160226/switch-midend.p4 b/testdata/p4_14_samples_outputs/switch_20160226/switch-midend.p4 index 16ebccbcdea..064259a2e7f 100644 --- a/testdata/p4_14_samples_outputs/switch_20160226/switch-midend.p4 +++ b/testdata/p4_14_samples_outputs/switch_20160226/switch-midend.p4 @@ -1137,18 +1137,6 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout } } -struct struct_0 { - bit<32> field; - bit<16> field_0; -} - -struct struct_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("hdr_7") headers hdr_49; @name("meta_7") metadata meta_49; @@ -3028,19 +3016,19 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } @name("process_egress_acl.egress_mirror") action process_egress_acl_egress_mirror(bit<16> session_id) { meta_60.i2e_metadata.mirror_session_id = session_id; - clone3(CloneType.E2E, (bit<32>)session_id, { meta_60.i2e_metadata.ingress_tstamp, meta_60.i2e_metadata.mirror_session_id }); + clone3, bit<16>>>(CloneType.E2E, (bit<32>)session_id, { meta_60.i2e_metadata.ingress_tstamp, meta_60.i2e_metadata.mirror_session_id }); } @name("process_egress_acl.egress_mirror_drop") action process_egress_acl_egress_mirror_drop(bit<16> session_id) { @name("process_egress_acl.egress_mirror") { meta_60.i2e_metadata.mirror_session_id = session_id; - clone3(CloneType.E2E, (bit<32>)session_id, { meta_60.i2e_metadata.ingress_tstamp, meta_60.i2e_metadata.mirror_session_id }); + clone3, bit<16>>>(CloneType.E2E, (bit<32>)session_id, { meta_60.i2e_metadata.ingress_tstamp, meta_60.i2e_metadata.mirror_session_id }); } mark_to_drop(); } @name("process_egress_acl.egress_redirect_to_cpu") action process_egress_acl_egress_redirect_to_cpu(bit<16> reason_code) { @name("process_egress_acl.egress_copy_to_cpu") { meta_60.fabric_metadata.reason_code = reason_code; - clone3(CloneType.E2E, 32w250, { meta_60.ingress_metadata.bd, meta_60.ingress_metadata.ifindex, meta_60.fabric_metadata.reason_code, meta_60.ingress_metadata.ingress_port }); + clone3, bit<16>, bit<16>, bit<9>>>(CloneType.E2E, 32w250, { meta_60.ingress_metadata.bd, meta_60.ingress_metadata.ifindex, meta_60.fabric_metadata.reason_code, meta_60.ingress_metadata.ingress_port }); } mark_to_drop(); } @@ -3368,77 +3356,12 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } } -struct struct_2 { - bit<32> field_5; - bit<16> field_6; -} - -struct struct_3 { - bit<32> field_7; - bit<16> field_8; -} - -struct struct_4 { - bit<32> field_9; - bit<32> field_10; - bit<8> field_11; - bit<16> field_12; - bit<16> field_13; -} - -struct struct_5 { - bit<48> field_14; - bit<48> field_15; - bit<32> field_16; - bit<32> field_17; - bit<8> field_18; - bit<16> field_19; - bit<16> field_20; -} - -struct struct_6 { - bit<128> field_21; - bit<128> field_22; - bit<8> field_23; - bit<16> field_24; - bit<16> field_25; -} - -struct struct_7 { - bit<48> field_26; - bit<48> field_27; - bit<128> field_28; - bit<128> field_29; - bit<8> field_30; - bit<16> field_31; - bit<16> field_32; -} - -struct struct_8 { - bit<16> field_33; - bit<48> field_34; - bit<48> field_35; - bit<16> field_36; -} - @name("mac_learn_digest") struct mac_learn_digest { bit<16> bd; bit<48> lkp_mac_sa; bit<16> ifindex; } -struct struct_9 { - bit<16> field_37; - bit<16> field_38; - bit<16> field_39; - bit<9> field_40; -} - -struct struct_10 { - bit<16> field_41; - bit<8> field_42; -} - control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("hdr_6") headers hdr_61; @name("meta_6") metadata meta_61; @@ -4414,7 +4337,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ meta_77.i2e_metadata.mirror_session_id = session_id; meta_77.i2e_metadata.ingress_tstamp = (bit<32>)meta_77.intrinsic_metadata.ingress_global_tstamp; meta_77.ingress_metadata.enable_dod = 1w0; - clone3(CloneType.I2E, (bit<32>)session_id, { meta_77.i2e_metadata.ingress_tstamp, meta_77.i2e_metadata.mirror_session_id }); + clone3, bit<16>>>(CloneType.I2E, (bit<32>)session_id, { meta_77.i2e_metadata.ingress_tstamp, meta_77.i2e_metadata.mirror_session_id }); meta_77.acl_metadata.acl_stats_index = acl_stats_index; } @name("process_mac_acl.mac_acl") table process_mac_acl_mac_acl_0() { @@ -4470,14 +4393,14 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ meta_78.i2e_metadata.mirror_session_id = session_id; meta_78.i2e_metadata.ingress_tstamp = (bit<32>)meta_78.intrinsic_metadata.ingress_global_tstamp; meta_78.ingress_metadata.enable_dod = 1w0; - clone3(CloneType.I2E, (bit<32>)session_id, { meta_78.i2e_metadata.ingress_tstamp, meta_78.i2e_metadata.mirror_session_id }); + clone3, bit<16>>>(CloneType.I2E, (bit<32>)session_id, { meta_78.i2e_metadata.ingress_tstamp, meta_78.i2e_metadata.mirror_session_id }); meta_78.acl_metadata.acl_stats_index = acl_stats_index; } @name("process_ip_acl.acl_mirror") action process_ip_acl_acl_mirror_2(bit<16> session_id, bit<32> acl_stats_index) { meta_78.i2e_metadata.mirror_session_id = session_id; meta_78.i2e_metadata.ingress_tstamp = (bit<32>)meta_78.intrinsic_metadata.ingress_global_tstamp; meta_78.ingress_metadata.enable_dod = 1w0; - clone3(CloneType.I2E, (bit<32>)session_id, { meta_78.i2e_metadata.ingress_tstamp, meta_78.i2e_metadata.mirror_session_id }); + clone3, bit<16>>>(CloneType.I2E, (bit<32>)session_id, { meta_78.i2e_metadata.ingress_tstamp, meta_78.i2e_metadata.mirror_session_id }); meta_78.acl_metadata.acl_stats_index = acl_stats_index; } @name("process_ip_acl.acl_dod_en") action process_ip_acl_acl_dod_en() { @@ -5021,15 +4944,15 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ default_action = NoAction_151(); } @name("process_hashes.compute_lkp_ipv4_hash") action process_hashes_compute_lkp_ipv4_hash() { - hash, bit<16>, struct_4, bit<32>>(meta_88.hash_metadata.hash1, HashAlgorithm.crc16, 16w0, { meta_88.ipv4_metadata.lkp_ipv4_sa, meta_88.ipv4_metadata.lkp_ipv4_da, meta_88.l3_metadata.lkp_ip_proto, meta_88.l3_metadata.lkp_l4_sport, meta_88.l3_metadata.lkp_l4_dport }, 32w65536); - hash, bit<16>, struct_5, bit<32>>(meta_88.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta_88.l2_metadata.lkp_mac_sa, meta_88.l2_metadata.lkp_mac_da, meta_88.ipv4_metadata.lkp_ipv4_sa, meta_88.ipv4_metadata.lkp_ipv4_da, meta_88.l3_metadata.lkp_ip_proto, meta_88.l3_metadata.lkp_l4_sport, meta_88.l3_metadata.lkp_l4_dport }, 32w65536); + hash, bit<16>, tuple, bit<32>, bit<8>, bit<16>, bit<16>>, bit<32>>(meta_88.hash_metadata.hash1, HashAlgorithm.crc16, 16w0, { meta_88.ipv4_metadata.lkp_ipv4_sa, meta_88.ipv4_metadata.lkp_ipv4_da, meta_88.l3_metadata.lkp_ip_proto, meta_88.l3_metadata.lkp_l4_sport, meta_88.l3_metadata.lkp_l4_dport }, 32w65536); + hash, bit<16>, tuple, bit<48>, bit<32>, bit<32>, bit<8>, bit<16>, bit<16>>, bit<32>>(meta_88.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta_88.l2_metadata.lkp_mac_sa, meta_88.l2_metadata.lkp_mac_da, meta_88.ipv4_metadata.lkp_ipv4_sa, meta_88.ipv4_metadata.lkp_ipv4_da, meta_88.l3_metadata.lkp_ip_proto, meta_88.l3_metadata.lkp_l4_sport, meta_88.l3_metadata.lkp_l4_dport }, 32w65536); } @name("process_hashes.compute_lkp_ipv6_hash") action process_hashes_compute_lkp_ipv6_hash() { - hash, bit<16>, struct_6, bit<32>>(meta_88.hash_metadata.hash1, HashAlgorithm.crc16, 16w0, { meta_88.ipv6_metadata.lkp_ipv6_sa, meta_88.ipv6_metadata.lkp_ipv6_da, meta_88.l3_metadata.lkp_ip_proto, meta_88.l3_metadata.lkp_l4_sport, meta_88.l3_metadata.lkp_l4_dport }, 32w65536); - hash, bit<16>, struct_7, bit<32>>(meta_88.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta_88.l2_metadata.lkp_mac_sa, meta_88.l2_metadata.lkp_mac_da, meta_88.ipv6_metadata.lkp_ipv6_sa, meta_88.ipv6_metadata.lkp_ipv6_da, meta_88.l3_metadata.lkp_ip_proto, meta_88.l3_metadata.lkp_l4_sport, meta_88.l3_metadata.lkp_l4_dport }, 32w65536); + hash, bit<16>, tuple, bit<128>, bit<8>, bit<16>, bit<16>>, bit<32>>(meta_88.hash_metadata.hash1, HashAlgorithm.crc16, 16w0, { meta_88.ipv6_metadata.lkp_ipv6_sa, meta_88.ipv6_metadata.lkp_ipv6_da, meta_88.l3_metadata.lkp_ip_proto, meta_88.l3_metadata.lkp_l4_sport, meta_88.l3_metadata.lkp_l4_dport }, 32w65536); + hash, bit<16>, tuple, bit<48>, bit<128>, bit<128>, bit<8>, bit<16>, bit<16>>, bit<32>>(meta_88.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta_88.l2_metadata.lkp_mac_sa, meta_88.l2_metadata.lkp_mac_da, meta_88.ipv6_metadata.lkp_ipv6_sa, meta_88.ipv6_metadata.lkp_ipv6_da, meta_88.l3_metadata.lkp_ip_proto, meta_88.l3_metadata.lkp_l4_sport, meta_88.l3_metadata.lkp_l4_dport }, 32w65536); } @name("process_hashes.compute_lkp_non_ip_hash") action process_hashes_compute_lkp_non_ip_hash() { - hash, bit<16>, struct_8, bit<32>>(meta_88.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta_88.ingress_metadata.ifindex, meta_88.l2_metadata.lkp_mac_sa, meta_88.l2_metadata.lkp_mac_da, meta_88.l2_metadata.lkp_mac_type }, 32w65536); + hash, bit<16>, tuple, bit<48>, bit<48>, bit<16>>, bit<32>>(meta_88.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta_88.ingress_metadata.ifindex, meta_88.l2_metadata.lkp_mac_sa, meta_88.l2_metadata.lkp_mac_da, meta_88.l2_metadata.lkp_mac_type }, 32w65536); } @name("process_hashes.computed_two_hashes") action process_hashes_computed_two_hashes() { meta_88.intrinsic_metadata.mcast_hash = (bit<13>)meta_88.hash_metadata.hash1; @@ -5307,12 +5230,12 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } @name("process_system_acl.copy_to_cpu") action process_system_acl_copy_to_cpu(bit<16> reason_code) { meta_97.fabric_metadata.reason_code = reason_code; - clone3(CloneType.I2E, 32w250, { meta_97.ingress_metadata.bd, meta_97.ingress_metadata.ifindex, meta_97.fabric_metadata.reason_code, meta_97.ingress_metadata.ingress_port }); + clone3, bit<16>, bit<16>, bit<9>>>(CloneType.I2E, 32w250, { meta_97.ingress_metadata.bd, meta_97.ingress_metadata.ifindex, meta_97.fabric_metadata.reason_code, meta_97.ingress_metadata.ingress_port }); } @name("process_system_acl.redirect_to_cpu") action process_system_acl_redirect_to_cpu(bit<16> reason_code) { @name("process_system_acl.copy_to_cpu") { meta_97.fabric_metadata.reason_code = reason_code; - clone3(CloneType.I2E, 32w250, { meta_97.ingress_metadata.bd, meta_97.ingress_metadata.ifindex, meta_97.fabric_metadata.reason_code, meta_97.ingress_metadata.ingress_port }); + clone3, bit<16>, bit<16>, bit<9>>>(CloneType.I2E, 32w250, { meta_97.ingress_metadata.bd, meta_97.ingress_metadata.ifindex, meta_97.fabric_metadata.reason_code, meta_97.ingress_metadata.ingress_port }); } mark_to_drop(); meta_97.fabric_metadata.dst_device = 8w0; @@ -5325,7 +5248,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ mark_to_drop(); } @name("process_system_acl.negative_mirror") action process_system_acl_negative_mirror(bit<8> session_id) { - clone3(CloneType.I2E, (bit<32>)session_id, { meta_97.ingress_metadata.ifindex, meta_97.ingress_metadata.drop_reason }); + clone3, bit<8>>>(CloneType.I2E, (bit<32>)session_id, { meta_97.ingress_metadata.ifindex, meta_97.ingress_metadata.drop_reason }); mark_to_drop(); } @name("process_system_acl.congestion_mirror_set") action process_system_acl_congestion_mirror_set() { @@ -6331,34 +6254,6 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_11 { - bit<4> field_43; - bit<4> field_44; - bit<8> field_45; - bit<16> field_46; - bit<16> field_47; - bit<3> field_48; - bit<13> field_49; - bit<8> field_50; - bit<8> field_51; - bit<32> field_52; - bit<32> field_53; -} - -struct struct_12 { - bit<4> field_54; - bit<4> field_55; - bit<8> field_56; - bit<16> field_57; - bit<16> field_58; - bit<3> field_59; - bit<13> field_60; - bit<8> field_61; - bit<8> field_62; - bit<32> field_63; - bit<32> field_64; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("inner_ipv4_checksum") Checksum16() inner_ipv4_checksum; @name("ipv4_checksum") Checksum16() ipv4_checksum; @@ -6381,49 +6276,21 @@ control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metad const default_action = act_77(); } apply { - if (hdr.inner_ipv4.ihl == 4w5 && hdr.inner_ipv4.hdrChecksum == (inner_ipv4_checksum.get({ 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 }))) + if (hdr.inner_ipv4.ihl == 4w5 && hdr.inner_ipv4.hdrChecksum == (inner_ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) tbl_act_76.apply(); - if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.hdrChecksum == (ipv4_checksum.get({ 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 }))) + if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.hdrChecksum == (ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) tbl_act_77.apply(); } } -struct struct_13 { - bit<4> field_65; - bit<4> field_66; - bit<8> field_67; - bit<16> field_68; - bit<16> field_69; - bit<3> field_70; - bit<13> field_71; - bit<8> field_72; - bit<8> field_73; - bit<32> field_74; - bit<32> field_75; -} - -struct struct_14 { - bit<4> field_76; - bit<4> field_77; - bit<8> field_78; - bit<16> field_79; - bit<16> field_80; - bit<3> field_81; - bit<13> field_82; - bit<8> field_83; - bit<8> field_84; - bit<32> field_85; - bit<32> field_86; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("inner_ipv4_checksum") Checksum16() inner_ipv4_checksum_2; @name("ipv4_checksum") Checksum16() ipv4_checksum_2; action act_78() { - hdr.inner_ipv4.hdrChecksum = inner_ipv4_checksum_2.get({ 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 = inner_ipv4_checksum_2.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } action act_79() { - hdr.ipv4.hdrChecksum = ipv4_checksum_2.get({ 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 = ipv4_checksum_2.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } table tbl_act_78() { actions = { 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 16b3a6aa7c5..8f1adcc0773 100644 --- a/testdata/p4_14_samples_outputs/switch_20160512/switch-first.p4 +++ b/testdata/p4_14_samples_outputs/switch_20160512/switch-first.p4 @@ -2928,24 +2928,12 @@ control process_egress_filter(inout headers hdr, inout metadata meta, inout stan } } -struct struct_0 { - bit<32> field; - bit<16> field_0; -} - -struct struct_1 { - bit<16> field_1; - bit<16> field_2; - bit<16> field_3; - bit<9> field_4; -} - control process_egress_acl(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("nop") action nop() { } @name("egress_mirror") action egress_mirror(bit<16> session_id) { meta.i2e_metadata.mirror_session_id = session_id; - clone3(CloneType.E2E, (bit<32>)session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); + clone3, bit<16>>>(CloneType.E2E, (bit<32>)session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); } @name("egress_mirror_drop") action egress_mirror_drop(bit<16> session_id) { egress_mirror(session_id); @@ -2953,7 +2941,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, 32w250, { meta.ingress_metadata.bd, meta.ingress_metadata.ifindex, meta.fabric_metadata.reason_code, meta.ingress_metadata.ingress_port }); + 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 }); } @name("egress_redirect_to_cpu") action egress_redirect_to_cpu(bit<16> reason_code) { egress_copy_to_cpu(reason_code); @@ -3459,11 +3447,6 @@ control process_ip_sourceguard(inout headers hdr, inout metadata meta, inout sta } } -struct struct_2 { - bit<1> field_5; - bit<16> field_6; -} - control process_int_endpoint(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("int_sink_update_vxlan_gpe_v4") action int_sink_update_vxlan_gpe_v4() { hdr.vxlan_gpe.next_proto = hdr.vxlan_gpe_int_header.next_proto; @@ -3482,7 +3465,7 @@ control process_int_endpoint(inout headers hdr, inout metadata meta, inout stand @name("int_sink") action int_sink(bit<16> mirror_id) { meta.int_metadata_i2e.sink = 1w1; meta.i2e_metadata.mirror_session_id = mirror_id; - clone3(CloneType.I2E, (bit<32>)mirror_id, { meta.int_metadata_i2e.sink, meta.i2e_metadata.mirror_session_id }); + clone3, bit<16>>>(CloneType.I2E, (bit<32>)mirror_id, { meta.int_metadata_i2e.sink, meta.i2e_metadata.mirror_session_id }); hdr.int_header.setInvalid(); hdr.int_val[0].setInvalid(); hdr.int_val[1].setInvalid(); @@ -4259,26 +4242,13 @@ control process_tunnel(inout headers hdr, inout metadata meta, inout standard_me } } -struct struct_3 { - bit<16> field_7; - bit<16> field_8; - bit<16> field_9; - bit<9> field_10; -} - -struct struct_4 { - struct_3 field_11; - bit<16> field_12; - bit<16> field_13; -} - control process_ingress_sflow(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("nop") action nop() { } @name("sflow_ing_pkt_to_cpu") action sflow_ing_pkt_to_cpu(bit<16> sflow_i2e_mirror_id, bit<16> reason_code) { meta.fabric_metadata.reason_code = reason_code; meta.i2e_metadata.mirror_session_id = 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, bit<16>, bit<16>, bit<9>>, bit<16>, bit<16>>>(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 }); } @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; @@ -4476,11 +4446,6 @@ control process_mac(inout headers hdr, inout metadata meta, inout standard_metad } } -struct struct_5 { - bit<32> field_14; - bit<16> field_15; -} - control process_mac_acl(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("nop") action nop() { } @@ -4500,7 +4465,7 @@ control process_mac_acl(inout headers hdr, inout metadata meta, inout standard_m @name("acl_mirror") action acl_mirror(bit<16> session_id, bit<14> acl_stats_index, bit<16> acl_meter_index) { meta.i2e_metadata.mirror_session_id = session_id; meta.i2e_metadata.ingress_tstamp = (bit<32>)meta.intrinsic_metadata.ingress_global_tstamp; - clone3(CloneType.I2E, (bit<32>)session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); + clone3, bit<16>>>(CloneType.I2E, (bit<32>)session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); meta.acl_metadata.acl_stats_index = acl_stats_index; meta.meter_metadata.meter_index = acl_meter_index; } @@ -4548,11 +4513,6 @@ control process_mac_acl(inout headers hdr, inout metadata meta, inout standard_m } } -struct struct_6 { - bit<32> field_16; - bit<16> field_17; -} - control process_ip_acl(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("nop") action nop() { } @@ -4572,7 +4532,7 @@ control process_ip_acl(inout headers hdr, inout metadata meta, inout standard_me @name("acl_mirror") action acl_mirror(bit<16> session_id, bit<14> acl_stats_index, bit<16> acl_meter_index) { meta.i2e_metadata.mirror_session_id = session_id; meta.i2e_metadata.ingress_tstamp = (bit<32>)meta.intrinsic_metadata.ingress_global_tstamp; - clone3(CloneType.I2E, (bit<32>)session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); + clone3, bit<16>>>(CloneType.I2E, (bit<32>)session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); meta.acl_metadata.acl_stats_index = acl_stats_index; meta.meter_metadata.meter_index = acl_meter_index; } @@ -5284,60 +5244,17 @@ control process_meter_index(inout headers hdr, inout metadata meta, inout standa } } -struct struct_7 { - bit<32> field_18; - bit<32> field_19; - bit<8> field_20; - bit<16> field_21; - bit<16> field_22; -} - -struct struct_8 { - bit<48> field_23; - bit<48> field_24; - bit<32> field_25; - bit<32> field_26; - bit<8> field_27; - bit<16> field_28; - bit<16> field_29; -} - -struct struct_9 { - bit<128> field_30; - bit<128> field_31; - bit<8> field_32; - bit<16> field_33; - bit<16> field_34; -} - -struct struct_10 { - bit<48> field_35; - bit<48> field_36; - bit<128> field_37; - bit<128> field_38; - bit<8> field_39; - bit<16> field_40; - bit<16> field_41; -} - -struct struct_11 { - bit<16> field_42; - bit<48> field_43; - bit<48> field_44; - bit<16> field_45; -} - control process_hashes(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("compute_lkp_ipv4_hash") action compute_lkp_ipv4_hash() { - hash, bit<16>, struct_7, bit<32>>(meta.hash_metadata.hash1, HashAlgorithm.crc16, 16w0, { meta.ipv4_metadata.lkp_ipv4_sa, meta.ipv4_metadata.lkp_ipv4_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); - hash, bit<16>, struct_8, bit<32>>(meta.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta.l2_metadata.lkp_mac_sa, meta.l2_metadata.lkp_mac_da, meta.ipv4_metadata.lkp_ipv4_sa, meta.ipv4_metadata.lkp_ipv4_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); + hash, bit<16>, tuple, bit<32>, bit<8>, bit<16>, bit<16>>, bit<32>>(meta.hash_metadata.hash1, HashAlgorithm.crc16, 16w0, { meta.ipv4_metadata.lkp_ipv4_sa, meta.ipv4_metadata.lkp_ipv4_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); + hash, bit<16>, tuple, bit<48>, bit<32>, bit<32>, bit<8>, bit<16>, bit<16>>, bit<32>>(meta.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta.l2_metadata.lkp_mac_sa, meta.l2_metadata.lkp_mac_da, meta.ipv4_metadata.lkp_ipv4_sa, meta.ipv4_metadata.lkp_ipv4_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); } @name("compute_lkp_ipv6_hash") action compute_lkp_ipv6_hash() { - hash, bit<16>, struct_9, bit<32>>(meta.hash_metadata.hash1, HashAlgorithm.crc16, 16w0, { meta.ipv6_metadata.lkp_ipv6_sa, meta.ipv6_metadata.lkp_ipv6_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); - hash, bit<16>, struct_10, bit<32>>(meta.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta.l2_metadata.lkp_mac_sa, meta.l2_metadata.lkp_mac_da, meta.ipv6_metadata.lkp_ipv6_sa, meta.ipv6_metadata.lkp_ipv6_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); + hash, bit<16>, tuple, bit<128>, bit<8>, bit<16>, bit<16>>, bit<32>>(meta.hash_metadata.hash1, HashAlgorithm.crc16, 16w0, { meta.ipv6_metadata.lkp_ipv6_sa, meta.ipv6_metadata.lkp_ipv6_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); + hash, bit<16>, tuple, bit<48>, bit<128>, bit<128>, bit<8>, bit<16>, bit<16>>, bit<32>>(meta.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta.l2_metadata.lkp_mac_sa, meta.l2_metadata.lkp_mac_da, meta.ipv6_metadata.lkp_ipv6_sa, meta.ipv6_metadata.lkp_ipv6_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); } @name("compute_lkp_non_ip_hash") action compute_lkp_non_ip_hash() { - hash, bit<16>, struct_11, bit<32>>(meta.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta.ingress_metadata.ifindex, meta.l2_metadata.lkp_mac_sa, meta.l2_metadata.lkp_mac_da, meta.l2_metadata.lkp_mac_type }, 32w65536); + hash, bit<16>, tuple, bit<48>, bit<48>, bit<16>>, bit<32>>(meta.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta.ingress_metadata.ifindex, meta.l2_metadata.lkp_mac_sa, meta.l2_metadata.lkp_mac_da, meta.l2_metadata.lkp_mac_type }, 32w65536); } @name("computed_two_hashes") action computed_two_hashes() { meta.intrinsic_metadata.mcast_hash = (bit<13>)meta.hash_metadata.hash1; @@ -5761,25 +5678,6 @@ control process_fabric_lag(inout headers hdr, inout metadata meta, inout standar } } -struct struct_12 { - bit<16> field_46; - bit<16> field_47; - bit<16> field_48; - bit<9> field_49; -} - -struct struct_13 { - bit<16> field_50; - bit<16> field_51; - bit<16> field_52; - bit<9> field_53; -} - -struct struct_14 { - bit<16> field_54; - bit<8> field_55; -} - control process_system_acl(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("drop_stats") counter(32w1024, CounterType.packets) drop_stats; @name("drop_stats_2") counter(32w1024, CounterType.packets) drop_stats_2; @@ -5790,7 +5688,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, 32w250, { meta.ingress_metadata.bd, meta.ingress_metadata.ifindex, meta.fabric_metadata.reason_code, meta.ingress_metadata.ingress_port }); + 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 }); } @name("redirect_to_cpu") action redirect_to_cpu(bit<16> reason_code) { copy_to_cpu_with_reason(reason_code); @@ -5798,7 +5696,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, 32w250, { meta.ingress_metadata.bd, meta.ingress_metadata.ifindex, meta.fabric_metadata.reason_code, meta.ingress_metadata.ingress_port }); + 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 }); } @name("drop_packet") action drop_packet() { mark_to_drop(); @@ -5808,7 +5706,7 @@ control process_system_acl(inout headers hdr, inout metadata meta, inout standar mark_to_drop(); } @name("negative_mirror") action negative_mirror(bit<8> session_id) { - clone3(CloneType.I2E, (bit<32>)session_id, { meta.ingress_metadata.ifindex, meta.ingress_metadata.drop_reason }); + clone3, bit<8>>>(CloneType.I2E, (bit<32>)session_id, { meta.ingress_metadata.ifindex, meta.ingress_metadata.drop_reason }); mark_to_drop(); } @name("drop_stats") table drop_stats_0() { @@ -6040,81 +5938,25 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_15 { - bit<4> field_56; - bit<4> field_57; - bit<8> field_58; - bit<16> field_59; - bit<16> field_60; - bit<3> field_61; - bit<13> field_62; - bit<8> field_63; - bit<8> field_64; - bit<32> field_65; - bit<32> field_66; -} - -struct struct_16 { - bit<4> field_67; - bit<4> field_68; - bit<8> field_69; - bit<16> field_70; - bit<16> field_71; - bit<3> field_72; - bit<13> field_73; - bit<8> field_74; - bit<8> field_75; - bit<32> field_76; - bit<32> field_77; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { Checksum16() inner_ipv4_checksum; Checksum16() ipv4_checksum; apply { - if (hdr.inner_ipv4.ihl == 4w5 && hdr.inner_ipv4.hdrChecksum == (inner_ipv4_checksum.get({ 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 }))) + if (hdr.inner_ipv4.ihl == 4w5 && hdr.inner_ipv4.hdrChecksum == (inner_ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) mark_to_drop(); - if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.hdrChecksum == (ipv4_checksum.get({ 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 }))) + if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.hdrChecksum == (ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) mark_to_drop(); } } -struct struct_17 { - bit<4> field_78; - bit<4> field_79; - bit<8> field_80; - bit<16> field_81; - bit<16> field_82; - bit<3> field_83; - bit<13> field_84; - bit<8> field_85; - bit<8> field_86; - bit<32> field_87; - bit<32> field_88; -} - -struct struct_18 { - bit<4> field_89; - bit<4> field_90; - bit<8> field_91; - bit<16> field_92; - bit<16> field_93; - bit<3> field_94; - bit<13> field_95; - bit<8> field_96; - bit<8> field_97; - bit<32> field_98; - bit<32> field_99; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { Checksum16() inner_ipv4_checksum; Checksum16() ipv4_checksum; apply { if (hdr.inner_ipv4.ihl == 4w5) - hdr.inner_ipv4.hdrChecksum = inner_ipv4_checksum.get({ 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 = inner_ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); if (hdr.ipv4.ihl == 4w5) - hdr.ipv4.hdrChecksum = ipv4_checksum.get({ 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 = ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } } 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 d4f75f7c94b..fd1c66dd386 100644 --- a/testdata/p4_14_samples_outputs/switch_20160512/switch-frontend.p4 +++ b/testdata/p4_14_samples_outputs/switch_20160512/switch-frontend.p4 @@ -2846,24 +2846,12 @@ control process_egress_filter(inout headers hdr, inout metadata meta, inout stan } } -struct struct_0 { - bit<32> field; - bit<16> field_0; -} - -struct struct_1 { - bit<16> field_1; - bit<16> field_2; - bit<16> field_3; - bit<9> field_4; -} - control process_egress_acl(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("nop") action nop_10() { } @name("egress_mirror") action egress_mirror_0(bit<16> session_id) { meta.i2e_metadata.mirror_session_id = session_id; - clone3(CloneType.E2E, (bit<32>)session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); + clone3, bit<16>>>(CloneType.E2E, (bit<32>)session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); } @name("egress_mirror_drop") action egress_mirror_drop_0(bit<16> session_id) { egress_mirror_0(session_id); @@ -2871,7 +2859,7 @@ control process_egress_acl(inout headers hdr, inout metadata meta, inout standar } @name("egress_copy_to_cpu") action egress_copy_to_cpu_0(bit<16> reason_code) { meta.fabric_metadata.reason_code = reason_code; - clone3(CloneType.E2E, 32w250, { meta.ingress_metadata.bd, meta.ingress_metadata.ifindex, meta.fabric_metadata.reason_code, meta.ingress_metadata.ingress_port }); + 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 }); } @name("egress_redirect_to_cpu") action egress_redirect_to_cpu_0(bit<16> reason_code) { egress_copy_to_cpu_0(reason_code); @@ -3375,11 +3363,6 @@ control process_ip_sourceguard(inout headers hdr, inout metadata meta, inout sta } } -struct struct_2 { - bit<1> field_5; - bit<16> field_6; -} - control process_int_endpoint(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("int_sink_update_vxlan_gpe_v4") action int_sink_update_vxlan_gpe_v4_0() { hdr.vxlan_gpe.next_proto = hdr.vxlan_gpe_int_header.next_proto; @@ -3398,7 +3381,7 @@ control process_int_endpoint(inout headers hdr, inout metadata meta, inout stand @name("int_sink") action int_sink_0(bit<16> mirror_id) { meta.int_metadata_i2e.sink = 1w1; meta.i2e_metadata.mirror_session_id = mirror_id; - clone3(CloneType.I2E, (bit<32>)mirror_id, { meta.int_metadata_i2e.sink, meta.i2e_metadata.mirror_session_id }); + clone3, bit<16>>>(CloneType.I2E, (bit<32>)mirror_id, { meta.int_metadata_i2e.sink, meta.i2e_metadata.mirror_session_id }); hdr.int_header.setInvalid(); hdr.int_val[0].setInvalid(); hdr.int_val[1].setInvalid(); @@ -4175,26 +4158,13 @@ control process_tunnel(inout headers hdr, inout metadata meta, inout standard_me } } -struct struct_3 { - bit<16> field_7; - bit<16> field_8; - bit<16> field_9; - bit<9> field_10; -} - -struct struct_4 { - struct_3 field_11; - bit<16> field_12; - bit<16> field_13; -} - control process_ingress_sflow(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("nop") action nop_19() { } @name("sflow_ing_pkt_to_cpu") action sflow_ing_pkt_to_cpu_0(bit<16> sflow_i2e_mirror_id, bit<16> reason_code) { meta.fabric_metadata.reason_code = reason_code; meta.i2e_metadata.mirror_session_id = 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, bit<16>, bit<16>, bit<9>>, bit<16>, bit<16>>>(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 }); } @name("sflow_ing_session_enable") action sflow_ing_session_enable_0(bit<32> rate_thr, bit<16> session_id) { meta.ingress_metadata.sflow_take_sample = rate_thr + meta.ingress_metadata.sflow_take_sample; @@ -4392,11 +4362,6 @@ control process_mac(inout headers hdr, inout metadata meta, inout standard_metad } } -struct struct_5 { - bit<32> field_14; - bit<16> field_15; -} - control process_mac_acl(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("nop") action nop_23() { } @@ -4416,7 +4381,7 @@ control process_mac_acl(inout headers hdr, inout metadata meta, inout standard_m @name("acl_mirror") action acl_mirror_0(bit<16> session_id, bit<14> acl_stats_index, bit<16> acl_meter_index) { meta.i2e_metadata.mirror_session_id = session_id; meta.i2e_metadata.ingress_tstamp = (bit<32>)meta.intrinsic_metadata.ingress_global_tstamp; - clone3(CloneType.I2E, (bit<32>)session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); + clone3, bit<16>>>(CloneType.I2E, (bit<32>)session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); meta.acl_metadata.acl_stats_index = acl_stats_index; meta.meter_metadata.meter_index = acl_meter_index; } @@ -4464,11 +4429,6 @@ control process_mac_acl(inout headers hdr, inout metadata meta, inout standard_m } } -struct struct_6 { - bit<32> field_16; - bit<16> field_17; -} - control process_ip_acl(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("nop") action nop_24() { } @@ -4488,7 +4448,7 @@ control process_ip_acl(inout headers hdr, inout metadata meta, inout standard_me @name("acl_mirror") action acl_mirror_1(bit<16> session_id, bit<14> acl_stats_index, bit<16> acl_meter_index) { meta.i2e_metadata.mirror_session_id = session_id; meta.i2e_metadata.ingress_tstamp = (bit<32>)meta.intrinsic_metadata.ingress_global_tstamp; - clone3(CloneType.I2E, (bit<32>)session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); + clone3, bit<16>>>(CloneType.I2E, (bit<32>)session_id, { meta.i2e_metadata.ingress_tstamp, meta.i2e_metadata.mirror_session_id }); meta.acl_metadata.acl_stats_index = acl_stats_index; meta.meter_metadata.meter_index = acl_meter_index; } @@ -5198,60 +5158,17 @@ control process_meter_index(inout headers hdr, inout metadata meta, inout standa } } -struct struct_7 { - bit<32> field_18; - bit<32> field_19; - bit<8> field_20; - bit<16> field_21; - bit<16> field_22; -} - -struct struct_8 { - bit<48> field_23; - bit<48> field_24; - bit<32> field_25; - bit<32> field_26; - bit<8> field_27; - bit<16> field_28; - bit<16> field_29; -} - -struct struct_9 { - bit<128> field_30; - bit<128> field_31; - bit<8> field_32; - bit<16> field_33; - bit<16> field_34; -} - -struct struct_10 { - bit<48> field_35; - bit<48> field_36; - bit<128> field_37; - bit<128> field_38; - bit<8> field_39; - bit<16> field_40; - bit<16> field_41; -} - -struct struct_11 { - bit<16> field_42; - bit<48> field_43; - bit<48> field_44; - bit<16> field_45; -} - control process_hashes(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("compute_lkp_ipv4_hash") action compute_lkp_ipv4_hash_0() { - hash, bit<16>, struct_7, bit<32>>(meta.hash_metadata.hash1, HashAlgorithm.crc16, 16w0, { meta.ipv4_metadata.lkp_ipv4_sa, meta.ipv4_metadata.lkp_ipv4_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); - hash, bit<16>, struct_8, bit<32>>(meta.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta.l2_metadata.lkp_mac_sa, meta.l2_metadata.lkp_mac_da, meta.ipv4_metadata.lkp_ipv4_sa, meta.ipv4_metadata.lkp_ipv4_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); + hash, bit<16>, tuple, bit<32>, bit<8>, bit<16>, bit<16>>, bit<32>>(meta.hash_metadata.hash1, HashAlgorithm.crc16, 16w0, { meta.ipv4_metadata.lkp_ipv4_sa, meta.ipv4_metadata.lkp_ipv4_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); + hash, bit<16>, tuple, bit<48>, bit<32>, bit<32>, bit<8>, bit<16>, bit<16>>, bit<32>>(meta.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta.l2_metadata.lkp_mac_sa, meta.l2_metadata.lkp_mac_da, meta.ipv4_metadata.lkp_ipv4_sa, meta.ipv4_metadata.lkp_ipv4_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); } @name("compute_lkp_ipv6_hash") action compute_lkp_ipv6_hash_0() { - hash, bit<16>, struct_9, bit<32>>(meta.hash_metadata.hash1, HashAlgorithm.crc16, 16w0, { meta.ipv6_metadata.lkp_ipv6_sa, meta.ipv6_metadata.lkp_ipv6_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); - hash, bit<16>, struct_10, bit<32>>(meta.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta.l2_metadata.lkp_mac_sa, meta.l2_metadata.lkp_mac_da, meta.ipv6_metadata.lkp_ipv6_sa, meta.ipv6_metadata.lkp_ipv6_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); + hash, bit<16>, tuple, bit<128>, bit<8>, bit<16>, bit<16>>, bit<32>>(meta.hash_metadata.hash1, HashAlgorithm.crc16, 16w0, { meta.ipv6_metadata.lkp_ipv6_sa, meta.ipv6_metadata.lkp_ipv6_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); + hash, bit<16>, tuple, bit<48>, bit<128>, bit<128>, bit<8>, bit<16>, bit<16>>, bit<32>>(meta.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta.l2_metadata.lkp_mac_sa, meta.l2_metadata.lkp_mac_da, meta.ipv6_metadata.lkp_ipv6_sa, meta.ipv6_metadata.lkp_ipv6_da, meta.l3_metadata.lkp_ip_proto, meta.l3_metadata.lkp_l4_sport, meta.l3_metadata.lkp_l4_dport }, 32w65536); } @name("compute_lkp_non_ip_hash") action compute_lkp_non_ip_hash_0() { - hash, bit<16>, struct_11, bit<32>>(meta.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta.ingress_metadata.ifindex, meta.l2_metadata.lkp_mac_sa, meta.l2_metadata.lkp_mac_da, meta.l2_metadata.lkp_mac_type }, 32w65536); + hash, bit<16>, tuple, bit<48>, bit<48>, bit<16>>, bit<32>>(meta.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta.ingress_metadata.ifindex, meta.l2_metadata.lkp_mac_sa, meta.l2_metadata.lkp_mac_da, meta.l2_metadata.lkp_mac_type }, 32w65536); } @name("computed_two_hashes") action computed_two_hashes_0() { meta.intrinsic_metadata.mcast_hash = (bit<13>)meta.hash_metadata.hash1; @@ -5675,25 +5592,6 @@ control process_fabric_lag(inout headers hdr, inout metadata meta, inout standar } } -struct struct_12 { - bit<16> field_46; - bit<16> field_47; - bit<16> field_48; - bit<9> field_49; -} - -struct struct_13 { - bit<16> field_50; - bit<16> field_51; - bit<16> field_52; - bit<9> field_53; -} - -struct struct_14 { - bit<16> field_54; - bit<8> field_55; -} - control process_system_acl(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("drop_stats") counter(32w1024, CounterType.packets) drop_stats_1; @name("drop_stats_2") counter(32w1024, CounterType.packets) drop_stats_3; @@ -5704,7 +5602,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_0(bit<16> reason_code) { meta.fabric_metadata.reason_code = reason_code; - clone3(CloneType.I2E, 32w250, { meta.ingress_metadata.bd, meta.ingress_metadata.ifindex, meta.fabric_metadata.reason_code, meta.ingress_metadata.ingress_port }); + 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 }); } @name("redirect_to_cpu") action redirect_to_cpu_0(bit<16> reason_code) { copy_to_cpu_with_reason_0(reason_code); @@ -5712,7 +5610,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_0() { - clone3(CloneType.I2E, 32w250, { meta.ingress_metadata.bd, meta.ingress_metadata.ifindex, meta.fabric_metadata.reason_code, meta.ingress_metadata.ingress_port }); + 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 }); } @name("drop_packet") action drop_packet_0() { mark_to_drop(); @@ -5722,7 +5620,7 @@ control process_system_acl(inout headers hdr, inout metadata meta, inout standar mark_to_drop(); } @name("negative_mirror") action negative_mirror_0(bit<8> session_id) { - clone3(CloneType.I2E, (bit<32>)session_id, { meta.ingress_metadata.ifindex, meta.ingress_metadata.drop_reason }); + clone3, bit<8>>>(CloneType.I2E, (bit<32>)session_id, { meta.ingress_metadata.ifindex, meta.ingress_metadata.drop_reason }); mark_to_drop(); } @name("drop_stats") table drop_stats_4() { @@ -5954,81 +5852,25 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_15 { - bit<4> field_56; - bit<4> field_57; - bit<8> field_58; - bit<16> field_59; - bit<16> field_60; - bit<3> field_61; - bit<13> field_62; - bit<8> field_63; - bit<8> field_64; - bit<32> field_65; - bit<32> field_66; -} - -struct struct_16 { - bit<4> field_67; - bit<4> field_68; - bit<8> field_69; - bit<16> field_70; - bit<16> field_71; - bit<3> field_72; - bit<13> field_73; - bit<8> field_74; - bit<8> field_75; - bit<32> field_76; - bit<32> field_77; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("inner_ipv4_checksum") Checksum16() inner_ipv4_checksum_0; @name("ipv4_checksum") Checksum16() ipv4_checksum_0; apply { - if (hdr.inner_ipv4.ihl == 4w5 && hdr.inner_ipv4.hdrChecksum == (inner_ipv4_checksum_0.get({ 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 }))) + if (hdr.inner_ipv4.ihl == 4w5 && hdr.inner_ipv4.hdrChecksum == (inner_ipv4_checksum_0.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) mark_to_drop(); - if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.hdrChecksum == (ipv4_checksum_0.get({ 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 }))) + if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.hdrChecksum == (ipv4_checksum_0.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) mark_to_drop(); } } -struct struct_17 { - bit<4> field_78; - bit<4> field_79; - bit<8> field_80; - bit<16> field_81; - bit<16> field_82; - bit<3> field_83; - bit<13> field_84; - bit<8> field_85; - bit<8> field_86; - bit<32> field_87; - bit<32> field_88; -} - -struct struct_18 { - bit<4> field_89; - bit<4> field_90; - bit<8> field_91; - bit<16> field_92; - bit<16> field_93; - bit<3> field_94; - bit<13> field_95; - bit<8> field_96; - bit<8> field_97; - bit<32> field_98; - bit<32> field_99; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("inner_ipv4_checksum") Checksum16() inner_ipv4_checksum_1; @name("ipv4_checksum") Checksum16() ipv4_checksum_1; apply { if (hdr.inner_ipv4.ihl == 4w5) - hdr.inner_ipv4.hdrChecksum = inner_ipv4_checksum_1.get({ 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 = inner_ipv4_checksum_1.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); if (hdr.ipv4.ihl == 4w5) - hdr.ipv4.hdrChecksum = ipv4_checksum_1.get({ 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 = ipv4_checksum_1.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } } 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 066bad77860..af93d89e711 100644 --- a/testdata/p4_14_samples_outputs/switch_20160512/switch-midend.p4 +++ b/testdata/p4_14_samples_outputs/switch_20160512/switch-midend.p4 @@ -1190,18 +1190,6 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout } } -struct struct_0 { - bit<32> field; - bit<16> field_0; -} - -struct struct_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("hdr_21") headers hdr_64; @name("meta_21") metadata meta_64; @@ -3221,19 +3209,19 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } @name("process_egress_acl.egress_mirror") action process_egress_acl_egress_mirror(bit<16> session_id) { meta_77.i2e_metadata.mirror_session_id = session_id; - clone3(CloneType.E2E, (bit<32>)session_id, { meta_77.i2e_metadata.ingress_tstamp, meta_77.i2e_metadata.mirror_session_id }); + clone3, bit<16>>>(CloneType.E2E, (bit<32>)session_id, { meta_77.i2e_metadata.ingress_tstamp, meta_77.i2e_metadata.mirror_session_id }); } @name("process_egress_acl.egress_mirror_drop") action process_egress_acl_egress_mirror_drop(bit<16> session_id) { @name("process_egress_acl.egress_mirror") { meta_77.i2e_metadata.mirror_session_id = session_id; - clone3(CloneType.E2E, (bit<32>)session_id, { meta_77.i2e_metadata.ingress_tstamp, meta_77.i2e_metadata.mirror_session_id }); + clone3, bit<16>>>(CloneType.E2E, (bit<32>)session_id, { meta_77.i2e_metadata.ingress_tstamp, meta_77.i2e_metadata.mirror_session_id }); } mark_to_drop(); } @name("process_egress_acl.egress_redirect_to_cpu") action process_egress_acl_egress_redirect_to_cpu(bit<16> reason_code) { @name("process_egress_acl.egress_copy_to_cpu") { meta_77.fabric_metadata.reason_code = reason_code; - clone3(CloneType.E2E, 32w250, { meta_77.ingress_metadata.bd, meta_77.ingress_metadata.ifindex, meta_77.fabric_metadata.reason_code, meta_77.ingress_metadata.ingress_port }); + clone3, bit<16>, bit<16>, bit<9>>>(CloneType.E2E, 32w250, { meta_77.ingress_metadata.bd, meta_77.ingress_metadata.ifindex, meta_77.fabric_metadata.reason_code, meta_77.ingress_metadata.ingress_port }); } mark_to_drop(); } @@ -3600,102 +3588,12 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } } -struct struct_2 { - bit<1> field_5; - bit<16> field_6; -} - -struct struct_3 { - bit<16> field_7; - bit<16> field_8; - bit<16> field_9; - bit<9> field_10; -} - -struct struct_4 { - struct_3 field_11; - bit<16> field_12; - bit<16> field_13; -} - -struct struct_5 { - bit<32> field_14; - bit<16> field_15; -} - -struct struct_6 { - bit<32> field_16; - bit<16> field_17; -} - -struct struct_7 { - bit<32> field_18; - bit<32> field_19; - bit<8> field_20; - bit<16> field_21; - bit<16> field_22; -} - -struct struct_8 { - bit<48> field_23; - bit<48> field_24; - bit<32> field_25; - bit<32> field_26; - bit<8> field_27; - bit<16> field_28; - bit<16> field_29; -} - -struct struct_9 { - bit<128> field_30; - bit<128> field_31; - bit<8> field_32; - bit<16> field_33; - bit<16> field_34; -} - -struct struct_10 { - bit<48> field_35; - bit<48> field_36; - bit<128> field_37; - bit<128> field_38; - bit<8> field_39; - bit<16> field_40; - bit<16> field_41; -} - -struct struct_11 { - bit<16> field_42; - bit<48> field_43; - bit<48> field_44; - bit<16> field_45; -} - @name("mac_learn_digest") struct mac_learn_digest { bit<16> bd; bit<48> lkp_mac_sa; bit<16> ifindex; } -struct struct_12 { - bit<16> field_46; - bit<16> field_47; - bit<16> field_48; - bit<9> field_49; -} - -struct struct_13 { - bit<16> field_50; - bit<16> field_51; - bit<16> field_52; - bit<9> field_53; -} - -struct struct_14 { - bit<16> field_54; - bit<8> field_55; -} - control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("hdr_14") headers hdr_78; @name("meta_14") metadata meta_78; @@ -4337,7 +4235,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ @name("process_int_endpoint.int_sink") { meta_87.int_metadata_i2e.sink = 1w1; meta_87.i2e_metadata.mirror_session_id = mirror_id; - clone3(CloneType.I2E, (bit<32>)mirror_id, { meta_87.int_metadata_i2e.sink, meta_87.i2e_metadata.mirror_session_id }); + clone3, bit<16>>>(CloneType.I2E, (bit<32>)mirror_id, { meta_87.int_metadata_i2e.sink, meta_87.i2e_metadata.mirror_session_id }); hdr_87.int_header.setInvalid(); hdr_87.int_val[0].setInvalid(); hdr_87.int_val[1].setInvalid(); @@ -5021,7 +4919,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ @name("process_ingress_sflow.sflow_ing_pkt_to_cpu") action process_ingress_sflow_sflow_ing_pkt_to_cpu(bit<16> sflow_i2e_mirror_id, bit<16> reason_code) { meta_97.fabric_metadata.reason_code = reason_code; meta_97.i2e_metadata.mirror_session_id = sflow_i2e_mirror_id; - clone3(CloneType.I2E, (bit<32>)sflow_i2e_mirror_id, { { meta_97.ingress_metadata.bd, meta_97.ingress_metadata.ifindex, meta_97.fabric_metadata.reason_code, meta_97.ingress_metadata.ingress_port }, meta_97.sflow_metadata.sflow_session_id, meta_97.i2e_metadata.mirror_session_id }); + clone3, bit<16>, bit<16>, bit<9>>, bit<16>, bit<16>>>(CloneType.I2E, (bit<32>)sflow_i2e_mirror_id, { { meta_97.ingress_metadata.bd, meta_97.ingress_metadata.ifindex, meta_97.fabric_metadata.reason_code, meta_97.ingress_metadata.ingress_port }, meta_97.sflow_metadata.sflow_session_id, meta_97.i2e_metadata.mirror_session_id }); } @name("process_ingress_sflow.sflow_ing_session_enable") action process_ingress_sflow_sflow_ing_session_enable(bit<32> rate_thr, bit<16> session_id) { meta_97.ingress_metadata.sflow_take_sample = rate_thr + meta_97.ingress_metadata.sflow_take_sample; @@ -5210,7 +5108,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ @name("process_mac_acl.acl_mirror") action process_mac_acl_acl_mirror(bit<16> session_id, bit<14> acl_stats_index, bit<16> acl_meter_index) { meta_101.i2e_metadata.mirror_session_id = session_id; meta_101.i2e_metadata.ingress_tstamp = (bit<32>)meta_101.intrinsic_metadata.ingress_global_tstamp; - clone3(CloneType.I2E, (bit<32>)session_id, { meta_101.i2e_metadata.ingress_tstamp, meta_101.i2e_metadata.mirror_session_id }); + clone3, bit<16>>>(CloneType.I2E, (bit<32>)session_id, { meta_101.i2e_metadata.ingress_tstamp, meta_101.i2e_metadata.mirror_session_id }); meta_101.acl_metadata.acl_stats_index = acl_stats_index; meta_101.meter_metadata.meter_index = acl_meter_index; } @@ -5285,14 +5183,14 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ @name("process_ip_acl.acl_mirror") action process_ip_acl_acl_mirror(bit<16> session_id, bit<14> acl_stats_index, bit<16> acl_meter_index) { meta_102.i2e_metadata.mirror_session_id = session_id; meta_102.i2e_metadata.ingress_tstamp = (bit<32>)meta_102.intrinsic_metadata.ingress_global_tstamp; - clone3(CloneType.I2E, (bit<32>)session_id, { meta_102.i2e_metadata.ingress_tstamp, meta_102.i2e_metadata.mirror_session_id }); + clone3, bit<16>>>(CloneType.I2E, (bit<32>)session_id, { meta_102.i2e_metadata.ingress_tstamp, meta_102.i2e_metadata.mirror_session_id }); meta_102.acl_metadata.acl_stats_index = acl_stats_index; meta_102.meter_metadata.meter_index = acl_meter_index; } @name("process_ip_acl.acl_mirror") action process_ip_acl_acl_mirror_2(bit<16> session_id, bit<14> acl_stats_index, bit<16> acl_meter_index) { meta_102.i2e_metadata.mirror_session_id = session_id; meta_102.i2e_metadata.ingress_tstamp = (bit<32>)meta_102.intrinsic_metadata.ingress_global_tstamp; - clone3(CloneType.I2E, (bit<32>)session_id, { meta_102.i2e_metadata.ingress_tstamp, meta_102.i2e_metadata.mirror_session_id }); + clone3, bit<16>>>(CloneType.I2E, (bit<32>)session_id, { meta_102.i2e_metadata.ingress_tstamp, meta_102.i2e_metadata.mirror_session_id }); meta_102.acl_metadata.acl_stats_index = acl_stats_index; meta_102.meter_metadata.meter_index = acl_meter_index; } @@ -5914,15 +5812,15 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ meters = process_meter_index_meter_index_1; } @name("process_hashes.compute_lkp_ipv4_hash") action process_hashes_compute_lkp_ipv4_hash() { - hash, bit<16>, struct_7, bit<32>>(meta_116.hash_metadata.hash1, HashAlgorithm.crc16, 16w0, { meta_116.ipv4_metadata.lkp_ipv4_sa, meta_116.ipv4_metadata.lkp_ipv4_da, meta_116.l3_metadata.lkp_ip_proto, meta_116.l3_metadata.lkp_l4_sport, meta_116.l3_metadata.lkp_l4_dport }, 32w65536); - hash, bit<16>, struct_8, bit<32>>(meta_116.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta_116.l2_metadata.lkp_mac_sa, meta_116.l2_metadata.lkp_mac_da, meta_116.ipv4_metadata.lkp_ipv4_sa, meta_116.ipv4_metadata.lkp_ipv4_da, meta_116.l3_metadata.lkp_ip_proto, meta_116.l3_metadata.lkp_l4_sport, meta_116.l3_metadata.lkp_l4_dport }, 32w65536); + hash, bit<16>, tuple, bit<32>, bit<8>, bit<16>, bit<16>>, bit<32>>(meta_116.hash_metadata.hash1, HashAlgorithm.crc16, 16w0, { meta_116.ipv4_metadata.lkp_ipv4_sa, meta_116.ipv4_metadata.lkp_ipv4_da, meta_116.l3_metadata.lkp_ip_proto, meta_116.l3_metadata.lkp_l4_sport, meta_116.l3_metadata.lkp_l4_dport }, 32w65536); + hash, bit<16>, tuple, bit<48>, bit<32>, bit<32>, bit<8>, bit<16>, bit<16>>, bit<32>>(meta_116.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta_116.l2_metadata.lkp_mac_sa, meta_116.l2_metadata.lkp_mac_da, meta_116.ipv4_metadata.lkp_ipv4_sa, meta_116.ipv4_metadata.lkp_ipv4_da, meta_116.l3_metadata.lkp_ip_proto, meta_116.l3_metadata.lkp_l4_sport, meta_116.l3_metadata.lkp_l4_dport }, 32w65536); } @name("process_hashes.compute_lkp_ipv6_hash") action process_hashes_compute_lkp_ipv6_hash() { - hash, bit<16>, struct_9, bit<32>>(meta_116.hash_metadata.hash1, HashAlgorithm.crc16, 16w0, { meta_116.ipv6_metadata.lkp_ipv6_sa, meta_116.ipv6_metadata.lkp_ipv6_da, meta_116.l3_metadata.lkp_ip_proto, meta_116.l3_metadata.lkp_l4_sport, meta_116.l3_metadata.lkp_l4_dport }, 32w65536); - hash, bit<16>, struct_10, bit<32>>(meta_116.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta_116.l2_metadata.lkp_mac_sa, meta_116.l2_metadata.lkp_mac_da, meta_116.ipv6_metadata.lkp_ipv6_sa, meta_116.ipv6_metadata.lkp_ipv6_da, meta_116.l3_metadata.lkp_ip_proto, meta_116.l3_metadata.lkp_l4_sport, meta_116.l3_metadata.lkp_l4_dport }, 32w65536); + hash, bit<16>, tuple, bit<128>, bit<8>, bit<16>, bit<16>>, bit<32>>(meta_116.hash_metadata.hash1, HashAlgorithm.crc16, 16w0, { meta_116.ipv6_metadata.lkp_ipv6_sa, meta_116.ipv6_metadata.lkp_ipv6_da, meta_116.l3_metadata.lkp_ip_proto, meta_116.l3_metadata.lkp_l4_sport, meta_116.l3_metadata.lkp_l4_dport }, 32w65536); + hash, bit<16>, tuple, bit<48>, bit<128>, bit<128>, bit<8>, bit<16>, bit<16>>, bit<32>>(meta_116.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta_116.l2_metadata.lkp_mac_sa, meta_116.l2_metadata.lkp_mac_da, meta_116.ipv6_metadata.lkp_ipv6_sa, meta_116.ipv6_metadata.lkp_ipv6_da, meta_116.l3_metadata.lkp_ip_proto, meta_116.l3_metadata.lkp_l4_sport, meta_116.l3_metadata.lkp_l4_dport }, 32w65536); } @name("process_hashes.compute_lkp_non_ip_hash") action process_hashes_compute_lkp_non_ip_hash() { - hash, bit<16>, struct_11, bit<32>>(meta_116.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta_116.ingress_metadata.ifindex, meta_116.l2_metadata.lkp_mac_sa, meta_116.l2_metadata.lkp_mac_da, meta_116.l2_metadata.lkp_mac_type }, 32w65536); + hash, bit<16>, tuple, bit<48>, bit<48>, bit<16>>, bit<32>>(meta_116.hash_metadata.hash2, HashAlgorithm.crc16, 16w0, { meta_116.ingress_metadata.ifindex, meta_116.l2_metadata.lkp_mac_sa, meta_116.l2_metadata.lkp_mac_da, meta_116.l2_metadata.lkp_mac_type }, 32w65536); } @name("process_hashes.computed_two_hashes") action process_hashes_computed_two_hashes() { meta_116.intrinsic_metadata.mcast_hash = (bit<13>)meta_116.hash_metadata.hash1; @@ -6273,18 +6171,18 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } @name("process_system_acl.copy_to_cpu_with_reason") action process_system_acl_copy_to_cpu_with_reason(bit<16> reason_code) { meta_127.fabric_metadata.reason_code = reason_code; - clone3(CloneType.I2E, 32w250, { meta_127.ingress_metadata.bd, meta_127.ingress_metadata.ifindex, meta_127.fabric_metadata.reason_code, meta_127.ingress_metadata.ingress_port }); + clone3, bit<16>, bit<16>, bit<9>>>(CloneType.I2E, 32w250, { meta_127.ingress_metadata.bd, meta_127.ingress_metadata.ifindex, meta_127.fabric_metadata.reason_code, meta_127.ingress_metadata.ingress_port }); } @name("process_system_acl.redirect_to_cpu") action process_system_acl_redirect_to_cpu(bit<16> reason_code) { @name("process_system_acl.copy_to_cpu_with_reason") { meta_127.fabric_metadata.reason_code = reason_code; - clone3(CloneType.I2E, 32w250, { meta_127.ingress_metadata.bd, meta_127.ingress_metadata.ifindex, meta_127.fabric_metadata.reason_code, meta_127.ingress_metadata.ingress_port }); + clone3, bit<16>, bit<16>, bit<9>>>(CloneType.I2E, 32w250, { meta_127.ingress_metadata.bd, meta_127.ingress_metadata.ifindex, meta_127.fabric_metadata.reason_code, meta_127.ingress_metadata.ingress_port }); } mark_to_drop(); meta_127.fabric_metadata.dst_device = 8w0; } @name("process_system_acl.copy_to_cpu") action process_system_acl_copy_to_cpu() { - clone3(CloneType.I2E, 32w250, { meta_127.ingress_metadata.bd, meta_127.ingress_metadata.ifindex, meta_127.fabric_metadata.reason_code, meta_127.ingress_metadata.ingress_port }); + clone3, bit<16>, bit<16>, bit<9>>>(CloneType.I2E, 32w250, { meta_127.ingress_metadata.bd, meta_127.ingress_metadata.ifindex, meta_127.fabric_metadata.reason_code, meta_127.ingress_metadata.ingress_port }); } @name("process_system_acl.drop_packet") action process_system_acl_drop_packet() { mark_to_drop(); @@ -6294,7 +6192,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ mark_to_drop(); } @name("process_system_acl.negative_mirror") action process_system_acl_negative_mirror(bit<8> session_id) { - clone3(CloneType.I2E, (bit<32>)session_id, { meta_127.ingress_metadata.ifindex, meta_127.ingress_metadata.drop_reason }); + clone3, bit<8>>>(CloneType.I2E, (bit<32>)session_id, { meta_127.ingress_metadata.ifindex, meta_127.ingress_metadata.drop_reason }); mark_to_drop(); } @name("process_system_acl.drop_stats") table process_system_acl_drop_stats_4() { @@ -7619,34 +7517,6 @@ control DeparserImpl(packet_out packet, in headers hdr) { } } -struct struct_15 { - bit<4> field_56; - bit<4> field_57; - bit<8> field_58; - bit<16> field_59; - bit<16> field_60; - bit<3> field_61; - bit<13> field_62; - bit<8> field_63; - bit<8> field_64; - bit<32> field_65; - bit<32> field_66; -} - -struct struct_16 { - bit<4> field_67; - bit<4> field_68; - bit<8> field_69; - bit<16> field_70; - bit<16> field_71; - bit<3> field_72; - bit<13> field_73; - bit<8> field_74; - bit<8> field_75; - bit<32> field_76; - bit<32> field_77; -} - control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("inner_ipv4_checksum") Checksum16() inner_ipv4_checksum; @name("ipv4_checksum") Checksum16() ipv4_checksum; @@ -7669,49 +7539,21 @@ control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metad const default_action = act_96(); } apply { - if (hdr.inner_ipv4.ihl == 4w5 && hdr.inner_ipv4.hdrChecksum == (inner_ipv4_checksum.get({ 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 }))) + if (hdr.inner_ipv4.ihl == 4w5 && hdr.inner_ipv4.hdrChecksum == (inner_ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) tbl_act_95.apply(); - if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.hdrChecksum == (ipv4_checksum.get({ 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 }))) + if (hdr.ipv4.ihl == 4w5 && hdr.ipv4.hdrChecksum == (ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) tbl_act_96.apply(); } } -struct struct_17 { - bit<4> field_78; - bit<4> field_79; - bit<8> field_80; - bit<16> field_81; - bit<16> field_82; - bit<3> field_83; - bit<13> field_84; - bit<8> field_85; - bit<8> field_86; - bit<32> field_87; - bit<32> field_88; -} - -struct struct_18 { - bit<4> field_89; - bit<4> field_90; - bit<8> field_91; - bit<16> field_92; - bit<16> field_93; - bit<3> field_94; - bit<13> field_95; - bit<8> field_96; - bit<8> field_97; - bit<32> field_98; - bit<32> field_99; -} - control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("inner_ipv4_checksum") Checksum16() inner_ipv4_checksum_2; @name("ipv4_checksum") Checksum16() ipv4_checksum_2; action act_97() { - hdr.inner_ipv4.hdrChecksum = inner_ipv4_checksum_2.get({ 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 = inner_ipv4_checksum_2.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } action act_98() { - hdr.ipv4.hdrChecksum = ipv4_checksum_2.get({ 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 = ipv4_checksum_2.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); } table tbl_act_97() { actions = { diff --git a/testdata/p4_16_errors/tuple-left.p4 b/testdata/p4_16_errors/tuple-left.p4 new file mode 100644 index 00000000000..885681f3059 --- /dev/null +++ b/testdata/p4_16_errors/tuple-left.p4 @@ -0,0 +1,28 @@ +/* +Copyright 2016 VMware, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +control c() { + bit<32> a; + bit<32> b; + apply { + { a, b } = { 10, 20 }; + } +} + +control proto(); +package top(proto _p); + +top(c()) main; diff --git a/testdata/p4_16_errors_outputs/tuple-left.p4-stderr b/testdata/p4_16_errors_outputs/tuple-left.p4-stderr new file mode 100644 index 00000000000..0df65e009c3 --- /dev/null +++ b/testdata/p4_16_errors_outputs/tuple-left.p4-stderr @@ -0,0 +1,4 @@ +../testdata/p4_16_errors/tuple-left.p4(21):syntax error, unexpected ',' + { a, + ^ +error: 1 errors encountered, aborting compilation diff --git a/testdata/p4_16_samples/tuple.p4 b/testdata/p4_16_samples/tuple.p4 new file mode 100644 index 00000000000..d3a0cba6608 --- /dev/null +++ b/testdata/p4_16_samples/tuple.p4 @@ -0,0 +1,36 @@ +/* +Copyright 2016 VMware, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +typedef tuple, bool> pair; +struct S { + bit<32> f; + bool s; +} + +control proto(); +package top(proto _p); + +control c() { + pair x = { 10, false }; + tuple, bool> y; + S z; + apply { + y = x; + z = y; + } +} + +top(c()) main; diff --git a/testdata/p4_16_samples/tuple1.p4 b/testdata/p4_16_samples/tuple1.p4 new file mode 100644 index 00000000000..06e078edcc5 --- /dev/null +++ b/testdata/p4_16_samples/tuple1.p4 @@ -0,0 +1,29 @@ +/* +Copyright 2016 VMware, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +extern void f(in T data); + +control proto(); +package top(proto _p); + +control c() { + tuple, bool> x = { 10, false }; + apply { + f(x); + } +} + +top(c()) main; diff --git a/testdata/p4_16_samples_outputs/tuple-first.p4 b/testdata/p4_16_samples_outputs/tuple-first.p4 new file mode 100644 index 00000000000..a82f2e0e76b --- /dev/null +++ b/testdata/p4_16_samples_outputs/tuple-first.p4 @@ -0,0 +1,19 @@ +typedef tuple, bool> pair; +struct S { + bit<32> f; + bool s; +} + +control proto(); +package top(proto _p); +control c() { + tuple, bool> x = { 32w10, false }; + tuple, bool> y; + S z; + apply { + y = x; + z = y; + } +} + +top(c()) main; diff --git a/testdata/p4_16_samples_outputs/tuple-frontend.p4 b/testdata/p4_16_samples_outputs/tuple-frontend.p4 new file mode 100644 index 00000000000..a75cd70856f --- /dev/null +++ b/testdata/p4_16_samples_outputs/tuple-frontend.p4 @@ -0,0 +1,19 @@ +struct S { + bit<32> f; + bool s; +} + +control proto(); +package top(proto _p); +control c() { + @name("x") tuple, bool> x_0; + @name("y") tuple, bool> y_0; + @name("z") S z_0; + apply { + x_0 = { 32w10, false }; + y_0 = x_0; + z_0 = y_0; + } +} + +top(c()) main; diff --git a/testdata/p4_16_samples_outputs/tuple-midend.p4 b/testdata/p4_16_samples_outputs/tuple-midend.p4 new file mode 100644 index 00000000000..b0b95ab23db --- /dev/null +++ b/testdata/p4_16_samples_outputs/tuple-midend.p4 @@ -0,0 +1,28 @@ +struct S { + bit<32> f; + bool s; +} + +control proto(); +package top(proto _p); +control c() { + @name("x") tuple, bool> x; + @name("y") tuple, bool> y; + @name("z") S z; + action act() { + x = { 32w10, false }; + y = x; + z = y; + } + table tbl_act() { + actions = { + act(); + } + const default_action = act(); + } + apply { + tbl_act.apply(); + } +} + +top(c()) main; diff --git a/testdata/p4_16_samples_outputs/tuple.p4 b/testdata/p4_16_samples_outputs/tuple.p4 new file mode 100644 index 00000000000..f6046f47ab1 --- /dev/null +++ b/testdata/p4_16_samples_outputs/tuple.p4 @@ -0,0 +1,19 @@ +typedef tuple, bool> pair; +struct S { + bit<32> f; + bool s; +} + +control proto(); +package top(proto _p); +control c() { + pair x = { 10, false }; + tuple, bool> y; + S z; + apply { + y = x; + z = y; + } +} + +top(c()) main; diff --git a/testdata/p4_16_samples_outputs/tuple.p4-stderr b/testdata/p4_16_samples_outputs/tuple.p4-stderr new file mode 100644 index 00000000000..e69de29bb2d diff --git a/testdata/p4_16_samples_outputs/tuple1-first.p4 b/testdata/p4_16_samples_outputs/tuple1-first.p4 new file mode 100644 index 00000000000..f3ece1ae81d --- /dev/null +++ b/testdata/p4_16_samples_outputs/tuple1-first.p4 @@ -0,0 +1,11 @@ +extern void f(in T data); +control proto(); +package top(proto _p); +control c() { + tuple, bool> x = { 32w10, false }; + apply { + f, bool>>(x); + } +} + +top(c()) main; diff --git a/testdata/p4_16_samples_outputs/tuple1-frontend.p4 b/testdata/p4_16_samples_outputs/tuple1-frontend.p4 new file mode 100644 index 00000000000..03b603e303f --- /dev/null +++ b/testdata/p4_16_samples_outputs/tuple1-frontend.p4 @@ -0,0 +1,12 @@ +extern void f(in T data); +control proto(); +package top(proto _p); +control c() { + @name("x") tuple, bool> x_0; + apply { + x_0 = { 32w10, false }; + f, bool>>(x_0); + } +} + +top(c()) main; diff --git a/testdata/p4_16_samples_outputs/tuple1-midend.p4 b/testdata/p4_16_samples_outputs/tuple1-midend.p4 new file mode 100644 index 00000000000..35f0a3da5c2 --- /dev/null +++ b/testdata/p4_16_samples_outputs/tuple1-midend.p4 @@ -0,0 +1,21 @@ +extern void f(in T data); +control proto(); +package top(proto _p); +control c() { + @name("x") tuple, bool> x; + action act() { + x = { 32w10, false }; + f, bool>>(x); + } + table tbl_act() { + actions = { + act(); + } + const default_action = act(); + } + apply { + tbl_act.apply(); + } +} + +top(c()) main; diff --git a/testdata/p4_16_samples_outputs/tuple1.p4 b/testdata/p4_16_samples_outputs/tuple1.p4 new file mode 100644 index 00000000000..ffc5d7cb664 --- /dev/null +++ b/testdata/p4_16_samples_outputs/tuple1.p4 @@ -0,0 +1,11 @@ +extern void f(in T data); +control proto(); +package top(proto _p); +control c() { + tuple, bool> x = { 10, false }; + apply { + f(x); + } +} + +top(c()) main; diff --git a/testdata/p4_16_samples_outputs/tuple1.p4-stderr b/testdata/p4_16_samples_outputs/tuple1.p4-stderr new file mode 100644 index 00000000000..e69de29bb2d diff --git a/testdata/p4_16_samples_outputs/uninit.p4-stderr b/testdata/p4_16_samples_outputs/uninit.p4-stderr index 00cdbdcdd42..e26f3bb642a 100644 --- a/testdata/p4_16_samples_outputs/uninit.p4-stderr +++ b/testdata/p4_16_samples_outputs/uninit.p4-stderr @@ -16,6 +16,9 @@ ../testdata/p4_16_samples/uninit.p4(42): warning: [] may not be completely initialized stack[0] = stack[1]; ^^^^^^^^ +../testdata/p4_16_samples/uninit.p4(62): warning: c_0 may be uninitialized + c = !c; + ^ ../testdata/p4_16_samples/uninit.p4(82): warning: b_1 may be uninitialized b = b + 1; ^ From b13c93bd6c67ae47632e6cf5b8214963757060bb Mon Sep 17 00:00:00 2001 From: mbudiu-vmw Date: Fri, 30 Sep 2016 08:41:33 -0700 Subject: [PATCH 6/9] Another bug fix addressing issue #94 - for the emit method --- backends/bmv2/jsonconverter.cpp | 5 +- testdata/p4_16_bmv_errors/no-header1-bmv2.p4 | 3 +- testdata/p4_16_bmv_errors/no-header2-bmv2.p4 | 71 ++++++++++++++++++++ 3 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 testdata/p4_16_bmv_errors/no-header2-bmv2.p4 diff --git a/backends/bmv2/jsonconverter.cpp b/backends/bmv2/jsonconverter.cpp index 40567579afc..dfe4bb4467b 100644 --- a/backends/bmv2/jsonconverter.cpp +++ b/backends/bmv2/jsonconverter.cpp @@ -1937,9 +1937,12 @@ void JsonConverter::convertDeparserBody(const IR::Vector* body, ref += "[" + Util::toString(i) + "]"; result->append(ref); } - } else { + } else if (type->is()) { auto j = conv->convert(arg); result->append(j->to()->get("value")); + } else { + ::error("%1%: emit only supports header and stack arguments, not %2%", + arg, type); } } continue; diff --git a/testdata/p4_16_bmv_errors/no-header1-bmv2.p4 b/testdata/p4_16_bmv_errors/no-header1-bmv2.p4 index 8211988896c..8c943696f9f 100644 --- a/testdata/p4_16_bmv_errors/no-header1-bmv2.p4 +++ b/testdata/p4_16_bmv_errors/no-header1-bmv2.p4 @@ -23,8 +23,7 @@ struct M { }; parser ParserI(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata) { state start { - // here I am trying to extract a struct -> segmentation fault - b.extract(parsedHdr); + b.extract(parsedHdr); // illegal data type transition accept; } } diff --git a/testdata/p4_16_bmv_errors/no-header2-bmv2.p4 b/testdata/p4_16_bmv_errors/no-header2-bmv2.p4 new file mode 100644 index 00000000000..6e1fd2d2b66 --- /dev/null +++ b/testdata/p4_16_bmv_errors/no-header2-bmv2.p4 @@ -0,0 +1,71 @@ +/* +Copyright 2016 VMware, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#include +#include + +struct H { }; +struct M { }; + +parser ParserI(packet_in b, out H parsedHdr, inout M meta, + inout standard_metadata_t standard_metadata) { + state start { + transition accept; + } +} + + +control VerifyChecksumI(in H hdr, + inout M meta, + inout standard_metadata_t standard_metadata) { + apply { } +} + + +control IngressI(inout H hdr, + inout M meta, + inout standard_metadata_t standard_metadata) { + apply { } +} + + +control EgressI(inout H hdr, + inout M meta, + inout standard_metadata_t standard_metadata) { + apply { } +} + + +control ComputeChecksumI(inout H hdr, + inout M meta, + inout standard_metadata_t standard_metadata) { + apply { } +} + + +control DeparserI(packet_out b, in H hdr) { + apply { + b.emit(hdr); // illegal data type + } +} + + +V1Switch(ParserI(), + VerifyChecksumI(), + IngressI(), + EgressI(), + ComputeChecksumI(), + DeparserI()) main; From 5d2f81a36774a62316311e497fb9805d7ff2da26 Mon Sep 17 00:00:00 2001 From: mbudiu-vmw Date: Fri, 30 Sep 2016 10:24:17 -0700 Subject: [PATCH 7/9] Added 3 @atomic tests and fix for bug losing @atomic block --- midend/actionSynthesis.cpp | 2 +- testdata/p4_16_samples/flowlet_switching.p4 | 233 +++++++++++++ testdata/p4_16_samples/rcp.p4 | 69 ++++ testdata/p4_16_samples/rcp1.p4 | 69 ++++ .../flowlet_switching-first.p4 | 233 +++++++++++++ .../flowlet_switching-frontend.p4 | 275 +++++++++++++++ .../flowlet_switching-midend.p4 | 329 ++++++++++++++++++ .../flowlet_switching.p4 | 233 +++++++++++++ .../flowlet_switching.p4-stderr | 0 testdata/p4_16_samples_outputs/rcp-first.p4 | 44 +++ .../p4_16_samples_outputs/rcp-frontend.p4 | 63 ++++ testdata/p4_16_samples_outputs/rcp-midend.p4 | 81 +++++ testdata/p4_16_samples_outputs/rcp.p4 | 44 +++ testdata/p4_16_samples_outputs/rcp.p4-stderr | 0 testdata/p4_16_samples_outputs/rcp1-first.p4 | 44 +++ .../p4_16_samples_outputs/rcp1-frontend.p4 | 47 +++ testdata/p4_16_samples_outputs/rcp1-midend.p4 | 56 +++ testdata/p4_16_samples_outputs/rcp1.p4 | 44 +++ testdata/p4_16_samples_outputs/rcp1.p4-stderr | 0 19 files changed, 1865 insertions(+), 1 deletion(-) create mode 100644 testdata/p4_16_samples/flowlet_switching.p4 create mode 100644 testdata/p4_16_samples/rcp.p4 create mode 100644 testdata/p4_16_samples/rcp1.p4 create mode 100644 testdata/p4_16_samples_outputs/flowlet_switching-first.p4 create mode 100644 testdata/p4_16_samples_outputs/flowlet_switching-frontend.p4 create mode 100644 testdata/p4_16_samples_outputs/flowlet_switching-midend.p4 create mode 100644 testdata/p4_16_samples_outputs/flowlet_switching.p4 create mode 100644 testdata/p4_16_samples_outputs/flowlet_switching.p4-stderr create mode 100644 testdata/p4_16_samples_outputs/rcp-first.p4 create mode 100644 testdata/p4_16_samples_outputs/rcp-frontend.p4 create mode 100644 testdata/p4_16_samples_outputs/rcp-midend.p4 create mode 100644 testdata/p4_16_samples_outputs/rcp.p4 create mode 100644 testdata/p4_16_samples_outputs/rcp.p4-stderr create mode 100644 testdata/p4_16_samples_outputs/rcp1-first.p4 create mode 100644 testdata/p4_16_samples_outputs/rcp1-frontend.p4 create mode 100644 testdata/p4_16_samples_outputs/rcp1-midend.p4 create mode 100644 testdata/p4_16_samples_outputs/rcp1.p4 create mode 100644 testdata/p4_16_samples_outputs/rcp1.p4-stderr diff --git a/midend/actionSynthesis.cpp b/midend/actionSynthesis.cpp index 6c530f37253..f18237f3fc9 100644 --- a/midend/actionSynthesis.cpp +++ b/midend/actionSynthesis.cpp @@ -170,7 +170,7 @@ const IR::Node* DoSynthesizeActions::preorder(IR::BlockStatement* statement) { // Since we have only one 'changes' per P4Control, this may // be conservatively creating a new block when it hasn't changed. // But the result should be correct. - auto result = new IR::BlockStatement(Util::SourceInfo(), IR::Annotations::empty, left); + auto result = new IR::BlockStatement(Util::SourceInfo(), statement->annotations, left); return result; } return statement; diff --git a/testdata/p4_16_samples/flowlet_switching.p4 b/testdata/p4_16_samples/flowlet_switching.p4 new file mode 100644 index 00000000000..df85aca5386 --- /dev/null +++ b/testdata/p4_16_samples/flowlet_switching.p4 @@ -0,0 +1,233 @@ +#include +#include + +struct ingress_metadata_t { + bit<32> flow_ipg; + bit<13> flowlet_map_index; + bit<16> flowlet_id; + bit<32> flowlet_lasttime; + bit<14> ecmp_offset; + bit<32> nhop_ipv4; +} + +struct intrinsic_metadata_t { + bit<48> ingress_global_timestamp; + bit<32> lf_field_list; + bit<16> mcast_grp; + bit<16> egress_rid; +} + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +header ipv4_t { + bit<4> version; + bit<4> ihl; + bit<8> diffserv; + bit<16> totalLen; + bit<16> identification; + bit<3> flags; + bit<13> fragOffset; + bit<8> ttl; + bit<8> protocol; + bit<16> hdrChecksum; + bit<32> srcAddr; + bit<32> dstAddr; +} + +header tcp_t { + bit<16> srcPort; + bit<16> dstPort; + bit<32> seqNo; + bit<32> ackNo; + bit<4> dataOffset; + bit<3> res; + bit<3> ecn; + bit<6> ctrl; + bit<16> window; + bit<16> checksum; + bit<16> urgentPtr; +} + +struct metadata { + @name("ingress_metadata") + ingress_metadata_t ingress_metadata; + @name("intrinsic_metadata") + intrinsic_metadata_t intrinsic_metadata; +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("ipv4") + ipv4_t ipv4; + @name("tcp") + tcp_t tcp; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_ethernet") state parse_ethernet { + packet.extract(hdr.ethernet); + transition select(hdr.ethernet.etherType) { + 16w0x800: parse_ipv4; + default: accept; + } + } + @name("parse_ipv4") state parse_ipv4 { + packet.extract(hdr.ipv4); + transition select(hdr.ipv4.protocol) { + 8w6: parse_tcp; + default: accept; + } + } + @name("parse_tcp") state parse_tcp { + packet.extract(hdr.tcp); + transition accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("rewrite_mac") action rewrite_mac(bit<48> smac) { + hdr.ethernet.srcAddr = smac; + } + @name("_drop") action _drop() { + mark_to_drop(); + } + @name("send_frame") table send_frame() { + actions = { + rewrite_mac; + _drop; + NoAction; + } + key = { + standard_metadata.egress_port: exact; + } + size = 256; + default_action = NoAction(); + } + apply { + send_frame.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("flowlet_id") register>(32w8192) flowlet_id; + @name("flowlet_lasttime") register>(32w8192) flowlet_lasttime; + @name("_drop") action _drop() { + mark_to_drop(); + } + @name("set_ecmp_select") action set_ecmp_select(bit<8> ecmp_base, bit<8> ecmp_count) { + hash(meta.ingress_metadata.ecmp_offset, HashAlgorithm.crc16, (bit<10>)ecmp_base, { hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, hdr.ipv4.protocol, hdr.tcp.srcPort, hdr.tcp.dstPort, meta.ingress_metadata.flowlet_id }, (bit<20>)ecmp_count); + } + @name("set_nhop") action set_nhop(bit<32> nhop_ipv4, bit<9> port) { + meta.ingress_metadata.nhop_ipv4 = nhop_ipv4; + standard_metadata.egress_spec = port; + hdr.ipv4.ttl = hdr.ipv4.ttl + 8w255; + } + @name("lookup_flowlet_map") action lookup_flowlet_map() { + hash(meta.ingress_metadata.flowlet_map_index, HashAlgorithm.crc16, (bit<13>)0, { hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, hdr.ipv4.protocol, hdr.tcp.srcPort, hdr.tcp.dstPort }, (bit<26>)13); + flowlet_id.read(meta.ingress_metadata.flowlet_id, (bit<32>)meta.ingress_metadata.flowlet_map_index); + meta.ingress_metadata.flow_ipg = meta.intrinsic_metadata.ingress_global_timestamp; + flowlet_lasttime.read(meta.ingress_metadata.flowlet_lasttime, (bit<32>)meta.ingress_metadata.flowlet_map_index); + meta.ingress_metadata.flow_ipg = meta.ingress_metadata.flow_ipg - meta.ingress_metadata.flowlet_lasttime; + flowlet_lasttime.write((bit<32>)meta.ingress_metadata.flowlet_map_index, (bit<32>)meta.intrinsic_metadata.ingress_global_timestamp); + } + @name("set_dmac") action set_dmac(bit<48> dmac) { + hdr.ethernet.dstAddr = dmac; + } + @name("update_flowlet_id") action update_flowlet_id() { + meta.ingress_metadata.flowlet_id = meta.ingress_metadata.flowlet_id + 16w1; + flowlet_id.write((bit<32>)meta.ingress_metadata.flowlet_map_index, (bit<16>)meta.ingress_metadata.flowlet_id); + } + @name("ecmp_group") table ecmp_group() { + actions = { + _drop; + set_ecmp_select; + NoAction; + } + key = { + hdr.ipv4.dstAddr: lpm; + } + size = 1024; + default_action = NoAction(); + } + @name("ecmp_nhop") table ecmp_nhop() { + actions = { + _drop; + set_nhop; + NoAction; + } + key = { + meta.ingress_metadata.ecmp_offset: exact; + } + size = 16384; + default_action = NoAction(); + } + @name("flowlet") table flowlet() { + actions = { + lookup_flowlet_map; + NoAction; + } + default_action = NoAction(); + } + @name("forward") table forward() { + actions = { + set_dmac; + _drop; + NoAction; + } + key = { + meta.ingress_metadata.nhop_ipv4: exact; + } + size = 512; + default_action = NoAction(); + } + @name("new_flowlet") table new_flowlet() { + actions = { + update_flowlet_id; + NoAction; + } + default_action = NoAction(); + } + apply { + @atomic { + flowlet.apply(); + if (meta.ingress_metadata.flow_ipg > 32w50000) + new_flowlet.apply(); + } + ecmp_group.apply(); + ecmp_nhop.apply(); + forward.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.ipv4); + packet.emit(hdr.tcp); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + Checksum16() ipv4_checksum; + apply { + if (hdr.ipv4.hdrChecksum == ipv4_checksum.get({ 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 })) + mark_to_drop(); + } +} + +control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + Checksum16() ipv4_checksum; + apply { + hdr.ipv4.hdrChecksum = ipv4_checksum.get({ 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 }); + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/p4_16_samples/rcp.p4 b/testdata/p4_16_samples/rcp.p4 new file mode 100644 index 00000000000..558c139c1ac --- /dev/null +++ b/testdata/p4_16_samples/rcp.p4 @@ -0,0 +1,69 @@ +/* +Copyright 2016 VMware, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Example Rate-Control Protocol implementation using @atomic blocks + +#include + +extern Register { + Register(bit<32> size); + void read(in bit<32> index, out T value); + void write(in bit<32> index, in T value); +} + +control proto(inout P packet, in M meta); +package top(proto _p); + +/////////////////////// + +header H { + bit<32> rtt; +} + +struct Metadata { + bit<32> pkt_len; +} + +const bit<32> MAX_ALLOWABLE_RTT = 2500; + +control ingress(inout H pkt_hdr, in Metadata metadata) { + Register>(1) input_traffic_bytes; + Register>(1) sum_rtt_Tr; + Register>(1) num_pkts_with_rtt; + + apply { + @atomic{ + bit<32> input_traffic_bytes_tmp; + input_traffic_bytes.read(0, input_traffic_bytes_tmp); + input_traffic_bytes_tmp = input_traffic_bytes_tmp + metadata.pkt_len; + input_traffic_bytes.write(input_traffic_bytes_tmp, 0); + if (pkt_hdr.rtt < MAX_ALLOWABLE_RTT) { + bit<32> sum_rtt_Tr_tmp; + sum_rtt_Tr.read(0, sum_rtt_Tr_tmp); + sum_rtt_Tr_tmp = sum_rtt_Tr_tmp + pkt_hdr.rtt; + sum_rtt_Tr.write(sum_rtt_Tr_tmp, 0); + + bit<32> num_pkts_with_rtt_tmp; + num_pkts_with_rtt.read(0, num_pkts_with_rtt_tmp); + num_pkts_with_rtt_tmp = num_pkts_with_rtt_tmp + 1; + num_pkts_with_rtt.write(num_pkts_with_rtt_tmp, 0); + } + } + } +} + + +top(ingress()) main; diff --git a/testdata/p4_16_samples/rcp1.p4 b/testdata/p4_16_samples/rcp1.p4 new file mode 100644 index 00000000000..5607730afa6 --- /dev/null +++ b/testdata/p4_16_samples/rcp1.p4 @@ -0,0 +1,69 @@ +/* +Copyright 2016 VMware, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Example Rate-Control Protocol implementation using @atomic blocks +// and custom extern blocks + +#include + +extern ConditionalAccumulator { + ConditionalAccumulator(bit<32> size); + void read(out T value); + void write(in T value, in bool condition); +} + +enum CounterType { + packets, + bytes, + packets_and_bytes +} + +extern Counter { + Counter(CounterType type); + void count(); +} + +control proto(inout P packet, in M meta); +package top(proto _p); + +/////////////////////// + +header H { + bit<32> rtt; +} + +struct Metadata { + bit<32> pkt_len; +} + +const bit<32> MAX_ALLOWABLE_RTT = 2500; + +control ingress(inout H pkt_hdr, in Metadata metadata) { + Counter>(CounterType.packets_and_bytes) input_traffic_bytes; + ConditionalAccumulator>(1) sum_rtt_Tr; + ConditionalAccumulator>(1) num_pkts_with_rtt; + + apply { + @atomic { + input_traffic_bytes.count(); + sum_rtt_Tr.write(pkt_hdr.rtt, pkt_hdr.rtt < MAX_ALLOWABLE_RTT); + num_pkts_with_rtt.write(1, pkt_hdr.rtt < MAX_ALLOWABLE_RTT); + } + } +} + + +top(ingress()) main; diff --git a/testdata/p4_16_samples_outputs/flowlet_switching-first.p4 b/testdata/p4_16_samples_outputs/flowlet_switching-first.p4 new file mode 100644 index 00000000000..faf04713530 --- /dev/null +++ b/testdata/p4_16_samples_outputs/flowlet_switching-first.p4 @@ -0,0 +1,233 @@ +#include +#include + +struct ingress_metadata_t { + bit<32> flow_ipg; + bit<13> flowlet_map_index; + bit<16> flowlet_id; + bit<32> flowlet_lasttime; + bit<14> ecmp_offset; + bit<32> nhop_ipv4; +} + +struct intrinsic_metadata_t { + bit<48> ingress_global_timestamp; + bit<32> lf_field_list; + bit<16> mcast_grp; + bit<16> egress_rid; +} + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +header ipv4_t { + bit<4> version; + bit<4> ihl; + bit<8> diffserv; + bit<16> totalLen; + bit<16> identification; + bit<3> flags; + bit<13> fragOffset; + bit<8> ttl; + bit<8> protocol; + bit<16> hdrChecksum; + bit<32> srcAddr; + bit<32> dstAddr; +} + +header tcp_t { + bit<16> srcPort; + bit<16> dstPort; + bit<32> seqNo; + bit<32> ackNo; + bit<4> dataOffset; + bit<3> res; + bit<3> ecn; + bit<6> ctrl; + bit<16> window; + bit<16> checksum; + bit<16> urgentPtr; +} + +struct metadata { + @name("ingress_metadata") + ingress_metadata_t ingress_metadata; + @name("intrinsic_metadata") + intrinsic_metadata_t intrinsic_metadata; +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("ipv4") + ipv4_t ipv4; + @name("tcp") + tcp_t tcp; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_ethernet") state parse_ethernet { + packet.extract(hdr.ethernet); + transition select(hdr.ethernet.etherType) { + 16w0x800: parse_ipv4; + default: accept; + } + } + @name("parse_ipv4") state parse_ipv4 { + packet.extract(hdr.ipv4); + transition select(hdr.ipv4.protocol) { + 8w6: parse_tcp; + default: accept; + } + } + @name("parse_tcp") state parse_tcp { + packet.extract(hdr.tcp); + transition accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("rewrite_mac") action rewrite_mac(bit<48> smac) { + hdr.ethernet.srcAddr = smac; + } + @name("_drop") action _drop() { + mark_to_drop(); + } + @name("send_frame") table send_frame() { + actions = { + rewrite_mac(); + _drop(); + NoAction(); + } + key = { + standard_metadata.egress_port: exact; + } + size = 256; + default_action = NoAction(); + } + apply { + send_frame.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("flowlet_id") register>(32w8192) flowlet_id; + @name("flowlet_lasttime") register>(32w8192) flowlet_lasttime; + @name("_drop") action _drop() { + mark_to_drop(); + } + @name("set_ecmp_select") action set_ecmp_select(bit<8> ecmp_base, bit<8> ecmp_count) { + hash, bit<10>, tuple, bit<32>, bit<8>, bit<16>, bit<16>, bit<16>>, bit<20>>(meta.ingress_metadata.ecmp_offset, HashAlgorithm.crc16, (bit<10>)ecmp_base, { hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, hdr.ipv4.protocol, hdr.tcp.srcPort, hdr.tcp.dstPort, meta.ingress_metadata.flowlet_id }, (bit<20>)ecmp_count); + } + @name("set_nhop") action set_nhop(bit<32> nhop_ipv4, bit<9> port) { + meta.ingress_metadata.nhop_ipv4 = nhop_ipv4; + standard_metadata.egress_spec = port; + hdr.ipv4.ttl = hdr.ipv4.ttl + 8w255; + } + @name("lookup_flowlet_map") action lookup_flowlet_map() { + hash, bit<13>, tuple, bit<32>, bit<8>, bit<16>, bit<16>>, bit<26>>(meta.ingress_metadata.flowlet_map_index, HashAlgorithm.crc16, 13w0, { hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, hdr.ipv4.protocol, hdr.tcp.srcPort, hdr.tcp.dstPort }, 26w13); + flowlet_id.read(meta.ingress_metadata.flowlet_id, (bit<32>)meta.ingress_metadata.flowlet_map_index); + meta.ingress_metadata.flow_ipg = (bit<32>)meta.intrinsic_metadata.ingress_global_timestamp; + flowlet_lasttime.read(meta.ingress_metadata.flowlet_lasttime, (bit<32>)meta.ingress_metadata.flowlet_map_index); + meta.ingress_metadata.flow_ipg = meta.ingress_metadata.flow_ipg - meta.ingress_metadata.flowlet_lasttime; + flowlet_lasttime.write((bit<32>)meta.ingress_metadata.flowlet_map_index, (bit<32>)meta.intrinsic_metadata.ingress_global_timestamp); + } + @name("set_dmac") action set_dmac(bit<48> dmac) { + hdr.ethernet.dstAddr = dmac; + } + @name("update_flowlet_id") action update_flowlet_id() { + meta.ingress_metadata.flowlet_id = meta.ingress_metadata.flowlet_id + 16w1; + flowlet_id.write((bit<32>)meta.ingress_metadata.flowlet_map_index, (bit<16>)meta.ingress_metadata.flowlet_id); + } + @name("ecmp_group") table ecmp_group() { + actions = { + _drop(); + set_ecmp_select(); + NoAction(); + } + key = { + hdr.ipv4.dstAddr: lpm; + } + size = 1024; + default_action = NoAction(); + } + @name("ecmp_nhop") table ecmp_nhop() { + actions = { + _drop(); + set_nhop(); + NoAction(); + } + key = { + meta.ingress_metadata.ecmp_offset: exact; + } + size = 16384; + default_action = NoAction(); + } + @name("flowlet") table flowlet() { + actions = { + lookup_flowlet_map(); + NoAction(); + } + default_action = NoAction(); + } + @name("forward") table forward() { + actions = { + set_dmac(); + _drop(); + NoAction(); + } + key = { + meta.ingress_metadata.nhop_ipv4: exact; + } + size = 512; + default_action = NoAction(); + } + @name("new_flowlet") table new_flowlet() { + actions = { + update_flowlet_id(); + NoAction(); + } + default_action = NoAction(); + } + apply { + @atomic { + flowlet.apply(); + if (meta.ingress_metadata.flow_ipg > 32w50000) + new_flowlet.apply(); + } + ecmp_group.apply(); + ecmp_nhop.apply(); + forward.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.ipv4); + packet.emit(hdr.tcp); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + Checksum16() ipv4_checksum; + apply { + if (hdr.ipv4.hdrChecksum == (ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }))) + mark_to_drop(); + } +} + +control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + Checksum16() ipv4_checksum; + apply { + hdr.ipv4.hdrChecksum = ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/p4_16_samples_outputs/flowlet_switching-frontend.p4 b/testdata/p4_16_samples_outputs/flowlet_switching-frontend.p4 new file mode 100644 index 00000000000..62c82d150fe --- /dev/null +++ b/testdata/p4_16_samples_outputs/flowlet_switching-frontend.p4 @@ -0,0 +1,275 @@ +#include +#include + +struct ingress_metadata_t { + bit<32> flow_ipg; + bit<13> flowlet_map_index; + bit<16> flowlet_id; + bit<32> flowlet_lasttime; + bit<14> ecmp_offset; + bit<32> nhop_ipv4; +} + +struct intrinsic_metadata_t { + bit<48> ingress_global_timestamp; + bit<32> lf_field_list; + bit<16> mcast_grp; + bit<16> egress_rid; +} + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +header ipv4_t { + bit<4> version; + bit<4> ihl; + bit<8> diffserv; + bit<16> totalLen; + bit<16> identification; + bit<3> flags; + bit<13> fragOffset; + bit<8> ttl; + bit<8> protocol; + bit<16> hdrChecksum; + bit<32> srcAddr; + bit<32> dstAddr; +} + +header tcp_t { + bit<16> srcPort; + bit<16> dstPort; + bit<32> seqNo; + bit<32> ackNo; + bit<4> dataOffset; + bit<3> res; + bit<3> ecn; + bit<6> ctrl; + bit<16> window; + bit<16> checksum; + bit<16> urgentPtr; +} + +struct metadata { + @name("ingress_metadata") + ingress_metadata_t ingress_metadata; + @name("intrinsic_metadata") + intrinsic_metadata_t intrinsic_metadata; +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("ipv4") + ipv4_t ipv4; + @name("tcp") + tcp_t tcp; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_ethernet") state parse_ethernet { + packet.extract(hdr.ethernet); + transition select(hdr.ethernet.etherType) { + 16w0x800: parse_ipv4; + default: accept; + } + } + @name("parse_ipv4") state parse_ipv4 { + packet.extract(hdr.ipv4); + transition select(hdr.ipv4.protocol) { + 8w6: parse_tcp; + default: accept; + } + } + @name("parse_tcp") state parse_tcp { + packet.extract(hdr.tcp); + transition accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("rewrite_mac") action rewrite_mac_0(bit<48> smac) { + hdr.ethernet.srcAddr = smac; + } + @name("_drop") action _drop_0() { + mark_to_drop(); + } + @name("send_frame") table send_frame_0() { + actions = { + rewrite_mac_0(); + _drop_0(); + NoAction(); + } + key = { + standard_metadata.egress_port: exact; + } + size = 256; + default_action = NoAction(); + } + apply { + send_frame_0.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("flowlet_id") register>(32w8192) flowlet_id_0; + @name("flowlet_lasttime") register>(32w8192) flowlet_lasttime_0; + @name("_drop") action _drop_1() { + mark_to_drop(); + } + @name("set_ecmp_select") action set_ecmp_select_0(bit<8> ecmp_base, bit<8> ecmp_count) { + bit<14> tmp; + HashAlgorithm tmp_0; + bit<10> tmp_1; + tuple, bit<32>, bit<8>, bit<16>, bit<16>, bit<16>> tmp_2; + bit<20> tmp_3; + tmp_0 = HashAlgorithm.crc16; + tmp_1 = (bit<10>)ecmp_base; + tmp_2 = { hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, hdr.ipv4.protocol, hdr.tcp.srcPort, hdr.tcp.dstPort, meta.ingress_metadata.flowlet_id }; + tmp_3 = (bit<20>)ecmp_count; + hash, bit<10>, tuple, bit<32>, bit<8>, bit<16>, bit<16>, bit<16>>, bit<20>>(tmp, tmp_0, tmp_1, tmp_2, tmp_3); + meta.ingress_metadata.ecmp_offset = tmp; + } + @name("set_nhop") action set_nhop_0(bit<32> nhop_ipv4, bit<9> port) { + bit<8> tmp_4; + meta.ingress_metadata.nhop_ipv4 = nhop_ipv4; + standard_metadata.egress_spec = port; + tmp_4 = hdr.ipv4.ttl + 8w255; + hdr.ipv4.ttl = tmp_4; + } + @name("lookup_flowlet_map") action lookup_flowlet_map_0() { + bit<13> tmp_5; + HashAlgorithm tmp_6; + bit<13> tmp_7; + tuple, bit<32>, bit<8>, bit<16>, bit<16>> tmp_8; + bit<26> tmp_9; + bit<16> tmp_10; + bit<32> tmp_11; + bit<32> tmp_12; + bit<32> tmp_13; + bit<32> tmp_14; + tmp_6 = HashAlgorithm.crc16; + tmp_7 = 13w0; + tmp_8 = { hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, hdr.ipv4.protocol, hdr.tcp.srcPort, hdr.tcp.dstPort }; + tmp_9 = 26w13; + hash, bit<13>, tuple, bit<32>, bit<8>, bit<16>, bit<16>>, bit<26>>(tmp_5, tmp_6, tmp_7, tmp_8, tmp_9); + meta.ingress_metadata.flowlet_map_index = tmp_5; + tmp_11 = (bit<32>)meta.ingress_metadata.flowlet_map_index; + flowlet_id_0.read(tmp_10, tmp_11); + meta.ingress_metadata.flowlet_id = tmp_10; + meta.ingress_metadata.flow_ipg = (bit<32>)meta.intrinsic_metadata.ingress_global_timestamp; + tmp_13 = (bit<32>)meta.ingress_metadata.flowlet_map_index; + flowlet_lasttime_0.read(tmp_12, tmp_13); + meta.ingress_metadata.flowlet_lasttime = tmp_12; + tmp_14 = meta.ingress_metadata.flow_ipg - meta.ingress_metadata.flowlet_lasttime; + meta.ingress_metadata.flow_ipg = tmp_14; + flowlet_lasttime_0.write((bit<32>)meta.ingress_metadata.flowlet_map_index, (bit<32>)meta.intrinsic_metadata.ingress_global_timestamp); + } + @name("set_dmac") action set_dmac_0(bit<48> dmac) { + hdr.ethernet.dstAddr = dmac; + } + @name("update_flowlet_id") action update_flowlet_id_0() { + bit<16> tmp_15; + tmp_15 = meta.ingress_metadata.flowlet_id + 16w1; + meta.ingress_metadata.flowlet_id = tmp_15; + flowlet_id_0.write((bit<32>)meta.ingress_metadata.flowlet_map_index, (bit<16>)meta.ingress_metadata.flowlet_id); + } + @name("ecmp_group") table ecmp_group_0() { + actions = { + _drop_1(); + set_ecmp_select_0(); + NoAction(); + } + key = { + hdr.ipv4.dstAddr: lpm; + } + size = 1024; + default_action = NoAction(); + } + @name("ecmp_nhop") table ecmp_nhop_0() { + actions = { + _drop_1(); + set_nhop_0(); + NoAction(); + } + key = { + meta.ingress_metadata.ecmp_offset: exact; + } + size = 16384; + default_action = NoAction(); + } + @name("flowlet") table flowlet_0() { + actions = { + lookup_flowlet_map_0(); + NoAction(); + } + default_action = NoAction(); + } + @name("forward") table forward_0() { + actions = { + set_dmac_0(); + _drop_1(); + NoAction(); + } + key = { + meta.ingress_metadata.nhop_ipv4: exact; + } + size = 512; + default_action = NoAction(); + } + @name("new_flowlet") table new_flowlet_0() { + actions = { + update_flowlet_id_0(); + NoAction(); + } + default_action = NoAction(); + } + bool tmp_16; + apply { + @atomic { + flowlet_0.apply(); + tmp_16 = meta.ingress_metadata.flow_ipg > 32w50000; + if (tmp_16) + new_flowlet_0.apply(); + } + ecmp_group_0.apply(); + ecmp_nhop_0.apply(); + forward_0.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.ipv4); + packet.emit(hdr.tcp); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("ipv4_checksum") Checksum16() ipv4_checksum_0; + bit<16> tmp_17; + bool tmp_18; + apply { + tmp_17 = ipv4_checksum_0.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); + tmp_18 = hdr.ipv4.hdrChecksum == tmp_17; + if (tmp_18) + mark_to_drop(); + } +} + +control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("ipv4_checksum") Checksum16() ipv4_checksum_1; + bit<16> tmp_19; + apply { + tmp_19 = ipv4_checksum_1.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 = tmp_19; + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/p4_16_samples_outputs/flowlet_switching-midend.p4 b/testdata/p4_16_samples_outputs/flowlet_switching-midend.p4 new file mode 100644 index 00000000000..fa0fa6d35d8 --- /dev/null +++ b/testdata/p4_16_samples_outputs/flowlet_switching-midend.p4 @@ -0,0 +1,329 @@ +#include +#include + +struct ingress_metadata_t { + bit<32> flow_ipg; + bit<13> flowlet_map_index; + bit<16> flowlet_id; + bit<32> flowlet_lasttime; + bit<14> ecmp_offset; + bit<32> nhop_ipv4; +} + +struct intrinsic_metadata_t { + bit<48> ingress_global_timestamp; + bit<32> lf_field_list; + bit<16> mcast_grp; + bit<16> egress_rid; +} + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +header ipv4_t { + bit<4> version; + bit<4> ihl; + bit<8> diffserv; + bit<16> totalLen; + bit<16> identification; + bit<3> flags; + bit<13> fragOffset; + bit<8> ttl; + bit<8> protocol; + bit<16> hdrChecksum; + bit<32> srcAddr; + bit<32> dstAddr; +} + +header tcp_t { + bit<16> srcPort; + bit<16> dstPort; + bit<32> seqNo; + bit<32> ackNo; + bit<4> dataOffset; + bit<3> res; + bit<3> ecn; + bit<6> ctrl; + bit<16> window; + bit<16> checksum; + bit<16> urgentPtr; +} + +struct metadata { + @name("ingress_metadata") + ingress_metadata_t ingress_metadata; + @name("intrinsic_metadata") + intrinsic_metadata_t intrinsic_metadata; +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("ipv4") + ipv4_t ipv4; + @name("tcp") + tcp_t tcp; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_ethernet") state parse_ethernet { + packet.extract(hdr.ethernet); + transition select(hdr.ethernet.etherType) { + 16w0x800: parse_ipv4; + default: accept; + } + } + @name("parse_ipv4") state parse_ipv4 { + packet.extract(hdr.ipv4); + transition select(hdr.ipv4.protocol) { + 8w6: parse_tcp; + default: accept; + } + } + @name("parse_tcp") state parse_tcp { + packet.extract(hdr.tcp); + transition accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("NoAction_2") action NoAction() { + } + @name("rewrite_mac") action rewrite_mac_0(bit<48> smac) { + hdr.ethernet.srcAddr = smac; + } + @name("_drop") action _drop_0() { + mark_to_drop(); + } + @name("send_frame") table send_frame() { + actions = { + rewrite_mac_0(); + _drop_0(); + NoAction(); + } + key = { + standard_metadata.egress_port: exact; + } + size = 256; + default_action = NoAction(); + } + apply { + send_frame.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("tmp") bit<14> tmp_20; + @name("tmp_0") HashAlgorithm tmp_21; + @name("tmp_1") bit<10> tmp_22; + @name("tmp_2") tuple, bit<32>, bit<8>, bit<16>, bit<16>, bit<16>> tmp_23; + @name("tmp_3") bit<20> tmp_24; + @name("tmp_4") bit<8> tmp_25; + @name("tmp_5") bit<13> tmp_26; + @name("tmp_6") HashAlgorithm tmp_27; + @name("tmp_7") bit<13> tmp_28; + @name("tmp_8") tuple, bit<32>, bit<8>, bit<16>, bit<16>> tmp_29; + @name("tmp_9") bit<26> tmp_30; + @name("tmp_10") bit<16> tmp_31; + @name("tmp_11") bit<32> tmp_32; + @name("tmp_12") bit<32> tmp_33; + @name("tmp_13") bit<32> tmp_34; + @name("tmp_14") bit<32> tmp_35; + @name("tmp_15") bit<16> tmp_36; + @name("tmp_16") bool tmp_37; + @name("NoAction_3") action NoAction_0() { + } + @name("NoAction_4") action NoAction_1() { + } + @name("NoAction_5") action NoAction_8() { + } + @name("NoAction_6") action NoAction_9() { + } + @name("NoAction_7") action NoAction_10() { + } + @name("flowlet_id") register>(32w8192) flowlet_id_1; + @name("flowlet_lasttime") register>(32w8192) flowlet_lasttime_1; + @name("_drop") action _drop_1() { + mark_to_drop(); + } + @name("_drop") action _drop_5() { + mark_to_drop(); + } + @name("_drop") action _drop_6() { + mark_to_drop(); + } + @name("set_ecmp_select") action set_ecmp_select_0(bit<8> ecmp_base, bit<8> ecmp_count) { + tmp_21 = HashAlgorithm.crc16; + tmp_22 = (bit<10>)ecmp_base; + tmp_23 = { hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, hdr.ipv4.protocol, hdr.tcp.srcPort, hdr.tcp.dstPort, meta.ingress_metadata.flowlet_id }; + tmp_24 = (bit<20>)ecmp_count; + hash, bit<10>, tuple, bit<32>, bit<8>, bit<16>, bit<16>, bit<16>>, bit<20>>(tmp_20, tmp_21, tmp_22, tmp_23, tmp_24); + meta.ingress_metadata.ecmp_offset = tmp_20; + } + @name("set_nhop") action set_nhop_0(bit<32> nhop_ipv4, bit<9> port) { + meta.ingress_metadata.nhop_ipv4 = nhop_ipv4; + standard_metadata.egress_spec = port; + tmp_25 = hdr.ipv4.ttl + 8w255; + hdr.ipv4.ttl = tmp_25; + } + @name("lookup_flowlet_map") action lookup_flowlet_map_0() { + tmp_27 = HashAlgorithm.crc16; + tmp_28 = 13w0; + tmp_29 = { hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, hdr.ipv4.protocol, hdr.tcp.srcPort, hdr.tcp.dstPort }; + tmp_30 = 26w13; + hash, bit<13>, tuple, bit<32>, bit<8>, bit<16>, bit<16>>, bit<26>>(tmp_26, tmp_27, tmp_28, tmp_29, tmp_30); + meta.ingress_metadata.flowlet_map_index = tmp_26; + tmp_32 = (bit<32>)meta.ingress_metadata.flowlet_map_index; + flowlet_id_1.read(tmp_31, tmp_32); + meta.ingress_metadata.flowlet_id = tmp_31; + meta.ingress_metadata.flow_ipg = (bit<32>)meta.intrinsic_metadata.ingress_global_timestamp; + tmp_34 = (bit<32>)meta.ingress_metadata.flowlet_map_index; + flowlet_lasttime_1.read(tmp_33, tmp_34); + meta.ingress_metadata.flowlet_lasttime = tmp_33; + tmp_35 = meta.ingress_metadata.flow_ipg - meta.ingress_metadata.flowlet_lasttime; + meta.ingress_metadata.flow_ipg = tmp_35; + flowlet_lasttime_1.write((bit<32>)meta.ingress_metadata.flowlet_map_index, (bit<32>)meta.intrinsic_metadata.ingress_global_timestamp); + } + @name("set_dmac") action set_dmac_0(bit<48> dmac) { + hdr.ethernet.dstAddr = dmac; + } + @name("update_flowlet_id") action update_flowlet_id_0() { + tmp_36 = meta.ingress_metadata.flowlet_id + 16w1; + meta.ingress_metadata.flowlet_id = tmp_36; + flowlet_id_1.write((bit<32>)meta.ingress_metadata.flowlet_map_index, (bit<16>)meta.ingress_metadata.flowlet_id); + } + @name("ecmp_group") table ecmp_group() { + actions = { + _drop_1(); + set_ecmp_select_0(); + NoAction_0(); + } + key = { + hdr.ipv4.dstAddr: lpm; + } + size = 1024; + default_action = NoAction_0(); + } + @name("ecmp_nhop") table ecmp_nhop() { + actions = { + _drop_5(); + set_nhop_0(); + NoAction_1(); + } + key = { + meta.ingress_metadata.ecmp_offset: exact; + } + size = 16384; + default_action = NoAction_1(); + } + @name("flowlet") table flowlet() { + actions = { + lookup_flowlet_map_0(); + NoAction_8(); + } + default_action = NoAction_8(); + } + @name("forward") table forward() { + actions = { + set_dmac_0(); + _drop_6(); + NoAction_9(); + } + key = { + meta.ingress_metadata.nhop_ipv4: exact; + } + size = 512; + default_action = NoAction_9(); + } + @name("new_flowlet") table new_flowlet() { + actions = { + update_flowlet_id_0(); + NoAction_10(); + } + default_action = NoAction_10(); + } + action act() { + tmp_37 = meta.ingress_metadata.flow_ipg > 32w50000; + } + table tbl_act() { + actions = { + act(); + } + const default_action = act(); + } + apply { + @atomic { + flowlet.apply(); + tbl_act.apply(); + if (tmp_37) + new_flowlet.apply(); + } + ecmp_group.apply(); + ecmp_nhop.apply(); + forward.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.ipv4); + packet.emit(hdr.tcp); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("tmp_17") bit<16> tmp_38; + @name("tmp_18") bool tmp_39; + @name("ipv4_checksum") Checksum16() ipv4_checksum; + action act_0() { + mark_to_drop(); + } + action act_1() { + tmp_38 = ipv4_checksum.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 }); + tmp_39 = hdr.ipv4.hdrChecksum == tmp_38; + } + table tbl_act_0() { + actions = { + act_1(); + } + const default_action = act_1(); + } + table tbl_act_1() { + actions = { + act_0(); + } + const default_action = act_0(); + } + apply { + tbl_act_0.apply(); + if (tmp_39) + tbl_act_1.apply(); + } +} + +control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("tmp_19") bit<16> tmp_40; + @name("ipv4_checksum") Checksum16() ipv4_checksum_2; + action act_2() { + tmp_40 = ipv4_checksum_2.get, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>>({ 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 = tmp_40; + } + table tbl_act_2() { + actions = { + act_2(); + } + const default_action = act_2(); + } + apply { + tbl_act_2.apply(); + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/p4_16_samples_outputs/flowlet_switching.p4 b/testdata/p4_16_samples_outputs/flowlet_switching.p4 new file mode 100644 index 00000000000..0d3fdfb3755 --- /dev/null +++ b/testdata/p4_16_samples_outputs/flowlet_switching.p4 @@ -0,0 +1,233 @@ +#include +#include + +struct ingress_metadata_t { + bit<32> flow_ipg; + bit<13> flowlet_map_index; + bit<16> flowlet_id; + bit<32> flowlet_lasttime; + bit<14> ecmp_offset; + bit<32> nhop_ipv4; +} + +struct intrinsic_metadata_t { + bit<48> ingress_global_timestamp; + bit<32> lf_field_list; + bit<16> mcast_grp; + bit<16> egress_rid; +} + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +header ipv4_t { + bit<4> version; + bit<4> ihl; + bit<8> diffserv; + bit<16> totalLen; + bit<16> identification; + bit<3> flags; + bit<13> fragOffset; + bit<8> ttl; + bit<8> protocol; + bit<16> hdrChecksum; + bit<32> srcAddr; + bit<32> dstAddr; +} + +header tcp_t { + bit<16> srcPort; + bit<16> dstPort; + bit<32> seqNo; + bit<32> ackNo; + bit<4> dataOffset; + bit<3> res; + bit<3> ecn; + bit<6> ctrl; + bit<16> window; + bit<16> checksum; + bit<16> urgentPtr; +} + +struct metadata { + @name("ingress_metadata") + ingress_metadata_t ingress_metadata; + @name("intrinsic_metadata") + intrinsic_metadata_t intrinsic_metadata; +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("ipv4") + ipv4_t ipv4; + @name("tcp") + tcp_t tcp; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_ethernet") state parse_ethernet { + packet.extract(hdr.ethernet); + transition select(hdr.ethernet.etherType) { + 16w0x800: parse_ipv4; + default: accept; + } + } + @name("parse_ipv4") state parse_ipv4 { + packet.extract(hdr.ipv4); + transition select(hdr.ipv4.protocol) { + 8w6: parse_tcp; + default: accept; + } + } + @name("parse_tcp") state parse_tcp { + packet.extract(hdr.tcp); + transition accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("rewrite_mac") action rewrite_mac(bit<48> smac) { + hdr.ethernet.srcAddr = smac; + } + @name("_drop") action _drop() { + mark_to_drop(); + } + @name("send_frame") table send_frame() { + actions = { + rewrite_mac; + _drop; + NoAction; + } + key = { + standard_metadata.egress_port: exact; + } + size = 256; + default_action = NoAction(); + } + apply { + send_frame.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("flowlet_id") register>(32w8192) flowlet_id; + @name("flowlet_lasttime") register>(32w8192) flowlet_lasttime; + @name("_drop") action _drop() { + mark_to_drop(); + } + @name("set_ecmp_select") action set_ecmp_select(bit<8> ecmp_base, bit<8> ecmp_count) { + hash(meta.ingress_metadata.ecmp_offset, HashAlgorithm.crc16, (bit<10>)ecmp_base, { hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, hdr.ipv4.protocol, hdr.tcp.srcPort, hdr.tcp.dstPort, meta.ingress_metadata.flowlet_id }, (bit<20>)ecmp_count); + } + @name("set_nhop") action set_nhop(bit<32> nhop_ipv4, bit<9> port) { + meta.ingress_metadata.nhop_ipv4 = nhop_ipv4; + standard_metadata.egress_spec = port; + hdr.ipv4.ttl = hdr.ipv4.ttl + 8w255; + } + @name("lookup_flowlet_map") action lookup_flowlet_map() { + hash(meta.ingress_metadata.flowlet_map_index, HashAlgorithm.crc16, (bit<13>)0, { hdr.ipv4.srcAddr, hdr.ipv4.dstAddr, hdr.ipv4.protocol, hdr.tcp.srcPort, hdr.tcp.dstPort }, (bit<26>)13); + flowlet_id.read(meta.ingress_metadata.flowlet_id, (bit<32>)meta.ingress_metadata.flowlet_map_index); + meta.ingress_metadata.flow_ipg = meta.intrinsic_metadata.ingress_global_timestamp; + flowlet_lasttime.read(meta.ingress_metadata.flowlet_lasttime, (bit<32>)meta.ingress_metadata.flowlet_map_index); + meta.ingress_metadata.flow_ipg = meta.ingress_metadata.flow_ipg - meta.ingress_metadata.flowlet_lasttime; + flowlet_lasttime.write((bit<32>)meta.ingress_metadata.flowlet_map_index, (bit<32>)meta.intrinsic_metadata.ingress_global_timestamp); + } + @name("set_dmac") action set_dmac(bit<48> dmac) { + hdr.ethernet.dstAddr = dmac; + } + @name("update_flowlet_id") action update_flowlet_id() { + meta.ingress_metadata.flowlet_id = meta.ingress_metadata.flowlet_id + 16w1; + flowlet_id.write((bit<32>)meta.ingress_metadata.flowlet_map_index, (bit<16>)meta.ingress_metadata.flowlet_id); + } + @name("ecmp_group") table ecmp_group() { + actions = { + _drop; + set_ecmp_select; + NoAction; + } + key = { + hdr.ipv4.dstAddr: lpm; + } + size = 1024; + default_action = NoAction(); + } + @name("ecmp_nhop") table ecmp_nhop() { + actions = { + _drop; + set_nhop; + NoAction; + } + key = { + meta.ingress_metadata.ecmp_offset: exact; + } + size = 16384; + default_action = NoAction(); + } + @name("flowlet") table flowlet() { + actions = { + lookup_flowlet_map; + NoAction; + } + default_action = NoAction(); + } + @name("forward") table forward() { + actions = { + set_dmac; + _drop; + NoAction; + } + key = { + meta.ingress_metadata.nhop_ipv4: exact; + } + size = 512; + default_action = NoAction(); + } + @name("new_flowlet") table new_flowlet() { + actions = { + update_flowlet_id; + NoAction; + } + default_action = NoAction(); + } + apply { + @atomic { + flowlet.apply(); + if (meta.ingress_metadata.flow_ipg > 32w50000) + new_flowlet.apply(); + } + ecmp_group.apply(); + ecmp_nhop.apply(); + forward.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.ipv4); + packet.emit(hdr.tcp); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + Checksum16() ipv4_checksum; + apply { + if (hdr.ipv4.hdrChecksum == ipv4_checksum.get({ 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 })) + mark_to_drop(); + } +} + +control computeChecksum(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + Checksum16() ipv4_checksum; + apply { + hdr.ipv4.hdrChecksum = ipv4_checksum.get({ 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 }); + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/p4_16_samples_outputs/flowlet_switching.p4-stderr b/testdata/p4_16_samples_outputs/flowlet_switching.p4-stderr new file mode 100644 index 00000000000..e69de29bb2d diff --git a/testdata/p4_16_samples_outputs/rcp-first.p4 b/testdata/p4_16_samples_outputs/rcp-first.p4 new file mode 100644 index 00000000000..b48cbca22d4 --- /dev/null +++ b/testdata/p4_16_samples_outputs/rcp-first.p4 @@ -0,0 +1,44 @@ +#include + +extern Register { + Register(bit<32> size); + void read(in bit<32> index, out T value); + void write(in bit<32> index, in T value); +} + +control proto(inout P packet, in M meta); +package top(proto _p); +header H { + bit<32> rtt; +} + +struct Metadata { + bit<32> pkt_len; +} + +const bit<32> MAX_ALLOWABLE_RTT = 32w2500; +control ingress(inout H pkt_hdr, in Metadata metadata) { + Register>(32w1) input_traffic_bytes; + Register>(32w1) sum_rtt_Tr; + Register>(32w1) num_pkts_with_rtt; + apply { + @atomic { + bit<32> input_traffic_bytes_tmp; + input_traffic_bytes.read(32w0, input_traffic_bytes_tmp); + input_traffic_bytes_tmp = input_traffic_bytes_tmp + metadata.pkt_len; + input_traffic_bytes.write(input_traffic_bytes_tmp, 32w0); + if (pkt_hdr.rtt < 32w2500) { + bit<32> sum_rtt_Tr_tmp; + sum_rtt_Tr.read(32w0, sum_rtt_Tr_tmp); + sum_rtt_Tr_tmp = sum_rtt_Tr_tmp + pkt_hdr.rtt; + sum_rtt_Tr.write(sum_rtt_Tr_tmp, 32w0); + bit<32> num_pkts_with_rtt_tmp; + num_pkts_with_rtt.read(32w0, num_pkts_with_rtt_tmp); + num_pkts_with_rtt_tmp = num_pkts_with_rtt_tmp + 32w1; + num_pkts_with_rtt.write(num_pkts_with_rtt_tmp, 32w0); + } + } + } +} + +top(ingress()) main; diff --git a/testdata/p4_16_samples_outputs/rcp-frontend.p4 b/testdata/p4_16_samples_outputs/rcp-frontend.p4 new file mode 100644 index 00000000000..be9937b6488 --- /dev/null +++ b/testdata/p4_16_samples_outputs/rcp-frontend.p4 @@ -0,0 +1,63 @@ +#include + +extern Register { + Register(bit<32> size); + void read(in bit<32> index, out T value); + void write(in bit<32> index, in T value); +} + +control proto(inout P packet, in M meta); +package top(proto _p); +header H { + bit<32> rtt; +} + +struct Metadata { + bit<32> pkt_len; +} + +control ingress(inout H pkt_hdr, in Metadata metadata) { + @name("input_traffic_bytes_tmp") bit<32> input_traffic_bytes_tmp_0; + @name("sum_rtt_Tr_tmp") bit<32> sum_rtt_Tr_tmp_0; + @name("num_pkts_with_rtt_tmp") bit<32> num_pkts_with_rtt_tmp_0; + @name("input_traffic_bytes") Register>(32w1) input_traffic_bytes_0; + @name("sum_rtt_Tr") Register>(32w1) sum_rtt_Tr_0; + @name("num_pkts_with_rtt") Register>(32w1) num_pkts_with_rtt_0; + bit<32> tmp; + bit<32> tmp_0; + bit<32> tmp_1; + bit<32> tmp_2; + bit<32> tmp_3; + bit<32> tmp_4; + bit<32> tmp_5; + bit<32> tmp_6; + bit<32> tmp_7; + bool tmp_8; + apply { + @atomic { + tmp = 32w0; + input_traffic_bytes_0.read(tmp, tmp_0); + input_traffic_bytes_tmp_0 = tmp_0; + tmp_1 = input_traffic_bytes_tmp_0 + metadata.pkt_len; + input_traffic_bytes_tmp_0 = tmp_1; + input_traffic_bytes_0.write(input_traffic_bytes_tmp_0, 32w0); + tmp_8 = pkt_hdr.rtt < 32w2500; + if (tmp_8) { + tmp_2 = 32w0; + sum_rtt_Tr_0.read(tmp_2, tmp_3); + sum_rtt_Tr_tmp_0 = tmp_3; + tmp_4 = sum_rtt_Tr_tmp_0 + pkt_hdr.rtt; + sum_rtt_Tr_tmp_0 = tmp_4; + sum_rtt_Tr_0.write(sum_rtt_Tr_tmp_0, 32w0); + tmp_5 = 32w0; + num_pkts_with_rtt_0.read(tmp_5, tmp_6); + num_pkts_with_rtt_tmp_0 = tmp_6; + tmp_7 = num_pkts_with_rtt_tmp_0 + 32w1; + num_pkts_with_rtt_tmp_0 = tmp_7; + num_pkts_with_rtt_0.write(num_pkts_with_rtt_tmp_0, 32w0); + } + } + } +} + +top(ingress()) main; diff --git a/testdata/p4_16_samples_outputs/rcp-midend.p4 b/testdata/p4_16_samples_outputs/rcp-midend.p4 new file mode 100644 index 00000000000..161fb68161b --- /dev/null +++ b/testdata/p4_16_samples_outputs/rcp-midend.p4 @@ -0,0 +1,81 @@ +#include + +extern Register { + Register(bit<32> size); + void read(in bit<32> index, out T value); + void write(in bit<32> index, in T value); +} + +control proto(inout P packet, in M meta); +package top(proto _p); +header H { + bit<32> rtt; +} + +struct Metadata { + bit<32> pkt_len; +} + +control ingress(inout H pkt_hdr, in Metadata metadata) { + @name("input_traffic_bytes_tmp") bit<32> input_traffic_bytes_tmp; + @name("sum_rtt_Tr_tmp") bit<32> sum_rtt_Tr_tmp; + @name("num_pkts_with_rtt_tmp") bit<32> num_pkts_with_rtt_tmp; + @name("tmp") bit<32> tmp_9; + @name("tmp_0") bit<32> tmp_10; + @name("tmp_1") bit<32> tmp_11; + @name("tmp_2") bit<32> tmp_12; + @name("tmp_3") bit<32> tmp_13; + @name("tmp_4") bit<32> tmp_14; + @name("tmp_5") bit<32> tmp_15; + @name("tmp_6") bit<32> tmp_16; + @name("tmp_7") bit<32> tmp_17; + @name("tmp_8") bool tmp_18; + @name("input_traffic_bytes") Register>(32w1) input_traffic_bytes; + @name("sum_rtt_Tr") Register>(32w1) sum_rtt_Tr; + @name("num_pkts_with_rtt") Register>(32w1) num_pkts_with_rtt; + action act() { + tmp_12 = 32w0; + sum_rtt_Tr.read(tmp_12, tmp_13); + sum_rtt_Tr_tmp = tmp_13; + tmp_14 = sum_rtt_Tr_tmp + pkt_hdr.rtt; + sum_rtt_Tr_tmp = tmp_14; + sum_rtt_Tr.write(sum_rtt_Tr_tmp, 32w0); + tmp_15 = 32w0; + num_pkts_with_rtt.read(tmp_15, tmp_16); + num_pkts_with_rtt_tmp = tmp_16; + tmp_17 = num_pkts_with_rtt_tmp + 32w1; + num_pkts_with_rtt_tmp = tmp_17; + num_pkts_with_rtt.write(num_pkts_with_rtt_tmp, 32w0); + } + action act_0() { + tmp_9 = 32w0; + input_traffic_bytes.read(tmp_9, tmp_10); + input_traffic_bytes_tmp = tmp_10; + tmp_11 = input_traffic_bytes_tmp + metadata.pkt_len; + input_traffic_bytes_tmp = tmp_11; + input_traffic_bytes.write(input_traffic_bytes_tmp, 32w0); + tmp_18 = pkt_hdr.rtt < 32w2500; + } + table tbl_act() { + actions = { + act_0(); + } + const default_action = act_0(); + } + table tbl_act_0() { + actions = { + act(); + } + const default_action = act(); + } + apply { + @atomic { + tbl_act.apply(); + if (tmp_18) { + tbl_act_0.apply(); + } + } + } +} + +top(ingress()) main; diff --git a/testdata/p4_16_samples_outputs/rcp.p4 b/testdata/p4_16_samples_outputs/rcp.p4 new file mode 100644 index 00000000000..4bbf66f9b2e --- /dev/null +++ b/testdata/p4_16_samples_outputs/rcp.p4 @@ -0,0 +1,44 @@ +#include + +extern Register { + Register(bit<32> size); + void read(in bit<32> index, out T value); + void write(in bit<32> index, in T value); +} + +control proto(inout P packet, in M meta); +package top(proto _p); +header H { + bit<32> rtt; +} + +struct Metadata { + bit<32> pkt_len; +} + +const bit<32> MAX_ALLOWABLE_RTT = 2500; +control ingress(inout H pkt_hdr, in Metadata metadata) { + Register>(1) input_traffic_bytes; + Register>(1) sum_rtt_Tr; + Register>(1) num_pkts_with_rtt; + apply { + @atomic { + bit<32> input_traffic_bytes_tmp; + input_traffic_bytes.read(0, input_traffic_bytes_tmp); + input_traffic_bytes_tmp = input_traffic_bytes_tmp + metadata.pkt_len; + input_traffic_bytes.write(input_traffic_bytes_tmp, 0); + if (pkt_hdr.rtt < MAX_ALLOWABLE_RTT) { + bit<32> sum_rtt_Tr_tmp; + sum_rtt_Tr.read(0, sum_rtt_Tr_tmp); + sum_rtt_Tr_tmp = sum_rtt_Tr_tmp + pkt_hdr.rtt; + sum_rtt_Tr.write(sum_rtt_Tr_tmp, 0); + bit<32> num_pkts_with_rtt_tmp; + num_pkts_with_rtt.read(0, num_pkts_with_rtt_tmp); + num_pkts_with_rtt_tmp = num_pkts_with_rtt_tmp + 1; + num_pkts_with_rtt.write(num_pkts_with_rtt_tmp, 0); + } + } + } +} + +top(ingress()) main; diff --git a/testdata/p4_16_samples_outputs/rcp.p4-stderr b/testdata/p4_16_samples_outputs/rcp.p4-stderr new file mode 100644 index 00000000000..e69de29bb2d diff --git a/testdata/p4_16_samples_outputs/rcp1-first.p4 b/testdata/p4_16_samples_outputs/rcp1-first.p4 new file mode 100644 index 00000000000..56a7aa67b4a --- /dev/null +++ b/testdata/p4_16_samples_outputs/rcp1-first.p4 @@ -0,0 +1,44 @@ +#include + +extern ConditionalAccumulator { + ConditionalAccumulator(bit<32> size); + void read(out T value); + void write(in T value, in bool condition); +} + +enum CounterType { + packets, + bytes, + packets_and_bytes +} + +extern Counter { + Counter(CounterType type); + void count(); +} + +control proto(inout P packet, in M meta); +package top(proto _p); +header H { + bit<32> rtt; +} + +struct Metadata { + bit<32> pkt_len; +} + +const bit<32> MAX_ALLOWABLE_RTT = 32w2500; +control ingress(inout H pkt_hdr, in Metadata metadata) { + Counter>(CounterType.packets_and_bytes) input_traffic_bytes; + ConditionalAccumulator>(32w1) sum_rtt_Tr; + ConditionalAccumulator>(32w1) num_pkts_with_rtt; + apply { + @atomic { + input_traffic_bytes.count(); + sum_rtt_Tr.write(pkt_hdr.rtt, pkt_hdr.rtt < 32w2500); + num_pkts_with_rtt.write(32w1, pkt_hdr.rtt < 32w2500); + } + } +} + +top(ingress()) main; diff --git a/testdata/p4_16_samples_outputs/rcp1-frontend.p4 b/testdata/p4_16_samples_outputs/rcp1-frontend.p4 new file mode 100644 index 00000000000..e1f8f1bf665 --- /dev/null +++ b/testdata/p4_16_samples_outputs/rcp1-frontend.p4 @@ -0,0 +1,47 @@ +#include + +extern ConditionalAccumulator { + ConditionalAccumulator(bit<32> size); + void read(out T value); + void write(in T value, in bool condition); +} + +enum CounterType { + packets, + bytes, + packets_and_bytes +} + +extern Counter { + Counter(CounterType type); + void count(); +} + +control proto(inout P packet, in M meta); +package top(proto _p); +header H { + bit<32> rtt; +} + +struct Metadata { + bit<32> pkt_len; +} + +control ingress(inout H pkt_hdr, in Metadata metadata) { + @name("input_traffic_bytes") Counter>(CounterType.packets_and_bytes) input_traffic_bytes_0; + @name("sum_rtt_Tr") ConditionalAccumulator>(32w1) sum_rtt_Tr_0; + @name("num_pkts_with_rtt") ConditionalAccumulator>(32w1) num_pkts_with_rtt_0; + bool tmp; + bool tmp_0; + apply { + @atomic { + input_traffic_bytes_0.count(); + tmp = pkt_hdr.rtt < 32w2500; + sum_rtt_Tr_0.write(pkt_hdr.rtt, tmp); + tmp_0 = pkt_hdr.rtt < 32w2500; + num_pkts_with_rtt_0.write(32w1, tmp_0); + } + } +} + +top(ingress()) main; diff --git a/testdata/p4_16_samples_outputs/rcp1-midend.p4 b/testdata/p4_16_samples_outputs/rcp1-midend.p4 new file mode 100644 index 00000000000..bf3f1b71ee1 --- /dev/null +++ b/testdata/p4_16_samples_outputs/rcp1-midend.p4 @@ -0,0 +1,56 @@ +#include + +extern ConditionalAccumulator { + ConditionalAccumulator(bit<32> size); + void read(out T value); + void write(in T value, in bool condition); +} + +enum CounterType { + packets, + bytes, + packets_and_bytes +} + +extern Counter { + Counter(CounterType type); + void count(); +} + +control proto(inout P packet, in M meta); +package top(proto _p); +header H { + bit<32> rtt; +} + +struct Metadata { + bit<32> pkt_len; +} + +control ingress(inout H pkt_hdr, in Metadata metadata) { + @name("tmp") bool tmp_1; + @name("tmp_0") bool tmp_2; + @name("input_traffic_bytes") Counter>(CounterType.packets_and_bytes) input_traffic_bytes; + @name("sum_rtt_Tr") ConditionalAccumulator>(32w1) sum_rtt_Tr; + @name("num_pkts_with_rtt") ConditionalAccumulator>(32w1) num_pkts_with_rtt; + action act() { + input_traffic_bytes.count(); + tmp_1 = pkt_hdr.rtt < 32w2500; + sum_rtt_Tr.write(pkt_hdr.rtt, tmp_1); + tmp_2 = pkt_hdr.rtt < 32w2500; + num_pkts_with_rtt.write(32w1, tmp_2); + } + table tbl_act() { + actions = { + act(); + } + const default_action = act(); + } + apply { + @atomic { + tbl_act.apply(); + } + } +} + +top(ingress()) main; diff --git a/testdata/p4_16_samples_outputs/rcp1.p4 b/testdata/p4_16_samples_outputs/rcp1.p4 new file mode 100644 index 00000000000..88e5ccf1a28 --- /dev/null +++ b/testdata/p4_16_samples_outputs/rcp1.p4 @@ -0,0 +1,44 @@ +#include + +extern ConditionalAccumulator { + ConditionalAccumulator(bit<32> size); + void read(out T value); + void write(in T value, in bool condition); +} + +enum CounterType { + packets, + bytes, + packets_and_bytes +} + +extern Counter { + Counter(CounterType type); + void count(); +} + +control proto(inout P packet, in M meta); +package top(proto _p); +header H { + bit<32> rtt; +} + +struct Metadata { + bit<32> pkt_len; +} + +const bit<32> MAX_ALLOWABLE_RTT = 2500; +control ingress(inout H pkt_hdr, in Metadata metadata) { + Counter>(CounterType.packets_and_bytes) input_traffic_bytes; + ConditionalAccumulator>(1) sum_rtt_Tr; + ConditionalAccumulator>(1) num_pkts_with_rtt; + apply { + @atomic { + input_traffic_bytes.count(); + sum_rtt_Tr.write(pkt_hdr.rtt, pkt_hdr.rtt < MAX_ALLOWABLE_RTT); + num_pkts_with_rtt.write(1, pkt_hdr.rtt < MAX_ALLOWABLE_RTT); + } + } +} + +top(ingress()) main; diff --git a/testdata/p4_16_samples_outputs/rcp1.p4-stderr b/testdata/p4_16_samples_outputs/rcp1.p4-stderr new file mode 100644 index 00000000000..e69de29bb2d From 1bb7fd007f225b74e3ac0ec427098da0b939d40a Mon Sep 17 00:00:00 2001 From: mbudiu-vmw Date: Fri, 30 Sep 2016 16:13:34 -0700 Subject: [PATCH 8/9] Moved specialization to front-end; added pass to remove control-flow from parsers --- backends/bmv2/midend.cpp | 2 + backends/p4test/midend.cpp | 7 +- frontends/Makefile.am | 4 +- frontends/p4/frontend.cpp | 2 + {midend => frontends/p4}/specialize.cpp | 0 {midend => frontends/p4}/specialize.h | 6 +- midend/Makefile.am | 6 +- midend/parserControlFlow.cpp | 140 ++++++++++++++++++ midend/parserControlFlow.h | 49 ++++++ .../p4_16_samples/parser-conditional.p4 | 27 ++-- .../inline-control-midend.p4 | 8 +- .../parser-conditional-first.p4 | 14 ++ .../parser-conditional-frontend.p4 | 48 ++++++ .../parser-conditional-midend.p4 | 74 +++++++++ .../parser-conditional.p4 | 14 ++ .../parser-conditional.p4-stderr | 0 16 files changed, 375 insertions(+), 26 deletions(-) rename {midend => frontends/p4}/specialize.cpp (100%) rename {midend => frontends/p4}/specialize.h (97%) create mode 100644 midend/parserControlFlow.cpp create mode 100644 midend/parserControlFlow.h rename midend/parserInlining.h => testdata/p4_16_samples/parser-conditional.p4 (65%) create mode 100644 testdata/p4_16_samples_outputs/parser-conditional-first.p4 create mode 100644 testdata/p4_16_samples_outputs/parser-conditional-frontend.p4 create mode 100644 testdata/p4_16_samples_outputs/parser-conditional-midend.p4 create mode 100644 testdata/p4_16_samples_outputs/parser-conditional.p4 create mode 100644 testdata/p4_16_samples_outputs/parser-conditional.p4-stderr diff --git a/backends/bmv2/midend.cpp b/backends/bmv2/midend.cpp index 86815b4c247..99767d39693 100644 --- a/backends/bmv2/midend.cpp +++ b/backends/bmv2/midend.cpp @@ -27,6 +27,7 @@ limitations under the License. #include "midend/removeLeftSlices.h" #include "midend/convertEnums.h" #include "midend/simplifyKey.h" +#include "midend/parserControlFlow.h" #include "midend/simplifySelect.h" #include "frontends/p4/uniqueNames.h" #include "frontends/p4/simplifyParsers.h" @@ -82,6 +83,7 @@ void MidEnd::setup_for_P4_16(CompilerOptions&) { // we may come through this path even if the program is actually a P4 v1.0 program auto evaluator = new P4::EvaluatorPass(&refMap, &typeMap); addPasses({ + new P4::RemoveParserControlFlow(&refMap, &typeMap), new P4::ConvertEnums(&refMap, &typeMap, new EnumOn32Bits()), new P4::RemoveReturns(&refMap), diff --git a/backends/p4test/midend.cpp b/backends/p4test/midend.cpp index ae22162ff74..6e49b6a16a4 100644 --- a/backends/p4test/midend.cpp +++ b/backends/p4test/midend.cpp @@ -25,8 +25,8 @@ limitations under the License. #include "midend/local_copyprop.h" #include "midend/simplifyKey.h" #include "midend/parserUnroll.h" -#include "midend/specialize.h" #include "midend/simplifySelect.h" +#include "midend/parserControlFlow.h" #include "frontends/p4/simplifyParsers.h" #include "frontends/p4/typeMap.h" #include "frontends/p4/evaluator/evaluator.h" @@ -47,19 +47,18 @@ MidEnd::MidEnd(CompilerOptions& options) { auto evaluator = new P4::EvaluatorPass(&refMap, &typeMap); setName("MidEnd"); - // TODO: def-use analysis and related optimizations + // TODO: def-use-related optimizations // TODO: parser loop unrolling // TODO: improve copy propagation // TODO: simplify actions which are too complex // TODO: lower errors to integers // TODO: handle bit-slices as out arguments - // TODO: remove control-flow from parsers addPasses({ + new P4::RemoveParserControlFlow(&refMap, &typeMap), new P4::RemoveReturns(&refMap), new P4::MoveConstructors(&refMap), new P4::RemoveAllUnusedDeclarations(&refMap), new P4::ClearTypeMap(&typeMap), - new P4::SpecializeAll(&refMap, &typeMap), evaluator, new VisitFunctor([evaluator](const IR::Node *root) -> const IR::Node * { auto toplevel = evaluator->getToplevelBlock(); diff --git a/frontends/Makefile.am b/frontends/Makefile.am index 003b3a0d694..76aa9ad8586 100644 --- a/frontends/Makefile.am +++ b/frontends/Makefile.am @@ -81,7 +81,9 @@ p4_frontend_SOURCES = \ frontends/p4/resetHeaders.cpp \ frontends/p4/resetHeaders.h \ frontends/p4/moveDeclarations.cpp \ - frontends/p4/moveDeclarations.h + frontends/p4/moveDeclarations.h \ + frontends/p4/specialize.h \ + frontends/p4/specialize.cpp common_frontend_SOURCES = \ frontends/common/options.h \ diff --git a/frontends/p4/frontend.cpp b/frontends/p4/frontend.cpp index bdae789d982..d62e4f55bc6 100644 --- a/frontends/p4/frontend.cpp +++ b/frontends/p4/frontend.cpp @@ -42,6 +42,7 @@ limitations under the License. #include "sideEffects.h" #include "simplifyDefUse.h" #include "simplifyParsers.h" +#include "specialize.h" namespace P4 { @@ -106,6 +107,7 @@ FrontEnd::run(const CompilerOptions &options, const IR::P4Program* program) { new SideEffectOrdering(&refMap, &typeMap), new SimplifyControlFlow(&refMap, &typeMap), new SimplifyDefUse(&refMap, &typeMap), + new P4::SpecializeAll(&refMap, &typeMap), }; passes.setName("FrontEnd"); diff --git a/midend/specialize.cpp b/frontends/p4/specialize.cpp similarity index 100% rename from midend/specialize.cpp rename to frontends/p4/specialize.cpp diff --git a/midend/specialize.h b/frontends/p4/specialize.h similarity index 97% rename from midend/specialize.h rename to frontends/p4/specialize.h index 27931805cd9..288fcdb266c 100644 --- a/midend/specialize.h +++ b/frontends/p4/specialize.h @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. */ -#ifndef _MIDEND_SPECIALIZE_H_ -#define _MIDEND_SPECIALIZE_H_ +#ifndef _FRONTENDS_P4_SPECIALIZE_H_ +#define _FRONTENDS_P4_SPECIALIZE_H_ #include "ir/ir.h" #include "frontends/common/resolveReferences/referenceMap.h" @@ -135,4 +135,4 @@ class SpecializeAll : public PassRepeated { } // namespace P4 -#endif /* _MIDEND_SPECIALIZE_H_ */ +#endif /* _FRONTENDS_P4_SPECIALIZE_H_ */ diff --git a/midend/Makefile.am b/midend/Makefile.am index 42a455b64af..7b89cba99bd 100644 --- a/midend/Makefile.am +++ b/midend/Makefile.am @@ -33,6 +33,8 @@ midend_SOURCES = \ midend/moveConstructors.h \ midend/parserUnroll.h \ midend/parserUnroll.cpp \ + midend/parserControlFlow.h \ + midend/parserControlFlow.cpp \ midend/removeParameters.cpp \ midend/removeParameters.h \ midend/removeReturns.cpp \ @@ -42,8 +44,6 @@ midend_SOURCES = \ midend/simplifyKey.h \ midend/simplifyKey.cpp \ midend/simplifySelect.cpp \ - midend/simplifySelect.h \ - midend/specialize.h \ - midend/specialize.cpp + midend/simplifySelect.h cpplint_FILES += $(midend_SOURCES) diff --git a/midend/parserControlFlow.cpp b/midend/parserControlFlow.cpp new file mode 100644 index 00000000000..b1716c688be --- /dev/null +++ b/midend/parserControlFlow.cpp @@ -0,0 +1,140 @@ +/* +Copyright 2016 VMware, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#include "parserControlFlow.h" + +namespace P4 { + +/* convert +state s { + statement1; + statement2; + if (exp) + statement3; + else + statement4; + statement5; + transition selectExpression; +} + +into 4 states: + +state s { + statement1; + statement2; + transition select(exp) { + true: s_true; + false: s_false; + } +} + +state s_true { + statement3; + transition s_join; +} + +state s_false { + statement4; + transition s_join; +} + +state s_join { + statement5; + transition selectExpression; +} + +*/ + +const IR::Node* DoRemoveParserControlFlow::postorder(IR::ParserState* state) { + LOG1("Visiting " << dbp(state)); + // TODO: we keep annotations on the first state, + // but this may be wrong for something like @atomic + + // Set of newly created states + auto states = new IR::IndexedVector(); + IR::ParserState* currentState = state; + // components of the currentState + auto currentComponents = new IR::IndexedVector(); + auto origComponents = state->components; + auto origSelect = state->selectExpression; + + cstring joinName; // non-empty if we split the state + for (auto c : *origComponents) { + if (c->is()) { + LOG1("Converting " << c << " into states"); + + states->push_back(currentState); + auto ifstat = c->to(); + cstring joinName = refMap->newName(state->name.name + "_join"); + + // s_true + cstring trueName = refMap->newName(state->name.name + "_true"); + auto trueComponents = new IR::IndexedVector(); + trueComponents->push_back(ifstat->ifTrue); + auto trueState = new IR::ParserState( + Util::SourceInfo(), trueName, IR::Annotations::empty, trueComponents, + new IR::PathExpression(IR::ID(joinName))); + states->push_back(trueState); + + // s_false + cstring falseName = joinName; + if (ifstat->ifFalse != nullptr) { + falseName = refMap->newName(state->name.name + "_false"); + auto falseComponents = new IR::IndexedVector(); + falseComponents->push_back(ifstat->ifFalse); + auto falseState = new IR::ParserState( + Util::SourceInfo(), falseName, IR::Annotations::empty, falseComponents, + new IR::PathExpression(IR::ID(joinName))); + states->push_back(falseState); + } + + // left-over + auto vec = new IR::Vector(); + vec->push_back(ifstat->condition); + auto trueCase = new IR::SelectCase( + Util::SourceInfo(), new IR::BoolLiteral(true), + new IR::PathExpression(IR::ID(trueName))); + auto falseCase = new IR::SelectCase( + Util::SourceInfo(), new IR::BoolLiteral(false), + new IR::PathExpression(IR::ID(falseName))); + auto cases = new IR::Vector(); + cases->push_back(trueCase); + cases->push_back(falseCase); + currentState->selectExpression = new IR::SelectExpression( + Util::SourceInfo(), new IR::ListExpression(vec), std::move(*cases)); + + currentState->components = currentComponents; + currentComponents = new IR::IndexedVector(); + currentState = new IR::ParserState( + Util::SourceInfo(), joinName, IR::Annotations::empty, + currentComponents, origSelect); // may be overriten + } else { + currentComponents->push_back(c); + } + } + + if (states->empty()) + return state; + states->push_back(currentState); + return states; +} + +Visitor::profile_t DoRemoveParserControlFlow::init_apply(const IR::Node* node) { + LOG1("DoRemoveControlFlow"); + return Transform::init_apply(node); +} + +} // namespace P4 diff --git a/midend/parserControlFlow.h b/midend/parserControlFlow.h new file mode 100644 index 00000000000..6851cee47fb --- /dev/null +++ b/midend/parserControlFlow.h @@ -0,0 +1,49 @@ +/* +Copyright 2016 VMware, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef _MIDEND_PARSERCONTROLFLOW_H_ +#define _MIDEND_PARSERCONTROLFLOW_H_ + +#include "ir/ir.h" +#include "frontends/common/resolveReferences/referenceMap.h" +#include "frontends/p4/simplify.h" + +namespace P4 { + +// Converts if statements in parsers into transitions. +// This should be run after variables have been moved to the "top" of +// the parser. +class DoRemoveParserControlFlow : public Transform { + ReferenceMap* refMap; + public: + DoRemoveParserControlFlow(ReferenceMap* refMap) : refMap(refMap) + { CHECK_NULL(refMap); setName("DoRemoveParserControlFlow"); } + const IR::Node* postorder(IR::ParserState* state) override; + Visitor::profile_t init_apply(const IR::Node* node) override; +}; + +class RemoveParserControlFlow : public PassRepeated { + public: + RemoveParserControlFlow(ReferenceMap* refMap, TypeMap* typeMap) : PassRepeated({}) { + passes.emplace_back(new DoRemoveParserControlFlow(refMap)); + passes.emplace_back(new SimplifyControlFlow(refMap, typeMap)); + setName("RemoveParserControlFlow"); + } +}; + +} // namespace P4 + +#endif /* _MIDEND_PARSERCONTROLFLOW_H_ */ diff --git a/midend/parserInlining.h b/testdata/p4_16_samples/parser-conditional.p4 similarity index 65% rename from midend/parserInlining.h rename to testdata/p4_16_samples/parser-conditional.p4 index b227ceed356..57a3e0b3e94 100644 --- a/midend/parserInlining.h +++ b/testdata/p4_16_samples/parser-conditional.p4 @@ -1,5 +1,5 @@ /* -Copyright 2013-present Barefoot Networks, Inc. +Copyright 2016 VMware, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,13 +14,18 @@ See the License for the specific language governing permissions and limitations under the License. */ -#ifndef _MIDEND_PARSERINLINING_H_ -#define _MIDEND_PARSERINLINING_H_ - -namespace P4 { - - - -} // namespace P4 - -#end /* _MIDEND_PARSERINLINING_H_ */ +parser p() { + bit<32> a = 1; + bit<32> b; + state start { + b = (a == 0) ? 32w2 : 3; + b = b + 1; + b = (a > 0) ? ((a > 1) ? b+1 : b+2) : b+3; + transition accept; + } +} + +parser proto(); +package top(proto _p); + +top(p()) main; diff --git a/testdata/p4_16_samples_outputs/inline-control-midend.p4 b/testdata/p4_16_samples_outputs/inline-control-midend.p4 index e3201f7d4db..ebbfd4d3a3b 100644 --- a/testdata/p4_16_samples_outputs/inline-control-midend.p4 +++ b/testdata/p4_16_samples_outputs/inline-control-midend.p4 @@ -5,11 +5,11 @@ extern Y { control d(out bit<32> x) { @name("x_0") bit<32> x_1; - @name("tmp") bit<32> tmp_2; - @name("tmp_0") Y(32w16) tmp_1; + @name("tmp") bit<32> tmp_0; + @name("cinst.inst") Y(32w16) cinst_inst_0; action act() { - tmp_2 = tmp_1.get(); - x_1 = tmp_2; + tmp_0 = cinst_inst_0.get(); + x_1 = tmp_0; x = x_1; } table tbl_act() { diff --git a/testdata/p4_16_samples_outputs/parser-conditional-first.p4 b/testdata/p4_16_samples_outputs/parser-conditional-first.p4 new file mode 100644 index 00000000000..78defaf10ba --- /dev/null +++ b/testdata/p4_16_samples_outputs/parser-conditional-first.p4 @@ -0,0 +1,14 @@ +parser p() { + bit<32> a = 32w1; + bit<32> b; + state start { + b = (a == 32w0 ? 32w2 : 32w3); + b = b + 32w1; + b = (a > 32w0 ? (a > 32w1 ? b + 32w1 : b + 32w2) : b + 32w3); + transition accept; + } +} + +parser proto(); +package top(proto _p); +top(p()) main; diff --git a/testdata/p4_16_samples_outputs/parser-conditional-frontend.p4 b/testdata/p4_16_samples_outputs/parser-conditional-frontend.p4 new file mode 100644 index 00000000000..cfab1b096a2 --- /dev/null +++ b/testdata/p4_16_samples_outputs/parser-conditional-frontend.p4 @@ -0,0 +1,48 @@ +parser p() { + @name("a") bit<32> a_0; + @name("b") bit<32> b_0; + bool tmp; + bit<32> tmp_0; + bit<32> tmp_1; + bool tmp_2; + bit<32> tmp_3; + bool tmp_4; + bit<32> tmp_5; + bit<32> tmp_6; + bit<32> tmp_7; + bit<32> tmp_8; + state start { + a_0 = 32w1; + tmp = a_0 == 32w0; + if (tmp) + tmp_0 = 32w2; + else + tmp_0 = 32w3; + b_0 = tmp_0; + tmp_1 = b_0 + 32w1; + b_0 = tmp_1; + tmp_2 = a_0 > 32w0; + if (tmp_2) { + tmp_4 = a_0 > 32w1; + if (tmp_4) { + tmp_6 = b_0 + 32w1; + tmp_5 = tmp_6; + } + else { + tmp_7 = b_0 + 32w2; + tmp_5 = tmp_7; + } + tmp_3 = tmp_5; + } + else { + tmp_8 = b_0 + 32w3; + tmp_3 = tmp_8; + } + b_0 = tmp_3; + transition accept; + } +} + +parser proto(); +package top(proto _p); +top(p()) main; diff --git a/testdata/p4_16_samples_outputs/parser-conditional-midend.p4 b/testdata/p4_16_samples_outputs/parser-conditional-midend.p4 new file mode 100644 index 00000000000..d5ef50aafcb --- /dev/null +++ b/testdata/p4_16_samples_outputs/parser-conditional-midend.p4 @@ -0,0 +1,74 @@ +parser p() { + @name("a") bit<32> a; + @name("b") bit<32> b; + @name("tmp") bool tmp_9; + @name("tmp_0") bit<32> tmp_10; + @name("tmp_1") bit<32> tmp_11; + @name("tmp_2") bool tmp_12; + @name("tmp_3") bit<32> tmp_13; + @name("tmp_4") bool tmp_14; + @name("tmp_5") bit<32> tmp_15; + @name("tmp_6") bit<32> tmp_16; + @name("tmp_7") bit<32> tmp_17; + @name("tmp_8") bit<32> tmp_18; + state start { + a = 32w1; + tmp_9 = a == 32w0; + transition select(tmp_9) { + true: start_true; + false: start_false; + } + } + state start_true { + tmp_10 = 32w2; + transition start_join; + } + state start_false { + tmp_10 = 32w3; + transition start_join; + } + state start_join { + b = tmp_10; + tmp_11 = b + 32w1; + b = tmp_11; + tmp_12 = a > 32w0; + transition select(tmp_12) { + true: start_true_0; + false: start_false_0; + } + } + state start_true_0 { + tmp_14 = a > 32w1; + transition select(tmp_14) { + true: start_true_0_true; + false: start_true_0_false; + } + } + state start_true_0_true { + tmp_16 = b + 32w1; + tmp_15 = tmp_16; + transition start_true_0_join; + } + state start_true_0_false { + tmp_17 = b + 32w2; + tmp_15 = tmp_17; + transition start_true_0_join; + } + state start_true_0_join { + tmp_13 = tmp_15; + transition start_join_0; + } + state start_false_0 { + tmp_18 = b + 32w3; + tmp_13 = tmp_18; + transition start_join_0; + } + state start_join_0 { + b = tmp_13; + transition accept; + } +} + +parser proto(); +package top(proto _p); +top(p()) main; diff --git a/testdata/p4_16_samples_outputs/parser-conditional.p4 b/testdata/p4_16_samples_outputs/parser-conditional.p4 new file mode 100644 index 00000000000..f5727511e0d --- /dev/null +++ b/testdata/p4_16_samples_outputs/parser-conditional.p4 @@ -0,0 +1,14 @@ +parser p() { + bit<32> a = 1; + bit<32> b; + state start { + b = (a == 0 ? 32w2 : 3); + b = b + 1; + b = (a > 0 ? (a > 1 ? b + 1 : b + 2) : b + 3); + transition accept; + } +} + +parser proto(); +package top(proto _p); +top(p()) main; diff --git a/testdata/p4_16_samples_outputs/parser-conditional.p4-stderr b/testdata/p4_16_samples_outputs/parser-conditional.p4-stderr new file mode 100644 index 00000000000..e69de29bb2d From 9c0c313d2d57dda13a15416c2735717f3cd9d2d0 Mon Sep 17 00:00:00 2001 From: mbudiu-vmw Date: Mon, 3 Oct 2016 16:39:42 -0700 Subject: [PATCH 9/9] An ID now has two potential strings: the original name and the new name --- frontends/p4/p4-parse.ypp | 38 ++++++++++--------- frontends/p4/toP4/toP4.cpp | 2 +- frontends/p4/uniqueNames.cpp | 4 +- ir/base.def | 26 +++++++++++-- ir/id.h | 18 +++++---- .../p4_16_samples_outputs/uninit.p4-stderr | 10 ++--- 6 files changed, 62 insertions(+), 36 deletions(-) diff --git a/frontends/p4/p4-parse.ypp b/frontends/p4/p4-parse.ypp index c2ed64f6cc0..c87c84a1c42 100644 --- a/frontends/p4/p4-parse.ypp +++ b/frontends/p4/p4-parse.ypp @@ -249,11 +249,11 @@ declaration ; name - : IDENTIFIER { $$ = new IR::ID(@1, $1); } - | APPLY { $$ = new IR::ID(@1, "apply"); } - | KEY { $$ = new IR::ID(@1, "key"); } - | ACTIONS { $$ = new IR::ID(@1, "actions"); } - | STATE { $$ = new IR::ID(@1, "state"); } + : IDENTIFIER { $$ = new IR::ID(@1, $1, $1); } + | APPLY { $$ = new IR::ID(@1, "apply", "apply"); } + | KEY { $$ = new IR::ID(@1, "key", "key"); } + | ACTIONS { $$ = new IR::ID(@1, "actions", "actions"); } + | STATE { $$ = new IR::ID(@1, "state", "state"); } ; optAnnotations @@ -345,12 +345,12 @@ pathPrefix relativePathPrefix : /* empty */ { $$ = new IR::PathPrefix(); } | relativePathPrefix NAMESPACE '.' { structure.pathAppendNamespace($2); - $$ = new IR::PathPrefix(@1 + @3, $1, IR::ID(@2, $2)); } + $$ = new IR::PathPrefix(@1 + @3, $1, IR::ID(@2, $2, $2)); } ; nonEmptyRelativePathPrefix : relativePathPrefix NAMESPACE '.' { structure.pathAppendNamespace($2); - $$ = new IR::PathPrefix(@1 + @3, $1, IR::ID(@2, $2)); } + $$ = new IR::PathPrefix(@1 + @3, $1, IR::ID(@2, $2, $2)); } ; /**************************** PARSER ******************************/ @@ -521,7 +521,7 @@ methodPrototype '(' parameterList ')' ';' { structure.pop(); } { auto par = new IR::ParameterList(@5, $5); auto mt = new IR::Type_Method(@1, $2, nullptr, par); - $$ = new IR::Method(@1, IR::ID(@1, $1), mt, false); } + $$ = new IR::Method(@1, IR::ID(@1, $1, $1), mt, false); } ; /************************** TYPES ****************************/ @@ -535,8 +535,8 @@ typeRef ; typeName - : TYPE { $$ = new IR::Type_Name(@1, new IR::Path(IR::ID(@1, $1))); } - | pathPrefix TYPE { $$ = new IR::Type_Name(@1, new IR::Path($1, IR::ID(@2, $2))); } + : TYPE { $$ = new IR::Type_Name(@1, new IR::Path(IR::ID(@1, $1, $1))); } + | pathPrefix TYPE { $$ = new IR::Type_Name(@1, new IR::Path($1, IR::ID(@2, $2, $2))); } ; tupleType @@ -549,10 +549,10 @@ headerStackType specializedType : pathPrefix TYPE '<' typeArgumentList '>' - { auto id = IR::ID(@2, $2); + { auto id = IR::ID(@2, $2, $2); auto type = new IR::Type_Name(@1, new IR::Path($1, id)); $$ = new IR::Type_Specialized(@1 + @5, type, $4); } - | TYPE '<' typeArgumentList '>' { auto id = IR::ID(@1, $1); + | TYPE '<' typeArgumentList '>' { auto id = IR::ID(@1, $1, $1); auto type = new IR::Type_Name(@1, new IR::Path(id)); $$ = new IR::Type_Specialized(@1 + @4, type, $3); } ; @@ -631,7 +631,7 @@ structFieldList structField : optAnnotations typeRef name ';' { $$ = new IR::StructField(@3, *$3, $1, $2); } - | optAnnotations typeRef TYPE ';' { $$ = new IR::StructField(@3, IR::ID(@3, $3), $1, $2); } + | optAnnotations typeRef TYPE ';' { $$ = new IR::StructField(@3, IR::ID(@3, $3, $3), $1, $2); } ; enumDeclaration @@ -766,21 +766,23 @@ tablePropertyList tableProperty : KEY '=' '{' keyElementList '}' { auto v = new IR::Key(@4, $4); auto id = IR::ID( - @1, IR::TableProperties::keyPropertyName); + @1, IR::TableProperties::keyPropertyName, + IR::TableProperties::keyPropertyName); $$ = new IR::TableProperty( @1 + @5, id, IR::Annotations::empty, v, false); } | ACTIONS '=' '{' actionList '}' { auto v = new IR::ActionList(@4, $4); auto id = IR::ID( - @1, IR::TableProperties::actionsPropertyName); + @1, IR::TableProperties::actionsPropertyName, + IR::TableProperties::actionsPropertyName); $$ = new IR::TableProperty( @1 + @5, id, IR::Annotations::empty, v, false); } | optAnnotations CONST IDENTIFIER '=' initializer ';' { auto v = new IR::ExpressionValue(@5, $5); - auto id = IR::ID(@3, $3); + auto id = IR::ID(@3, $3, $3); $$ = new IR::TableProperty(@3, id, $1, v, true); } | optAnnotations IDENTIFIER '=' initializer ';' { auto v = new IR::ExpressionValue(@4, $4); - auto id = IR::ID(@2, $2); + auto id = IR::ID(@2, $2, $2); $$ = new IR::TableProperty(@2, id, $1, v, false); } ; @@ -875,7 +877,7 @@ expressionList member : name - | TYPE { $$ = new IR::ID(@1, $1); } + | TYPE { $$ = new IR::ID(@1, $1, $1); } ; lvalue diff --git a/frontends/p4/toP4/toP4.cpp b/frontends/p4/toP4/toP4.cpp index f61ce697859..7092d2dfc71 100644 --- a/frontends/p4/toP4/toP4.cpp +++ b/frontends/p4/toP4/toP4.cpp @@ -1189,7 +1189,7 @@ bool ToP4::preorder(const IR::P4Table* c) { } bool ToP4::preorder(const IR::Path* p) { - builder.append(p->toString()); + builder.append(p->asString()); return false; } } // namespace P4 diff --git a/frontends/p4/uniqueNames.cpp b/frontends/p4/uniqueNames.cpp index f8a477300dc..d1eaa19f82b 100644 --- a/frontends/p4/uniqueNames.cpp +++ b/frontends/p4/uniqueNames.cpp @@ -53,7 +53,7 @@ IR::ID* RenameSymbols::getName() const { if (!renameMap->toRename(orig)) return nullptr; auto newName = renameMap->getName(orig); - auto name = new IR::ID(orig->getName().srcInfo, newName); + auto name = new IR::ID(orig->getName().srcInfo, newName, orig->getName().name); return name; } @@ -95,7 +95,7 @@ const IR::Node* RenameSymbols::postorder(IR::PathExpression* expression) { BUG_CHECK(expression->path->prefix == nullptr, "%1%: renaming expression with path", expression); auto newName = renameMap->getName(decl); - auto name = IR::ID(expression->path->name.srcInfo, newName); + auto name = IR::ID(expression->path->name.srcInfo, newName, expression->path->name.originalName); auto result = new IR::PathExpression(name); return result; } diff --git a/ir/base.def b/ir/base.def index 2719c93f052..29934889ead 100644 --- a/ir/base.def +++ b/ir/base.def @@ -140,6 +140,7 @@ class PathPrefix { void setAbsolute() { absolute = true; } toString{ // Prints path prefix without the trailing dot + // This uses the original name std::stringstream result; bool first = true; if (absolute) @@ -148,7 +149,7 @@ class PathPrefix { if (!first) result << "."; first = false; - result << a.name.c_str(); + result << a.toString(); } return cstring(result.str()); } @@ -161,15 +162,34 @@ class Path { Path { if (!srcInfo) srcInfo = prefix ? prefix->srcInfo + name.srcInfo : name.srcInfo; } bool isDontCare() const { return prefix == nullptr && name.isDontCare(); } toString{ + // This is the ORIGINAL name the user used std::stringstream str; if (prefix == nullptr) { - str << name; + str << name.toString(); } else { cstring ps = prefix->toString(); - str << ps << "." << name; + str << ps << "." << name.toString(); } return cstring(str.str()); } + cstring asString() const { + // The CURRENT internal name + std::stringstream result; + bool first = true; + if (prefix != nullptr) { + if (prefix->absolute) + first = false; + for (auto a : prefix->components) { + if (!first) + result << "."; + first = false; + result << a; + } + result << "."; + } + result << name; + return cstring(result.str()); + } dbprint{ Node::dbprint(out); out << ":" << toString(); } } diff --git a/ir/id.h b/ir/id.h index 717ab72deb7..083b373ff19 100644 --- a/ir/id.h +++ b/ir/id.h @@ -1,5 +1,5 @@ /* -Copyright 2013-present Barefoot Networks, Inc. +Copyright 2013-present Barefoot Networks, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -24,15 +24,19 @@ limitations under the License. namespace IR { -// an identifier +// An identifier. struct ID : Util::IHasSourceInfo { Util::SourceInfo srcInfo; cstring name = nullptr; + // We save the original name to show the user on error messages + cstring originalName = nullptr; ID() = default; - ID(Util::SourceInfo si, cstring n) : srcInfo(si), name(n) { - if (n.isNullOrEmpty()) BUG("Identifier with no name"); } - ID(const char *n) : ID(Util::SourceInfo(), n) {} // NOLINT(runtime/explicit) - ID(cstring n) : ID(Util::SourceInfo(), n) {} // NOLINT(runtime/explicit) + ID(Util::SourceInfo si, cstring n, cstring o = nullptr) : srcInfo(si), name(n), originalName(o) + { if (n.isNullOrEmpty()) BUG("Identifier with no name"); } + ID(const char *n, const char* o = nullptr) : // NOLINT(runtime/explicit) + ID(Util::SourceInfo(), n, o) {} + ID(cstring n, cstring o = nullptr) : // NOLINT(runtime/explicit) + ID(Util::SourceInfo(), n, o) {} void dbprint(std::ostream &out) const { out << name; } bool operator==(const ID &a) const { return name == a.name; } bool operator!=(const ID &a) const { return name != a.name; } @@ -40,7 +44,7 @@ struct ID : Util::IHasSourceInfo { operator cstring() const { return name; } bool isDontCare() const { return name == "_"; } Util::SourceInfo getSourceInfo() const override { return srcInfo; } - cstring toString() const override { return name; } + cstring toString() const override { return originalName.isNullOrEmpty() ? name : originalName; } }; } // namespace IR diff --git a/testdata/p4_16_samples_outputs/uninit.p4-stderr b/testdata/p4_16_samples_outputs/uninit.p4-stderr index e26f3bb642a..339b2c827a1 100644 --- a/testdata/p4_16_samples_outputs/uninit.p4-stderr +++ b/testdata/p4_16_samples_outputs/uninit.p4-stderr @@ -16,19 +16,19 @@ ../testdata/p4_16_samples/uninit.p4(42): warning: [] may not be completely initialized stack[0] = stack[1]; ^^^^^^^^ -../testdata/p4_16_samples/uninit.p4(62): warning: c_0 may be uninitialized +../testdata/p4_16_samples/uninit.p4(62): warning: c may be uninitialized c = !c; ^ -../testdata/p4_16_samples/uninit.p4(82): warning: b_1 may be uninitialized +../testdata/p4_16_samples/uninit.p4(82): warning: b may be uninitialized b = b + 1; ^ -../testdata/p4_16_samples/uninit.p4(86): warning: e_0 may be uninitialized +../testdata/p4_16_samples/uninit.p4(86): warning: e may be uninitialized if (e > 0) { ^ -../testdata/p4_16_samples/uninit.p4(92): warning: e_0 may be uninitialized +../testdata/p4_16_samples/uninit.p4(92): warning: e may be uninitialized e = e + 1; ^ -../testdata/p4_16_samples/uninit.p4(97): warning: touched_0 may be uninitialized +../testdata/p4_16_samples/uninit.p4(97): warning: touched may be uninitialized touched = !touched; ^^^^^^^ ../testdata/p4_16_samples/uninit.p4(68): warning: out parameter v may be uninitialized when control c terminates