From 6b1a8ed42c0ae73d85c584c40b9374fb3d9e9d83 Mon Sep 17 00:00:00 2001 From: Mihai Budiu Date: Mon, 9 May 2016 15:02:28 -0700 Subject: [PATCH 1/2] Moved P4/IR dumping into options and made uniform --- backends/bmv2/bmv2.cpp | 4 + backends/bmv2/midend.cpp | 12 +- backends/bmv2/midend.h | 3 + backends/ebpf/midend.cpp | 14 +- backends/ebpf/midend.h | 2 + backends/ebpf/p4c-ebpf.cpp | 38 ++- backends/v12test/Makefile.am | 8 +- backends/v12test/midend.cpp | 20 +- backends/v12test/options.cpp | 12 - backends/v12test/options.h | 16 -- backends/v12test/run-v12-sample.py | 9 +- backends/v12test/v12test.cpp | 57 +--- frontends/common/options.cpp | 85 ++++-- frontends/common/options.h | 23 +- frontends/p4/evaluator/evaluator.cpp | 3 +- frontends/p4/frontend.cpp | 9 +- frontends/p4/toP4/toP4.cpp | 4 +- ir/dbprint.cpp | 2 +- ir/ir.cpp | 49 ++-- ir/ir.def | 3 +- ir/pass_manager.h | 3 + ir/type.def | 3 +- lib/options.h | 15 +- midend/removeReturns.cpp | 76 ++++-- midend/removeReturns.h | 21 +- ...tent_e-FrontEnd_11_SimplifyControlFlowE.p4 | 15 ++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 15 ++ ...-uses-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ....p4 => action-uses-MidEnd_25_Evaluator.p4} | 0 ...tions-FrontEnd_11_SimplifyControlFlowE.p4} | 1 - ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 .../v1_2_samples_outputs/actionAnnotations.p4 | 1 - ...eturn-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...p4 => after-return-MidEnd_25_Evaluator.p4} | 0 ...tions-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...apply-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...midend.p4 => apply-MidEnd_25_Evaluator.p4} | 0 ...ly-cf-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...h-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 | 181 +++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 163 ++++++++++++ .../arith-bmv2-MidEnd_25_Evaluator.p4 | 163 ++++++++++++ .../v1_2_samples_outputs/arith-bmv2-fe.p4 | 62 ----- .../v1_2_samples_outputs/arith-bmv2-last.p4 | 62 ----- .../v1_2_samples_outputs/arith-bmv2-midend.p4 | 61 ----- testdata/v1_2_samples_outputs/arith-bmv2.p4 | 1 - ...e-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 | 188 +++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 170 ++++++++++++ .../arith-inline-bmv2-MidEnd_25_Evaluator.p4 | 184 +++++++++++++ .../arith-inline-bmv2-fe.p4 | 68 ----- .../arith-inline-bmv2-last.p4 | 68 ----- .../arith-inline-bmv2-midend.p4 | 82 ------ ...leton-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...leton-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...1-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 | 181 +++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 163 ++++++++++++ .../arith1-bmv2-MidEnd_25_Evaluator.p4 | 163 ++++++++++++ .../v1_2_samples_outputs/arith1-bmv2-fe.p4 | 61 ----- .../v1_2_samples_outputs/arith1-bmv2-last.p4 | 61 ----- .../arith1-bmv2-midend.p4 | 61 ----- ...2-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 | 181 +++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 163 ++++++++++++ .../arith2-bmv2-MidEnd_25_Evaluator.p4 | 163 ++++++++++++ .../v1_2_samples_outputs/arith2-bmv2-fe.p4 | 62 ----- .../v1_2_samples_outputs/arith2-bmv2-last.p4 | 62 ----- .../arith2-bmv2-midend.p4 | 61 ----- testdata/v1_2_samples_outputs/arith2-bmv2.p4 | 1 - ...e-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 | 182 +++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 164 ++++++++++++ .../arith2-inline-bmv2-MidEnd_25_Evaluator.p4 | 196 ++++++++++++++ .../arith2-inline-bmv2-fe.p4 | 62 ----- .../arith2-inline-bmv2-last.p4 | 62 ----- .../arith2-inline-bmv2-midend.p4 | 94 ------- ...3-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 | 181 +++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 163 ++++++++++++ .../arith3-bmv2-MidEnd_25_Evaluator.p4 | 163 ++++++++++++ .../v1_2_samples_outputs/arith3-bmv2-fe.p4 | 62 ----- .../v1_2_samples_outputs/arith3-bmv2-last.p4 | 62 ----- .../arith3-bmv2-midend.p4 | 61 ----- testdata/v1_2_samples_outputs/arith3-bmv2.p4 | 1 - ...4-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 | 181 +++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 163 ++++++++++++ .../arith4-bmv2-MidEnd_25_Evaluator.p4 | 163 ++++++++++++ .../v1_2_samples_outputs/arith4-bmv2-fe.p4 | 62 ----- .../v1_2_samples_outputs/arith4-bmv2-last.p4 | 62 ----- .../arith4-bmv2-midend.p4 | 61 ----- testdata/v1_2_samples_outputs/arith4-bmv2.p4 | 1 - ...5-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 | 181 +++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 163 ++++++++++++ .../arith5-bmv2-MidEnd_25_Evaluator.p4 | 163 ++++++++++++ .../v1_2_samples_outputs/arith5-bmv2-fe.p4 | 62 ----- .../v1_2_samples_outputs/arith5-bmv2-last.p4 | 62 ----- .../arith5-bmv2-midend.p4 | 61 ----- testdata/v1_2_samples_outputs/arith5-bmv2.p4 | 1 - ...tract-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ..._cast-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ... call-FrontEnd_11_SimplifyControlFlowE.p4} | 1 - ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 testdata/v1_2_samples_outputs/call.p4 | 1 - ...cases-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ... cast-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...const-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...lding-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...tants-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ..._cast-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...igned-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ..._ebpf-FrontEnd_11_SimplifyControlFlowE.p4} | 54 +++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 49 +++- ...d.p4 => count_ebpf-MidEnd_25_Evaluator.p4} | 49 +++- ... decl-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...decl2-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...midend.p4 => decl2-MidEnd_25_Evaluator.p4} | 0 ...ction-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...4 => direct-action-MidEnd_25_Evaluator.p4} | 0 ...aders-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...empty-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ... enum-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...> ex1-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...ssion-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...xtern-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...ilter-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...match-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...ctors-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...end.p4 => functors-MidEnd_25_Evaluator.p4} | 0 ...tors1-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...nd.p4 => functors1-MidEnd_25_Evaluator.p4} | 0 ...tors2-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...nd.p4 => functors2-MidEnd_25_Evaluator.p4} | 0 ...tors3-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...nd.p4 => functors3-MidEnd_25_Evaluator.p4} | 0 ...tors4-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...nd.p4 => functors4-MidEnd_25_Evaluator.p4} | 0 ...tors5-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...nd.p4 => functors5-MidEnd_25_Evaluator.p4} | 0 ...tors6-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...nd.p4 => functors6-MidEnd_25_Evaluator.p4} | 0 ...tors7-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...nd.p4 => functors7-MidEnd_25_Evaluator.p4} | 0 ...tors8-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...nd.p4 => functors8-MidEnd_25_Evaluator.p4} | 0 ...tors9-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...nd.p4 => functors9-MidEnd_25_Evaluator.p4} | 0 ...neric-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...ction-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...4 => global-action-MidEnd_25_Evaluator.p4} | 0 ...tion1-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ... => global-action1-MidEnd_25_Evaluator.p4} | 0 ...eader-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...order-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...nd.p4 => highorder-MidEnd_25_Evaluator.p4} | 0 ...licit-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...lizer-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...nline-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...idend.p4 => inline-MidEnd_25_Evaluator.p4} | 0 ...ction-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...4 => inline-action-MidEnd_25_Evaluator.p4} | 0 ...ntrol-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ... => inline-control-MidEnd_25_Evaluator.p4} | 0 ...witch-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...4 => inline-switch-MidEnd_25_Evaluator.p4} | 6 +- ...rface-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...nd.p4 => interface-MidEnd_25_Evaluator.p4} | 0 ...face1-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...d.p4 => interface1-MidEnd_25_Evaluator.p4} | 0 ...face2-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...large-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ... line-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...xample-FrontEnd_11_SimplifyControlFlowE.p4 | 113 ++++++++ ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 54 +++- ...d.p4 => lj_example-MidEnd_25_Evaluator.p4} | 53 +++- .../v1_2_samples_outputs/lj_example-last.p4 | 55 ---- testdata/v1_2_samples_outputs/lj_example.p4 | 1 - ...match-FrontEnd_11_SimplifyControlFlowE.p4} | 36 ++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 32 ++- ...odule-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...names-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...parse-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...ocals-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...4 => parser-locals-MidEnd_25_Evaluator.p4} | 0 ... pipe-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...-midend.p4 => pipe-MidEnd_25_Evaluator.p4} | 0 ...eline-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...dence-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...-type-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...hadow-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...ample-FrontEnd_11_SimplifyControlFlowE.p4} | 63 ++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 56 +++- ...ple-switch-example-MidEnd_25_Evaluator.p4} | 54 +++- ...model-FrontEnd_11_SimplifyControlFlowE.p4} | 36 ++- ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 48 ++++ .../v1_2_samples_outputs/simple_model-last.p4 | 18 -- ...-ex01-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...-ex03-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...-ex04-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...-ex06-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...-ex08-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...-ex09-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...-ex10-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...-ex12-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...-ex13-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...-ex14-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...-ex15-FrontEnd_11_SimplifyControlFlowE.p4} | 36 ++- ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 38 +++ .../v1_2_samples_outputs/spec-ex15-last.p4 | 8 - ...c-ex16-FrontEnd_11_SimplifyControlFlowE.p4 | 56 ++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 46 ++++ .../spec-ex16-MidEnd_25_Evaluator.p4 | 46 ++++ testdata/v1_2_samples_outputs/spec-ex16-fe.p4 | 22 -- .../v1_2_samples_outputs/spec-ex16-last.p4 | 16 -- .../v1_2_samples_outputs/spec-ex16-midend.p4 | 16 -- ...c-ex17-FrontEnd_11_SimplifyControlFlowE.p4 | 40 +++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 35 +++ testdata/v1_2_samples_outputs/spec-ex17-fe.p4 | 6 - .../v1_2_samples_outputs/spec-ex17-last.p4 | 5 - ...-ex18-FrontEnd_11_SimplifyControlFlowE.p4} | 36 ++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 32 ++- ...-ex19-FrontEnd_11_SimplifyControlFlowE.p4} | 36 ++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 32 ++- ...-ex20-FrontEnd_11_SimplifyControlFlowE.p4} | 36 ++- ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 50 ++++ .../v1_2_samples_outputs/spec-ex20-last.p4 | 20 -- ...-ex22-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...-ex25-FrontEnd_11_SimplifyControlFlowE.p4} | 1 - ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 testdata/v1_2_samples_outputs/spec-ex25.p4 | 1 - ...c-ex26-FrontEnd_11_SimplifyControlFlowE.p4 | 96 +++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 54 ++++ testdata/v1_2_samples_outputs/spec-ex26-fe.p4 | 38 --- .../v1_2_samples_outputs/spec-ex26-last.p4 | 9 - testdata/v1_2_samples_outputs/spec-ex26.p4 | 1 - ...c-ex27-FrontEnd_11_SimplifyControlFlowE.p4 | 40 +++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 35 +++ testdata/v1_2_samples_outputs/spec-ex27-fe.p4 | 6 - .../v1_2_samples_outputs/spec-ex27-last.p4 | 5 - ...-ex29-FrontEnd_11_SimplifyControlFlowE.p4} | 36 ++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 32 ++- ...-ex30-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...-ex31-FrontEnd_11_SimplifyControlFlowE.p4} | 36 ++- ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 45 ++++ .../v1_2_samples_outputs/spec-ex31-last.p4 | 15 -- ...-ex32-FrontEnd_11_SimplifyControlFlowE.p4} | 36 ++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 32 ++- ...-ex34-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...ation-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...stack-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...aders-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...tates-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...idend.p4 => states-MidEnd_25_Evaluator.p4} | 0 ...ength-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ..._anno-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...truct-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ..._ebpf-FrontEnd_11_SimplifyControlFlowE.p4} | 54 +++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 51 +++- ....p4 => switch_ebpf-MidEnd_25_Evaluator.p4} | 49 +++- ...ction-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...p4 => synth-action-MidEnd_25_Evaluator.p4} | 0 ...plate-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ..._ebpf-FrontEnd_11_SimplifyControlFlowE.p4} | 54 +++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 51 +++- ...nd.p4 => test_ebpf-MidEnd_25_Evaluator.p4} | 49 +++- ...oPipe-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ..._ebpf-FrontEnd_11_SimplifyControlFlowE.p4} | 54 +++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 51 +++- ...end.p4 => two_ebpf-MidEnd_25_Evaluator.p4} | 49 +++- ...arams-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...valid-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...rsion-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...rtual-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...dend.p4 => virtual-MidEnd_25_Evaluator.p4} | 0 ...tual2-FrontEnd_11_SimplifyControlFlowE.p4} | 0 ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 0 ...end.p4 => virtual2-MidEnd_25_Evaluator.p4} | 0 ...Match-FrontEnd_11_SimplifyControlFlowE.p4} | 124 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 108 +++++++- ....p4 => 01-BigMatch-MidEnd_25_Evaluator.p4} | 106 +++++++- ...adata1-FrontEnd_11_SimplifyControlFlowE.p4 | 178 +++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 162 ++++++++++++ .../01-DeadMetadata1-MidEnd_25_Evaluator.p4 | 162 ++++++++++++ .../v1_samples_outputs/01-DeadMetadata1-fe.p4 | 58 ----- .../01-DeadMetadata1-last.p4 | 58 ----- .../01-DeadMetadata1-midend.p4 | 60 ----- ...llPHV-FrontEnd_11_SimplifyControlFlowE.p4} | 124 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 108 +++++++- ...d.p4 => 01-FullPHV-MidEnd_25_Evaluator.p4} | 106 +++++++- ...hernet-FrontEnd_11_SimplifyControlFlowE.p4 | 171 ++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 153 +++++++++++ .../01-JustEthernet-MidEnd_25_Evaluator.p4 | 153 +++++++++++ .../v1_samples_outputs/01-JustEthernet-fe.p4 | 51 ---- .../01-JustEthernet-last.p4 | 51 ---- .../01-JustEthernet-midend.p4 | 51 ---- ...NoDeps-FrontEnd_11_SimplifyControlFlowE.p4 | 223 ++++++++++++++++ ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 108 +++++++- ...nd.p4 => 01-NoDeps-MidEnd_25_Evaluator.p4} | 106 +++++++- testdata/v1_samples_outputs/01-NoDeps-fe.p4 | 103 -------- ...eField-FrontEnd_11_SimplifyControlFlowE.p4 | 217 +++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 201 ++++++++++++++ .../02-BadSizeField-MidEnd_25_Evaluator.p4 | 203 +++++++++++++++ .../v1_samples_outputs/02-BadSizeField-fe.p4 | 97 ------- .../02-BadSizeField-last.p4 | 97 ------- .../02-BadSizeField-midend.p4 | 101 ------- ...adata2-FrontEnd_11_SimplifyControlFlowE.p4 | 179 +++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 163 ++++++++++++ .../02-DeadMetadata2-MidEnd_25_Evaluator.p4 | 163 ++++++++++++ .../v1_samples_outputs/02-DeadMetadata2-fe.p4 | 59 ----- .../02-DeadMetadata2-last.p4 | 59 ----- .../02-DeadMetadata2-midend.p4 | 61 ----- ...lPHV1-FrontEnd_11_SimplifyControlFlowE.p4} | 129 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 113 +++++++- ....p4 => 02-FullPHV1-MidEnd_25_Evaluator.p4} | 106 +++++++- testdata/v1_samples_outputs/02-FullPHV1.p4 | 5 - ...hernet-FrontEnd_11_SimplifyControlFlowE.p4 | 221 ++++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 205 +++++++++++++++ ...> 02-SplitEthernet-MidEnd_25_Evaluator.p4} | 106 +++++++- .../v1_samples_outputs/02-SplitEthernet-fe.p4 | 101 ------- .../02-SplitEthernet-last.p4 | 101 ------- ...adata3-FrontEnd_11_SimplifyControlFlowE.p4 | 193 ++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 177 +++++++++++++ .../03-DeadMetadata3-MidEnd_25_Evaluator.p4 | 179 +++++++++++++ .../v1_samples_outputs/03-DeadMetadata3-fe.p4 | 73 ------ .../03-DeadMetadata3-last.p4 | 73 ------ .../03-DeadMetadata3-midend.p4 | 77 ------ ...lPHV2-FrontEnd_11_SimplifyControlFlowE.p4} | 130 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 114 +++++++- ....p4 => 03-FullPHV2-MidEnd_25_Evaluator.p4} | 106 +++++++- testdata/v1_samples_outputs/03-FullPHV2.p4 | 6 - ...teway-FrontEnd_11_SimplifyControlFlowE.p4} | 124 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 108 +++++++- ...d.p4 => 03-Gateway-MidEnd_25_Evaluator.p4} | 106 +++++++- ...ompact-FrontEnd_11_SimplifyControlFlowE.p4 | 212 +++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 196 ++++++++++++++ ...plitEthernetCompact-MidEnd_25_Evaluator.p4 | 198 ++++++++++++++ .../03-SplitEthernetCompact-fe.p4 | 94 ------- .../03-SplitEthernetCompact-last.p4 | 94 ------- .../03-SplitEthernetCompact-midend.p4 | 96 ------- .../03-SplitEthernetCompact.p4 | 2 - ...fault-FrontEnd_11_SimplifyControlFlowE.p4} | 129 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 113 +++++++- ... 04-GatewayDefault-MidEnd_25_Evaluator.p4} | 106 +++++++- .../v1_samples_outputs/04-GatewayDefault.p4 | 5 - ...leVlan-FrontEnd_11_SimplifyControlFlowE.p4 | 218 ++++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 202 ++++++++++++++ .../04-SimpleVlan-MidEnd_25_Evaluator.p4 | 204 +++++++++++++++ .../v1_samples_outputs/04-SimpleVlan-fe.p4 | 100 ------- .../v1_samples_outputs/04-SimpleVlan-last.p4 | 100 ------- .../04-SimpleVlan-midend.p4 | 102 -------- testdata/v1_samples_outputs/04-SimpleVlan.p4 | 2 - ...roblem-FrontEnd_11_SimplifyControlFlowE.p4 | 210 +++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 194 ++++++++++++++ .../05-FieldProblem-MidEnd_25_Evaluator.p4 | 196 ++++++++++++++ .../v1_samples_outputs/05-FieldProblem-fe.p4 | 92 ------- .../05-FieldProblem-last.p4 | 92 ------- .../05-FieldProblem-midend.p4 | 94 ------- .../v1_samples_outputs/05-FieldProblem.p4 | 2 - ...lTPHV-FrontEnd_11_SimplifyControlFlowE.p4} | 130 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 114 +++++++- ....p4 => 05-FullTPHV-MidEnd_25_Evaluator.p4} | 106 +++++++- testdata/v1_samples_outputs/05-FullTPHV.p4 | 6 - ...eVlan1-FrontEnd_11_SimplifyControlFlowE.p4 | 217 +++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 201 ++++++++++++++ .../05-SimpleVlan1-MidEnd_25_Evaluator.p4 | 203 +++++++++++++++ .../v1_samples_outputs/05-SimpleVlan1-fe.p4 | 99 ------- .../v1_samples_outputs/05-SimpleVlan1-last.p4 | 99 ------- .../05-SimpleVlan1-midend.p4 | 101 ------- testdata/v1_samples_outputs/05-SimpleVlan1.p4 | 2 - ...TPHV1-FrontEnd_11_SimplifyControlFlowE.p4} | 130 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 114 +++++++- ...p4 => 06-FullTPHV1-MidEnd_25_Evaluator.p4} | 106 +++++++- testdata/v1_samples_outputs/06-FullTPHV1.p4 | 6 - ...nStack-FrontEnd_11_SimplifyControlFlowE.p4 | 220 ++++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 204 +++++++++++++++ ...06-SimpleVlanStack-MidEnd_25_Evaluator.p4} | 106 +++++++- .../06-SimpleVlanStack-fe.p4 | 102 -------- .../06-SimpleVlanStack-last.p4 | 102 -------- .../v1_samples_outputs/06-SimpleVlanStack.p4 | 2 - ...TPHV2-FrontEnd_11_SimplifyControlFlowE.p4} | 130 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 114 +++++++- ...p4 => 07-FullTPHV2-MidEnd_25_Evaluator.p4} | 106 +++++++- testdata/v1_samples_outputs/07-FullTPHV2.p4 | 6 - ...tocol-FrontEnd_11_SimplifyControlFlowE.p4} | 128 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 112 +++++++- ...> 07-MultiProtocol-MidEnd_25_Evaluator.p4} | 106 +++++++- .../v1_samples_outputs/07-MultiProtocol.p4 | 4 - ...tackIP-FrontEnd_11_SimplifyControlFlowE.p4 | 244 +++++++++++++++++ ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 110 +++++++- ...-SimpleVlanStackIP-MidEnd_25_Evaluator.p4} | 106 +++++++- .../07-SimpleVlanStackIP-last.p4 | 126 --------- .../07-SimpleVlanStackIP.p4 | 2 - ...TPHV3-FrontEnd_11_SimplifyControlFlowE.p4} | 130 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 114 +++++++- ...p4 => 08-FullTPHV3-MidEnd_25_Evaluator.p4} | 106 +++++++- testdata/v1_samples_outputs/08-FullTPHV3.p4 | 6 - ...fElse-FrontEnd_11_SimplifyControlFlowE.p4} | 127 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 111 +++++++- ...ultiProtocolIfElse-MidEnd_25_Evaluator.p4} | 106 +++++++- .../08-MultiProtocolIfElse.p4 | 3 - ...tFlags-FrontEnd_11_SimplifyControlFlowE.p4 | 246 ++++++++++++++++++ ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 110 +++++++- ...nStackIPSplitFlags-MidEnd_25_Evaluator.p4} | 106 +++++++- .../08-SimpleVlanStackIPSplitFlags-fe.p4 | 128 --------- .../08-SimpleVlanStackIPSplitFlags.p4 | 2 - ...rities-FrontEnd_11_SimplifyControlFlowE.p4 | 227 ++++++++++++++++ ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 110 +++++++- ...0-SelectPriorities-MidEnd_25_Evaluator.p4} | 106 +++++++- .../10-SelectPriorities-last.p4 | 109 -------- .../v1_samples_outputs/10-SelectPriorities.p4 | 2 - ...tiTags-FrontEnd_11_SimplifyControlFlowE.p4 | 235 +++++++++++++++++ ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 110 +++++++- ...p4 => 11-MultiTags-MidEnd_25_Evaluator.p4} | 106 +++++++- testdata/v1_samples_outputs/11-MultiTags.p4 | 2 - ...unters-FrontEnd_11_SimplifyControlFlowE.p4 | 197 ++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 181 +++++++++++++ .../12-Counters-MidEnd_25_Evaluator.p4 | 186 +++++++++++++ testdata/v1_samples_outputs/12-Counters-fe.p4 | 79 ------ .../v1_samples_outputs/12-Counters-last.p4 | 79 ------ .../v1_samples_outputs/12-Counters-midend.p4 | 84 ------ testdata/v1_samples_outputs/12-Counters.p4 | 2 - ...NoLoop-FrontEnd_11_SimplifyControlFlowE.p4 | 233 +++++++++++++++++ ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 112 +++++++- ...12-MultiTagsNoLoop-MidEnd_25_Evaluator.p4} | 106 +++++++- .../12-MultiTagsNoLoop-fe.p4 | 115 -------- .../12-MultiTagsNoLoop-last.p4 | 115 -------- .../v1_samples_outputs/12-MultiTagsNoLoop.p4 | 2 - ...s1and2-FrontEnd_11_SimplifyControlFlowE.p4 | 194 ++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 178 +++++++++++++ .../13-Counters1and2-MidEnd_25_Evaluator.p4 | 180 +++++++++++++ .../v1_samples_outputs/13-Counters1and2-fe.p4 | 76 ------ .../13-Counters1and2-last.p4 | 76 ------ .../13-Counters1and2-midend.p4 | 78 ------ .../v1_samples_outputs/13-Counters1and2.p4 | 2 - ...rrect-FrontEnd_11_SimplifyControlFlowE.p4} | 126 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 110 +++++++- ...3-MultiTagsCorrect-MidEnd_25_Evaluator.p4} | 106 +++++++- .../v1_samples_outputs/13-MultiTagsCorrect.p4 | 2 - ...ounter-FrontEnd_11_SimplifyControlFlowE.p4 | 183 +++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 167 ++++++++++++ .../14-Counter-MidEnd_25_Evaluator.p4 | 167 ++++++++++++ testdata/v1_samples_outputs/14-Counter-fe.p4 | 64 ----- .../v1_samples_outputs/14-Counter-last.p4 | 64 ----- .../v1_samples_outputs/14-Counter-midend.p4 | 65 ----- testdata/v1_samples_outputs/14-Counter.p4 | 1 - ...erThan-FrontEnd_11_SimplifyControlFlowE.p4 | 188 +++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 172 ++++++++++++ ...-GatewayGreaterThan-MidEnd_25_Evaluator.p4 | 172 ++++++++++++ .../14-GatewayGreaterThan-fe.p4 | 69 ----- .../14-GatewayGreaterThan-last.p4 | 69 ----- .../14-GatewayGreaterThan-midend.p4 | 70 ----- .../14-GatewayGreaterThan.p4 | 1 - ...tVlan-FrontEnd_11_SimplifyControlFlowE.p4} | 126 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 110 +++++++- ...-SplitEthernetVlan-MidEnd_25_Evaluator.p4} | 106 +++++++- .../14-SplitEthernetVlan.p4 | 2 - ...nimal-FrontEnd_11_SimplifyControlFlowE.p4} | 126 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 110 +++++++- ...tocolIfElseMinimal-MidEnd_25_Evaluator.p4} | 106 +++++++- .../15-MultiProtocolIfElseMinimal.p4 | 2 - ...eaders-FrontEnd_11_SimplifyControlFlowE.p4 | 171 ++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 155 +++++++++++ .../16-NoHeaders-MidEnd_25_Evaluator.p4 | 155 +++++++++++ .../v1_samples_outputs/16-NoHeaders-fe.p4 | 52 ---- .../v1_samples_outputs/16-NoHeaders-last.p4 | 52 ---- .../v1_samples_outputs/16-NoHeaders-midend.p4 | 53 ---- testdata/v1_samples_outputs/16-NoHeaders.p4 | 1 - ...rences-FrontEnd_11_SimplifyControlFlowE.p4 | 241 +++++++++++++++++ ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 114 +++++++- ...> 16-TwoReferences-MidEnd_25_Evaluator.p4} | 106 +++++++- .../16-TwoReferences-last.p4 | 127 --------- .../v1_samples_outputs/16-TwoReferences.p4 | 6 - ...inimal-FrontEnd_11_SimplifyControlFlowE.p4 | 161 ++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 143 ++++++++++ .../17-Minimal-MidEnd_25_Evaluator.p4 | 143 ++++++++++ testdata/v1_samples_outputs/17-Minimal-fe.p4 | 41 --- .../v1_samples_outputs/17-Minimal-last.p4 | 41 --- .../v1_samples_outputs/17-Minimal-midend.p4 | 41 --- ...elines-FrontEnd_11_SimplifyControlFlowE.p4 | 171 ++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 153 +++++++++++ .../18-EmptyPipelines-MidEnd_25_Evaluator.p4 | 153 +++++++++++ .../18-EmptyPipelines-fe.p4 | 51 ---- .../18-EmptyPipelines-last.p4 | 51 ---- .../18-EmptyPipelines-midend.p4 | 51 ---- ... acl1-FrontEnd_11_SimplifyControlFlowE.p4} | 124 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 108 +++++++- ...-midend.p4 => acl1-MidEnd_25_Evaluator.p4} | 106 +++++++- testdata/v1_samples_outputs/acl1.p4 | 4 +- ..._bus1-FrontEnd_11_SimplifyControlFlowE.p4} | 132 +++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 116 ++++++++- ....p4 => action_bus1-MidEnd_25_Evaluator.p4} | 106 +++++++- testdata/v1_samples_outputs/action_bus1.p4 | 8 - ...hain1-FrontEnd_11_SimplifyControlFlowE.p4} | 129 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 113 +++++++- ...4 => action_chain1-MidEnd_25_Evaluator.p4} | 106 +++++++- testdata/v1_samples_outputs/action_chain1.p4 | 5 - ...inline-FrontEnd_11_SimplifyControlFlowE.p4 | 182 +++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 166 ++++++++++++ .../action_inline-MidEnd_25_Evaluator.p4 | 163 ++++++++++++ .../v1_samples_outputs/action_inline-fe.p4 | 62 ----- .../v1_samples_outputs/action_inline-last.p4 | 62 ----- .../action_inline-midend.p4 | 61 ----- testdata/v1_samples_outputs/action_inline.p4 | 4 +- ...nline1-FrontEnd_11_SimplifyControlFlowE.p4 | 196 ++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 180 +++++++++++++ .../action_inline1-MidEnd_25_Evaluator.p4 | 177 +++++++++++++ .../v1_samples_outputs/action_inline1-fe.p4 | 76 ------ .../v1_samples_outputs/action_inline1-last.p4 | 76 ------ .../action_inline1-midend.p4 | 75 ------ testdata/v1_samples_outputs/action_inline1.p4 | 4 +- ... axon-FrontEnd_11_SimplifyControlFlowE.p4} | 126 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 111 +++++++- ...-midend.p4 => axon-MidEnd_25_Evaluator.p4} | 107 +++++++- testdata/v1_samples_outputs/axon.p4 | 2 - ...uting-FrontEnd_11_SimplifyControlFlowE.p4} | 124 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 108 +++++++- ...4 => basic_routing-MidEnd_25_Evaluator.p4} | 106 +++++++- ...ksum1-FrontEnd_11_SimplifyControlFlowE.p4} | 126 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 110 +++++++- ...nd.p4 => checksum1-MidEnd_25_Evaluator.p4} | 106 +++++++- testdata/v1_samples_outputs/checksum1.p4 | 2 - ...to_cpu-FrontEnd_11_SimplifyControlFlowE.p4 | 231 ++++++++++++++++ ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 117 ++++++++- ....p4 => copy_to_cpu-MidEnd_25_Evaluator.p4} | 113 +++++++- .../v1_samples_outputs/copy_to_cpu-last.p4 | 113 -------- testdata/v1_samples_outputs/copy_to_cpu.p4 | 2 - ...ounter-FrontEnd_11_SimplifyControlFlowE.p4 | 210 +++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 195 ++++++++++++++ .../counter-MidEnd_25_Evaluator.p4 | 195 ++++++++++++++ testdata/v1_samples_outputs/counter-fe.p4 | 91 ------- testdata/v1_samples_outputs/counter-last.p4 | 91 ------- testdata/v1_samples_outputs/counter-midend.p4 | 92 ------- testdata/v1_samples_outputs/counter.p4 | 1 - ...unter1-FrontEnd_11_SimplifyControlFlowE.p4 | 188 +++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 172 ++++++++++++ .../counter1-MidEnd_25_Evaluator.p4 | 172 ++++++++++++ testdata/v1_samples_outputs/counter1-fe.p4 | 69 ----- testdata/v1_samples_outputs/counter1-last.p4 | 69 ----- .../v1_samples_outputs/counter1-midend.p4 | 70 ----- testdata/v1_samples_outputs/counter1.p4 | 1 - ...unter2-FrontEnd_11_SimplifyControlFlowE.p4 | 188 +++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 172 ++++++++++++ .../counter2-MidEnd_25_Evaluator.p4 | 172 ++++++++++++ testdata/v1_samples_outputs/counter2-fe.p4 | 69 ----- testdata/v1_samples_outputs/counter2-last.p4 | 69 ----- .../v1_samples_outputs/counter2-midend.p4 | 70 ----- testdata/v1_samples_outputs/counter2.p4 | 1 - ...unter3-FrontEnd_11_SimplifyControlFlowE.p4 | 188 +++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 172 ++++++++++++ .../counter3-MidEnd_25_Evaluator.p4 | 172 ++++++++++++ testdata/v1_samples_outputs/counter3-fe.p4 | 69 ----- testdata/v1_samples_outputs/counter3-last.p4 | 69 ----- .../v1_samples_outputs/counter3-midend.p4 | 70 ----- testdata/v1_samples_outputs/counter3.p4 | 1 - ...unter4-FrontEnd_11_SimplifyControlFlowE.p4 | 189 ++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 173 ++++++++++++ .../counter4-MidEnd_25_Evaluator.p4 | 173 ++++++++++++ testdata/v1_samples_outputs/counter4-fe.p4 | 70 ----- testdata/v1_samples_outputs/counter4-last.p4 | 70 ----- .../v1_samples_outputs/counter4-midend.p4 | 71 ----- testdata/v1_samples_outputs/counter4.p4 | 1 - ...unter5-FrontEnd_11_SimplifyControlFlowE.p4 | 188 +++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 172 ++++++++++++ .../counter5-MidEnd_25_Evaluator.p4 | 172 ++++++++++++ testdata/v1_samples_outputs/counter5-fe.p4 | 69 ----- testdata/v1_samples_outputs/counter5-last.p4 | 69 ----- .../v1_samples_outputs/counter5-midend.p4 | 70 ----- testdata/v1_samples_outputs/counter5.p4 | 1 - ...othing-FrontEnd_11_SimplifyControlFlowE.p4 | 187 +++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 171 ++++++++++++ .../do_nothing-MidEnd_25_Evaluator.p4 | 171 ++++++++++++ testdata/v1_samples_outputs/do_nothing-fe.p4 | 68 ----- .../v1_samples_outputs/do_nothing-last.p4 | 68 ----- .../v1_samples_outputs/do_nothing-midend.p4 | 69 ----- testdata/v1_samples_outputs/do_nothing.p4 | 1 - ...match1-FrontEnd_11_SimplifyControlFlowE.p4 | 191 ++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 175 +++++++++++++ .../exact_match1-MidEnd_25_Evaluator.p4 | 175 +++++++++++++ .../v1_samples_outputs/exact_match1-fe.p4 | 72 ----- .../v1_samples_outputs/exact_match1-last.p4 | 72 ----- .../v1_samples_outputs/exact_match1-midend.p4 | 73 ------ testdata/v1_samples_outputs/exact_match1.p4 | 1 - ...match2-FrontEnd_11_SimplifyControlFlowE.p4 | 192 ++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 176 +++++++++++++ .../exact_match2-MidEnd_25_Evaluator.p4 | 176 +++++++++++++ .../v1_samples_outputs/exact_match2-fe.p4 | 73 ------ .../v1_samples_outputs/exact_match2-last.p4 | 73 ------ .../v1_samples_outputs/exact_match2-midend.p4 | 74 ------ testdata/v1_samples_outputs/exact_match2.p4 | 1 - ...match3-FrontEnd_11_SimplifyControlFlowE.p4 | 192 ++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 176 +++++++++++++ .../exact_match3-MidEnd_25_Evaluator.p4 | 176 +++++++++++++ .../v1_samples_outputs/exact_match3-fe.p4 | 73 ------ .../v1_samples_outputs/exact_match3-last.p4 | 73 ------ .../v1_samples_outputs/exact_match3-midend.p4 | 74 ------ testdata/v1_samples_outputs/exact_match3.p4 | 1 - ...match4-FrontEnd_11_SimplifyControlFlowE.p4 | 224 ++++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 208 +++++++++++++++ .../exact_match4-MidEnd_25_Evaluator.p4 | 208 +++++++++++++++ .../v1_samples_outputs/exact_match4-fe.p4 | 105 -------- .../v1_samples_outputs/exact_match4-last.p4 | 105 -------- .../v1_samples_outputs/exact_match4-midend.p4 | 106 -------- testdata/v1_samples_outputs/exact_match4.p4 | 1 - ...match5-FrontEnd_11_SimplifyControlFlowE.p4 | 225 ++++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 209 +++++++++++++++ .../exact_match5-MidEnd_25_Evaluator.p4 | 209 +++++++++++++++ .../v1_samples_outputs/exact_match5-fe.p4 | 106 -------- .../v1_samples_outputs/exact_match5-last.p4 | 106 -------- .../v1_samples_outputs/exact_match5-midend.p4 | 107 -------- testdata/v1_samples_outputs/exact_match5.p4 | 1 - ...match6-FrontEnd_11_SimplifyControlFlowE.p4 | 199 ++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 183 +++++++++++++ .../exact_match6-MidEnd_25_Evaluator.p4 | 183 +++++++++++++ .../v1_samples_outputs/exact_match6-fe.p4 | 80 ------ .../v1_samples_outputs/exact_match6-last.p4 | 80 ------ .../v1_samples_outputs/exact_match6-midend.p4 | 81 ------ testdata/v1_samples_outputs/exact_match6.p4 | 1 - ...match7-FrontEnd_11_SimplifyControlFlowE.p4 | 198 ++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 182 +++++++++++++ .../exact_match7-MidEnd_25_Evaluator.p4 | 182 +++++++++++++ .../v1_samples_outputs/exact_match7-fe.p4 | 79 ------ .../v1_samples_outputs/exact_match7-last.p4 | 79 ------ .../v1_samples_outputs/exact_match7-midend.p4 | 80 ------ testdata/v1_samples_outputs/exact_match7.p4 | 1 - ...match8-FrontEnd_11_SimplifyControlFlowE.p4 | 235 +++++++++++++++++ ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 109 +++++++- ...p4 => exact_match8-MidEnd_25_Evaluator.p4} | 106 +++++++- .../v1_samples_outputs/exact_match8-fe.p4 | 116 --------- testdata/v1_samples_outputs/exact_match8.p4 | 1 - ...match9-FrontEnd_11_SimplifyControlFlowE.p4 | 206 +++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 190 ++++++++++++++ .../exact_match9-MidEnd_25_Evaluator.p4 | 190 ++++++++++++++ .../v1_samples_outputs/exact_match9-fe.p4 | 87 ------- .../v1_samples_outputs/exact_match9-last.p4 | 87 ------- .../v1_samples_outputs/exact_match9-midend.p4 | 88 ------- testdata/v1_samples_outputs/exact_match9.p4 | 1 - ...valid1-FrontEnd_11_SimplifyControlFlowE.p4 | 204 +++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 188 +++++++++++++ .../exact_match_valid1-MidEnd_25_Evaluator.p4 | 188 +++++++++++++ .../exact_match_valid1-fe.p4 | 85 ------ .../exact_match_valid1-last.p4 | 85 ------ .../exact_match_valid1-midend.p4 | 86 ------ .../v1_samples_outputs/exact_match_valid1.p4 | 1 - ...ching-FrontEnd_11_SimplifyControlFlowE.p4} | 124 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 110 +++++++- ... flowlet_switching-MidEnd_25_Evaluator.p4} | 108 +++++++- ...teway1-FrontEnd_11_SimplifyControlFlowE.p4 | 204 +++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 188 +++++++++++++ .../gateway1-MidEnd_25_Evaluator.p4 | 196 ++++++++++++++ testdata/v1_samples_outputs/gateway1-fe.p4 | 86 ------ testdata/v1_samples_outputs/gateway1-last.p4 | 86 ------ .../v1_samples_outputs/gateway1-midend.p4 | 94 ------- testdata/v1_samples_outputs/gateway1.p4 | 2 - ...teway2-FrontEnd_11_SimplifyControlFlowE.p4 | 206 +++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 190 ++++++++++++++ .../gateway2-MidEnd_25_Evaluator.p4 | 198 ++++++++++++++ testdata/v1_samples_outputs/gateway2-fe.p4 | 88 ------- testdata/v1_samples_outputs/gateway2-last.p4 | 88 ------- .../v1_samples_outputs/gateway2-midend.p4 | 96 ------- testdata/v1_samples_outputs/gateway2.p4 | 2 - ...teway3-FrontEnd_11_SimplifyControlFlowE.p4 | 208 +++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 192 ++++++++++++++ .../gateway3-MidEnd_25_Evaluator.p4 | 200 ++++++++++++++ testdata/v1_samples_outputs/gateway3-fe.p4 | 90 ------- testdata/v1_samples_outputs/gateway3-last.p4 | 90 ------- .../v1_samples_outputs/gateway3-midend.p4 | 98 ------- testdata/v1_samples_outputs/gateway3.p4 | 2 - ...teway4-FrontEnd_11_SimplifyControlFlowE.p4 | 220 ++++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 204 +++++++++++++++ ...end.p4 => gateway4-MidEnd_25_Evaluator.p4} | 106 +++++++- testdata/v1_samples_outputs/gateway4-fe.p4 | 102 -------- testdata/v1_samples_outputs/gateway4-last.p4 | 102 -------- testdata/v1_samples_outputs/gateway4.p4 | 2 - ...teway5-FrontEnd_11_SimplifyControlFlowE.p4 | 213 +++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 197 ++++++++++++++ .../gateway5-MidEnd_25_Evaluator.p4 | 204 +++++++++++++++ testdata/v1_samples_outputs/gateway5-fe.p4 | 95 ------- testdata/v1_samples_outputs/gateway5-last.p4 | 95 ------- .../v1_samples_outputs/gateway5-midend.p4 | 102 -------- testdata/v1_samples_outputs/gateway5.p4 | 2 - ...teway6-FrontEnd_11_SimplifyControlFlowE.p4 | 207 +++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 191 ++++++++++++++ .../gateway6-MidEnd_25_Evaluator.p4 | 198 ++++++++++++++ testdata/v1_samples_outputs/gateway6-fe.p4 | 89 ------- testdata/v1_samples_outputs/gateway6-last.p4 | 89 ------- .../v1_samples_outputs/gateway6-midend.p4 | 96 ------- testdata/v1_samples_outputs/gateway6.p4 | 2 - ...teway7-FrontEnd_11_SimplifyControlFlowE.p4 | 207 +++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 191 ++++++++++++++ .../gateway7-MidEnd_25_Evaluator.p4 | 198 ++++++++++++++ testdata/v1_samples_outputs/gateway7-fe.p4 | 89 ------- testdata/v1_samples_outputs/gateway7-last.p4 | 89 ------- .../v1_samples_outputs/gateway7-midend.p4 | 96 ------- testdata/v1_samples_outputs/gateway7.p4 | 2 - .../hit-FrontEnd_11_SimplifyControlFlowE.p4 | 213 +++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 197 ++++++++++++++ ...t-midend.p4 => hit-MidEnd_25_Evaluator.p4} | 106 +++++++- testdata/v1_samples_outputs/hit-fe.p4 | 96 ------- testdata/v1_samples_outputs/hit-last.p4 | 96 ------- testdata/v1_samples_outputs/hit.p4 | 3 - ...itmiss-FrontEnd_11_SimplifyControlFlowE.p4 | 218 ++++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 202 ++++++++++++++ ...dend.p4 => hitmiss-MidEnd_25_Evaluator.p4} | 106 +++++++- testdata/v1_samples_outputs/hitmiss-fe.p4 | 101 ------- testdata/v1_samples_outputs/hitmiss-last.p4 | 101 ------- testdata/v1_samples_outputs/hitmiss.p4 | 3 - ...inline-FrontEnd_11_SimplifyControlFlowE.p4 | 192 ++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 176 +++++++++++++ .../inline-MidEnd_25_Evaluator.p4 | 198 ++++++++++++++ testdata/v1_samples_outputs/inline-fe.p4 | 72 ----- testdata/v1_samples_outputs/inline-last.p4 | 72 ----- testdata/v1_samples_outputs/inline-midend.p4 | 96 ------- ...truct1-FrontEnd_11_SimplifyControlFlowE.p4 | 219 ++++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 203 +++++++++++++++ .../instruct1-MidEnd_25_Evaluator.p4 | 203 +++++++++++++++ testdata/v1_samples_outputs/instruct1-fe.p4 | 100 ------- testdata/v1_samples_outputs/instruct1-last.p4 | 100 ------- .../v1_samples_outputs/instruct1-midend.p4 | 101 ------- testdata/v1_samples_outputs/instruct1.p4 | 1 - ...truct2-FrontEnd_11_SimplifyControlFlowE.p4 | 202 ++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 186 +++++++++++++ .../instruct2-MidEnd_25_Evaluator.p4 | 186 +++++++++++++ testdata/v1_samples_outputs/instruct2-fe.p4 | 83 ------ testdata/v1_samples_outputs/instruct2-last.p4 | 83 ------ .../v1_samples_outputs/instruct2-midend.p4 | 84 ------ testdata/v1_samples_outputs/instruct2.p4 | 1 - ...truct3-FrontEnd_11_SimplifyControlFlowE.p4 | 192 ++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 176 +++++++++++++ .../instruct3-MidEnd_25_Evaluator.p4 | 176 +++++++++++++ testdata/v1_samples_outputs/instruct3-fe.p4 | 73 ------ testdata/v1_samples_outputs/instruct3-last.p4 | 73 ------ .../v1_samples_outputs/instruct3-midend.p4 | 74 ------ testdata/v1_samples_outputs/instruct3.p4 | 1 - ...truct4-FrontEnd_11_SimplifyControlFlowE.p4 | 193 ++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 177 +++++++++++++ .../instruct4-MidEnd_25_Evaluator.p4 | 177 +++++++++++++ testdata/v1_samples_outputs/instruct4-fe.p4 | 74 ------ testdata/v1_samples_outputs/instruct4-last.p4 | 74 ------ .../v1_samples_outputs/instruct4-midend.p4 | 75 ------ testdata/v1_samples_outputs/instruct4.p4 | 1 - ...truct5-FrontEnd_11_SimplifyControlFlowE.p4 | 215 +++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 199 ++++++++++++++ .../instruct5-MidEnd_25_Evaluator.p4 | 199 ++++++++++++++ testdata/v1_samples_outputs/instruct5-fe.p4 | 96 ------- testdata/v1_samples_outputs/instruct5-last.p4 | 96 ------- .../v1_samples_outputs/instruct5-midend.p4 | 97 ------- testdata/v1_samples_outputs/instruct5.p4 | 1 - ...write-FrontEnd_11_SimplifyControlFlowE.p4} | 126 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 110 +++++++- ....p4 => mac_rewrite-MidEnd_25_Evaluator.p4} | 106 +++++++- testdata/v1_samples_outputs/mac_rewrite.p4 | 2 - .../meter-FrontEnd_11_SimplifyControlFlowE.p4 | 225 ++++++++++++++++ ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 111 +++++++- ...midend.p4 => meter-MidEnd_25_Evaluator.p4} | 107 +++++++- testdata/v1_samples_outputs/meter-fe.p4 | 107 -------- testdata/v1_samples_outputs/meter.p4 | 2 - ...meter1-FrontEnd_11_SimplifyControlFlowE.p4 | 234 +++++++++++++++++ ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 111 +++++++- ...idend.p4 => meter1-MidEnd_25_Evaluator.p4} | 107 +++++++- testdata/v1_samples_outputs/meter1-fe.p4 | 116 --------- testdata/v1_samples_outputs/meter1.p4 | 2 - .../miss-FrontEnd_11_SimplifyControlFlowE.p4 | 215 +++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 199 ++++++++++++++ ...-midend.p4 => miss-MidEnd_25_Evaluator.p4} | 106 +++++++- testdata/v1_samples_outputs/miss-fe.p4 | 98 ------- testdata/v1_samples_outputs/miss-last.p4 | 98 ------- testdata/v1_samples_outputs/miss.p4 | 3 - ...erflow-FrontEnd_11_SimplifyControlFlowE.p4 | 182 +++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 166 ++++++++++++ .../overflow-MidEnd_25_Evaluator.p4 | 166 ++++++++++++ testdata/v1_samples_outputs/overflow-fe.p4 | 63 ----- testdata/v1_samples_outputs/overflow-last.p4 | 63 ----- .../v1_samples_outputs/overflow-midend.p4 | 64 ----- testdata/v1_samples_outputs/overflow.p4 | 1 - ...irect-FrontEnd_11_SimplifyControlFlowE.p4} | 127 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 119 ++++++++- ...=> packet_redirect-MidEnd_25_Evaluator.p4} | 114 +++++++- .../v1_samples_outputs/packet_redirect.p4 | 3 - ...rser1-FrontEnd_11_SimplifyControlFlowE.p4} | 125 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 109 +++++++- ...dend.p4 => parser1-MidEnd_25_Evaluator.p4} | 106 +++++++- testdata/v1_samples_outputs/parser1.p4 | 1 - ...rser2-FrontEnd_11_SimplifyControlFlowE.p4} | 125 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 109 +++++++- ...dend.p4 => parser2-MidEnd_25_Evaluator.p4} | 106 +++++++- testdata/v1_samples_outputs/parser2.p4 | 1 - ...arser3-FrontEnd_11_SimplifyControlFlowE.p4 | 209 +++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 193 ++++++++++++++ .../parser3-MidEnd_25_Evaluator.p4 | 193 ++++++++++++++ testdata/v1_samples_outputs/parser3-fe.p4 | 90 ------- testdata/v1_samples_outputs/parser3-last.p4 | 90 ------- testdata/v1_samples_outputs/parser3-midend.p4 | 91 ------- testdata/v1_samples_outputs/parser3.p4 | 1 - ...rser4-FrontEnd_11_SimplifyControlFlowE.p4} | 125 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 109 +++++++- ...dend.p4 => parser4-MidEnd_25_Evaluator.p4} | 106 +++++++- testdata/v1_samples_outputs/parser4.p4 | 1 - ..._full-FrontEnd_11_SimplifyControlFlowE.p4} | 125 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 109 +++++++- ... => parser_dc_full-MidEnd_25_Evaluator.p4} | 106 +++++++- testdata/v1_samples_outputs/parser_dc_full.p4 | 1 - ...pping-FrontEnd_11_SimplifyControlFlowE.p4} | 125 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 109 +++++++- ... port_vlan_mapping-MidEnd_25_Evaluator.p4} | 106 +++++++- .../v1_samples_outputs/port_vlan_mapping.p4 | 1 - ...eueing-FrontEnd_11_SimplifyControlFlowE.p4 | 230 ++++++++++++++++ ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 111 +++++++- ...end.p4 => queueing-MidEnd_25_Evaluator.p4} | 107 +++++++- testdata/v1_samples_outputs/queueing-last.p4 | 112 -------- testdata/v1_samples_outputs/queueing.p4 | 2 - ...gister-FrontEnd_11_SimplifyControlFlowE.p4 | 208 +++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 192 ++++++++++++++ .../register-MidEnd_25_Evaluator.p4 | 192 ++++++++++++++ testdata/v1_samples_outputs/register-fe.p4 | 89 ------- testdata/v1_samples_outputs/register-last.p4 | 89 ------- .../v1_samples_outputs/register-midend.p4 | 90 ------- testdata/v1_samples_outputs/register.p4 | 1 - ...submit-FrontEnd_11_SimplifyControlFlowE.p4 | 225 ++++++++++++++++ ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 111 +++++++- ...end.p4 => resubmit-MidEnd_25_Evaluator.p4} | 107 +++++++- testdata/v1_samples_outputs/resubmit-last.p4 | 107 -------- testdata/v1_samples_outputs/resubmit.p4 | 2 - ...ai_p4-FrontEnd_11_SimplifyControlFlowE.p4} | 133 +++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 118 ++++++++- ...idend.p4 => sai_p4-MidEnd_25_Evaluator.p4} | 107 +++++++- testdata/v1_samples_outputs/sai_p4.p4 | 9 - ...ector0-FrontEnd_11_SimplifyControlFlowE.p4 | 195 ++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 179 +++++++++++++ .../selector0-MidEnd_25_Evaluator.p4 | 179 +++++++++++++ testdata/v1_samples_outputs/selector0-fe.p4 | 76 ------ testdata/v1_samples_outputs/selector0-last.p4 | 76 ------ .../v1_samples_outputs/selector0-midend.p4 | 77 ------ testdata/v1_samples_outputs/selector0.p4 | 1 - ...ector1-FrontEnd_11_SimplifyControlFlowE.p4 | 199 ++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 183 +++++++++++++ .../selector1-MidEnd_25_Evaluator.p4 | 183 +++++++++++++ testdata/v1_samples_outputs/selector1-fe.p4 | 80 ------ testdata/v1_samples_outputs/selector1-last.p4 | 80 ------ .../v1_samples_outputs/selector1-midend.p4 | 81 ------ testdata/v1_samples_outputs/selector1.p4 | 1 - ...ector2-FrontEnd_11_SimplifyControlFlowE.p4 | 199 ++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 183 +++++++++++++ .../selector2-MidEnd_25_Evaluator.p4 | 183 +++++++++++++ testdata/v1_samples_outputs/selector2-fe.p4 | 80 ------ testdata/v1_samples_outputs/selector2-last.p4 | 80 ------ .../v1_samples_outputs/selector2-midend.p4 | 81 ------ testdata/v1_samples_outputs/selector2.p4 | 1 - ...ector3-FrontEnd_11_SimplifyControlFlowE.p4 | 206 +++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 190 ++++++++++++++ .../selector3-MidEnd_25_Evaluator.p4 | 190 ++++++++++++++ testdata/v1_samples_outputs/selector3-fe.p4 | 87 ------- testdata/v1_samples_outputs/selector3-last.p4 | 87 ------- .../v1_samples_outputs/selector3-midend.p4 | 88 ------- testdata/v1_samples_outputs/selector3.p4 | 1 - ...e_nat-FrontEnd_11_SimplifyControlFlowE.p4} | 130 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 121 ++++++++- ...d.p4 => simple_nat-MidEnd_25_Evaluator.p4} | 113 +++++++- testdata/v1_samples_outputs/simple_nat.p4 | 6 - ...outer-FrontEnd_11_SimplifyControlFlowE.p4} | 127 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 112 +++++++- ...4 => simple_router-MidEnd_25_Evaluator.p4} | 107 +++++++- testdata/v1_samples_outputs/simple_router.p4 | 3 - ...outing-FrontEnd_11_SimplifyControlFlowE.p4 | 211 +++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 196 ++++++++++++++ ... => source_routing-MidEnd_25_Evaluator.p4} | 107 +++++++- .../v1_samples_outputs/source_routing-fe.p4 | 92 ------- .../v1_samples_outputs/source_routing-last.p4 | 92 ------- testdata/v1_samples_outputs/source_routing.p4 | 1 - ...swap_1-FrontEnd_11_SimplifyControlFlowE.p4 | 189 ++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 173 ++++++++++++ .../swap_1-MidEnd_25_Evaluator.p4 | 173 ++++++++++++ testdata/v1_samples_outputs/swap_1-fe.p4 | 70 ----- testdata/v1_samples_outputs/swap_1-last.p4 | 70 ----- testdata/v1_samples_outputs/swap_1-midend.p4 | 71 ----- testdata/v1_samples_outputs/swap_1.p4 | 1 - ...swap_2-FrontEnd_11_SimplifyControlFlowE.p4 | 190 ++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 174 +++++++++++++ .../swap_2-MidEnd_25_Evaluator.p4 | 174 +++++++++++++ testdata/v1_samples_outputs/swap_2-fe.p4 | 71 ----- testdata/v1_samples_outputs/swap_2-last.p4 | 71 ----- testdata/v1_samples_outputs/swap_2-midend.p4 | 72 ----- testdata/v1_samples_outputs/swap_2.p4 | 1 - ...witch-FrontEnd_11_SimplifyControlFlowE.p4} | 124 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 117 ++++++++- ...idend.p4 => switch-MidEnd_25_Evaluator.p4} | 115 +++++++- testdata/v1_samples_outputs/switch.p4 | 4 +- ...match0-FrontEnd_11_SimplifyControlFlowE.p4 | 189 ++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 173 ++++++++++++ .../ternary_match0-MidEnd_25_Evaluator.p4 | 173 ++++++++++++ .../v1_samples_outputs/ternary_match0-fe.p4 | 70 ----- .../v1_samples_outputs/ternary_match0-last.p4 | 70 ----- .../ternary_match0-midend.p4 | 71 ----- testdata/v1_samples_outputs/ternary_match0.p4 | 1 - ...match1-FrontEnd_11_SimplifyControlFlowE.p4 | 193 ++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 177 +++++++++++++ .../ternary_match1-MidEnd_25_Evaluator.p4 | 177 +++++++++++++ .../v1_samples_outputs/ternary_match1-fe.p4 | 74 ------ .../v1_samples_outputs/ternary_match1-last.p4 | 74 ------ .../ternary_match1-midend.p4 | 75 ------ testdata/v1_samples_outputs/ternary_match1.p4 | 1 - ...match2-FrontEnd_11_SimplifyControlFlowE.p4 | 193 ++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 177 +++++++++++++ .../ternary_match2-MidEnd_25_Evaluator.p4 | 177 +++++++++++++ .../v1_samples_outputs/ternary_match2-fe.p4 | 74 ------ .../v1_samples_outputs/ternary_match2-last.p4 | 74 ------ .../ternary_match2-midend.p4 | 75 ------ testdata/v1_samples_outputs/ternary_match2.p4 | 1 - ...match3-FrontEnd_11_SimplifyControlFlowE.p4 | 195 ++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 179 +++++++++++++ .../ternary_match3-MidEnd_25_Evaluator.p4 | 179 +++++++++++++ .../v1_samples_outputs/ternary_match3-fe.p4 | 76 ------ .../v1_samples_outputs/ternary_match3-last.p4 | 76 ------ .../ternary_match3-midend.p4 | 77 ------ testdata/v1_samples_outputs/ternary_match3.p4 | 1 - ...match4-FrontEnd_11_SimplifyControlFlowE.p4 | 196 ++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 180 +++++++++++++ .../ternary_match4-MidEnd_25_Evaluator.p4 | 180 +++++++++++++ .../v1_samples_outputs/ternary_match4-fe.p4 | 77 ------ .../v1_samples_outputs/ternary_match4-last.p4 | 77 ------ .../ternary_match4-midend.p4 | 78 ------ testdata/v1_samples_outputs/ternary_match4.p4 | 1 - ...ntrol-FrontEnd_11_SimplifyControlFlowE.p4} | 125 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 109 +++++++- ...st_7_storm_control-MidEnd_25_Evaluator.p4} | 106 +++++++- .../test_7_storm_control.p4 | 1 - ...no_key-FrontEnd_11_SimplifyControlFlowE.p4 | 217 +++++++++++++++ ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 111 +++++++- ..._table_with_no_key-MidEnd_25_Evaluator.p4} | 106 +++++++- ...config_175_match_table_with_no_key-last.p4 | 100 ------- ...test_config_175_match_table_with_no_key.p4 | 3 - ...testgw-FrontEnd_11_SimplifyControlFlowE.p4 | 239 +++++++++++++++++ ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 111 +++++++- ...idend.p4 => testgw-MidEnd_25_Evaluator.p4} | 106 +++++++- testdata/v1_samples_outputs/testgw-last.p4 | 122 --------- testdata/v1_samples_outputs/testgw.p4 | 3 - .../tp2a-FrontEnd_11_SimplifyControlFlowE.p4 | 240 +++++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 224 ++++++++++++++++ ...-midend.p4 => tp2a-MidEnd_25_Evaluator.p4} | 106 +++++++- testdata/v1_samples_outputs/tp2a-fe.p4 | 124 --------- testdata/v1_samples_outputs/tp2a-last.p4 | 124 --------- testdata/v1_samples_outputs/tp2a.p4 | 4 - ... tp2b-FrontEnd_11_SimplifyControlFlowE.p4} | 131 +++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 115 +++++++- ...-midend.p4 => tp2b-MidEnd_25_Evaluator.p4} | 106 +++++++- testdata/v1_samples_outputs/tp2b.p4 | 7 - ... tp2c-FrontEnd_11_SimplifyControlFlowE.p4} | 130 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 114 +++++++- ...-midend.p4 => tp2c-MidEnd_25_Evaluator.p4} | 106 +++++++- testdata/v1_samples_outputs/tp2c.p4 | 6 - ... tp3a-FrontEnd_11_SimplifyControlFlowE.p4} | 133 +++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 117 ++++++++- ...-midend.p4 => tp3a-MidEnd_25_Evaluator.p4} | 106 +++++++- testdata/v1_samples_outputs/tp3a.p4 | 9 - ...iv_eth-FrontEnd_11_SimplifyControlFlowE.p4 | 189 ++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 173 ++++++++++++ .../triv_eth-MidEnd_25_Evaluator.p4 | 173 ++++++++++++ testdata/v1_samples_outputs/triv_eth-fe.p4 | 70 ----- testdata/v1_samples_outputs/triv_eth-last.p4 | 70 ----- .../v1_samples_outputs/triv_eth-midend.p4 | 71 ----- testdata/v1_samples_outputs/triv_eth.p4 | 1 - ...v_ipv4-FrontEnd_11_SimplifyControlFlowE.p4 | 217 +++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 201 ++++++++++++++ .../triv_ipv4-MidEnd_25_Evaluator.p4 | 201 ++++++++++++++ testdata/v1_samples_outputs/triv_ipv4-fe.p4 | 98 ------- testdata/v1_samples_outputs/triv_ipv4-last.p4 | 98 ------- .../v1_samples_outputs/triv_ipv4-midend.p4 | 99 ------- testdata/v1_samples_outputs/triv_ipv4.p4 | 1 - ...ernet-FrontEnd_11_SimplifyControlFlowE.p4} | 125 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 109 +++++++- ...ate_outer_ethernet-MidEnd_25_Evaluator.p4} | 106 +++++++- .../validate_outer_ethernet.p4 | 1 - ...ction1-FrontEnd_11_SimplifyControlFlowE.p4 | 216 +++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 200 ++++++++++++++ .../wide_action1-MidEnd_25_Evaluator.p4 | 200 ++++++++++++++ .../v1_samples_outputs/wide_action1-fe.p4 | 97 ------- .../v1_samples_outputs/wide_action1-last.p4 | 97 ------- .../v1_samples_outputs/wide_action1-midend.p4 | 98 ------- testdata/v1_samples_outputs/wide_action1.p4 | 1 - ...tion2-FrontEnd_11_SimplifyControlFlowE.p4} | 125 ++++++++- ...rontEnd_12_RemoveAllUnusedDeclarations.p4} | 109 +++++++- ...p4 => wide_action2-MidEnd_25_Evaluator.p4} | 106 +++++++- testdata/v1_samples_outputs/wide_action2.p4 | 1 - ...ction3-FrontEnd_11_SimplifyControlFlowE.p4 | 217 +++++++++++++++ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 201 ++++++++++++++ .../wide_action3-MidEnd_25_Evaluator.p4 | 201 ++++++++++++++ .../v1_samples_outputs/wide_action3-fe.p4 | 98 ------- .../v1_samples_outputs/wide_action3-last.p4 | 98 ------- .../v1_samples_outputs/wide_action3-midend.p4 | 99 ------- testdata/v1_samples_outputs/wide_action3.p4 | 1 - 1072 files changed, 66342 insertions(+), 21505 deletions(-) delete mode 100644 backends/v12test/options.cpp delete mode 100644 backends/v12test/options.h create mode 100644 testdata/v1_2_errors_outputs/persistent_e-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_2_errors_outputs/persistent_e-FrontEnd_12_RemoveAllUnusedDeclarations.p4 rename testdata/v1_2_samples_outputs/{action-uses-fe.p4 => action-uses-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{action-uses-last.p4 => action-uses-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{action-uses-midend.p4 => action-uses-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{actionAnnotations-fe.p4 => actionAnnotations-FrontEnd_11_SimplifyControlFlowE.p4} (99%) rename testdata/v1_2_samples_outputs/{actionAnnotations-last.p4 => actionAnnotations-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{after-return-fe.p4 => after-return-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{after-return-last.p4 => after-return-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{after-return-midend.p4 => after-return-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{annotations-fe.p4 => annotations-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{annotations-last.p4 => annotations-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{apply-fe.p4 => apply-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{apply-last.p4 => apply-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{apply-midend.p4 => apply-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{apply-cf-fe.p4 => apply-cf-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{apply-cf-last.p4 => apply-cf-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) create mode 100644 testdata/v1_2_samples_outputs/arith-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_2_samples_outputs/arith-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_2_samples_outputs/arith-bmv2-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_2_samples_outputs/arith-bmv2-fe.p4 delete mode 100644 testdata/v1_2_samples_outputs/arith-bmv2-last.p4 delete mode 100644 testdata/v1_2_samples_outputs/arith-bmv2-midend.p4 create mode 100644 testdata/v1_2_samples_outputs/arith-inline-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_2_samples_outputs/arith-inline-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_2_samples_outputs/arith-inline-bmv2-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_2_samples_outputs/arith-inline-bmv2-fe.p4 delete mode 100644 testdata/v1_2_samples_outputs/arith-inline-bmv2-last.p4 delete mode 100644 testdata/v1_2_samples_outputs/arith-inline-bmv2-midend.p4 rename testdata/v1_2_samples_outputs/{arith-inline-skeleton-fe.p4 => arith-inline-skeleton-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{arith-inline-skeleton-last.p4 => arith-inline-skeleton-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{arith-skeleton-fe.p4 => arith-skeleton-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{arith-skeleton-last.p4 => arith-skeleton-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) create mode 100644 testdata/v1_2_samples_outputs/arith1-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_2_samples_outputs/arith1-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_2_samples_outputs/arith1-bmv2-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_2_samples_outputs/arith1-bmv2-fe.p4 delete mode 100644 testdata/v1_2_samples_outputs/arith1-bmv2-last.p4 delete mode 100644 testdata/v1_2_samples_outputs/arith1-bmv2-midend.p4 create mode 100644 testdata/v1_2_samples_outputs/arith2-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_2_samples_outputs/arith2-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_2_samples_outputs/arith2-bmv2-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_2_samples_outputs/arith2-bmv2-fe.p4 delete mode 100644 testdata/v1_2_samples_outputs/arith2-bmv2-last.p4 delete mode 100644 testdata/v1_2_samples_outputs/arith2-bmv2-midend.p4 create mode 100644 testdata/v1_2_samples_outputs/arith2-inline-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_2_samples_outputs/arith2-inline-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_2_samples_outputs/arith2-inline-bmv2-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_2_samples_outputs/arith2-inline-bmv2-fe.p4 delete mode 100644 testdata/v1_2_samples_outputs/arith2-inline-bmv2-last.p4 delete mode 100644 testdata/v1_2_samples_outputs/arith2-inline-bmv2-midend.p4 create mode 100644 testdata/v1_2_samples_outputs/arith3-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_2_samples_outputs/arith3-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_2_samples_outputs/arith3-bmv2-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_2_samples_outputs/arith3-bmv2-fe.p4 delete mode 100644 testdata/v1_2_samples_outputs/arith3-bmv2-last.p4 delete mode 100644 testdata/v1_2_samples_outputs/arith3-bmv2-midend.p4 create mode 100644 testdata/v1_2_samples_outputs/arith4-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_2_samples_outputs/arith4-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_2_samples_outputs/arith4-bmv2-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_2_samples_outputs/arith4-bmv2-fe.p4 delete mode 100644 testdata/v1_2_samples_outputs/arith4-bmv2-last.p4 delete mode 100644 testdata/v1_2_samples_outputs/arith4-bmv2-midend.p4 create mode 100644 testdata/v1_2_samples_outputs/arith5-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_2_samples_outputs/arith5-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_2_samples_outputs/arith5-bmv2-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_2_samples_outputs/arith5-bmv2-fe.p4 delete mode 100644 testdata/v1_2_samples_outputs/arith5-bmv2-last.p4 delete mode 100644 testdata/v1_2_samples_outputs/arith5-bmv2-midend.p4 rename testdata/v1_2_samples_outputs/{bitExtract-fe.p4 => bitExtract-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{bitExtract-last.p4 => bitExtract-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{bool_cast-fe.p4 => bool_cast-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{bool_cast-last.p4 => bool_cast-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{call-fe.p4 => call-FrontEnd_11_SimplifyControlFlowE.p4} (99%) rename testdata/v1_2_samples_outputs/{call-last.p4 => call-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{cases-fe.p4 => cases-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{cases-last.p4 => cases-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{cast-fe.p4 => cast-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{cast-last.p4 => cast-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{const-fe.p4 => const-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{const-last.p4 => const-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{constant_folding-fe.p4 => constant_folding-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{constant_folding-last.p4 => constant_folding-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{constants-fe.p4 => constants-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{constants-last.p4 => constants-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{constructor_cast-fe.p4 => constructor_cast-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{constructor_cast-last.p4 => constructor_cast-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{constsigned-fe.p4 => constsigned-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{constsigned-last.p4 => constsigned-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{count_ebpf-last.p4 => count_ebpf-FrontEnd_11_SimplifyControlFlowE.p4} (55%) rename testdata/v1_2_samples_outputs/{count_ebpf-fe.p4 => count_ebpf-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (59%) rename testdata/v1_2_samples_outputs/{count_ebpf-midend.p4 => count_ebpf-MidEnd_25_Evaluator.p4} (65%) rename testdata/v1_2_samples_outputs/{decl-fe.p4 => decl-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{decl-last.p4 => decl-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{decl2-fe.p4 => decl2-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{decl2-last.p4 => decl2-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{decl2-midend.p4 => decl2-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{direct-action-fe.p4 => direct-action-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{direct-action-last.p4 => direct-action-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{direct-action-midend.p4 => direct-action-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{ebpf_headers-fe.p4 => ebpf_headers-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{ebpf_headers-last.p4 => ebpf_headers-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{empty-fe.p4 => empty-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{empty-last.p4 => empty-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{enum-fe.p4 => enum-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{enum-last.p4 => enum-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{ex1-fe.p4 => ex1-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{ex1-last.p4 => ex1-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{expression-fe.p4 => expression-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{expression-last.p4 => expression-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{extern-fe.p4 => extern-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{extern-last.p4 => extern-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{filter-fe.p4 => filter-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{filter-last.p4 => filter-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{fold_match-fe.p4 => fold_match-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{fold_match-last.p4 => fold_match-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{functors-fe.p4 => functors-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{functors-last.p4 => functors-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{functors-midend.p4 => functors-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{functors1-fe.p4 => functors1-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{functors1-last.p4 => functors1-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{functors1-midend.p4 => functors1-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{functors2-fe.p4 => functors2-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{functors2-last.p4 => functors2-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{functors2-midend.p4 => functors2-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{functors3-fe.p4 => functors3-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{functors3-last.p4 => functors3-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{functors3-midend.p4 => functors3-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{functors4-fe.p4 => functors4-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{functors4-last.p4 => functors4-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{functors4-midend.p4 => functors4-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{functors5-fe.p4 => functors5-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{functors5-last.p4 => functors5-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{functors5-midend.p4 => functors5-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{functors6-fe.p4 => functors6-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{functors6-last.p4 => functors6-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{functors6-midend.p4 => functors6-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{functors7-fe.p4 => functors7-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{functors7-last.p4 => functors7-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{functors7-midend.p4 => functors7-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{functors8-fe.p4 => functors8-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{functors8-last.p4 => functors8-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{functors8-midend.p4 => functors8-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{functors9-fe.p4 => functors9-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{functors9-last.p4 => functors9-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{functors9-midend.p4 => functors9-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{generic-fe.p4 => generic-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{generic-last.p4 => generic-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{global-action-fe.p4 => global-action-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{global-action-last.p4 => global-action-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{global-action-midend.p4 => global-action-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{global-action1-fe.p4 => global-action1-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{global-action1-last.p4 => global-action1-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{global-action1-midend.p4 => global-action1-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{header-fe.p4 => header-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{header-last.p4 => header-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{highorder-fe.p4 => highorder-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{highorder-last.p4 => highorder-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{highorder-midend.p4 => highorder-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{implicit-fe.p4 => implicit-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{implicit-last.p4 => implicit-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{initializer-fe.p4 => initializer-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{initializer-last.p4 => initializer-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{inline-fe.p4 => inline-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{inline-last.p4 => inline-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{inline-midend.p4 => inline-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{inline-action-fe.p4 => inline-action-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{inline-action-last.p4 => inline-action-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{inline-action-midend.p4 => inline-action-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{inline-control-fe.p4 => inline-control-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{inline-control-last.p4 => inline-control-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{inline-control-midend.p4 => inline-control-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{inline-switch-fe.p4 => inline-switch-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{inline-switch-last.p4 => inline-switch-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{inline-switch-midend.p4 => inline-switch-MidEnd_25_Evaluator.p4} (89%) rename testdata/v1_2_samples_outputs/{interface-fe.p4 => interface-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{interface-last.p4 => interface-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{interface-midend.p4 => interface-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{interface1-fe.p4 => interface1-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{interface1-last.p4 => interface1-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{interface1-midend.p4 => interface1-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{interface2-fe.p4 => interface2-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{interface2-last.p4 => interface2-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{large-fe.p4 => large-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{large-last.p4 => large-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{line-fe.p4 => line-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{line-last.p4 => line-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) create mode 100644 testdata/v1_2_samples_outputs/lj_example-FrontEnd_11_SimplifyControlFlowE.p4 rename testdata/v1_2_samples_outputs/{lj_example-fe.p4 => lj_example-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (51%) rename testdata/v1_2_samples_outputs/{lj_example-midend.p4 => lj_example-MidEnd_25_Evaluator.p4} (53%) delete mode 100644 testdata/v1_2_samples_outputs/lj_example-last.p4 rename testdata/v1_2_samples_outputs/{match-fe.p4 => match-FrontEnd_11_SimplifyControlFlowE.p4} (69%) rename testdata/v1_2_samples_outputs/{match-last.p4 => match-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (52%) rename testdata/v1_2_samples_outputs/{module-fe.p4 => module-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{module-last.p4 => module-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{names-fe.p4 => names-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{names-last.p4 => names-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{parse-fe.p4 => parse-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{parse-last.p4 => parse-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{parser-locals-fe.p4 => parser-locals-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{parser-locals-last.p4 => parser-locals-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{parser-locals-midend.p4 => parser-locals-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{pipe-fe.p4 => pipe-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{pipe-last.p4 => pipe-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{pipe-midend.p4 => pipe-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{pipeline-fe.p4 => pipeline-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{pipeline-last.p4 => pipeline-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{precedence-fe.p4 => precedence-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{precedence-last.p4 => precedence-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{select-type-fe.p4 => select-type-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{select-type-last.p4 => select-type-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{shadow-fe.p4 => shadow-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{shadow-last.p4 => shadow-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{simple-switch-example-last.p4 => simple-switch-example-FrontEnd_11_SimplifyControlFlowE.p4} (72%) rename testdata/v1_2_samples_outputs/{simple-switch-example-fe.p4 => simple-switch-example-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (76%) rename testdata/v1_2_samples_outputs/{simple-switch-example-midend.p4 => simple-switch-example-MidEnd_25_Evaluator.p4} (84%) rename testdata/v1_2_samples_outputs/{simple_model-fe.p4 => simple_model-FrontEnd_11_SimplifyControlFlowE.p4} (56%) create mode 100644 testdata/v1_2_samples_outputs/simple_model-FrontEnd_12_RemoveAllUnusedDeclarations.p4 delete mode 100644 testdata/v1_2_samples_outputs/simple_model-last.p4 rename testdata/v1_2_samples_outputs/{spec-ex01-fe.p4 => spec-ex01-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{spec-ex01-last.p4 => spec-ex01-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{spec-ex03-fe.p4 => spec-ex03-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{spec-ex03-last.p4 => spec-ex03-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{spec-ex04-fe.p4 => spec-ex04-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{spec-ex04-last.p4 => spec-ex04-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{spec-ex06-fe.p4 => spec-ex06-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{spec-ex06-last.p4 => spec-ex06-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{spec-ex08-fe.p4 => spec-ex08-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{spec-ex08-last.p4 => spec-ex08-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{spec-ex09-fe.p4 => spec-ex09-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{spec-ex09-last.p4 => spec-ex09-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{spec-ex10-fe.p4 => spec-ex10-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{spec-ex10-last.p4 => spec-ex10-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{spec-ex12-fe.p4 => spec-ex12-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{spec-ex12-last.p4 => spec-ex12-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{spec-ex13-fe.p4 => spec-ex13-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{spec-ex13-last.p4 => spec-ex13-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{spec-ex14-fe.p4 => spec-ex14-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{spec-ex14-last.p4 => spec-ex14-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{spec-ex15-fe.p4 => spec-ex15-FrontEnd_11_SimplifyControlFlowE.p4} (52%) create mode 100644 testdata/v1_2_samples_outputs/spec-ex15-FrontEnd_12_RemoveAllUnusedDeclarations.p4 delete mode 100644 testdata/v1_2_samples_outputs/spec-ex15-last.p4 create mode 100644 testdata/v1_2_samples_outputs/spec-ex16-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_2_samples_outputs/spec-ex16-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_2_samples_outputs/spec-ex16-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_2_samples_outputs/spec-ex16-fe.p4 delete mode 100644 testdata/v1_2_samples_outputs/spec-ex16-last.p4 delete mode 100644 testdata/v1_2_samples_outputs/spec-ex16-midend.p4 create mode 100644 testdata/v1_2_samples_outputs/spec-ex17-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_2_samples_outputs/spec-ex17-FrontEnd_12_RemoveAllUnusedDeclarations.p4 delete mode 100644 testdata/v1_2_samples_outputs/spec-ex17-fe.p4 delete mode 100644 testdata/v1_2_samples_outputs/spec-ex17-last.p4 rename testdata/v1_2_samples_outputs/{spec-ex18-fe.p4 => spec-ex18-FrontEnd_11_SimplifyControlFlowE.p4} (69%) rename testdata/v1_2_samples_outputs/{spec-ex18-last.p4 => spec-ex18-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (52%) rename testdata/v1_2_samples_outputs/{spec-ex19-fe.p4 => spec-ex19-FrontEnd_11_SimplifyControlFlowE.p4} (73%) rename testdata/v1_2_samples_outputs/{spec-ex19-last.p4 => spec-ex19-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (57%) rename testdata/v1_2_samples_outputs/{spec-ex20-fe.p4 => spec-ex20-FrontEnd_11_SimplifyControlFlowE.p4} (53%) create mode 100644 testdata/v1_2_samples_outputs/spec-ex20-FrontEnd_12_RemoveAllUnusedDeclarations.p4 delete mode 100644 testdata/v1_2_samples_outputs/spec-ex20-last.p4 rename testdata/v1_2_samples_outputs/{spec-ex22-fe.p4 => spec-ex22-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{spec-ex22-last.p4 => spec-ex22-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{spec-ex25-fe.p4 => spec-ex25-FrontEnd_11_SimplifyControlFlowE.p4} (99%) rename testdata/v1_2_samples_outputs/{spec-ex25-last.p4 => spec-ex25-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) create mode 100644 testdata/v1_2_samples_outputs/spec-ex26-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_2_samples_outputs/spec-ex26-FrontEnd_12_RemoveAllUnusedDeclarations.p4 delete mode 100644 testdata/v1_2_samples_outputs/spec-ex26-fe.p4 delete mode 100644 testdata/v1_2_samples_outputs/spec-ex26-last.p4 create mode 100644 testdata/v1_2_samples_outputs/spec-ex27-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_2_samples_outputs/spec-ex27-FrontEnd_12_RemoveAllUnusedDeclarations.p4 delete mode 100644 testdata/v1_2_samples_outputs/spec-ex27-fe.p4 delete mode 100644 testdata/v1_2_samples_outputs/spec-ex27-last.p4 rename testdata/v1_2_samples_outputs/{spec-ex29-fe.p4 => spec-ex29-FrontEnd_11_SimplifyControlFlowE.p4} (70%) rename testdata/v1_2_samples_outputs/{spec-ex29-last.p4 => spec-ex29-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (56%) rename testdata/v1_2_samples_outputs/{spec-ex30-fe.p4 => spec-ex30-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{spec-ex30-last.p4 => spec-ex30-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{spec-ex31-fe.p4 => spec-ex31-FrontEnd_11_SimplifyControlFlowE.p4} (58%) create mode 100644 testdata/v1_2_samples_outputs/spec-ex31-FrontEnd_12_RemoveAllUnusedDeclarations.p4 delete mode 100644 testdata/v1_2_samples_outputs/spec-ex31-last.p4 rename testdata/v1_2_samples_outputs/{spec-ex32-fe.p4 => spec-ex32-FrontEnd_11_SimplifyControlFlowE.p4} (60%) rename testdata/v1_2_samples_outputs/{spec-ex32-last.p4 => spec-ex32-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (50%) rename testdata/v1_2_samples_outputs/{spec-ex34-fe.p4 => spec-ex34-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{spec-ex34-last.p4 => spec-ex34-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{specialization-fe.p4 => specialization-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{specialization-last.p4 => specialization-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{stack-fe.p4 => stack-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{stack-last.p4 => stack-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{standard_headers-fe.p4 => standard_headers-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{standard_headers-last.p4 => standard_headers-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{states-fe.p4 => states-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{states-last.p4 => states-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{states-midend.p4 => states-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{strength-fe.p4 => strength-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{strength-last.p4 => strength-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{string_anno-fe.p4 => string_anno-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{string_anno-last.p4 => string_anno-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{struct-fe.p4 => struct-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{struct-last.p4 => struct-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{switch_ebpf-fe.p4 => switch_ebpf-FrontEnd_11_SimplifyControlFlowE.p4} (60%) rename testdata/v1_2_samples_outputs/{switch_ebpf-last.p4 => switch_ebpf-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (64%) rename testdata/v1_2_samples_outputs/{switch_ebpf-midend.p4 => switch_ebpf-MidEnd_25_Evaluator.p4} (70%) rename testdata/v1_2_samples_outputs/{synth-action-fe.p4 => synth-action-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{synth-action-last.p4 => synth-action-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{synth-action-midend.p4 => synth-action-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{template-fe.p4 => template-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{template-last.p4 => template-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{test_ebpf-fe.p4 => test_ebpf-FrontEnd_11_SimplifyControlFlowE.p4} (60%) rename testdata/v1_2_samples_outputs/{test_ebpf-last.p4 => test_ebpf-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (63%) rename testdata/v1_2_samples_outputs/{test_ebpf-midend.p4 => test_ebpf-MidEnd_25_Evaluator.p4} (70%) rename testdata/v1_2_samples_outputs/{twoPipe-fe.p4 => twoPipe-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{twoPipe-last.p4 => twoPipe-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{two_ebpf-last.p4 => two_ebpf-FrontEnd_11_SimplifyControlFlowE.p4} (60%) rename testdata/v1_2_samples_outputs/{two_ebpf-fe.p4 => two_ebpf-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (63%) rename testdata/v1_2_samples_outputs/{two_ebpf-midend.p4 => two_ebpf-MidEnd_25_Evaluator.p4} (70%) rename testdata/v1_2_samples_outputs/{type-params-fe.p4 => type-params-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{type-params-last.p4 => type-params-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{valid-fe.p4 => valid-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{valid-last.p4 => valid-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{version-fe.p4 => version-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{version-last.p4 => version-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{virtual-fe.p4 => virtual-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{virtual-last.p4 => virtual-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{virtual-midend.p4 => virtual-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_2_samples_outputs/{virtual2-fe.p4 => virtual2-FrontEnd_11_SimplifyControlFlowE.p4} (100%) rename testdata/v1_2_samples_outputs/{virtual2-last.p4 => virtual2-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (100%) rename testdata/v1_2_samples_outputs/{virtual2-midend.p4 => virtual2-MidEnd_25_Evaluator.p4} (100%) rename testdata/v1_samples_outputs/{01-BigMatch-fe.p4 => 01-BigMatch-FrontEnd_11_SimplifyControlFlowE.p4} (51%) rename testdata/v1_samples_outputs/{01-BigMatch-last.p4 => 01-BigMatch-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (57%) rename testdata/v1_samples_outputs/{01-BigMatch-midend.p4 => 01-BigMatch-MidEnd_25_Evaluator.p4} (60%) create mode 100644 testdata/v1_samples_outputs/01-DeadMetadata1-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/01-DeadMetadata1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/01-DeadMetadata1-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/01-DeadMetadata1-fe.p4 delete mode 100644 testdata/v1_samples_outputs/01-DeadMetadata1-last.p4 delete mode 100644 testdata/v1_samples_outputs/01-DeadMetadata1-midend.p4 rename testdata/v1_samples_outputs/{01-FullPHV-last.p4 => 01-FullPHV-FrontEnd_11_SimplifyControlFlowE.p4} (83%) rename testdata/v1_samples_outputs/{01-FullPHV-fe.p4 => 01-FullPHV-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (86%) rename testdata/v1_samples_outputs/{01-FullPHV-midend.p4 => 01-FullPHV-MidEnd_25_Evaluator.p4} (86%) create mode 100644 testdata/v1_samples_outputs/01-JustEthernet-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/01-JustEthernet-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/01-JustEthernet-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/01-JustEthernet-fe.p4 delete mode 100644 testdata/v1_samples_outputs/01-JustEthernet-last.p4 delete mode 100644 testdata/v1_samples_outputs/01-JustEthernet-midend.p4 create mode 100644 testdata/v1_samples_outputs/01-NoDeps-FrontEnd_11_SimplifyControlFlowE.p4 rename testdata/v1_samples_outputs/{01-NoDeps-last.p4 => 01-NoDeps-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (50%) rename testdata/v1_samples_outputs/{01-NoDeps-midend.p4 => 01-NoDeps-MidEnd_25_Evaluator.p4} (52%) delete mode 100644 testdata/v1_samples_outputs/01-NoDeps-fe.p4 create mode 100644 testdata/v1_samples_outputs/02-BadSizeField-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/02-BadSizeField-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/02-BadSizeField-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/02-BadSizeField-fe.p4 delete mode 100644 testdata/v1_samples_outputs/02-BadSizeField-last.p4 delete mode 100644 testdata/v1_samples_outputs/02-BadSizeField-midend.p4 create mode 100644 testdata/v1_samples_outputs/02-DeadMetadata2-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/02-DeadMetadata2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/02-DeadMetadata2-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/02-DeadMetadata2-fe.p4 delete mode 100644 testdata/v1_samples_outputs/02-DeadMetadata2-last.p4 delete mode 100644 testdata/v1_samples_outputs/02-DeadMetadata2-midend.p4 rename testdata/v1_samples_outputs/{02-FullPHV1-fe.p4 => 02-FullPHV1-FrontEnd_11_SimplifyControlFlowE.p4} (88%) rename testdata/v1_samples_outputs/{02-FullPHV1-last.p4 => 02-FullPHV1-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (90%) rename testdata/v1_samples_outputs/{02-FullPHV1-midend.p4 => 02-FullPHV1-MidEnd_25_Evaluator.p4} (91%) create mode 100644 testdata/v1_samples_outputs/02-SplitEthernet-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/02-SplitEthernet-FrontEnd_12_RemoveAllUnusedDeclarations.p4 rename testdata/v1_samples_outputs/{02-SplitEthernet-midend.p4 => 02-SplitEthernet-MidEnd_25_Evaluator.p4} (50%) delete mode 100644 testdata/v1_samples_outputs/02-SplitEthernet-fe.p4 delete mode 100644 testdata/v1_samples_outputs/02-SplitEthernet-last.p4 create mode 100644 testdata/v1_samples_outputs/03-DeadMetadata3-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/03-DeadMetadata3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/03-DeadMetadata3-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/03-DeadMetadata3-fe.p4 delete mode 100644 testdata/v1_samples_outputs/03-DeadMetadata3-last.p4 delete mode 100644 testdata/v1_samples_outputs/03-DeadMetadata3-midend.p4 rename testdata/v1_samples_outputs/{03-FullPHV2-fe.p4 => 03-FullPHV2-FrontEnd_11_SimplifyControlFlowE.p4} (87%) rename testdata/v1_samples_outputs/{03-FullPHV2-last.p4 => 03-FullPHV2-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (89%) rename testdata/v1_samples_outputs/{03-FullPHV2-midend.p4 => 03-FullPHV2-MidEnd_25_Evaluator.p4} (90%) rename testdata/v1_samples_outputs/{03-Gateway-fe.p4 => 03-Gateway-FrontEnd_11_SimplifyControlFlowE.p4} (55%) rename testdata/v1_samples_outputs/{03-Gateway-last.p4 => 03-Gateway-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (61%) rename testdata/v1_samples_outputs/{03-Gateway-midend.p4 => 03-Gateway-MidEnd_25_Evaluator.p4} (63%) create mode 100644 testdata/v1_samples_outputs/03-SplitEthernetCompact-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/03-SplitEthernetCompact-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/03-SplitEthernetCompact-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/03-SplitEthernetCompact-fe.p4 delete mode 100644 testdata/v1_samples_outputs/03-SplitEthernetCompact-last.p4 delete mode 100644 testdata/v1_samples_outputs/03-SplitEthernetCompact-midend.p4 rename testdata/v1_samples_outputs/{04-GatewayDefault-last.p4 => 04-GatewayDefault-FrontEnd_11_SimplifyControlFlowE.p4} (54%) rename testdata/v1_samples_outputs/{04-GatewayDefault-fe.p4 => 04-GatewayDefault-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (60%) rename testdata/v1_samples_outputs/{04-GatewayDefault-midend.p4 => 04-GatewayDefault-MidEnd_25_Evaluator.p4} (63%) create mode 100644 testdata/v1_samples_outputs/04-SimpleVlan-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/04-SimpleVlan-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/04-SimpleVlan-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/04-SimpleVlan-fe.p4 delete mode 100644 testdata/v1_samples_outputs/04-SimpleVlan-last.p4 delete mode 100644 testdata/v1_samples_outputs/04-SimpleVlan-midend.p4 create mode 100644 testdata/v1_samples_outputs/05-FieldProblem-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/05-FieldProblem-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/05-FieldProblem-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/05-FieldProblem-fe.p4 delete mode 100644 testdata/v1_samples_outputs/05-FieldProblem-last.p4 delete mode 100644 testdata/v1_samples_outputs/05-FieldProblem-midend.p4 rename testdata/v1_samples_outputs/{05-FullTPHV-fe.p4 => 05-FullTPHV-FrontEnd_11_SimplifyControlFlowE.p4} (90%) rename testdata/v1_samples_outputs/{05-FullTPHV-last.p4 => 05-FullTPHV-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (91%) rename testdata/v1_samples_outputs/{05-FullTPHV-midend.p4 => 05-FullTPHV-MidEnd_25_Evaluator.p4} (92%) create mode 100644 testdata/v1_samples_outputs/05-SimpleVlan1-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/05-SimpleVlan1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/05-SimpleVlan1-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/05-SimpleVlan1-fe.p4 delete mode 100644 testdata/v1_samples_outputs/05-SimpleVlan1-last.p4 delete mode 100644 testdata/v1_samples_outputs/05-SimpleVlan1-midend.p4 rename testdata/v1_samples_outputs/{06-FullTPHV1-fe.p4 => 06-FullTPHV1-FrontEnd_11_SimplifyControlFlowE.p4} (89%) rename testdata/v1_samples_outputs/{06-FullTPHV1-last.p4 => 06-FullTPHV1-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (91%) rename testdata/v1_samples_outputs/{06-FullTPHV1-midend.p4 => 06-FullTPHV1-MidEnd_25_Evaluator.p4} (91%) create mode 100644 testdata/v1_samples_outputs/06-SimpleVlanStack-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/06-SimpleVlanStack-FrontEnd_12_RemoveAllUnusedDeclarations.p4 rename testdata/v1_samples_outputs/{06-SimpleVlanStack-midend.p4 => 06-SimpleVlanStack-MidEnd_25_Evaluator.p4} (51%) delete mode 100644 testdata/v1_samples_outputs/06-SimpleVlanStack-fe.p4 delete mode 100644 testdata/v1_samples_outputs/06-SimpleVlanStack-last.p4 rename testdata/v1_samples_outputs/{07-FullTPHV2-fe.p4 => 07-FullTPHV2-FrontEnd_11_SimplifyControlFlowE.p4} (89%) rename testdata/v1_samples_outputs/{07-FullTPHV2-last.p4 => 07-FullTPHV2-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (91%) rename testdata/v1_samples_outputs/{07-FullTPHV2-midend.p4 => 07-FullTPHV2-MidEnd_25_Evaluator.p4} (91%) rename testdata/v1_samples_outputs/{07-MultiProtocol-last.p4 => 07-MultiProtocol-FrontEnd_11_SimplifyControlFlowE.p4} (68%) rename testdata/v1_samples_outputs/{07-MultiProtocol-fe.p4 => 07-MultiProtocol-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (73%) rename testdata/v1_samples_outputs/{07-MultiProtocol-midend.p4 => 07-MultiProtocol-MidEnd_25_Evaluator.p4} (75%) create mode 100644 testdata/v1_samples_outputs/07-SimpleVlanStackIP-FrontEnd_11_SimplifyControlFlowE.p4 rename testdata/v1_samples_outputs/{07-SimpleVlanStackIP-fe.p4 => 07-SimpleVlanStackIP-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (55%) rename testdata/v1_samples_outputs/{07-SimpleVlanStackIP-midend.p4 => 07-SimpleVlanStackIP-MidEnd_25_Evaluator.p4} (56%) delete mode 100644 testdata/v1_samples_outputs/07-SimpleVlanStackIP-last.p4 rename testdata/v1_samples_outputs/{08-FullTPHV3-fe.p4 => 08-FullTPHV3-FrontEnd_11_SimplifyControlFlowE.p4} (91%) rename testdata/v1_samples_outputs/{08-FullTPHV3-last.p4 => 08-FullTPHV3-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (93%) rename testdata/v1_samples_outputs/{08-FullTPHV3-midend.p4 => 08-FullTPHV3-MidEnd_25_Evaluator.p4} (93%) rename testdata/v1_samples_outputs/{08-MultiProtocolIfElse-last.p4 => 08-MultiProtocolIfElse-FrontEnd_11_SimplifyControlFlowE.p4} (64%) rename testdata/v1_samples_outputs/{08-MultiProtocolIfElse-fe.p4 => 08-MultiProtocolIfElse-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (70%) rename testdata/v1_samples_outputs/{08-MultiProtocolIfElse-midend.p4 => 08-MultiProtocolIfElse-MidEnd_25_Evaluator.p4} (71%) create mode 100644 testdata/v1_samples_outputs/08-SimpleVlanStackIPSplitFlags-FrontEnd_11_SimplifyControlFlowE.p4 rename testdata/v1_samples_outputs/{08-SimpleVlanStackIPSplitFlags-last.p4 => 08-SimpleVlanStackIPSplitFlags-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (55%) rename testdata/v1_samples_outputs/{08-SimpleVlanStackIPSplitFlags-midend.p4 => 08-SimpleVlanStackIPSplitFlags-MidEnd_25_Evaluator.p4} (56%) delete mode 100644 testdata/v1_samples_outputs/08-SimpleVlanStackIPSplitFlags-fe.p4 create mode 100644 testdata/v1_samples_outputs/10-SelectPriorities-FrontEnd_11_SimplifyControlFlowE.p4 rename testdata/v1_samples_outputs/{10-SelectPriorities-fe.p4 => 10-SelectPriorities-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (50%) rename testdata/v1_samples_outputs/{10-SelectPriorities-midend.p4 => 10-SelectPriorities-MidEnd_25_Evaluator.p4} (52%) delete mode 100644 testdata/v1_samples_outputs/10-SelectPriorities-last.p4 create mode 100644 testdata/v1_samples_outputs/11-MultiTags-FrontEnd_11_SimplifyControlFlowE.p4 rename testdata/v1_samples_outputs/{11-MultiTags-fe.p4 => 11-MultiTags-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (53%) rename testdata/v1_samples_outputs/{11-MultiTags-midend.p4 => 11-MultiTags-MidEnd_25_Evaluator.p4} (54%) create mode 100644 testdata/v1_samples_outputs/12-Counters-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/12-Counters-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/12-Counters-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/12-Counters-fe.p4 delete mode 100644 testdata/v1_samples_outputs/12-Counters-last.p4 delete mode 100644 testdata/v1_samples_outputs/12-Counters-midend.p4 create mode 100644 testdata/v1_samples_outputs/12-MultiTagsNoLoop-FrontEnd_11_SimplifyControlFlowE.p4 rename testdata/v1_samples_outputs/{11-MultiTags-last.p4 => 12-MultiTagsNoLoop-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (52%) rename testdata/v1_samples_outputs/{12-MultiTagsNoLoop-midend.p4 => 12-MultiTagsNoLoop-MidEnd_25_Evaluator.p4} (53%) delete mode 100644 testdata/v1_samples_outputs/12-MultiTagsNoLoop-fe.p4 delete mode 100644 testdata/v1_samples_outputs/12-MultiTagsNoLoop-last.p4 create mode 100644 testdata/v1_samples_outputs/13-Counters1and2-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/13-Counters1and2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/13-Counters1and2-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/13-Counters1and2-fe.p4 delete mode 100644 testdata/v1_samples_outputs/13-Counters1and2-last.p4 delete mode 100644 testdata/v1_samples_outputs/13-Counters1and2-midend.p4 rename testdata/v1_samples_outputs/{13-MultiTagsCorrect-last.p4 => 13-MultiTagsCorrect-FrontEnd_11_SimplifyControlFlowE.p4} (50%) rename testdata/v1_samples_outputs/{13-MultiTagsCorrect-fe.p4 => 13-MultiTagsCorrect-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (56%) rename testdata/v1_samples_outputs/{13-MultiTagsCorrect-midend.p4 => 13-MultiTagsCorrect-MidEnd_25_Evaluator.p4} (57%) create mode 100644 testdata/v1_samples_outputs/14-Counter-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/14-Counter-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/14-Counter-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/14-Counter-fe.p4 delete mode 100644 testdata/v1_samples_outputs/14-Counter-last.p4 delete mode 100644 testdata/v1_samples_outputs/14-Counter-midend.p4 create mode 100644 testdata/v1_samples_outputs/14-GatewayGreaterThan-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/14-GatewayGreaterThan-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/14-GatewayGreaterThan-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/14-GatewayGreaterThan-fe.p4 delete mode 100644 testdata/v1_samples_outputs/14-GatewayGreaterThan-last.p4 delete mode 100644 testdata/v1_samples_outputs/14-GatewayGreaterThan-midend.p4 rename testdata/v1_samples_outputs/{14-SplitEthernetVlan-last.p4 => 14-SplitEthernetVlan-FrontEnd_11_SimplifyControlFlowE.p4} (50%) rename testdata/v1_samples_outputs/{14-SplitEthernetVlan-fe.p4 => 14-SplitEthernetVlan-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (56%) rename testdata/v1_samples_outputs/{14-SplitEthernetVlan-midend.p4 => 14-SplitEthernetVlan-MidEnd_25_Evaluator.p4} (56%) rename testdata/v1_samples_outputs/{15-MultiProtocolIfElseMinimal-fe.p4 => 15-MultiProtocolIfElseMinimal-FrontEnd_11_SimplifyControlFlowE.p4} (51%) rename testdata/v1_samples_outputs/{15-MultiProtocolIfElseMinimal-last.p4 => 15-MultiProtocolIfElseMinimal-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (57%) rename testdata/v1_samples_outputs/{15-MultiProtocolIfElseMinimal-midend.p4 => 15-MultiProtocolIfElseMinimal-MidEnd_25_Evaluator.p4} (59%) create mode 100644 testdata/v1_samples_outputs/16-NoHeaders-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/16-NoHeaders-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/16-NoHeaders-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/16-NoHeaders-fe.p4 delete mode 100644 testdata/v1_samples_outputs/16-NoHeaders-last.p4 delete mode 100644 testdata/v1_samples_outputs/16-NoHeaders-midend.p4 create mode 100644 testdata/v1_samples_outputs/16-TwoReferences-FrontEnd_11_SimplifyControlFlowE.p4 rename testdata/v1_samples_outputs/{16-TwoReferences-fe.p4 => 16-TwoReferences-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (52%) rename testdata/v1_samples_outputs/{16-TwoReferences-midend.p4 => 16-TwoReferences-MidEnd_25_Evaluator.p4} (56%) delete mode 100644 testdata/v1_samples_outputs/16-TwoReferences-last.p4 create mode 100644 testdata/v1_samples_outputs/17-Minimal-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/17-Minimal-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/17-Minimal-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/17-Minimal-fe.p4 delete mode 100644 testdata/v1_samples_outputs/17-Minimal-last.p4 delete mode 100644 testdata/v1_samples_outputs/17-Minimal-midend.p4 create mode 100644 testdata/v1_samples_outputs/18-EmptyPipelines-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/18-EmptyPipelines-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/18-EmptyPipelines-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/18-EmptyPipelines-fe.p4 delete mode 100644 testdata/v1_samples_outputs/18-EmptyPipelines-last.p4 delete mode 100644 testdata/v1_samples_outputs/18-EmptyPipelines-midend.p4 rename testdata/v1_samples_outputs/{acl1-last.p4 => acl1-FrontEnd_11_SimplifyControlFlowE.p4} (72%) rename testdata/v1_samples_outputs/{acl1-fe.p4 => acl1-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (77%) rename testdata/v1_samples_outputs/{acl1-midend.p4 => acl1-MidEnd_25_Evaluator.p4} (77%) rename testdata/v1_samples_outputs/{action_bus1-last.p4 => action_bus1-FrontEnd_11_SimplifyControlFlowE.p4} (66%) rename testdata/v1_samples_outputs/{action_bus1-fe.p4 => action_bus1-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (71%) rename testdata/v1_samples_outputs/{action_bus1-midend.p4 => action_bus1-MidEnd_25_Evaluator.p4} (73%) rename testdata/v1_samples_outputs/{action_chain1-last.p4 => action_chain1-FrontEnd_11_SimplifyControlFlowE.p4} (55%) rename testdata/v1_samples_outputs/{action_chain1-fe.p4 => action_chain1-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (61%) rename testdata/v1_samples_outputs/{action_chain1-midend.p4 => action_chain1-MidEnd_25_Evaluator.p4} (64%) create mode 100644 testdata/v1_samples_outputs/action_inline-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/action_inline-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/action_inline-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/action_inline-fe.p4 delete mode 100644 testdata/v1_samples_outputs/action_inline-last.p4 delete mode 100644 testdata/v1_samples_outputs/action_inline-midend.p4 create mode 100644 testdata/v1_samples_outputs/action_inline1-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/action_inline1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/action_inline1-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/action_inline1-fe.p4 delete mode 100644 testdata/v1_samples_outputs/action_inline1-last.p4 delete mode 100644 testdata/v1_samples_outputs/action_inline1-midend.p4 rename testdata/v1_samples_outputs/{axon-last.p4 => axon-FrontEnd_11_SimplifyControlFlowE.p4} (58%) rename testdata/v1_samples_outputs/{axon-fe.p4 => axon-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (63%) rename testdata/v1_samples_outputs/{axon-midend.p4 => axon-MidEnd_25_Evaluator.p4} (64%) rename testdata/v1_samples_outputs/{basic_routing-last.p4 => basic_routing-FrontEnd_11_SimplifyControlFlowE.p4} (65%) rename testdata/v1_samples_outputs/{basic_routing-fe.p4 => basic_routing-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (70%) rename testdata/v1_samples_outputs/{basic_routing-midend.p4 => basic_routing-MidEnd_25_Evaluator.p4} (73%) rename testdata/v1_samples_outputs/{checksum1-last.p4 => checksum1-FrontEnd_11_SimplifyControlFlowE.p4} (54%) rename testdata/v1_samples_outputs/{checksum1-fe.p4 => checksum1-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (60%) rename testdata/v1_samples_outputs/{checksum1-midend.p4 => checksum1-MidEnd_25_Evaluator.p4} (63%) create mode 100644 testdata/v1_samples_outputs/copy_to_cpu-FrontEnd_11_SimplifyControlFlowE.p4 rename testdata/v1_samples_outputs/{copy_to_cpu-fe.p4 => copy_to_cpu-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (52%) rename testdata/v1_samples_outputs/{copy_to_cpu-midend.p4 => copy_to_cpu-MidEnd_25_Evaluator.p4} (53%) delete mode 100644 testdata/v1_samples_outputs/copy_to_cpu-last.p4 create mode 100644 testdata/v1_samples_outputs/counter-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/counter-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/counter-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/counter-fe.p4 delete mode 100644 testdata/v1_samples_outputs/counter-last.p4 delete mode 100644 testdata/v1_samples_outputs/counter-midend.p4 create mode 100644 testdata/v1_samples_outputs/counter1-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/counter1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/counter1-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/counter1-fe.p4 delete mode 100644 testdata/v1_samples_outputs/counter1-last.p4 delete mode 100644 testdata/v1_samples_outputs/counter1-midend.p4 create mode 100644 testdata/v1_samples_outputs/counter2-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/counter2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/counter2-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/counter2-fe.p4 delete mode 100644 testdata/v1_samples_outputs/counter2-last.p4 delete mode 100644 testdata/v1_samples_outputs/counter2-midend.p4 create mode 100644 testdata/v1_samples_outputs/counter3-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/counter3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/counter3-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/counter3-fe.p4 delete mode 100644 testdata/v1_samples_outputs/counter3-last.p4 delete mode 100644 testdata/v1_samples_outputs/counter3-midend.p4 create mode 100644 testdata/v1_samples_outputs/counter4-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/counter4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/counter4-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/counter4-fe.p4 delete mode 100644 testdata/v1_samples_outputs/counter4-last.p4 delete mode 100644 testdata/v1_samples_outputs/counter4-midend.p4 create mode 100644 testdata/v1_samples_outputs/counter5-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/counter5-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/counter5-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/counter5-fe.p4 delete mode 100644 testdata/v1_samples_outputs/counter5-last.p4 delete mode 100644 testdata/v1_samples_outputs/counter5-midend.p4 create mode 100644 testdata/v1_samples_outputs/do_nothing-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/do_nothing-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/do_nothing-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/do_nothing-fe.p4 delete mode 100644 testdata/v1_samples_outputs/do_nothing-last.p4 delete mode 100644 testdata/v1_samples_outputs/do_nothing-midend.p4 create mode 100644 testdata/v1_samples_outputs/exact_match1-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/exact_match1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/exact_match1-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/exact_match1-fe.p4 delete mode 100644 testdata/v1_samples_outputs/exact_match1-last.p4 delete mode 100644 testdata/v1_samples_outputs/exact_match1-midend.p4 create mode 100644 testdata/v1_samples_outputs/exact_match2-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/exact_match2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/exact_match2-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/exact_match2-fe.p4 delete mode 100644 testdata/v1_samples_outputs/exact_match2-last.p4 delete mode 100644 testdata/v1_samples_outputs/exact_match2-midend.p4 create mode 100644 testdata/v1_samples_outputs/exact_match3-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/exact_match3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/exact_match3-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/exact_match3-fe.p4 delete mode 100644 testdata/v1_samples_outputs/exact_match3-last.p4 delete mode 100644 testdata/v1_samples_outputs/exact_match3-midend.p4 create mode 100644 testdata/v1_samples_outputs/exact_match4-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/exact_match4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/exact_match4-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/exact_match4-fe.p4 delete mode 100644 testdata/v1_samples_outputs/exact_match4-last.p4 delete mode 100644 testdata/v1_samples_outputs/exact_match4-midend.p4 create mode 100644 testdata/v1_samples_outputs/exact_match5-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/exact_match5-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/exact_match5-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/exact_match5-fe.p4 delete mode 100644 testdata/v1_samples_outputs/exact_match5-last.p4 delete mode 100644 testdata/v1_samples_outputs/exact_match5-midend.p4 create mode 100644 testdata/v1_samples_outputs/exact_match6-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/exact_match6-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/exact_match6-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/exact_match6-fe.p4 delete mode 100644 testdata/v1_samples_outputs/exact_match6-last.p4 delete mode 100644 testdata/v1_samples_outputs/exact_match6-midend.p4 create mode 100644 testdata/v1_samples_outputs/exact_match7-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/exact_match7-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/exact_match7-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/exact_match7-fe.p4 delete mode 100644 testdata/v1_samples_outputs/exact_match7-last.p4 delete mode 100644 testdata/v1_samples_outputs/exact_match7-midend.p4 create mode 100644 testdata/v1_samples_outputs/exact_match8-FrontEnd_11_SimplifyControlFlowE.p4 rename testdata/v1_samples_outputs/{exact_match8-last.p4 => exact_match8-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (53%) rename testdata/v1_samples_outputs/{exact_match8-midend.p4 => exact_match8-MidEnd_25_Evaluator.p4} (54%) delete mode 100644 testdata/v1_samples_outputs/exact_match8-fe.p4 create mode 100644 testdata/v1_samples_outputs/exact_match9-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/exact_match9-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/exact_match9-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/exact_match9-fe.p4 delete mode 100644 testdata/v1_samples_outputs/exact_match9-last.p4 delete mode 100644 testdata/v1_samples_outputs/exact_match9-midend.p4 create mode 100644 testdata/v1_samples_outputs/exact_match_valid1-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/exact_match_valid1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/exact_match_valid1-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/exact_match_valid1-fe.p4 delete mode 100644 testdata/v1_samples_outputs/exact_match_valid1-last.p4 delete mode 100644 testdata/v1_samples_outputs/exact_match_valid1-midend.p4 rename testdata/v1_samples_outputs/{flowlet_switching-last.p4 => flowlet_switching-FrontEnd_11_SimplifyControlFlowE.p4} (71%) rename testdata/v1_samples_outputs/{flowlet_switching-fe.p4 => flowlet_switching-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (74%) rename testdata/v1_samples_outputs/{flowlet_switching-midend.p4 => flowlet_switching-MidEnd_25_Evaluator.p4} (76%) create mode 100644 testdata/v1_samples_outputs/gateway1-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/gateway1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/gateway1-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/gateway1-fe.p4 delete mode 100644 testdata/v1_samples_outputs/gateway1-last.p4 delete mode 100644 testdata/v1_samples_outputs/gateway1-midend.p4 create mode 100644 testdata/v1_samples_outputs/gateway2-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/gateway2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/gateway2-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/gateway2-fe.p4 delete mode 100644 testdata/v1_samples_outputs/gateway2-last.p4 delete mode 100644 testdata/v1_samples_outputs/gateway2-midend.p4 create mode 100644 testdata/v1_samples_outputs/gateway3-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/gateway3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/gateway3-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/gateway3-fe.p4 delete mode 100644 testdata/v1_samples_outputs/gateway3-last.p4 delete mode 100644 testdata/v1_samples_outputs/gateway3-midend.p4 create mode 100644 testdata/v1_samples_outputs/gateway4-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/gateway4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 rename testdata/v1_samples_outputs/{gateway4-midend.p4 => gateway4-MidEnd_25_Evaluator.p4} (51%) delete mode 100644 testdata/v1_samples_outputs/gateway4-fe.p4 delete mode 100644 testdata/v1_samples_outputs/gateway4-last.p4 create mode 100644 testdata/v1_samples_outputs/gateway5-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/gateway5-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/gateway5-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/gateway5-fe.p4 delete mode 100644 testdata/v1_samples_outputs/gateway5-last.p4 delete mode 100644 testdata/v1_samples_outputs/gateway5-midend.p4 create mode 100644 testdata/v1_samples_outputs/gateway6-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/gateway6-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/gateway6-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/gateway6-fe.p4 delete mode 100644 testdata/v1_samples_outputs/gateway6-last.p4 delete mode 100644 testdata/v1_samples_outputs/gateway6-midend.p4 create mode 100644 testdata/v1_samples_outputs/gateway7-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/gateway7-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/gateway7-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/gateway7-fe.p4 delete mode 100644 testdata/v1_samples_outputs/gateway7-last.p4 delete mode 100644 testdata/v1_samples_outputs/gateway7-midend.p4 create mode 100644 testdata/v1_samples_outputs/hit-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/hit-FrontEnd_12_RemoveAllUnusedDeclarations.p4 rename testdata/v1_samples_outputs/{hit-midend.p4 => hit-MidEnd_25_Evaluator.p4} (50%) delete mode 100644 testdata/v1_samples_outputs/hit-fe.p4 delete mode 100644 testdata/v1_samples_outputs/hit-last.p4 create mode 100644 testdata/v1_samples_outputs/hitmiss-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/hitmiss-FrontEnd_12_RemoveAllUnusedDeclarations.p4 rename testdata/v1_samples_outputs/{hitmiss-midend.p4 => hitmiss-MidEnd_25_Evaluator.p4} (53%) delete mode 100644 testdata/v1_samples_outputs/hitmiss-fe.p4 delete mode 100644 testdata/v1_samples_outputs/hitmiss-last.p4 create mode 100644 testdata/v1_samples_outputs/inline-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/inline-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/inline-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/inline-fe.p4 delete mode 100644 testdata/v1_samples_outputs/inline-last.p4 delete mode 100644 testdata/v1_samples_outputs/inline-midend.p4 create mode 100644 testdata/v1_samples_outputs/instruct1-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/instruct1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/instruct1-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/instruct1-fe.p4 delete mode 100644 testdata/v1_samples_outputs/instruct1-last.p4 delete mode 100644 testdata/v1_samples_outputs/instruct1-midend.p4 create mode 100644 testdata/v1_samples_outputs/instruct2-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/instruct2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/instruct2-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/instruct2-fe.p4 delete mode 100644 testdata/v1_samples_outputs/instruct2-last.p4 delete mode 100644 testdata/v1_samples_outputs/instruct2-midend.p4 create mode 100644 testdata/v1_samples_outputs/instruct3-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/instruct3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/instruct3-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/instruct3-fe.p4 delete mode 100644 testdata/v1_samples_outputs/instruct3-last.p4 delete mode 100644 testdata/v1_samples_outputs/instruct3-midend.p4 create mode 100644 testdata/v1_samples_outputs/instruct4-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/instruct4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/instruct4-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/instruct4-fe.p4 delete mode 100644 testdata/v1_samples_outputs/instruct4-last.p4 delete mode 100644 testdata/v1_samples_outputs/instruct4-midend.p4 create mode 100644 testdata/v1_samples_outputs/instruct5-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/instruct5-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/instruct5-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/instruct5-fe.p4 delete mode 100644 testdata/v1_samples_outputs/instruct5-last.p4 delete mode 100644 testdata/v1_samples_outputs/instruct5-midend.p4 rename testdata/v1_samples_outputs/{mac_rewrite-last.p4 => mac_rewrite-FrontEnd_11_SimplifyControlFlowE.p4} (62%) rename testdata/v1_samples_outputs/{mac_rewrite-fe.p4 => mac_rewrite-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (68%) rename testdata/v1_samples_outputs/{mac_rewrite-midend.p4 => mac_rewrite-MidEnd_25_Evaluator.p4} (71%) create mode 100644 testdata/v1_samples_outputs/meter-FrontEnd_11_SimplifyControlFlowE.p4 rename testdata/v1_samples_outputs/{meter-last.p4 => meter-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (51%) rename testdata/v1_samples_outputs/{meter-midend.p4 => meter-MidEnd_25_Evaluator.p4} (52%) delete mode 100644 testdata/v1_samples_outputs/meter-fe.p4 create mode 100644 testdata/v1_samples_outputs/meter1-FrontEnd_11_SimplifyControlFlowE.p4 rename testdata/v1_samples_outputs/{meter1-last.p4 => meter1-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (52%) rename testdata/v1_samples_outputs/{meter1-midend.p4 => meter1-MidEnd_25_Evaluator.p4} (53%) delete mode 100644 testdata/v1_samples_outputs/meter1-fe.p4 create mode 100644 testdata/v1_samples_outputs/miss-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/miss-FrontEnd_12_RemoveAllUnusedDeclarations.p4 rename testdata/v1_samples_outputs/{miss-midend.p4 => miss-MidEnd_25_Evaluator.p4} (51%) delete mode 100644 testdata/v1_samples_outputs/miss-fe.p4 delete mode 100644 testdata/v1_samples_outputs/miss-last.p4 create mode 100644 testdata/v1_samples_outputs/overflow-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/overflow-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/overflow-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/overflow-fe.p4 delete mode 100644 testdata/v1_samples_outputs/overflow-last.p4 delete mode 100644 testdata/v1_samples_outputs/overflow-midend.p4 rename testdata/v1_samples_outputs/{packet_redirect-last.p4 => packet_redirect-FrontEnd_11_SimplifyControlFlowE.p4} (54%) rename testdata/v1_samples_outputs/{packet_redirect-fe.p4 => packet_redirect-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (58%) rename testdata/v1_samples_outputs/{packet_redirect-midend.p4 => packet_redirect-MidEnd_25_Evaluator.p4} (60%) rename testdata/v1_samples_outputs/{parser1-last.p4 => parser1-FrontEnd_11_SimplifyControlFlowE.p4} (55%) rename testdata/v1_samples_outputs/{parser1-fe.p4 => parser1-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (61%) rename testdata/v1_samples_outputs/{parser1-midend.p4 => parser1-MidEnd_25_Evaluator.p4} (62%) rename testdata/v1_samples_outputs/{parser2-last.p4 => parser2-FrontEnd_11_SimplifyControlFlowE.p4} (66%) rename testdata/v1_samples_outputs/{parser2-fe.p4 => parser2-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (71%) rename testdata/v1_samples_outputs/{parser2-midend.p4 => parser2-MidEnd_25_Evaluator.p4} (71%) create mode 100644 testdata/v1_samples_outputs/parser3-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/parser3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/parser3-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/parser3-fe.p4 delete mode 100644 testdata/v1_samples_outputs/parser3-last.p4 delete mode 100644 testdata/v1_samples_outputs/parser3-midend.p4 rename testdata/v1_samples_outputs/{parser4-last.p4 => parser4-FrontEnd_11_SimplifyControlFlowE.p4} (56%) rename testdata/v1_samples_outputs/{parser4-fe.p4 => parser4-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (62%) rename testdata/v1_samples_outputs/{parser4-midend.p4 => parser4-MidEnd_25_Evaluator.p4} (62%) rename testdata/v1_samples_outputs/{parser_dc_full-fe.p4 => parser_dc_full-FrontEnd_11_SimplifyControlFlowE.p4} (86%) rename testdata/v1_samples_outputs/{parser_dc_full-last.p4 => parser_dc_full-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (89%) rename testdata/v1_samples_outputs/{parser_dc_full-midend.p4 => parser_dc_full-MidEnd_25_Evaluator.p4} (89%) rename testdata/v1_samples_outputs/{port_vlan_mapping-fe.p4 => port_vlan_mapping-FrontEnd_11_SimplifyControlFlowE.p4} (91%) rename testdata/v1_samples_outputs/{port_vlan_mapping-last.p4 => port_vlan_mapping-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (93%) rename testdata/v1_samples_outputs/{port_vlan_mapping-midend.p4 => port_vlan_mapping-MidEnd_25_Evaluator.p4} (93%) create mode 100644 testdata/v1_samples_outputs/queueing-FrontEnd_11_SimplifyControlFlowE.p4 rename testdata/v1_samples_outputs/{queueing-fe.p4 => queueing-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (55%) rename testdata/v1_samples_outputs/{queueing-midend.p4 => queueing-MidEnd_25_Evaluator.p4} (56%) delete mode 100644 testdata/v1_samples_outputs/queueing-last.p4 create mode 100644 testdata/v1_samples_outputs/register-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/register-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/register-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/register-fe.p4 delete mode 100644 testdata/v1_samples_outputs/register-last.p4 delete mode 100644 testdata/v1_samples_outputs/register-midend.p4 create mode 100644 testdata/v1_samples_outputs/resubmit-FrontEnd_11_SimplifyControlFlowE.p4 rename testdata/v1_samples_outputs/{resubmit-fe.p4 => resubmit-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (50%) rename testdata/v1_samples_outputs/{resubmit-midend.p4 => resubmit-MidEnd_25_Evaluator.p4} (52%) delete mode 100644 testdata/v1_samples_outputs/resubmit-last.p4 rename testdata/v1_samples_outputs/{sai_p4-fe.p4 => sai_p4-FrontEnd_11_SimplifyControlFlowE.p4} (81%) rename testdata/v1_samples_outputs/{sai_p4-last.p4 => sai_p4-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (84%) rename testdata/v1_samples_outputs/{sai_p4-midend.p4 => sai_p4-MidEnd_25_Evaluator.p4} (85%) create mode 100644 testdata/v1_samples_outputs/selector0-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/selector0-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/selector0-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/selector0-fe.p4 delete mode 100644 testdata/v1_samples_outputs/selector0-last.p4 delete mode 100644 testdata/v1_samples_outputs/selector0-midend.p4 create mode 100644 testdata/v1_samples_outputs/selector1-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/selector1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/selector1-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/selector1-fe.p4 delete mode 100644 testdata/v1_samples_outputs/selector1-last.p4 delete mode 100644 testdata/v1_samples_outputs/selector1-midend.p4 create mode 100644 testdata/v1_samples_outputs/selector2-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/selector2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/selector2-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/selector2-fe.p4 delete mode 100644 testdata/v1_samples_outputs/selector2-last.p4 delete mode 100644 testdata/v1_samples_outputs/selector2-midend.p4 create mode 100644 testdata/v1_samples_outputs/selector3-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/selector3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/selector3-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/selector3-fe.p4 delete mode 100644 testdata/v1_samples_outputs/selector3-last.p4 delete mode 100644 testdata/v1_samples_outputs/selector3-midend.p4 rename testdata/v1_samples_outputs/{simple_nat-fe.p4 => simple_nat-FrontEnd_11_SimplifyControlFlowE.p4} (75%) rename testdata/v1_samples_outputs/{simple_nat-last.p4 => simple_nat-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (79%) rename testdata/v1_samples_outputs/{simple_nat-midend.p4 => simple_nat-MidEnd_25_Evaluator.p4} (81%) rename testdata/v1_samples_outputs/{simple_router-last.p4 => simple_router-FrontEnd_11_SimplifyControlFlowE.p4} (58%) rename testdata/v1_samples_outputs/{simple_router-fe.p4 => simple_router-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (63%) rename testdata/v1_samples_outputs/{simple_router-midend.p4 => simple_router-MidEnd_25_Evaluator.p4} (66%) create mode 100644 testdata/v1_samples_outputs/source_routing-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/source_routing-FrontEnd_12_RemoveAllUnusedDeclarations.p4 rename testdata/v1_samples_outputs/{source_routing-midend.p4 => source_routing-MidEnd_25_Evaluator.p4} (50%) delete mode 100644 testdata/v1_samples_outputs/source_routing-fe.p4 delete mode 100644 testdata/v1_samples_outputs/source_routing-last.p4 create mode 100644 testdata/v1_samples_outputs/swap_1-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/swap_1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/swap_1-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/swap_1-fe.p4 delete mode 100644 testdata/v1_samples_outputs/swap_1-last.p4 delete mode 100644 testdata/v1_samples_outputs/swap_1-midend.p4 create mode 100644 testdata/v1_samples_outputs/swap_2-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/swap_2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/swap_2-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/swap_2-fe.p4 delete mode 100644 testdata/v1_samples_outputs/swap_2-last.p4 delete mode 100644 testdata/v1_samples_outputs/swap_2-midend.p4 rename testdata/v1_samples_outputs/{switch-fe.p4 => switch-FrontEnd_11_SimplifyControlFlowE.p4} (98%) rename testdata/v1_samples_outputs/{switch-last.p4 => switch-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (98%) rename testdata/v1_samples_outputs/{switch-midend.p4 => switch-MidEnd_25_Evaluator.p4} (99%) create mode 100644 testdata/v1_samples_outputs/ternary_match0-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/ternary_match0-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/ternary_match0-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/ternary_match0-fe.p4 delete mode 100644 testdata/v1_samples_outputs/ternary_match0-last.p4 delete mode 100644 testdata/v1_samples_outputs/ternary_match0-midend.p4 create mode 100644 testdata/v1_samples_outputs/ternary_match1-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/ternary_match1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/ternary_match1-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/ternary_match1-fe.p4 delete mode 100644 testdata/v1_samples_outputs/ternary_match1-last.p4 delete mode 100644 testdata/v1_samples_outputs/ternary_match1-midend.p4 create mode 100644 testdata/v1_samples_outputs/ternary_match2-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/ternary_match2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/ternary_match2-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/ternary_match2-fe.p4 delete mode 100644 testdata/v1_samples_outputs/ternary_match2-last.p4 delete mode 100644 testdata/v1_samples_outputs/ternary_match2-midend.p4 create mode 100644 testdata/v1_samples_outputs/ternary_match3-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/ternary_match3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/ternary_match3-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/ternary_match3-fe.p4 delete mode 100644 testdata/v1_samples_outputs/ternary_match3-last.p4 delete mode 100644 testdata/v1_samples_outputs/ternary_match3-midend.p4 create mode 100644 testdata/v1_samples_outputs/ternary_match4-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/ternary_match4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/ternary_match4-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/ternary_match4-fe.p4 delete mode 100644 testdata/v1_samples_outputs/ternary_match4-last.p4 delete mode 100644 testdata/v1_samples_outputs/ternary_match4-midend.p4 rename testdata/v1_samples_outputs/{test_7_storm_control-last.p4 => test_7_storm_control-FrontEnd_11_SimplifyControlFlowE.p4} (55%) rename testdata/v1_samples_outputs/{test_7_storm_control-fe.p4 => test_7_storm_control-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (60%) rename testdata/v1_samples_outputs/{test_7_storm_control-midend.p4 => test_7_storm_control-MidEnd_25_Evaluator.p4} (61%) create mode 100644 testdata/v1_samples_outputs/test_config_175_match_table_with_no_key-FrontEnd_11_SimplifyControlFlowE.p4 rename testdata/v1_samples_outputs/{test_config_175_match_table_with_no_key-fe.p4 => test_config_175_match_table_with_no_key-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (50%) rename testdata/v1_samples_outputs/{test_config_175_match_table_with_no_key-midend.p4 => test_config_175_match_table_with_no_key-MidEnd_25_Evaluator.p4} (51%) delete mode 100644 testdata/v1_samples_outputs/test_config_175_match_table_with_no_key-last.p4 create mode 100644 testdata/v1_samples_outputs/testgw-FrontEnd_11_SimplifyControlFlowE.p4 rename testdata/v1_samples_outputs/{testgw-fe.p4 => testgw-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (53%) rename testdata/v1_samples_outputs/{testgw-midend.p4 => testgw-MidEnd_25_Evaluator.p4} (55%) delete mode 100644 testdata/v1_samples_outputs/testgw-last.p4 create mode 100644 testdata/v1_samples_outputs/tp2a-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/tp2a-FrontEnd_12_RemoveAllUnusedDeclarations.p4 rename testdata/v1_samples_outputs/{tp2a-midend.p4 => tp2a-MidEnd_25_Evaluator.p4} (55%) delete mode 100644 testdata/v1_samples_outputs/tp2a-fe.p4 delete mode 100644 testdata/v1_samples_outputs/tp2a-last.p4 rename testdata/v1_samples_outputs/{tp2b-last.p4 => tp2b-FrontEnd_11_SimplifyControlFlowE.p4} (55%) rename testdata/v1_samples_outputs/{tp2b-fe.p4 => tp2b-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (61%) rename testdata/v1_samples_outputs/{tp2b-midend.p4 => tp2b-MidEnd_25_Evaluator.p4} (64%) rename testdata/v1_samples_outputs/{tp2c-last.p4 => tp2c-FrontEnd_11_SimplifyControlFlowE.p4} (52%) rename testdata/v1_samples_outputs/{tp2c-fe.p4 => tp2c-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (58%) rename testdata/v1_samples_outputs/{tp2c-midend.p4 => tp2c-MidEnd_25_Evaluator.p4} (62%) rename testdata/v1_samples_outputs/{tp3a-last.p4 => tp3a-FrontEnd_11_SimplifyControlFlowE.p4} (58%) rename testdata/v1_samples_outputs/{tp3a-fe.p4 => tp3a-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (64%) rename testdata/v1_samples_outputs/{tp3a-midend.p4 => tp3a-MidEnd_25_Evaluator.p4} (68%) create mode 100644 testdata/v1_samples_outputs/triv_eth-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/triv_eth-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/triv_eth-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/triv_eth-fe.p4 delete mode 100644 testdata/v1_samples_outputs/triv_eth-last.p4 delete mode 100644 testdata/v1_samples_outputs/triv_eth-midend.p4 create mode 100644 testdata/v1_samples_outputs/triv_ipv4-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/triv_ipv4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/triv_ipv4-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/triv_ipv4-fe.p4 delete mode 100644 testdata/v1_samples_outputs/triv_ipv4-last.p4 delete mode 100644 testdata/v1_samples_outputs/triv_ipv4-midend.p4 rename testdata/v1_samples_outputs/{validate_outer_ethernet-fe.p4 => validate_outer_ethernet-FrontEnd_11_SimplifyControlFlowE.p4} (72%) rename testdata/v1_samples_outputs/{validate_outer_ethernet-last.p4 => validate_outer_ethernet-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (77%) rename testdata/v1_samples_outputs/{validate_outer_ethernet-midend.p4 => validate_outer_ethernet-MidEnd_25_Evaluator.p4} (77%) create mode 100644 testdata/v1_samples_outputs/wide_action1-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/wide_action1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/wide_action1-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/wide_action1-fe.p4 delete mode 100644 testdata/v1_samples_outputs/wide_action1-last.p4 delete mode 100644 testdata/v1_samples_outputs/wide_action1-midend.p4 rename testdata/v1_samples_outputs/{wide_action2-last.p4 => wide_action2-FrontEnd_11_SimplifyControlFlowE.p4} (54%) rename testdata/v1_samples_outputs/{wide_action2-fe.p4 => wide_action2-FrontEnd_12_RemoveAllUnusedDeclarations.p4} (60%) rename testdata/v1_samples_outputs/{wide_action2-midend.p4 => wide_action2-MidEnd_25_Evaluator.p4} (61%) create mode 100644 testdata/v1_samples_outputs/wide_action3-FrontEnd_11_SimplifyControlFlowE.p4 create mode 100644 testdata/v1_samples_outputs/wide_action3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 create mode 100644 testdata/v1_samples_outputs/wide_action3-MidEnd_25_Evaluator.p4 delete mode 100644 testdata/v1_samples_outputs/wide_action3-fe.p4 delete mode 100644 testdata/v1_samples_outputs/wide_action3-last.p4 delete mode 100644 testdata/v1_samples_outputs/wide_action3-midend.p4 diff --git a/backends/bmv2/bmv2.cpp b/backends/bmv2/bmv2.cpp index 42aa15ae203..8d3a71cd851 100644 --- a/backends/bmv2/bmv2.cpp +++ b/backends/bmv2/bmv2.cpp @@ -24,17 +24,21 @@ int main(int argc, char *const argv[]) { if (::errorCount() > 0) return 1; + auto hook = options.getDebugHook(); + // BMV2 is required for compatibility with the previous compiler. options.preprocessor_options += " -D__TARGET_BMV2__"; auto program = parseP4File(options); if (program == nullptr || ::errorCount() > 0) return 1; FrontEnd frontend; + frontend.addDebugHook(hook); program = frontend.run(options, program); if (program == nullptr || ::errorCount() > 0) return 1; BMV2::MidEnd midEnd; + midEnd.addDebugHook(hook); auto blockMap = midEnd.process(options, program); if (::errorCount() > 0 || blockMap == nullptr) return 1; diff --git a/backends/bmv2/midend.cpp b/backends/bmv2/midend.cpp index 91af3ca37b9..d7734faf4af 100644 --- a/backends/bmv2/midend.cpp +++ b/backends/bmv2/midend.cpp @@ -46,7 +46,7 @@ const IR::P4Program* MidEnd::processV1(CompilerOptions&, const IR::P4Program* pr new P4::RemoveAllUnusedDeclarations(&refMap, isv1), }; midend.setName("Mid end"); - midend.setStopOnError(true); + midend.addDebugHooks(hooks); program = program->apply(midend); if (::errorCount() > 0) return nullptr; @@ -69,7 +69,7 @@ const IR::P4Program* MidEnd::processV1_2(CompilerOptions&, const IR::P4Program* // Move all local declarations to the beginning new P4::MoveDeclarations(), new P4::ResolveReferences(&refMap, isv1), - new P4::RemoveReturns(&refMap, true), + new P4::RemoveReturns(&refMap), // Move some constructor calls into temporaries new P4::MoveConstructors(isv1), new P4::RemoveAllUnusedDeclarations(&refMap, isv1), @@ -77,7 +77,7 @@ const IR::P4Program* MidEnd::processV1_2(CompilerOptions&, const IR::P4Program* }; simplify.setName("Simplify"); - simplify.setStopOnError(true); + simplify.addDebugHooks(hooks); program = program->apply(simplify); if (::errorCount() > 0) return nullptr; @@ -113,7 +113,7 @@ const IR::P4Program* MidEnd::processV1_2(CompilerOptions&, const IR::P4Program* }; midEnd.setName("Mid end"); - midEnd.setStopOnError(true); + midEnd.addDebugHooks(hooks); program = program->apply(midEnd); if (::errorCount() > 0) return nullptr; @@ -130,13 +130,11 @@ P4::BlockMap* MidEnd::process(CompilerOptions& options, const IR::P4Program* pro if (program == nullptr) return nullptr; - std::ostream *midendStream = options.dumpStream("-midend"); // BMv2-specific passes P4::ReferenceMap refMap; P4::TypeMap typeMap; auto evaluator = new P4::EvaluatorPass(isv1); PassManager backend = { - new P4::ToP4(midendStream, false, options.file), new P4::TypeChecking(&refMap, &typeMap, isv1), new P4::SimplifyControlFlow(&refMap, &typeMap), new P4::TypeChecking(&refMap, &typeMap, isv1), @@ -149,7 +147,7 @@ P4::BlockMap* MidEnd::process(CompilerOptions& options, const IR::P4Program* pro }; backend.setName("Backend"); - backend.setStopOnError(true); + backend.addDebugHooks(hooks); program = program->apply(backend); if (::errorCount() > 0) return nullptr; diff --git a/backends/bmv2/midend.h b/backends/bmv2/midend.h index 02172af2afa..2230dccde2b 100644 --- a/backends/bmv2/midend.h +++ b/backends/bmv2/midend.h @@ -8,10 +8,13 @@ namespace BMV2 { class MidEnd { + std::vector hooks; + const IR::P4Program* processV1(CompilerOptions& options, const IR::P4Program* program); const IR::P4Program* processV1_2(CompilerOptions& options, const IR::P4Program* program); public: P4::BlockMap* process(CompilerOptions& options, const IR::P4Program* program); + void addDebugHook(DebugHook hook) { hooks.push_back(hook); } }; } // namespace BMV2 diff --git a/backends/ebpf/midend.cpp b/backends/ebpf/midend.cpp index acf3177c2b6..6f25ba23d0d 100644 --- a/backends/ebpf/midend.cpp +++ b/backends/ebpf/midend.cpp @@ -37,7 +37,7 @@ const IR::P4Program* MidEnd::run(EbpfOptions& options, const IR::P4Program* prog // Move all local declarations to the beginning new P4::MoveDeclarations(), new P4::ResolveReferences(&refMap, isv1), - new P4::RemoveReturns(&refMap, true), // necessary for inlining + new P4::RemoveReturns(&refMap), // necessary for inlining // Move some constructor calls into temporaries new P4::MoveConstructors(isv1), new P4::ResolveReferences(&refMap, isv1), @@ -46,7 +46,7 @@ const IR::P4Program* MidEnd::run(EbpfOptions& options, const IR::P4Program* prog }; simplify.setName("Simplify"); - simplify.setStopOnError(true); + simplify.addDebugHooks(hooks); program = program->apply(simplify); if (::errorCount() > 0) return nullptr; @@ -72,8 +72,8 @@ const IR::P4Program* MidEnd::run(EbpfOptions& options, const IR::P4Program* prog new P4::RemoveAllUnusedDeclarations(&refMap, isv1), new P4::TypeChecking(&refMap, &typeMap, isv1), new P4::SimplifyControlFlow(&refMap, &typeMap), - new P4::ResolveReferences(&refMap, isv1), - new P4::RemoveReturns(&refMap, false), // remove exits + new P4::TypeChecking(&refMap, &typeMap, isv1), + new P4::RemoveExits(&refMap, &typeMap), new P4::TypeChecking(&refMap, &typeMap, isv1), new P4::ConstantFolding(&refMap, &typeMap), new P4::StrengthReduction(), @@ -82,15 +82,11 @@ const IR::P4Program* MidEnd::run(EbpfOptions& options, const IR::P4Program* prog new P4::MoveActionsToTables(&refMap, &typeMap), }; midEnd.setName("MidEnd"); - midEnd.setStopOnError(true); + midEnd.addDebugHooks(hooks); program = program->apply(midEnd); if (::errorCount() > 0) return nullptr; - std::ostream *midendStream = options.dumpStream("-midend"); - P4::ToP4 top4(midendStream, false, options.file); - program->apply(top4); - return program; } diff --git a/backends/ebpf/midend.h b/backends/ebpf/midend.h index 76167eacbd8..e7750d221dc 100644 --- a/backends/ebpf/midend.h +++ b/backends/ebpf/midend.h @@ -7,7 +7,9 @@ namespace EBPF { class MidEnd { + std::vector hooks; public: + void addDebugHook(DebugHook hook) { hooks.push_back(hook); } const IR::P4Program* run(EbpfOptions& options, const IR::P4Program* program); }; diff --git a/backends/ebpf/p4c-ebpf.cpp b/backends/ebpf/p4c-ebpf.cpp index f0e89f95d6f..c2d23b48ecb 100644 --- a/backends/ebpf/p4c-ebpf.cpp +++ b/backends/ebpf/p4c-ebpf.cpp @@ -11,29 +11,32 @@ #include "midend.h" #include "ebpfOptions.h" #include "ebpfBackend.h" -#include "frontends/p4/p4-parse.h" +#include "frontends/common/parseInput.h" #include "frontends/p4/frontend.h" -void compile(EbpfOptions& options, FILE* in) { +void compile(EbpfOptions& options) { + auto hook = options.getDebugHook(); bool isv1 = options.langVersion == CompilerOptions::FrontendVersion::P4v1; if (isv1) { ::error("This compiler only handles P4 v1.2"); return; } - const IR::P4Program* v12 = parse_p4v1_2_file(options.file, in); - options.closeInput(in); - if (ErrorReporter::instance.getErrorCount() > 0) { - ::error("%1% errors ecountered, aborting compilation", - ErrorReporter::instance.getErrorCount()); + auto program = parseP4File(options); + if (::errorCount() > 0) return; - } FrontEnd frontend; - v12 = frontend.run(options, v12); + frontend.addDebugHook(hook); + program = frontend.run(options, program); + if (::errorCount() > 0) + return; EBPF::MidEnd midend; - v12 = midend.run(options, v12); + midend.addDebugHook(hook); + program = midend.run(options, program); + if (::errorCount() > 0) + return; - EBPF::run_ebpf_backend(options, v12); + EBPF::run_ebpf_backend(options, program); } int main(int argc, char *const argv[]) { @@ -43,17 +46,12 @@ int main(int argc, char *const argv[]) { EbpfOptions options; if (options.process(argc, argv) != nullptr) options.setInputFile(); - - if (ErrorReporter::instance.getErrorCount() > 0) + if (::errorCount() > 0) exit(1); - FILE* in = options.preprocess(); - if (in != nullptr) { - compile(options, in); - } + compile(options); - if (verbose) + if (options.verbosity > 0) std::cerr << "Done." << std::endl; - - return ErrorReporter::instance.getErrorCount() > 0; + return ::errorCount() > 0; } diff --git a/backends/v12test/Makefile.am b/backends/v12test/Makefile.am index cddcc6e4526..93625f11c04 100644 --- a/backends/v12test/Makefile.am +++ b/backends/v12test/Makefile.am @@ -7,9 +7,7 @@ v12test_LDADD = libfrontend.a libp4ctoolkit.a v12test_SOURCES = \ backends/v12test/v12test.cpp \ backends/v12test/midend.h \ - backends/v12test/midend.cpp \ - backends/v12test/options.h \ - backends/v12test/options.cpp + backends/v12test/midend.cpp cpplint_FILES += $(v12test_SOURCES) @@ -27,7 +25,7 @@ CLEANFILES += \ $(srcdir)/v12tests.am: $(srcdir)/testdata/v1_2_samples/*.p4 $(srcdir)/testdata/v1_2_errors/*.p4 @$(GENTESTS) $(srcdir) v12 $(srcdir)/backends/v12test/run-v12-sample.py $^ >$@ -$(srcdir)/v1to12tests.am: $(srcdir)/testdata/v1_samples/*.p4 +$(srcdir)/v1to12tests.am: $(srcdir)/testdata/v1_samples/*.p4 @$(GENTESTS) $(srcdir) v1to12 $(srcdir)/backends/v12test/run-v12-sample.py $^ >$@ V12BUGS = \ @@ -37,4 +35,4 @@ V12BUGS = \ XFAIL_TESTS += \ $(V12BUGS) \ - v12/testdata/v1_2_samples/cast-call.p4.test + v12/testdata/v1_2_samples/cast-call.p4.test diff --git a/backends/v12test/midend.cpp b/backends/v12test/midend.cpp index e30bb120fe9..8f58122e283 100644 --- a/backends/v12test/midend.cpp +++ b/backends/v12test/midend.cpp @@ -26,8 +26,8 @@ P4::BlockMap* MidEnd::process(CompilerOptions& options, const IR::P4Program* pro P4::ReferenceMap refMap; P4::TypeMap typeMap; - // TODO: remove table parameters if possible - // TODO: remove action parameters if possible + // TODO: remove table parameters + // TODO: remove action in/out/inout parameters // TODO: remove expressions in table key // TODO: break down expression into simple parts // TODO: def-use analysis @@ -45,7 +45,7 @@ P4::BlockMap* MidEnd::process(CompilerOptions& options, const IR::P4Program* pro // Move all local declarations to the beginning new P4::MoveDeclarations(), new P4::ResolveReferences(&refMap, isv1), - new P4::RemoveReturns(&refMap, true), + new P4::RemoveReturns(&refMap), // Move some constructor calls into temporaries new P4::MoveConstructors(isv1), new P4::RemoveAllUnusedDeclarations(&refMap, isv1), @@ -54,8 +54,7 @@ P4::BlockMap* MidEnd::process(CompilerOptions& options, const IR::P4Program* pro simplify.setName("Simplify"); simplify.setStopOnError(true); - for (auto h : hooks) - simplify.addDebugHook(h); + simplify.addDebugHooks(hooks); program = program->apply(simplify); if (::errorCount() > 0) return nullptr; @@ -83,8 +82,8 @@ P4::BlockMap* MidEnd::process(CompilerOptions& options, const IR::P4Program* pro new P4::RemoveAllUnusedDeclarations(&refMap, isv1), new P4::TypeChecking(&refMap, &typeMap, isv1), new P4::SimplifyControlFlow(&refMap, &typeMap), - new P4::ResolveReferences(&refMap, isv1), - new P4::RemoveReturns(&refMap, false), // remove exits: FIXME: currently incorrect + new P4::TypeChecking(&refMap, &typeMap, isv1), + new P4::RemoveExits(&refMap, &typeMap), // FIXME: currently incorrect new P4::TypeChecking(&refMap, &typeMap, isv1), new P4::ConstantFolding(&refMap, &typeMap), new P4::StrengthReduction(), @@ -103,16 +102,11 @@ P4::BlockMap* MidEnd::process(CompilerOptions& options, const IR::P4Program* pro }; midEnd.setName("MidEnd"); midEnd.setStopOnError(true); - for (auto h : hooks) - midEnd.addDebugHook(h); + midEnd.addDebugHooks(hooks); program = program->apply(midEnd); if (::errorCount() > 0) return nullptr; - std::ostream *midendStream = options.dumpStream("-midend"); - P4::ToP4 top4(midendStream, false, options.file); - program->apply(top4); - blockMap = evaluator->getBlockMap(); return blockMap; } diff --git a/backends/v12test/options.cpp b/backends/v12test/options.cpp deleted file mode 100644 index 42e310d6f10..00000000000 --- a/backends/v12test/options.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "options.h" - -namespace V12Test { - -V12TestOptions::V12TestOptions() : top4(nullptr) { - registerOption("--top4", "regex", - [this](const char* arg) { top4 = arg; return true; }, - "[Compiler debugging] Dump the P4 representation after\n" - "passes matching regex"); -} - -} // namespace V12Test diff --git a/backends/v12test/options.h b/backends/v12test/options.h deleted file mode 100644 index 80639ae039a..00000000000 --- a/backends/v12test/options.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef _BACKENDS_V12TEST_OPTIONS_H_ -#define _BACKENDS_V12TEST_OPTIONS_H_ - -#include "frontends/common/options.h" - -namespace V12Test { - -class V12TestOptions : public CompilerOptions { - public: - V12TestOptions(); - const char* top4; // regular expression matching pass names -}; - -} // namespace V12Test - -#endif /* _BACKENDS_V12TEST_OPTIONS_H_ */ diff --git a/backends/v12test/run-v12-sample.py b/backends/v12test/run-v12-sample.py index 31fb9f8b609..b5658718d6f 100755 --- a/backends/v12test/run-v12-sample.py +++ b/backends/v12test/run-v12-sample.py @@ -106,7 +106,7 @@ def compare_files(options, produced, expected): continue if ignoreNextMarker: ignoreNextMarker = False - if marker.match(l): + if marker.match(l): continue if l[0] == ' ': continue result = FAILURE @@ -154,16 +154,17 @@ def process_file(options, argv): base, ext = os.path.splitext(basename) dirname = os.path.dirname(options.p4filename) expected_dirname = dirname + "_outputs" # expected outputs are here - + if options.verbose: print("Writing temporary files into ", tmpdir) ppfile = tmpdir + "/" + basename # after parsing - lastfile = tmpdir + "/" + base + "-last" + ext # last file produced + referenceOutputs = "FrontEnd_11,FrontEnd_12,MidEnd_25" + lastfile = tmpdir + "/" + base + "-FrontEnd_12_RemoveAllUnusedDeclarations" + ext # last file produced by front-end stderr = tmpdir + "/" + basename + "-stderr" if not os.path.isfile(options.p4filename): raise Exception("No such file " + options.p4filename) - args = ["./v12test", "--pp", ppfile, "--dump", tmpdir] + options.compilerOptions + args = ["./v12test", "--pp", ppfile, "--dump", tmpdir, "--top4", referenceOutputs] + options.compilerOptions if "v1_samples" in options.p4filename: args.extend(["--p4v", "1.0"]); args.extend(argv) diff --git a/backends/v12test/v12test.cpp b/backends/v12test/v12test.cpp index 039b839ef7d..a27afbab22d 100644 --- a/backends/v12test/v12test.cpp +++ b/backends/v12test/v12test.cpp @@ -1,8 +1,3 @@ -#include -#include -#include -#include - #include "ir/ir.h" #include "lib/log.h" #include "lib/error.h" @@ -13,51 +8,13 @@ #include "frontends/p4/evaluator/evaluator.h" #include "frontends/p4/frontend.h" #include "frontends/p4/toP4/toP4.h" -#include "options.h" #include "midend.h" -class PrintDump { - V12Test::V12TestOptions& options; - std::regex* regex = nullptr; - bool verbose; - - public: - explicit PrintDump(V12Test::V12TestOptions& options) : - options(options), verbose(options.verbosity > 0) { - if (options.top4 != nullptr) { - cstring r = cstring(".*") + options.top4 + ".*"; - regex = new std::regex(r.c_str()); - } - } - void printPass(const char* manager, unsigned seq, const char* pass, const IR::Node* node) { - // Pass names are currently C++ class names mangled; this is a weak attempt at making them - // more readable. - std::string p = pass; - size_t last = p.find_last_of("0123456789", strlen(pass) - 3); - if (last != strlen(pass)) - pass = pass + last + 1; - cstring name = cstring(manager) + "_" + Util::toString(seq) + "_" + pass; - std::cerr << name << std::endl; - - if (regex != nullptr) { - bool match = std::regex_match(name.c_str(), *regex); - if (match) { - auto stream = options.dumpStream(name); - if (verbose) - std::cerr << "Writing program to " << options.dumpFileName(name) << std::endl; - P4::ToP4 toP4(stream, true); - node->apply(toP4); - } - } - } -}; - - int main(int argc, char *const argv[]) { setup_gc_logging(); setup_signals(); - V12Test::V12TestOptions options; + CompilerOptions options; options.langVersion = CompilerOptions::FrontendVersion::P4v1_2; if (options.process(argc, argv) != nullptr) @@ -65,20 +22,16 @@ int main(int argc, char *const argv[]) { if (::errorCount() > 0) return 1; - PrintDump pd(options); - auto dp = std::bind(&PrintDump::printPass, &pd, - std::placeholders::_1, std::placeholders::_2, - std::placeholders::_3, std::placeholders::_4); auto program = parseP4File(options); + auto hook = options.getDebugHook(); + if (program != nullptr && ::errorCount() == 0) { FrontEnd fe; - if (::verbose) - fe.addDebugHook(dp); + fe.addDebugHook(hook); program = fe.run(options, program); if (program != nullptr && ::errorCount() == 0) { V12Test::MidEnd midEnd; - if (::verbose) - midEnd.addDebugHook(dp); + midEnd.addDebugHook(hook); (void)midEnd.process(options, program); } } diff --git a/frontends/common/options.cpp b/frontends/common/options.cpp index 0b2b93dfea0..afc90022cda 100644 --- a/frontends/common/options.cpp +++ b/frontends/common/options.cpp @@ -6,8 +6,9 @@ #include "lib/exceptions.h" #include "lib/nullstream.h" #include "lib/path.h" +#include "frontends/p4/toP4/toP4.h" -static cstring version = "0.0.3"; +static cstring version = "0.0.4"; extern int verbose; const char* CompilerOptions::defaultMessage = "Compile a P4 program"; @@ -45,8 +46,7 @@ CompilerOptions::CompilerOptions() : Util::Options(defaultMessage) { } else if (!strcmp(arg, "1.2")) { langVersion = CompilerOptions::FrontendVersion::P4v1_2; } else { - std::cerr << "Illegal language version " << arg << std::endl; - usage(); + ::error("Illegal language version %1%", arg); return false; } return true; }, @@ -60,17 +60,36 @@ CompilerOptions::CompilerOptions() : Util::Options(defaultMessage) { "specified file (output is always in P4 v1.2)."); registerOption("-o", "outfile", [this](const char* arg) { outputFile = arg; return true; }, - "Write output program to outfile"); + "Write output to outfile"); registerOption("-T", "loglevel", [](const char* arg) { ::add_debug_spec(arg); return true; }, "[Compiler debugging] Adjust logging level per file (see below)"); - registerOption("--dump", "folder", - [this](const char* arg) { dumpFolder = arg; return true; }, - "[Compiler debugging] Dump the program after various passes in\n" - "P4 files in the specified folder."); registerOption("-v", nullptr, [this](const char*) { ::verbose++; verbosity++; return true; }, "[Compiler debugging] Increase verbosity level (can be repeated)"); + registerOption("--top4", "pass1[,pass2]", + [this](const char* arg) { + auto copy = new char[strlen(arg)+1]; + strcpy(copy, arg); + while (*copy) { + char* next = strchr(copy, ','); + if (next == nullptr) { + top4.push_back(copy); + break; + } else { + *next = 0; + top4.push_back(copy); + copy = next + 1; + } + } + return true; + }, + "[Compiler debugging] Dump the P4 representation after\n" + "passes whose name contains one of `passX' substrings.\n" + "When '-v' is used this will include the compiler IR.\n"); + registerOption("--dump", "folder", + [this](const char* arg) { dumpFolder = arg; return true; }, + "[Compiler debugging] Folder where P4 programs are dumped\n"); registerUsage("loglevel format is:\n" " sourceFile:level,...,sourceFile:level\n" "where 'sourceFile' is a compiler source file and\n" @@ -148,21 +167,45 @@ static cstring makeFileName(cstring folder, cstring name, cstring baseSuffix) { return result.toString(); } -cstring CompilerOptions::dumpFileName(cstring suffix) const { - if (dumpFolder.isNullOrEmpty()) - return nullptr; - cstring filename = file; - if (filename == "-") - filename = "tmp.p4"; - return makeFileName(dumpFolder, filename, suffix); +bool CompilerOptions::isv1() const { + return langVersion == CompilerOptions::FrontendVersion::P4v1; } -std::ostream* CompilerOptions::dumpStream(cstring suffix) const { - if (dumpFolder.isNullOrEmpty()) - return new nullstream(); - return openFile(dumpFileName(suffix), true); +void CompilerOptions::dumpPass(const char* manager, unsigned seq, const char* pass, const IR::Node* node) const { + // Pass names are currently C++ class names mangled; this is a weak attempt at making them + // more readable. + bool verbose = verbosity > 0; + + std::string p = pass; + size_t last = p.find_last_of("0123456789", strlen(pass) - 3); + if (last != strlen(pass)) + pass = pass + last + 1; + cstring name = cstring(manager) + "_" + Util::toString(seq) + "_" + pass; + if (verbose) + std::cerr << name << std::endl; + + for (auto s : top4) { + if (strstr(name.c_str(), s.c_str()) != nullptr) { + cstring suffix = cstring("-") + name; + cstring filename = file; + if (filename == "-") + filename = "tmp.p4"; + + cstring fileName = makeFileName(dumpFolder, filename, suffix); + auto stream = openFile(fileName, true); + if (stream != nullptr) { + if (verbose) + std::cerr << "Writing program to " << fileName << std::endl; + P4::ToP4 toP4(stream, verbose); + node->apply(toP4); + } + } + } } -bool CompilerOptions::isv1() const { - return langVersion == CompilerOptions::FrontendVersion::P4v1; +DebugHook CompilerOptions::getDebugHook() const { + auto dp = std::bind(&CompilerOptions::dumpPass, this, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3, std::placeholders::_4); + return dp; } diff --git a/frontends/common/options.h b/frontends/common/options.h index 5e5217fe776..7b2c99c836d 100644 --- a/frontends/common/options.h +++ b/frontends/common/options.h @@ -3,8 +3,10 @@ #ifndef FRONTENDS_COMMON_OPTIONS_H_ #define FRONTENDS_COMMON_OPTIONS_H_ +#include #include "lib/cstring.h" #include "lib/options.h" +#include "ir/ir.h" // for DebugHook definition // Base class for compiler options. // This class contains the options for the front-ends. @@ -13,6 +15,10 @@ class CompilerOptions : public Util::Options { bool close_input = false; static const char* defaultMessage; + protected: + // Function that is returned by getDebugHook. + void dumpPass(const char* manager, unsigned seq, const char* pass, const IR::Node* node) const; + public: CompilerOptions(); @@ -31,9 +37,9 @@ class CompilerOptions : public Util::Options { cstring file = nullptr; // if true preprocess only bool doNotCompile = false; - // (V1.2 only) dump program after each pass in the specified folder - cstring dumpFolder = nullptr; - // (V1.2 only) Pretty-print the program in the specified file + // debugging dumps of programs written in this folder + cstring dumpFolder = "."; + // Pretty-print the program in the specified file cstring prettyPrintFile = nullptr; // file to output to cstring outputFile = nullptr; @@ -41,6 +47,8 @@ class CompilerOptions : public Util::Options { unsigned verbosity = 0; // Compiler target architecture cstring target = nullptr; + // substrings matched agains pass names + std::vector top4; // Expect that the only remaining argument is the input file. void setInputFile(); @@ -50,14 +58,11 @@ class CompilerOptions : public Util::Options { // Closes the input stream returned by preprocess. void closeInput(FILE* input) const; - // Returns a stream for dumping some information - // based on the dumpFolder. If dumpFolder is not set, - // returns a nullstream, i.e., /dev/null. - std::ostream* dumpStream(cstring suffix) const; - // Name of file that is used for dumpStream(suffix) - cstring dumpFileName(cstring suffix) const; // True if we are compiling a P4 v1.0 or v1.1 program bool isv1() const; + // Get a debug hook function suitable for insertion + // in the pass managers that are executed. + DebugHook getDebugHook() const; }; #endif /* FRONTENDS_COMMON_OPTIONS_H_ */ diff --git a/frontends/p4/evaluator/evaluator.cpp b/frontends/p4/evaluator/evaluator.cpp index 758671b54b7..6e81b0391de 100644 --- a/frontends/p4/evaluator/evaluator.cpp +++ b/frontends/p4/evaluator/evaluator.cpp @@ -248,8 +248,7 @@ EvaluatorPass::EvaluatorPass(bool anyOrder) : refMap(new ReferenceMap), typeMap(new TypeMap()), blockMap(new BlockMap(refMap, typeMap)) { setName("Evaluator"); setStopOnError(true); - passes.emplace_back(new P4::ResolveReferences(refMap, anyOrder)); - passes.emplace_back(new P4::TypeInference(refMap, typeMap)); + passes.emplace_back(new P4::TypeChecking(refMap, typeMap, anyOrder)); passes.emplace_back(new P4::Evaluator(blockMap)); } diff --git a/frontends/p4/frontend.cpp b/frontends/p4/frontend.cpp index fd1995017e5..7dcfdc1d5f0 100644 --- a/frontends/p4/frontend.cpp +++ b/frontends/p4/frontend.cpp @@ -29,8 +29,6 @@ FrontEnd::run(const CompilerOptions &options, const IR::P4Program* v12_program) Util::PathName path(options.prettyPrintFile); std::ostream *ppStream = openFile(path.toString(), true); - std::ostream *midStream = options.dumpStream("-fe"); - std::ostream *endStream = options.dumpStream("-last"); P4::ReferenceMap refMap; // This is reused many times, since every analysis clear it P4::TypeMap typeMap; @@ -55,17 +53,12 @@ FrontEnd::run(const CompilerOptions &options, const IR::P4Program* v12_program) new P4::StrengthReduction(), new P4::TypeChecking(&refMap, &typeMap, isv1), new P4::SimplifyControlFlow(&refMap, &typeMap), - // Print program in the middle - new P4::ToP4(midStream, false, options.file), new P4::RemoveAllUnusedDeclarations(&refMap, isv1), - // Print the program before the end. - new P4::ToP4(endStream, false, options.file), }; passes.setName("FrontEnd"); passes.setStopOnError(true); - for (auto h : hooks) - passes.addDebugHook(h); + passes.addDebugHooks(hooks); const IR::P4Program* result = v12_program->apply(passes); return result; } diff --git a/frontends/p4/toP4/toP4.cpp b/frontends/p4/toP4/toP4.cpp index 1b71bc4150a..da3a3dc1945 100644 --- a/frontends/p4/toP4/toP4.cpp +++ b/frontends/p4/toP4/toP4.cpp @@ -36,7 +36,6 @@ class DumpIR : public Inspector { } void display(const IR::Node* node) { str << IndentCtl::endl; - cstring tn = node->node_type_name(); if (node->is()) { node->Node::dbprint(str); str << node->to()->member; @@ -48,8 +47,7 @@ class DumpIR : public Inspector { node->is() || node->is() || node->is() || - tn.startsWith("Vector") || - tn.startsWith("IndexedVector")) { + node->is()) { node->Node::dbprint(str); } else { str << node; diff --git a/ir/dbprint.cpp b/ir/dbprint.cpp index b4e1a4d8f39..7a02c8e17c0 100644 --- a/ir/dbprint.cpp +++ b/ir/dbprint.cpp @@ -113,7 +113,7 @@ void IR::TypeParameters::dbprint(std::ostream& out) const { } void IR::Type_Table::dbprint(std::ostream& out) const -{ Node::dbprint(out); out << container->name; } +{ Node::dbprint(out); out << table->name; } std::ostream &operator<<(std::ostream &out, const IR::Vector &v) { int prec = getprec(out); diff --git a/ir/ir.cpp b/ir/ir.cpp index 9e3f865ce29..1fc19bd32bc 100644 --- a/ir/ir.cpp +++ b/ir/ir.cpp @@ -102,34 +102,35 @@ Type_Control::getApplyMethodType() const { } const Type_Method* -Type_Table::getApplyMethodType() const { - if (applyMethod == nullptr) { - // Let's synthesize a new type for the return - auto actions = container->properties->getProperty(IR::TableProperties::actionsPropertyName); - if (actions == nullptr) { - ::error("Table %1% does not contain a list of actions", container); - return nullptr; - } - if (!actions->value->is()) - BUG("Action property is not an IR::ActionList, but %1%", - actions); - auto alv = actions->value->to(); - auto fields = new IR::IndexedVector(); - auto hit = new IR::StructField(Util::SourceInfo(), IR::Type_Table::hit, - IR::Annotations::empty, IR::Type_Boolean::get()); - fields->push_back(hit); - auto label = new IR::StructField(Util::SourceInfo(), IR::Type_Table::action_run, - IR::Annotations::empty, - new IR::Type_ActionEnum(Util::SourceInfo(), alv)); - fields->push_back(label); - auto rettype = new IR::Type_Struct(Util::SourceInfo(), ID(container->name), - IR::Annotations::empty, fields); - applyMethod = new IR::Type_Method(Util::SourceInfo(), new TypeParameters(), - rettype, container->parameters); +P4Table::getApplyMethodType() const { + // Synthesize a new type for the return + auto actions = properties->getProperty(IR::TableProperties::actionsPropertyName); + if (actions == nullptr) { + ::error("Table %1% does not contain a list of actions", this); + return nullptr; } + if (!actions->value->is()) + BUG("Action property is not an IR::ActionList, but %1%", + actions); + auto alv = actions->value->to(); + auto fields = new IR::IndexedVector(); + auto hit = new IR::StructField(Util::SourceInfo(), IR::Type_Table::hit, + IR::Annotations::empty, IR::Type_Boolean::get()); + fields->push_back(hit); + auto label = new IR::StructField(Util::SourceInfo(), IR::Type_Table::action_run, + IR::Annotations::empty, + new IR::Type_ActionEnum(Util::SourceInfo(), alv)); + fields->push_back(label); + auto rettype = new IR::Type_Struct(Util::SourceInfo(), ID(name), + IR::Annotations::empty, fields); + auto applyMethod = new IR::Type_Method(Util::SourceInfo(), new TypeParameters(), + rettype, parameters); return applyMethod; } +const Type_Method* Type_Table::getApplyMethodType() const +{ return table->getApplyMethodType(); } + void InstantiatedBlock::instantiate(std::vector *args) { CHECK_NULL(args); auto it = args->begin(); diff --git a/ir/ir.def b/ir/ir.def index 5bc6d40db82..88ae687e84b 100644 --- a/ir/ir.def +++ b/ir/ir.def @@ -230,12 +230,13 @@ class TableProperties : ISimpleNamespace { validate{ properties->check_null(); } } -class P4Table : Declaration, IAnnotated { +class P4Table : Declaration, IAnnotated, IApply { Annotations annotations; ParameterList parameters; TableProperties properties; #emit const Annotations* getAnnotations() const override { return annotations; } + const Type_Method* getApplyMethodType() const; const ActionList* getActionList() const { auto ap = properties->getProperty(TableProperties::actionsPropertyName); if (ap == nullptr) diff --git a/ir/pass_manager.h b/ir/pass_manager.h index 983afcc603a..4f4e6f98d10 100644 --- a/ir/pass_manager.h +++ b/ir/pass_manager.h @@ -25,6 +25,8 @@ class PassManager : virtual public Visitor { const IR::Node *apply_visitor(const IR::Node *, const char * = 0) override; void setStopOnError(bool stop) { stop_on_error = stop; } void addDebugHook(DebugHook h) { debugHooks.push_back(h); } + void addDebugHooks(std::vector hooks) + { debugHooks.insert(debugHooks.end(), hooks.begin(), hooks.end()); } const char* name() const override { return managerName != nullptr ? managerName : Visitor::name(); } }; @@ -39,6 +41,7 @@ class PassRepeated : virtual public PassManager { void setRepeats(unsigned repeats) { this->repeats = repeats; } }; +// Converts a function Node* -> Node* into a visitor class VisitFunctor : virtual public Visitor { std::function fn; const IR::Node *apply_visitor(const IR::Node *n, const char * = 0) override { return fn(n); } diff --git a/ir/type.def b/ir/type.def index f831b82673b..8e8a2ca7928 100644 --- a/ir/type.def +++ b/ir/type.def @@ -377,9 +377,8 @@ class Type_Enum : Type_Declaration, ISimpleNamespace { } class Type_Table : Type, IApply { - P4Table container; + P4Table table; #emit - mutable const Type_Method* applyMethod = nullptr; // type of the apply method cached here const Type_Method* getApplyMethodType() const; // names for the fields of the struct returned // by applying a table diff --git a/lib/options.h b/lib/options.h index cc63d452418..3c580b087e8 100644 --- a/lib/options.h +++ b/lib/options.h @@ -100,14 +100,19 @@ class Options { remainingOptions.push_back(opt); } else { if (option->argName != nullptr && arg == nullptr) { - if (i == argc - 1) - throw std::logic_error(std::string("Option ") + opt + - " is missing required argument " + option->argName); + if (i == argc - 1) { + ::error("Option %1% is missing required argument %2%", + opt, option->argName); + usage(); + return nullptr; + } arg = argv[++i]; } bool success = option->processor(arg); - if (!success) - break; + if (!success) { + usage(); + return nullptr; + } } } return &remainingOptions; diff --git a/midend/removeReturns.cpp b/midend/removeReturns.cpp index 05707d0017d..c02fa1b9a7d 100644 --- a/midend/removeReturns.cpp +++ b/midend/removeReturns.cpp @@ -1,4 +1,5 @@ #include "removeReturns.h" +#include "frontends/p4/methodInstance.h" namespace P4 { @@ -23,14 +24,12 @@ const IR::Node* RemoveReturns::preorder(IR::P4Action* action) { // 'hasExits' variable should be in the calling control. HasExits he; (void)action->apply(he); - if ((removeReturns && !he.hasReturns) || - (!removeReturns && !he.hasExits)) { + if (!he.hasReturns) { // don't pollute the code unnecessarily prune(); return action; } - cstring base = removeReturns ? "hasReturned" : "hasExited"; - cstring var = refMap->newName(base); + cstring var = refMap->newName(variableName); returnVar = IR::ID(var); auto f = new IR::BoolLiteral(Util::SourceInfo(), false); auto decl = new IR::Declaration_Variable(Util::SourceInfo(), returnVar, @@ -52,15 +51,13 @@ const IR::Node* RemoveReturns::preorder(IR::P4Action* action) { const IR::Node* RemoveReturns::preorder(IR::P4Control* control) { HasExits he; (void)control->body->apply(he); - if ((removeReturns && !he.hasReturns) || - (!removeReturns && !he.hasExits)) { + if (!he.hasReturns) { // don't pollute the code unnecessarily prune(); return control; } - cstring base = removeReturns ? "hasReturned" : "hasExited"; - cstring var = refMap->newName(base); + cstring var = refMap->newName(variableName); returnVar = IR::ID(var); auto f = new IR::BoolLiteral(Util::SourceInfo(), false); auto decl = new IR::Declaration_Variable(Util::SourceInfo(), returnVar, @@ -81,22 +78,15 @@ const IR::Node* RemoveReturns::preorder(IR::P4Control* control) { } const IR::Node* RemoveReturns::preorder(IR::ReturnStatement* statement) { - if (removeReturns) { - set(Returns::Yes); - auto left = new IR::PathExpression(returnVar); - return new IR::AssignmentStatement(statement->srcInfo, left, - new IR::BoolLiteral(Util::SourceInfo(), true)); - } + set(Returns::Yes); + auto left = new IR::PathExpression(returnVar); + return new IR::AssignmentStatement(statement->srcInfo, left, + new IR::BoolLiteral(Util::SourceInfo(), true)); return statement; } const IR::Node* RemoveReturns::preorder(IR::ExitStatement* statement) { set(Returns::Yes); // exit implies return - if (!removeReturns) { - auto left = new IR::PathExpression(returnVar); - return new IR::AssignmentStatement(statement->srcInfo, left, - new IR::BoolLiteral(Util::SourceInfo(), true)); - } return statement; } @@ -168,4 +158,52 @@ const IR::Node* RemoveReturns::preorder(IR::SwitchStatement* statement) { return statement; } +//////////////////////////////////////////////////////////////// + +namespace { +class CallsExit : public Inspector { + ReferenceMap* refMap; + TypeMap* typeMap; + std::set* callers; + + public: + bool callsExit = false; + CallsExit(ReferenceMap* refMap, TypeMap* typeMap, std::set* callers) : + refMap(refMap), typeMap(typeMap), callers(callers) {} + void postorder(const IR::MethodCallExpression* expression) override { + auto mi = MethodInstance::resolve(expression, refMap, typeMap); + if (!mi->isApply()) + return; + auto am = mi->to(); + CHECK_NULL(am->object); + auto obj = am->object->getNode(); + if (callers->find(obj) != callers->end()) + callsExit = true; + } +}; +} // namespace + +const IR::Node* RemoveExits::preorder(IR::ExitStatement* statement) { + auto action = findOrigCtxt(); + if (action != nullptr) { + LOG4(getOriginal() << " calls exit"); + callsExit.emplace(action); + } + return statement; +} + +const IR::Node* RemoveExits::preorder(IR::P4Table* table) { + for (auto a : *table->getActionList()->actionList) { + auto path = a->name; + auto decl = refMap->getDeclaration(path->path, true); + BUG_CHECK(decl->is(), "%1% is not an action", decl); + if (callsExit.find(decl->getNode()) != callsExit.end()) { + LOG4(getOriginal() << " calls exit"); + callsExit.emplace(getOriginal()); + break; + } + } + return table; +} + } // namespace P4 diff --git a/midend/removeReturns.h b/midend/removeReturns.h index 694f3a4414a..3a2cae88094 100644 --- a/midend/removeReturns.h +++ b/midend/removeReturns.h @@ -2,15 +2,17 @@ #define _MIDEND_REMOVERETURNS_H_ #include "ir/ir.h" -#include "frontends/common/resolveReferences/resolveReferences.h" +#include "frontends/common/resolveReferences/referenceMap.h" +#include "frontends/common/typeMap.h" namespace P4 { // This replaces 'returns' and/or 'exits' by ifs class RemoveReturns : public Transform { + protected: P4::ReferenceMap* refMap; - bool removeReturns; // if true remove returns, else remove exits IR::ID returnVar; // one for each context + cstring variableName; enum class Returns { Yes, @@ -25,8 +27,8 @@ class RemoveReturns : public Transform { Returns hasReturned() { BUG_CHECK(!stack.empty(), "Empty stack"); return stack.back(); } public: - explicit RemoveReturns(P4::ReferenceMap* refMap, bool removeReturns = true) : - refMap(refMap), removeReturns(removeReturns) {} + explicit RemoveReturns(P4::ReferenceMap* refMap, cstring varName = "hasReturned") : + refMap(refMap), variableName(varName) { CHECK_NULL(refMap); } const IR::Node* preorder(IR::Function* function) override { prune(); return function; } // We leave returns in functions alone @@ -40,6 +42,17 @@ class RemoveReturns : public Transform { const IR::Node* preorder(IR::P4Control* control) override; }; +class RemoveExits : public RemoveReturns { + std::set callsExit; // actions, tables + TypeMap* typeMap; + public: + explicit RemoveExits(ReferenceMap* refMap, TypeMap* typeMap) : + RemoveReturns(refMap, "hasExited"), typeMap(typeMap) { CHECK_NULL(typeMap); } + + const IR::Node* preorder(IR::ExitStatement* action) override; + const IR::Node* preorder(IR::P4Table* table) override; +}; + } // namespace P4 #endif /* _MIDEND_REMOVERETURNS_H_ */ diff --git a/testdata/v1_2_errors_outputs/persistent_e-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_2_errors_outputs/persistent_e-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..9fbcd031f2b --- /dev/null +++ b/testdata/v1_2_errors_outputs/persistent_e-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,15 @@ +control p()(bit<1> y) { + apply { + } +} + +control q(in bit<1> z) { + p(z) p1; + apply { + p1.apply(); + } +} + +control simple(in bit<1> z); +package m(simple s); +m(q()) main; diff --git a/testdata/v1_2_errors_outputs/persistent_e-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_2_errors_outputs/persistent_e-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..9fbcd031f2b --- /dev/null +++ b/testdata/v1_2_errors_outputs/persistent_e-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,15 @@ +control p()(bit<1> y) { + apply { + } +} + +control q(in bit<1> z) { + p(z) p1; + apply { + p1.apply(); + } +} + +control simple(in bit<1> z); +package m(simple s); +m(q()) main; diff --git a/testdata/v1_2_samples_outputs/action-uses-fe.p4 b/testdata/v1_2_samples_outputs/action-uses-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/action-uses-fe.p4 rename to testdata/v1_2_samples_outputs/action-uses-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/action-uses-last.p4 b/testdata/v1_2_samples_outputs/action-uses-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/action-uses-last.p4 rename to testdata/v1_2_samples_outputs/action-uses-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/action-uses-midend.p4 b/testdata/v1_2_samples_outputs/action-uses-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/action-uses-midend.p4 rename to testdata/v1_2_samples_outputs/action-uses-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/actionAnnotations-fe.p4 b/testdata/v1_2_samples_outputs/actionAnnotations-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 99% rename from testdata/v1_2_samples_outputs/actionAnnotations-fe.p4 rename to testdata/v1_2_samples_outputs/actionAnnotations-FrontEnd_11_SimplifyControlFlowE.p4 index fda7e0aa81e..a9982637c7d 100644 --- a/testdata/v1_2_samples_outputs/actionAnnotations-fe.p4 +++ b/testdata/v1_2_samples_outputs/actionAnnotations-FrontEnd_11_SimplifyControlFlowE.p4 @@ -10,7 +10,6 @@ control test() { } default_action = drop; } - apply { } } diff --git a/testdata/v1_2_samples_outputs/actionAnnotations-last.p4 b/testdata/v1_2_samples_outputs/actionAnnotations-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/actionAnnotations-last.p4 rename to testdata/v1_2_samples_outputs/actionAnnotations-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/actionAnnotations.p4 b/testdata/v1_2_samples_outputs/actionAnnotations.p4 index fda7e0aa81e..a9982637c7d 100644 --- a/testdata/v1_2_samples_outputs/actionAnnotations.p4 +++ b/testdata/v1_2_samples_outputs/actionAnnotations.p4 @@ -10,7 +10,6 @@ control test() { } default_action = drop; } - apply { } } diff --git a/testdata/v1_2_samples_outputs/after-return-fe.p4 b/testdata/v1_2_samples_outputs/after-return-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/after-return-fe.p4 rename to testdata/v1_2_samples_outputs/after-return-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/after-return-last.p4 b/testdata/v1_2_samples_outputs/after-return-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/after-return-last.p4 rename to testdata/v1_2_samples_outputs/after-return-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/after-return-midend.p4 b/testdata/v1_2_samples_outputs/after-return-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/after-return-midend.p4 rename to testdata/v1_2_samples_outputs/after-return-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/annotations-fe.p4 b/testdata/v1_2_samples_outputs/annotations-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/annotations-fe.p4 rename to testdata/v1_2_samples_outputs/annotations-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/annotations-last.p4 b/testdata/v1_2_samples_outputs/annotations-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/annotations-last.p4 rename to testdata/v1_2_samples_outputs/annotations-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/apply-fe.p4 b/testdata/v1_2_samples_outputs/apply-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/apply-fe.p4 rename to testdata/v1_2_samples_outputs/apply-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/apply-last.p4 b/testdata/v1_2_samples_outputs/apply-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/apply-last.p4 rename to testdata/v1_2_samples_outputs/apply-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/apply-midend.p4 b/testdata/v1_2_samples_outputs/apply-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/apply-midend.p4 rename to testdata/v1_2_samples_outputs/apply-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/apply-cf-fe.p4 b/testdata/v1_2_samples_outputs/apply-cf-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/apply-cf-fe.p4 rename to testdata/v1_2_samples_outputs/apply-cf-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/apply-cf-last.p4 b/testdata/v1_2_samples_outputs/apply-cf-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/apply-cf-last.p4 rename to testdata/v1_2_samples_outputs/apply-cf-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/arith-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_2_samples_outputs/arith-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..65f52e33bd7 --- /dev/null +++ b/testdata/v1_2_samples_outputs/arith-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,181 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr { + bit<32> a; + bit<32> b; + bit<64> c; +} + +struct Headers { + hdr h; +} + +struct Meta { +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + b.extract(h.h); + transition accept; + } +} + +control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control update(inout Headers h, inout Meta m) { + apply { + } +} + +control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control deparser(packet_out b, in Headers h) { + apply { + b.emit(h.h); + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + action add() { + h.h.c = (bit<64>)(h.h.a + h.h.b); + sm.egress_spec = 9w0; + } + table t() { + actions = { + add; + } + const default_action = add; + } + apply { + t.apply(); + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_2_samples_outputs/arith-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..0d33d20d37f --- /dev/null +++ b/testdata/v1_2_samples_outputs/arith-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,163 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr { + bit<32> a; + bit<32> b; + bit<64> c; +} + +struct Headers { + hdr h; +} + +struct Meta { +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + b.extract(h.h); + transition accept; + } +} + +control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control update(inout Headers h, inout Meta m) { + apply { + } +} + +control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control deparser(packet_out b, in Headers h) { + apply { + b.emit(h.h); + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + action add() { + h.h.c = (bit<64>)(h.h.a + h.h.b); + sm.egress_spec = 9w0; + } + table t() { + actions = { + add; + } + const default_action = add; + } + apply { + t.apply(); + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith-bmv2-MidEnd_25_Evaluator.p4 b/testdata/v1_2_samples_outputs/arith-bmv2-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..bb03523f330 --- /dev/null +++ b/testdata/v1_2_samples_outputs/arith-bmv2-MidEnd_25_Evaluator.p4 @@ -0,0 +1,163 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr { + bit<32> a; + bit<32> b; + bit<64> c; +} + +struct Headers { + hdr h; +} + +struct Meta { +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + b.extract(h.h); + transition accept; + } +} + +control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control update(inout Headers h, inout Meta m) { + apply { + } +} + +control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control deparser(packet_out b, in Headers h) { + apply { + b.emit(h.h); + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + @name("add") action add_0() { + h.h.c = (bit<64>)(h.h.a + h.h.b); + sm.egress_spec = 9w0; + } + @name("t") table t_0() { + actions = { + add_0; + } + const default_action = add_0; + } + apply { + t_0.apply(); + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith-bmv2-fe.p4 b/testdata/v1_2_samples_outputs/arith-bmv2-fe.p4 deleted file mode 100644 index 123f77badcb..00000000000 --- a/testdata/v1_2_samples_outputs/arith-bmv2-fe.p4 +++ /dev/null @@ -1,62 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr { - bit<32> a; - bit<32> b; - bit<64> c; -} - -struct Headers { - hdr h; -} - -struct Meta { -} - -parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { - state start { - b.extract(h.h); - transition accept; - } -} - -control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out b, in Headers h) { - apply { - b.emit(h.h); - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - action add() { - h.h.c = (bit<64>)(h.h.a + h.h.b); - sm.egress_spec = 9w0; - } - table t() { - actions = { - add; - } - const default_action = add; - } - - apply { - t.apply(); - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith-bmv2-last.p4 b/testdata/v1_2_samples_outputs/arith-bmv2-last.p4 deleted file mode 100644 index 123f77badcb..00000000000 --- a/testdata/v1_2_samples_outputs/arith-bmv2-last.p4 +++ /dev/null @@ -1,62 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr { - bit<32> a; - bit<32> b; - bit<64> c; -} - -struct Headers { - hdr h; -} - -struct Meta { -} - -parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { - state start { - b.extract(h.h); - transition accept; - } -} - -control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out b, in Headers h) { - apply { - b.emit(h.h); - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - action add() { - h.h.c = (bit<64>)(h.h.a + h.h.b); - sm.egress_spec = 9w0; - } - table t() { - actions = { - add; - } - const default_action = add; - } - - apply { - t.apply(); - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith-bmv2-midend.p4 b/testdata/v1_2_samples_outputs/arith-bmv2-midend.p4 deleted file mode 100644 index 4110ed97cf7..00000000000 --- a/testdata/v1_2_samples_outputs/arith-bmv2-midend.p4 +++ /dev/null @@ -1,61 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr { - bit<32> a; - bit<32> b; - bit<64> c; -} - -struct Headers { - hdr h; -} - -struct Meta { -} - -parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { - state start { - b.extract(h.h); - transition accept; - } -} - -control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out b, in Headers h) { - apply { - b.emit(h.h); - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - @name("add") action add_0() { - h.h.c = (bit<64>)(h.h.a + h.h.b); - sm.egress_spec = 9w0; - } - @name("t") table t_0() { - actions = { - add_0; - } - const default_action = add_0; - } - apply { - t_0.apply(); - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith-bmv2.p4 b/testdata/v1_2_samples_outputs/arith-bmv2.p4 index 56d702f599d..a7a7b980f32 100644 --- a/testdata/v1_2_samples_outputs/arith-bmv2.p4 +++ b/testdata/v1_2_samples_outputs/arith-bmv2.p4 @@ -53,7 +53,6 @@ control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { } const default_action = add; } - apply { t.apply(); } diff --git a/testdata/v1_2_samples_outputs/arith-inline-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_2_samples_outputs/arith-inline-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..11fb0d1c5b0 --- /dev/null +++ b/testdata/v1_2_samples_outputs/arith-inline-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,188 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr { + bit<32> a; + bit<32> b; + bit<64> c; +} + +control compute(inout hdr h) { + action add() { + h.c = (bit<64>)(h.a + h.b); + } + table t() { + actions = { + add; + } + const default_action = add; + } + apply { + t.apply(); + } +} + +struct Headers { + hdr h; +} + +struct Meta { +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + b.extract(h.h); + transition accept; + } +} + +control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control update(inout Headers h, inout Meta m) { + apply { + } +} + +control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control deparser(packet_out b, in Headers h) { + apply { + b.emit(h.h); + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + compute() c; + apply { + c.apply(h.h); + sm.egress_spec = 9w0; + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith-inline-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_2_samples_outputs/arith-inline-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..aaae05cc04b --- /dev/null +++ b/testdata/v1_2_samples_outputs/arith-inline-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,170 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr { + bit<32> a; + bit<32> b; + bit<64> c; +} + +control compute(inout hdr h) { + action add() { + h.c = (bit<64>)(h.a + h.b); + } + table t() { + actions = { + add; + } + const default_action = add; + } + apply { + t.apply(); + } +} + +struct Headers { + hdr h; +} + +struct Meta { +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + b.extract(h.h); + transition accept; + } +} + +control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control update(inout Headers h, inout Meta m) { + apply { + } +} + +control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control deparser(packet_out b, in Headers h) { + apply { + b.emit(h.h); + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + compute() c; + apply { + c.apply(h.h); + sm.egress_spec = 9w0; + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith-inline-bmv2-MidEnd_25_Evaluator.p4 b/testdata/v1_2_samples_outputs/arith-inline-bmv2-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..6eef29d1d18 --- /dev/null +++ b/testdata/v1_2_samples_outputs/arith-inline-bmv2-MidEnd_25_Evaluator.p4 @@ -0,0 +1,184 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr { + bit<32> a; + bit<32> b; + bit<64> c; +} + +struct Headers { + hdr h; +} + +struct Meta { +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + b.extract(h.h); + transition accept; + } +} + +control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control update(inout Headers h, inout Meta m) { + apply { + } +} + +control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control deparser(packet_out b, in Headers h) { + apply { + b.emit(h.h); + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + hdr h_0; + @name("c.add") action c_add() { + h_0.c = (bit<64>)(h_0.a + h_0.b); + } + @name("c.t") table c_t() { + actions = { + c_add; + } + const default_action = c_add; + } + action act() { + h_0 = h.h; + } + action act_0() { + h.h = h_0; + sm.egress_spec = 9w0; + } + table tbl_act() { + actions = { + act; + } + const default_action = act(); + } + table tbl_act_0() { + actions = { + act_0; + } + const default_action = act_0(); + } + apply { + tbl_act.apply(); + c_t.apply(); + tbl_act_0.apply(); + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith-inline-bmv2-fe.p4 b/testdata/v1_2_samples_outputs/arith-inline-bmv2-fe.p4 deleted file mode 100644 index b71d78a7d31..00000000000 --- a/testdata/v1_2_samples_outputs/arith-inline-bmv2-fe.p4 +++ /dev/null @@ -1,68 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr { - bit<32> a; - bit<32> b; - bit<64> c; -} - -control compute(inout hdr h) { - action add() { - h.c = (bit<64>)(h.a + h.b); - } - table t() { - actions = { - add; - } - const default_action = add; - } - apply { - t.apply(); - } -} - -struct Headers { - hdr h; -} - -struct Meta { -} - -parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { - state start { - b.extract(h.h); - transition accept; - } -} - -control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out b, in Headers h) { - apply { - b.emit(h.h); - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - compute() c; - apply { - c.apply(h.h); - sm.egress_spec = 9w0; - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith-inline-bmv2-last.p4 b/testdata/v1_2_samples_outputs/arith-inline-bmv2-last.p4 deleted file mode 100644 index b71d78a7d31..00000000000 --- a/testdata/v1_2_samples_outputs/arith-inline-bmv2-last.p4 +++ /dev/null @@ -1,68 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr { - bit<32> a; - bit<32> b; - bit<64> c; -} - -control compute(inout hdr h) { - action add() { - h.c = (bit<64>)(h.a + h.b); - } - table t() { - actions = { - add; - } - const default_action = add; - } - apply { - t.apply(); - } -} - -struct Headers { - hdr h; -} - -struct Meta { -} - -parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { - state start { - b.extract(h.h); - transition accept; - } -} - -control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out b, in Headers h) { - apply { - b.emit(h.h); - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - compute() c; - apply { - c.apply(h.h); - sm.egress_spec = 9w0; - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith-inline-bmv2-midend.p4 b/testdata/v1_2_samples_outputs/arith-inline-bmv2-midend.p4 deleted file mode 100644 index 6ecc80210d4..00000000000 --- a/testdata/v1_2_samples_outputs/arith-inline-bmv2-midend.p4 +++ /dev/null @@ -1,82 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr { - bit<32> a; - bit<32> b; - bit<64> c; -} - -struct Headers { - hdr h; -} - -struct Meta { -} - -parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { - state start { - b.extract(h.h); - transition accept; - } -} - -control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out b, in Headers h) { - apply { - b.emit(h.h); - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - hdr h_0; - @name("c.add") action c_add() { - h_0.c = (bit<64>)(h_0.a + h_0.b); - } - @name("c.t") table c_t() { - actions = { - c_add; - } - const default_action = c_add; - } - action act() { - h_0 = h.h; - } - action act_0() { - h.h = h_0; - sm.egress_spec = 9w0; - } - table tbl_act() { - actions = { - act; - } - const default_action = act(); - } - table tbl_act_0() { - actions = { - act_0; - } - const default_action = act_0(); - } - apply { - tbl_act.apply(); - c_t.apply(); - tbl_act_0.apply(); - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith-inline-skeleton-fe.p4 b/testdata/v1_2_samples_outputs/arith-inline-skeleton-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/arith-inline-skeleton-fe.p4 rename to testdata/v1_2_samples_outputs/arith-inline-skeleton-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/arith-inline-skeleton-last.p4 b/testdata/v1_2_samples_outputs/arith-inline-skeleton-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/arith-inline-skeleton-last.p4 rename to testdata/v1_2_samples_outputs/arith-inline-skeleton-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/arith-skeleton-fe.p4 b/testdata/v1_2_samples_outputs/arith-skeleton-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/arith-skeleton-fe.p4 rename to testdata/v1_2_samples_outputs/arith-skeleton-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/arith-skeleton-last.p4 b/testdata/v1_2_samples_outputs/arith-skeleton-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/arith-skeleton-last.p4 rename to testdata/v1_2_samples_outputs/arith-skeleton-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/arith1-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_2_samples_outputs/arith1-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..cb2d412a592 --- /dev/null +++ b/testdata/v1_2_samples_outputs/arith1-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,181 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr { + int<32> a; + int<32> b; + bit<8> c; +} + +struct Headers { + hdr h; +} + +struct Meta { +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + b.extract(h.h); + transition accept; + } +} + +control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control update(inout Headers h, inout Meta m) { + apply { + } +} + +control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control deparser(packet_out b, in Headers h) { + apply { + b.emit(h.h); + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + action compare() { + h.h.c = (bit<8>)(bit<1>)(h.h.a < h.h.b); + sm.egress_spec = 9w0; + } + table t() { + actions = { + compare; + } + const default_action = compare; + } + apply { + t.apply(); + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith1-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_2_samples_outputs/arith1-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..643d0ae02a6 --- /dev/null +++ b/testdata/v1_2_samples_outputs/arith1-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,163 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr { + int<32> a; + int<32> b; + bit<8> c; +} + +struct Headers { + hdr h; +} + +struct Meta { +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + b.extract(h.h); + transition accept; + } +} + +control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control update(inout Headers h, inout Meta m) { + apply { + } +} + +control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control deparser(packet_out b, in Headers h) { + apply { + b.emit(h.h); + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + action compare() { + h.h.c = (bit<8>)(bit<1>)(h.h.a < h.h.b); + sm.egress_spec = 9w0; + } + table t() { + actions = { + compare; + } + const default_action = compare; + } + apply { + t.apply(); + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith1-bmv2-MidEnd_25_Evaluator.p4 b/testdata/v1_2_samples_outputs/arith1-bmv2-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..b1699407ee2 --- /dev/null +++ b/testdata/v1_2_samples_outputs/arith1-bmv2-MidEnd_25_Evaluator.p4 @@ -0,0 +1,163 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr { + int<32> a; + int<32> b; + bit<8> c; +} + +struct Headers { + hdr h; +} + +struct Meta { +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + b.extract(h.h); + transition accept; + } +} + +control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control update(inout Headers h, inout Meta m) { + apply { + } +} + +control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control deparser(packet_out b, in Headers h) { + apply { + b.emit(h.h); + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + @name("compare") action compare_0() { + h.h.c = (bit<8>)(bit<1>)(h.h.a < h.h.b); + sm.egress_spec = 9w0; + } + @name("t") table t_0() { + actions = { + compare_0; + } + const default_action = compare_0; + } + apply { + t_0.apply(); + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith1-bmv2-fe.p4 b/testdata/v1_2_samples_outputs/arith1-bmv2-fe.p4 deleted file mode 100644 index 17b7f2c9d7a..00000000000 --- a/testdata/v1_2_samples_outputs/arith1-bmv2-fe.p4 +++ /dev/null @@ -1,61 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr { - int<32> a; - int<32> b; - bit<8> c; -} - -struct Headers { - hdr h; -} - -struct Meta { -} - -parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { - state start { - b.extract(h.h); - transition accept; - } -} - -control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out b, in Headers h) { - apply { - b.emit(h.h); - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - action compare() { - h.h.c = (bit<8>)(bit<1>)(h.h.a < h.h.b); - sm.egress_spec = 9w0; - } - table t() { - actions = { - compare; - } - const default_action = compare; - } - apply { - t.apply(); - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith1-bmv2-last.p4 b/testdata/v1_2_samples_outputs/arith1-bmv2-last.p4 deleted file mode 100644 index 17b7f2c9d7a..00000000000 --- a/testdata/v1_2_samples_outputs/arith1-bmv2-last.p4 +++ /dev/null @@ -1,61 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr { - int<32> a; - int<32> b; - bit<8> c; -} - -struct Headers { - hdr h; -} - -struct Meta { -} - -parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { - state start { - b.extract(h.h); - transition accept; - } -} - -control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out b, in Headers h) { - apply { - b.emit(h.h); - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - action compare() { - h.h.c = (bit<8>)(bit<1>)(h.h.a < h.h.b); - sm.egress_spec = 9w0; - } - table t() { - actions = { - compare; - } - const default_action = compare; - } - apply { - t.apply(); - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith1-bmv2-midend.p4 b/testdata/v1_2_samples_outputs/arith1-bmv2-midend.p4 deleted file mode 100644 index 7f1aee2cda0..00000000000 --- a/testdata/v1_2_samples_outputs/arith1-bmv2-midend.p4 +++ /dev/null @@ -1,61 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr { - int<32> a; - int<32> b; - bit<8> c; -} - -struct Headers { - hdr h; -} - -struct Meta { -} - -parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { - state start { - b.extract(h.h); - transition accept; - } -} - -control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out b, in Headers h) { - apply { - b.emit(h.h); - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - @name("compare") action compare_0() { - h.h.c = (bit<8>)(bit<1>)(h.h.a < h.h.b); - sm.egress_spec = 9w0; - } - @name("t") table t_0() { - actions = { - compare_0; - } - const default_action = compare_0; - } - apply { - t_0.apply(); - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith2-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_2_samples_outputs/arith2-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..84aeae710a1 --- /dev/null +++ b/testdata/v1_2_samples_outputs/arith2-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,181 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr { + bit<32> a; + bit<32> b; + bit<8> c; +} + +struct Headers { + hdr h; +} + +struct Meta { +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + b.extract(h.h); + transition accept; + } +} + +control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control update(inout Headers h, inout Meta m) { + apply { + } +} + +control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control deparser(packet_out b, in Headers h) { + apply { + b.emit(h.h); + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + action compare() { + h.h.c = (bit<8>)(bit<1>)(h.h.a < h.h.b); + sm.egress_spec = 9w0; + } + table t() { + actions = { + compare; + } + const default_action = compare; + } + apply { + t.apply(); + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith2-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_2_samples_outputs/arith2-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..a1c9bdc0970 --- /dev/null +++ b/testdata/v1_2_samples_outputs/arith2-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,163 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr { + bit<32> a; + bit<32> b; + bit<8> c; +} + +struct Headers { + hdr h; +} + +struct Meta { +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + b.extract(h.h); + transition accept; + } +} + +control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control update(inout Headers h, inout Meta m) { + apply { + } +} + +control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control deparser(packet_out b, in Headers h) { + apply { + b.emit(h.h); + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + action compare() { + h.h.c = (bit<8>)(bit<1>)(h.h.a < h.h.b); + sm.egress_spec = 9w0; + } + table t() { + actions = { + compare; + } + const default_action = compare; + } + apply { + t.apply(); + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith2-bmv2-MidEnd_25_Evaluator.p4 b/testdata/v1_2_samples_outputs/arith2-bmv2-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..4acb465e08d --- /dev/null +++ b/testdata/v1_2_samples_outputs/arith2-bmv2-MidEnd_25_Evaluator.p4 @@ -0,0 +1,163 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr { + bit<32> a; + bit<32> b; + bit<8> c; +} + +struct Headers { + hdr h; +} + +struct Meta { +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + b.extract(h.h); + transition accept; + } +} + +control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control update(inout Headers h, inout Meta m) { + apply { + } +} + +control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control deparser(packet_out b, in Headers h) { + apply { + b.emit(h.h); + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + @name("compare") action compare_0() { + h.h.c = (bit<8>)(bit<1>)(h.h.a < h.h.b); + sm.egress_spec = 9w0; + } + @name("t") table t_0() { + actions = { + compare_0; + } + const default_action = compare_0; + } + apply { + t_0.apply(); + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith2-bmv2-fe.p4 b/testdata/v1_2_samples_outputs/arith2-bmv2-fe.p4 deleted file mode 100644 index 7e20e074594..00000000000 --- a/testdata/v1_2_samples_outputs/arith2-bmv2-fe.p4 +++ /dev/null @@ -1,62 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr { - bit<32> a; - bit<32> b; - bit<8> c; -} - -struct Headers { - hdr h; -} - -struct Meta { -} - -parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { - state start { - b.extract(h.h); - transition accept; - } -} - -control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out b, in Headers h) { - apply { - b.emit(h.h); - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - action compare() { - h.h.c = (bit<8>)(bit<1>)(h.h.a < h.h.b); - sm.egress_spec = 9w0; - } - table t() { - actions = { - compare; - } - const default_action = compare; - } - - apply { - t.apply(); - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith2-bmv2-last.p4 b/testdata/v1_2_samples_outputs/arith2-bmv2-last.p4 deleted file mode 100644 index 7e20e074594..00000000000 --- a/testdata/v1_2_samples_outputs/arith2-bmv2-last.p4 +++ /dev/null @@ -1,62 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr { - bit<32> a; - bit<32> b; - bit<8> c; -} - -struct Headers { - hdr h; -} - -struct Meta { -} - -parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { - state start { - b.extract(h.h); - transition accept; - } -} - -control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out b, in Headers h) { - apply { - b.emit(h.h); - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - action compare() { - h.h.c = (bit<8>)(bit<1>)(h.h.a < h.h.b); - sm.egress_spec = 9w0; - } - table t() { - actions = { - compare; - } - const default_action = compare; - } - - apply { - t.apply(); - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith2-bmv2-midend.p4 b/testdata/v1_2_samples_outputs/arith2-bmv2-midend.p4 deleted file mode 100644 index c2f96ab3518..00000000000 --- a/testdata/v1_2_samples_outputs/arith2-bmv2-midend.p4 +++ /dev/null @@ -1,61 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr { - bit<32> a; - bit<32> b; - bit<8> c; -} - -struct Headers { - hdr h; -} - -struct Meta { -} - -parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { - state start { - b.extract(h.h); - transition accept; - } -} - -control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out b, in Headers h) { - apply { - b.emit(h.h); - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - @name("compare") action compare_0() { - h.h.c = (bit<8>)(bit<1>)(h.h.a < h.h.b); - sm.egress_spec = 9w0; - } - @name("t") table t_0() { - actions = { - compare_0; - } - const default_action = compare_0; - } - apply { - t_0.apply(); - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith2-bmv2.p4 b/testdata/v1_2_samples_outputs/arith2-bmv2.p4 index 27667fdfb64..2b359af78b2 100644 --- a/testdata/v1_2_samples_outputs/arith2-bmv2.p4 +++ b/testdata/v1_2_samples_outputs/arith2-bmv2.p4 @@ -53,7 +53,6 @@ control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { } const default_action = compare; } - apply { t.apply(); } diff --git a/testdata/v1_2_samples_outputs/arith2-inline-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_2_samples_outputs/arith2-inline-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..a5d8ba53556 --- /dev/null +++ b/testdata/v1_2_samples_outputs/arith2-inline-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,182 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr { + bit<32> a; + bit<32> b; + bit<8> c; +} + +control compute(inout hdr h) { + apply { + if (h.a < h.b) + h.c = 8w0; + else + h.c = 8w1; + } +} + +struct Headers { + hdr h; +} + +struct Meta { +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + b.extract(h.h); + transition accept; + } +} + +control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control update(inout Headers h, inout Meta m) { + apply { + } +} + +control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control deparser(packet_out b, in Headers h) { + apply { + b.emit(h.h); + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + compute() c; + apply { + c.apply(h.h); + sm.egress_spec = 9w0; + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith2-inline-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_2_samples_outputs/arith2-inline-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..7981d76723a --- /dev/null +++ b/testdata/v1_2_samples_outputs/arith2-inline-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,164 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr { + bit<32> a; + bit<32> b; + bit<8> c; +} + +control compute(inout hdr h) { + apply { + if (h.a < h.b) + h.c = 8w0; + else + h.c = 8w1; + } +} + +struct Headers { + hdr h; +} + +struct Meta { +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + b.extract(h.h); + transition accept; + } +} + +control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control update(inout Headers h, inout Meta m) { + apply { + } +} + +control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control deparser(packet_out b, in Headers h) { + apply { + b.emit(h.h); + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + compute() c; + apply { + c.apply(h.h); + sm.egress_spec = 9w0; + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith2-inline-bmv2-MidEnd_25_Evaluator.p4 b/testdata/v1_2_samples_outputs/arith2-inline-bmv2-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..8eec8e41c07 --- /dev/null +++ b/testdata/v1_2_samples_outputs/arith2-inline-bmv2-MidEnd_25_Evaluator.p4 @@ -0,0 +1,196 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr { + bit<32> a; + bit<32> b; + bit<8> c; +} + +struct Headers { + hdr h; +} + +struct Meta { +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + b.extract(h.h); + transition accept; + } +} + +control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control update(inout Headers h, inout Meta m) { + apply { + } +} + +control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control deparser(packet_out b, in Headers h) { + apply { + b.emit(h.h); + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + hdr h_0; + action act() { + h_0.c = 8w0; + } + action act_0() { + h_0.c = 8w1; + } + action act_1() { + h_0 = h.h; + } + action act_2() { + h.h = h_0; + sm.egress_spec = 9w0; + } + table tbl_act() { + actions = { + act_1; + } + const default_action = act_1(); + } + table tbl_act_0() { + actions = { + act; + } + const default_action = act(); + } + table tbl_act_1() { + actions = { + act_0; + } + const default_action = act_0(); + } + table tbl_act_2() { + actions = { + act_2; + } + const default_action = act_2(); + } + apply { + tbl_act.apply(); + if (h_0.a < h_0.b) + tbl_act_0.apply(); + else + tbl_act_1.apply(); + tbl_act_2.apply(); + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith2-inline-bmv2-fe.p4 b/testdata/v1_2_samples_outputs/arith2-inline-bmv2-fe.p4 deleted file mode 100644 index a63298bbaa4..00000000000 --- a/testdata/v1_2_samples_outputs/arith2-inline-bmv2-fe.p4 +++ /dev/null @@ -1,62 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr { - bit<32> a; - bit<32> b; - bit<8> c; -} - -control compute(inout hdr h) { - apply { - if (h.a < h.b) - h.c = 8w0; - else - h.c = 8w1; - } -} - -struct Headers { - hdr h; -} - -struct Meta { -} - -parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { - state start { - b.extract(h.h); - transition accept; - } -} - -control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out b, in Headers h) { - apply { - b.emit(h.h); - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - compute() c; - apply { - c.apply(h.h); - sm.egress_spec = 9w0; - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith2-inline-bmv2-last.p4 b/testdata/v1_2_samples_outputs/arith2-inline-bmv2-last.p4 deleted file mode 100644 index a63298bbaa4..00000000000 --- a/testdata/v1_2_samples_outputs/arith2-inline-bmv2-last.p4 +++ /dev/null @@ -1,62 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr { - bit<32> a; - bit<32> b; - bit<8> c; -} - -control compute(inout hdr h) { - apply { - if (h.a < h.b) - h.c = 8w0; - else - h.c = 8w1; - } -} - -struct Headers { - hdr h; -} - -struct Meta { -} - -parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { - state start { - b.extract(h.h); - transition accept; - } -} - -control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out b, in Headers h) { - apply { - b.emit(h.h); - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - compute() c; - apply { - c.apply(h.h); - sm.egress_spec = 9w0; - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith2-inline-bmv2-midend.p4 b/testdata/v1_2_samples_outputs/arith2-inline-bmv2-midend.p4 deleted file mode 100644 index 8361a45de3f..00000000000 --- a/testdata/v1_2_samples_outputs/arith2-inline-bmv2-midend.p4 +++ /dev/null @@ -1,94 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr { - bit<32> a; - bit<32> b; - bit<8> c; -} - -struct Headers { - hdr h; -} - -struct Meta { -} - -parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { - state start { - b.extract(h.h); - transition accept; - } -} - -control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out b, in Headers h) { - apply { - b.emit(h.h); - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - hdr h_0; - action act() { - h_0.c = 8w0; - } - action act_0() { - h_0.c = 8w1; - } - action act_1() { - h_0 = h.h; - } - action act_2() { - h.h = h_0; - sm.egress_spec = 9w0; - } - table tbl_act() { - actions = { - act_1; - } - const default_action = act_1(); - } - table tbl_act_0() { - actions = { - act; - } - const default_action = act(); - } - table tbl_act_1() { - actions = { - act_0; - } - const default_action = act_0(); - } - table tbl_act_2() { - actions = { - act_2; - } - const default_action = act_2(); - } - apply { - tbl_act.apply(); - if (h_0.a < h_0.b) - tbl_act_0.apply(); - else - tbl_act_1.apply(); - tbl_act_2.apply(); - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith3-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_2_samples_outputs/arith3-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..9148caf9e77 --- /dev/null +++ b/testdata/v1_2_samples_outputs/arith3-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,181 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr { + bit<32> a; + bit<8> b; + bit<64> c; +} + +struct Headers { + hdr h; +} + +struct Meta { +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + b.extract(h.h); + transition accept; + } +} + +control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control update(inout Headers h, inout Meta m) { + apply { + } +} + +control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control deparser(packet_out b, in Headers h) { + apply { + b.emit(h.h); + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + action shift() { + h.h.c = (bit<64>)(h.h.a << h.h.b); + sm.egress_spec = 9w0; + } + table t() { + actions = { + shift; + } + const default_action = shift; + } + apply { + t.apply(); + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith3-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_2_samples_outputs/arith3-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..66f0421e816 --- /dev/null +++ b/testdata/v1_2_samples_outputs/arith3-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,163 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr { + bit<32> a; + bit<8> b; + bit<64> c; +} + +struct Headers { + hdr h; +} + +struct Meta { +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + b.extract(h.h); + transition accept; + } +} + +control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control update(inout Headers h, inout Meta m) { + apply { + } +} + +control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control deparser(packet_out b, in Headers h) { + apply { + b.emit(h.h); + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + action shift() { + h.h.c = (bit<64>)(h.h.a << h.h.b); + sm.egress_spec = 9w0; + } + table t() { + actions = { + shift; + } + const default_action = shift; + } + apply { + t.apply(); + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith3-bmv2-MidEnd_25_Evaluator.p4 b/testdata/v1_2_samples_outputs/arith3-bmv2-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..87b41715ce4 --- /dev/null +++ b/testdata/v1_2_samples_outputs/arith3-bmv2-MidEnd_25_Evaluator.p4 @@ -0,0 +1,163 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr { + bit<32> a; + bit<8> b; + bit<64> c; +} + +struct Headers { + hdr h; +} + +struct Meta { +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + b.extract(h.h); + transition accept; + } +} + +control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control update(inout Headers h, inout Meta m) { + apply { + } +} + +control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control deparser(packet_out b, in Headers h) { + apply { + b.emit(h.h); + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + @name("shift") action shift_0() { + h.h.c = (bit<64>)(h.h.a << h.h.b); + sm.egress_spec = 9w0; + } + @name("t") table t_0() { + actions = { + shift_0; + } + const default_action = shift_0; + } + apply { + t_0.apply(); + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith3-bmv2-fe.p4 b/testdata/v1_2_samples_outputs/arith3-bmv2-fe.p4 deleted file mode 100644 index 927ebbb78f2..00000000000 --- a/testdata/v1_2_samples_outputs/arith3-bmv2-fe.p4 +++ /dev/null @@ -1,62 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr { - bit<32> a; - bit<8> b; - bit<64> c; -} - -struct Headers { - hdr h; -} - -struct Meta { -} - -parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { - state start { - b.extract(h.h); - transition accept; - } -} - -control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out b, in Headers h) { - apply { - b.emit(h.h); - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - action shift() { - h.h.c = (bit<64>)(h.h.a << h.h.b); - sm.egress_spec = 9w0; - } - table t() { - actions = { - shift; - } - const default_action = shift; - } - - apply { - t.apply(); - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith3-bmv2-last.p4 b/testdata/v1_2_samples_outputs/arith3-bmv2-last.p4 deleted file mode 100644 index 927ebbb78f2..00000000000 --- a/testdata/v1_2_samples_outputs/arith3-bmv2-last.p4 +++ /dev/null @@ -1,62 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr { - bit<32> a; - bit<8> b; - bit<64> c; -} - -struct Headers { - hdr h; -} - -struct Meta { -} - -parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { - state start { - b.extract(h.h); - transition accept; - } -} - -control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out b, in Headers h) { - apply { - b.emit(h.h); - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - action shift() { - h.h.c = (bit<64>)(h.h.a << h.h.b); - sm.egress_spec = 9w0; - } - table t() { - actions = { - shift; - } - const default_action = shift; - } - - apply { - t.apply(); - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith3-bmv2-midend.p4 b/testdata/v1_2_samples_outputs/arith3-bmv2-midend.p4 deleted file mode 100644 index fa45088e810..00000000000 --- a/testdata/v1_2_samples_outputs/arith3-bmv2-midend.p4 +++ /dev/null @@ -1,61 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr { - bit<32> a; - bit<8> b; - bit<64> c; -} - -struct Headers { - hdr h; -} - -struct Meta { -} - -parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { - state start { - b.extract(h.h); - transition accept; - } -} - -control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out b, in Headers h) { - apply { - b.emit(h.h); - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - @name("shift") action shift_0() { - h.h.c = (bit<64>)(h.h.a << h.h.b); - sm.egress_spec = 9w0; - } - @name("t") table t_0() { - actions = { - shift_0; - } - const default_action = shift_0; - } - apply { - t_0.apply(); - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith3-bmv2.p4 b/testdata/v1_2_samples_outputs/arith3-bmv2.p4 index 06e4061792e..3f036d3de57 100644 --- a/testdata/v1_2_samples_outputs/arith3-bmv2.p4 +++ b/testdata/v1_2_samples_outputs/arith3-bmv2.p4 @@ -53,7 +53,6 @@ control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { } const default_action = shift; } - apply { t.apply(); } diff --git a/testdata/v1_2_samples_outputs/arith4-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_2_samples_outputs/arith4-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..0ebee78cfb4 --- /dev/null +++ b/testdata/v1_2_samples_outputs/arith4-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,181 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr { + bit<32> a; + bit<8> b; + bit<64> c; +} + +struct Headers { + hdr h; +} + +struct Meta { +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + b.extract(h.h); + transition accept; + } +} + +control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control update(inout Headers h, inout Meta m) { + apply { + } +} + +control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control deparser(packet_out b, in Headers h) { + apply { + b.emit(h.h); + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + action shift() { + h.h.c = (bit<64>)(h.h.a >> h.h.b); + sm.egress_spec = 9w0; + } + table t() { + actions = { + shift; + } + const default_action = shift; + } + apply { + t.apply(); + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith4-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_2_samples_outputs/arith4-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..46ddcb5b8e9 --- /dev/null +++ b/testdata/v1_2_samples_outputs/arith4-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,163 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr { + bit<32> a; + bit<8> b; + bit<64> c; +} + +struct Headers { + hdr h; +} + +struct Meta { +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + b.extract(h.h); + transition accept; + } +} + +control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control update(inout Headers h, inout Meta m) { + apply { + } +} + +control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control deparser(packet_out b, in Headers h) { + apply { + b.emit(h.h); + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + action shift() { + h.h.c = (bit<64>)(h.h.a >> h.h.b); + sm.egress_spec = 9w0; + } + table t() { + actions = { + shift; + } + const default_action = shift; + } + apply { + t.apply(); + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith4-bmv2-MidEnd_25_Evaluator.p4 b/testdata/v1_2_samples_outputs/arith4-bmv2-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..bc52b935048 --- /dev/null +++ b/testdata/v1_2_samples_outputs/arith4-bmv2-MidEnd_25_Evaluator.p4 @@ -0,0 +1,163 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr { + bit<32> a; + bit<8> b; + bit<64> c; +} + +struct Headers { + hdr h; +} + +struct Meta { +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + b.extract(h.h); + transition accept; + } +} + +control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control update(inout Headers h, inout Meta m) { + apply { + } +} + +control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control deparser(packet_out b, in Headers h) { + apply { + b.emit(h.h); + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + @name("shift") action shift_0() { + h.h.c = (bit<64>)(h.h.a >> h.h.b); + sm.egress_spec = 9w0; + } + @name("t") table t_0() { + actions = { + shift_0; + } + const default_action = shift_0; + } + apply { + t_0.apply(); + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith4-bmv2-fe.p4 b/testdata/v1_2_samples_outputs/arith4-bmv2-fe.p4 deleted file mode 100644 index 3bb617cae37..00000000000 --- a/testdata/v1_2_samples_outputs/arith4-bmv2-fe.p4 +++ /dev/null @@ -1,62 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr { - bit<32> a; - bit<8> b; - bit<64> c; -} - -struct Headers { - hdr h; -} - -struct Meta { -} - -parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { - state start { - b.extract(h.h); - transition accept; - } -} - -control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out b, in Headers h) { - apply { - b.emit(h.h); - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - action shift() { - h.h.c = (bit<64>)(h.h.a >> h.h.b); - sm.egress_spec = 9w0; - } - table t() { - actions = { - shift; - } - const default_action = shift; - } - - apply { - t.apply(); - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith4-bmv2-last.p4 b/testdata/v1_2_samples_outputs/arith4-bmv2-last.p4 deleted file mode 100644 index 3bb617cae37..00000000000 --- a/testdata/v1_2_samples_outputs/arith4-bmv2-last.p4 +++ /dev/null @@ -1,62 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr { - bit<32> a; - bit<8> b; - bit<64> c; -} - -struct Headers { - hdr h; -} - -struct Meta { -} - -parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { - state start { - b.extract(h.h); - transition accept; - } -} - -control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out b, in Headers h) { - apply { - b.emit(h.h); - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - action shift() { - h.h.c = (bit<64>)(h.h.a >> h.h.b); - sm.egress_spec = 9w0; - } - table t() { - actions = { - shift; - } - const default_action = shift; - } - - apply { - t.apply(); - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith4-bmv2-midend.p4 b/testdata/v1_2_samples_outputs/arith4-bmv2-midend.p4 deleted file mode 100644 index eacff11c657..00000000000 --- a/testdata/v1_2_samples_outputs/arith4-bmv2-midend.p4 +++ /dev/null @@ -1,61 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr { - bit<32> a; - bit<8> b; - bit<64> c; -} - -struct Headers { - hdr h; -} - -struct Meta { -} - -parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { - state start { - b.extract(h.h); - transition accept; - } -} - -control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out b, in Headers h) { - apply { - b.emit(h.h); - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - @name("shift") action shift_0() { - h.h.c = (bit<64>)(h.h.a >> h.h.b); - sm.egress_spec = 9w0; - } - @name("t") table t_0() { - actions = { - shift_0; - } - const default_action = shift_0; - } - apply { - t_0.apply(); - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith4-bmv2.p4 b/testdata/v1_2_samples_outputs/arith4-bmv2.p4 index 88c1d88269b..c4b49276d65 100644 --- a/testdata/v1_2_samples_outputs/arith4-bmv2.p4 +++ b/testdata/v1_2_samples_outputs/arith4-bmv2.p4 @@ -53,7 +53,6 @@ control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { } const default_action = shift; } - apply { t.apply(); } diff --git a/testdata/v1_2_samples_outputs/arith5-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_2_samples_outputs/arith5-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..b0ff0eb0016 --- /dev/null +++ b/testdata/v1_2_samples_outputs/arith5-bmv2-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,181 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr { + int<32> a; + bit<8> b; + int<64> c; +} + +struct Headers { + hdr h; +} + +struct Meta { +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + b.extract(h.h); + transition accept; + } +} + +control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control update(inout Headers h, inout Meta m) { + apply { + } +} + +control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control deparser(packet_out b, in Headers h) { + apply { + b.emit(h.h); + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + action shift() { + h.h.c = (int<64>)(h.h.a >> h.h.b); + sm.egress_spec = 9w0; + } + table t() { + actions = { + shift; + } + const default_action = shift; + } + apply { + t.apply(); + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith5-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_2_samples_outputs/arith5-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..d5b3dda0fb4 --- /dev/null +++ b/testdata/v1_2_samples_outputs/arith5-bmv2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,163 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr { + int<32> a; + bit<8> b; + int<64> c; +} + +struct Headers { + hdr h; +} + +struct Meta { +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + b.extract(h.h); + transition accept; + } +} + +control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control update(inout Headers h, inout Meta m) { + apply { + } +} + +control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control deparser(packet_out b, in Headers h) { + apply { + b.emit(h.h); + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + action shift() { + h.h.c = (int<64>)(h.h.a >> h.h.b); + sm.egress_spec = 9w0; + } + table t() { + actions = { + shift; + } + const default_action = shift; + } + apply { + t.apply(); + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith5-bmv2-MidEnd_25_Evaluator.p4 b/testdata/v1_2_samples_outputs/arith5-bmv2-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..7042b2c1677 --- /dev/null +++ b/testdata/v1_2_samples_outputs/arith5-bmv2-MidEnd_25_Evaluator.p4 @@ -0,0 +1,163 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr { + int<32> a; + bit<8> b; + int<64> c; +} + +struct Headers { + hdr h; +} + +struct Meta { +} + +parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { + state start { + b.extract(h.h); + transition accept; + } +} + +control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control update(inout Headers h, inout Meta m) { + apply { + } +} + +control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + apply { + } +} + +control deparser(packet_out b, in Headers h) { + apply { + b.emit(h.h); + } +} + +control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { + @name("shift") action shift_0() { + h.h.c = (int<64>)(h.h.a >> h.h.b); + sm.egress_spec = 9w0; + } + @name("t") table t_0() { + actions = { + shift_0; + } + const default_action = shift_0; + } + apply { + t_0.apply(); + } +} + +V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith5-bmv2-fe.p4 b/testdata/v1_2_samples_outputs/arith5-bmv2-fe.p4 deleted file mode 100644 index 9c021a1ffe5..00000000000 --- a/testdata/v1_2_samples_outputs/arith5-bmv2-fe.p4 +++ /dev/null @@ -1,62 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr { - int<32> a; - bit<8> b; - int<64> c; -} - -struct Headers { - hdr h; -} - -struct Meta { -} - -parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { - state start { - b.extract(h.h); - transition accept; - } -} - -control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out b, in Headers h) { - apply { - b.emit(h.h); - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - action shift() { - h.h.c = (int<64>)(h.h.a >> h.h.b); - sm.egress_spec = 9w0; - } - table t() { - actions = { - shift; - } - const default_action = shift; - } - - apply { - t.apply(); - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith5-bmv2-last.p4 b/testdata/v1_2_samples_outputs/arith5-bmv2-last.p4 deleted file mode 100644 index 9c021a1ffe5..00000000000 --- a/testdata/v1_2_samples_outputs/arith5-bmv2-last.p4 +++ /dev/null @@ -1,62 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr { - int<32> a; - bit<8> b; - int<64> c; -} - -struct Headers { - hdr h; -} - -struct Meta { -} - -parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { - state start { - b.extract(h.h); - transition accept; - } -} - -control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out b, in Headers h) { - apply { - b.emit(h.h); - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - action shift() { - h.h.c = (int<64>)(h.h.a >> h.h.b); - sm.egress_spec = 9w0; - } - table t() { - actions = { - shift; - } - const default_action = shift; - } - - apply { - t.apply(); - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith5-bmv2-midend.p4 b/testdata/v1_2_samples_outputs/arith5-bmv2-midend.p4 deleted file mode 100644 index 2fcc2fa81f0..00000000000 --- a/testdata/v1_2_samples_outputs/arith5-bmv2-midend.p4 +++ /dev/null @@ -1,61 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr { - int<32> a; - bit<8> b; - int<64> c; -} - -struct Headers { - hdr h; -} - -struct Meta { -} - -parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { - state start { - b.extract(h.h); - transition accept; - } -} - -control vrfy(in Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control update(inout Headers h, inout Meta m) { - apply { - } -} - -control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - apply { - } -} - -control deparser(packet_out b, in Headers h) { - apply { - b.emit(h.h); - } -} - -control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { - @name("shift") action shift_0() { - h.h.c = (int<64>)(h.h.a >> h.h.b); - sm.egress_spec = 9w0; - } - @name("t") table t_0() { - actions = { - shift_0; - } - const default_action = shift_0; - } - apply { - t_0.apply(); - } -} - -V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; diff --git a/testdata/v1_2_samples_outputs/arith5-bmv2.p4 b/testdata/v1_2_samples_outputs/arith5-bmv2.p4 index c4e0657006f..946a7e73733 100644 --- a/testdata/v1_2_samples_outputs/arith5-bmv2.p4 +++ b/testdata/v1_2_samples_outputs/arith5-bmv2.p4 @@ -53,7 +53,6 @@ control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { } const default_action = shift; } - apply { t.apply(); } diff --git a/testdata/v1_2_samples_outputs/bitExtract-fe.p4 b/testdata/v1_2_samples_outputs/bitExtract-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/bitExtract-fe.p4 rename to testdata/v1_2_samples_outputs/bitExtract-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/bitExtract-last.p4 b/testdata/v1_2_samples_outputs/bitExtract-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/bitExtract-last.p4 rename to testdata/v1_2_samples_outputs/bitExtract-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/bool_cast-fe.p4 b/testdata/v1_2_samples_outputs/bool_cast-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/bool_cast-fe.p4 rename to testdata/v1_2_samples_outputs/bool_cast-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/bool_cast-last.p4 b/testdata/v1_2_samples_outputs/bool_cast-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/bool_cast-last.p4 rename to testdata/v1_2_samples_outputs/bool_cast-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/call-fe.p4 b/testdata/v1_2_samples_outputs/call-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 99% rename from testdata/v1_2_samples_outputs/call-fe.p4 rename to testdata/v1_2_samples_outputs/call-FrontEnd_11_SimplifyControlFlowE.p4 index 6c4c181d480..da0de31c43e 100644 --- a/testdata/v1_2_samples_outputs/call-fe.p4 +++ b/testdata/v1_2_samples_outputs/call-FrontEnd_11_SimplifyControlFlowE.p4 @@ -7,7 +7,6 @@ control qp() { } default_action = drop; } - apply { m.apply(); } diff --git a/testdata/v1_2_samples_outputs/call-last.p4 b/testdata/v1_2_samples_outputs/call-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/call-last.p4 rename to testdata/v1_2_samples_outputs/call-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/call.p4 b/testdata/v1_2_samples_outputs/call.p4 index 6c4c181d480..da0de31c43e 100644 --- a/testdata/v1_2_samples_outputs/call.p4 +++ b/testdata/v1_2_samples_outputs/call.p4 @@ -7,7 +7,6 @@ control qp() { } default_action = drop; } - apply { m.apply(); } diff --git a/testdata/v1_2_samples_outputs/cases-fe.p4 b/testdata/v1_2_samples_outputs/cases-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/cases-fe.p4 rename to testdata/v1_2_samples_outputs/cases-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/cases-last.p4 b/testdata/v1_2_samples_outputs/cases-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/cases-last.p4 rename to testdata/v1_2_samples_outputs/cases-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/cast-fe.p4 b/testdata/v1_2_samples_outputs/cast-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/cast-fe.p4 rename to testdata/v1_2_samples_outputs/cast-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/cast-last.p4 b/testdata/v1_2_samples_outputs/cast-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/cast-last.p4 rename to testdata/v1_2_samples_outputs/cast-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/const-fe.p4 b/testdata/v1_2_samples_outputs/const-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/const-fe.p4 rename to testdata/v1_2_samples_outputs/const-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/const-last.p4 b/testdata/v1_2_samples_outputs/const-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/const-last.p4 rename to testdata/v1_2_samples_outputs/const-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/constant_folding-fe.p4 b/testdata/v1_2_samples_outputs/constant_folding-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/constant_folding-fe.p4 rename to testdata/v1_2_samples_outputs/constant_folding-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/constant_folding-last.p4 b/testdata/v1_2_samples_outputs/constant_folding-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/constant_folding-last.p4 rename to testdata/v1_2_samples_outputs/constant_folding-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/constants-fe.p4 b/testdata/v1_2_samples_outputs/constants-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/constants-fe.p4 rename to testdata/v1_2_samples_outputs/constants-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/constants-last.p4 b/testdata/v1_2_samples_outputs/constants-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/constants-last.p4 rename to testdata/v1_2_samples_outputs/constants-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/constructor_cast-fe.p4 b/testdata/v1_2_samples_outputs/constructor_cast-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/constructor_cast-fe.p4 rename to testdata/v1_2_samples_outputs/constructor_cast-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/constructor_cast-last.p4 b/testdata/v1_2_samples_outputs/constructor_cast-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/constructor_cast-last.p4 rename to testdata/v1_2_samples_outputs/constructor_cast-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/constsigned-fe.p4 b/testdata/v1_2_samples_outputs/constsigned-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/constsigned-fe.p4 rename to testdata/v1_2_samples_outputs/constsigned-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/constsigned-last.p4 b/testdata/v1_2_samples_outputs/constsigned-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/constsigned-last.p4 rename to testdata/v1_2_samples_outputs/constsigned-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/count_ebpf-last.p4 b/testdata/v1_2_samples_outputs/count_ebpf-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 55% rename from testdata/v1_2_samples_outputs/count_ebpf-last.p4 rename to testdata/v1_2_samples_outputs/count_ebpf-FrontEnd_11_SimplifyControlFlowE.p4 index fcc82e288f8..d3d7a432354 100644 --- a/testdata/v1_2_samples_outputs/count_ebpf-last.p4 +++ b/testdata/v1_2_samples_outputs/count_ebpf-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,56 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/ebpf_model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version ebpf_version = { 8w0, 8w1 }; +extern CounterArray { + CounterArray(bit<32> max_index, bool sparse); + void increment(in bit<32> index); +} + +extern array_table { + array_table(bit<32> size); +} + +extern hash_table { + hash_table(bit<32> size); +} +parser parse(packet_in packet, out H headers); +control filter(inout H headers, out bool accept); +package ebpfFilter(parse prs, filter filt); typedef bit<48> @ethernetaddress EthernetAddress; typedef bit<32> @ipv4address IPv4Address; header Ethernet_h { diff --git a/testdata/v1_2_samples_outputs/count_ebpf-fe.p4 b/testdata/v1_2_samples_outputs/count_ebpf-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 59% rename from testdata/v1_2_samples_outputs/count_ebpf-fe.p4 rename to testdata/v1_2_samples_outputs/count_ebpf-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index fcc82e288f8..4e4650ddc49 100644 --- a/testdata/v1_2_samples_outputs/count_ebpf-fe.p4 +++ b/testdata/v1_2_samples_outputs/count_ebpf-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,51 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/ebpf_model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +extern CounterArray { + CounterArray(bit<32> max_index, bool sparse); + void increment(in bit<32> index); +} + +extern array_table { + array_table(bit<32> size); +} + +extern hash_table { + hash_table(bit<32> size); +} +parser parse(packet_in packet, out H headers); +control filter(inout H headers, out bool accept); +package ebpfFilter(parse prs, filter filt); typedef bit<48> @ethernetaddress EthernetAddress; typedef bit<32> @ipv4address IPv4Address; header Ethernet_h { diff --git a/testdata/v1_2_samples_outputs/count_ebpf-midend.p4 b/testdata/v1_2_samples_outputs/count_ebpf-MidEnd_25_Evaluator.p4 similarity index 65% rename from testdata/v1_2_samples_outputs/count_ebpf-midend.p4 rename to testdata/v1_2_samples_outputs/count_ebpf-MidEnd_25_Evaluator.p4 index f2811a3acb9..94c794410ed 100644 --- a/testdata/v1_2_samples_outputs/count_ebpf-midend.p4 +++ b/testdata/v1_2_samples_outputs/count_ebpf-MidEnd_25_Evaluator.p4 @@ -1,6 +1,51 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/ebpf_model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +extern CounterArray { + CounterArray(bit<32> max_index, bool sparse); + void increment(in bit<32> index); +} + +extern array_table { + array_table(bit<32> size); +} + +extern hash_table { + hash_table(bit<32> size); +} +parser parse(packet_in packet, out H headers); +control filter(inout H headers, out bool accept); +package ebpfFilter(parse prs, filter filt); typedef bit<48> @ethernetaddress EthernetAddress; typedef bit<32> @ipv4address IPv4Address; header Ethernet_h { diff --git a/testdata/v1_2_samples_outputs/decl-fe.p4 b/testdata/v1_2_samples_outputs/decl-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/decl-fe.p4 rename to testdata/v1_2_samples_outputs/decl-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/decl-last.p4 b/testdata/v1_2_samples_outputs/decl-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/decl-last.p4 rename to testdata/v1_2_samples_outputs/decl-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/decl2-fe.p4 b/testdata/v1_2_samples_outputs/decl2-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/decl2-fe.p4 rename to testdata/v1_2_samples_outputs/decl2-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/decl2-last.p4 b/testdata/v1_2_samples_outputs/decl2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/decl2-last.p4 rename to testdata/v1_2_samples_outputs/decl2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/decl2-midend.p4 b/testdata/v1_2_samples_outputs/decl2-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/decl2-midend.p4 rename to testdata/v1_2_samples_outputs/decl2-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/direct-action-fe.p4 b/testdata/v1_2_samples_outputs/direct-action-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/direct-action-fe.p4 rename to testdata/v1_2_samples_outputs/direct-action-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/direct-action-last.p4 b/testdata/v1_2_samples_outputs/direct-action-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/direct-action-last.p4 rename to testdata/v1_2_samples_outputs/direct-action-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/direct-action-midend.p4 b/testdata/v1_2_samples_outputs/direct-action-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/direct-action-midend.p4 rename to testdata/v1_2_samples_outputs/direct-action-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/ebpf_headers-fe.p4 b/testdata/v1_2_samples_outputs/ebpf_headers-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/ebpf_headers-fe.p4 rename to testdata/v1_2_samples_outputs/ebpf_headers-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/ebpf_headers-last.p4 b/testdata/v1_2_samples_outputs/ebpf_headers-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/ebpf_headers-last.p4 rename to testdata/v1_2_samples_outputs/ebpf_headers-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/empty-fe.p4 b/testdata/v1_2_samples_outputs/empty-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/empty-fe.p4 rename to testdata/v1_2_samples_outputs/empty-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/empty-last.p4 b/testdata/v1_2_samples_outputs/empty-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/empty-last.p4 rename to testdata/v1_2_samples_outputs/empty-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/enum-fe.p4 b/testdata/v1_2_samples_outputs/enum-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/enum-fe.p4 rename to testdata/v1_2_samples_outputs/enum-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/enum-last.p4 b/testdata/v1_2_samples_outputs/enum-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/enum-last.p4 rename to testdata/v1_2_samples_outputs/enum-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/ex1-fe.p4 b/testdata/v1_2_samples_outputs/ex1-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/ex1-fe.p4 rename to testdata/v1_2_samples_outputs/ex1-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/ex1-last.p4 b/testdata/v1_2_samples_outputs/ex1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/ex1-last.p4 rename to testdata/v1_2_samples_outputs/ex1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/expression-fe.p4 b/testdata/v1_2_samples_outputs/expression-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/expression-fe.p4 rename to testdata/v1_2_samples_outputs/expression-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/expression-last.p4 b/testdata/v1_2_samples_outputs/expression-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/expression-last.p4 rename to testdata/v1_2_samples_outputs/expression-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/extern-fe.p4 b/testdata/v1_2_samples_outputs/extern-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/extern-fe.p4 rename to testdata/v1_2_samples_outputs/extern-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/extern-last.p4 b/testdata/v1_2_samples_outputs/extern-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/extern-last.p4 rename to testdata/v1_2_samples_outputs/extern-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/filter-fe.p4 b/testdata/v1_2_samples_outputs/filter-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/filter-fe.p4 rename to testdata/v1_2_samples_outputs/filter-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/filter-last.p4 b/testdata/v1_2_samples_outputs/filter-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/filter-last.p4 rename to testdata/v1_2_samples_outputs/filter-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/fold_match-fe.p4 b/testdata/v1_2_samples_outputs/fold_match-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/fold_match-fe.p4 rename to testdata/v1_2_samples_outputs/fold_match-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/fold_match-last.p4 b/testdata/v1_2_samples_outputs/fold_match-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/fold_match-last.p4 rename to testdata/v1_2_samples_outputs/fold_match-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/functors-fe.p4 b/testdata/v1_2_samples_outputs/functors-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors-fe.p4 rename to testdata/v1_2_samples_outputs/functors-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/functors-last.p4 b/testdata/v1_2_samples_outputs/functors-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors-last.p4 rename to testdata/v1_2_samples_outputs/functors-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/functors-midend.p4 b/testdata/v1_2_samples_outputs/functors-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors-midend.p4 rename to testdata/v1_2_samples_outputs/functors-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/functors1-fe.p4 b/testdata/v1_2_samples_outputs/functors1-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors1-fe.p4 rename to testdata/v1_2_samples_outputs/functors1-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/functors1-last.p4 b/testdata/v1_2_samples_outputs/functors1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors1-last.p4 rename to testdata/v1_2_samples_outputs/functors1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/functors1-midend.p4 b/testdata/v1_2_samples_outputs/functors1-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors1-midend.p4 rename to testdata/v1_2_samples_outputs/functors1-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/functors2-fe.p4 b/testdata/v1_2_samples_outputs/functors2-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors2-fe.p4 rename to testdata/v1_2_samples_outputs/functors2-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/functors2-last.p4 b/testdata/v1_2_samples_outputs/functors2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors2-last.p4 rename to testdata/v1_2_samples_outputs/functors2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/functors2-midend.p4 b/testdata/v1_2_samples_outputs/functors2-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors2-midend.p4 rename to testdata/v1_2_samples_outputs/functors2-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/functors3-fe.p4 b/testdata/v1_2_samples_outputs/functors3-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors3-fe.p4 rename to testdata/v1_2_samples_outputs/functors3-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/functors3-last.p4 b/testdata/v1_2_samples_outputs/functors3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors3-last.p4 rename to testdata/v1_2_samples_outputs/functors3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/functors3-midend.p4 b/testdata/v1_2_samples_outputs/functors3-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors3-midend.p4 rename to testdata/v1_2_samples_outputs/functors3-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/functors4-fe.p4 b/testdata/v1_2_samples_outputs/functors4-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors4-fe.p4 rename to testdata/v1_2_samples_outputs/functors4-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/functors4-last.p4 b/testdata/v1_2_samples_outputs/functors4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors4-last.p4 rename to testdata/v1_2_samples_outputs/functors4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/functors4-midend.p4 b/testdata/v1_2_samples_outputs/functors4-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors4-midend.p4 rename to testdata/v1_2_samples_outputs/functors4-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/functors5-fe.p4 b/testdata/v1_2_samples_outputs/functors5-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors5-fe.p4 rename to testdata/v1_2_samples_outputs/functors5-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/functors5-last.p4 b/testdata/v1_2_samples_outputs/functors5-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors5-last.p4 rename to testdata/v1_2_samples_outputs/functors5-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/functors5-midend.p4 b/testdata/v1_2_samples_outputs/functors5-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors5-midend.p4 rename to testdata/v1_2_samples_outputs/functors5-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/functors6-fe.p4 b/testdata/v1_2_samples_outputs/functors6-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors6-fe.p4 rename to testdata/v1_2_samples_outputs/functors6-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/functors6-last.p4 b/testdata/v1_2_samples_outputs/functors6-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors6-last.p4 rename to testdata/v1_2_samples_outputs/functors6-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/functors6-midend.p4 b/testdata/v1_2_samples_outputs/functors6-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors6-midend.p4 rename to testdata/v1_2_samples_outputs/functors6-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/functors7-fe.p4 b/testdata/v1_2_samples_outputs/functors7-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors7-fe.p4 rename to testdata/v1_2_samples_outputs/functors7-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/functors7-last.p4 b/testdata/v1_2_samples_outputs/functors7-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors7-last.p4 rename to testdata/v1_2_samples_outputs/functors7-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/functors7-midend.p4 b/testdata/v1_2_samples_outputs/functors7-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors7-midend.p4 rename to testdata/v1_2_samples_outputs/functors7-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/functors8-fe.p4 b/testdata/v1_2_samples_outputs/functors8-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors8-fe.p4 rename to testdata/v1_2_samples_outputs/functors8-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/functors8-last.p4 b/testdata/v1_2_samples_outputs/functors8-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors8-last.p4 rename to testdata/v1_2_samples_outputs/functors8-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/functors8-midend.p4 b/testdata/v1_2_samples_outputs/functors8-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors8-midend.p4 rename to testdata/v1_2_samples_outputs/functors8-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/functors9-fe.p4 b/testdata/v1_2_samples_outputs/functors9-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors9-fe.p4 rename to testdata/v1_2_samples_outputs/functors9-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/functors9-last.p4 b/testdata/v1_2_samples_outputs/functors9-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors9-last.p4 rename to testdata/v1_2_samples_outputs/functors9-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/functors9-midend.p4 b/testdata/v1_2_samples_outputs/functors9-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/functors9-midend.p4 rename to testdata/v1_2_samples_outputs/functors9-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/generic-fe.p4 b/testdata/v1_2_samples_outputs/generic-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/generic-fe.p4 rename to testdata/v1_2_samples_outputs/generic-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/generic-last.p4 b/testdata/v1_2_samples_outputs/generic-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/generic-last.p4 rename to testdata/v1_2_samples_outputs/generic-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/global-action-fe.p4 b/testdata/v1_2_samples_outputs/global-action-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/global-action-fe.p4 rename to testdata/v1_2_samples_outputs/global-action-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/global-action-last.p4 b/testdata/v1_2_samples_outputs/global-action-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/global-action-last.p4 rename to testdata/v1_2_samples_outputs/global-action-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/global-action-midend.p4 b/testdata/v1_2_samples_outputs/global-action-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/global-action-midend.p4 rename to testdata/v1_2_samples_outputs/global-action-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/global-action1-fe.p4 b/testdata/v1_2_samples_outputs/global-action1-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/global-action1-fe.p4 rename to testdata/v1_2_samples_outputs/global-action1-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/global-action1-last.p4 b/testdata/v1_2_samples_outputs/global-action1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/global-action1-last.p4 rename to testdata/v1_2_samples_outputs/global-action1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/global-action1-midend.p4 b/testdata/v1_2_samples_outputs/global-action1-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/global-action1-midend.p4 rename to testdata/v1_2_samples_outputs/global-action1-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/header-fe.p4 b/testdata/v1_2_samples_outputs/header-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/header-fe.p4 rename to testdata/v1_2_samples_outputs/header-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/header-last.p4 b/testdata/v1_2_samples_outputs/header-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/header-last.p4 rename to testdata/v1_2_samples_outputs/header-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/highorder-fe.p4 b/testdata/v1_2_samples_outputs/highorder-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/highorder-fe.p4 rename to testdata/v1_2_samples_outputs/highorder-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/highorder-last.p4 b/testdata/v1_2_samples_outputs/highorder-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/highorder-last.p4 rename to testdata/v1_2_samples_outputs/highorder-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/highorder-midend.p4 b/testdata/v1_2_samples_outputs/highorder-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/highorder-midend.p4 rename to testdata/v1_2_samples_outputs/highorder-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/implicit-fe.p4 b/testdata/v1_2_samples_outputs/implicit-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/implicit-fe.p4 rename to testdata/v1_2_samples_outputs/implicit-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/implicit-last.p4 b/testdata/v1_2_samples_outputs/implicit-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/implicit-last.p4 rename to testdata/v1_2_samples_outputs/implicit-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/initializer-fe.p4 b/testdata/v1_2_samples_outputs/initializer-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/initializer-fe.p4 rename to testdata/v1_2_samples_outputs/initializer-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/initializer-last.p4 b/testdata/v1_2_samples_outputs/initializer-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/initializer-last.p4 rename to testdata/v1_2_samples_outputs/initializer-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/inline-fe.p4 b/testdata/v1_2_samples_outputs/inline-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/inline-fe.p4 rename to testdata/v1_2_samples_outputs/inline-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/inline-last.p4 b/testdata/v1_2_samples_outputs/inline-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/inline-last.p4 rename to testdata/v1_2_samples_outputs/inline-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/inline-midend.p4 b/testdata/v1_2_samples_outputs/inline-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/inline-midend.p4 rename to testdata/v1_2_samples_outputs/inline-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/inline-action-fe.p4 b/testdata/v1_2_samples_outputs/inline-action-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/inline-action-fe.p4 rename to testdata/v1_2_samples_outputs/inline-action-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/inline-action-last.p4 b/testdata/v1_2_samples_outputs/inline-action-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/inline-action-last.p4 rename to testdata/v1_2_samples_outputs/inline-action-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/inline-action-midend.p4 b/testdata/v1_2_samples_outputs/inline-action-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/inline-action-midend.p4 rename to testdata/v1_2_samples_outputs/inline-action-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/inline-control-fe.p4 b/testdata/v1_2_samples_outputs/inline-control-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/inline-control-fe.p4 rename to testdata/v1_2_samples_outputs/inline-control-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/inline-control-last.p4 b/testdata/v1_2_samples_outputs/inline-control-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/inline-control-last.p4 rename to testdata/v1_2_samples_outputs/inline-control-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/inline-control-midend.p4 b/testdata/v1_2_samples_outputs/inline-control-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/inline-control-midend.p4 rename to testdata/v1_2_samples_outputs/inline-control-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/inline-switch-fe.p4 b/testdata/v1_2_samples_outputs/inline-switch-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/inline-switch-fe.p4 rename to testdata/v1_2_samples_outputs/inline-switch-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/inline-switch-last.p4 b/testdata/v1_2_samples_outputs/inline-switch-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/inline-switch-last.p4 rename to testdata/v1_2_samples_outputs/inline-switch-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/inline-switch-midend.p4 b/testdata/v1_2_samples_outputs/inline-switch-MidEnd_25_Evaluator.p4 similarity index 89% rename from testdata/v1_2_samples_outputs/inline-switch-midend.p4 rename to testdata/v1_2_samples_outputs/inline-switch-MidEnd_25_Evaluator.p4 index 35ccb9d3d00..0c5a9fc2c37 100644 --- a/testdata/v1_2_samples_outputs/inline-switch-midend.p4 +++ b/testdata/v1_2_samples_outputs/inline-switch-MidEnd_25_Evaluator.p4 @@ -1,5 +1,6 @@ control d(out bit<32> x) { bit<32> x_0; + bool hasExited; bool hasReturned; @name("cinst.a1") action cinst_a1() { } @@ -13,6 +14,7 @@ control d(out bit<32> x) { default_action = cinst_a1; } action act() { + hasExited = false; hasReturned = false; } action act_0() { @@ -42,7 +44,9 @@ control d(out bit<32> x) { } } - tbl_act_0.apply(); + if (!hasExited) + tbl_act_0.apply(); + ; } } diff --git a/testdata/v1_2_samples_outputs/interface-fe.p4 b/testdata/v1_2_samples_outputs/interface-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/interface-fe.p4 rename to testdata/v1_2_samples_outputs/interface-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/interface-last.p4 b/testdata/v1_2_samples_outputs/interface-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/interface-last.p4 rename to testdata/v1_2_samples_outputs/interface-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/interface-midend.p4 b/testdata/v1_2_samples_outputs/interface-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/interface-midend.p4 rename to testdata/v1_2_samples_outputs/interface-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/interface1-fe.p4 b/testdata/v1_2_samples_outputs/interface1-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/interface1-fe.p4 rename to testdata/v1_2_samples_outputs/interface1-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/interface1-last.p4 b/testdata/v1_2_samples_outputs/interface1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/interface1-last.p4 rename to testdata/v1_2_samples_outputs/interface1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/interface1-midend.p4 b/testdata/v1_2_samples_outputs/interface1-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/interface1-midend.p4 rename to testdata/v1_2_samples_outputs/interface1-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/interface2-fe.p4 b/testdata/v1_2_samples_outputs/interface2-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/interface2-fe.p4 rename to testdata/v1_2_samples_outputs/interface2-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/interface2-last.p4 b/testdata/v1_2_samples_outputs/interface2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/interface2-last.p4 rename to testdata/v1_2_samples_outputs/interface2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/large-fe.p4 b/testdata/v1_2_samples_outputs/large-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/large-fe.p4 rename to testdata/v1_2_samples_outputs/large-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/large-last.p4 b/testdata/v1_2_samples_outputs/large-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/large-last.p4 rename to testdata/v1_2_samples_outputs/large-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/line-fe.p4 b/testdata/v1_2_samples_outputs/line-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/line-fe.p4 rename to testdata/v1_2_samples_outputs/line-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/line-last.p4 b/testdata/v1_2_samples_outputs/line-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/line-last.p4 rename to testdata/v1_2_samples_outputs/line-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/lj_example-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_2_samples_outputs/lj_example-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..0f17b74af68 --- /dev/null +++ b/testdata/v1_2_samples_outputs/lj_example-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,113 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +extern Checksum16 { + void clear(); + void update(in D dt); + void update(in bool condition, in D dt); + bit<16> get(); +} + +typedef bit<4> PortId_t; +const PortId_t REAL_PORT_COUNT = 4w8; +struct InControl { + PortId_t inputPort; +} + +const PortId_t RECIRCULATE_INPUT_PORT = 4w0xd; +const PortId_t CPU_INPUT_PORT = 4w0xe; +struct OutControl { + PortId_t outputPort; +} + +const PortId_t DROP_PORT = 4w0xf; +const PortId_t CPU_OUT_PORT = 4w0xe; +const PortId_t RECIRCULATE_OUT_PORT = 4w0xd; +parser Parser(packet_in b, out H parsedHeaders); +control MAP(inout H headers, in error parseError, in InControl inCtrl, out OutControl outCtrl); +control Deparser(inout H outputHeaders, packet_out b); +package Simple(Parser p, MAP map, Deparser d); +header ARPA_hdr { + bit<48> src; + bit<48> dest; + bit<16> etype; +} + +struct Parsed_rep { + ARPA_hdr arpa_pak; +} + +parser LJparse(packet_in b, out Parsed_rep p) { + state start { + b.extract(p.arpa_pak); + transition accept; + } +} + +control LjPipe(inout Parsed_rep p, in error parseError, in InControl inCtrl, out OutControl outCtrl) { + action Drop_action(out PortId_t port) { + port = 4w0xf; + } + action Drop_1() { + outCtrl.outputPort = 4w0xf; + } + action Forward(PortId_t outPort) { + outCtrl.outputPort = outPort; + } + table Enet_lkup() { + key = { + p.arpa_pak.dest: exact; + } + actions = { + Drop_action(outCtrl.outputPort); + Drop_1; + Forward; + } + default_action = Drop_1; + } + apply { + if (p.arpa_pak.isValid()) + Enet_lkup.apply(); + } +} + +control LJdeparse(inout Parsed_rep p, packet_out b) { + apply { + b.emit(p.arpa_pak); + } +} + +Simple(LJparse(), LjPipe(), LJdeparse()) main; diff --git a/testdata/v1_2_samples_outputs/lj_example-fe.p4 b/testdata/v1_2_samples_outputs/lj_example-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 51% rename from testdata/v1_2_samples_outputs/lj_example-fe.p4 rename to testdata/v1_2_samples_outputs/lj_example-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 48aa1ff4036..ca412be2aef 100644 --- a/testdata/v1_2_samples_outputs/lj_example-fe.p4 +++ b/testdata/v1_2_samples_outputs/lj_example-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,55 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "../testdata/v1_2_samples/simple_model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +extern Checksum16 { + void clear(); + void update(in D dt); + void update(in bool condition, in D dt); + bit<16> get(); +} + +typedef bit<4> PortId_t; +struct InControl { + PortId_t inputPort; +} + +struct OutControl { + PortId_t outputPort; +} +parser Parser(packet_in b, out H parsedHeaders); +control MAP(inout H headers, in error parseError, in InControl inCtrl, out OutControl outCtrl); +control Deparser(inout H outputHeaders, packet_out b); +package Simple(Parser p, MAP map, Deparser d); header ARPA_hdr { bit<48> src; bit<48> dest; @@ -39,7 +88,6 @@ control LjPipe(inout Parsed_rep p, in error parseError, in InControl inCtrl, out } default_action = Drop_1; } - apply { if (p.arpa_pak.isValid()) Enet_lkup.apply(); diff --git a/testdata/v1_2_samples_outputs/lj_example-midend.p4 b/testdata/v1_2_samples_outputs/lj_example-MidEnd_25_Evaluator.p4 similarity index 53% rename from testdata/v1_2_samples_outputs/lj_example-midend.p4 rename to testdata/v1_2_samples_outputs/lj_example-MidEnd_25_Evaluator.p4 index 09a821b78a1..fcabde53826 100644 --- a/testdata/v1_2_samples_outputs/lj_example-midend.p4 +++ b/testdata/v1_2_samples_outputs/lj_example-MidEnd_25_Evaluator.p4 @@ -1,6 +1,55 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "../testdata/v1_2_samples/simple_model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +extern Checksum16 { + void clear(); + void update(in D dt); + void update(in bool condition, in D dt); + bit<16> get(); +} + +typedef bit<4> PortId_t; +struct InControl { + PortId_t inputPort; +} + +struct OutControl { + PortId_t outputPort; +} +parser Parser(packet_in b, out H parsedHeaders); +control MAP(inout H headers, in error parseError, in InControl inCtrl, out OutControl outCtrl); +control Deparser(inout H outputHeaders, packet_out b); +package Simple(Parser p, MAP map, Deparser d); header ARPA_hdr { bit<48> src; bit<48> dest; diff --git a/testdata/v1_2_samples_outputs/lj_example-last.p4 b/testdata/v1_2_samples_outputs/lj_example-last.p4 deleted file mode 100644 index 48aa1ff4036..00000000000 --- a/testdata/v1_2_samples_outputs/lj_example-last.p4 +++ /dev/null @@ -1,55 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "../testdata/v1_2_samples/simple_model.p4" - -header ARPA_hdr { - bit<48> src; - bit<48> dest; - bit<16> etype; -} - -struct Parsed_rep { - ARPA_hdr arpa_pak; -} - -parser LJparse(packet_in b, out Parsed_rep p) { - state start { - b.extract(p.arpa_pak); - transition accept; - } -} - -control LjPipe(inout Parsed_rep p, in error parseError, in InControl inCtrl, out OutControl outCtrl) { - action Drop_action(out PortId_t port) { - port = 4w0xf; - } - action Drop_1() { - outCtrl.outputPort = 4w0xf; - } - action Forward(PortId_t outPort) { - outCtrl.outputPort = outPort; - } - table Enet_lkup() { - key = { - p.arpa_pak.dest: exact; - } - actions = { - Drop_action(outCtrl.outputPort); - Drop_1; - Forward; - } - default_action = Drop_1; - } - - apply { - if (p.arpa_pak.isValid()) - Enet_lkup.apply(); - } -} - -control LJdeparse(inout Parsed_rep p, packet_out b) { - apply { - b.emit(p.arpa_pak); - } -} - -Simple(LJparse(), LjPipe(), LJdeparse()) main; diff --git a/testdata/v1_2_samples_outputs/lj_example.p4 b/testdata/v1_2_samples_outputs/lj_example.p4 index 927a4c88cbb..38f8c661ca8 100644 --- a/testdata/v1_2_samples_outputs/lj_example.p4 +++ b/testdata/v1_2_samples_outputs/lj_example.p4 @@ -39,7 +39,6 @@ control LjPipe(inout Parsed_rep p, in error parseError, in InControl inCtrl, out } default_action = Drop_1; } - apply { if (p.arpa_pak.isValid()) Enet_lkup.apply(); diff --git a/testdata/v1_2_samples_outputs/match-fe.p4 b/testdata/v1_2_samples_outputs/match-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 69% rename from testdata/v1_2_samples_outputs/match-fe.p4 rename to testdata/v1_2_samples_outputs/match-FrontEnd_11_SimplifyControlFlowE.p4 index 2e3f92e25f3..2023d1beded 100644 --- a/testdata/v1_2_samples_outputs/match-fe.p4 +++ b/testdata/v1_2_samples_outputs/match-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,4 +1,38 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} header Ipv4_no_options_h { bit<4> version; diff --git a/testdata/v1_2_samples_outputs/match-last.p4 b/testdata/v1_2_samples_outputs/match-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 52% rename from testdata/v1_2_samples_outputs/match-last.p4 rename to testdata/v1_2_samples_outputs/match-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 53a77633dd0..72577858b7d 100644 --- a/testdata/v1_2_samples_outputs/match-last.p4 +++ b/testdata/v1_2_samples_outputs/match-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,4 +1,34 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} header Ipv4_no_options_h { bit<4> version; diff --git a/testdata/v1_2_samples_outputs/module-fe.p4 b/testdata/v1_2_samples_outputs/module-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/module-fe.p4 rename to testdata/v1_2_samples_outputs/module-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/module-last.p4 b/testdata/v1_2_samples_outputs/module-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/module-last.p4 rename to testdata/v1_2_samples_outputs/module-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/names-fe.p4 b/testdata/v1_2_samples_outputs/names-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/names-fe.p4 rename to testdata/v1_2_samples_outputs/names-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/names-last.p4 b/testdata/v1_2_samples_outputs/names-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/names-last.p4 rename to testdata/v1_2_samples_outputs/names-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/parse-fe.p4 b/testdata/v1_2_samples_outputs/parse-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/parse-fe.p4 rename to testdata/v1_2_samples_outputs/parse-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/parse-last.p4 b/testdata/v1_2_samples_outputs/parse-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/parse-last.p4 rename to testdata/v1_2_samples_outputs/parse-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/parser-locals-fe.p4 b/testdata/v1_2_samples_outputs/parser-locals-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/parser-locals-fe.p4 rename to testdata/v1_2_samples_outputs/parser-locals-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/parser-locals-last.p4 b/testdata/v1_2_samples_outputs/parser-locals-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/parser-locals-last.p4 rename to testdata/v1_2_samples_outputs/parser-locals-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/parser-locals-midend.p4 b/testdata/v1_2_samples_outputs/parser-locals-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/parser-locals-midend.p4 rename to testdata/v1_2_samples_outputs/parser-locals-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/pipe-fe.p4 b/testdata/v1_2_samples_outputs/pipe-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/pipe-fe.p4 rename to testdata/v1_2_samples_outputs/pipe-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/pipe-last.p4 b/testdata/v1_2_samples_outputs/pipe-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/pipe-last.p4 rename to testdata/v1_2_samples_outputs/pipe-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/pipe-midend.p4 b/testdata/v1_2_samples_outputs/pipe-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/pipe-midend.p4 rename to testdata/v1_2_samples_outputs/pipe-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/pipeline-fe.p4 b/testdata/v1_2_samples_outputs/pipeline-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/pipeline-fe.p4 rename to testdata/v1_2_samples_outputs/pipeline-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/pipeline-last.p4 b/testdata/v1_2_samples_outputs/pipeline-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/pipeline-last.p4 rename to testdata/v1_2_samples_outputs/pipeline-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/precedence-fe.p4 b/testdata/v1_2_samples_outputs/precedence-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/precedence-fe.p4 rename to testdata/v1_2_samples_outputs/precedence-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/precedence-last.p4 b/testdata/v1_2_samples_outputs/precedence-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/precedence-last.p4 rename to testdata/v1_2_samples_outputs/precedence-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/select-type-fe.p4 b/testdata/v1_2_samples_outputs/select-type-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/select-type-fe.p4 rename to testdata/v1_2_samples_outputs/select-type-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/select-type-last.p4 b/testdata/v1_2_samples_outputs/select-type-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/select-type-last.p4 rename to testdata/v1_2_samples_outputs/select-type-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/shadow-fe.p4 b/testdata/v1_2_samples_outputs/shadow-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/shadow-fe.p4 rename to testdata/v1_2_samples_outputs/shadow-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/shadow-last.p4 b/testdata/v1_2_samples_outputs/shadow-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/shadow-last.p4 rename to testdata/v1_2_samples_outputs/shadow-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/simple-switch-example-last.p4 b/testdata/v1_2_samples_outputs/simple-switch-example-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 72% rename from testdata/v1_2_samples_outputs/simple-switch-example-last.p4 rename to testdata/v1_2_samples_outputs/simple-switch-example-FrontEnd_11_SimplifyControlFlowE.p4 index b9f3b44cd4a..a1d5194e416 100644 --- a/testdata/v1_2_samples_outputs/simple-switch-example-last.p4 +++ b/testdata/v1_2_samples_outputs/simple-switch-example-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,65 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "../testdata/v1_2_samples/simple_model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +extern Checksum16 { + void clear(); + void update(in D dt); + void update(in bool condition, in D dt); + bit<16> get(); +} + +typedef bit<4> PortId_t; +const PortId_t REAL_PORT_COUNT = 4w8; +struct InControl { + PortId_t inputPort; +} + +const PortId_t RECIRCULATE_INPUT_PORT = 4w0xd; +const PortId_t CPU_INPUT_PORT = 4w0xe; +struct OutControl { + PortId_t outputPort; +} +const PortId_t DROP_PORT = 4w0xf; +const PortId_t CPU_OUT_PORT = 4w0xe; +const PortId_t RECIRCULATE_OUT_PORT = 4w0xd; +parser Parser(packet_in b, out H parsedHeaders); +control MAP(inout H headers, in error parseError, in InControl inCtrl, out OutControl outCtrl); +control Deparser(inout H outputHeaders, packet_out b); +package Simple(Parser p, MAP map, Deparser d); typedef bit<48> @ethernetaddress EthernetAddress; typedef bit<32> @ipv4address IPv4Address; header Ethernet_h { diff --git a/testdata/v1_2_samples_outputs/simple-switch-example-fe.p4 b/testdata/v1_2_samples_outputs/simple-switch-example-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 76% rename from testdata/v1_2_samples_outputs/simple-switch-example-fe.p4 rename to testdata/v1_2_samples_outputs/simple-switch-example-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index b9f3b44cd4a..ea3c90251a1 100644 --- a/testdata/v1_2_samples_outputs/simple-switch-example-fe.p4 +++ b/testdata/v1_2_samples_outputs/simple-switch-example-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,58 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "../testdata/v1_2_samples/simple_model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +extern Checksum16 { + void clear(); + void update(in D dt); + void update(in bool condition, in D dt); + bit<16> get(); +} + +typedef bit<4> PortId_t; +struct InControl { + PortId_t inputPort; +} + +struct OutControl { + PortId_t outputPort; +} +parser Parser(packet_in b, out H parsedHeaders); +control MAP(inout H headers, in error parseError, in InControl inCtrl, out OutControl outCtrl); +control Deparser(inout H outputHeaders, packet_out b); +package Simple(Parser p, MAP map, Deparser d); typedef bit<48> @ethernetaddress EthernetAddress; typedef bit<32> @ipv4address IPv4Address; header Ethernet_h { diff --git a/testdata/v1_2_samples_outputs/simple-switch-example-midend.p4 b/testdata/v1_2_samples_outputs/simple-switch-example-MidEnd_25_Evaluator.p4 similarity index 84% rename from testdata/v1_2_samples_outputs/simple-switch-example-midend.p4 rename to testdata/v1_2_samples_outputs/simple-switch-example-MidEnd_25_Evaluator.p4 index ce52a9ce19d..88701b17011 100644 --- a/testdata/v1_2_samples_outputs/simple-switch-example-midend.p4 +++ b/testdata/v1_2_samples_outputs/simple-switch-example-MidEnd_25_Evaluator.p4 @@ -1,6 +1,56 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "../testdata/v1_2_samples/simple_model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +match_kind { + exact, + ternary, + lpm +} + +extern Checksum16 { + void clear(); + void update(in D dt); + void update(in bool condition, in D dt); + bit<16> get(); +} + +typedef bit<4> PortId_t; +struct InControl { + PortId_t inputPort; +} + +struct OutControl { + PortId_t outputPort; +} +parser Parser(packet_in b, out H parsedHeaders); +control MAP(inout H headers, in error parseError, in InControl inCtrl, out OutControl outCtrl); +control Deparser(inout H outputHeaders, packet_out b); +package Simple(Parser p, MAP map, Deparser d); typedef bit<48> @ethernetaddress EthernetAddress; typedef bit<32> @ipv4address IPv4Address; header Ethernet_h { diff --git a/testdata/v1_2_samples_outputs/simple_model-fe.p4 b/testdata/v1_2_samples_outputs/simple_model-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 56% rename from testdata/v1_2_samples_outputs/simple_model-fe.p4 rename to testdata/v1_2_samples_outputs/simple_model-FrontEnd_11_SimplifyControlFlowE.p4 index af9bb0e4b3c..14b114b536a 100644 --- a/testdata/v1_2_samples_outputs/simple_model-fe.p4 +++ b/testdata/v1_2_samples_outputs/simple_model-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,4 +1,38 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} extern Checksum16 { void clear(); diff --git a/testdata/v1_2_samples_outputs/simple_model-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_2_samples_outputs/simple_model-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..c0a0a9e4b17 --- /dev/null +++ b/testdata/v1_2_samples_outputs/simple_model-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,48 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +extern Checksum16 { + void clear(); + void update(in D dt); + void update(in bool condition, in D dt); + bit<16> get(); +} + +typedef bit<4> PortId_t; +struct InControl { + PortId_t inputPort; +} + +struct OutControl { + PortId_t outputPort; +} + diff --git a/testdata/v1_2_samples_outputs/simple_model-last.p4 b/testdata/v1_2_samples_outputs/simple_model-last.p4 deleted file mode 100644 index d0f738fef2a..00000000000 --- a/testdata/v1_2_samples_outputs/simple_model-last.p4 +++ /dev/null @@ -1,18 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" - -extern Checksum16 { - void clear(); - void update(in D dt); - void update(in bool condition, in D dt); - bit<16> get(); -} - -typedef bit<4> PortId_t; -struct InControl { - PortId_t inputPort; -} - -struct OutControl { - PortId_t outputPort; -} - diff --git a/testdata/v1_2_samples_outputs/spec-ex01-fe.p4 b/testdata/v1_2_samples_outputs/spec-ex01-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/spec-ex01-fe.p4 rename to testdata/v1_2_samples_outputs/spec-ex01-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/spec-ex01-last.p4 b/testdata/v1_2_samples_outputs/spec-ex01-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/spec-ex01-last.p4 rename to testdata/v1_2_samples_outputs/spec-ex01-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/spec-ex03-fe.p4 b/testdata/v1_2_samples_outputs/spec-ex03-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/spec-ex03-fe.p4 rename to testdata/v1_2_samples_outputs/spec-ex03-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/spec-ex03-last.p4 b/testdata/v1_2_samples_outputs/spec-ex03-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/spec-ex03-last.p4 rename to testdata/v1_2_samples_outputs/spec-ex03-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/spec-ex04-fe.p4 b/testdata/v1_2_samples_outputs/spec-ex04-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/spec-ex04-fe.p4 rename to testdata/v1_2_samples_outputs/spec-ex04-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/spec-ex04-last.p4 b/testdata/v1_2_samples_outputs/spec-ex04-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/spec-ex04-last.p4 rename to testdata/v1_2_samples_outputs/spec-ex04-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/spec-ex06-fe.p4 b/testdata/v1_2_samples_outputs/spec-ex06-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/spec-ex06-fe.p4 rename to testdata/v1_2_samples_outputs/spec-ex06-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/spec-ex06-last.p4 b/testdata/v1_2_samples_outputs/spec-ex06-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/spec-ex06-last.p4 rename to testdata/v1_2_samples_outputs/spec-ex06-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/spec-ex08-fe.p4 b/testdata/v1_2_samples_outputs/spec-ex08-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/spec-ex08-fe.p4 rename to testdata/v1_2_samples_outputs/spec-ex08-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/spec-ex08-last.p4 b/testdata/v1_2_samples_outputs/spec-ex08-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/spec-ex08-last.p4 rename to testdata/v1_2_samples_outputs/spec-ex08-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/spec-ex09-fe.p4 b/testdata/v1_2_samples_outputs/spec-ex09-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/spec-ex09-fe.p4 rename to testdata/v1_2_samples_outputs/spec-ex09-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/spec-ex09-last.p4 b/testdata/v1_2_samples_outputs/spec-ex09-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/spec-ex09-last.p4 rename to testdata/v1_2_samples_outputs/spec-ex09-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/spec-ex10-fe.p4 b/testdata/v1_2_samples_outputs/spec-ex10-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/spec-ex10-fe.p4 rename to testdata/v1_2_samples_outputs/spec-ex10-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/spec-ex10-last.p4 b/testdata/v1_2_samples_outputs/spec-ex10-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/spec-ex10-last.p4 rename to testdata/v1_2_samples_outputs/spec-ex10-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/spec-ex12-fe.p4 b/testdata/v1_2_samples_outputs/spec-ex12-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/spec-ex12-fe.p4 rename to testdata/v1_2_samples_outputs/spec-ex12-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/spec-ex12-last.p4 b/testdata/v1_2_samples_outputs/spec-ex12-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/spec-ex12-last.p4 rename to testdata/v1_2_samples_outputs/spec-ex12-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/spec-ex13-fe.p4 b/testdata/v1_2_samples_outputs/spec-ex13-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/spec-ex13-fe.p4 rename to testdata/v1_2_samples_outputs/spec-ex13-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/spec-ex13-last.p4 b/testdata/v1_2_samples_outputs/spec-ex13-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/spec-ex13-last.p4 rename to testdata/v1_2_samples_outputs/spec-ex13-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/spec-ex14-fe.p4 b/testdata/v1_2_samples_outputs/spec-ex14-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/spec-ex14-fe.p4 rename to testdata/v1_2_samples_outputs/spec-ex14-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/spec-ex14-last.p4 b/testdata/v1_2_samples_outputs/spec-ex14-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/spec-ex14-last.p4 rename to testdata/v1_2_samples_outputs/spec-ex14-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/spec-ex15-fe.p4 b/testdata/v1_2_samples_outputs/spec-ex15-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 52% rename from testdata/v1_2_samples_outputs/spec-ex15-fe.p4 rename to testdata/v1_2_samples_outputs/spec-ex15-FrontEnd_11_SimplifyControlFlowE.p4 index 54aa5b98244..b3d30183fb9 100644 --- a/testdata/v1_2_samples_outputs/spec-ex15-fe.p4 +++ b/testdata/v1_2_samples_outputs/spec-ex15-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,4 +1,38 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} struct InControl { } diff --git a/testdata/v1_2_samples_outputs/spec-ex15-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_2_samples_outputs/spec-ex15-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..09fd4963fca --- /dev/null +++ b/testdata/v1_2_samples_outputs/spec-ex15-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,38 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +struct InControl { +} + +struct OutControl { +} + diff --git a/testdata/v1_2_samples_outputs/spec-ex15-last.p4 b/testdata/v1_2_samples_outputs/spec-ex15-last.p4 deleted file mode 100644 index bf56424e1f3..00000000000 --- a/testdata/v1_2_samples_outputs/spec-ex15-last.p4 +++ /dev/null @@ -1,8 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" - -struct InControl { -} - -struct OutControl { -} - diff --git a/testdata/v1_2_samples_outputs/spec-ex16-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_2_samples_outputs/spec-ex16-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..32714d23de4 --- /dev/null +++ b/testdata/v1_2_samples_outputs/spec-ex16-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,56 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +parser Prs(packet_in b, out T result); +control Map(in T d); +package Switch(Prs prs, Map map); +parser P(packet_in b, out bit<32> d) { + state start { + } +} + +control Map1(in bit<32> d) { + apply { + } +} + +control Map2(in bit<8> d) { + apply { + } +} + +Switch(P(), Map1()) main; +Switch>(P(), Map1()) main1; diff --git a/testdata/v1_2_samples_outputs/spec-ex16-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_2_samples_outputs/spec-ex16-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..46e6a607e33 --- /dev/null +++ b/testdata/v1_2_samples_outputs/spec-ex16-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,46 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +parser Prs(packet_in b, out T result); +control Map(in T d); +package Switch(Prs prs, Map map); +parser P(packet_in b, out bit<32> d) { + state start { + } +} + +control Map1(in bit<32> d) { + apply { + } +} + +Switch(P(), Map1()) main; diff --git a/testdata/v1_2_samples_outputs/spec-ex16-MidEnd_25_Evaluator.p4 b/testdata/v1_2_samples_outputs/spec-ex16-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..46e6a607e33 --- /dev/null +++ b/testdata/v1_2_samples_outputs/spec-ex16-MidEnd_25_Evaluator.p4 @@ -0,0 +1,46 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +parser Prs(packet_in b, out T result); +control Map(in T d); +package Switch(Prs prs, Map map); +parser P(packet_in b, out bit<32> d) { + state start { + } +} + +control Map1(in bit<32> d) { + apply { + } +} + +Switch(P(), Map1()) main; diff --git a/testdata/v1_2_samples_outputs/spec-ex16-fe.p4 b/testdata/v1_2_samples_outputs/spec-ex16-fe.p4 deleted file mode 100644 index c175707cd00..00000000000 --- a/testdata/v1_2_samples_outputs/spec-ex16-fe.p4 +++ /dev/null @@ -1,22 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" - -parser Prs(packet_in b, out T result); -control Map(in T d); -package Switch(Prs prs, Map map); -parser P(packet_in b, out bit<32> d) { - state start { - } -} - -control Map1(in bit<32> d) { - apply { - } -} - -control Map2(in bit<8> d) { - apply { - } -} - -Switch(P(), Map1()) main; -Switch>(P(), Map1()) main1; diff --git a/testdata/v1_2_samples_outputs/spec-ex16-last.p4 b/testdata/v1_2_samples_outputs/spec-ex16-last.p4 deleted file mode 100644 index 762f8d00ea7..00000000000 --- a/testdata/v1_2_samples_outputs/spec-ex16-last.p4 +++ /dev/null @@ -1,16 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" - -parser Prs(packet_in b, out T result); -control Map(in T d); -package Switch(Prs prs, Map map); -parser P(packet_in b, out bit<32> d) { - state start { - } -} - -control Map1(in bit<32> d) { - apply { - } -} - -Switch(P(), Map1()) main; diff --git a/testdata/v1_2_samples_outputs/spec-ex16-midend.p4 b/testdata/v1_2_samples_outputs/spec-ex16-midend.p4 deleted file mode 100644 index 762f8d00ea7..00000000000 --- a/testdata/v1_2_samples_outputs/spec-ex16-midend.p4 +++ /dev/null @@ -1,16 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" - -parser Prs(packet_in b, out T result); -control Map(in T d); -package Switch(Prs prs, Map map); -parser P(packet_in b, out bit<32> d) { - state start { - } -} - -control Map1(in bit<32> d) { - apply { - } -} - -Switch(P(), Map1()) main; diff --git a/testdata/v1_2_samples_outputs/spec-ex17-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_2_samples_outputs/spec-ex17-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..f0f2933b9a1 --- /dev/null +++ b/testdata/v1_2_samples_outputs/spec-ex17-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,40 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +struct Counters { +} + +parser P(packet_in b, out IH packetHeaders, out Counters counters); diff --git a/testdata/v1_2_samples_outputs/spec-ex17-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_2_samples_outputs/spec-ex17-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..435dfad01f5 --- /dev/null +++ b/testdata/v1_2_samples_outputs/spec-ex17-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,35 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +struct Counters { +} + diff --git a/testdata/v1_2_samples_outputs/spec-ex17-fe.p4 b/testdata/v1_2_samples_outputs/spec-ex17-fe.p4 deleted file mode 100644 index 23c22c70549..00000000000 --- a/testdata/v1_2_samples_outputs/spec-ex17-fe.p4 +++ /dev/null @@ -1,6 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" - -struct Counters { -} - -parser P(packet_in b, out IH packetHeaders, out Counters counters); diff --git a/testdata/v1_2_samples_outputs/spec-ex17-last.p4 b/testdata/v1_2_samples_outputs/spec-ex17-last.p4 deleted file mode 100644 index b691de0a644..00000000000 --- a/testdata/v1_2_samples_outputs/spec-ex17-last.p4 +++ /dev/null @@ -1,5 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" - -struct Counters { -} - diff --git a/testdata/v1_2_samples_outputs/spec-ex18-fe.p4 b/testdata/v1_2_samples_outputs/spec-ex18-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 69% rename from testdata/v1_2_samples_outputs/spec-ex18-fe.p4 rename to testdata/v1_2_samples_outputs/spec-ex18-FrontEnd_11_SimplifyControlFlowE.p4 index db6054f5a6f..ea5b6e2bab7 100644 --- a/testdata/v1_2_samples_outputs/spec-ex18-fe.p4 +++ b/testdata/v1_2_samples_outputs/spec-ex18-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,4 +1,38 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} header IPv4_no_options_h { bit<4> version; diff --git a/testdata/v1_2_samples_outputs/spec-ex18-last.p4 b/testdata/v1_2_samples_outputs/spec-ex18-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 52% rename from testdata/v1_2_samples_outputs/spec-ex18-last.p4 rename to testdata/v1_2_samples_outputs/spec-ex18-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index c1d2484d85f..ae9feb2f668 100644 --- a/testdata/v1_2_samples_outputs/spec-ex18-last.p4 +++ b/testdata/v1_2_samples_outputs/spec-ex18-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,4 +1,34 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} header IPv4_no_options_h { bit<4> version; diff --git a/testdata/v1_2_samples_outputs/spec-ex19-fe.p4 b/testdata/v1_2_samples_outputs/spec-ex19-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 73% rename from testdata/v1_2_samples_outputs/spec-ex19-fe.p4 rename to testdata/v1_2_samples_outputs/spec-ex19-FrontEnd_11_SimplifyControlFlowE.p4 index 36e22379252..5c7dd7f7b3f 100644 --- a/testdata/v1_2_samples_outputs/spec-ex19-fe.p4 +++ b/testdata/v1_2_samples_outputs/spec-ex19-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,4 +1,38 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} header Mpls_h { bit<20> label; diff --git a/testdata/v1_2_samples_outputs/spec-ex19-last.p4 b/testdata/v1_2_samples_outputs/spec-ex19-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 57% rename from testdata/v1_2_samples_outputs/spec-ex19-last.p4 rename to testdata/v1_2_samples_outputs/spec-ex19-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index bdc60d0c64a..6e40d489326 100644 --- a/testdata/v1_2_samples_outputs/spec-ex19-last.p4 +++ b/testdata/v1_2_samples_outputs/spec-ex19-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,4 +1,34 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} header Mpls_h { bit<20> label; diff --git a/testdata/v1_2_samples_outputs/spec-ex20-fe.p4 b/testdata/v1_2_samples_outputs/spec-ex20-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 53% rename from testdata/v1_2_samples_outputs/spec-ex20-fe.p4 rename to testdata/v1_2_samples_outputs/spec-ex20-FrontEnd_11_SimplifyControlFlowE.p4 index 641238760aa..a5dc095692d 100644 --- a/testdata/v1_2_samples_outputs/spec-ex20-fe.p4 +++ b/testdata/v1_2_samples_outputs/spec-ex20-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,4 +1,38 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} header Ethernet_h { bit<48> dstAddr; diff --git a/testdata/v1_2_samples_outputs/spec-ex20-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_2_samples_outputs/spec-ex20-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..55983097d81 --- /dev/null +++ b/testdata/v1_2_samples_outputs/spec-ex20-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,50 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +header Ethernet_h { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +header Mpls_h { + bit<20> label; + bit<3> tc; + bit<1> bos; + bit<8> ttl; +} + +struct Pkthdr { + Ethernet_h ethernet; + Mpls_h[3] mpls_vec; +} + diff --git a/testdata/v1_2_samples_outputs/spec-ex20-last.p4 b/testdata/v1_2_samples_outputs/spec-ex20-last.p4 deleted file mode 100644 index 323df31dd4b..00000000000 --- a/testdata/v1_2_samples_outputs/spec-ex20-last.p4 +++ /dev/null @@ -1,20 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" - -header Ethernet_h { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> etherType; -} - -header Mpls_h { - bit<20> label; - bit<3> tc; - bit<1> bos; - bit<8> ttl; -} - -struct Pkthdr { - Ethernet_h ethernet; - Mpls_h[3] mpls_vec; -} - diff --git a/testdata/v1_2_samples_outputs/spec-ex22-fe.p4 b/testdata/v1_2_samples_outputs/spec-ex22-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/spec-ex22-fe.p4 rename to testdata/v1_2_samples_outputs/spec-ex22-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/spec-ex22-last.p4 b/testdata/v1_2_samples_outputs/spec-ex22-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/spec-ex22-last.p4 rename to testdata/v1_2_samples_outputs/spec-ex22-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/spec-ex25-fe.p4 b/testdata/v1_2_samples_outputs/spec-ex25-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 99% rename from testdata/v1_2_samples_outputs/spec-ex25-fe.p4 rename to testdata/v1_2_samples_outputs/spec-ex25-FrontEnd_11_SimplifyControlFlowE.p4 index 56897ef72bd..cf775dbd447 100644 --- a/testdata/v1_2_samples_outputs/spec-ex25-fe.p4 +++ b/testdata/v1_2_samples_outputs/spec-ex25-FrontEnd_11_SimplifyControlFlowE.p4 @@ -22,7 +22,6 @@ control c(bit<1> x) { default_action = Set_dmac(48w0xaabbccddeeff); implementation = tbl(); } - apply { } } diff --git a/testdata/v1_2_samples_outputs/spec-ex25-last.p4 b/testdata/v1_2_samples_outputs/spec-ex25-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/spec-ex25-last.p4 rename to testdata/v1_2_samples_outputs/spec-ex25-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/spec-ex25.p4 b/testdata/v1_2_samples_outputs/spec-ex25.p4 index 2a4aa650152..2a01aa124da 100644 --- a/testdata/v1_2_samples_outputs/spec-ex25.p4 +++ b/testdata/v1_2_samples_outputs/spec-ex25.p4 @@ -22,7 +22,6 @@ control c(bit<1> x) { default_action = Set_dmac((EthernetAddress)48w0xaabbccddeeff); implementation = tbl(); } - apply { } } diff --git a/testdata/v1_2_samples_outputs/spec-ex26-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_2_samples_outputs/spec-ex26-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..b02967ff3f2 --- /dev/null +++ b/testdata/v1_2_samples_outputs/spec-ex26-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,96 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +extern Checksum16 { + void clear(); + void update(in D dt); + void update(in bool condition, in D dt); + bit<16> get(); +} + +typedef bit<4> PortId_t; +const PortId_t REAL_PORT_COUNT = 4w8; +struct InControl { + PortId_t inputPort; +} + +const PortId_t RECIRCULATE_INPUT_PORT = 4w0xd; +const PortId_t CPU_INPUT_PORT = 4w0xe; +struct OutControl { + PortId_t outputPort; +} + +const PortId_t DROP_PORT = 4w0xf; +const PortId_t CPU_OUT_PORT = 4w0xe; +const PortId_t RECIRCULATE_OUT_PORT = 4w0xd; +parser Parser(packet_in b, out H parsedHeaders); +control MAP(inout H headers, in error parseError, in InControl inCtrl, out OutControl outCtrl); +control Deparser(inout H outputHeaders, packet_out b); +package Simple(Parser p, MAP map, Deparser d); +struct Parsed_packet { +} + +typedef bit<32> IPv4Address; +extern tbl { +} + +control Pipe(inout Parsed_packet headers, in error parseError, in InControl inCtrl, out OutControl outCtrl) { + action Drop_action(out PortId_t port) { + port = 4w0xf; + } + action drop() { + } + table IPv4_match(in IPv4Address a) { + actions = { + drop; + } + key = { + inCtrl.inputPort: exact; + } + implementation = tbl(); + default_action = drop; + } + apply { + if (parseError != NoError) { + Drop_action(outCtrl.outputPort); + return; + } + IPv4Address nextHop; + if (!IPv4_match.apply(nextHop).hit) + return; + } +} + diff --git a/testdata/v1_2_samples_outputs/spec-ex26-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_2_samples_outputs/spec-ex26-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..ceccde20e9a --- /dev/null +++ b/testdata/v1_2_samples_outputs/spec-ex26-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,54 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +extern Checksum16 { + void clear(); + void update(in D dt); + void update(in bool condition, in D dt); + bit<16> get(); +} + +typedef bit<4> PortId_t; +struct InControl { + PortId_t inputPort; +} + +struct OutControl { + PortId_t outputPort; +} + +struct Parsed_packet { +} + +extern tbl { +} + diff --git a/testdata/v1_2_samples_outputs/spec-ex26-fe.p4 b/testdata/v1_2_samples_outputs/spec-ex26-fe.p4 deleted file mode 100644 index ee9bece4116..00000000000 --- a/testdata/v1_2_samples_outputs/spec-ex26-fe.p4 +++ /dev/null @@ -1,38 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "../testdata/v1_2_samples/simple_model.p4" - -struct Parsed_packet { -} - -typedef bit<32> IPv4Address; -extern tbl { -} - -control Pipe(inout Parsed_packet headers, in error parseError, in InControl inCtrl, out OutControl outCtrl) { - action Drop_action(out PortId_t port) { - port = 4w0xf; - } - action drop() { - } - table IPv4_match(in IPv4Address a) { - actions = { - drop; - } - key = { - inCtrl.inputPort: exact; - } - implementation = tbl(); - default_action = drop; - } - - apply { - if (parseError != NoError) { - Drop_action(outCtrl.outputPort); - return; - } - IPv4Address nextHop; - if (!IPv4_match.apply(nextHop).hit) - return; - } -} - diff --git a/testdata/v1_2_samples_outputs/spec-ex26-last.p4 b/testdata/v1_2_samples_outputs/spec-ex26-last.p4 deleted file mode 100644 index 2e5fa514a93..00000000000 --- a/testdata/v1_2_samples_outputs/spec-ex26-last.p4 +++ /dev/null @@ -1,9 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "../testdata/v1_2_samples/simple_model.p4" - -struct Parsed_packet { -} - -extern tbl { -} - diff --git a/testdata/v1_2_samples_outputs/spec-ex26.p4 b/testdata/v1_2_samples_outputs/spec-ex26.p4 index 81e5e8d6c6d..adeb2e09c9c 100644 --- a/testdata/v1_2_samples_outputs/spec-ex26.p4 +++ b/testdata/v1_2_samples_outputs/spec-ex26.p4 @@ -24,7 +24,6 @@ control Pipe(inout Parsed_packet headers, in error parseError, in InControl inCt implementation = tbl(); default_action = drop; } - apply { if (parseError != NoError) { Drop_action(outCtrl.outputPort); diff --git a/testdata/v1_2_samples_outputs/spec-ex27-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_2_samples_outputs/spec-ex27-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..6547fb5d54c --- /dev/null +++ b/testdata/v1_2_samples_outputs/spec-ex27-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,40 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +struct Ports { +} + +control Dep(packet_out b, in OH packetHeaders, in Ports ports); diff --git a/testdata/v1_2_samples_outputs/spec-ex27-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_2_samples_outputs/spec-ex27-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..9870f68157f --- /dev/null +++ b/testdata/v1_2_samples_outputs/spec-ex27-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,35 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +struct Ports { +} + diff --git a/testdata/v1_2_samples_outputs/spec-ex27-fe.p4 b/testdata/v1_2_samples_outputs/spec-ex27-fe.p4 deleted file mode 100644 index c6963ae00a0..00000000000 --- a/testdata/v1_2_samples_outputs/spec-ex27-fe.p4 +++ /dev/null @@ -1,6 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" - -struct Ports { -} - -control Dep(packet_out b, in OH packetHeaders, in Ports ports); diff --git a/testdata/v1_2_samples_outputs/spec-ex27-last.p4 b/testdata/v1_2_samples_outputs/spec-ex27-last.p4 deleted file mode 100644 index ef681cadadd..00000000000 --- a/testdata/v1_2_samples_outputs/spec-ex27-last.p4 +++ /dev/null @@ -1,5 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" - -struct Ports { -} - diff --git a/testdata/v1_2_samples_outputs/spec-ex29-fe.p4 b/testdata/v1_2_samples_outputs/spec-ex29-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 70% rename from testdata/v1_2_samples_outputs/spec-ex29-fe.p4 rename to testdata/v1_2_samples_outputs/spec-ex29-FrontEnd_11_SimplifyControlFlowE.p4 index 7957ea1d72e..fc4aa487e38 100644 --- a/testdata/v1_2_samples_outputs/spec-ex29-fe.p4 +++ b/testdata/v1_2_samples_outputs/spec-ex29-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,4 +1,38 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} header Ethernet { bit<16> etherType; diff --git a/testdata/v1_2_samples_outputs/spec-ex29-last.p4 b/testdata/v1_2_samples_outputs/spec-ex29-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 56% rename from testdata/v1_2_samples_outputs/spec-ex29-last.p4 rename to testdata/v1_2_samples_outputs/spec-ex29-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 94c519d6b7d..e3f368b3d22 100644 --- a/testdata/v1_2_samples_outputs/spec-ex29-last.p4 +++ b/testdata/v1_2_samples_outputs/spec-ex29-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,4 +1,34 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} header Ethernet { bit<16> etherType; diff --git a/testdata/v1_2_samples_outputs/spec-ex30-fe.p4 b/testdata/v1_2_samples_outputs/spec-ex30-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/spec-ex30-fe.p4 rename to testdata/v1_2_samples_outputs/spec-ex30-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/spec-ex30-last.p4 b/testdata/v1_2_samples_outputs/spec-ex30-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/spec-ex30-last.p4 rename to testdata/v1_2_samples_outputs/spec-ex30-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/spec-ex31-fe.p4 b/testdata/v1_2_samples_outputs/spec-ex31-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 58% rename from testdata/v1_2_samples_outputs/spec-ex31-fe.p4 rename to testdata/v1_2_samples_outputs/spec-ex31-FrontEnd_11_SimplifyControlFlowE.p4 index 33959c1e51d..3124d5fb479 100644 --- a/testdata/v1_2_samples_outputs/spec-ex31-fe.p4 +++ b/testdata/v1_2_samples_outputs/spec-ex31-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,4 +1,38 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} struct EthernetHeader { bit<16> etherType; diff --git a/testdata/v1_2_samples_outputs/spec-ex31-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_2_samples_outputs/spec-ex31-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..ad469752ca7 --- /dev/null +++ b/testdata/v1_2_samples_outputs/spec-ex31-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,45 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +struct EthernetHeader { + bit<16> etherType; +} + +struct IPv4 { + bit<16> protocol; +} + +struct Packet_header { + EthernetHeader ethernet; + IPv4 ipv4; +} + diff --git a/testdata/v1_2_samples_outputs/spec-ex31-last.p4 b/testdata/v1_2_samples_outputs/spec-ex31-last.p4 deleted file mode 100644 index 8f01adab616..00000000000 --- a/testdata/v1_2_samples_outputs/spec-ex31-last.p4 +++ /dev/null @@ -1,15 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" - -struct EthernetHeader { - bit<16> etherType; -} - -struct IPv4 { - bit<16> protocol; -} - -struct Packet_header { - EthernetHeader ethernet; - IPv4 ipv4; -} - diff --git a/testdata/v1_2_samples_outputs/spec-ex32-fe.p4 b/testdata/v1_2_samples_outputs/spec-ex32-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 60% rename from testdata/v1_2_samples_outputs/spec-ex32-fe.p4 rename to testdata/v1_2_samples_outputs/spec-ex32-FrontEnd_11_SimplifyControlFlowE.p4 index ede874c1492..0e63888d270 100644 --- a/testdata/v1_2_samples_outputs/spec-ex32-fe.p4 +++ b/testdata/v1_2_samples_outputs/spec-ex32-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,4 +1,38 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} header Hdr { bit<8> size; diff --git a/testdata/v1_2_samples_outputs/spec-ex32-last.p4 b/testdata/v1_2_samples_outputs/spec-ex32-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 50% rename from testdata/v1_2_samples_outputs/spec-ex32-last.p4 rename to testdata/v1_2_samples_outputs/spec-ex32-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 96c12e3fd18..bf7e5947b27 100644 --- a/testdata/v1_2_samples_outputs/spec-ex32-last.p4 +++ b/testdata/v1_2_samples_outputs/spec-ex32-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,4 +1,34 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} header Hdr { bit<8> size; diff --git a/testdata/v1_2_samples_outputs/spec-ex34-fe.p4 b/testdata/v1_2_samples_outputs/spec-ex34-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/spec-ex34-fe.p4 rename to testdata/v1_2_samples_outputs/spec-ex34-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/spec-ex34-last.p4 b/testdata/v1_2_samples_outputs/spec-ex34-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/spec-ex34-last.p4 rename to testdata/v1_2_samples_outputs/spec-ex34-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/specialization-fe.p4 b/testdata/v1_2_samples_outputs/specialization-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/specialization-fe.p4 rename to testdata/v1_2_samples_outputs/specialization-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/specialization-last.p4 b/testdata/v1_2_samples_outputs/specialization-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/specialization-last.p4 rename to testdata/v1_2_samples_outputs/specialization-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/stack-fe.p4 b/testdata/v1_2_samples_outputs/stack-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/stack-fe.p4 rename to testdata/v1_2_samples_outputs/stack-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/stack-last.p4 b/testdata/v1_2_samples_outputs/stack-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/stack-last.p4 rename to testdata/v1_2_samples_outputs/stack-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/standard_headers-fe.p4 b/testdata/v1_2_samples_outputs/standard_headers-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/standard_headers-fe.p4 rename to testdata/v1_2_samples_outputs/standard_headers-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/standard_headers-last.p4 b/testdata/v1_2_samples_outputs/standard_headers-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/standard_headers-last.p4 rename to testdata/v1_2_samples_outputs/standard_headers-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/states-fe.p4 b/testdata/v1_2_samples_outputs/states-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/states-fe.p4 rename to testdata/v1_2_samples_outputs/states-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/states-last.p4 b/testdata/v1_2_samples_outputs/states-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/states-last.p4 rename to testdata/v1_2_samples_outputs/states-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/states-midend.p4 b/testdata/v1_2_samples_outputs/states-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/states-midend.p4 rename to testdata/v1_2_samples_outputs/states-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/strength-fe.p4 b/testdata/v1_2_samples_outputs/strength-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/strength-fe.p4 rename to testdata/v1_2_samples_outputs/strength-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/strength-last.p4 b/testdata/v1_2_samples_outputs/strength-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/strength-last.p4 rename to testdata/v1_2_samples_outputs/strength-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/string_anno-fe.p4 b/testdata/v1_2_samples_outputs/string_anno-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/string_anno-fe.p4 rename to testdata/v1_2_samples_outputs/string_anno-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/string_anno-last.p4 b/testdata/v1_2_samples_outputs/string_anno-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/string_anno-last.p4 rename to testdata/v1_2_samples_outputs/string_anno-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/struct-fe.p4 b/testdata/v1_2_samples_outputs/struct-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/struct-fe.p4 rename to testdata/v1_2_samples_outputs/struct-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/struct-last.p4 b/testdata/v1_2_samples_outputs/struct-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/struct-last.p4 rename to testdata/v1_2_samples_outputs/struct-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/switch_ebpf-fe.p4 b/testdata/v1_2_samples_outputs/switch_ebpf-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 60% rename from testdata/v1_2_samples_outputs/switch_ebpf-fe.p4 rename to testdata/v1_2_samples_outputs/switch_ebpf-FrontEnd_11_SimplifyControlFlowE.p4 index 493d6672056..76b440f6a67 100644 --- a/testdata/v1_2_samples_outputs/switch_ebpf-fe.p4 +++ b/testdata/v1_2_samples_outputs/switch_ebpf-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,56 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/ebpf_model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version ebpf_version = { 8w0, 8w1 }; +extern CounterArray { + CounterArray(bit<32> max_index, bool sparse); + void increment(in bit<32> index); +} + +extern array_table { + array_table(bit<32> size); +} + +extern hash_table { + hash_table(bit<32> size); +} +parser parse(packet_in packet, out H headers); +control filter(inout H headers, out bool accept); +package ebpfFilter(parse prs, filter filt); typedef bit<48> @ethernetaddress EthernetAddress; typedef bit<32> @ipv4address IPv4Address; header Ethernet_h { diff --git a/testdata/v1_2_samples_outputs/switch_ebpf-last.p4 b/testdata/v1_2_samples_outputs/switch_ebpf-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 64% rename from testdata/v1_2_samples_outputs/switch_ebpf-last.p4 rename to testdata/v1_2_samples_outputs/switch_ebpf-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 493d6672056..7810c8c6bcc 100644 --- a/testdata/v1_2_samples_outputs/switch_ebpf-last.p4 +++ b/testdata/v1_2_samples_outputs/switch_ebpf-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,53 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/ebpf_model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +extern CounterArray { + CounterArray(bit<32> max_index, bool sparse); + void increment(in bit<32> index); +} + +extern array_table { + array_table(bit<32> size); +} + +extern hash_table { + hash_table(bit<32> size); +} +parser parse(packet_in packet, out H headers); +control filter(inout H headers, out bool accept); +package ebpfFilter(parse prs, filter filt); typedef bit<48> @ethernetaddress EthernetAddress; typedef bit<32> @ipv4address IPv4Address; header Ethernet_h { diff --git a/testdata/v1_2_samples_outputs/switch_ebpf-midend.p4 b/testdata/v1_2_samples_outputs/switch_ebpf-MidEnd_25_Evaluator.p4 similarity index 70% rename from testdata/v1_2_samples_outputs/switch_ebpf-midend.p4 rename to testdata/v1_2_samples_outputs/switch_ebpf-MidEnd_25_Evaluator.p4 index ff3e166e683..c3ba79a50aa 100644 --- a/testdata/v1_2_samples_outputs/switch_ebpf-midend.p4 +++ b/testdata/v1_2_samples_outputs/switch_ebpf-MidEnd_25_Evaluator.p4 @@ -1,6 +1,51 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/ebpf_model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +extern CounterArray { + CounterArray(bit<32> max_index, bool sparse); + void increment(in bit<32> index); +} + +extern array_table { + array_table(bit<32> size); +} + +extern hash_table { + hash_table(bit<32> size); +} +parser parse(packet_in packet, out H headers); +control filter(inout H headers, out bool accept); +package ebpfFilter(parse prs, filter filt); typedef bit<48> @ethernetaddress EthernetAddress; typedef bit<32> @ipv4address IPv4Address; header Ethernet_h { diff --git a/testdata/v1_2_samples_outputs/synth-action-fe.p4 b/testdata/v1_2_samples_outputs/synth-action-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/synth-action-fe.p4 rename to testdata/v1_2_samples_outputs/synth-action-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/synth-action-last.p4 b/testdata/v1_2_samples_outputs/synth-action-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/synth-action-last.p4 rename to testdata/v1_2_samples_outputs/synth-action-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/synth-action-midend.p4 b/testdata/v1_2_samples_outputs/synth-action-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/synth-action-midend.p4 rename to testdata/v1_2_samples_outputs/synth-action-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/template-fe.p4 b/testdata/v1_2_samples_outputs/template-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/template-fe.p4 rename to testdata/v1_2_samples_outputs/template-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/template-last.p4 b/testdata/v1_2_samples_outputs/template-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/template-last.p4 rename to testdata/v1_2_samples_outputs/template-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/test_ebpf-fe.p4 b/testdata/v1_2_samples_outputs/test_ebpf-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 60% rename from testdata/v1_2_samples_outputs/test_ebpf-fe.p4 rename to testdata/v1_2_samples_outputs/test_ebpf-FrontEnd_11_SimplifyControlFlowE.p4 index 3c9cece5738..db0d5c0138a 100644 --- a/testdata/v1_2_samples_outputs/test_ebpf-fe.p4 +++ b/testdata/v1_2_samples_outputs/test_ebpf-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,56 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/ebpf_model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version ebpf_version = { 8w0, 8w1 }; +extern CounterArray { + CounterArray(bit<32> max_index, bool sparse); + void increment(in bit<32> index); +} + +extern array_table { + array_table(bit<32> size); +} + +extern hash_table { + hash_table(bit<32> size); +} +parser parse(packet_in packet, out H headers); +control filter(inout H headers, out bool accept); +package ebpfFilter(parse prs, filter filt); typedef bit<48> @ethernetaddress EthernetAddress; typedef bit<32> @ipv4address IPv4Address; header Ethernet_h { diff --git a/testdata/v1_2_samples_outputs/test_ebpf-last.p4 b/testdata/v1_2_samples_outputs/test_ebpf-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 63% rename from testdata/v1_2_samples_outputs/test_ebpf-last.p4 rename to testdata/v1_2_samples_outputs/test_ebpf-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 3c9cece5738..eb814d2297f 100644 --- a/testdata/v1_2_samples_outputs/test_ebpf-last.p4 +++ b/testdata/v1_2_samples_outputs/test_ebpf-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,53 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/ebpf_model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +extern CounterArray { + CounterArray(bit<32> max_index, bool sparse); + void increment(in bit<32> index); +} + +extern array_table { + array_table(bit<32> size); +} + +extern hash_table { + hash_table(bit<32> size); +} +parser parse(packet_in packet, out H headers); +control filter(inout H headers, out bool accept); +package ebpfFilter(parse prs, filter filt); typedef bit<48> @ethernetaddress EthernetAddress; typedef bit<32> @ipv4address IPv4Address; header Ethernet_h { diff --git a/testdata/v1_2_samples_outputs/test_ebpf-midend.p4 b/testdata/v1_2_samples_outputs/test_ebpf-MidEnd_25_Evaluator.p4 similarity index 70% rename from testdata/v1_2_samples_outputs/test_ebpf-midend.p4 rename to testdata/v1_2_samples_outputs/test_ebpf-MidEnd_25_Evaluator.p4 index 53af8f51e2c..8bb5e4698e8 100644 --- a/testdata/v1_2_samples_outputs/test_ebpf-midend.p4 +++ b/testdata/v1_2_samples_outputs/test_ebpf-MidEnd_25_Evaluator.p4 @@ -1,6 +1,51 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/ebpf_model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +extern CounterArray { + CounterArray(bit<32> max_index, bool sparse); + void increment(in bit<32> index); +} + +extern array_table { + array_table(bit<32> size); +} + +extern hash_table { + hash_table(bit<32> size); +} +parser parse(packet_in packet, out H headers); +control filter(inout H headers, out bool accept); +package ebpfFilter(parse prs, filter filt); typedef bit<48> @ethernetaddress EthernetAddress; typedef bit<32> @ipv4address IPv4Address; header Ethernet_h { diff --git a/testdata/v1_2_samples_outputs/twoPipe-fe.p4 b/testdata/v1_2_samples_outputs/twoPipe-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/twoPipe-fe.p4 rename to testdata/v1_2_samples_outputs/twoPipe-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/twoPipe-last.p4 b/testdata/v1_2_samples_outputs/twoPipe-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/twoPipe-last.p4 rename to testdata/v1_2_samples_outputs/twoPipe-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/two_ebpf-last.p4 b/testdata/v1_2_samples_outputs/two_ebpf-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 60% rename from testdata/v1_2_samples_outputs/two_ebpf-last.p4 rename to testdata/v1_2_samples_outputs/two_ebpf-FrontEnd_11_SimplifyControlFlowE.p4 index 66370e74480..b0250bd68c0 100644 --- a/testdata/v1_2_samples_outputs/two_ebpf-last.p4 +++ b/testdata/v1_2_samples_outputs/two_ebpf-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,56 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/ebpf_model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version ebpf_version = { 8w0, 8w1 }; +extern CounterArray { + CounterArray(bit<32> max_index, bool sparse); + void increment(in bit<32> index); +} + +extern array_table { + array_table(bit<32> size); +} + +extern hash_table { + hash_table(bit<32> size); +} +parser parse(packet_in packet, out H headers); +control filter(inout H headers, out bool accept); +package ebpfFilter(parse prs, filter filt); typedef bit<48> @ethernetaddress EthernetAddress; typedef bit<32> @ipv4address IPv4Address; header Ethernet_h { diff --git a/testdata/v1_2_samples_outputs/two_ebpf-fe.p4 b/testdata/v1_2_samples_outputs/two_ebpf-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 63% rename from testdata/v1_2_samples_outputs/two_ebpf-fe.p4 rename to testdata/v1_2_samples_outputs/two_ebpf-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 66370e74480..b149766e156 100644 --- a/testdata/v1_2_samples_outputs/two_ebpf-fe.p4 +++ b/testdata/v1_2_samples_outputs/two_ebpf-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,53 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/ebpf_model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +extern CounterArray { + CounterArray(bit<32> max_index, bool sparse); + void increment(in bit<32> index); +} + +extern array_table { + array_table(bit<32> size); +} + +extern hash_table { + hash_table(bit<32> size); +} +parser parse(packet_in packet, out H headers); +control filter(inout H headers, out bool accept); +package ebpfFilter(parse prs, filter filt); typedef bit<48> @ethernetaddress EthernetAddress; typedef bit<32> @ipv4address IPv4Address; header Ethernet_h { diff --git a/testdata/v1_2_samples_outputs/two_ebpf-midend.p4 b/testdata/v1_2_samples_outputs/two_ebpf-MidEnd_25_Evaluator.p4 similarity index 70% rename from testdata/v1_2_samples_outputs/two_ebpf-midend.p4 rename to testdata/v1_2_samples_outputs/two_ebpf-MidEnd_25_Evaluator.p4 index f8d60383a6a..9adeca66a35 100644 --- a/testdata/v1_2_samples_outputs/two_ebpf-midend.p4 +++ b/testdata/v1_2_samples_outputs/two_ebpf-MidEnd_25_Evaluator.p4 @@ -1,6 +1,51 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/ebpf_model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +extern CounterArray { + CounterArray(bit<32> max_index, bool sparse); + void increment(in bit<32> index); +} + +extern array_table { + array_table(bit<32> size); +} + +extern hash_table { + hash_table(bit<32> size); +} +parser parse(packet_in packet, out H headers); +control filter(inout H headers, out bool accept); +package ebpfFilter(parse prs, filter filt); typedef bit<48> @ethernetaddress EthernetAddress; typedef bit<32> @ipv4address IPv4Address; header Ethernet_h { diff --git a/testdata/v1_2_samples_outputs/type-params-fe.p4 b/testdata/v1_2_samples_outputs/type-params-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/type-params-fe.p4 rename to testdata/v1_2_samples_outputs/type-params-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/type-params-last.p4 b/testdata/v1_2_samples_outputs/type-params-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/type-params-last.p4 rename to testdata/v1_2_samples_outputs/type-params-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/valid-fe.p4 b/testdata/v1_2_samples_outputs/valid-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/valid-fe.p4 rename to testdata/v1_2_samples_outputs/valid-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/valid-last.p4 b/testdata/v1_2_samples_outputs/valid-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/valid-last.p4 rename to testdata/v1_2_samples_outputs/valid-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/version-fe.p4 b/testdata/v1_2_samples_outputs/version-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/version-fe.p4 rename to testdata/v1_2_samples_outputs/version-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/version-last.p4 b/testdata/v1_2_samples_outputs/version-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/version-last.p4 rename to testdata/v1_2_samples_outputs/version-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/virtual-fe.p4 b/testdata/v1_2_samples_outputs/virtual-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/virtual-fe.p4 rename to testdata/v1_2_samples_outputs/virtual-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/virtual-last.p4 b/testdata/v1_2_samples_outputs/virtual-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/virtual-last.p4 rename to testdata/v1_2_samples_outputs/virtual-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/virtual-midend.p4 b/testdata/v1_2_samples_outputs/virtual-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/virtual-midend.p4 rename to testdata/v1_2_samples_outputs/virtual-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_2_samples_outputs/virtual2-fe.p4 b/testdata/v1_2_samples_outputs/virtual2-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/virtual2-fe.p4 rename to testdata/v1_2_samples_outputs/virtual2-FrontEnd_11_SimplifyControlFlowE.p4 diff --git a/testdata/v1_2_samples_outputs/virtual2-last.p4 b/testdata/v1_2_samples_outputs/virtual2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/virtual2-last.p4 rename to testdata/v1_2_samples_outputs/virtual2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 diff --git a/testdata/v1_2_samples_outputs/virtual2-midend.p4 b/testdata/v1_2_samples_outputs/virtual2-MidEnd_25_Evaluator.p4 similarity index 100% rename from testdata/v1_2_samples_outputs/virtual2-midend.p4 rename to testdata/v1_2_samples_outputs/virtual2-MidEnd_25_Evaluator.p4 diff --git a/testdata/v1_samples_outputs/01-BigMatch-fe.p4 b/testdata/v1_samples_outputs/01-BigMatch-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 51% rename from testdata/v1_samples_outputs/01-BigMatch-fe.p4 rename to testdata/v1_samples_outputs/01-BigMatch-FrontEnd_11_SimplifyControlFlowE.p4 index 954d36f0c7c..6d752d06016 100644 --- a/testdata/v1_samples_outputs/01-BigMatch-fe.p4 +++ b/testdata/v1_samples_outputs/01-BigMatch-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<1> drop; bit<8> egress_port; diff --git a/testdata/v1_samples_outputs/01-BigMatch-last.p4 b/testdata/v1_samples_outputs/01-BigMatch-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 57% rename from testdata/v1_samples_outputs/01-BigMatch-last.p4 rename to testdata/v1_samples_outputs/01-BigMatch-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 954d36f0c7c..44420bd59e2 100644 --- a/testdata/v1_samples_outputs/01-BigMatch-last.p4 +++ b/testdata/v1_samples_outputs/01-BigMatch-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<1> drop; bit<8> egress_port; diff --git a/testdata/v1_samples_outputs/01-BigMatch-midend.p4 b/testdata/v1_samples_outputs/01-BigMatch-MidEnd_25_Evaluator.p4 similarity index 60% rename from testdata/v1_samples_outputs/01-BigMatch-midend.p4 rename to testdata/v1_samples_outputs/01-BigMatch-MidEnd_25_Evaluator.p4 index 4ee6ec587ac..07ffdfaad75 100644 --- a/testdata/v1_samples_outputs/01-BigMatch-midend.p4 +++ b/testdata/v1_samples_outputs/01-BigMatch-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<1> drop; bit<8> egress_port; diff --git a/testdata/v1_samples_outputs/01-DeadMetadata1-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/01-DeadMetadata1-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..ecf4ff82642 --- /dev/null +++ b/testdata/v1_samples_outputs/01-DeadMetadata1-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,178 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct m_t { + bit<32> f1; +} + +struct metadata { + @name("m") + m_t m; +} + +struct headers { +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("a1") action a1() { + meta.m.f1 = 32w1; + } + @name("t1") table t1() { + actions = { + a1; + NoAction; + } + default_action = NoAction(); + } + apply { + t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/01-DeadMetadata1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/01-DeadMetadata1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..7dc020c4818 --- /dev/null +++ b/testdata/v1_samples_outputs/01-DeadMetadata1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,162 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct m_t { + bit<32> f1; +} + +struct metadata { + @name("m") + m_t m; +} + +struct headers { +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("a1") action a1() { + meta.m.f1 = 32w1; + } + @name("t1") table t1() { + actions = { + a1; + NoAction; + } + default_action = NoAction(); + } + apply { + t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/01-DeadMetadata1-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/01-DeadMetadata1-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..c46ea3c3853 --- /dev/null +++ b/testdata/v1_samples_outputs/01-DeadMetadata1-MidEnd_25_Evaluator.p4 @@ -0,0 +1,162 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct m_t { + bit<32> f1; +} + +struct metadata { + @name("m") + m_t m; +} + +struct headers { +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("a1") action a1_0() { + meta.m.f1 = 32w1; + } + @name("t1") table t1_0() { + actions = { + a1_0; + NoAction_0; + } + default_action = NoAction_0(); + } + apply { + t1_0.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/01-DeadMetadata1-fe.p4 b/testdata/v1_samples_outputs/01-DeadMetadata1-fe.p4 deleted file mode 100644 index dc34f598297..00000000000 --- a/testdata/v1_samples_outputs/01-DeadMetadata1-fe.p4 +++ /dev/null @@ -1,58 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct m_t { - bit<32> f1; -} - -struct metadata { - @name("m") - m_t m; -} - -struct headers { -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("a1") action a1() { - meta.m.f1 = 32w1; - } - @name("t1") table t1() { - actions = { - a1; - NoAction; - } - default_action = NoAction(); - } - apply { - t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/01-DeadMetadata1-last.p4 b/testdata/v1_samples_outputs/01-DeadMetadata1-last.p4 deleted file mode 100644 index dc34f598297..00000000000 --- a/testdata/v1_samples_outputs/01-DeadMetadata1-last.p4 +++ /dev/null @@ -1,58 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct m_t { - bit<32> f1; -} - -struct metadata { - @name("m") - m_t m; -} - -struct headers { -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("a1") action a1() { - meta.m.f1 = 32w1; - } - @name("t1") table t1() { - actions = { - a1; - NoAction; - } - default_action = NoAction(); - } - apply { - t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/01-DeadMetadata1-midend.p4 b/testdata/v1_samples_outputs/01-DeadMetadata1-midend.p4 deleted file mode 100644 index 203a5fc7f7b..00000000000 --- a/testdata/v1_samples_outputs/01-DeadMetadata1-midend.p4 +++ /dev/null @@ -1,60 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct m_t { - bit<32> f1; -} - -struct metadata { - @name("m") - m_t m; -} - -struct headers { -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("a1") action a1_0() { - meta.m.f1 = 32w1; - } - @name("t1") table t1_0() { - actions = { - a1_0; - NoAction_0; - } - default_action = NoAction_0(); - } - apply { - t1_0.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/01-FullPHV-last.p4 b/testdata/v1_samples_outputs/01-FullPHV-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 83% rename from testdata/v1_samples_outputs/01-FullPHV-last.p4 rename to testdata/v1_samples_outputs/01-FullPHV-FrontEnd_11_SimplifyControlFlowE.p4 index f2fac835d6b..85755563545 100644 --- a/testdata/v1_samples_outputs/01-FullPHV-last.p4 +++ b/testdata/v1_samples_outputs/01-FullPHV-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct m_t { bit<8> field_8_01; bit<8> field_8_02; diff --git a/testdata/v1_samples_outputs/01-FullPHV-fe.p4 b/testdata/v1_samples_outputs/01-FullPHV-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 86% rename from testdata/v1_samples_outputs/01-FullPHV-fe.p4 rename to testdata/v1_samples_outputs/01-FullPHV-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index f2fac835d6b..88dcb9f50fe 100644 --- a/testdata/v1_samples_outputs/01-FullPHV-fe.p4 +++ b/testdata/v1_samples_outputs/01-FullPHV-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct m_t { bit<8> field_8_01; bit<8> field_8_02; diff --git a/testdata/v1_samples_outputs/01-FullPHV-midend.p4 b/testdata/v1_samples_outputs/01-FullPHV-MidEnd_25_Evaluator.p4 similarity index 86% rename from testdata/v1_samples_outputs/01-FullPHV-midend.p4 rename to testdata/v1_samples_outputs/01-FullPHV-MidEnd_25_Evaluator.p4 index e51bc6a94ec..719c3007c09 100644 --- a/testdata/v1_samples_outputs/01-FullPHV-midend.p4 +++ b/testdata/v1_samples_outputs/01-FullPHV-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct m_t { bit<8> field_8_01; bit<8> field_8_02; diff --git a/testdata/v1_samples_outputs/01-JustEthernet-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/01-JustEthernet-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..3e832bbe3e8 --- /dev/null +++ b/testdata/v1_samples_outputs/01-JustEthernet-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,171 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.ethernet); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/01-JustEthernet-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/01-JustEthernet-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..12ad239029c --- /dev/null +++ b/testdata/v1_samples_outputs/01-JustEthernet-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,153 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.ethernet); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/01-JustEthernet-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/01-JustEthernet-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..12ad239029c --- /dev/null +++ b/testdata/v1_samples_outputs/01-JustEthernet-MidEnd_25_Evaluator.p4 @@ -0,0 +1,153 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.ethernet); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/01-JustEthernet-fe.p4 b/testdata/v1_samples_outputs/01-JustEthernet-fe.p4 deleted file mode 100644 index 13c8e3165e0..00000000000 --- a/testdata/v1_samples_outputs/01-JustEthernet-fe.p4 +++ /dev/null @@ -1,51 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.ethernet); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/01-JustEthernet-last.p4 b/testdata/v1_samples_outputs/01-JustEthernet-last.p4 deleted file mode 100644 index 13c8e3165e0..00000000000 --- a/testdata/v1_samples_outputs/01-JustEthernet-last.p4 +++ /dev/null @@ -1,51 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.ethernet); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/01-JustEthernet-midend.p4 b/testdata/v1_samples_outputs/01-JustEthernet-midend.p4 deleted file mode 100644 index 13c8e3165e0..00000000000 --- a/testdata/v1_samples_outputs/01-JustEthernet-midend.p4 +++ /dev/null @@ -1,51 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.ethernet); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/01-NoDeps-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/01-NoDeps-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..3c79c8514d0 --- /dev/null +++ b/testdata/v1_samples_outputs/01-NoDeps-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,223 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct ingress_metadata_t { + bit<1> drop; + bit<8> egress_port; +} + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +struct metadata { + @name("ing_metadata") + ingress_metadata_t ing_metadata; +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.ethernet); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("e_t1") table e_t1() { + actions = { + nop; + NoAction; + } + key = { + hdr.ethernet.srcAddr: exact; + } + default_action = NoAction(); + } + apply { + e_t1.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("set_egress_port") action set_egress_port(bit<8> egress_port) { + meta.ing_metadata.egress_port = egress_port; + } + @name("ing_drop") action ing_drop() { + meta.ing_metadata.drop = 1w1; + } + @name("dmac") table dmac() { + actions = { + nop; + set_egress_port; + NoAction; + } + key = { + hdr.ethernet.dstAddr: exact; + } + default_action = NoAction(); + } + @name("smac_filter") table smac_filter() { + actions = { + nop; + ing_drop; + NoAction; + } + key = { + hdr.ethernet.srcAddr: exact; + } + default_action = NoAction(); + } + apply { + dmac.apply(); + smac_filter.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/01-NoDeps-last.p4 b/testdata/v1_samples_outputs/01-NoDeps-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 50% rename from testdata/v1_samples_outputs/01-NoDeps-last.p4 rename to testdata/v1_samples_outputs/01-NoDeps-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 50a35515be7..a82e96da782 100644 --- a/testdata/v1_samples_outputs/01-NoDeps-last.p4 +++ b/testdata/v1_samples_outputs/01-NoDeps-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<1> drop; bit<8> egress_port; diff --git a/testdata/v1_samples_outputs/01-NoDeps-midend.p4 b/testdata/v1_samples_outputs/01-NoDeps-MidEnd_25_Evaluator.p4 similarity index 52% rename from testdata/v1_samples_outputs/01-NoDeps-midend.p4 rename to testdata/v1_samples_outputs/01-NoDeps-MidEnd_25_Evaluator.p4 index 4b5b454aaee..82601acdfe6 100644 --- a/testdata/v1_samples_outputs/01-NoDeps-midend.p4 +++ b/testdata/v1_samples_outputs/01-NoDeps-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<1> drop; bit<8> egress_port; diff --git a/testdata/v1_samples_outputs/01-NoDeps-fe.p4 b/testdata/v1_samples_outputs/01-NoDeps-fe.p4 deleted file mode 100644 index 50a35515be7..00000000000 --- a/testdata/v1_samples_outputs/01-NoDeps-fe.p4 +++ /dev/null @@ -1,103 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct ingress_metadata_t { - bit<1> drop; - bit<8> egress_port; -} - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -struct metadata { - @name("ing_metadata") - ingress_metadata_t ing_metadata; -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.ethernet); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("e_t1") table e_t1() { - actions = { - nop; - NoAction; - } - key = { - hdr.ethernet.srcAddr: exact; - } - default_action = NoAction(); - } - apply { - e_t1.apply(); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("set_egress_port") action set_egress_port(bit<8> egress_port) { - meta.ing_metadata.egress_port = egress_port; - } - @name("ing_drop") action ing_drop() { - meta.ing_metadata.drop = 1w1; - } - @name("dmac") table dmac() { - actions = { - nop; - set_egress_port; - NoAction; - } - key = { - hdr.ethernet.dstAddr: exact; - } - default_action = NoAction(); - } - @name("smac_filter") table smac_filter() { - actions = { - nop; - ing_drop; - NoAction; - } - key = { - hdr.ethernet.srcAddr: exact; - } - default_action = NoAction(); - } - apply { - dmac.apply(); - smac_filter.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/02-BadSizeField-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/02-BadSizeField-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..4034047d4c7 --- /dev/null +++ b/testdata/v1_samples_outputs/02-BadSizeField-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,217 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct ingress_metadata_t { + bit<1> drop; + bit<8> egress_port; +} + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<15> ethertype; +} + +header vag_t { + bit<33> f1; + bit<7> f2; +} + +struct metadata { + @name("ing_metadata") + ingress_metadata_t ing_metadata; +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("vag") + vag_t vag; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.ethernet); + packet.extract(hdr.vag); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("e_t1") table e_t1() { + actions = { + nop; + NoAction; + } + key = { + hdr.ethernet.srcAddr: exact; + } + default_action = NoAction(); + } + apply { + e_t1.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("set_egress_port") action set_egress_port(bit<8> egress_port) { + meta.ing_metadata.egress_port = egress_port; + } + @name("i_t1") table i_t1() { + actions = { + nop; + set_egress_port; + NoAction; + } + key = { + hdr.ethernet.dstAddr: exact; + } + default_action = NoAction(); + } + apply { + i_t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.vag); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/02-BadSizeField-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/02-BadSizeField-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..ea7e58f1e05 --- /dev/null +++ b/testdata/v1_samples_outputs/02-BadSizeField-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,201 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct ingress_metadata_t { + bit<1> drop; + bit<8> egress_port; +} + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<15> ethertype; +} + +header vag_t { + bit<33> f1; + bit<7> f2; +} + +struct metadata { + @name("ing_metadata") + ingress_metadata_t ing_metadata; +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("vag") + vag_t vag; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.ethernet); + packet.extract(hdr.vag); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("e_t1") table e_t1() { + actions = { + nop; + NoAction; + } + key = { + hdr.ethernet.srcAddr: exact; + } + default_action = NoAction(); + } + apply { + e_t1.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("set_egress_port") action set_egress_port(bit<8> egress_port) { + meta.ing_metadata.egress_port = egress_port; + } + @name("i_t1") table i_t1() { + actions = { + nop; + set_egress_port; + NoAction; + } + key = { + hdr.ethernet.dstAddr: exact; + } + default_action = NoAction(); + } + apply { + i_t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.vag); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/02-BadSizeField-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/02-BadSizeField-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..3f2fe0ad279 --- /dev/null +++ b/testdata/v1_samples_outputs/02-BadSizeField-MidEnd_25_Evaluator.p4 @@ -0,0 +1,203 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct ingress_metadata_t { + bit<1> drop; + bit<8> egress_port; +} + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<15> ethertype; +} + +header vag_t { + bit<33> f1; + bit<7> f2; +} + +struct metadata { + @name("ing_metadata") + ingress_metadata_t ing_metadata; +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("vag") + vag_t vag; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.ethernet); + packet.extract(hdr.vag); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("nop") action nop_0() { + } + @name("e_t1") table e_t1_0() { + actions = { + nop_0; + NoAction_0; + } + key = { + hdr.ethernet.srcAddr: exact; + } + default_action = NoAction_0(); + } + apply { + e_t1_0.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_1() { + } + @name("nop") action nop_1() { + } + @name("set_egress_port") action set_egress_port_0(bit<8> egress_port) { + meta.ing_metadata.egress_port = egress_port; + } + @name("i_t1") table i_t1_0() { + actions = { + nop_1; + set_egress_port_0; + NoAction_1; + } + key = { + hdr.ethernet.dstAddr: exact; + } + default_action = NoAction_1(); + } + apply { + i_t1_0.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.vag); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/02-BadSizeField-fe.p4 b/testdata/v1_samples_outputs/02-BadSizeField-fe.p4 deleted file mode 100644 index 1581827be94..00000000000 --- a/testdata/v1_samples_outputs/02-BadSizeField-fe.p4 +++ /dev/null @@ -1,97 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct ingress_metadata_t { - bit<1> drop; - bit<8> egress_port; -} - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<15> ethertype; -} - -header vag_t { - bit<33> f1; - bit<7> f2; -} - -struct metadata { - @name("ing_metadata") - ingress_metadata_t ing_metadata; -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; - @name("vag") - vag_t vag; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.ethernet); - packet.extract(hdr.vag); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("e_t1") table e_t1() { - actions = { - nop; - NoAction; - } - key = { - hdr.ethernet.srcAddr: exact; - } - default_action = NoAction(); - } - apply { - e_t1.apply(); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("set_egress_port") action set_egress_port(bit<8> egress_port) { - meta.ing_metadata.egress_port = egress_port; - } - @name("i_t1") table i_t1() { - actions = { - nop; - set_egress_port; - NoAction; - } - key = { - hdr.ethernet.dstAddr: exact; - } - default_action = NoAction(); - } - apply { - i_t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - packet.emit(hdr.vag); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/02-BadSizeField-last.p4 b/testdata/v1_samples_outputs/02-BadSizeField-last.p4 deleted file mode 100644 index 1581827be94..00000000000 --- a/testdata/v1_samples_outputs/02-BadSizeField-last.p4 +++ /dev/null @@ -1,97 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct ingress_metadata_t { - bit<1> drop; - bit<8> egress_port; -} - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<15> ethertype; -} - -header vag_t { - bit<33> f1; - bit<7> f2; -} - -struct metadata { - @name("ing_metadata") - ingress_metadata_t ing_metadata; -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; - @name("vag") - vag_t vag; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.ethernet); - packet.extract(hdr.vag); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("e_t1") table e_t1() { - actions = { - nop; - NoAction; - } - key = { - hdr.ethernet.srcAddr: exact; - } - default_action = NoAction(); - } - apply { - e_t1.apply(); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("set_egress_port") action set_egress_port(bit<8> egress_port) { - meta.ing_metadata.egress_port = egress_port; - } - @name("i_t1") table i_t1() { - actions = { - nop; - set_egress_port; - NoAction; - } - key = { - hdr.ethernet.dstAddr: exact; - } - default_action = NoAction(); - } - apply { - i_t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - packet.emit(hdr.vag); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/02-BadSizeField-midend.p4 b/testdata/v1_samples_outputs/02-BadSizeField-midend.p4 deleted file mode 100644 index 80c059eb7e1..00000000000 --- a/testdata/v1_samples_outputs/02-BadSizeField-midend.p4 +++ /dev/null @@ -1,101 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct ingress_metadata_t { - bit<1> drop; - bit<8> egress_port; -} - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<15> ethertype; -} - -header vag_t { - bit<33> f1; - bit<7> f2; -} - -struct metadata { - @name("ing_metadata") - ingress_metadata_t ing_metadata; -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; - @name("vag") - vag_t vag; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.ethernet); - packet.extract(hdr.vag); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("nop") action nop_0() { - } - @name("e_t1") table e_t1_0() { - actions = { - nop_0; - NoAction_0; - } - key = { - hdr.ethernet.srcAddr: exact; - } - default_action = NoAction_0(); - } - apply { - e_t1_0.apply(); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_1() { - } - @name("nop") action nop_1() { - } - @name("set_egress_port") action set_egress_port_0(bit<8> egress_port) { - meta.ing_metadata.egress_port = egress_port; - } - @name("i_t1") table i_t1_0() { - actions = { - nop_1; - set_egress_port_0; - NoAction_1; - } - key = { - hdr.ethernet.dstAddr: exact; - } - default_action = NoAction_1(); - } - apply { - i_t1_0.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - packet.emit(hdr.vag); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/02-DeadMetadata2-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/02-DeadMetadata2-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..37f3de221ec --- /dev/null +++ b/testdata/v1_samples_outputs/02-DeadMetadata2-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,179 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct m_t { + bit<32> f1; +} + +struct metadata { + @name("m") + m_t m; +} + +struct headers { +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + meta.m.f1 = 32w2; + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("a1") action a1() { + meta.m.f1 = 32w1; + } + @name("t1") table t1() { + actions = { + a1; + NoAction; + } + default_action = NoAction(); + } + apply { + t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/02-DeadMetadata2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/02-DeadMetadata2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..c27dfc166cf --- /dev/null +++ b/testdata/v1_samples_outputs/02-DeadMetadata2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,163 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct m_t { + bit<32> f1; +} + +struct metadata { + @name("m") + m_t m; +} + +struct headers { +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + meta.m.f1 = 32w2; + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("a1") action a1() { + meta.m.f1 = 32w1; + } + @name("t1") table t1() { + actions = { + a1; + NoAction; + } + default_action = NoAction(); + } + apply { + t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/02-DeadMetadata2-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/02-DeadMetadata2-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..770918f206b --- /dev/null +++ b/testdata/v1_samples_outputs/02-DeadMetadata2-MidEnd_25_Evaluator.p4 @@ -0,0 +1,163 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct m_t { + bit<32> f1; +} + +struct metadata { + @name("m") + m_t m; +} + +struct headers { +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + meta.m.f1 = 32w2; + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("a1") action a1_0() { + meta.m.f1 = 32w1; + } + @name("t1") table t1_0() { + actions = { + a1_0; + NoAction_0; + } + default_action = NoAction_0(); + } + apply { + t1_0.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/02-DeadMetadata2-fe.p4 b/testdata/v1_samples_outputs/02-DeadMetadata2-fe.p4 deleted file mode 100644 index 77f4807bad3..00000000000 --- a/testdata/v1_samples_outputs/02-DeadMetadata2-fe.p4 +++ /dev/null @@ -1,59 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct m_t { - bit<32> f1; -} - -struct metadata { - @name("m") - m_t m; -} - -struct headers { -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - meta.m.f1 = 32w2; - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("a1") action a1() { - meta.m.f1 = 32w1; - } - @name("t1") table t1() { - actions = { - a1; - NoAction; - } - default_action = NoAction(); - } - apply { - t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/02-DeadMetadata2-last.p4 b/testdata/v1_samples_outputs/02-DeadMetadata2-last.p4 deleted file mode 100644 index 77f4807bad3..00000000000 --- a/testdata/v1_samples_outputs/02-DeadMetadata2-last.p4 +++ /dev/null @@ -1,59 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct m_t { - bit<32> f1; -} - -struct metadata { - @name("m") - m_t m; -} - -struct headers { -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - meta.m.f1 = 32w2; - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("a1") action a1() { - meta.m.f1 = 32w1; - } - @name("t1") table t1() { - actions = { - a1; - NoAction; - } - default_action = NoAction(); - } - apply { - t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/02-DeadMetadata2-midend.p4 b/testdata/v1_samples_outputs/02-DeadMetadata2-midend.p4 deleted file mode 100644 index 83315d99711..00000000000 --- a/testdata/v1_samples_outputs/02-DeadMetadata2-midend.p4 +++ /dev/null @@ -1,61 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct m_t { - bit<32> f1; -} - -struct metadata { - @name("m") - m_t m; -} - -struct headers { -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - meta.m.f1 = 32w2; - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("a1") action a1_0() { - meta.m.f1 = 32w1; - } - @name("t1") table t1_0() { - actions = { - a1_0; - NoAction_0; - } - default_action = NoAction_0(); - } - apply { - t1_0.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/02-FullPHV1-fe.p4 b/testdata/v1_samples_outputs/02-FullPHV1-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 88% rename from testdata/v1_samples_outputs/02-FullPHV1-fe.p4 rename to testdata/v1_samples_outputs/02-FullPHV1-FrontEnd_11_SimplifyControlFlowE.p4 index e3fcfba423d..d3e89f7c17a 100644 --- a/testdata/v1_samples_outputs/02-FullPHV1-fe.p4 +++ b/testdata/v1_samples_outputs/02-FullPHV1-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct m_t { bit<8> field_8_01; bit<8> field_8_02; @@ -568,7 +688,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t2_1") table t2_1() { actions = { a2_1; @@ -642,7 +761,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t2_2") table t2_2() { actions = { a2_2; @@ -668,7 +786,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t2_3") table t2_3() { actions = { a2_3; @@ -694,7 +811,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t3_1") table t3_1() { actions = { a3_1; @@ -721,7 +837,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); t2_1.apply(); diff --git a/testdata/v1_samples_outputs/02-FullPHV1-last.p4 b/testdata/v1_samples_outputs/02-FullPHV1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 90% rename from testdata/v1_samples_outputs/02-FullPHV1-last.p4 rename to testdata/v1_samples_outputs/02-FullPHV1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index e3fcfba423d..9d2cbb4542d 100644 --- a/testdata/v1_samples_outputs/02-FullPHV1-last.p4 +++ b/testdata/v1_samples_outputs/02-FullPHV1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct m_t { bit<8> field_8_01; bit<8> field_8_02; @@ -568,7 +672,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t2_1") table t2_1() { actions = { a2_1; @@ -642,7 +745,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t2_2") table t2_2() { actions = { a2_2; @@ -668,7 +770,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t2_3") table t2_3() { actions = { a2_3; @@ -694,7 +795,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t3_1") table t3_1() { actions = { a3_1; @@ -721,7 +821,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); t2_1.apply(); diff --git a/testdata/v1_samples_outputs/02-FullPHV1-midend.p4 b/testdata/v1_samples_outputs/02-FullPHV1-MidEnd_25_Evaluator.p4 similarity index 91% rename from testdata/v1_samples_outputs/02-FullPHV1-midend.p4 rename to testdata/v1_samples_outputs/02-FullPHV1-MidEnd_25_Evaluator.p4 index a4611973cd8..759f970b7a9 100644 --- a/testdata/v1_samples_outputs/02-FullPHV1-midend.p4 +++ b/testdata/v1_samples_outputs/02-FullPHV1-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct m_t { bit<8> field_8_01; bit<8> field_8_02; diff --git a/testdata/v1_samples_outputs/02-FullPHV1.p4 b/testdata/v1_samples_outputs/02-FullPHV1.p4 index e3fcfba423d..9691383fcd8 100644 --- a/testdata/v1_samples_outputs/02-FullPHV1.p4 +++ b/testdata/v1_samples_outputs/02-FullPHV1.p4 @@ -568,7 +568,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t2_1") table t2_1() { actions = { a2_1; @@ -642,7 +641,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t2_2") table t2_2() { actions = { a2_2; @@ -668,7 +666,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t2_3") table t2_3() { actions = { a2_3; @@ -694,7 +691,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t3_1") table t3_1() { actions = { a3_1; @@ -721,7 +717,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); t2_1.apply(); diff --git a/testdata/v1_samples_outputs/02-SplitEthernet-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/02-SplitEthernet-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..a11c7cc1747 --- /dev/null +++ b/testdata/v1_samples_outputs/02-SplitEthernet-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,221 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header len_or_type_t { + bit<48> value; +} + +header mac_da_t { + bit<48> mac; +} + +header mac_sa_t { + bit<48> mac; +} + +struct metadata { +} + +struct headers { + @name("len_or_type") + len_or_type_t len_or_type; + @name("mac_da") + mac_da_t mac_da; + @name("mac_sa") + mac_sa_t mac_sa; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_len_or_type") state parse_len_or_type { + packet.extract(hdr.len_or_type); + transition accept; + } + @name("parse_mac_da") state parse_mac_da { + packet.extract(hdr.mac_da); + transition parse_mac_sa; + } + @name("parse_mac_sa") state parse_mac_sa { + packet.extract(hdr.mac_sa); + transition parse_len_or_type; + } + @name("start") state start { + transition parse_mac_da; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t2") table t2() { + actions = { + nop; + NoAction; + } + key = { + hdr.mac_sa.mac: exact; + } + default_action = NoAction(); + } + apply { + t2.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t1") table t1() { + actions = { + nop; + NoAction; + } + key = { + hdr.mac_da.mac : exact; + hdr.len_or_type.value: exact; + } + default_action = NoAction(); + } + apply { + t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.mac_da); + packet.emit(hdr.mac_sa); + packet.emit(hdr.len_or_type); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/02-SplitEthernet-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/02-SplitEthernet-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..fd43d526469 --- /dev/null +++ b/testdata/v1_samples_outputs/02-SplitEthernet-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,205 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header len_or_type_t { + bit<48> value; +} + +header mac_da_t { + bit<48> mac; +} + +header mac_sa_t { + bit<48> mac; +} + +struct metadata { +} + +struct headers { + @name("len_or_type") + len_or_type_t len_or_type; + @name("mac_da") + mac_da_t mac_da; + @name("mac_sa") + mac_sa_t mac_sa; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_len_or_type") state parse_len_or_type { + packet.extract(hdr.len_or_type); + transition accept; + } + @name("parse_mac_da") state parse_mac_da { + packet.extract(hdr.mac_da); + transition parse_mac_sa; + } + @name("parse_mac_sa") state parse_mac_sa { + packet.extract(hdr.mac_sa); + transition parse_len_or_type; + } + @name("start") state start { + transition parse_mac_da; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t2") table t2() { + actions = { + nop; + NoAction; + } + key = { + hdr.mac_sa.mac: exact; + } + default_action = NoAction(); + } + apply { + t2.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t1") table t1() { + actions = { + nop; + NoAction; + } + key = { + hdr.mac_da.mac : exact; + hdr.len_or_type.value: exact; + } + default_action = NoAction(); + } + apply { + t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.mac_da); + packet.emit(hdr.mac_sa); + packet.emit(hdr.len_or_type); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/02-SplitEthernet-midend.p4 b/testdata/v1_samples_outputs/02-SplitEthernet-MidEnd_25_Evaluator.p4 similarity index 50% rename from testdata/v1_samples_outputs/02-SplitEthernet-midend.p4 rename to testdata/v1_samples_outputs/02-SplitEthernet-MidEnd_25_Evaluator.p4 index b364ff2b0ff..87e93f25def 100644 --- a/testdata/v1_samples_outputs/02-SplitEthernet-midend.p4 +++ b/testdata/v1_samples_outputs/02-SplitEthernet-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header len_or_type_t { bit<48> value; } diff --git a/testdata/v1_samples_outputs/02-SplitEthernet-fe.p4 b/testdata/v1_samples_outputs/02-SplitEthernet-fe.p4 deleted file mode 100644 index 5ccc0bde473..00000000000 --- a/testdata/v1_samples_outputs/02-SplitEthernet-fe.p4 +++ /dev/null @@ -1,101 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header len_or_type_t { - bit<48> value; -} - -header mac_da_t { - bit<48> mac; -} - -header mac_sa_t { - bit<48> mac; -} - -struct metadata { -} - -struct headers { - @name("len_or_type") - len_or_type_t len_or_type; - @name("mac_da") - mac_da_t mac_da; - @name("mac_sa") - mac_sa_t mac_sa; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("parse_len_or_type") state parse_len_or_type { - packet.extract(hdr.len_or_type); - transition accept; - } - @name("parse_mac_da") state parse_mac_da { - packet.extract(hdr.mac_da); - transition parse_mac_sa; - } - @name("parse_mac_sa") state parse_mac_sa { - packet.extract(hdr.mac_sa); - transition parse_len_or_type; - } - @name("start") state start { - transition parse_mac_da; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t2") table t2() { - actions = { - nop; - NoAction; - } - key = { - hdr.mac_sa.mac: exact; - } - default_action = NoAction(); - } - apply { - t2.apply(); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t1") table t1() { - actions = { - nop; - NoAction; - } - key = { - hdr.mac_da.mac : exact; - hdr.len_or_type.value: exact; - } - default_action = NoAction(); - } - apply { - t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.mac_da); - packet.emit(hdr.mac_sa); - packet.emit(hdr.len_or_type); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/02-SplitEthernet-last.p4 b/testdata/v1_samples_outputs/02-SplitEthernet-last.p4 deleted file mode 100644 index 5ccc0bde473..00000000000 --- a/testdata/v1_samples_outputs/02-SplitEthernet-last.p4 +++ /dev/null @@ -1,101 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header len_or_type_t { - bit<48> value; -} - -header mac_da_t { - bit<48> mac; -} - -header mac_sa_t { - bit<48> mac; -} - -struct metadata { -} - -struct headers { - @name("len_or_type") - len_or_type_t len_or_type; - @name("mac_da") - mac_da_t mac_da; - @name("mac_sa") - mac_sa_t mac_sa; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("parse_len_or_type") state parse_len_or_type { - packet.extract(hdr.len_or_type); - transition accept; - } - @name("parse_mac_da") state parse_mac_da { - packet.extract(hdr.mac_da); - transition parse_mac_sa; - } - @name("parse_mac_sa") state parse_mac_sa { - packet.extract(hdr.mac_sa); - transition parse_len_or_type; - } - @name("start") state start { - transition parse_mac_da; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t2") table t2() { - actions = { - nop; - NoAction; - } - key = { - hdr.mac_sa.mac: exact; - } - default_action = NoAction(); - } - apply { - t2.apply(); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t1") table t1() { - actions = { - nop; - NoAction; - } - key = { - hdr.mac_da.mac : exact; - hdr.len_or_type.value: exact; - } - default_action = NoAction(); - } - apply { - t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.mac_da); - packet.emit(hdr.mac_sa); - packet.emit(hdr.len_or_type); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/03-DeadMetadata3-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/03-DeadMetadata3-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..dbfb55aa79b --- /dev/null +++ b/testdata/v1_samples_outputs/03-DeadMetadata3-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,193 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct m_t { + bit<32> f1; + bit<32> f2; +} + +struct metadata { + @name("m") + m_t m; +} + +struct headers { +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("a1") action a1() { + meta.m.f1 = 32w1; + } + @name("a2") action a2() { + meta.m.f2 = 32w2; + } + @name("t1") table t1() { + actions = { + a1; + NoAction; + } + default_action = NoAction(); + } + @name("t2") table t2() { + actions = { + a2; + NoAction; + } + key = { + meta.m.f1: exact; + } + default_action = NoAction(); + } + apply { + t1.apply(); + t2.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/03-DeadMetadata3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/03-DeadMetadata3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..6292d0399bb --- /dev/null +++ b/testdata/v1_samples_outputs/03-DeadMetadata3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,177 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct m_t { + bit<32> f1; + bit<32> f2; +} + +struct metadata { + @name("m") + m_t m; +} + +struct headers { +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("a1") action a1() { + meta.m.f1 = 32w1; + } + @name("a2") action a2() { + meta.m.f2 = 32w2; + } + @name("t1") table t1() { + actions = { + a1; + NoAction; + } + default_action = NoAction(); + } + @name("t2") table t2() { + actions = { + a2; + NoAction; + } + key = { + meta.m.f1: exact; + } + default_action = NoAction(); + } + apply { + t1.apply(); + t2.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/03-DeadMetadata3-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/03-DeadMetadata3-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..282ffba237b --- /dev/null +++ b/testdata/v1_samples_outputs/03-DeadMetadata3-MidEnd_25_Evaluator.p4 @@ -0,0 +1,179 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct m_t { + bit<32> f1; + bit<32> f2; +} + +struct metadata { + @name("m") + m_t m; +} + +struct headers { +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + action NoAction_1() { + } + @name("a1") action a1_0() { + meta.m.f1 = 32w1; + } + @name("a2") action a2_0() { + meta.m.f2 = 32w2; + } + @name("t1") table t1_0() { + actions = { + a1_0; + NoAction_0; + } + default_action = NoAction_0(); + } + @name("t2") table t2_0() { + actions = { + a2_0; + NoAction_1; + } + key = { + meta.m.f1: exact; + } + default_action = NoAction_0(); + } + apply { + t1_0.apply(); + t2_0.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/03-DeadMetadata3-fe.p4 b/testdata/v1_samples_outputs/03-DeadMetadata3-fe.p4 deleted file mode 100644 index 27b3090b959..00000000000 --- a/testdata/v1_samples_outputs/03-DeadMetadata3-fe.p4 +++ /dev/null @@ -1,73 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct m_t { - bit<32> f1; - bit<32> f2; -} - -struct metadata { - @name("m") - m_t m; -} - -struct headers { -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("a1") action a1() { - meta.m.f1 = 32w1; - } - @name("a2") action a2() { - meta.m.f2 = 32w2; - } - @name("t1") table t1() { - actions = { - a1; - NoAction; - } - default_action = NoAction(); - } - @name("t2") table t2() { - actions = { - a2; - NoAction; - } - key = { - meta.m.f1: exact; - } - default_action = NoAction(); - } - apply { - t1.apply(); - t2.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/03-DeadMetadata3-last.p4 b/testdata/v1_samples_outputs/03-DeadMetadata3-last.p4 deleted file mode 100644 index 27b3090b959..00000000000 --- a/testdata/v1_samples_outputs/03-DeadMetadata3-last.p4 +++ /dev/null @@ -1,73 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct m_t { - bit<32> f1; - bit<32> f2; -} - -struct metadata { - @name("m") - m_t m; -} - -struct headers { -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("a1") action a1() { - meta.m.f1 = 32w1; - } - @name("a2") action a2() { - meta.m.f2 = 32w2; - } - @name("t1") table t1() { - actions = { - a1; - NoAction; - } - default_action = NoAction(); - } - @name("t2") table t2() { - actions = { - a2; - NoAction; - } - key = { - meta.m.f1: exact; - } - default_action = NoAction(); - } - apply { - t1.apply(); - t2.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/03-DeadMetadata3-midend.p4 b/testdata/v1_samples_outputs/03-DeadMetadata3-midend.p4 deleted file mode 100644 index 6a40666f7aa..00000000000 --- a/testdata/v1_samples_outputs/03-DeadMetadata3-midend.p4 +++ /dev/null @@ -1,77 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct m_t { - bit<32> f1; - bit<32> f2; -} - -struct metadata { - @name("m") - m_t m; -} - -struct headers { -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - action NoAction_1() { - } - @name("a1") action a1_0() { - meta.m.f1 = 32w1; - } - @name("a2") action a2_0() { - meta.m.f2 = 32w2; - } - @name("t1") table t1_0() { - actions = { - a1_0; - NoAction_0; - } - default_action = NoAction_0(); - } - @name("t2") table t2_0() { - actions = { - a2_0; - NoAction_1; - } - key = { - meta.m.f1: exact; - } - default_action = NoAction_0(); - } - apply { - t1_0.apply(); - t2_0.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/03-FullPHV2-fe.p4 b/testdata/v1_samples_outputs/03-FullPHV2-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 87% rename from testdata/v1_samples_outputs/03-FullPHV2-fe.p4 rename to testdata/v1_samples_outputs/03-FullPHV2-FrontEnd_11_SimplifyControlFlowE.p4 index dc6fa2779b1..e6352ec9e50 100644 --- a/testdata/v1_samples_outputs/03-FullPHV2-fe.p4 +++ b/testdata/v1_samples_outputs/03-FullPHV2-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct m_t { bit<8> field_8_01; bit<8> field_8_02; @@ -467,7 +587,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t2_1") table t2_1() { actions = { a2_1; @@ -541,7 +660,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t2_2") table t2_2() { actions = { a2_2; @@ -567,7 +685,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t2_3") table t2_3() { actions = { a2_3; @@ -593,7 +710,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t3_1") table t3_1() { actions = { a3_1; @@ -622,7 +738,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t4_1") table t4_1() { actions = { a4_1; @@ -658,7 +773,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); t2_1.apply(); diff --git a/testdata/v1_samples_outputs/03-FullPHV2-last.p4 b/testdata/v1_samples_outputs/03-FullPHV2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 89% rename from testdata/v1_samples_outputs/03-FullPHV2-last.p4 rename to testdata/v1_samples_outputs/03-FullPHV2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index dc6fa2779b1..bafff5679ba 100644 --- a/testdata/v1_samples_outputs/03-FullPHV2-last.p4 +++ b/testdata/v1_samples_outputs/03-FullPHV2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct m_t { bit<8> field_8_01; bit<8> field_8_02; @@ -467,7 +571,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t2_1") table t2_1() { actions = { a2_1; @@ -541,7 +644,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t2_2") table t2_2() { actions = { a2_2; @@ -567,7 +669,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t2_3") table t2_3() { actions = { a2_3; @@ -593,7 +694,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t3_1") table t3_1() { actions = { a3_1; @@ -622,7 +722,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t4_1") table t4_1() { actions = { a4_1; @@ -658,7 +757,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); t2_1.apply(); diff --git a/testdata/v1_samples_outputs/03-FullPHV2-midend.p4 b/testdata/v1_samples_outputs/03-FullPHV2-MidEnd_25_Evaluator.p4 similarity index 90% rename from testdata/v1_samples_outputs/03-FullPHV2-midend.p4 rename to testdata/v1_samples_outputs/03-FullPHV2-MidEnd_25_Evaluator.p4 index cc7051da971..9b45956ccee 100644 --- a/testdata/v1_samples_outputs/03-FullPHV2-midend.p4 +++ b/testdata/v1_samples_outputs/03-FullPHV2-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct m_t { bit<8> field_8_01; bit<8> field_8_02; diff --git a/testdata/v1_samples_outputs/03-FullPHV2.p4 b/testdata/v1_samples_outputs/03-FullPHV2.p4 index dc6fa2779b1..5800deb8edf 100644 --- a/testdata/v1_samples_outputs/03-FullPHV2.p4 +++ b/testdata/v1_samples_outputs/03-FullPHV2.p4 @@ -467,7 +467,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t2_1") table t2_1() { actions = { a2_1; @@ -541,7 +540,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t2_2") table t2_2() { actions = { a2_2; @@ -567,7 +565,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t2_3") table t2_3() { actions = { a2_3; @@ -593,7 +590,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t3_1") table t3_1() { actions = { a3_1; @@ -622,7 +618,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t4_1") table t4_1() { actions = { a4_1; @@ -658,7 +653,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); t2_1.apply(); diff --git a/testdata/v1_samples_outputs/03-Gateway-fe.p4 b/testdata/v1_samples_outputs/03-Gateway-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 55% rename from testdata/v1_samples_outputs/03-Gateway-fe.p4 rename to testdata/v1_samples_outputs/03-Gateway-FrontEnd_11_SimplifyControlFlowE.p4 index 9c198c2b216..807ffe0eb29 100644 --- a/testdata/v1_samples_outputs/03-Gateway-fe.p4 +++ b/testdata/v1_samples_outputs/03-Gateway-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<1> drop; bit<8> egress_port; diff --git a/testdata/v1_samples_outputs/03-Gateway-last.p4 b/testdata/v1_samples_outputs/03-Gateway-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 61% rename from testdata/v1_samples_outputs/03-Gateway-last.p4 rename to testdata/v1_samples_outputs/03-Gateway-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 9c198c2b216..fac085d1360 100644 --- a/testdata/v1_samples_outputs/03-Gateway-last.p4 +++ b/testdata/v1_samples_outputs/03-Gateway-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<1> drop; bit<8> egress_port; diff --git a/testdata/v1_samples_outputs/03-Gateway-midend.p4 b/testdata/v1_samples_outputs/03-Gateway-MidEnd_25_Evaluator.p4 similarity index 63% rename from testdata/v1_samples_outputs/03-Gateway-midend.p4 rename to testdata/v1_samples_outputs/03-Gateway-MidEnd_25_Evaluator.p4 index 0f0b62c3d14..ab721954955 100644 --- a/testdata/v1_samples_outputs/03-Gateway-midend.p4 +++ b/testdata/v1_samples_outputs/03-Gateway-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<1> drop; bit<8> egress_port; diff --git a/testdata/v1_samples_outputs/03-SplitEthernetCompact-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/03-SplitEthernetCompact-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..4ff5258e4de --- /dev/null +++ b/testdata/v1_samples_outputs/03-SplitEthernetCompact-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,212 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header len_or_type_t { + bit<48> value; +} + +header mac_da_t { + bit<48> mac; +} + +header mac_sa_t { + bit<48> mac; +} + +struct metadata { +} + +struct headers { + @name("len_or_type") + len_or_type_t len_or_type; + @name("mac_da") + mac_da_t mac_da; + @name("mac_sa") + mac_sa_t mac_sa; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.mac_da); + packet.extract(hdr.mac_sa); + packet.extract(hdr.len_or_type); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t2") table t2() { + actions = { + nop; + NoAction; + } + key = { + hdr.mac_sa.mac: exact; + } + default_action = NoAction(); + } + apply { + t2.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t1") table t1() { + actions = { + nop; + NoAction; + } + key = { + hdr.mac_da.mac : exact; + hdr.len_or_type.value: exact; + } + default_action = NoAction(); + } + apply { + t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.mac_da); + packet.emit(hdr.mac_sa); + packet.emit(hdr.len_or_type); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/03-SplitEthernetCompact-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/03-SplitEthernetCompact-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..b51a77cd91d --- /dev/null +++ b/testdata/v1_samples_outputs/03-SplitEthernetCompact-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,196 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header len_or_type_t { + bit<48> value; +} + +header mac_da_t { + bit<48> mac; +} + +header mac_sa_t { + bit<48> mac; +} + +struct metadata { +} + +struct headers { + @name("len_or_type") + len_or_type_t len_or_type; + @name("mac_da") + mac_da_t mac_da; + @name("mac_sa") + mac_sa_t mac_sa; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.mac_da); + packet.extract(hdr.mac_sa); + packet.extract(hdr.len_or_type); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t2") table t2() { + actions = { + nop; + NoAction; + } + key = { + hdr.mac_sa.mac: exact; + } + default_action = NoAction(); + } + apply { + t2.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t1") table t1() { + actions = { + nop; + NoAction; + } + key = { + hdr.mac_da.mac : exact; + hdr.len_or_type.value: exact; + } + default_action = NoAction(); + } + apply { + t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.mac_da); + packet.emit(hdr.mac_sa); + packet.emit(hdr.len_or_type); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/03-SplitEthernetCompact-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/03-SplitEthernetCompact-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..4ddac4c71a0 --- /dev/null +++ b/testdata/v1_samples_outputs/03-SplitEthernetCompact-MidEnd_25_Evaluator.p4 @@ -0,0 +1,198 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header len_or_type_t { + bit<48> value; +} + +header mac_da_t { + bit<48> mac; +} + +header mac_sa_t { + bit<48> mac; +} + +struct metadata { +} + +struct headers { + @name("len_or_type") + len_or_type_t len_or_type; + @name("mac_da") + mac_da_t mac_da; + @name("mac_sa") + mac_sa_t mac_sa; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.mac_da); + packet.extract(hdr.mac_sa); + packet.extract(hdr.len_or_type); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("nop") action nop_0() { + } + @name("t2") table t2_0() { + actions = { + nop_0; + NoAction_0; + } + key = { + hdr.mac_sa.mac: exact; + } + default_action = NoAction_0(); + } + apply { + t2_0.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_1() { + } + @name("nop") action nop_1() { + } + @name("t1") table t1_0() { + actions = { + nop_1; + NoAction_1; + } + key = { + hdr.mac_da.mac : exact; + hdr.len_or_type.value: exact; + } + default_action = NoAction_1(); + } + apply { + t1_0.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.mac_da); + packet.emit(hdr.mac_sa); + packet.emit(hdr.len_or_type); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/03-SplitEthernetCompact-fe.p4 b/testdata/v1_samples_outputs/03-SplitEthernetCompact-fe.p4 deleted file mode 100644 index 23d13c0cd02..00000000000 --- a/testdata/v1_samples_outputs/03-SplitEthernetCompact-fe.p4 +++ /dev/null @@ -1,94 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header len_or_type_t { - bit<48> value; -} - -header mac_da_t { - bit<48> mac; -} - -header mac_sa_t { - bit<48> mac; -} - -struct metadata { -} - -struct headers { - @name("len_or_type") - len_or_type_t len_or_type; - @name("mac_da") - mac_da_t mac_da; - @name("mac_sa") - mac_sa_t mac_sa; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.mac_da); - packet.extract(hdr.mac_sa); - packet.extract(hdr.len_or_type); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t2") table t2() { - actions = { - nop; - NoAction; - } - key = { - hdr.mac_sa.mac: exact; - } - default_action = NoAction(); - } - - apply { - t2.apply(); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t1") table t1() { - actions = { - nop; - NoAction; - } - key = { - hdr.mac_da.mac : exact; - hdr.len_or_type.value: exact; - } - default_action = NoAction(); - } - - apply { - t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.mac_da); - packet.emit(hdr.mac_sa); - packet.emit(hdr.len_or_type); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/03-SplitEthernetCompact-last.p4 b/testdata/v1_samples_outputs/03-SplitEthernetCompact-last.p4 deleted file mode 100644 index 23d13c0cd02..00000000000 --- a/testdata/v1_samples_outputs/03-SplitEthernetCompact-last.p4 +++ /dev/null @@ -1,94 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header len_or_type_t { - bit<48> value; -} - -header mac_da_t { - bit<48> mac; -} - -header mac_sa_t { - bit<48> mac; -} - -struct metadata { -} - -struct headers { - @name("len_or_type") - len_or_type_t len_or_type; - @name("mac_da") - mac_da_t mac_da; - @name("mac_sa") - mac_sa_t mac_sa; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.mac_da); - packet.extract(hdr.mac_sa); - packet.extract(hdr.len_or_type); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t2") table t2() { - actions = { - nop; - NoAction; - } - key = { - hdr.mac_sa.mac: exact; - } - default_action = NoAction(); - } - - apply { - t2.apply(); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t1") table t1() { - actions = { - nop; - NoAction; - } - key = { - hdr.mac_da.mac : exact; - hdr.len_or_type.value: exact; - } - default_action = NoAction(); - } - - apply { - t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.mac_da); - packet.emit(hdr.mac_sa); - packet.emit(hdr.len_or_type); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/03-SplitEthernetCompact-midend.p4 b/testdata/v1_samples_outputs/03-SplitEthernetCompact-midend.p4 deleted file mode 100644 index 47eba13193a..00000000000 --- a/testdata/v1_samples_outputs/03-SplitEthernetCompact-midend.p4 +++ /dev/null @@ -1,96 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header len_or_type_t { - bit<48> value; -} - -header mac_da_t { - bit<48> mac; -} - -header mac_sa_t { - bit<48> mac; -} - -struct metadata { -} - -struct headers { - @name("len_or_type") - len_or_type_t len_or_type; - @name("mac_da") - mac_da_t mac_da; - @name("mac_sa") - mac_sa_t mac_sa; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.mac_da); - packet.extract(hdr.mac_sa); - packet.extract(hdr.len_or_type); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("nop") action nop_0() { - } - @name("t2") table t2_0() { - actions = { - nop_0; - NoAction_0; - } - key = { - hdr.mac_sa.mac: exact; - } - default_action = NoAction_0(); - } - apply { - t2_0.apply(); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_1() { - } - @name("nop") action nop_1() { - } - @name("t1") table t1_0() { - actions = { - nop_1; - NoAction_1; - } - key = { - hdr.mac_da.mac : exact; - hdr.len_or_type.value: exact; - } - default_action = NoAction_1(); - } - apply { - t1_0.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.mac_da); - packet.emit(hdr.mac_sa); - packet.emit(hdr.len_or_type); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/03-SplitEthernetCompact.p4 b/testdata/v1_samples_outputs/03-SplitEthernetCompact.p4 index 23d13c0cd02..1d213770f89 100644 --- a/testdata/v1_samples_outputs/03-SplitEthernetCompact.p4 +++ b/testdata/v1_samples_outputs/03-SplitEthernetCompact.p4 @@ -47,7 +47,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { t2.apply(); } @@ -67,7 +66,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); } diff --git a/testdata/v1_samples_outputs/04-GatewayDefault-last.p4 b/testdata/v1_samples_outputs/04-GatewayDefault-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 54% rename from testdata/v1_samples_outputs/04-GatewayDefault-last.p4 rename to testdata/v1_samples_outputs/04-GatewayDefault-FrontEnd_11_SimplifyControlFlowE.p4 index 2016144169c..c0dd4232366 100644 --- a/testdata/v1_samples_outputs/04-GatewayDefault-last.p4 +++ b/testdata/v1_samples_outputs/04-GatewayDefault-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<8> drop; bit<8> egress_port; @@ -46,7 +166,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { e_t1.apply(); } @@ -88,7 +207,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("i_t2") table i_t2() { actions = { nop; @@ -100,7 +218,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("i_t3") table i_t3() { actions = { nop; @@ -112,7 +229,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("i_t4") table i_t4() { actions = { nop; @@ -124,7 +240,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { switch (i_t1.apply().action_run) { default: { diff --git a/testdata/v1_samples_outputs/04-GatewayDefault-fe.p4 b/testdata/v1_samples_outputs/04-GatewayDefault-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 60% rename from testdata/v1_samples_outputs/04-GatewayDefault-fe.p4 rename to testdata/v1_samples_outputs/04-GatewayDefault-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 2016144169c..3440faf717c 100644 --- a/testdata/v1_samples_outputs/04-GatewayDefault-fe.p4 +++ b/testdata/v1_samples_outputs/04-GatewayDefault-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<8> drop; bit<8> egress_port; @@ -46,7 +150,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { e_t1.apply(); } @@ -88,7 +191,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("i_t2") table i_t2() { actions = { nop; @@ -100,7 +202,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("i_t3") table i_t3() { actions = { nop; @@ -112,7 +213,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("i_t4") table i_t4() { actions = { nop; @@ -124,7 +224,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { switch (i_t1.apply().action_run) { default: { diff --git a/testdata/v1_samples_outputs/04-GatewayDefault-midend.p4 b/testdata/v1_samples_outputs/04-GatewayDefault-MidEnd_25_Evaluator.p4 similarity index 63% rename from testdata/v1_samples_outputs/04-GatewayDefault-midend.p4 rename to testdata/v1_samples_outputs/04-GatewayDefault-MidEnd_25_Evaluator.p4 index 6b8f3f5cc49..8ec5a7d432d 100644 --- a/testdata/v1_samples_outputs/04-GatewayDefault-midend.p4 +++ b/testdata/v1_samples_outputs/04-GatewayDefault-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<8> drop; bit<8> egress_port; diff --git a/testdata/v1_samples_outputs/04-GatewayDefault.p4 b/testdata/v1_samples_outputs/04-GatewayDefault.p4 index 2016144169c..cf5d7a92399 100644 --- a/testdata/v1_samples_outputs/04-GatewayDefault.p4 +++ b/testdata/v1_samples_outputs/04-GatewayDefault.p4 @@ -46,7 +46,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { e_t1.apply(); } @@ -88,7 +87,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("i_t2") table i_t2() { actions = { nop; @@ -100,7 +98,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("i_t3") table i_t3() { actions = { nop; @@ -112,7 +109,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("i_t4") table i_t4() { actions = { nop; @@ -124,7 +120,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { switch (i_t1.apply().action_run) { default: { diff --git a/testdata/v1_samples_outputs/04-SimpleVlan-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/04-SimpleVlan-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..dc8372e5802 --- /dev/null +++ b/testdata/v1_samples_outputs/04-SimpleVlan-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,218 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +header vlan_tag_t { + bit<3> pcp; + bit<1> cfi; + bit<12> vlan_id; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("vlan_tag") + vlan_tag_t vlan_tag; +} + +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) { + 16w0x8100: parse_vlan_tag; + 16w0x9100: parse_vlan_tag; + default: accept; + } + } + @name("parse_vlan_tag") state parse_vlan_tag { + packet.extract(hdr.vlan_tag); + transition accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t2") table t2() { + actions = { + nop; + NoAction; + } + key = { + hdr.ethernet.srcAddr: exact; + } + default_action = NoAction(); + } + apply { + t2.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t1") table t1() { + actions = { + nop; + NoAction; + } + key = { + hdr.ethernet.dstAddr: exact; + } + default_action = NoAction(); + } + apply { + t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.vlan_tag); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/04-SimpleVlan-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/04-SimpleVlan-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..a51858be9b4 --- /dev/null +++ b/testdata/v1_samples_outputs/04-SimpleVlan-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,202 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +header vlan_tag_t { + bit<3> pcp; + bit<1> cfi; + bit<12> vlan_id; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("vlan_tag") + vlan_tag_t vlan_tag; +} + +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) { + 16w0x8100: parse_vlan_tag; + 16w0x9100: parse_vlan_tag; + default: accept; + } + } + @name("parse_vlan_tag") state parse_vlan_tag { + packet.extract(hdr.vlan_tag); + transition accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t2") table t2() { + actions = { + nop; + NoAction; + } + key = { + hdr.ethernet.srcAddr: exact; + } + default_action = NoAction(); + } + apply { + t2.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t1") table t1() { + actions = { + nop; + NoAction; + } + key = { + hdr.ethernet.dstAddr: exact; + } + default_action = NoAction(); + } + apply { + t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.vlan_tag); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/04-SimpleVlan-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/04-SimpleVlan-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..62f950ddcc8 --- /dev/null +++ b/testdata/v1_samples_outputs/04-SimpleVlan-MidEnd_25_Evaluator.p4 @@ -0,0 +1,204 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +header vlan_tag_t { + bit<3> pcp; + bit<1> cfi; + bit<12> vlan_id; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("vlan_tag") + vlan_tag_t vlan_tag; +} + +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) { + 16w0x8100: parse_vlan_tag; + 16w0x9100: parse_vlan_tag; + default: accept; + } + } + @name("parse_vlan_tag") state parse_vlan_tag { + packet.extract(hdr.vlan_tag); + transition accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("nop") action nop_0() { + } + @name("t2") table t2_0() { + actions = { + nop_0; + NoAction_0; + } + key = { + hdr.ethernet.srcAddr: exact; + } + default_action = NoAction_0(); + } + apply { + t2_0.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_1() { + } + @name("nop") action nop_1() { + } + @name("t1") table t1_0() { + actions = { + nop_1; + NoAction_1; + } + key = { + hdr.ethernet.dstAddr: exact; + } + default_action = NoAction_1(); + } + apply { + t1_0.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.vlan_tag); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/04-SimpleVlan-fe.p4 b/testdata/v1_samples_outputs/04-SimpleVlan-fe.p4 deleted file mode 100644 index f3c3587e9ae..00000000000 --- a/testdata/v1_samples_outputs/04-SimpleVlan-fe.p4 +++ /dev/null @@ -1,100 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -header vlan_tag_t { - bit<3> pcp; - bit<1> cfi; - bit<12> vlan_id; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; - @name("vlan_tag") - vlan_tag_t vlan_tag; -} - -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) { - 16w0x8100: parse_vlan_tag; - 16w0x9100: parse_vlan_tag; - default: accept; - } - } - @name("parse_vlan_tag") state parse_vlan_tag { - packet.extract(hdr.vlan_tag); - transition accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t2") table t2() { - actions = { - nop; - NoAction; - } - key = { - hdr.ethernet.srcAddr: exact; - } - default_action = NoAction(); - } - - apply { - t2.apply(); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t1") table t1() { - actions = { - nop; - NoAction; - } - key = { - hdr.ethernet.dstAddr: exact; - } - default_action = NoAction(); - } - - apply { - t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - packet.emit(hdr.vlan_tag); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/04-SimpleVlan-last.p4 b/testdata/v1_samples_outputs/04-SimpleVlan-last.p4 deleted file mode 100644 index f3c3587e9ae..00000000000 --- a/testdata/v1_samples_outputs/04-SimpleVlan-last.p4 +++ /dev/null @@ -1,100 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -header vlan_tag_t { - bit<3> pcp; - bit<1> cfi; - bit<12> vlan_id; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; - @name("vlan_tag") - vlan_tag_t vlan_tag; -} - -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) { - 16w0x8100: parse_vlan_tag; - 16w0x9100: parse_vlan_tag; - default: accept; - } - } - @name("parse_vlan_tag") state parse_vlan_tag { - packet.extract(hdr.vlan_tag); - transition accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t2") table t2() { - actions = { - nop; - NoAction; - } - key = { - hdr.ethernet.srcAddr: exact; - } - default_action = NoAction(); - } - - apply { - t2.apply(); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t1") table t1() { - actions = { - nop; - NoAction; - } - key = { - hdr.ethernet.dstAddr: exact; - } - default_action = NoAction(); - } - - apply { - t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - packet.emit(hdr.vlan_tag); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/04-SimpleVlan-midend.p4 b/testdata/v1_samples_outputs/04-SimpleVlan-midend.p4 deleted file mode 100644 index babd6845b14..00000000000 --- a/testdata/v1_samples_outputs/04-SimpleVlan-midend.p4 +++ /dev/null @@ -1,102 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -header vlan_tag_t { - bit<3> pcp; - bit<1> cfi; - bit<12> vlan_id; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; - @name("vlan_tag") - vlan_tag_t vlan_tag; -} - -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) { - 16w0x8100: parse_vlan_tag; - 16w0x9100: parse_vlan_tag; - default: accept; - } - } - @name("parse_vlan_tag") state parse_vlan_tag { - packet.extract(hdr.vlan_tag); - transition accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("nop") action nop_0() { - } - @name("t2") table t2_0() { - actions = { - nop_0; - NoAction_0; - } - key = { - hdr.ethernet.srcAddr: exact; - } - default_action = NoAction_0(); - } - apply { - t2_0.apply(); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_1() { - } - @name("nop") action nop_1() { - } - @name("t1") table t1_0() { - actions = { - nop_1; - NoAction_1; - } - key = { - hdr.ethernet.dstAddr: exact; - } - default_action = NoAction_1(); - } - apply { - t1_0.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - packet.emit(hdr.vlan_tag); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/04-SimpleVlan.p4 b/testdata/v1_samples_outputs/04-SimpleVlan.p4 index f3c3587e9ae..6770939f445 100644 --- a/testdata/v1_samples_outputs/04-SimpleVlan.p4 +++ b/testdata/v1_samples_outputs/04-SimpleVlan.p4 @@ -55,7 +55,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { t2.apply(); } @@ -74,7 +73,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); } diff --git a/testdata/v1_samples_outputs/05-FieldProblem-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/05-FieldProblem-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..1c684004dbc --- /dev/null +++ b/testdata/v1_samples_outputs/05-FieldProblem-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,210 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct ingress_metadata_t { + bit<8> f1; + bit<16> f2; + bit<32> f3; +} + +header vag_t { + bit<8> f1; + bit<16> f2; + bit<32> f3; +} + +struct metadata { + @name("ing_metadata") + ingress_metadata_t ing_metadata; +} + +struct headers { + @name("vag") + vag_t vag; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.vag); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("e_t1") table e_t1() { + actions = { + nop; + NoAction; + } + key = { + hdr.vag.f1: exact; + } + default_action = NoAction(); + } + apply { + e_t1.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("set_f1") action set_f1(bit<8> f1) { + meta.ing_metadata.f1 = f1; + } + @name("i_t1") table i_t1() { + actions = { + nop; + set_f1; + NoAction; + } + key = { + hdr.vag.f1: exact; + } + size = 1024; + default_action = NoAction(); + } + apply { + i_t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.vag); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/05-FieldProblem-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/05-FieldProblem-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..2cc4fdf2604 --- /dev/null +++ b/testdata/v1_samples_outputs/05-FieldProblem-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,194 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct ingress_metadata_t { + bit<8> f1; + bit<16> f2; + bit<32> f3; +} + +header vag_t { + bit<8> f1; + bit<16> f2; + bit<32> f3; +} + +struct metadata { + @name("ing_metadata") + ingress_metadata_t ing_metadata; +} + +struct headers { + @name("vag") + vag_t vag; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.vag); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("e_t1") table e_t1() { + actions = { + nop; + NoAction; + } + key = { + hdr.vag.f1: exact; + } + default_action = NoAction(); + } + apply { + e_t1.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("set_f1") action set_f1(bit<8> f1) { + meta.ing_metadata.f1 = f1; + } + @name("i_t1") table i_t1() { + actions = { + nop; + set_f1; + NoAction; + } + key = { + hdr.vag.f1: exact; + } + size = 1024; + default_action = NoAction(); + } + apply { + i_t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.vag); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/05-FieldProblem-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/05-FieldProblem-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..a1f9e4bf273 --- /dev/null +++ b/testdata/v1_samples_outputs/05-FieldProblem-MidEnd_25_Evaluator.p4 @@ -0,0 +1,196 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct ingress_metadata_t { + bit<8> f1; + bit<16> f2; + bit<32> f3; +} + +header vag_t { + bit<8> f1; + bit<16> f2; + bit<32> f3; +} + +struct metadata { + @name("ing_metadata") + ingress_metadata_t ing_metadata; +} + +struct headers { + @name("vag") + vag_t vag; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.vag); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("nop") action nop_0() { + } + @name("e_t1") table e_t1_0() { + actions = { + nop_0; + NoAction_0; + } + key = { + hdr.vag.f1: exact; + } + default_action = NoAction_0(); + } + apply { + e_t1_0.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_1() { + } + @name("nop") action nop_1() { + } + @name("set_f1") action set_f1_0(bit<8> f1) { + meta.ing_metadata.f1 = f1; + } + @name("i_t1") table i_t1_0() { + actions = { + nop_1; + set_f1_0; + NoAction_1; + } + key = { + hdr.vag.f1: exact; + } + size = 1024; + default_action = NoAction_1(); + } + apply { + i_t1_0.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.vag); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/05-FieldProblem-fe.p4 b/testdata/v1_samples_outputs/05-FieldProblem-fe.p4 deleted file mode 100644 index a56ce966d7b..00000000000 --- a/testdata/v1_samples_outputs/05-FieldProblem-fe.p4 +++ /dev/null @@ -1,92 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct ingress_metadata_t { - bit<8> f1; - bit<16> f2; - bit<32> f3; -} - -header vag_t { - bit<8> f1; - bit<16> f2; - bit<32> f3; -} - -struct metadata { - @name("ing_metadata") - ingress_metadata_t ing_metadata; -} - -struct headers { - @name("vag") - vag_t vag; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.vag); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("e_t1") table e_t1() { - actions = { - nop; - NoAction; - } - key = { - hdr.vag.f1: exact; - } - default_action = NoAction(); - } - - apply { - e_t1.apply(); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("set_f1") action set_f1(bit<8> f1) { - meta.ing_metadata.f1 = f1; - } - @name("i_t1") table i_t1() { - actions = { - nop; - set_f1; - NoAction; - } - key = { - hdr.vag.f1: exact; - } - size = 1024; - default_action = NoAction(); - } - - apply { - i_t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.vag); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/05-FieldProblem-last.p4 b/testdata/v1_samples_outputs/05-FieldProblem-last.p4 deleted file mode 100644 index a56ce966d7b..00000000000 --- a/testdata/v1_samples_outputs/05-FieldProblem-last.p4 +++ /dev/null @@ -1,92 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct ingress_metadata_t { - bit<8> f1; - bit<16> f2; - bit<32> f3; -} - -header vag_t { - bit<8> f1; - bit<16> f2; - bit<32> f3; -} - -struct metadata { - @name("ing_metadata") - ingress_metadata_t ing_metadata; -} - -struct headers { - @name("vag") - vag_t vag; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.vag); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("e_t1") table e_t1() { - actions = { - nop; - NoAction; - } - key = { - hdr.vag.f1: exact; - } - default_action = NoAction(); - } - - apply { - e_t1.apply(); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("set_f1") action set_f1(bit<8> f1) { - meta.ing_metadata.f1 = f1; - } - @name("i_t1") table i_t1() { - actions = { - nop; - set_f1; - NoAction; - } - key = { - hdr.vag.f1: exact; - } - size = 1024; - default_action = NoAction(); - } - - apply { - i_t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.vag); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/05-FieldProblem-midend.p4 b/testdata/v1_samples_outputs/05-FieldProblem-midend.p4 deleted file mode 100644 index 9d24ec7250f..00000000000 --- a/testdata/v1_samples_outputs/05-FieldProblem-midend.p4 +++ /dev/null @@ -1,94 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct ingress_metadata_t { - bit<8> f1; - bit<16> f2; - bit<32> f3; -} - -header vag_t { - bit<8> f1; - bit<16> f2; - bit<32> f3; -} - -struct metadata { - @name("ing_metadata") - ingress_metadata_t ing_metadata; -} - -struct headers { - @name("vag") - vag_t vag; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.vag); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("nop") action nop_0() { - } - @name("e_t1") table e_t1_0() { - actions = { - nop_0; - NoAction_0; - } - key = { - hdr.vag.f1: exact; - } - default_action = NoAction_0(); - } - apply { - e_t1_0.apply(); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_1() { - } - @name("nop") action nop_1() { - } - @name("set_f1") action set_f1_0(bit<8> f1) { - meta.ing_metadata.f1 = f1; - } - @name("i_t1") table i_t1_0() { - actions = { - nop_1; - set_f1_0; - NoAction_1; - } - key = { - hdr.vag.f1: exact; - } - size = 1024; - default_action = NoAction_1(); - } - apply { - i_t1_0.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.vag); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/05-FieldProblem.p4 b/testdata/v1_samples_outputs/05-FieldProblem.p4 index a56ce966d7b..e5fa3547134 100644 --- a/testdata/v1_samples_outputs/05-FieldProblem.p4 +++ b/testdata/v1_samples_outputs/05-FieldProblem.p4 @@ -43,7 +43,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { e_t1.apply(); } @@ -67,7 +66,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 1024; default_action = NoAction(); } - apply { i_t1.apply(); } diff --git a/testdata/v1_samples_outputs/05-FullTPHV-fe.p4 b/testdata/v1_samples_outputs/05-FullTPHV-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 90% rename from testdata/v1_samples_outputs/05-FullTPHV-fe.p4 rename to testdata/v1_samples_outputs/05-FullTPHV-FrontEnd_11_SimplifyControlFlowE.p4 index 6fd92bd1ced..16821101794 100644 --- a/testdata/v1_samples_outputs/05-FullTPHV-fe.p4 +++ b/testdata/v1_samples_outputs/05-FullTPHV-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct m_t { bit<8> field_8_01; bit<8> field_8_02; @@ -546,7 +666,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_16bit_fields_1") table use_16bit_fields_1() { actions = { set_egress_spec; @@ -620,7 +739,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_16bit_fields_2") table use_16bit_fields_2() { actions = { set_egress_spec; @@ -662,7 +780,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_32bit_fields_1") table use_32bit_fields_1() { actions = { set_egress_spec; @@ -704,7 +821,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_32bit_fields_2") table use_32bit_fields_2() { actions = { set_egress_spec; @@ -745,7 +861,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_8bit_fields") table use_8bit_fields() { actions = { set_egress_spec; @@ -819,7 +934,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); use_8bit_fields.apply(); diff --git a/testdata/v1_samples_outputs/05-FullTPHV-last.p4 b/testdata/v1_samples_outputs/05-FullTPHV-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 91% rename from testdata/v1_samples_outputs/05-FullTPHV-last.p4 rename to testdata/v1_samples_outputs/05-FullTPHV-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 6fd92bd1ced..1bd604826c5 100644 --- a/testdata/v1_samples_outputs/05-FullTPHV-last.p4 +++ b/testdata/v1_samples_outputs/05-FullTPHV-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct m_t { bit<8> field_8_01; bit<8> field_8_02; @@ -546,7 +650,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_16bit_fields_1") table use_16bit_fields_1() { actions = { set_egress_spec; @@ -620,7 +723,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_16bit_fields_2") table use_16bit_fields_2() { actions = { set_egress_spec; @@ -662,7 +764,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_32bit_fields_1") table use_32bit_fields_1() { actions = { set_egress_spec; @@ -704,7 +805,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_32bit_fields_2") table use_32bit_fields_2() { actions = { set_egress_spec; @@ -745,7 +845,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_8bit_fields") table use_8bit_fields() { actions = { set_egress_spec; @@ -819,7 +918,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); use_8bit_fields.apply(); diff --git a/testdata/v1_samples_outputs/05-FullTPHV-midend.p4 b/testdata/v1_samples_outputs/05-FullTPHV-MidEnd_25_Evaluator.p4 similarity index 92% rename from testdata/v1_samples_outputs/05-FullTPHV-midend.p4 rename to testdata/v1_samples_outputs/05-FullTPHV-MidEnd_25_Evaluator.p4 index 2b4fc3cfab4..08638f47c5f 100644 --- a/testdata/v1_samples_outputs/05-FullTPHV-midend.p4 +++ b/testdata/v1_samples_outputs/05-FullTPHV-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct m_t { bit<8> field_8_01; bit<8> field_8_02; diff --git a/testdata/v1_samples_outputs/05-FullTPHV.p4 b/testdata/v1_samples_outputs/05-FullTPHV.p4 index 6fd92bd1ced..6c41354f8d1 100644 --- a/testdata/v1_samples_outputs/05-FullTPHV.p4 +++ b/testdata/v1_samples_outputs/05-FullTPHV.p4 @@ -546,7 +546,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_16bit_fields_1") table use_16bit_fields_1() { actions = { set_egress_spec; @@ -620,7 +619,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_16bit_fields_2") table use_16bit_fields_2() { actions = { set_egress_spec; @@ -662,7 +660,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_32bit_fields_1") table use_32bit_fields_1() { actions = { set_egress_spec; @@ -704,7 +701,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_32bit_fields_2") table use_32bit_fields_2() { actions = { set_egress_spec; @@ -745,7 +741,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_8bit_fields") table use_8bit_fields() { actions = { set_egress_spec; @@ -819,7 +814,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); use_8bit_fields.apply(); diff --git a/testdata/v1_samples_outputs/05-SimpleVlan1-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/05-SimpleVlan1-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..a1cbc3055d0 --- /dev/null +++ b/testdata/v1_samples_outputs/05-SimpleVlan1-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,217 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +header vlan_tag_t { + bit<3> pcp; + bit<1> cfi; + bit<12> vlan_id; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("vlan_tag") + vlan_tag_t vlan_tag; +} + +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) { + 16w0x8100 &&& 16w0xefff: parse_vlan_tag; + default: accept; + } + } + @name("parse_vlan_tag") state parse_vlan_tag { + packet.extract(hdr.vlan_tag); + transition accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t2") table t2() { + actions = { + nop; + NoAction; + } + key = { + hdr.ethernet.srcAddr: exact; + } + default_action = NoAction(); + } + apply { + t2.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t1") table t1() { + actions = { + nop; + NoAction; + } + key = { + hdr.ethernet.dstAddr: exact; + } + default_action = NoAction(); + } + apply { + t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.vlan_tag); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/05-SimpleVlan1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/05-SimpleVlan1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..35c5a0d472f --- /dev/null +++ b/testdata/v1_samples_outputs/05-SimpleVlan1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,201 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +header vlan_tag_t { + bit<3> pcp; + bit<1> cfi; + bit<12> vlan_id; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("vlan_tag") + vlan_tag_t vlan_tag; +} + +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) { + 16w0x8100 &&& 16w0xefff: parse_vlan_tag; + default: accept; + } + } + @name("parse_vlan_tag") state parse_vlan_tag { + packet.extract(hdr.vlan_tag); + transition accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t2") table t2() { + actions = { + nop; + NoAction; + } + key = { + hdr.ethernet.srcAddr: exact; + } + default_action = NoAction(); + } + apply { + t2.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t1") table t1() { + actions = { + nop; + NoAction; + } + key = { + hdr.ethernet.dstAddr: exact; + } + default_action = NoAction(); + } + apply { + t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.vlan_tag); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/05-SimpleVlan1-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/05-SimpleVlan1-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..988bb0614b1 --- /dev/null +++ b/testdata/v1_samples_outputs/05-SimpleVlan1-MidEnd_25_Evaluator.p4 @@ -0,0 +1,203 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +header vlan_tag_t { + bit<3> pcp; + bit<1> cfi; + bit<12> vlan_id; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("vlan_tag") + vlan_tag_t vlan_tag; +} + +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) { + 16w0x8100 &&& 16w0xefff: parse_vlan_tag; + default: accept; + } + } + @name("parse_vlan_tag") state parse_vlan_tag { + packet.extract(hdr.vlan_tag); + transition accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("nop") action nop_0() { + } + @name("t2") table t2_0() { + actions = { + nop_0; + NoAction_0; + } + key = { + hdr.ethernet.srcAddr: exact; + } + default_action = NoAction_0(); + } + apply { + t2_0.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_1() { + } + @name("nop") action nop_1() { + } + @name("t1") table t1_0() { + actions = { + nop_1; + NoAction_1; + } + key = { + hdr.ethernet.dstAddr: exact; + } + default_action = NoAction_1(); + } + apply { + t1_0.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.vlan_tag); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/05-SimpleVlan1-fe.p4 b/testdata/v1_samples_outputs/05-SimpleVlan1-fe.p4 deleted file mode 100644 index f7f0a479368..00000000000 --- a/testdata/v1_samples_outputs/05-SimpleVlan1-fe.p4 +++ /dev/null @@ -1,99 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -header vlan_tag_t { - bit<3> pcp; - bit<1> cfi; - bit<12> vlan_id; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; - @name("vlan_tag") - vlan_tag_t vlan_tag; -} - -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) { - 16w0x8100 &&& 16w0xefff: parse_vlan_tag; - default: accept; - } - } - @name("parse_vlan_tag") state parse_vlan_tag { - packet.extract(hdr.vlan_tag); - transition accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t2") table t2() { - actions = { - nop; - NoAction; - } - key = { - hdr.ethernet.srcAddr: exact; - } - default_action = NoAction(); - } - - apply { - t2.apply(); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t1") table t1() { - actions = { - nop; - NoAction; - } - key = { - hdr.ethernet.dstAddr: exact; - } - default_action = NoAction(); - } - - apply { - t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - packet.emit(hdr.vlan_tag); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/05-SimpleVlan1-last.p4 b/testdata/v1_samples_outputs/05-SimpleVlan1-last.p4 deleted file mode 100644 index f7f0a479368..00000000000 --- a/testdata/v1_samples_outputs/05-SimpleVlan1-last.p4 +++ /dev/null @@ -1,99 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -header vlan_tag_t { - bit<3> pcp; - bit<1> cfi; - bit<12> vlan_id; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; - @name("vlan_tag") - vlan_tag_t vlan_tag; -} - -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) { - 16w0x8100 &&& 16w0xefff: parse_vlan_tag; - default: accept; - } - } - @name("parse_vlan_tag") state parse_vlan_tag { - packet.extract(hdr.vlan_tag); - transition accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t2") table t2() { - actions = { - nop; - NoAction; - } - key = { - hdr.ethernet.srcAddr: exact; - } - default_action = NoAction(); - } - - apply { - t2.apply(); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t1") table t1() { - actions = { - nop; - NoAction; - } - key = { - hdr.ethernet.dstAddr: exact; - } - default_action = NoAction(); - } - - apply { - t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - packet.emit(hdr.vlan_tag); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/05-SimpleVlan1-midend.p4 b/testdata/v1_samples_outputs/05-SimpleVlan1-midend.p4 deleted file mode 100644 index 8384ce3f08c..00000000000 --- a/testdata/v1_samples_outputs/05-SimpleVlan1-midend.p4 +++ /dev/null @@ -1,101 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -header vlan_tag_t { - bit<3> pcp; - bit<1> cfi; - bit<12> vlan_id; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; - @name("vlan_tag") - vlan_tag_t vlan_tag; -} - -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) { - 16w0x8100 &&& 16w0xefff: parse_vlan_tag; - default: accept; - } - } - @name("parse_vlan_tag") state parse_vlan_tag { - packet.extract(hdr.vlan_tag); - transition accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("nop") action nop_0() { - } - @name("t2") table t2_0() { - actions = { - nop_0; - NoAction_0; - } - key = { - hdr.ethernet.srcAddr: exact; - } - default_action = NoAction_0(); - } - apply { - t2_0.apply(); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_1() { - } - @name("nop") action nop_1() { - } - @name("t1") table t1_0() { - actions = { - nop_1; - NoAction_1; - } - key = { - hdr.ethernet.dstAddr: exact; - } - default_action = NoAction_1(); - } - apply { - t1_0.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - packet.emit(hdr.vlan_tag); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/05-SimpleVlan1.p4 b/testdata/v1_samples_outputs/05-SimpleVlan1.p4 index f7f0a479368..cacc2a4c00c 100644 --- a/testdata/v1_samples_outputs/05-SimpleVlan1.p4 +++ b/testdata/v1_samples_outputs/05-SimpleVlan1.p4 @@ -54,7 +54,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { t2.apply(); } @@ -73,7 +72,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); } diff --git a/testdata/v1_samples_outputs/06-FullTPHV1-fe.p4 b/testdata/v1_samples_outputs/06-FullTPHV1-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 89% rename from testdata/v1_samples_outputs/06-FullTPHV1-fe.p4 rename to testdata/v1_samples_outputs/06-FullTPHV1-FrontEnd_11_SimplifyControlFlowE.p4 index c537ff8bff3..2adf18c36c2 100644 --- a/testdata/v1_samples_outputs/06-FullTPHV1-fe.p4 +++ b/testdata/v1_samples_outputs/06-FullTPHV1-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct m_t { bit<8> field_8_01; bit<8> field_8_02; @@ -529,7 +649,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_16bit_fields_1") table use_16bit_fields_1() { actions = { set_egress_spec; @@ -603,7 +722,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_16bit_fields_2") table use_16bit_fields_2() { actions = { set_egress_spec; @@ -645,7 +763,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_32bit_fields_1") table use_32bit_fields_1() { actions = { set_egress_spec; @@ -687,7 +804,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_32bit_fields_2") table use_32bit_fields_2() { actions = { set_egress_spec; @@ -728,7 +844,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_8bit_fields") table use_8bit_fields() { actions = { set_egress_spec; @@ -770,7 +885,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); use_8bit_fields.apply(); diff --git a/testdata/v1_samples_outputs/06-FullTPHV1-last.p4 b/testdata/v1_samples_outputs/06-FullTPHV1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 91% rename from testdata/v1_samples_outputs/06-FullTPHV1-last.p4 rename to testdata/v1_samples_outputs/06-FullTPHV1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index c537ff8bff3..d6606d16d8e 100644 --- a/testdata/v1_samples_outputs/06-FullTPHV1-last.p4 +++ b/testdata/v1_samples_outputs/06-FullTPHV1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct m_t { bit<8> field_8_01; bit<8> field_8_02; @@ -529,7 +633,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_16bit_fields_1") table use_16bit_fields_1() { actions = { set_egress_spec; @@ -603,7 +706,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_16bit_fields_2") table use_16bit_fields_2() { actions = { set_egress_spec; @@ -645,7 +747,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_32bit_fields_1") table use_32bit_fields_1() { actions = { set_egress_spec; @@ -687,7 +788,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_32bit_fields_2") table use_32bit_fields_2() { actions = { set_egress_spec; @@ -728,7 +828,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_8bit_fields") table use_8bit_fields() { actions = { set_egress_spec; @@ -770,7 +869,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); use_8bit_fields.apply(); diff --git a/testdata/v1_samples_outputs/06-FullTPHV1-midend.p4 b/testdata/v1_samples_outputs/06-FullTPHV1-MidEnd_25_Evaluator.p4 similarity index 91% rename from testdata/v1_samples_outputs/06-FullTPHV1-midend.p4 rename to testdata/v1_samples_outputs/06-FullTPHV1-MidEnd_25_Evaluator.p4 index 9b9e1bad60c..463807abade 100644 --- a/testdata/v1_samples_outputs/06-FullTPHV1-midend.p4 +++ b/testdata/v1_samples_outputs/06-FullTPHV1-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct m_t { bit<8> field_8_01; bit<8> field_8_02; diff --git a/testdata/v1_samples_outputs/06-FullTPHV1.p4 b/testdata/v1_samples_outputs/06-FullTPHV1.p4 index c537ff8bff3..3a4b47f5792 100644 --- a/testdata/v1_samples_outputs/06-FullTPHV1.p4 +++ b/testdata/v1_samples_outputs/06-FullTPHV1.p4 @@ -529,7 +529,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_16bit_fields_1") table use_16bit_fields_1() { actions = { set_egress_spec; @@ -603,7 +602,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_16bit_fields_2") table use_16bit_fields_2() { actions = { set_egress_spec; @@ -645,7 +643,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_32bit_fields_1") table use_32bit_fields_1() { actions = { set_egress_spec; @@ -687,7 +684,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_32bit_fields_2") table use_32bit_fields_2() { actions = { set_egress_spec; @@ -728,7 +724,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_8bit_fields") table use_8bit_fields() { actions = { set_egress_spec; @@ -770,7 +765,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); use_8bit_fields.apply(); diff --git a/testdata/v1_samples_outputs/06-SimpleVlanStack-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/06-SimpleVlanStack-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..014a74e9715 --- /dev/null +++ b/testdata/v1_samples_outputs/06-SimpleVlanStack-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,220 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +header vlan_tag_t { + bit<3> pcp; + bit<1> cfi; + bit<12> vlan_id; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("vlan_tag") + vlan_tag_t[5] vlan_tag; +} + +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) { + 16w0x8100 &&& 16w0xefff: parse_vlan_tag; + default: accept; + } + } + @name("parse_vlan_tag") state parse_vlan_tag { + packet.extract(hdr.vlan_tag.next); + transition select(hdr.vlan_tag.last.ethertype) { + 16w0x8100 &&& 16w0xefff: parse_vlan_tag; + default: accept; + } + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t2") table t2() { + actions = { + nop; + NoAction; + } + key = { + hdr.ethernet.srcAddr: exact; + } + default_action = NoAction(); + } + apply { + t2.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t1") table t1() { + actions = { + nop; + NoAction; + } + key = { + hdr.ethernet.dstAddr: exact; + } + default_action = NoAction(); + } + apply { + t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.vlan_tag); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/06-SimpleVlanStack-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/06-SimpleVlanStack-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..b05fab58bbb --- /dev/null +++ b/testdata/v1_samples_outputs/06-SimpleVlanStack-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,204 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +header vlan_tag_t { + bit<3> pcp; + bit<1> cfi; + bit<12> vlan_id; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("vlan_tag") + vlan_tag_t[5] vlan_tag; +} + +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) { + 16w0x8100 &&& 16w0xefff: parse_vlan_tag; + default: accept; + } + } + @name("parse_vlan_tag") state parse_vlan_tag { + packet.extract(hdr.vlan_tag.next); + transition select(hdr.vlan_tag.last.ethertype) { + 16w0x8100 &&& 16w0xefff: parse_vlan_tag; + default: accept; + } + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t2") table t2() { + actions = { + nop; + NoAction; + } + key = { + hdr.ethernet.srcAddr: exact; + } + default_action = NoAction(); + } + apply { + t2.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t1") table t1() { + actions = { + nop; + NoAction; + } + key = { + hdr.ethernet.dstAddr: exact; + } + default_action = NoAction(); + } + apply { + t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.vlan_tag); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/06-SimpleVlanStack-midend.p4 b/testdata/v1_samples_outputs/06-SimpleVlanStack-MidEnd_25_Evaluator.p4 similarity index 51% rename from testdata/v1_samples_outputs/06-SimpleVlanStack-midend.p4 rename to testdata/v1_samples_outputs/06-SimpleVlanStack-MidEnd_25_Evaluator.p4 index 4dd3160aae4..884269bf05b 100644 --- a/testdata/v1_samples_outputs/06-SimpleVlanStack-midend.p4 +++ b/testdata/v1_samples_outputs/06-SimpleVlanStack-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; diff --git a/testdata/v1_samples_outputs/06-SimpleVlanStack-fe.p4 b/testdata/v1_samples_outputs/06-SimpleVlanStack-fe.p4 deleted file mode 100644 index 9390934dbb3..00000000000 --- a/testdata/v1_samples_outputs/06-SimpleVlanStack-fe.p4 +++ /dev/null @@ -1,102 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -header vlan_tag_t { - bit<3> pcp; - bit<1> cfi; - bit<12> vlan_id; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; - @name("vlan_tag") - vlan_tag_t[5] vlan_tag; -} - -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) { - 16w0x8100 &&& 16w0xefff: parse_vlan_tag; - default: accept; - } - } - @name("parse_vlan_tag") state parse_vlan_tag { - packet.extract(hdr.vlan_tag.next); - transition select(hdr.vlan_tag.last.ethertype) { - 16w0x8100 &&& 16w0xefff: parse_vlan_tag; - default: accept; - } - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t2") table t2() { - actions = { - nop; - NoAction; - } - key = { - hdr.ethernet.srcAddr: exact; - } - default_action = NoAction(); - } - - apply { - t2.apply(); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t1") table t1() { - actions = { - nop; - NoAction; - } - key = { - hdr.ethernet.dstAddr: exact; - } - default_action = NoAction(); - } - - apply { - t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - packet.emit(hdr.vlan_tag); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/06-SimpleVlanStack-last.p4 b/testdata/v1_samples_outputs/06-SimpleVlanStack-last.p4 deleted file mode 100644 index 9390934dbb3..00000000000 --- a/testdata/v1_samples_outputs/06-SimpleVlanStack-last.p4 +++ /dev/null @@ -1,102 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -header vlan_tag_t { - bit<3> pcp; - bit<1> cfi; - bit<12> vlan_id; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; - @name("vlan_tag") - vlan_tag_t[5] vlan_tag; -} - -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) { - 16w0x8100 &&& 16w0xefff: parse_vlan_tag; - default: accept; - } - } - @name("parse_vlan_tag") state parse_vlan_tag { - packet.extract(hdr.vlan_tag.next); - transition select(hdr.vlan_tag.last.ethertype) { - 16w0x8100 &&& 16w0xefff: parse_vlan_tag; - default: accept; - } - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t2") table t2() { - actions = { - nop; - NoAction; - } - key = { - hdr.ethernet.srcAddr: exact; - } - default_action = NoAction(); - } - - apply { - t2.apply(); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t1") table t1() { - actions = { - nop; - NoAction; - } - key = { - hdr.ethernet.dstAddr: exact; - } - default_action = NoAction(); - } - - apply { - t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - packet.emit(hdr.vlan_tag); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/06-SimpleVlanStack.p4 b/testdata/v1_samples_outputs/06-SimpleVlanStack.p4 index 9390934dbb3..e18b1649a1f 100644 --- a/testdata/v1_samples_outputs/06-SimpleVlanStack.p4 +++ b/testdata/v1_samples_outputs/06-SimpleVlanStack.p4 @@ -57,7 +57,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { t2.apply(); } @@ -76,7 +75,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); } diff --git a/testdata/v1_samples_outputs/07-FullTPHV2-fe.p4 b/testdata/v1_samples_outputs/07-FullTPHV2-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 89% rename from testdata/v1_samples_outputs/07-FullTPHV2-fe.p4 rename to testdata/v1_samples_outputs/07-FullTPHV2-FrontEnd_11_SimplifyControlFlowE.p4 index 1ae9c9aad30..8b4124b4167 100644 --- a/testdata/v1_samples_outputs/07-FullTPHV2-fe.p4 +++ b/testdata/v1_samples_outputs/07-FullTPHV2-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct m_t { bit<8> field_8_01; bit<8> field_8_02; @@ -562,7 +682,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_16bit_fields_1") table use_16bit_fields_1() { actions = { set_egress_spec; @@ -573,7 +692,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_16bit_fields_2") table use_16bit_fields_2() { actions = { set_egress_spec; @@ -615,7 +733,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_32bit_fields_1") table use_32bit_fields_1() { actions = { set_egress_spec; @@ -657,7 +774,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_32bit_fields_2") table use_32bit_fields_2() { actions = { set_egress_spec; @@ -699,7 +815,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_8bit_fields") table use_8bit_fields() { actions = { set_egress_spec; @@ -773,7 +888,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); use_8bit_fields.apply(); diff --git a/testdata/v1_samples_outputs/07-FullTPHV2-last.p4 b/testdata/v1_samples_outputs/07-FullTPHV2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 91% rename from testdata/v1_samples_outputs/07-FullTPHV2-last.p4 rename to testdata/v1_samples_outputs/07-FullTPHV2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 1ae9c9aad30..b4d52c36db8 100644 --- a/testdata/v1_samples_outputs/07-FullTPHV2-last.p4 +++ b/testdata/v1_samples_outputs/07-FullTPHV2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct m_t { bit<8> field_8_01; bit<8> field_8_02; @@ -562,7 +666,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_16bit_fields_1") table use_16bit_fields_1() { actions = { set_egress_spec; @@ -573,7 +676,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_16bit_fields_2") table use_16bit_fields_2() { actions = { set_egress_spec; @@ -615,7 +717,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_32bit_fields_1") table use_32bit_fields_1() { actions = { set_egress_spec; @@ -657,7 +758,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_32bit_fields_2") table use_32bit_fields_2() { actions = { set_egress_spec; @@ -699,7 +799,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_8bit_fields") table use_8bit_fields() { actions = { set_egress_spec; @@ -773,7 +872,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); use_8bit_fields.apply(); diff --git a/testdata/v1_samples_outputs/07-FullTPHV2-midend.p4 b/testdata/v1_samples_outputs/07-FullTPHV2-MidEnd_25_Evaluator.p4 similarity index 91% rename from testdata/v1_samples_outputs/07-FullTPHV2-midend.p4 rename to testdata/v1_samples_outputs/07-FullTPHV2-MidEnd_25_Evaluator.p4 index 510d5574fa6..7e6eed60bd2 100644 --- a/testdata/v1_samples_outputs/07-FullTPHV2-midend.p4 +++ b/testdata/v1_samples_outputs/07-FullTPHV2-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct m_t { bit<8> field_8_01; bit<8> field_8_02; diff --git a/testdata/v1_samples_outputs/07-FullTPHV2.p4 b/testdata/v1_samples_outputs/07-FullTPHV2.p4 index 1ae9c9aad30..ddf80b050be 100644 --- a/testdata/v1_samples_outputs/07-FullTPHV2.p4 +++ b/testdata/v1_samples_outputs/07-FullTPHV2.p4 @@ -562,7 +562,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_16bit_fields_1") table use_16bit_fields_1() { actions = { set_egress_spec; @@ -573,7 +572,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_16bit_fields_2") table use_16bit_fields_2() { actions = { set_egress_spec; @@ -615,7 +613,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_32bit_fields_1") table use_32bit_fields_1() { actions = { set_egress_spec; @@ -657,7 +654,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_32bit_fields_2") table use_32bit_fields_2() { actions = { set_egress_spec; @@ -699,7 +695,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_8bit_fields") table use_8bit_fields() { actions = { set_egress_spec; @@ -773,7 +768,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); use_8bit_fields.apply(); diff --git a/testdata/v1_samples_outputs/07-MultiProtocol-last.p4 b/testdata/v1_samples_outputs/07-MultiProtocol-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 68% rename from testdata/v1_samples_outputs/07-MultiProtocol-last.p4 rename to testdata/v1_samples_outputs/07-MultiProtocol-FrontEnd_11_SimplifyControlFlowE.p4 index 1ec3565181e..e5975161d7e 100644 --- a/testdata/v1_samples_outputs/07-MultiProtocol-last.p4 +++ b/testdata/v1_samples_outputs/07-MultiProtocol-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<1> drop; bit<8> egress_port; @@ -184,7 +304,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("ipv4_match") table ipv4_match() { actions = { nop; @@ -196,7 +315,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("ipv6_match") table ipv6_match() { actions = { nop; @@ -208,7 +326,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("l2_match") table l2_match() { actions = { nop; @@ -220,7 +337,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { switch (ethertype_match.apply().action_run) { default: { diff --git a/testdata/v1_samples_outputs/07-MultiProtocol-fe.p4 b/testdata/v1_samples_outputs/07-MultiProtocol-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 73% rename from testdata/v1_samples_outputs/07-MultiProtocol-fe.p4 rename to testdata/v1_samples_outputs/07-MultiProtocol-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 1ec3565181e..321e239a263 100644 --- a/testdata/v1_samples_outputs/07-MultiProtocol-fe.p4 +++ b/testdata/v1_samples_outputs/07-MultiProtocol-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<1> drop; bit<8> egress_port; @@ -184,7 +288,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("ipv4_match") table ipv4_match() { actions = { nop; @@ -196,7 +299,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("ipv6_match") table ipv6_match() { actions = { nop; @@ -208,7 +310,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("l2_match") table l2_match() { actions = { nop; @@ -220,7 +321,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { switch (ethertype_match.apply().action_run) { default: { diff --git a/testdata/v1_samples_outputs/07-MultiProtocol-midend.p4 b/testdata/v1_samples_outputs/07-MultiProtocol-MidEnd_25_Evaluator.p4 similarity index 75% rename from testdata/v1_samples_outputs/07-MultiProtocol-midend.p4 rename to testdata/v1_samples_outputs/07-MultiProtocol-MidEnd_25_Evaluator.p4 index bb14b2194ec..5150ba413be 100644 --- a/testdata/v1_samples_outputs/07-MultiProtocol-midend.p4 +++ b/testdata/v1_samples_outputs/07-MultiProtocol-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<1> drop; bit<8> egress_port; diff --git a/testdata/v1_samples_outputs/07-MultiProtocol.p4 b/testdata/v1_samples_outputs/07-MultiProtocol.p4 index 1ec3565181e..f5810123a47 100644 --- a/testdata/v1_samples_outputs/07-MultiProtocol.p4 +++ b/testdata/v1_samples_outputs/07-MultiProtocol.p4 @@ -184,7 +184,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("ipv4_match") table ipv4_match() { actions = { nop; @@ -196,7 +195,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("ipv6_match") table ipv6_match() { actions = { nop; @@ -208,7 +206,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("l2_match") table l2_match() { actions = { nop; @@ -220,7 +217,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { switch (ethertype_match.apply().action_run) { default: { diff --git a/testdata/v1_samples_outputs/07-SimpleVlanStackIP-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/07-SimpleVlanStackIP-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..125516c22a6 --- /dev/null +++ b/testdata/v1_samples_outputs/07-SimpleVlanStackIP-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,244 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +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 vlan_tag_t { + bit<3> pcp; + bit<1> cfi; + bit<12> vlan_id; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("ipv4") + ipv4_t ipv4; + @name("vlan_tag") + vlan_tag_t[2] vlan_tag; +} + +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) { + 16w0x8100 &&& 16w0xefff: parse_vlan_tag; + 16w0x800: parse_ipv4; + default: accept; + } + } + @name("parse_ipv4") state parse_ipv4 { + packet.extract(hdr.ipv4); + transition accept; + } + @name("parse_vlan_tag") state parse_vlan_tag { + packet.extract(hdr.vlan_tag.next); + transition select(hdr.vlan_tag.last.ethertype) { + 16w0x8100 &&& 16w0xefff: parse_vlan_tag; + 16w0x800: parse_ipv4; + default: accept; + } + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t2") table t2() { + actions = { + nop; + NoAction; + } + key = { + hdr.ethernet.srcAddr: exact; + } + default_action = NoAction(); + } + apply { + t2.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t1") table t1() { + actions = { + nop; + NoAction; + } + key = { + hdr.ethernet.dstAddr: exact; + } + default_action = NoAction(); + } + apply { + t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.vlan_tag); + packet.emit(hdr.ipv4); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/07-SimpleVlanStackIP-fe.p4 b/testdata/v1_samples_outputs/07-SimpleVlanStackIP-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 55% rename from testdata/v1_samples_outputs/07-SimpleVlanStackIP-fe.p4 rename to testdata/v1_samples_outputs/07-SimpleVlanStackIP-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 960d6362f2d..51b8a10c326 100644 --- a/testdata/v1_samples_outputs/07-SimpleVlanStackIP-fe.p4 +++ b/testdata/v1_samples_outputs/07-SimpleVlanStackIP-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; @@ -80,7 +184,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { t2.apply(); } @@ -99,7 +202,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); } diff --git a/testdata/v1_samples_outputs/07-SimpleVlanStackIP-midend.p4 b/testdata/v1_samples_outputs/07-SimpleVlanStackIP-MidEnd_25_Evaluator.p4 similarity index 56% rename from testdata/v1_samples_outputs/07-SimpleVlanStackIP-midend.p4 rename to testdata/v1_samples_outputs/07-SimpleVlanStackIP-MidEnd_25_Evaluator.p4 index f667c6440e4..d7ccc72c505 100644 --- a/testdata/v1_samples_outputs/07-SimpleVlanStackIP-midend.p4 +++ b/testdata/v1_samples_outputs/07-SimpleVlanStackIP-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; diff --git a/testdata/v1_samples_outputs/07-SimpleVlanStackIP-last.p4 b/testdata/v1_samples_outputs/07-SimpleVlanStackIP-last.p4 deleted file mode 100644 index 960d6362f2d..00000000000 --- a/testdata/v1_samples_outputs/07-SimpleVlanStackIP-last.p4 +++ /dev/null @@ -1,126 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -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 vlan_tag_t { - bit<3> pcp; - bit<1> cfi; - bit<12> vlan_id; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; - @name("ipv4") - ipv4_t ipv4; - @name("vlan_tag") - vlan_tag_t[2] vlan_tag; -} - -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) { - 16w0x8100 &&& 16w0xefff: parse_vlan_tag; - 16w0x800: parse_ipv4; - default: accept; - } - } - @name("parse_ipv4") state parse_ipv4 { - packet.extract(hdr.ipv4); - transition accept; - } - @name("parse_vlan_tag") state parse_vlan_tag { - packet.extract(hdr.vlan_tag.next); - transition select(hdr.vlan_tag.last.ethertype) { - 16w0x8100 &&& 16w0xefff: parse_vlan_tag; - 16w0x800: parse_ipv4; - default: accept; - } - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t2") table t2() { - actions = { - nop; - NoAction; - } - key = { - hdr.ethernet.srcAddr: exact; - } - default_action = NoAction(); - } - - apply { - t2.apply(); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t1") table t1() { - actions = { - nop; - NoAction; - } - key = { - hdr.ethernet.dstAddr: exact; - } - default_action = NoAction(); - } - - apply { - t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - packet.emit(hdr.vlan_tag); - packet.emit(hdr.ipv4); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/07-SimpleVlanStackIP.p4 b/testdata/v1_samples_outputs/07-SimpleVlanStackIP.p4 index 960d6362f2d..f703522f463 100644 --- a/testdata/v1_samples_outputs/07-SimpleVlanStackIP.p4 +++ b/testdata/v1_samples_outputs/07-SimpleVlanStackIP.p4 @@ -80,7 +80,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { t2.apply(); } @@ -99,7 +98,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); } diff --git a/testdata/v1_samples_outputs/08-FullTPHV3-fe.p4 b/testdata/v1_samples_outputs/08-FullTPHV3-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 91% rename from testdata/v1_samples_outputs/08-FullTPHV3-fe.p4 rename to testdata/v1_samples_outputs/08-FullTPHV3-FrontEnd_11_SimplifyControlFlowE.p4 index 90d241f97ca..bff9fcc6097 100644 --- a/testdata/v1_samples_outputs/08-FullTPHV3-fe.p4 +++ b/testdata/v1_samples_outputs/08-FullTPHV3-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct m_t { bit<8> field_8_01; bit<8> field_8_02; @@ -732,7 +852,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_16bit_fields_1") table use_16bit_fields_1() { actions = { set_egress_spec; @@ -806,7 +925,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_16bit_fields_2") table use_16bit_fields_2() { actions = { set_egress_spec; @@ -848,7 +966,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_32bit_fields_1") table use_32bit_fields_1() { actions = { set_egress_spec; @@ -890,7 +1007,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_32bit_fields_2") table use_32bit_fields_2() { actions = { set_egress_spec; @@ -931,7 +1047,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_8bit_fields") table use_8bit_fields() { actions = { set_egress_spec; @@ -1005,7 +1120,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); use_8bit_fields.apply(); diff --git a/testdata/v1_samples_outputs/08-FullTPHV3-last.p4 b/testdata/v1_samples_outputs/08-FullTPHV3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 93% rename from testdata/v1_samples_outputs/08-FullTPHV3-last.p4 rename to testdata/v1_samples_outputs/08-FullTPHV3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 90d241f97ca..7ea89d7c7e2 100644 --- a/testdata/v1_samples_outputs/08-FullTPHV3-last.p4 +++ b/testdata/v1_samples_outputs/08-FullTPHV3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct m_t { bit<8> field_8_01; bit<8> field_8_02; @@ -732,7 +836,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_16bit_fields_1") table use_16bit_fields_1() { actions = { set_egress_spec; @@ -806,7 +909,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_16bit_fields_2") table use_16bit_fields_2() { actions = { set_egress_spec; @@ -848,7 +950,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_32bit_fields_1") table use_32bit_fields_1() { actions = { set_egress_spec; @@ -890,7 +991,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_32bit_fields_2") table use_32bit_fields_2() { actions = { set_egress_spec; @@ -931,7 +1031,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_8bit_fields") table use_8bit_fields() { actions = { set_egress_spec; @@ -1005,7 +1104,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); use_8bit_fields.apply(); diff --git a/testdata/v1_samples_outputs/08-FullTPHV3-midend.p4 b/testdata/v1_samples_outputs/08-FullTPHV3-MidEnd_25_Evaluator.p4 similarity index 93% rename from testdata/v1_samples_outputs/08-FullTPHV3-midend.p4 rename to testdata/v1_samples_outputs/08-FullTPHV3-MidEnd_25_Evaluator.p4 index 26cfca65889..4761352d117 100644 --- a/testdata/v1_samples_outputs/08-FullTPHV3-midend.p4 +++ b/testdata/v1_samples_outputs/08-FullTPHV3-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct m_t { bit<8> field_8_01; bit<8> field_8_02; diff --git a/testdata/v1_samples_outputs/08-FullTPHV3.p4 b/testdata/v1_samples_outputs/08-FullTPHV3.p4 index 90d241f97ca..dd07761beae 100644 --- a/testdata/v1_samples_outputs/08-FullTPHV3.p4 +++ b/testdata/v1_samples_outputs/08-FullTPHV3.p4 @@ -732,7 +732,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_16bit_fields_1") table use_16bit_fields_1() { actions = { set_egress_spec; @@ -806,7 +805,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_16bit_fields_2") table use_16bit_fields_2() { actions = { set_egress_spec; @@ -848,7 +846,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_32bit_fields_1") table use_32bit_fields_1() { actions = { set_egress_spec; @@ -890,7 +887,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_32bit_fields_2") table use_32bit_fields_2() { actions = { set_egress_spec; @@ -931,7 +927,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("use_8bit_fields") table use_8bit_fields() { actions = { set_egress_spec; @@ -1005,7 +1000,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); use_8bit_fields.apply(); diff --git a/testdata/v1_samples_outputs/08-MultiProtocolIfElse-last.p4 b/testdata/v1_samples_outputs/08-MultiProtocolIfElse-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 64% rename from testdata/v1_samples_outputs/08-MultiProtocolIfElse-last.p4 rename to testdata/v1_samples_outputs/08-MultiProtocolIfElse-FrontEnd_11_SimplifyControlFlowE.p4 index 4d607642919..1d4db6897b8 100644 --- a/testdata/v1_samples_outputs/08-MultiProtocolIfElse-last.p4 +++ b/testdata/v1_samples_outputs/08-MultiProtocolIfElse-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<1> drop; bit<8> egress_port; @@ -166,7 +286,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("ipv6_match") table ipv6_match() { actions = { nop; @@ -178,7 +297,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("l2_match") table l2_match() { actions = { nop; @@ -190,7 +308,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (hdr.ethernet.etherType == 16w0x800) ipv4_match.apply(); diff --git a/testdata/v1_samples_outputs/08-MultiProtocolIfElse-fe.p4 b/testdata/v1_samples_outputs/08-MultiProtocolIfElse-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 70% rename from testdata/v1_samples_outputs/08-MultiProtocolIfElse-fe.p4 rename to testdata/v1_samples_outputs/08-MultiProtocolIfElse-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 4d607642919..ed5c62b6433 100644 --- a/testdata/v1_samples_outputs/08-MultiProtocolIfElse-fe.p4 +++ b/testdata/v1_samples_outputs/08-MultiProtocolIfElse-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<1> drop; bit<8> egress_port; @@ -166,7 +270,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("ipv6_match") table ipv6_match() { actions = { nop; @@ -178,7 +281,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("l2_match") table l2_match() { actions = { nop; @@ -190,7 +292,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (hdr.ethernet.etherType == 16w0x800) ipv4_match.apply(); diff --git a/testdata/v1_samples_outputs/08-MultiProtocolIfElse-midend.p4 b/testdata/v1_samples_outputs/08-MultiProtocolIfElse-MidEnd_25_Evaluator.p4 similarity index 71% rename from testdata/v1_samples_outputs/08-MultiProtocolIfElse-midend.p4 rename to testdata/v1_samples_outputs/08-MultiProtocolIfElse-MidEnd_25_Evaluator.p4 index d4723836d46..080926ab6b1 100644 --- a/testdata/v1_samples_outputs/08-MultiProtocolIfElse-midend.p4 +++ b/testdata/v1_samples_outputs/08-MultiProtocolIfElse-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<1> drop; bit<8> egress_port; diff --git a/testdata/v1_samples_outputs/08-MultiProtocolIfElse.p4 b/testdata/v1_samples_outputs/08-MultiProtocolIfElse.p4 index 335a3d7aa12..b77aa08f855 100644 --- a/testdata/v1_samples_outputs/08-MultiProtocolIfElse.p4 +++ b/testdata/v1_samples_outputs/08-MultiProtocolIfElse.p4 @@ -166,7 +166,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("ipv6_match") table ipv6_match() { actions = { nop; @@ -178,7 +177,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("l2_match") table l2_match() { actions = { nop; @@ -190,7 +188,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (hdr.ethernet.etherType == 16w0x800) { ipv4_match.apply(); diff --git a/testdata/v1_samples_outputs/08-SimpleVlanStackIPSplitFlags-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/08-SimpleVlanStackIPSplitFlags-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..1e1af6298f9 --- /dev/null +++ b/testdata/v1_samples_outputs/08-SimpleVlanStackIPSplitFlags-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,246 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +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<1> reserved_0; + bit<1> df; + bit<1> mf; + bit<13> fragOffset; + bit<8> ttl; + bit<8> protocol; + bit<16> hdrChecksum; + bit<32> srcAddr; + bit<32> dstAddr; +} + +header vlan_tag_t { + bit<3> pcp; + bit<1> cfi; + bit<12> vlan_id; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("ipv4") + ipv4_t ipv4; + @name("vlan_tag") + vlan_tag_t[2] vlan_tag; +} + +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) { + 16w0x8100 &&& 16w0xefff: parse_vlan_tag; + 16w0x800: parse_ipv4; + default: accept; + } + } + @name("parse_ipv4") state parse_ipv4 { + packet.extract(hdr.ipv4); + transition accept; + } + @name("parse_vlan_tag") state parse_vlan_tag { + packet.extract(hdr.vlan_tag.next); + transition select(hdr.vlan_tag.last.ethertype) { + 16w0x8100 &&& 16w0xefff: parse_vlan_tag; + 16w0x800: parse_ipv4; + default: accept; + } + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t2") table t2() { + actions = { + nop; + NoAction; + } + key = { + hdr.ethernet.srcAddr: exact; + } + default_action = NoAction(); + } + apply { + t2.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t1") table t1() { + actions = { + nop; + NoAction; + } + key = { + hdr.ethernet.dstAddr: exact; + } + default_action = NoAction(); + } + apply { + t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.vlan_tag); + packet.emit(hdr.ipv4); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/08-SimpleVlanStackIPSplitFlags-last.p4 b/testdata/v1_samples_outputs/08-SimpleVlanStackIPSplitFlags-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 55% rename from testdata/v1_samples_outputs/08-SimpleVlanStackIPSplitFlags-last.p4 rename to testdata/v1_samples_outputs/08-SimpleVlanStackIPSplitFlags-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index a75471f3596..7d0078b562b 100644 --- a/testdata/v1_samples_outputs/08-SimpleVlanStackIPSplitFlags-last.p4 +++ b/testdata/v1_samples_outputs/08-SimpleVlanStackIPSplitFlags-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; @@ -82,7 +186,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { t2.apply(); } @@ -101,7 +204,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); } diff --git a/testdata/v1_samples_outputs/08-SimpleVlanStackIPSplitFlags-midend.p4 b/testdata/v1_samples_outputs/08-SimpleVlanStackIPSplitFlags-MidEnd_25_Evaluator.p4 similarity index 56% rename from testdata/v1_samples_outputs/08-SimpleVlanStackIPSplitFlags-midend.p4 rename to testdata/v1_samples_outputs/08-SimpleVlanStackIPSplitFlags-MidEnd_25_Evaluator.p4 index 98c8ba764fa..341ca55c0c0 100644 --- a/testdata/v1_samples_outputs/08-SimpleVlanStackIPSplitFlags-midend.p4 +++ b/testdata/v1_samples_outputs/08-SimpleVlanStackIPSplitFlags-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; diff --git a/testdata/v1_samples_outputs/08-SimpleVlanStackIPSplitFlags-fe.p4 b/testdata/v1_samples_outputs/08-SimpleVlanStackIPSplitFlags-fe.p4 deleted file mode 100644 index a75471f3596..00000000000 --- a/testdata/v1_samples_outputs/08-SimpleVlanStackIPSplitFlags-fe.p4 +++ /dev/null @@ -1,128 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -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<1> reserved_0; - bit<1> df; - bit<1> mf; - bit<13> fragOffset; - bit<8> ttl; - bit<8> protocol; - bit<16> hdrChecksum; - bit<32> srcAddr; - bit<32> dstAddr; -} - -header vlan_tag_t { - bit<3> pcp; - bit<1> cfi; - bit<12> vlan_id; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; - @name("ipv4") - ipv4_t ipv4; - @name("vlan_tag") - vlan_tag_t[2] vlan_tag; -} - -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) { - 16w0x8100 &&& 16w0xefff: parse_vlan_tag; - 16w0x800: parse_ipv4; - default: accept; - } - } - @name("parse_ipv4") state parse_ipv4 { - packet.extract(hdr.ipv4); - transition accept; - } - @name("parse_vlan_tag") state parse_vlan_tag { - packet.extract(hdr.vlan_tag.next); - transition select(hdr.vlan_tag.last.ethertype) { - 16w0x8100 &&& 16w0xefff: parse_vlan_tag; - 16w0x800: parse_ipv4; - default: accept; - } - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t2") table t2() { - actions = { - nop; - NoAction; - } - key = { - hdr.ethernet.srcAddr: exact; - } - default_action = NoAction(); - } - - apply { - t2.apply(); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t1") table t1() { - actions = { - nop; - NoAction; - } - key = { - hdr.ethernet.dstAddr: exact; - } - default_action = NoAction(); - } - - apply { - t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - packet.emit(hdr.vlan_tag); - packet.emit(hdr.ipv4); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/08-SimpleVlanStackIPSplitFlags.p4 b/testdata/v1_samples_outputs/08-SimpleVlanStackIPSplitFlags.p4 index a75471f3596..5477ea8bba9 100644 --- a/testdata/v1_samples_outputs/08-SimpleVlanStackIPSplitFlags.p4 +++ b/testdata/v1_samples_outputs/08-SimpleVlanStackIPSplitFlags.p4 @@ -82,7 +82,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { t2.apply(); } @@ -101,7 +100,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); } diff --git a/testdata/v1_samples_outputs/10-SelectPriorities-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/10-SelectPriorities-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..998fe5f434e --- /dev/null +++ b/testdata/v1_samples_outputs/10-SelectPriorities-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,227 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +header other_tag_t { + bit<16> field1; + bit<16> ethertype; +} + +header vlan_tag_t { + bit<3> pcp; + bit<1> cfi; + bit<12> vlan_id; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("other_tag") + other_tag_t other_tag; + @name("vlan_tag") + vlan_tag_t vlan_tag; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_other_tag") state parse_other_tag { + packet.extract(hdr.other_tag); + transition accept; + } + @name("parse_vlan_tag") state parse_vlan_tag { + packet.extract(hdr.vlan_tag); + transition accept; + } + @name("start") state start { + packet.extract(hdr.ethernet); + transition select(hdr.ethernet.ethertype) { + 16w0x8100 &&& 16w0xff00: parse_vlan_tag; + 16w0x8153: parse_other_tag; + default: accept; + } + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t2") table t2() { + actions = { + nop; + NoAction; + } + key = { + hdr.ethernet.srcAddr: exact; + } + default_action = NoAction(); + } + apply { + t2.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t1") table t1() { + actions = { + nop; + NoAction; + } + key = { + hdr.ethernet.dstAddr: exact; + } + default_action = NoAction(); + } + apply { + t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.other_tag); + packet.emit(hdr.vlan_tag); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/10-SelectPriorities-fe.p4 b/testdata/v1_samples_outputs/10-SelectPriorities-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 50% rename from testdata/v1_samples_outputs/10-SelectPriorities-fe.p4 rename to testdata/v1_samples_outputs/10-SelectPriorities-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index d65e9f34892..28dd758dbbc 100644 --- a/testdata/v1_samples_outputs/10-SelectPriorities-fe.p4 +++ b/testdata/v1_samples_outputs/10-SelectPriorities-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; @@ -63,7 +167,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { t2.apply(); } @@ -82,7 +185,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); } diff --git a/testdata/v1_samples_outputs/10-SelectPriorities-midend.p4 b/testdata/v1_samples_outputs/10-SelectPriorities-MidEnd_25_Evaluator.p4 similarity index 52% rename from testdata/v1_samples_outputs/10-SelectPriorities-midend.p4 rename to testdata/v1_samples_outputs/10-SelectPriorities-MidEnd_25_Evaluator.p4 index a76e1237569..404fc77e4bb 100644 --- a/testdata/v1_samples_outputs/10-SelectPriorities-midend.p4 +++ b/testdata/v1_samples_outputs/10-SelectPriorities-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; diff --git a/testdata/v1_samples_outputs/10-SelectPriorities-last.p4 b/testdata/v1_samples_outputs/10-SelectPriorities-last.p4 deleted file mode 100644 index d65e9f34892..00000000000 --- a/testdata/v1_samples_outputs/10-SelectPriorities-last.p4 +++ /dev/null @@ -1,109 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -header other_tag_t { - bit<16> field1; - bit<16> ethertype; -} - -header vlan_tag_t { - bit<3> pcp; - bit<1> cfi; - bit<12> vlan_id; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; - @name("other_tag") - other_tag_t other_tag; - @name("vlan_tag") - vlan_tag_t vlan_tag; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("parse_other_tag") state parse_other_tag { - packet.extract(hdr.other_tag); - transition accept; - } - @name("parse_vlan_tag") state parse_vlan_tag { - packet.extract(hdr.vlan_tag); - transition accept; - } - @name("start") state start { - packet.extract(hdr.ethernet); - transition select(hdr.ethernet.ethertype) { - 16w0x8100 &&& 16w0xff00: parse_vlan_tag; - 16w0x8153: parse_other_tag; - default: accept; - } - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t2") table t2() { - actions = { - nop; - NoAction; - } - key = { - hdr.ethernet.srcAddr: exact; - } - default_action = NoAction(); - } - - apply { - t2.apply(); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t1") table t1() { - actions = { - nop; - NoAction; - } - key = { - hdr.ethernet.dstAddr: exact; - } - default_action = NoAction(); - } - - apply { - t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - packet.emit(hdr.other_tag); - packet.emit(hdr.vlan_tag); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/10-SelectPriorities.p4 b/testdata/v1_samples_outputs/10-SelectPriorities.p4 index d65e9f34892..2b529777572 100644 --- a/testdata/v1_samples_outputs/10-SelectPriorities.p4 +++ b/testdata/v1_samples_outputs/10-SelectPriorities.p4 @@ -63,7 +63,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { t2.apply(); } @@ -82,7 +81,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); } diff --git a/testdata/v1_samples_outputs/11-MultiTags-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/11-MultiTags-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..ed61976d271 --- /dev/null +++ b/testdata/v1_samples_outputs/11-MultiTags-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,235 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +header my_tag_t { + bit<32> bd; + bit<16> ethertype; +} + +header vlan_tag_t { + bit<3> pcp; + bit<1> cfi; + bit<12> vlan_id; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("my_tag") + my_tag_t my_tag; + @name("vlan_tag") + vlan_tag_t vlan_tag; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_my_tag") state parse_my_tag { + packet.extract(hdr.my_tag); + transition select(hdr.my_tag.ethertype) { + 16w0x8100 &&& 16w0xefff: parse_vlan_tag; + 16w0x9000: parse_my_tag; + default: accept; + } + } + @name("parse_vlan_tag") state parse_vlan_tag { + packet.extract(hdr.vlan_tag); + transition select(hdr.vlan_tag.ethertype) { + 16w0x8100 &&& 16w0xefff: parse_vlan_tag; + 16w0x9000: parse_my_tag; + default: accept; + } + } + @name("start") state start { + packet.extract(hdr.ethernet); + transition select(hdr.ethernet.ethertype) { + 16w0x8100 &&& 16w0xefff: parse_vlan_tag; + 16w0x9000: parse_my_tag; + default: accept; + } + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t2") table t2() { + actions = { + nop; + NoAction; + } + key = { + hdr.ethernet.srcAddr: exact; + } + default_action = NoAction(); + } + apply { + t2.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t1") table t1() { + actions = { + nop; + NoAction; + } + key = { + hdr.ethernet.dstAddr: exact; + } + default_action = NoAction(); + } + apply { + t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.vlan_tag); + packet.emit(hdr.my_tag); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/11-MultiTags-fe.p4 b/testdata/v1_samples_outputs/11-MultiTags-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 53% rename from testdata/v1_samples_outputs/11-MultiTags-fe.p4 rename to testdata/v1_samples_outputs/11-MultiTags-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index e412282cccb..e8197d762ab 100644 --- a/testdata/v1_samples_outputs/11-MultiTags-fe.p4 +++ b/testdata/v1_samples_outputs/11-MultiTags-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; @@ -71,7 +175,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { t2.apply(); } @@ -90,7 +193,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); } diff --git a/testdata/v1_samples_outputs/11-MultiTags-midend.p4 b/testdata/v1_samples_outputs/11-MultiTags-MidEnd_25_Evaluator.p4 similarity index 54% rename from testdata/v1_samples_outputs/11-MultiTags-midend.p4 rename to testdata/v1_samples_outputs/11-MultiTags-MidEnd_25_Evaluator.p4 index ae8972b9ea0..e3072bf243f 100644 --- a/testdata/v1_samples_outputs/11-MultiTags-midend.p4 +++ b/testdata/v1_samples_outputs/11-MultiTags-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; diff --git a/testdata/v1_samples_outputs/11-MultiTags.p4 b/testdata/v1_samples_outputs/11-MultiTags.p4 index e412282cccb..07c8a0818d0 100644 --- a/testdata/v1_samples_outputs/11-MultiTags.p4 +++ b/testdata/v1_samples_outputs/11-MultiTags.p4 @@ -71,7 +71,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { t2.apply(); } @@ -90,7 +89,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); } diff --git a/testdata/v1_samples_outputs/12-Counters-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/12-Counters-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..ae06b9f39de --- /dev/null +++ b/testdata/v1_samples_outputs/12-Counters-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,197 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.ethernet); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + Counter(32w1024, CounterType.Packets) @name("c1") c1; + @name("count_c1_1") action count_c1_1() { + c1.increment(32w1); + } + @name("t1") table t1() { + actions = { + count_c1_1; + NoAction; + } + key = { + hdr.ethernet.dstAddr: exact; + } + default_action = NoAction(); + } + @name("t2") table t2() { + actions = { + count_c1_1; + NoAction; + } + key = { + hdr.ethernet.srcAddr: exact; + } + default_action = NoAction(); + } + apply { + t1.apply(); + t2.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/12-Counters-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/12-Counters-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..6293bd65630 --- /dev/null +++ b/testdata/v1_samples_outputs/12-Counters-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,181 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.ethernet); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + Counter(32w1024, CounterType.Packets) @name("c1") c1; + @name("count_c1_1") action count_c1_1() { + c1.increment(32w1); + } + @name("t1") table t1() { + actions = { + count_c1_1; + NoAction; + } + key = { + hdr.ethernet.dstAddr: exact; + } + default_action = NoAction(); + } + @name("t2") table t2() { + actions = { + count_c1_1; + NoAction; + } + key = { + hdr.ethernet.srcAddr: exact; + } + default_action = NoAction(); + } + apply { + t1.apply(); + t2.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/12-Counters-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/12-Counters-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..8d0f68fad9b --- /dev/null +++ b/testdata/v1_samples_outputs/12-Counters-MidEnd_25_Evaluator.p4 @@ -0,0 +1,186 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.ethernet); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + action NoAction_1() { + } + Counter(32w1024, CounterType.Packets) @name("c1") c1_0; + @name("count_c1_1") action count_c1() { + c1_0.increment(32w1); + } + @name("count_c1_1") action count_c1_0() { + c1_0.increment(32w1); + } + @name("t1") table t1_0() { + actions = { + count_c1; + NoAction_0; + } + key = { + hdr.ethernet.dstAddr: exact; + } + default_action = NoAction_0(); + } + @name("t2") table t2_0() { + actions = { + count_c1_0; + NoAction_1; + } + key = { + hdr.ethernet.srcAddr: exact; + } + default_action = NoAction_0(); + } + apply { + t1_0.apply(); + t2_0.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/12-Counters-fe.p4 b/testdata/v1_samples_outputs/12-Counters-fe.p4 deleted file mode 100644 index 13e7d9d6e17..00000000000 --- a/testdata/v1_samples_outputs/12-Counters-fe.p4 +++ /dev/null @@ -1,79 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.ethernet); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - Counter(32w1024, CounterType.Packets) @name("c1") c1; - @name("count_c1_1") action count_c1_1() { - c1.increment(32w1); - } - @name("t1") table t1() { - actions = { - count_c1_1; - NoAction; - } - key = { - hdr.ethernet.dstAddr: exact; - } - default_action = NoAction(); - } - - @name("t2") table t2() { - actions = { - count_c1_1; - NoAction; - } - key = { - hdr.ethernet.srcAddr: exact; - } - default_action = NoAction(); - } - - apply { - t1.apply(); - t2.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/12-Counters-last.p4 b/testdata/v1_samples_outputs/12-Counters-last.p4 deleted file mode 100644 index 13e7d9d6e17..00000000000 --- a/testdata/v1_samples_outputs/12-Counters-last.p4 +++ /dev/null @@ -1,79 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.ethernet); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - Counter(32w1024, CounterType.Packets) @name("c1") c1; - @name("count_c1_1") action count_c1_1() { - c1.increment(32w1); - } - @name("t1") table t1() { - actions = { - count_c1_1; - NoAction; - } - key = { - hdr.ethernet.dstAddr: exact; - } - default_action = NoAction(); - } - - @name("t2") table t2() { - actions = { - count_c1_1; - NoAction; - } - key = { - hdr.ethernet.srcAddr: exact; - } - default_action = NoAction(); - } - - apply { - t1.apply(); - t2.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/12-Counters-midend.p4 b/testdata/v1_samples_outputs/12-Counters-midend.p4 deleted file mode 100644 index c6f3d6e5b1a..00000000000 --- a/testdata/v1_samples_outputs/12-Counters-midend.p4 +++ /dev/null @@ -1,84 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.ethernet); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - action NoAction_1() { - } - Counter(32w1024, CounterType.Packets) @name("c1") c1_0; - @name("count_c1_1") action count_c1() { - c1_0.increment(32w1); - } - @name("count_c1_1") action count_c1_0() { - c1_0.increment(32w1); - } - @name("t1") table t1_0() { - actions = { - count_c1; - NoAction_0; - } - key = { - hdr.ethernet.dstAddr: exact; - } - default_action = NoAction_0(); - } - @name("t2") table t2_0() { - actions = { - count_c1_0; - NoAction_1; - } - key = { - hdr.ethernet.srcAddr: exact; - } - default_action = NoAction_0(); - } - apply { - t1_0.apply(); - t2_0.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/12-Counters.p4 b/testdata/v1_samples_outputs/12-Counters.p4 index ee406b11aed..921cbfb23ba 100644 --- a/testdata/v1_samples_outputs/12-Counters.p4 +++ b/testdata/v1_samples_outputs/12-Counters.p4 @@ -42,7 +42,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t2") table t2() { actions = { count_c1_1; @@ -53,7 +52,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); t2.apply(); diff --git a/testdata/v1_samples_outputs/12-MultiTagsNoLoop-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/12-MultiTagsNoLoop-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..63a791c0f5c --- /dev/null +++ b/testdata/v1_samples_outputs/12-MultiTagsNoLoop-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,233 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +header my_tag_t { + bit<32> bd; + bit<16> ethertype; +} + +header vlan_tag_t { + bit<3> pcp; + bit<1> cfi; + bit<12> vlan_id; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("my_tag") + my_tag_t my_tag; + @name("vlan_tag") + vlan_tag_t vlan_tag; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_my_tag") state parse_my_tag { + packet.extract(hdr.my_tag); + transition select(hdr.my_tag.ethertype) { + 16w0x8100 &&& 16w0xefff: parse_vlan_tag; + default: accept; + } + } + @name("parse_vlan_tag") state parse_vlan_tag { + packet.extract(hdr.vlan_tag); + transition select(hdr.vlan_tag.ethertype) { + 16w0x9000: parse_my_tag; + default: accept; + } + } + @name("start") state start { + packet.extract(hdr.ethernet); + transition select(hdr.ethernet.ethertype) { + 16w0x8100 &&& 16w0xefff: parse_vlan_tag; + 16w0x9000: parse_my_tag; + default: accept; + } + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t2") table t2() { + actions = { + nop; + NoAction; + } + key = { + hdr.ethernet.srcAddr: exact; + } + default_action = NoAction(); + } + apply { + t2.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t1") table t1() { + actions = { + nop; + NoAction; + } + key = { + hdr.ethernet.dstAddr: exact; + } + default_action = NoAction(); + } + apply { + t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.vlan_tag); + packet.emit(hdr.my_tag); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/11-MultiTags-last.p4 b/testdata/v1_samples_outputs/12-MultiTagsNoLoop-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 52% rename from testdata/v1_samples_outputs/11-MultiTags-last.p4 rename to testdata/v1_samples_outputs/12-MultiTagsNoLoop-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index e412282cccb..4b5640a8b25 100644 --- a/testdata/v1_samples_outputs/11-MultiTags-last.p4 +++ b/testdata/v1_samples_outputs/12-MultiTagsNoLoop-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; @@ -36,14 +140,12 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout packet.extract(hdr.my_tag); transition select(hdr.my_tag.ethertype) { 16w0x8100 &&& 16w0xefff: parse_vlan_tag; - 16w0x9000: parse_my_tag; default: accept; } } @name("parse_vlan_tag") state parse_vlan_tag { packet.extract(hdr.vlan_tag); transition select(hdr.vlan_tag.ethertype) { - 16w0x8100 &&& 16w0xefff: parse_vlan_tag; 16w0x9000: parse_my_tag; default: accept; } @@ -71,7 +173,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { t2.apply(); } @@ -90,7 +191,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); } diff --git a/testdata/v1_samples_outputs/12-MultiTagsNoLoop-midend.p4 b/testdata/v1_samples_outputs/12-MultiTagsNoLoop-MidEnd_25_Evaluator.p4 similarity index 53% rename from testdata/v1_samples_outputs/12-MultiTagsNoLoop-midend.p4 rename to testdata/v1_samples_outputs/12-MultiTagsNoLoop-MidEnd_25_Evaluator.p4 index 44fc61fc95a..88f9b9805bb 100644 --- a/testdata/v1_samples_outputs/12-MultiTagsNoLoop-midend.p4 +++ b/testdata/v1_samples_outputs/12-MultiTagsNoLoop-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; diff --git a/testdata/v1_samples_outputs/12-MultiTagsNoLoop-fe.p4 b/testdata/v1_samples_outputs/12-MultiTagsNoLoop-fe.p4 deleted file mode 100644 index d83af6e4a33..00000000000 --- a/testdata/v1_samples_outputs/12-MultiTagsNoLoop-fe.p4 +++ /dev/null @@ -1,115 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -header my_tag_t { - bit<32> bd; - bit<16> ethertype; -} - -header vlan_tag_t { - bit<3> pcp; - bit<1> cfi; - bit<12> vlan_id; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; - @name("my_tag") - my_tag_t my_tag; - @name("vlan_tag") - vlan_tag_t vlan_tag; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("parse_my_tag") state parse_my_tag { - packet.extract(hdr.my_tag); - transition select(hdr.my_tag.ethertype) { - 16w0x8100 &&& 16w0xefff: parse_vlan_tag; - default: accept; - } - } - @name("parse_vlan_tag") state parse_vlan_tag { - packet.extract(hdr.vlan_tag); - transition select(hdr.vlan_tag.ethertype) { - 16w0x9000: parse_my_tag; - default: accept; - } - } - @name("start") state start { - packet.extract(hdr.ethernet); - transition select(hdr.ethernet.ethertype) { - 16w0x8100 &&& 16w0xefff: parse_vlan_tag; - 16w0x9000: parse_my_tag; - default: accept; - } - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t2") table t2() { - actions = { - nop; - NoAction; - } - key = { - hdr.ethernet.srcAddr: exact; - } - default_action = NoAction(); - } - - apply { - t2.apply(); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t1") table t1() { - actions = { - nop; - NoAction; - } - key = { - hdr.ethernet.dstAddr: exact; - } - default_action = NoAction(); - } - - apply { - t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - packet.emit(hdr.vlan_tag); - packet.emit(hdr.my_tag); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/12-MultiTagsNoLoop-last.p4 b/testdata/v1_samples_outputs/12-MultiTagsNoLoop-last.p4 deleted file mode 100644 index d83af6e4a33..00000000000 --- a/testdata/v1_samples_outputs/12-MultiTagsNoLoop-last.p4 +++ /dev/null @@ -1,115 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -header my_tag_t { - bit<32> bd; - bit<16> ethertype; -} - -header vlan_tag_t { - bit<3> pcp; - bit<1> cfi; - bit<12> vlan_id; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; - @name("my_tag") - my_tag_t my_tag; - @name("vlan_tag") - vlan_tag_t vlan_tag; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("parse_my_tag") state parse_my_tag { - packet.extract(hdr.my_tag); - transition select(hdr.my_tag.ethertype) { - 16w0x8100 &&& 16w0xefff: parse_vlan_tag; - default: accept; - } - } - @name("parse_vlan_tag") state parse_vlan_tag { - packet.extract(hdr.vlan_tag); - transition select(hdr.vlan_tag.ethertype) { - 16w0x9000: parse_my_tag; - default: accept; - } - } - @name("start") state start { - packet.extract(hdr.ethernet); - transition select(hdr.ethernet.ethertype) { - 16w0x8100 &&& 16w0xefff: parse_vlan_tag; - 16w0x9000: parse_my_tag; - default: accept; - } - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t2") table t2() { - actions = { - nop; - NoAction; - } - key = { - hdr.ethernet.srcAddr: exact; - } - default_action = NoAction(); - } - - apply { - t2.apply(); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t1") table t1() { - actions = { - nop; - NoAction; - } - key = { - hdr.ethernet.dstAddr: exact; - } - default_action = NoAction(); - } - - apply { - t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - packet.emit(hdr.vlan_tag); - packet.emit(hdr.my_tag); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/12-MultiTagsNoLoop.p4 b/testdata/v1_samples_outputs/12-MultiTagsNoLoop.p4 index d83af6e4a33..c4adcf09fc2 100644 --- a/testdata/v1_samples_outputs/12-MultiTagsNoLoop.p4 +++ b/testdata/v1_samples_outputs/12-MultiTagsNoLoop.p4 @@ -69,7 +69,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { t2.apply(); } @@ -88,7 +87,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); } diff --git a/testdata/v1_samples_outputs/13-Counters1and2-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/13-Counters1and2-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..94220372687 --- /dev/null +++ b/testdata/v1_samples_outputs/13-Counters1and2-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,194 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.ethernet); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + Counter(32w1024, CounterType.Packets) @name("c1") c1; + @name("count_c1_1") action count_c1_1() { + c1.increment(32w1); + } + @name("count_c1_2") action count_c1_2() { + c1.increment(32w2); + } + @name("t1") table t1() { + actions = { + count_c1_1; + NoAction; + } + default_action = NoAction(); + } + @name("t2") table t2() { + actions = { + count_c1_2; + NoAction; + } + default_action = NoAction(); + } + apply { + t1.apply(); + t2.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/13-Counters1and2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/13-Counters1and2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..97a17735ead --- /dev/null +++ b/testdata/v1_samples_outputs/13-Counters1and2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,178 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.ethernet); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + Counter(32w1024, CounterType.Packets) @name("c1") c1; + @name("count_c1_1") action count_c1_1() { + c1.increment(32w1); + } + @name("count_c1_2") action count_c1_2() { + c1.increment(32w2); + } + @name("t1") table t1() { + actions = { + count_c1_1; + NoAction; + } + default_action = NoAction(); + } + @name("t2") table t2() { + actions = { + count_c1_2; + NoAction; + } + default_action = NoAction(); + } + apply { + t1.apply(); + t2.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/13-Counters1and2-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/13-Counters1and2-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..d0893d8a080 --- /dev/null +++ b/testdata/v1_samples_outputs/13-Counters1and2-MidEnd_25_Evaluator.p4 @@ -0,0 +1,180 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.ethernet); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + action NoAction_1() { + } + Counter(32w1024, CounterType.Packets) @name("c1") c1_0; + @name("count_c1_1") action count_c1() { + c1_0.increment(32w1); + } + @name("count_c1_2") action count_c1_0() { + c1_0.increment(32w2); + } + @name("t1") table t1_0() { + actions = { + count_c1; + NoAction_0; + } + default_action = NoAction_0(); + } + @name("t2") table t2_0() { + actions = { + count_c1_0; + NoAction_1; + } + default_action = NoAction_0(); + } + apply { + t1_0.apply(); + t2_0.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/13-Counters1and2-fe.p4 b/testdata/v1_samples_outputs/13-Counters1and2-fe.p4 deleted file mode 100644 index b32584bbc66..00000000000 --- a/testdata/v1_samples_outputs/13-Counters1and2-fe.p4 +++ /dev/null @@ -1,76 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.ethernet); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - Counter(32w1024, CounterType.Packets) @name("c1") c1; - @name("count_c1_1") action count_c1_1() { - c1.increment(32w1); - } - @name("count_c1_2") action count_c1_2() { - c1.increment(32w2); - } - @name("t1") table t1() { - actions = { - count_c1_1; - NoAction; - } - default_action = NoAction(); - } - - @name("t2") table t2() { - actions = { - count_c1_2; - NoAction; - } - default_action = NoAction(); - } - - apply { - t1.apply(); - t2.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/13-Counters1and2-last.p4 b/testdata/v1_samples_outputs/13-Counters1and2-last.p4 deleted file mode 100644 index b32584bbc66..00000000000 --- a/testdata/v1_samples_outputs/13-Counters1and2-last.p4 +++ /dev/null @@ -1,76 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.ethernet); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - Counter(32w1024, CounterType.Packets) @name("c1") c1; - @name("count_c1_1") action count_c1_1() { - c1.increment(32w1); - } - @name("count_c1_2") action count_c1_2() { - c1.increment(32w2); - } - @name("t1") table t1() { - actions = { - count_c1_1; - NoAction; - } - default_action = NoAction(); - } - - @name("t2") table t2() { - actions = { - count_c1_2; - NoAction; - } - default_action = NoAction(); - } - - apply { - t1.apply(); - t2.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/13-Counters1and2-midend.p4 b/testdata/v1_samples_outputs/13-Counters1and2-midend.p4 deleted file mode 100644 index 4a87f6b6c88..00000000000 --- a/testdata/v1_samples_outputs/13-Counters1and2-midend.p4 +++ /dev/null @@ -1,78 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.ethernet); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - action NoAction_1() { - } - Counter(32w1024, CounterType.Packets) @name("c1") c1_0; - @name("count_c1_1") action count_c1() { - c1_0.increment(32w1); - } - @name("count_c1_2") action count_c1_0() { - c1_0.increment(32w2); - } - @name("t1") table t1_0() { - actions = { - count_c1; - NoAction_0; - } - default_action = NoAction_0(); - } - @name("t2") table t2_0() { - actions = { - count_c1_0; - NoAction_1; - } - default_action = NoAction_0(); - } - apply { - t1_0.apply(); - t2_0.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/13-Counters1and2.p4 b/testdata/v1_samples_outputs/13-Counters1and2.p4 index 1ed7aaf55dd..bb62532ef60 100644 --- a/testdata/v1_samples_outputs/13-Counters1and2.p4 +++ b/testdata/v1_samples_outputs/13-Counters1and2.p4 @@ -42,7 +42,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("t2") table t2() { actions = { count_c1_2; @@ -50,7 +49,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); t2.apply(); diff --git a/testdata/v1_samples_outputs/13-MultiTagsCorrect-last.p4 b/testdata/v1_samples_outputs/13-MultiTagsCorrect-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 50% rename from testdata/v1_samples_outputs/13-MultiTagsCorrect-last.p4 rename to testdata/v1_samples_outputs/13-MultiTagsCorrect-FrontEnd_11_SimplifyControlFlowE.p4 index 65efb1cf946..472b0677b02 100644 --- a/testdata/v1_samples_outputs/13-MultiTagsCorrect-last.p4 +++ b/testdata/v1_samples_outputs/13-MultiTagsCorrect-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; @@ -81,7 +201,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { t2.apply(); } @@ -100,7 +219,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); } diff --git a/testdata/v1_samples_outputs/13-MultiTagsCorrect-fe.p4 b/testdata/v1_samples_outputs/13-MultiTagsCorrect-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 56% rename from testdata/v1_samples_outputs/13-MultiTagsCorrect-fe.p4 rename to testdata/v1_samples_outputs/13-MultiTagsCorrect-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 65efb1cf946..6fa2bb70aee 100644 --- a/testdata/v1_samples_outputs/13-MultiTagsCorrect-fe.p4 +++ b/testdata/v1_samples_outputs/13-MultiTagsCorrect-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; @@ -81,7 +185,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { t2.apply(); } @@ -100,7 +203,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); } diff --git a/testdata/v1_samples_outputs/13-MultiTagsCorrect-midend.p4 b/testdata/v1_samples_outputs/13-MultiTagsCorrect-MidEnd_25_Evaluator.p4 similarity index 57% rename from testdata/v1_samples_outputs/13-MultiTagsCorrect-midend.p4 rename to testdata/v1_samples_outputs/13-MultiTagsCorrect-MidEnd_25_Evaluator.p4 index 0b4daeea8de..dd33efae67a 100644 --- a/testdata/v1_samples_outputs/13-MultiTagsCorrect-midend.p4 +++ b/testdata/v1_samples_outputs/13-MultiTagsCorrect-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; diff --git a/testdata/v1_samples_outputs/13-MultiTagsCorrect.p4 b/testdata/v1_samples_outputs/13-MultiTagsCorrect.p4 index 65efb1cf946..ea71007aa88 100644 --- a/testdata/v1_samples_outputs/13-MultiTagsCorrect.p4 +++ b/testdata/v1_samples_outputs/13-MultiTagsCorrect.p4 @@ -81,7 +81,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { t2.apply(); } @@ -100,7 +99,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); } diff --git a/testdata/v1_samples_outputs/14-Counter-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/14-Counter-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..9912f179d9a --- /dev/null +++ b/testdata/v1_samples_outputs/14-Counter-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,183 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.ethernet); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + Counter(32w1024, CounterType.Packets) @name("c1") c1; + @name("count_c1_1") action count_c1_1() { + c1.increment(32w1); + } + @name("t1") table t1() { + actions = { + count_c1_1; + NoAction; + } + default_action = NoAction(); + } + apply { + t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/14-Counter-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/14-Counter-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..f31303c02f3 --- /dev/null +++ b/testdata/v1_samples_outputs/14-Counter-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,167 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.ethernet); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + Counter(32w1024, CounterType.Packets) @name("c1") c1; + @name("count_c1_1") action count_c1_1() { + c1.increment(32w1); + } + @name("t1") table t1() { + actions = { + count_c1_1; + NoAction; + } + default_action = NoAction(); + } + apply { + t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/14-Counter-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/14-Counter-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..95741747106 --- /dev/null +++ b/testdata/v1_samples_outputs/14-Counter-MidEnd_25_Evaluator.p4 @@ -0,0 +1,167 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.ethernet); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + Counter(32w1024, CounterType.Packets) @name("c1") c1_0; + @name("count_c1_1") action count_c1() { + c1_0.increment(32w1); + } + @name("t1") table t1_0() { + actions = { + count_c1; + NoAction_0; + } + default_action = NoAction_0(); + } + apply { + t1_0.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/14-Counter-fe.p4 b/testdata/v1_samples_outputs/14-Counter-fe.p4 deleted file mode 100644 index 5e4b701da0b..00000000000 --- a/testdata/v1_samples_outputs/14-Counter-fe.p4 +++ /dev/null @@ -1,64 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.ethernet); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - Counter(32w1024, CounterType.Packets) @name("c1") c1; - @name("count_c1_1") action count_c1_1() { - c1.increment(32w1); - } - @name("t1") table t1() { - actions = { - count_c1_1; - NoAction; - } - default_action = NoAction(); - } - - apply { - t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/14-Counter-last.p4 b/testdata/v1_samples_outputs/14-Counter-last.p4 deleted file mode 100644 index 5e4b701da0b..00000000000 --- a/testdata/v1_samples_outputs/14-Counter-last.p4 +++ /dev/null @@ -1,64 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.ethernet); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - Counter(32w1024, CounterType.Packets) @name("c1") c1; - @name("count_c1_1") action count_c1_1() { - c1.increment(32w1); - } - @name("t1") table t1() { - actions = { - count_c1_1; - NoAction; - } - default_action = NoAction(); - } - - apply { - t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/14-Counter-midend.p4 b/testdata/v1_samples_outputs/14-Counter-midend.p4 deleted file mode 100644 index f1342d2e81a..00000000000 --- a/testdata/v1_samples_outputs/14-Counter-midend.p4 +++ /dev/null @@ -1,65 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.ethernet); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - Counter(32w1024, CounterType.Packets) @name("c1") c1_0; - @name("count_c1_1") action count_c1() { - c1_0.increment(32w1); - } - @name("t1") table t1_0() { - actions = { - count_c1; - NoAction_0; - } - default_action = NoAction_0(); - } - apply { - t1_0.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/14-Counter.p4 b/testdata/v1_samples_outputs/14-Counter.p4 index 7c92c477a1d..4add6f82a67 100644 --- a/testdata/v1_samples_outputs/14-Counter.p4 +++ b/testdata/v1_samples_outputs/14-Counter.p4 @@ -39,7 +39,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); } diff --git a/testdata/v1_samples_outputs/14-GatewayGreaterThan-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/14-GatewayGreaterThan-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..de9f083943d --- /dev/null +++ b/testdata/v1_samples_outputs/14-GatewayGreaterThan-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,188 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +header h_t { + bit<13> f1; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("h") + h_t h; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.ethernet); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t1") table t1() { + actions = { + nop; + NoAction; + } + default_action = NoAction(); + } + apply { + if (hdr.h.f1 > 13w1) + t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/14-GatewayGreaterThan-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/14-GatewayGreaterThan-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..5a96bd8774c --- /dev/null +++ b/testdata/v1_samples_outputs/14-GatewayGreaterThan-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,172 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +header h_t { + bit<13> f1; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("h") + h_t h; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.ethernet); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("nop") action nop() { + } + @name("t1") table t1() { + actions = { + nop; + NoAction; + } + default_action = NoAction(); + } + apply { + if (hdr.h.f1 > 13w1) + t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/14-GatewayGreaterThan-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/14-GatewayGreaterThan-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..74bea1f7870 --- /dev/null +++ b/testdata/v1_samples_outputs/14-GatewayGreaterThan-MidEnd_25_Evaluator.p4 @@ -0,0 +1,172 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +header h_t { + bit<13> f1; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("h") + h_t h; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.ethernet); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("nop") action nop_0() { + } + @name("t1") table t1_0() { + actions = { + nop_0; + NoAction_0; + } + default_action = NoAction_0(); + } + apply { + if (hdr.h.f1 > 13w1) + t1_0.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/14-GatewayGreaterThan-fe.p4 b/testdata/v1_samples_outputs/14-GatewayGreaterThan-fe.p4 deleted file mode 100644 index ff97561a933..00000000000 --- a/testdata/v1_samples_outputs/14-GatewayGreaterThan-fe.p4 +++ /dev/null @@ -1,69 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -header h_t { - bit<13> f1; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; - @name("h") - h_t h; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.ethernet); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t1") table t1() { - actions = { - nop; - NoAction; - } - default_action = NoAction(); - } - - apply { - if (hdr.h.f1 > 13w1) - t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/14-GatewayGreaterThan-last.p4 b/testdata/v1_samples_outputs/14-GatewayGreaterThan-last.p4 deleted file mode 100644 index ff97561a933..00000000000 --- a/testdata/v1_samples_outputs/14-GatewayGreaterThan-last.p4 +++ /dev/null @@ -1,69 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -header h_t { - bit<13> f1; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; - @name("h") - h_t h; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.ethernet); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("nop") action nop() { - } - @name("t1") table t1() { - actions = { - nop; - NoAction; - } - default_action = NoAction(); - } - - apply { - if (hdr.h.f1 > 13w1) - t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/14-GatewayGreaterThan-midend.p4 b/testdata/v1_samples_outputs/14-GatewayGreaterThan-midend.p4 deleted file mode 100644 index 8dcb33c862e..00000000000 --- a/testdata/v1_samples_outputs/14-GatewayGreaterThan-midend.p4 +++ /dev/null @@ -1,70 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -header h_t { - bit<13> f1; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; - @name("h") - h_t h; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.ethernet); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("nop") action nop_0() { - } - @name("t1") table t1_0() { - actions = { - nop_0; - NoAction_0; - } - default_action = NoAction_0(); - } - apply { - if (hdr.h.f1 > 13w1) - t1_0.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/14-GatewayGreaterThan.p4 b/testdata/v1_samples_outputs/14-GatewayGreaterThan.p4 index 699f401bc9c..f135c34e230 100644 --- a/testdata/v1_samples_outputs/14-GatewayGreaterThan.p4 +++ b/testdata/v1_samples_outputs/14-GatewayGreaterThan.p4 @@ -43,7 +43,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (hdr.h.f1 > 13w1) { t1.apply(); diff --git a/testdata/v1_samples_outputs/14-SplitEthernetVlan-last.p4 b/testdata/v1_samples_outputs/14-SplitEthernetVlan-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 50% rename from testdata/v1_samples_outputs/14-SplitEthernetVlan-last.p4 rename to testdata/v1_samples_outputs/14-SplitEthernetVlan-FrontEnd_11_SimplifyControlFlowE.p4 index 96311a9c23c..c88848c8c9c 100644 --- a/testdata/v1_samples_outputs/14-SplitEthernetVlan-last.p4 +++ b/testdata/v1_samples_outputs/14-SplitEthernetVlan-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header cfi_t { bit<1> cfi; } @@ -86,7 +206,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { t2.apply(); } @@ -106,7 +225,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); } diff --git a/testdata/v1_samples_outputs/14-SplitEthernetVlan-fe.p4 b/testdata/v1_samples_outputs/14-SplitEthernetVlan-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 56% rename from testdata/v1_samples_outputs/14-SplitEthernetVlan-fe.p4 rename to testdata/v1_samples_outputs/14-SplitEthernetVlan-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 96311a9c23c..e2120fed0c6 100644 --- a/testdata/v1_samples_outputs/14-SplitEthernetVlan-fe.p4 +++ b/testdata/v1_samples_outputs/14-SplitEthernetVlan-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header cfi_t { bit<1> cfi; } @@ -86,7 +190,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { t2.apply(); } @@ -106,7 +209,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); } diff --git a/testdata/v1_samples_outputs/14-SplitEthernetVlan-midend.p4 b/testdata/v1_samples_outputs/14-SplitEthernetVlan-MidEnd_25_Evaluator.p4 similarity index 56% rename from testdata/v1_samples_outputs/14-SplitEthernetVlan-midend.p4 rename to testdata/v1_samples_outputs/14-SplitEthernetVlan-MidEnd_25_Evaluator.p4 index 47c9bcb232e..d5082d96776 100644 --- a/testdata/v1_samples_outputs/14-SplitEthernetVlan-midend.p4 +++ b/testdata/v1_samples_outputs/14-SplitEthernetVlan-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header cfi_t { bit<1> cfi; } diff --git a/testdata/v1_samples_outputs/14-SplitEthernetVlan.p4 b/testdata/v1_samples_outputs/14-SplitEthernetVlan.p4 index 96311a9c23c..ae04fd2ec26 100644 --- a/testdata/v1_samples_outputs/14-SplitEthernetVlan.p4 +++ b/testdata/v1_samples_outputs/14-SplitEthernetVlan.p4 @@ -86,7 +86,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { t2.apply(); } @@ -106,7 +105,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); } diff --git a/testdata/v1_samples_outputs/15-MultiProtocolIfElseMinimal-fe.p4 b/testdata/v1_samples_outputs/15-MultiProtocolIfElseMinimal-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 51% rename from testdata/v1_samples_outputs/15-MultiProtocolIfElseMinimal-fe.p4 rename to testdata/v1_samples_outputs/15-MultiProtocolIfElseMinimal-FrontEnd_11_SimplifyControlFlowE.p4 index d16bb6f8395..f465d814b6f 100644 --- a/testdata/v1_samples_outputs/15-MultiProtocolIfElseMinimal-fe.p4 +++ b/testdata/v1_samples_outputs/15-MultiProtocolIfElseMinimal-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<1> drop; bit<8> egress_port; @@ -94,7 +214,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("l2_match") table l2_match() { actions = { nop; @@ -106,7 +225,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (hdr.ethernet.etherType == 16w0x800) ipv4_match.apply(); diff --git a/testdata/v1_samples_outputs/15-MultiProtocolIfElseMinimal-last.p4 b/testdata/v1_samples_outputs/15-MultiProtocolIfElseMinimal-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 57% rename from testdata/v1_samples_outputs/15-MultiProtocolIfElseMinimal-last.p4 rename to testdata/v1_samples_outputs/15-MultiProtocolIfElseMinimal-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index d16bb6f8395..1c1ae44d8c4 100644 --- a/testdata/v1_samples_outputs/15-MultiProtocolIfElseMinimal-last.p4 +++ b/testdata/v1_samples_outputs/15-MultiProtocolIfElseMinimal-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<1> drop; bit<8> egress_port; @@ -94,7 +198,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("l2_match") table l2_match() { actions = { nop; @@ -106,7 +209,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (hdr.ethernet.etherType == 16w0x800) ipv4_match.apply(); diff --git a/testdata/v1_samples_outputs/15-MultiProtocolIfElseMinimal-midend.p4 b/testdata/v1_samples_outputs/15-MultiProtocolIfElseMinimal-MidEnd_25_Evaluator.p4 similarity index 59% rename from testdata/v1_samples_outputs/15-MultiProtocolIfElseMinimal-midend.p4 rename to testdata/v1_samples_outputs/15-MultiProtocolIfElseMinimal-MidEnd_25_Evaluator.p4 index a9c23610043..28907521885 100644 --- a/testdata/v1_samples_outputs/15-MultiProtocolIfElseMinimal-midend.p4 +++ b/testdata/v1_samples_outputs/15-MultiProtocolIfElseMinimal-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<1> drop; bit<8> egress_port; diff --git a/testdata/v1_samples_outputs/15-MultiProtocolIfElseMinimal.p4 b/testdata/v1_samples_outputs/15-MultiProtocolIfElseMinimal.p4 index 4e597f424eb..c0924eb19f6 100644 --- a/testdata/v1_samples_outputs/15-MultiProtocolIfElseMinimal.p4 +++ b/testdata/v1_samples_outputs/15-MultiProtocolIfElseMinimal.p4 @@ -94,7 +94,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("l2_match") table l2_match() { actions = { nop; @@ -106,7 +105,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (hdr.ethernet.etherType == 16w0x800) { ipv4_match.apply(); diff --git a/testdata/v1_samples_outputs/16-NoHeaders-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/16-NoHeaders-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..2158f330fdf --- /dev/null +++ b/testdata/v1_samples_outputs/16-NoHeaders-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,171 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct metadata { +} + +struct headers { +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("a1") action a1() { + } + @name("t1") table t1() { + actions = { + a1; + NoAction; + } + default_action = NoAction(); + } + apply { + t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/16-NoHeaders-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/16-NoHeaders-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..28b1ec0de16 --- /dev/null +++ b/testdata/v1_samples_outputs/16-NoHeaders-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,155 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct metadata { +} + +struct headers { +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("a1") action a1() { + } + @name("t1") table t1() { + actions = { + a1; + NoAction; + } + default_action = NoAction(); + } + apply { + t1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/16-NoHeaders-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/16-NoHeaders-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..44f101dce1f --- /dev/null +++ b/testdata/v1_samples_outputs/16-NoHeaders-MidEnd_25_Evaluator.p4 @@ -0,0 +1,155 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct metadata { +} + +struct headers { +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("a1") action a1_0() { + } + @name("t1") table t1_0() { + actions = { + a1_0; + NoAction_0; + } + default_action = NoAction_0(); + } + apply { + t1_0.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/16-NoHeaders-fe.p4 b/testdata/v1_samples_outputs/16-NoHeaders-fe.p4 deleted file mode 100644 index fdb9ef26e86..00000000000 --- a/testdata/v1_samples_outputs/16-NoHeaders-fe.p4 +++ /dev/null @@ -1,52 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct metadata { -} - -struct headers { -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("a1") action a1() { - } - @name("t1") table t1() { - actions = { - a1; - NoAction; - } - default_action = NoAction(); - } - - apply { - t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/16-NoHeaders-last.p4 b/testdata/v1_samples_outputs/16-NoHeaders-last.p4 deleted file mode 100644 index fdb9ef26e86..00000000000 --- a/testdata/v1_samples_outputs/16-NoHeaders-last.p4 +++ /dev/null @@ -1,52 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct metadata { -} - -struct headers { -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("a1") action a1() { - } - @name("t1") table t1() { - actions = { - a1; - NoAction; - } - default_action = NoAction(); - } - - apply { - t1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/16-NoHeaders-midend.p4 b/testdata/v1_samples_outputs/16-NoHeaders-midend.p4 deleted file mode 100644 index 915277cf33c..00000000000 --- a/testdata/v1_samples_outputs/16-NoHeaders-midend.p4 +++ /dev/null @@ -1,53 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct metadata { -} - -struct headers { -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("a1") action a1_0() { - } - @name("t1") table t1_0() { - actions = { - a1_0; - NoAction_0; - } - default_action = NoAction_0(); - } - apply { - t1_0.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/16-NoHeaders.p4 b/testdata/v1_samples_outputs/16-NoHeaders.p4 index fdb9ef26e86..56b27af0ac3 100644 --- a/testdata/v1_samples_outputs/16-NoHeaders.p4 +++ b/testdata/v1_samples_outputs/16-NoHeaders.p4 @@ -28,7 +28,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { t1.apply(); } diff --git a/testdata/v1_samples_outputs/16-TwoReferences-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/16-TwoReferences-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..989febb5c93 --- /dev/null +++ b/testdata/v1_samples_outputs/16-TwoReferences-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,241 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.ethernet); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("do_b") action do_b() { + } + @name("do_d") action do_d() { + } + @name("do_e") action do_e() { + } + @name("nop") action nop() { + } + @name("A") table A() { + actions = { + do_b; + do_d; + do_e; + NoAction; + } + key = { + hdr.ethernet.dstAddr: exact; + } + default_action = NoAction(); + } + @name("B") table B() { + actions = { + nop; + NoAction; + } + default_action = NoAction(); + } + @name("C") table C() { + actions = { + nop; + NoAction; + } + default_action = NoAction(); + } + @name("D") table D() { + actions = { + nop; + NoAction; + } + default_action = NoAction(); + } + @name("E") table E() { + actions = { + nop; + NoAction; + } + default_action = NoAction(); + } + @name("F") table F() { + actions = { + nop; + NoAction; + } + default_action = NoAction(); + } + apply { + switch (A.apply().action_run) { + do_b: { + B.apply(); + C.apply(); + } + do_d: { + D.apply(); + C.apply(); + } + do_e: { + E.apply(); + } + } + + F.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/16-TwoReferences-fe.p4 b/testdata/v1_samples_outputs/16-TwoReferences-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 52% rename from testdata/v1_samples_outputs/16-TwoReferences-fe.p4 rename to testdata/v1_samples_outputs/16-TwoReferences-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 92ca5752b1e..225b3fcb807 100644 --- a/testdata/v1_samples_outputs/16-TwoReferences-fe.p4 +++ b/testdata/v1_samples_outputs/16-TwoReferences-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; @@ -48,7 +152,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("B") table B() { actions = { nop; @@ -56,7 +159,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("C") table C() { actions = { nop; @@ -64,7 +166,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("D") table D() { actions = { nop; @@ -72,7 +173,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("E") table E() { actions = { nop; @@ -80,7 +180,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("F") table F() { actions = { nop; @@ -88,7 +187,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { switch (A.apply().action_run) { do_b: { diff --git a/testdata/v1_samples_outputs/16-TwoReferences-midend.p4 b/testdata/v1_samples_outputs/16-TwoReferences-MidEnd_25_Evaluator.p4 similarity index 56% rename from testdata/v1_samples_outputs/16-TwoReferences-midend.p4 rename to testdata/v1_samples_outputs/16-TwoReferences-MidEnd_25_Evaluator.p4 index 5f0fed24626..7107fcf0f09 100644 --- a/testdata/v1_samples_outputs/16-TwoReferences-midend.p4 +++ b/testdata/v1_samples_outputs/16-TwoReferences-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; diff --git a/testdata/v1_samples_outputs/16-TwoReferences-last.p4 b/testdata/v1_samples_outputs/16-TwoReferences-last.p4 deleted file mode 100644 index 92ca5752b1e..00000000000 --- a/testdata/v1_samples_outputs/16-TwoReferences-last.p4 +++ /dev/null @@ -1,127 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.ethernet); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("do_b") action do_b() { - } - @name("do_d") action do_d() { - } - @name("do_e") action do_e() { - } - @name("nop") action nop() { - } - @name("A") table A() { - actions = { - do_b; - do_d; - do_e; - NoAction; - } - key = { - hdr.ethernet.dstAddr: exact; - } - default_action = NoAction(); - } - - @name("B") table B() { - actions = { - nop; - NoAction; - } - default_action = NoAction(); - } - - @name("C") table C() { - actions = { - nop; - NoAction; - } - default_action = NoAction(); - } - - @name("D") table D() { - actions = { - nop; - NoAction; - } - default_action = NoAction(); - } - - @name("E") table E() { - actions = { - nop; - NoAction; - } - default_action = NoAction(); - } - - @name("F") table F() { - actions = { - nop; - NoAction; - } - default_action = NoAction(); - } - - apply { - switch (A.apply().action_run) { - do_b: { - B.apply(); - C.apply(); - } - do_d: { - D.apply(); - C.apply(); - } - do_e: { - E.apply(); - } - } - - F.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/16-TwoReferences.p4 b/testdata/v1_samples_outputs/16-TwoReferences.p4 index 58df0c0994e..e5980fb7a71 100644 --- a/testdata/v1_samples_outputs/16-TwoReferences.p4 +++ b/testdata/v1_samples_outputs/16-TwoReferences.p4 @@ -52,7 +52,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("B") table B() { actions = { nop; @@ -60,7 +59,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("C") table C() { actions = { nop; @@ -68,7 +66,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("D") table D() { actions = { nop; @@ -76,7 +73,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("E") table E() { actions = { nop; @@ -84,7 +80,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("F") table F() { actions = { nop; @@ -92,7 +87,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { switch (A.apply().action_run) { do_b: { diff --git a/testdata/v1_samples_outputs/17-Minimal-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/17-Minimal-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..e4dd7c1ef4d --- /dev/null +++ b/testdata/v1_samples_outputs/17-Minimal-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,161 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct metadata { +} + +struct headers { +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/17-Minimal-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/17-Minimal-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..e45ef04a576 --- /dev/null +++ b/testdata/v1_samples_outputs/17-Minimal-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,143 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct metadata { +} + +struct headers { +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/17-Minimal-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/17-Minimal-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..e45ef04a576 --- /dev/null +++ b/testdata/v1_samples_outputs/17-Minimal-MidEnd_25_Evaluator.p4 @@ -0,0 +1,143 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct metadata { +} + +struct headers { +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/17-Minimal-fe.p4 b/testdata/v1_samples_outputs/17-Minimal-fe.p4 deleted file mode 100644 index a5f8c2338af..00000000000 --- a/testdata/v1_samples_outputs/17-Minimal-fe.p4 +++ /dev/null @@ -1,41 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct metadata { -} - -struct headers { -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/17-Minimal-last.p4 b/testdata/v1_samples_outputs/17-Minimal-last.p4 deleted file mode 100644 index a5f8c2338af..00000000000 --- a/testdata/v1_samples_outputs/17-Minimal-last.p4 +++ /dev/null @@ -1,41 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct metadata { -} - -struct headers { -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/17-Minimal-midend.p4 b/testdata/v1_samples_outputs/17-Minimal-midend.p4 deleted file mode 100644 index a5f8c2338af..00000000000 --- a/testdata/v1_samples_outputs/17-Minimal-midend.p4 +++ /dev/null @@ -1,41 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct metadata { -} - -struct headers { -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/18-EmptyPipelines-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/18-EmptyPipelines-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..3e832bbe3e8 --- /dev/null +++ b/testdata/v1_samples_outputs/18-EmptyPipelines-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,171 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.ethernet); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/18-EmptyPipelines-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/18-EmptyPipelines-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..12ad239029c --- /dev/null +++ b/testdata/v1_samples_outputs/18-EmptyPipelines-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,153 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.ethernet); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/18-EmptyPipelines-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/18-EmptyPipelines-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..12ad239029c --- /dev/null +++ b/testdata/v1_samples_outputs/18-EmptyPipelines-MidEnd_25_Evaluator.p4 @@ -0,0 +1,153 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.ethernet); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/18-EmptyPipelines-fe.p4 b/testdata/v1_samples_outputs/18-EmptyPipelines-fe.p4 deleted file mode 100644 index 13c8e3165e0..00000000000 --- a/testdata/v1_samples_outputs/18-EmptyPipelines-fe.p4 +++ /dev/null @@ -1,51 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.ethernet); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/18-EmptyPipelines-last.p4 b/testdata/v1_samples_outputs/18-EmptyPipelines-last.p4 deleted file mode 100644 index 13c8e3165e0..00000000000 --- a/testdata/v1_samples_outputs/18-EmptyPipelines-last.p4 +++ /dev/null @@ -1,51 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.ethernet); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/18-EmptyPipelines-midend.p4 b/testdata/v1_samples_outputs/18-EmptyPipelines-midend.p4 deleted file mode 100644 index 13c8e3165e0..00000000000 --- a/testdata/v1_samples_outputs/18-EmptyPipelines-midend.p4 +++ /dev/null @@ -1,51 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.ethernet); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/acl1-last.p4 b/testdata/v1_samples_outputs/acl1-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 72% rename from testdata/v1_samples_outputs/acl1-last.p4 rename to testdata/v1_samples_outputs/acl1-FrontEnd_11_SimplifyControlFlowE.p4 index 87f69cfd14c..67b50429f7e 100644 --- a/testdata/v1_samples_outputs/acl1-last.p4 +++ b/testdata/v1_samples_outputs/acl1-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/cdodd/p4c/build/../p4include/core.p4" -#include "/home/cdodd/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct acl_metadata_t { bit<1> acl_deny; bit<1> racl_deny; diff --git a/testdata/v1_samples_outputs/acl1-fe.p4 b/testdata/v1_samples_outputs/acl1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 77% rename from testdata/v1_samples_outputs/acl1-fe.p4 rename to testdata/v1_samples_outputs/acl1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 87f69cfd14c..ebb79880979 100644 --- a/testdata/v1_samples_outputs/acl1-fe.p4 +++ b/testdata/v1_samples_outputs/acl1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/cdodd/p4c/build/../p4include/core.p4" -#include "/home/cdodd/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct acl_metadata_t { bit<1> acl_deny; bit<1> racl_deny; diff --git a/testdata/v1_samples_outputs/acl1-midend.p4 b/testdata/v1_samples_outputs/acl1-MidEnd_25_Evaluator.p4 similarity index 77% rename from testdata/v1_samples_outputs/acl1-midend.p4 rename to testdata/v1_samples_outputs/acl1-MidEnd_25_Evaluator.p4 index 7f30ca59ef2..fe046c7bd2f 100644 --- a/testdata/v1_samples_outputs/acl1-midend.p4 +++ b/testdata/v1_samples_outputs/acl1-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct acl_metadata_t { bit<1> acl_deny; bit<1> racl_deny; diff --git a/testdata/v1_samples_outputs/acl1.p4 b/testdata/v1_samples_outputs/acl1.p4 index 2fd406b06c6..42d84281fdf 100644 --- a/testdata/v1_samples_outputs/acl1.p4 +++ b/testdata/v1_samples_outputs/acl1.p4 @@ -1,5 +1,5 @@ -#include "/home/cdodd/p4c/build/../p4include/core.p4" -#include "/home/cdodd/p4c/build/../p4include/v1model.p4" +#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" +#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" struct acl_metadata_t { bit<1> acl_deny; diff --git a/testdata/v1_samples_outputs/action_bus1-last.p4 b/testdata/v1_samples_outputs/action_bus1-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 66% rename from testdata/v1_samples_outputs/action_bus1-last.p4 rename to testdata/v1_samples_outputs/action_bus1-FrontEnd_11_SimplifyControlFlowE.p4 index e1acc04308f..d4552695bfc 100644 --- a/testdata/v1_samples_outputs/action_bus1-last.p4 +++ b/testdata/v1_samples_outputs/action_bus1-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header data_t { bit<32> f1_1; bit<32> f1_2; @@ -129,7 +249,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl2") table tbl2() { actions = { set2; @@ -141,7 +260,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl3") table tbl3() { actions = { set3; @@ -153,7 +271,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl4") table tbl4() { actions = { set4; @@ -165,7 +282,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl5") table tbl5() { actions = { set5; @@ -177,7 +293,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl6") table tbl6() { actions = { set6; @@ -189,7 +304,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl7") table tbl7() { actions = { set7; @@ -201,7 +315,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl8") table tbl8() { actions = { set8; @@ -213,7 +326,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { tbl1.apply(); tbl2.apply(); diff --git a/testdata/v1_samples_outputs/action_bus1-fe.p4 b/testdata/v1_samples_outputs/action_bus1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 71% rename from testdata/v1_samples_outputs/action_bus1-fe.p4 rename to testdata/v1_samples_outputs/action_bus1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index e1acc04308f..e67ce9e5218 100644 --- a/testdata/v1_samples_outputs/action_bus1-fe.p4 +++ b/testdata/v1_samples_outputs/action_bus1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header data_t { bit<32> f1_1; bit<32> f1_2; @@ -129,7 +233,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl2") table tbl2() { actions = { set2; @@ -141,7 +244,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl3") table tbl3() { actions = { set3; @@ -153,7 +255,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl4") table tbl4() { actions = { set4; @@ -165,7 +266,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl5") table tbl5() { actions = { set5; @@ -177,7 +277,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl6") table tbl6() { actions = { set6; @@ -189,7 +288,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl7") table tbl7() { actions = { set7; @@ -201,7 +299,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl8") table tbl8() { actions = { set8; @@ -213,7 +310,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { tbl1.apply(); tbl2.apply(); diff --git a/testdata/v1_samples_outputs/action_bus1-midend.p4 b/testdata/v1_samples_outputs/action_bus1-MidEnd_25_Evaluator.p4 similarity index 73% rename from testdata/v1_samples_outputs/action_bus1-midend.p4 rename to testdata/v1_samples_outputs/action_bus1-MidEnd_25_Evaluator.p4 index 39d484d5054..d48da879710 100644 --- a/testdata/v1_samples_outputs/action_bus1-midend.p4 +++ b/testdata/v1_samples_outputs/action_bus1-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header data_t { bit<32> f1_1; bit<32> f1_2; diff --git a/testdata/v1_samples_outputs/action_bus1.p4 b/testdata/v1_samples_outputs/action_bus1.p4 index e1acc04308f..90e8a39e29a 100644 --- a/testdata/v1_samples_outputs/action_bus1.p4 +++ b/testdata/v1_samples_outputs/action_bus1.p4 @@ -129,7 +129,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl2") table tbl2() { actions = { set2; @@ -141,7 +140,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl3") table tbl3() { actions = { set3; @@ -153,7 +151,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl4") table tbl4() { actions = { set4; @@ -165,7 +162,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl5") table tbl5() { actions = { set5; @@ -177,7 +173,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl6") table tbl6() { actions = { set6; @@ -189,7 +184,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl7") table tbl7() { actions = { set7; @@ -201,7 +195,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl8") table tbl8() { actions = { set8; @@ -213,7 +206,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { tbl1.apply(); tbl2.apply(); diff --git a/testdata/v1_samples_outputs/action_chain1-last.p4 b/testdata/v1_samples_outputs/action_chain1-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 55% rename from testdata/v1_samples_outputs/action_chain1-last.p4 rename to testdata/v1_samples_outputs/action_chain1-FrontEnd_11_SimplifyControlFlowE.p4 index bea939c962d..099ab34ad6c 100644 --- a/testdata/v1_samples_outputs/action_chain1-last.p4 +++ b/testdata/v1_samples_outputs/action_chain1-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header data_t { bit<32> f1; bit<32> f2; @@ -81,7 +201,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl1") table tbl1() { actions = { setb2; @@ -93,7 +212,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl2") table tbl2() { actions = { set1b1; @@ -105,7 +223,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl3") table tbl3() { actions = { set2b2; @@ -117,7 +234,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("test1") table test1() { actions = { setb1; @@ -129,7 +245,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { test1.apply(); switch (ex1.apply().action_run) { diff --git a/testdata/v1_samples_outputs/action_chain1-fe.p4 b/testdata/v1_samples_outputs/action_chain1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 61% rename from testdata/v1_samples_outputs/action_chain1-fe.p4 rename to testdata/v1_samples_outputs/action_chain1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index bea939c962d..494fb67a856 100644 --- a/testdata/v1_samples_outputs/action_chain1-fe.p4 +++ b/testdata/v1_samples_outputs/action_chain1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header data_t { bit<32> f1; bit<32> f2; @@ -81,7 +185,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl1") table tbl1() { actions = { setb2; @@ -93,7 +196,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl2") table tbl2() { actions = { set1b1; @@ -105,7 +207,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl3") table tbl3() { actions = { set2b2; @@ -117,7 +218,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("test1") table test1() { actions = { setb1; @@ -129,7 +229,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { test1.apply(); switch (ex1.apply().action_run) { diff --git a/testdata/v1_samples_outputs/action_chain1-midend.p4 b/testdata/v1_samples_outputs/action_chain1-MidEnd_25_Evaluator.p4 similarity index 64% rename from testdata/v1_samples_outputs/action_chain1-midend.p4 rename to testdata/v1_samples_outputs/action_chain1-MidEnd_25_Evaluator.p4 index 6895528c044..ff647065078 100644 --- a/testdata/v1_samples_outputs/action_chain1-midend.p4 +++ b/testdata/v1_samples_outputs/action_chain1-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header data_t { bit<32> f1; bit<32> f2; diff --git a/testdata/v1_samples_outputs/action_chain1.p4 b/testdata/v1_samples_outputs/action_chain1.p4 index bea939c962d..c05400e7890 100644 --- a/testdata/v1_samples_outputs/action_chain1.p4 +++ b/testdata/v1_samples_outputs/action_chain1.p4 @@ -81,7 +81,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl1") table tbl1() { actions = { setb2; @@ -93,7 +92,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl2") table tbl2() { actions = { set1b1; @@ -105,7 +103,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("tbl3") table tbl3() { actions = { set2b2; @@ -117,7 +114,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("test1") table test1() { actions = { setb1; @@ -129,7 +125,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { test1.apply(); switch (ex1.apply().action_run) { diff --git a/testdata/v1_samples_outputs/action_inline-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/action_inline-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..ac9319b3d19 --- /dev/null +++ b/testdata/v1_samples_outputs/action_inline-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,182 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct ht { + bit<1> b; +} + +struct metadata { + @name("md") + ht md; +} + +struct headers { +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("a") action a(inout bit<1> y0) { + y0 = y0 + 1w1; + } + @name("b") action b() { + a(meta.md.b); + a(meta.md.b); + } + @name("t") table t() { + actions = { + b; + NoAction; + } + default_action = NoAction(); + } + apply { + t.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/action_inline-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/action_inline-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..bcae916578c --- /dev/null +++ b/testdata/v1_samples_outputs/action_inline-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,166 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct ht { + bit<1> b; +} + +struct metadata { + @name("md") + ht md; +} + +struct headers { +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("a") action a(inout bit<1> y0) { + y0 = y0 + 1w1; + } + @name("b") action b() { + a(meta.md.b); + a(meta.md.b); + } + @name("t") table t() { + actions = { + b; + NoAction; + } + default_action = NoAction(); + } + apply { + t.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/action_inline-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/action_inline-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..6f484a5c2b8 --- /dev/null +++ b/testdata/v1_samples_outputs/action_inline-MidEnd_25_Evaluator.p4 @@ -0,0 +1,163 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct ht { + bit<1> b; +} + +struct metadata { + @name("md") + ht md; +} + +struct headers { +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("b") action b_0() { + meta.md.b = meta.md.b + 1w1; + meta.md.b = meta.md.b + 1w1; + } + @name("t") table t_0() { + actions = { + b_0; + NoAction_0; + } + default_action = NoAction_0(); + } + apply { + t_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/action_inline-fe.p4 b/testdata/v1_samples_outputs/action_inline-fe.p4 deleted file mode 100644 index 45924376997..00000000000 --- a/testdata/v1_samples_outputs/action_inline-fe.p4 +++ /dev/null @@ -1,62 +0,0 @@ -#include "/home/cdodd/p4c/build/../p4include/core.p4" -#include "/home/cdodd/p4c/build/../p4include/v1model.p4" - -struct ht { - bit<1> b; -} - -struct metadata { - @name("md") - ht md; -} - -struct headers { -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("a") action a(inout bit<1> y0) { - y0 = y0 + 1w1; - } - @name("b") action b() { - a(meta.md.b); - a(meta.md.b); - } - @name("t") table t() { - actions = { - b; - NoAction; - } - default_action = NoAction(); - } - apply { - t.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/action_inline-last.p4 b/testdata/v1_samples_outputs/action_inline-last.p4 deleted file mode 100644 index 45924376997..00000000000 --- a/testdata/v1_samples_outputs/action_inline-last.p4 +++ /dev/null @@ -1,62 +0,0 @@ -#include "/home/cdodd/p4c/build/../p4include/core.p4" -#include "/home/cdodd/p4c/build/../p4include/v1model.p4" - -struct ht { - bit<1> b; -} - -struct metadata { - @name("md") - ht md; -} - -struct headers { -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("a") action a(inout bit<1> y0) { - y0 = y0 + 1w1; - } - @name("b") action b() { - a(meta.md.b); - a(meta.md.b); - } - @name("t") table t() { - actions = { - b; - NoAction; - } - default_action = NoAction(); - } - apply { - t.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/action_inline-midend.p4 b/testdata/v1_samples_outputs/action_inline-midend.p4 deleted file mode 100644 index cfc6385bcfa..00000000000 --- a/testdata/v1_samples_outputs/action_inline-midend.p4 +++ /dev/null @@ -1,61 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct ht { - bit<1> b; -} - -struct metadata { - @name("md") - ht md; -} - -struct headers { -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("b") action b_0() { - meta.md.b = meta.md.b + 1w1; - meta.md.b = meta.md.b + 1w1; - } - @name("t") table t_0() { - actions = { - b_0; - NoAction_0; - } - default_action = NoAction_0(); - } - apply { - t_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/action_inline.p4 b/testdata/v1_samples_outputs/action_inline.p4 index 45924376997..6547586fe34 100644 --- a/testdata/v1_samples_outputs/action_inline.p4 +++ b/testdata/v1_samples_outputs/action_inline.p4 @@ -1,5 +1,5 @@ -#include "/home/cdodd/p4c/build/../p4include/core.p4" -#include "/home/cdodd/p4c/build/../p4include/v1model.p4" +#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" +#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" struct ht { bit<1> b; diff --git a/testdata/v1_samples_outputs/action_inline1-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/action_inline1-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..3e1ac0bf389 --- /dev/null +++ b/testdata/v1_samples_outputs/action_inline1-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,196 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<16> h1; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setbyte") action setbyte(inout bit<8> dest, in bit<8> val) { + dest = val; + } + @name("setb1") action setb1(bit<8> val, bit<9> port) { + setbyte(hdr.data.b1, val); + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: ternary; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/action_inline1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/action_inline1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..ea573e2af5f --- /dev/null +++ b/testdata/v1_samples_outputs/action_inline1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,180 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<16> h1; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setbyte") action setbyte(inout bit<8> dest, in bit<8> val) { + dest = val; + } + @name("setb1") action setb1(bit<8> val, bit<9> port) { + setbyte(hdr.data.b1, val); + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: ternary; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/action_inline1-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/action_inline1-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..ffc671a3b86 --- /dev/null +++ b/testdata/v1_samples_outputs/action_inline1-MidEnd_25_Evaluator.p4 @@ -0,0 +1,177 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<16> h1; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("setb1") action setb1_0(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop_0() { + } + @name("test1") table test1_0() { + actions = { + setb1_0; + noop_0; + NoAction_0; + } + key = { + hdr.data.f1: ternary; + } + default_action = NoAction_0(); + } + apply { + test1_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/action_inline1-fe.p4 b/testdata/v1_samples_outputs/action_inline1-fe.p4 deleted file mode 100644 index 03195ecfc4a..00000000000 --- a/testdata/v1_samples_outputs/action_inline1-fe.p4 +++ /dev/null @@ -1,76 +0,0 @@ -#include "/home/cdodd/p4c/build/../p4include/core.p4" -#include "/home/cdodd/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<16> h1; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setbyte") action setbyte(inout bit<8> dest, in bit<8> val) { - dest = val; - } - @name("setb1") action setb1(bit<8> val, bit<9> port) { - setbyte(hdr.data.b1, val); - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: ternary; - } - default_action = NoAction(); - } - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/action_inline1-last.p4 b/testdata/v1_samples_outputs/action_inline1-last.p4 deleted file mode 100644 index 03195ecfc4a..00000000000 --- a/testdata/v1_samples_outputs/action_inline1-last.p4 +++ /dev/null @@ -1,76 +0,0 @@ -#include "/home/cdodd/p4c/build/../p4include/core.p4" -#include "/home/cdodd/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<16> h1; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setbyte") action setbyte(inout bit<8> dest, in bit<8> val) { - dest = val; - } - @name("setb1") action setb1(bit<8> val, bit<9> port) { - setbyte(hdr.data.b1, val); - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: ternary; - } - default_action = NoAction(); - } - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/action_inline1-midend.p4 b/testdata/v1_samples_outputs/action_inline1-midend.p4 deleted file mode 100644 index e82a23242b7..00000000000 --- a/testdata/v1_samples_outputs/action_inline1-midend.p4 +++ /dev/null @@ -1,75 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<16> h1; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("setb1") action setb1_0(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop_0() { - } - @name("test1") table test1_0() { - actions = { - setb1_0; - noop_0; - NoAction_0; - } - key = { - hdr.data.f1: ternary; - } - default_action = NoAction_0(); - } - apply { - test1_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/action_inline1.p4 b/testdata/v1_samples_outputs/action_inline1.p4 index 03195ecfc4a..def7ba951f9 100644 --- a/testdata/v1_samples_outputs/action_inline1.p4 +++ b/testdata/v1_samples_outputs/action_inline1.p4 @@ -1,5 +1,5 @@ -#include "/home/cdodd/p4c/build/../p4include/core.p4" -#include "/home/cdodd/p4c/build/../p4include/v1model.p4" +#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" +#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" header data_t { bit<32> f1; diff --git a/testdata/v1_samples_outputs/axon-last.p4 b/testdata/v1_samples_outputs/axon-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 58% rename from testdata/v1_samples_outputs/axon-last.p4 rename to testdata/v1_samples_outputs/axon-FrontEnd_11_SimplifyControlFlowE.p4 index 4d0b344d4eb..0a7118fb04c 100644 --- a/testdata/v1_samples_outputs/axon-last.p4 +++ b/testdata/v1_samples_outputs/axon-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct my_metadata_t { bit<8> fwdHopCount; bit<8> revHopCount; @@ -99,7 +219,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 1; default_action = NoAction(); } - @name("route_pkt") table route_pkt() { actions = { _drop; @@ -113,7 +232,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 1; default_action = NoAction(); } - apply { if (hdr.axon_head.axonLength != meta.my_metadata.headerLen) drop_pkt.apply(); diff --git a/testdata/v1_samples_outputs/axon-fe.p4 b/testdata/v1_samples_outputs/axon-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 63% rename from testdata/v1_samples_outputs/axon-fe.p4 rename to testdata/v1_samples_outputs/axon-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 4d0b344d4eb..55c89c607cb 100644 --- a/testdata/v1_samples_outputs/axon-fe.p4 +++ b/testdata/v1_samples_outputs/axon-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,111 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct my_metadata_t { bit<8> fwdHopCount; bit<8> revHopCount; @@ -99,7 +204,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 1; default_action = NoAction(); } - @name("route_pkt") table route_pkt() { actions = { _drop; @@ -113,7 +217,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 1; default_action = NoAction(); } - apply { if (hdr.axon_head.axonLength != meta.my_metadata.headerLen) drop_pkt.apply(); diff --git a/testdata/v1_samples_outputs/axon-midend.p4 b/testdata/v1_samples_outputs/axon-MidEnd_25_Evaluator.p4 similarity index 64% rename from testdata/v1_samples_outputs/axon-midend.p4 rename to testdata/v1_samples_outputs/axon-MidEnd_25_Evaluator.p4 index 14a24907585..743e802da92 100644 --- a/testdata/v1_samples_outputs/axon-midend.p4 +++ b/testdata/v1_samples_outputs/axon-MidEnd_25_Evaluator.p4 @@ -1,6 +1,109 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct my_metadata_t { bit<8> fwdHopCount; bit<8> revHopCount; diff --git a/testdata/v1_samples_outputs/axon.p4 b/testdata/v1_samples_outputs/axon.p4 index 6189910537d..9c2f1975667 100644 --- a/testdata/v1_samples_outputs/axon.p4 +++ b/testdata/v1_samples_outputs/axon.p4 @@ -99,7 +99,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 1; default_action = NoAction(); } - @name("route_pkt") table route_pkt() { actions = { _drop; @@ -113,7 +112,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 1; default_action = NoAction(); } - apply { if (hdr.axon_head.axonLength != meta.my_metadata.headerLen) { drop_pkt.apply(); diff --git a/testdata/v1_samples_outputs/basic_routing-last.p4 b/testdata/v1_samples_outputs/basic_routing-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 65% rename from testdata/v1_samples_outputs/basic_routing-last.p4 rename to testdata/v1_samples_outputs/basic_routing-FrontEnd_11_SimplifyControlFlowE.p4 index 352c38aa48e..b975881c430 100644 --- a/testdata/v1_samples_outputs/basic_routing-last.p4 +++ b/testdata/v1_samples_outputs/basic_routing-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<12> vrf; bit<16> bd; diff --git a/testdata/v1_samples_outputs/basic_routing-fe.p4 b/testdata/v1_samples_outputs/basic_routing-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 70% rename from testdata/v1_samples_outputs/basic_routing-fe.p4 rename to testdata/v1_samples_outputs/basic_routing-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 352c38aa48e..886685fb695 100644 --- a/testdata/v1_samples_outputs/basic_routing-fe.p4 +++ b/testdata/v1_samples_outputs/basic_routing-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<12> vrf; bit<16> bd; diff --git a/testdata/v1_samples_outputs/basic_routing-midend.p4 b/testdata/v1_samples_outputs/basic_routing-MidEnd_25_Evaluator.p4 similarity index 73% rename from testdata/v1_samples_outputs/basic_routing-midend.p4 rename to testdata/v1_samples_outputs/basic_routing-MidEnd_25_Evaluator.p4 index 17a4a051b00..54f5f1c6a34 100644 --- a/testdata/v1_samples_outputs/basic_routing-midend.p4 +++ b/testdata/v1_samples_outputs/basic_routing-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<12> vrf; bit<16> bd; diff --git a/testdata/v1_samples_outputs/checksum1-last.p4 b/testdata/v1_samples_outputs/checksum1-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 54% rename from testdata/v1_samples_outputs/checksum1-last.p4 rename to testdata/v1_samples_outputs/checksum1-FrontEnd_11_SimplifyControlFlowE.p4 index 5dd2d0b1945..cf295807643 100644 --- a/testdata/v1_samples_outputs/checksum1-last.p4 +++ b/testdata/v1_samples_outputs/checksum1-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; @@ -87,7 +207,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("setup") table setup() { actions = { do_setup; @@ -98,7 +217,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { setup.apply(); route.apply(); diff --git a/testdata/v1_samples_outputs/checksum1-fe.p4 b/testdata/v1_samples_outputs/checksum1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 60% rename from testdata/v1_samples_outputs/checksum1-fe.p4 rename to testdata/v1_samples_outputs/checksum1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 5dd2d0b1945..d290951d131 100644 --- a/testdata/v1_samples_outputs/checksum1-fe.p4 +++ b/testdata/v1_samples_outputs/checksum1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; @@ -87,7 +191,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("setup") table setup() { actions = { do_setup; @@ -98,7 +201,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { setup.apply(); route.apply(); diff --git a/testdata/v1_samples_outputs/checksum1-midend.p4 b/testdata/v1_samples_outputs/checksum1-MidEnd_25_Evaluator.p4 similarity index 63% rename from testdata/v1_samples_outputs/checksum1-midend.p4 rename to testdata/v1_samples_outputs/checksum1-MidEnd_25_Evaluator.p4 index 77a97e7ab17..00320be7534 100644 --- a/testdata/v1_samples_outputs/checksum1-midend.p4 +++ b/testdata/v1_samples_outputs/checksum1-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; diff --git a/testdata/v1_samples_outputs/checksum1.p4 b/testdata/v1_samples_outputs/checksum1.p4 index 1a6aaf7a6c4..64ab539d232 100644 --- a/testdata/v1_samples_outputs/checksum1.p4 +++ b/testdata/v1_samples_outputs/checksum1.p4 @@ -87,7 +87,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("setup") table setup() { actions = { do_setup; @@ -98,7 +97,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { setup.apply(); route.apply(); diff --git a/testdata/v1_samples_outputs/copy_to_cpu-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/copy_to_cpu-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..a3e1620f27a --- /dev/null +++ b/testdata/v1_samples_outputs/copy_to_cpu-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,231 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct intrinsic_metadata_t { + bit<4> mcast_grp; + bit<4> egress_rid; + bit<16> mcast_hash; + bit<32> lf_field_list; +} + +header cpu_header_t { + bit<8> device; + bit<8> reason; +} + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +struct metadata { + @name("intrinsic_metadata") + intrinsic_metadata_t intrinsic_metadata; +} + +struct headers { + @name("cpu_header") + cpu_header_t cpu_header; + @name("ethernet") + ethernet_t ethernet; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_cpu_header") state parse_cpu_header { + packet.extract(hdr.cpu_header); + transition parse_ethernet; + } + @name("parse_ethernet") state parse_ethernet { + packet.extract(hdr.ethernet); + transition accept; + } + @name("start") state start { + transition select(packet.lookahead>()[63:0]) { + 64w0: parse_cpu_header; + default: parse_ethernet; + } + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("_drop") action _drop() { + mark_to_drop(); + } + @name("do_cpu_encap") action do_cpu_encap() { + hdr.cpu_header.setValid(true); + hdr.cpu_header.device = 8w0; + hdr.cpu_header.reason = 8w0xab; + } + @name("redirect") table redirect() { + actions = { + _drop; + do_cpu_encap; + NoAction; + } + key = { + standard_metadata.instance_type: exact; + } + size = 16; + default_action = NoAction(); + } + apply { + redirect.apply(); + } +} + +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 }); + } + @name("copy_to_cpu") table copy_to_cpu() { + actions = { + do_copy_to_cpu; + NoAction; + } + size = 1; + default_action = NoAction(); + } + apply { + copy_to_cpu.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.cpu_header); + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/copy_to_cpu-fe.p4 b/testdata/v1_samples_outputs/copy_to_cpu-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 52% rename from testdata/v1_samples_outputs/copy_to_cpu-fe.p4 rename to testdata/v1_samples_outputs/copy_to_cpu-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 32282d3cd3f..7543b42ff5a 100644 --- a/testdata/v1_samples_outputs/copy_to_cpu-fe.p4 +++ b/testdata/v1_samples_outputs/copy_to_cpu-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,117 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; @@ -69,7 +180,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t size = 16; default_action = NoAction(); } - apply { redirect.apply(); } @@ -87,7 +197,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 1; default_action = NoAction(); } - apply { copy_to_cpu.apply(); } diff --git a/testdata/v1_samples_outputs/copy_to_cpu-midend.p4 b/testdata/v1_samples_outputs/copy_to_cpu-MidEnd_25_Evaluator.p4 similarity index 53% rename from testdata/v1_samples_outputs/copy_to_cpu-midend.p4 rename to testdata/v1_samples_outputs/copy_to_cpu-MidEnd_25_Evaluator.p4 index 13b7390c9dc..f123cd65d45 100644 --- a/testdata/v1_samples_outputs/copy_to_cpu-midend.p4 +++ b/testdata/v1_samples_outputs/copy_to_cpu-MidEnd_25_Evaluator.p4 @@ -1,6 +1,115 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; diff --git a/testdata/v1_samples_outputs/copy_to_cpu-last.p4 b/testdata/v1_samples_outputs/copy_to_cpu-last.p4 deleted file mode 100644 index 32282d3cd3f..00000000000 --- a/testdata/v1_samples_outputs/copy_to_cpu-last.p4 +++ /dev/null @@ -1,113 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct intrinsic_metadata_t { - bit<4> mcast_grp; - bit<4> egress_rid; - bit<16> mcast_hash; - bit<32> lf_field_list; -} - -header cpu_header_t { - bit<8> device; - bit<8> reason; -} - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> etherType; -} - -struct metadata { - @name("intrinsic_metadata") - intrinsic_metadata_t intrinsic_metadata; -} - -struct headers { - @name("cpu_header") - cpu_header_t cpu_header; - @name("ethernet") - ethernet_t ethernet; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("parse_cpu_header") state parse_cpu_header { - packet.extract(hdr.cpu_header); - transition parse_ethernet; - } - @name("parse_ethernet") state parse_ethernet { - packet.extract(hdr.ethernet); - transition accept; - } - @name("start") state start { - transition select(packet.lookahead>()[63:0]) { - 64w0: parse_cpu_header; - default: parse_ethernet; - } - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("_drop") action _drop() { - mark_to_drop(); - } - @name("do_cpu_encap") action do_cpu_encap() { - hdr.cpu_header.setValid(true); - hdr.cpu_header.device = 8w0; - hdr.cpu_header.reason = 8w0xab; - } - @name("redirect") table redirect() { - actions = { - _drop; - do_cpu_encap; - NoAction; - } - key = { - standard_metadata.instance_type: exact; - } - size = 16; - default_action = NoAction(); - } - - apply { - redirect.apply(); - } -} - -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 }); - } - @name("copy_to_cpu") table copy_to_cpu() { - actions = { - do_copy_to_cpu; - NoAction; - } - size = 1; - default_action = NoAction(); - } - - apply { - copy_to_cpu.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.cpu_header); - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/copy_to_cpu.p4 b/testdata/v1_samples_outputs/copy_to_cpu.p4 index 193afde2e19..d83bad953f7 100644 --- a/testdata/v1_samples_outputs/copy_to_cpu.p4 +++ b/testdata/v1_samples_outputs/copy_to_cpu.p4 @@ -69,7 +69,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t size = 16; default_action = NoAction(); } - apply { redirect.apply(); } @@ -87,7 +86,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 1; default_action = NoAction(); } - apply { copy_to_cpu.apply(); } diff --git a/testdata/v1_samples_outputs/counter-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/counter-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..7d0d1455ddd --- /dev/null +++ b/testdata/v1_samples_outputs/counter-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,210 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct intrinsic_metadata_t { + bit<4> mcast_grp; + bit<4> egress_rid; + bit<16> mcast_hash; + bit<32> lf_field_list; +} + +struct meta_t { + bit<32> register_tmp; +} + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +struct metadata { + @name("intrinsic_metadata") + intrinsic_metadata_t intrinsic_metadata; + @name("meta") + meta_t meta; +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +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 accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + Counter(32w16384, CounterType.Packets) @name("my_indirect_counter") my_indirect_counter; + @name("m_action") action m_action(bit<8> idx) { + my_indirect_counter.increment((bit<32>)idx); + mark_to_drop(); + } + @name("_nop") action _nop() { + } + @name("m_table") table m_table() { + actions = { + m_action; + _nop; + NoAction; + } + key = { + hdr.ethernet.srcAddr: exact; + } + size = 16384; + default_action = NoAction(); + @name("my_direct_counter") counters = DirectCounter(CounterType.Bytes); + } + apply { + m_table.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/counter-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..d87e96f33ac --- /dev/null +++ b/testdata/v1_samples_outputs/counter-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,195 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct intrinsic_metadata_t { + bit<4> mcast_grp; + bit<4> egress_rid; + bit<16> mcast_hash; + bit<32> lf_field_list; +} + +struct meta_t { + bit<32> register_tmp; +} + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +struct metadata { + @name("intrinsic_metadata") + intrinsic_metadata_t intrinsic_metadata; + @name("meta") + meta_t meta; +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +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 accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + Counter(32w16384, CounterType.Packets) @name("my_indirect_counter") my_indirect_counter; + @name("m_action") action m_action(bit<8> idx) { + my_indirect_counter.increment((bit<32>)idx); + mark_to_drop(); + } + @name("_nop") action _nop() { + } + @name("m_table") table m_table() { + actions = { + m_action; + _nop; + NoAction; + } + key = { + hdr.ethernet.srcAddr: exact; + } + size = 16384; + default_action = NoAction(); + @name("my_direct_counter") counters = DirectCounter(CounterType.Bytes); + } + apply { + m_table.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/counter-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..47d86255679 --- /dev/null +++ b/testdata/v1_samples_outputs/counter-MidEnd_25_Evaluator.p4 @@ -0,0 +1,195 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct intrinsic_metadata_t { + bit<4> mcast_grp; + bit<4> egress_rid; + bit<16> mcast_hash; + bit<32> lf_field_list; +} + +struct meta_t { + bit<32> register_tmp; +} + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +struct metadata { + @name("intrinsic_metadata") + intrinsic_metadata_t intrinsic_metadata; + @name("meta") + meta_t meta; +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +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 accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + Counter(32w16384, CounterType.Packets) @name("my_indirect_counter") my_indirect_counter_0; + @name("m_action") action m_action_0(bit<8> idx) { + my_indirect_counter_0.increment((bit<32>)idx); + mark_to_drop(); + } + @name("_nop") action _nop_0() { + } + @name("m_table") table m_table_0() { + actions = { + m_action_0; + _nop_0; + NoAction_0; + } + key = { + hdr.ethernet.srcAddr: exact; + } + size = 16384; + default_action = NoAction_0(); + @name("my_direct_counter") counters = DirectCounter(CounterType.Bytes); + } + apply { + m_table_0.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter-fe.p4 b/testdata/v1_samples_outputs/counter-fe.p4 deleted file mode 100644 index 0d086c2e583..00000000000 --- a/testdata/v1_samples_outputs/counter-fe.p4 +++ /dev/null @@ -1,91 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct intrinsic_metadata_t { - bit<4> mcast_grp; - bit<4> egress_rid; - bit<16> mcast_hash; - bit<32> lf_field_list; -} - -struct meta_t { - bit<32> register_tmp; -} - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> etherType; -} - -struct metadata { - @name("intrinsic_metadata") - intrinsic_metadata_t intrinsic_metadata; - @name("meta") - meta_t meta; -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -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 accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - Counter(32w16384, CounterType.Packets) @name("my_indirect_counter") my_indirect_counter; - @name("m_action") action m_action(bit<8> idx) { - my_indirect_counter.increment((bit<32>)idx); - mark_to_drop(); - } - @name("_nop") action _nop() { - } - @name("m_table") table m_table() { - actions = { - m_action; - _nop; - NoAction; - } - key = { - hdr.ethernet.srcAddr: exact; - } - size = 16384; - default_action = NoAction(); - @name("my_direct_counter") counters = DirectCounter(CounterType.Bytes); - } - - apply { - m_table.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter-last.p4 b/testdata/v1_samples_outputs/counter-last.p4 deleted file mode 100644 index 0d086c2e583..00000000000 --- a/testdata/v1_samples_outputs/counter-last.p4 +++ /dev/null @@ -1,91 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct intrinsic_metadata_t { - bit<4> mcast_grp; - bit<4> egress_rid; - bit<16> mcast_hash; - bit<32> lf_field_list; -} - -struct meta_t { - bit<32> register_tmp; -} - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> etherType; -} - -struct metadata { - @name("intrinsic_metadata") - intrinsic_metadata_t intrinsic_metadata; - @name("meta") - meta_t meta; -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -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 accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - Counter(32w16384, CounterType.Packets) @name("my_indirect_counter") my_indirect_counter; - @name("m_action") action m_action(bit<8> idx) { - my_indirect_counter.increment((bit<32>)idx); - mark_to_drop(); - } - @name("_nop") action _nop() { - } - @name("m_table") table m_table() { - actions = { - m_action; - _nop; - NoAction; - } - key = { - hdr.ethernet.srcAddr: exact; - } - size = 16384; - default_action = NoAction(); - @name("my_direct_counter") counters = DirectCounter(CounterType.Bytes); - } - - apply { - m_table.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter-midend.p4 b/testdata/v1_samples_outputs/counter-midend.p4 deleted file mode 100644 index 97ad245b584..00000000000 --- a/testdata/v1_samples_outputs/counter-midend.p4 +++ /dev/null @@ -1,92 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct intrinsic_metadata_t { - bit<4> mcast_grp; - bit<4> egress_rid; - bit<16> mcast_hash; - bit<32> lf_field_list; -} - -struct meta_t { - bit<32> register_tmp; -} - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> etherType; -} - -struct metadata { - @name("intrinsic_metadata") - intrinsic_metadata_t intrinsic_metadata; - @name("meta") - meta_t meta; -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -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 accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - Counter(32w16384, CounterType.Packets) @name("my_indirect_counter") my_indirect_counter_0; - @name("m_action") action m_action_0(bit<8> idx) { - my_indirect_counter_0.increment((bit<32>)idx); - mark_to_drop(); - } - @name("_nop") action _nop_0() { - } - @name("m_table") table m_table_0() { - actions = { - m_action_0; - _nop_0; - NoAction_0; - } - key = { - hdr.ethernet.srcAddr: exact; - } - size = 16384; - default_action = NoAction_0(); - @name("my_direct_counter") counters = DirectCounter(CounterType.Bytes); - } - apply { - m_table_0.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter.p4 b/testdata/v1_samples_outputs/counter.p4 index 0d086c2e583..f1f961fd472 100644 --- a/testdata/v1_samples_outputs/counter.p4 +++ b/testdata/v1_samples_outputs/counter.p4 @@ -66,7 +66,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ default_action = NoAction(); @name("my_direct_counter") counters = DirectCounter(CounterType.Bytes); } - apply { m_table.apply(); } diff --git a/testdata/v1_samples_outputs/counter1-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/counter1-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..ada28422972 --- /dev/null +++ b/testdata/v1_samples_outputs/counter1-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,188 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +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 accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("act") action act(bit<48> idx) { + hdr.ethernet.dstAddr = idx; + } + @name("tab1") table tab1() { + actions = { + act; + NoAction; + } + key = { + hdr.ethernet.dstAddr: exact; + } + size = 128; + default_action = NoAction(); + @name("cnt") counters = DirectCounter(CounterType.Packets); + } + apply { + tab1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/counter1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..bc7a030b978 --- /dev/null +++ b/testdata/v1_samples_outputs/counter1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,172 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +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 accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("act") action act(bit<48> idx) { + hdr.ethernet.dstAddr = idx; + } + @name("tab1") table tab1() { + actions = { + act; + NoAction; + } + key = { + hdr.ethernet.dstAddr: exact; + } + size = 128; + default_action = NoAction(); + @name("cnt") counters = DirectCounter(CounterType.Packets); + } + apply { + tab1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter1-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/counter1-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..5b62aecaab7 --- /dev/null +++ b/testdata/v1_samples_outputs/counter1-MidEnd_25_Evaluator.p4 @@ -0,0 +1,172 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +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 accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("act") action act_0(bit<48> idx) { + hdr.ethernet.dstAddr = idx; + } + @name("tab1") table tab1_0() { + actions = { + act_0; + NoAction_0; + } + key = { + hdr.ethernet.dstAddr: exact; + } + size = 128; + default_action = NoAction_0(); + @name("cnt") counters = DirectCounter(CounterType.Packets); + } + apply { + tab1_0.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter1-fe.p4 b/testdata/v1_samples_outputs/counter1-fe.p4 deleted file mode 100644 index cbfee48a63f..00000000000 --- a/testdata/v1_samples_outputs/counter1-fe.p4 +++ /dev/null @@ -1,69 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -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 accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("act") action act(bit<48> idx) { - hdr.ethernet.dstAddr = idx; - } - @name("tab1") table tab1() { - actions = { - act; - NoAction; - } - key = { - hdr.ethernet.dstAddr: exact; - } - size = 128; - default_action = NoAction(); - @name("cnt") counters = DirectCounter(CounterType.Packets); - } - - apply { - tab1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter1-last.p4 b/testdata/v1_samples_outputs/counter1-last.p4 deleted file mode 100644 index cbfee48a63f..00000000000 --- a/testdata/v1_samples_outputs/counter1-last.p4 +++ /dev/null @@ -1,69 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -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 accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("act") action act(bit<48> idx) { - hdr.ethernet.dstAddr = idx; - } - @name("tab1") table tab1() { - actions = { - act; - NoAction; - } - key = { - hdr.ethernet.dstAddr: exact; - } - size = 128; - default_action = NoAction(); - @name("cnt") counters = DirectCounter(CounterType.Packets); - } - - apply { - tab1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter1-midend.p4 b/testdata/v1_samples_outputs/counter1-midend.p4 deleted file mode 100644 index 70a3f7557cc..00000000000 --- a/testdata/v1_samples_outputs/counter1-midend.p4 +++ /dev/null @@ -1,70 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -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 accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("act") action act_0(bit<48> idx) { - hdr.ethernet.dstAddr = idx; - } - @name("tab1") table tab1_0() { - actions = { - act_0; - NoAction_0; - } - key = { - hdr.ethernet.dstAddr: exact; - } - size = 128; - default_action = NoAction_0(); - @name("cnt") counters = DirectCounter(CounterType.Packets); - } - apply { - tab1_0.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter1.p4 b/testdata/v1_samples_outputs/counter1.p4 index cbfee48a63f..616235861a6 100644 --- a/testdata/v1_samples_outputs/counter1.p4 +++ b/testdata/v1_samples_outputs/counter1.p4 @@ -44,7 +44,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ default_action = NoAction(); @name("cnt") counters = DirectCounter(CounterType.Packets); } - apply { tab1.apply(); } diff --git a/testdata/v1_samples_outputs/counter2-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/counter2-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..a25aadc5a24 --- /dev/null +++ b/testdata/v1_samples_outputs/counter2-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,188 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +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 accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("act") action act(bit<48> idx) { + hdr.ethernet.dstAddr = idx; + } + @name("tab1") table tab1() { + actions = { + act; + NoAction; + } + key = { + hdr.ethernet.dstAddr: ternary; + } + size = 128; + default_action = NoAction(); + @name("cnt") counters = DirectCounter(CounterType.Packets); + } + apply { + tab1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/counter2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..309260fef4e --- /dev/null +++ b/testdata/v1_samples_outputs/counter2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,172 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +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 accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("act") action act(bit<48> idx) { + hdr.ethernet.dstAddr = idx; + } + @name("tab1") table tab1() { + actions = { + act; + NoAction; + } + key = { + hdr.ethernet.dstAddr: ternary; + } + size = 128; + default_action = NoAction(); + @name("cnt") counters = DirectCounter(CounterType.Packets); + } + apply { + tab1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter2-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/counter2-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..0db633256a1 --- /dev/null +++ b/testdata/v1_samples_outputs/counter2-MidEnd_25_Evaluator.p4 @@ -0,0 +1,172 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +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 accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("act") action act_0(bit<48> idx) { + hdr.ethernet.dstAddr = idx; + } + @name("tab1") table tab1_0() { + actions = { + act_0; + NoAction_0; + } + key = { + hdr.ethernet.dstAddr: ternary; + } + size = 128; + default_action = NoAction_0(); + @name("cnt") counters = DirectCounter(CounterType.Packets); + } + apply { + tab1_0.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter2-fe.p4 b/testdata/v1_samples_outputs/counter2-fe.p4 deleted file mode 100644 index 3b63b106aec..00000000000 --- a/testdata/v1_samples_outputs/counter2-fe.p4 +++ /dev/null @@ -1,69 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -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 accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("act") action act(bit<48> idx) { - hdr.ethernet.dstAddr = idx; - } - @name("tab1") table tab1() { - actions = { - act; - NoAction; - } - key = { - hdr.ethernet.dstAddr: ternary; - } - size = 128; - default_action = NoAction(); - @name("cnt") counters = DirectCounter(CounterType.Packets); - } - - apply { - tab1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter2-last.p4 b/testdata/v1_samples_outputs/counter2-last.p4 deleted file mode 100644 index 3b63b106aec..00000000000 --- a/testdata/v1_samples_outputs/counter2-last.p4 +++ /dev/null @@ -1,69 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -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 accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("act") action act(bit<48> idx) { - hdr.ethernet.dstAddr = idx; - } - @name("tab1") table tab1() { - actions = { - act; - NoAction; - } - key = { - hdr.ethernet.dstAddr: ternary; - } - size = 128; - default_action = NoAction(); - @name("cnt") counters = DirectCounter(CounterType.Packets); - } - - apply { - tab1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter2-midend.p4 b/testdata/v1_samples_outputs/counter2-midend.p4 deleted file mode 100644 index 31c99aec886..00000000000 --- a/testdata/v1_samples_outputs/counter2-midend.p4 +++ /dev/null @@ -1,70 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -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 accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("act") action act_0(bit<48> idx) { - hdr.ethernet.dstAddr = idx; - } - @name("tab1") table tab1_0() { - actions = { - act_0; - NoAction_0; - } - key = { - hdr.ethernet.dstAddr: ternary; - } - size = 128; - default_action = NoAction_0(); - @name("cnt") counters = DirectCounter(CounterType.Packets); - } - apply { - tab1_0.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter2.p4 b/testdata/v1_samples_outputs/counter2.p4 index 3b63b106aec..8519afd5582 100644 --- a/testdata/v1_samples_outputs/counter2.p4 +++ b/testdata/v1_samples_outputs/counter2.p4 @@ -44,7 +44,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ default_action = NoAction(); @name("cnt") counters = DirectCounter(CounterType.Packets); } - apply { tab1.apply(); } diff --git a/testdata/v1_samples_outputs/counter3-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/counter3-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..ada28422972 --- /dev/null +++ b/testdata/v1_samples_outputs/counter3-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,188 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +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 accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("act") action act(bit<48> idx) { + hdr.ethernet.dstAddr = idx; + } + @name("tab1") table tab1() { + actions = { + act; + NoAction; + } + key = { + hdr.ethernet.dstAddr: exact; + } + size = 128; + default_action = NoAction(); + @name("cnt") counters = DirectCounter(CounterType.Packets); + } + apply { + tab1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/counter3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..bc7a030b978 --- /dev/null +++ b/testdata/v1_samples_outputs/counter3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,172 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +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 accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("act") action act(bit<48> idx) { + hdr.ethernet.dstAddr = idx; + } + @name("tab1") table tab1() { + actions = { + act; + NoAction; + } + key = { + hdr.ethernet.dstAddr: exact; + } + size = 128; + default_action = NoAction(); + @name("cnt") counters = DirectCounter(CounterType.Packets); + } + apply { + tab1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter3-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/counter3-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..5b62aecaab7 --- /dev/null +++ b/testdata/v1_samples_outputs/counter3-MidEnd_25_Evaluator.p4 @@ -0,0 +1,172 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +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 accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("act") action act_0(bit<48> idx) { + hdr.ethernet.dstAddr = idx; + } + @name("tab1") table tab1_0() { + actions = { + act_0; + NoAction_0; + } + key = { + hdr.ethernet.dstAddr: exact; + } + size = 128; + default_action = NoAction_0(); + @name("cnt") counters = DirectCounter(CounterType.Packets); + } + apply { + tab1_0.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter3-fe.p4 b/testdata/v1_samples_outputs/counter3-fe.p4 deleted file mode 100644 index cbfee48a63f..00000000000 --- a/testdata/v1_samples_outputs/counter3-fe.p4 +++ /dev/null @@ -1,69 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -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 accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("act") action act(bit<48> idx) { - hdr.ethernet.dstAddr = idx; - } - @name("tab1") table tab1() { - actions = { - act; - NoAction; - } - key = { - hdr.ethernet.dstAddr: exact; - } - size = 128; - default_action = NoAction(); - @name("cnt") counters = DirectCounter(CounterType.Packets); - } - - apply { - tab1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter3-last.p4 b/testdata/v1_samples_outputs/counter3-last.p4 deleted file mode 100644 index cbfee48a63f..00000000000 --- a/testdata/v1_samples_outputs/counter3-last.p4 +++ /dev/null @@ -1,69 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -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 accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("act") action act(bit<48> idx) { - hdr.ethernet.dstAddr = idx; - } - @name("tab1") table tab1() { - actions = { - act; - NoAction; - } - key = { - hdr.ethernet.dstAddr: exact; - } - size = 128; - default_action = NoAction(); - @name("cnt") counters = DirectCounter(CounterType.Packets); - } - - apply { - tab1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter3-midend.p4 b/testdata/v1_samples_outputs/counter3-midend.p4 deleted file mode 100644 index 70a3f7557cc..00000000000 --- a/testdata/v1_samples_outputs/counter3-midend.p4 +++ /dev/null @@ -1,70 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -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 accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("act") action act_0(bit<48> idx) { - hdr.ethernet.dstAddr = idx; - } - @name("tab1") table tab1_0() { - actions = { - act_0; - NoAction_0; - } - key = { - hdr.ethernet.dstAddr: exact; - } - size = 128; - default_action = NoAction_0(); - @name("cnt") counters = DirectCounter(CounterType.Packets); - } - apply { - tab1_0.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter3.p4 b/testdata/v1_samples_outputs/counter3.p4 index cbfee48a63f..616235861a6 100644 --- a/testdata/v1_samples_outputs/counter3.p4 +++ b/testdata/v1_samples_outputs/counter3.p4 @@ -44,7 +44,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ default_action = NoAction(); @name("cnt") counters = DirectCounter(CounterType.Packets); } - apply { tab1.apply(); } diff --git a/testdata/v1_samples_outputs/counter4-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/counter4-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..919a0ee092e --- /dev/null +++ b/testdata/v1_samples_outputs/counter4-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,189 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +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 accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + Counter(32w200, CounterType.Packets) @name("cntDum") cntDum; + @name("act") action act(bit<48> idx) { + hdr.ethernet.dstAddr = idx; + cntDum.increment((bit<32>)idx); + } + @name("tab1") table tab1() { + actions = { + act; + NoAction; + } + key = { + hdr.ethernet.dstAddr: exact; + } + size = 70000; + default_action = NoAction(); + } + apply { + tab1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/counter4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..7db954ef1b4 --- /dev/null +++ b/testdata/v1_samples_outputs/counter4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,173 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +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 accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + Counter(32w200, CounterType.Packets) @name("cntDum") cntDum; + @name("act") action act(bit<48> idx) { + hdr.ethernet.dstAddr = idx; + cntDum.increment((bit<32>)idx); + } + @name("tab1") table tab1() { + actions = { + act; + NoAction; + } + key = { + hdr.ethernet.dstAddr: exact; + } + size = 70000; + default_action = NoAction(); + } + apply { + tab1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter4-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/counter4-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..c2e86bfe456 --- /dev/null +++ b/testdata/v1_samples_outputs/counter4-MidEnd_25_Evaluator.p4 @@ -0,0 +1,173 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +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 accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + Counter(32w200, CounterType.Packets) @name("cntDum") cntDum_0; + @name("act") action act_0(bit<48> idx) { + hdr.ethernet.dstAddr = idx; + cntDum_0.increment((bit<32>)idx); + } + @name("tab1") table tab1_0() { + actions = { + act_0; + NoAction_0; + } + key = { + hdr.ethernet.dstAddr: exact; + } + size = 70000; + default_action = NoAction_0(); + } + apply { + tab1_0.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter4-fe.p4 b/testdata/v1_samples_outputs/counter4-fe.p4 deleted file mode 100644 index e0be0ab2a1f..00000000000 --- a/testdata/v1_samples_outputs/counter4-fe.p4 +++ /dev/null @@ -1,70 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -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 accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - Counter(32w200, CounterType.Packets) @name("cntDum") cntDum; - @name("act") action act(bit<48> idx) { - hdr.ethernet.dstAddr = idx; - cntDum.increment((bit<32>)idx); - } - @name("tab1") table tab1() { - actions = { - act; - NoAction; - } - key = { - hdr.ethernet.dstAddr: exact; - } - size = 70000; - default_action = NoAction(); - } - - apply { - tab1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter4-last.p4 b/testdata/v1_samples_outputs/counter4-last.p4 deleted file mode 100644 index e0be0ab2a1f..00000000000 --- a/testdata/v1_samples_outputs/counter4-last.p4 +++ /dev/null @@ -1,70 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -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 accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - Counter(32w200, CounterType.Packets) @name("cntDum") cntDum; - @name("act") action act(bit<48> idx) { - hdr.ethernet.dstAddr = idx; - cntDum.increment((bit<32>)idx); - } - @name("tab1") table tab1() { - actions = { - act; - NoAction; - } - key = { - hdr.ethernet.dstAddr: exact; - } - size = 70000; - default_action = NoAction(); - } - - apply { - tab1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter4-midend.p4 b/testdata/v1_samples_outputs/counter4-midend.p4 deleted file mode 100644 index a828213c5de..00000000000 --- a/testdata/v1_samples_outputs/counter4-midend.p4 +++ /dev/null @@ -1,71 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -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 accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - Counter(32w200, CounterType.Packets) @name("cntDum") cntDum_0; - @name("act") action act_0(bit<48> idx) { - hdr.ethernet.dstAddr = idx; - cntDum_0.increment((bit<32>)idx); - } - @name("tab1") table tab1_0() { - actions = { - act_0; - NoAction_0; - } - key = { - hdr.ethernet.dstAddr: exact; - } - size = 70000; - default_action = NoAction_0(); - } - apply { - tab1_0.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter4.p4 b/testdata/v1_samples_outputs/counter4.p4 index e0be0ab2a1f..31ddd7a8d84 100644 --- a/testdata/v1_samples_outputs/counter4.p4 +++ b/testdata/v1_samples_outputs/counter4.p4 @@ -45,7 +45,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 70000; default_action = NoAction(); } - apply { tab1.apply(); } diff --git a/testdata/v1_samples_outputs/counter5-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/counter5-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..5cd48c35877 --- /dev/null +++ b/testdata/v1_samples_outputs/counter5-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,188 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +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 accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + Counter(32w70000, CounterType.Packets) @name("cntDum") cntDum; + @name("act") action act(bit<8> idx) { + cntDum.increment((bit<32>)idx); + } + @name("tab1") table tab1() { + actions = { + act; + NoAction; + } + key = { + hdr.ethernet.dstAddr: exact; + } + size = 160000; + default_action = NoAction(); + } + apply { + tab1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter5-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/counter5-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..c31e16ec576 --- /dev/null +++ b/testdata/v1_samples_outputs/counter5-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,172 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +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 accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + Counter(32w70000, CounterType.Packets) @name("cntDum") cntDum; + @name("act") action act(bit<8> idx) { + cntDum.increment((bit<32>)idx); + } + @name("tab1") table tab1() { + actions = { + act; + NoAction; + } + key = { + hdr.ethernet.dstAddr: exact; + } + size = 160000; + default_action = NoAction(); + } + apply { + tab1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter5-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/counter5-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..b7b1358b708 --- /dev/null +++ b/testdata/v1_samples_outputs/counter5-MidEnd_25_Evaluator.p4 @@ -0,0 +1,172 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +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 accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + Counter(32w70000, CounterType.Packets) @name("cntDum") cntDum_0; + @name("act") action act_0(bit<8> idx) { + cntDum_0.increment((bit<32>)idx); + } + @name("tab1") table tab1_0() { + actions = { + act_0; + NoAction_0; + } + key = { + hdr.ethernet.dstAddr: exact; + } + size = 160000; + default_action = NoAction_0(); + } + apply { + tab1_0.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter5-fe.p4 b/testdata/v1_samples_outputs/counter5-fe.p4 deleted file mode 100644 index 7fc0a006918..00000000000 --- a/testdata/v1_samples_outputs/counter5-fe.p4 +++ /dev/null @@ -1,69 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -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 accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - Counter(32w70000, CounterType.Packets) @name("cntDum") cntDum; - @name("act") action act(bit<8> idx) { - cntDum.increment((bit<32>)idx); - } - @name("tab1") table tab1() { - actions = { - act; - NoAction; - } - key = { - hdr.ethernet.dstAddr: exact; - } - size = 160000; - default_action = NoAction(); - } - - apply { - tab1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter5-last.p4 b/testdata/v1_samples_outputs/counter5-last.p4 deleted file mode 100644 index 7fc0a006918..00000000000 --- a/testdata/v1_samples_outputs/counter5-last.p4 +++ /dev/null @@ -1,69 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -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 accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - Counter(32w70000, CounterType.Packets) @name("cntDum") cntDum; - @name("act") action act(bit<8> idx) { - cntDum.increment((bit<32>)idx); - } - @name("tab1") table tab1() { - actions = { - act; - NoAction; - } - key = { - hdr.ethernet.dstAddr: exact; - } - size = 160000; - default_action = NoAction(); - } - - apply { - tab1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter5-midend.p4 b/testdata/v1_samples_outputs/counter5-midend.p4 deleted file mode 100644 index cdf96ba8160..00000000000 --- a/testdata/v1_samples_outputs/counter5-midend.p4 +++ /dev/null @@ -1,70 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -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 accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - Counter(32w70000, CounterType.Packets) @name("cntDum") cntDum_0; - @name("act") action act_0(bit<8> idx) { - cntDum_0.increment((bit<32>)idx); - } - @name("tab1") table tab1_0() { - actions = { - act_0; - NoAction_0; - } - key = { - hdr.ethernet.dstAddr: exact; - } - size = 160000; - default_action = NoAction_0(); - } - apply { - tab1_0.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/counter5.p4 b/testdata/v1_samples_outputs/counter5.p4 index 7fc0a006918..a19a7e94d17 100644 --- a/testdata/v1_samples_outputs/counter5.p4 +++ b/testdata/v1_samples_outputs/counter5.p4 @@ -44,7 +44,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 160000; default_action = NoAction(); } - apply { tab1.apply(); } diff --git a/testdata/v1_samples_outputs/do_nothing-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/do_nothing-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..47870ec9a2b --- /dev/null +++ b/testdata/v1_samples_outputs/do_nothing-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,187 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +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 accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("action_0") action action_0() { + } + @name("table_0") table table_0() { + actions = { + action_0; + NoAction; + } + key = { + hdr.ethernet.etherType: ternary; + } + default_action = NoAction(); + } + apply { + table_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/do_nothing-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/do_nothing-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..5d902dd8eb2 --- /dev/null +++ b/testdata/v1_samples_outputs/do_nothing-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,171 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +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 accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("action_0") action action_0() { + } + @name("table_0") table table_0() { + actions = { + action_0; + NoAction; + } + key = { + hdr.ethernet.etherType: ternary; + } + default_action = NoAction(); + } + apply { + table_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/do_nothing-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/do_nothing-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..5b6d778f773 --- /dev/null +++ b/testdata/v1_samples_outputs/do_nothing-MidEnd_25_Evaluator.p4 @@ -0,0 +1,171 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +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 accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("action_0") action action() { + } + @name("table_0") table table() { + actions = { + action; + NoAction_0; + } + key = { + hdr.ethernet.etherType: ternary; + } + default_action = NoAction_0(); + } + apply { + table.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/do_nothing-fe.p4 b/testdata/v1_samples_outputs/do_nothing-fe.p4 deleted file mode 100644 index b552d1cd7a2..00000000000 --- a/testdata/v1_samples_outputs/do_nothing-fe.p4 +++ /dev/null @@ -1,68 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> etherType; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -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 accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("action_0") action action_0() { - } - @name("table_0") table table_0() { - actions = { - action_0; - NoAction; - } - key = { - hdr.ethernet.etherType: ternary; - } - default_action = NoAction(); - } - - apply { - table_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/do_nothing-last.p4 b/testdata/v1_samples_outputs/do_nothing-last.p4 deleted file mode 100644 index b552d1cd7a2..00000000000 --- a/testdata/v1_samples_outputs/do_nothing-last.p4 +++ /dev/null @@ -1,68 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> etherType; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -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 accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("action_0") action action_0() { - } - @name("table_0") table table_0() { - actions = { - action_0; - NoAction; - } - key = { - hdr.ethernet.etherType: ternary; - } - default_action = NoAction(); - } - - apply { - table_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/do_nothing-midend.p4 b/testdata/v1_samples_outputs/do_nothing-midend.p4 deleted file mode 100644 index 97265f5968d..00000000000 --- a/testdata/v1_samples_outputs/do_nothing-midend.p4 +++ /dev/null @@ -1,69 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> etherType; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -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 accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("action_0") action action() { - } - @name("table_0") table table() { - actions = { - action; - NoAction_0; - } - key = { - hdr.ethernet.etherType: ternary; - } - default_action = NoAction_0(); - } - apply { - table.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/do_nothing.p4 b/testdata/v1_samples_outputs/do_nothing.p4 index bd2281dd348..fc2f5bc31d0 100644 --- a/testdata/v1_samples_outputs/do_nothing.p4 +++ b/testdata/v1_samples_outputs/do_nothing.p4 @@ -39,7 +39,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { table_0.apply(); } diff --git a/testdata/v1_samples_outputs/exact_match1-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/exact_match1-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..8adf5022150 --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match1-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,191 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<16> h1; + bit<8> b1; + bit<8> b2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/exact_match1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..326cc1690fa --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,175 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<16> h1; + bit<8> b1; + bit<8> b2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match1-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/exact_match1-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..1b52c8a8389 --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match1-MidEnd_25_Evaluator.p4 @@ -0,0 +1,175 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<16> h1; + bit<8> b1; + bit<8> b2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("setb1") action setb1_0(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop_0() { + } + @name("test1") table test1_0() { + actions = { + setb1_0; + noop_0; + NoAction_0; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction_0(); + } + apply { + test1_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match1-fe.p4 b/testdata/v1_samples_outputs/exact_match1-fe.p4 deleted file mode 100644 index 0cb37173d06..00000000000 --- a/testdata/v1_samples_outputs/exact_match1-fe.p4 +++ /dev/null @@ -1,72 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<16> h1; - bit<8> b1; - bit<8> b2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match1-last.p4 b/testdata/v1_samples_outputs/exact_match1-last.p4 deleted file mode 100644 index 0cb37173d06..00000000000 --- a/testdata/v1_samples_outputs/exact_match1-last.p4 +++ /dev/null @@ -1,72 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<16> h1; - bit<8> b1; - bit<8> b2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match1-midend.p4 b/testdata/v1_samples_outputs/exact_match1-midend.p4 deleted file mode 100644 index f9e9f397397..00000000000 --- a/testdata/v1_samples_outputs/exact_match1-midend.p4 +++ /dev/null @@ -1,73 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<16> h1; - bit<8> b1; - bit<8> b2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("setb1") action setb1_0(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop_0() { - } - @name("test1") table test1_0() { - actions = { - setb1_0; - noop_0; - NoAction_0; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction_0(); - } - apply { - test1_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match1.p4 b/testdata/v1_samples_outputs/exact_match1.p4 index 0cb37173d06..67cf6e3bb6f 100644 --- a/testdata/v1_samples_outputs/exact_match1.p4 +++ b/testdata/v1_samples_outputs/exact_match1.p4 @@ -42,7 +42,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { test1.apply(); } diff --git a/testdata/v1_samples_outputs/exact_match2-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/exact_match2-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..c3f3bcda2d3 --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match2-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,192 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<16> h1; + bit<8> b1; + bit<8> b2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + size = 10000; + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/exact_match2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..e02983ec520 --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,176 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<16> h1; + bit<8> b1; + bit<8> b2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + size = 10000; + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match2-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/exact_match2-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..4df9a9c425d --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match2-MidEnd_25_Evaluator.p4 @@ -0,0 +1,176 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<16> h1; + bit<8> b1; + bit<8> b2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("setb1") action setb1_0(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop_0() { + } + @name("test1") table test1_0() { + actions = { + setb1_0; + noop_0; + NoAction_0; + } + key = { + hdr.data.f1: exact; + } + size = 10000; + default_action = NoAction_0(); + } + apply { + test1_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match2-fe.p4 b/testdata/v1_samples_outputs/exact_match2-fe.p4 deleted file mode 100644 index b331cd23649..00000000000 --- a/testdata/v1_samples_outputs/exact_match2-fe.p4 +++ /dev/null @@ -1,73 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<16> h1; - bit<8> b1; - bit<8> b2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - size = 10000; - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match2-last.p4 b/testdata/v1_samples_outputs/exact_match2-last.p4 deleted file mode 100644 index b331cd23649..00000000000 --- a/testdata/v1_samples_outputs/exact_match2-last.p4 +++ /dev/null @@ -1,73 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<16> h1; - bit<8> b1; - bit<8> b2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - size = 10000; - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match2-midend.p4 b/testdata/v1_samples_outputs/exact_match2-midend.p4 deleted file mode 100644 index a72c3e602c3..00000000000 --- a/testdata/v1_samples_outputs/exact_match2-midend.p4 +++ /dev/null @@ -1,74 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<16> h1; - bit<8> b1; - bit<8> b2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("setb1") action setb1_0(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop_0() { - } - @name("test1") table test1_0() { - actions = { - setb1_0; - noop_0; - NoAction_0; - } - key = { - hdr.data.f1: exact; - } - size = 10000; - default_action = NoAction_0(); - } - apply { - test1_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match2.p4 b/testdata/v1_samples_outputs/exact_match2.p4 index b331cd23649..effdb2bc409 100644 --- a/testdata/v1_samples_outputs/exact_match2.p4 +++ b/testdata/v1_samples_outputs/exact_match2.p4 @@ -43,7 +43,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 10000; default_action = NoAction(); } - apply { test1.apply(); } diff --git a/testdata/v1_samples_outputs/exact_match3-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/exact_match3-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..75e2fd8bcda --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match3-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,192 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<16> h1; + bit<8> b1; + bit<8> b2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + size = 300000; + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/exact_match3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..a91f9457521 --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,176 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<16> h1; + bit<8> b1; + bit<8> b2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + size = 300000; + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match3-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/exact_match3-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..9d55d54e45a --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match3-MidEnd_25_Evaluator.p4 @@ -0,0 +1,176 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<16> h1; + bit<8> b1; + bit<8> b2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("setb1") action setb1_0(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop_0() { + } + @name("test1") table test1_0() { + actions = { + setb1_0; + noop_0; + NoAction_0; + } + key = { + hdr.data.f1: exact; + } + size = 300000; + default_action = NoAction_0(); + } + apply { + test1_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match3-fe.p4 b/testdata/v1_samples_outputs/exact_match3-fe.p4 deleted file mode 100644 index 3e55948223b..00000000000 --- a/testdata/v1_samples_outputs/exact_match3-fe.p4 +++ /dev/null @@ -1,73 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<16> h1; - bit<8> b1; - bit<8> b2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - size = 300000; - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match3-last.p4 b/testdata/v1_samples_outputs/exact_match3-last.p4 deleted file mode 100644 index 3e55948223b..00000000000 --- a/testdata/v1_samples_outputs/exact_match3-last.p4 +++ /dev/null @@ -1,73 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<16> h1; - bit<8> b1; - bit<8> b2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - size = 300000; - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match3-midend.p4 b/testdata/v1_samples_outputs/exact_match3-midend.p4 deleted file mode 100644 index 8981053619d..00000000000 --- a/testdata/v1_samples_outputs/exact_match3-midend.p4 +++ /dev/null @@ -1,74 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<16> h1; - bit<8> b1; - bit<8> b2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("setb1") action setb1_0(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop_0() { - } - @name("test1") table test1_0() { - actions = { - setb1_0; - noop_0; - NoAction_0; - } - key = { - hdr.data.f1: exact; - } - size = 300000; - default_action = NoAction_0(); - } - apply { - test1_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match3.p4 b/testdata/v1_samples_outputs/exact_match3.p4 index 3e55948223b..a62cea72746 100644 --- a/testdata/v1_samples_outputs/exact_match3.p4 +++ b/testdata/v1_samples_outputs/exact_match3.p4 @@ -43,7 +43,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 300000; default_action = NoAction(); } - apply { test1.apply(); } diff --git a/testdata/v1_samples_outputs/exact_match4-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/exact_match4-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..e1368f76699 --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match4-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,224 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<128> f4; + bit<8> b1; + bit<8> b2; +} + +header data1_t { + bit<128> f1; +} + +header data2_t { + bit<128> f2; +} + +header data3_t { + bit<128> f3; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; + @name("data1") + data1_t data1; + @name("data2") + data2_t data2; + @name("data3") + data3_t data3; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("d2") state d2 { + packet.extract(hdr.data2); + transition d3; + } + @name("d3") state d3 { + packet.extract(hdr.data3); + transition more; + } + @name("more") state more { + packet.extract(hdr.data); + transition accept; + } + @name("start") state start { + packet.extract(hdr.data1); + transition d2; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data1.f1: exact; + hdr.data2.f2: exact; + hdr.data3.f3: exact; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data1); + packet.emit(hdr.data2); + packet.emit(hdr.data3); + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/exact_match4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..ecc2514b4a5 --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,208 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<128> f4; + bit<8> b1; + bit<8> b2; +} + +header data1_t { + bit<128> f1; +} + +header data2_t { + bit<128> f2; +} + +header data3_t { + bit<128> f3; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; + @name("data1") + data1_t data1; + @name("data2") + data2_t data2; + @name("data3") + data3_t data3; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("d2") state d2 { + packet.extract(hdr.data2); + transition d3; + } + @name("d3") state d3 { + packet.extract(hdr.data3); + transition more; + } + @name("more") state more { + packet.extract(hdr.data); + transition accept; + } + @name("start") state start { + packet.extract(hdr.data1); + transition d2; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data1.f1: exact; + hdr.data2.f2: exact; + hdr.data3.f3: exact; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data1); + packet.emit(hdr.data2); + packet.emit(hdr.data3); + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match4-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/exact_match4-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..4810b85718b --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match4-MidEnd_25_Evaluator.p4 @@ -0,0 +1,208 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<128> f4; + bit<8> b1; + bit<8> b2; +} + +header data1_t { + bit<128> f1; +} + +header data2_t { + bit<128> f2; +} + +header data3_t { + bit<128> f3; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; + @name("data1") + data1_t data1; + @name("data2") + data2_t data2; + @name("data3") + data3_t data3; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("d2") state d2 { + packet.extract(hdr.data2); + transition d3; + } + @name("d3") state d3 { + packet.extract(hdr.data3); + transition more; + } + @name("more") state more { + packet.extract(hdr.data); + transition accept; + } + @name("start") state start { + packet.extract(hdr.data1); + transition d2; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("setb1") action setb1_0(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop_0() { + } + @name("test1") table test1_0() { + actions = { + setb1_0; + noop_0; + NoAction_0; + } + key = { + hdr.data1.f1: exact; + hdr.data2.f2: exact; + hdr.data3.f3: exact; + } + default_action = NoAction_0(); + } + apply { + test1_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data1); + packet.emit(hdr.data2); + packet.emit(hdr.data3); + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match4-fe.p4 b/testdata/v1_samples_outputs/exact_match4-fe.p4 deleted file mode 100644 index 6eed7434309..00000000000 --- a/testdata/v1_samples_outputs/exact_match4-fe.p4 +++ /dev/null @@ -1,105 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<128> f4; - bit<8> b1; - bit<8> b2; -} - -header data1_t { - bit<128> f1; -} - -header data2_t { - bit<128> f2; -} - -header data3_t { - bit<128> f3; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; - @name("data1") - data1_t data1; - @name("data2") - data2_t data2; - @name("data3") - data3_t data3; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("d2") state d2 { - packet.extract(hdr.data2); - transition d3; - } - @name("d3") state d3 { - packet.extract(hdr.data3); - transition more; - } - @name("more") state more { - packet.extract(hdr.data); - transition accept; - } - @name("start") state start { - packet.extract(hdr.data1); - transition d2; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data1.f1: exact; - hdr.data2.f2: exact; - hdr.data3.f3: exact; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data1); - packet.emit(hdr.data2); - packet.emit(hdr.data3); - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match4-last.p4 b/testdata/v1_samples_outputs/exact_match4-last.p4 deleted file mode 100644 index 6eed7434309..00000000000 --- a/testdata/v1_samples_outputs/exact_match4-last.p4 +++ /dev/null @@ -1,105 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<128> f4; - bit<8> b1; - bit<8> b2; -} - -header data1_t { - bit<128> f1; -} - -header data2_t { - bit<128> f2; -} - -header data3_t { - bit<128> f3; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; - @name("data1") - data1_t data1; - @name("data2") - data2_t data2; - @name("data3") - data3_t data3; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("d2") state d2 { - packet.extract(hdr.data2); - transition d3; - } - @name("d3") state d3 { - packet.extract(hdr.data3); - transition more; - } - @name("more") state more { - packet.extract(hdr.data); - transition accept; - } - @name("start") state start { - packet.extract(hdr.data1); - transition d2; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data1.f1: exact; - hdr.data2.f2: exact; - hdr.data3.f3: exact; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data1); - packet.emit(hdr.data2); - packet.emit(hdr.data3); - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match4-midend.p4 b/testdata/v1_samples_outputs/exact_match4-midend.p4 deleted file mode 100644 index b00782dc69e..00000000000 --- a/testdata/v1_samples_outputs/exact_match4-midend.p4 +++ /dev/null @@ -1,106 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<128> f4; - bit<8> b1; - bit<8> b2; -} - -header data1_t { - bit<128> f1; -} - -header data2_t { - bit<128> f2; -} - -header data3_t { - bit<128> f3; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; - @name("data1") - data1_t data1; - @name("data2") - data2_t data2; - @name("data3") - data3_t data3; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("d2") state d2 { - packet.extract(hdr.data2); - transition d3; - } - @name("d3") state d3 { - packet.extract(hdr.data3); - transition more; - } - @name("more") state more { - packet.extract(hdr.data); - transition accept; - } - @name("start") state start { - packet.extract(hdr.data1); - transition d2; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("setb1") action setb1_0(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop_0() { - } - @name("test1") table test1_0() { - actions = { - setb1_0; - noop_0; - NoAction_0; - } - key = { - hdr.data1.f1: exact; - hdr.data2.f2: exact; - hdr.data3.f3: exact; - } - default_action = NoAction_0(); - } - apply { - test1_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data1); - packet.emit(hdr.data2); - packet.emit(hdr.data3); - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match4.p4 b/testdata/v1_samples_outputs/exact_match4.p4 index 6eed7434309..e3b9d5a619f 100644 --- a/testdata/v1_samples_outputs/exact_match4.p4 +++ b/testdata/v1_samples_outputs/exact_match4.p4 @@ -72,7 +72,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { test1.apply(); } diff --git a/testdata/v1_samples_outputs/exact_match5-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/exact_match5-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..2e6230adaa8 --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match5-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,225 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<128> f4; + bit<8> b1; + bit<8> b2; +} + +header data1_t { + bit<128> f1; +} + +header data2_t { + bit<128> f2; +} + +header data3_t { + bit<128> f3; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; + @name("data1") + data1_t data1; + @name("data2") + data2_t data2; + @name("data3") + data3_t data3; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("d2") state d2 { + packet.extract(hdr.data2); + transition d3; + } + @name("d3") state d3 { + packet.extract(hdr.data3); + transition more; + } + @name("more") state more { + packet.extract(hdr.data); + transition accept; + } + @name("start") state start { + packet.extract(hdr.data1); + transition d2; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data1.f1: exact; + hdr.data2.f2: exact; + hdr.data3.f3: exact; + } + size = 100000; + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data1); + packet.emit(hdr.data2); + packet.emit(hdr.data3); + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match5-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/exact_match5-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..113e964267e --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match5-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,209 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<128> f4; + bit<8> b1; + bit<8> b2; +} + +header data1_t { + bit<128> f1; +} + +header data2_t { + bit<128> f2; +} + +header data3_t { + bit<128> f3; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; + @name("data1") + data1_t data1; + @name("data2") + data2_t data2; + @name("data3") + data3_t data3; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("d2") state d2 { + packet.extract(hdr.data2); + transition d3; + } + @name("d3") state d3 { + packet.extract(hdr.data3); + transition more; + } + @name("more") state more { + packet.extract(hdr.data); + transition accept; + } + @name("start") state start { + packet.extract(hdr.data1); + transition d2; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data1.f1: exact; + hdr.data2.f2: exact; + hdr.data3.f3: exact; + } + size = 100000; + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data1); + packet.emit(hdr.data2); + packet.emit(hdr.data3); + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match5-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/exact_match5-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..88d868f52c0 --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match5-MidEnd_25_Evaluator.p4 @@ -0,0 +1,209 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<128> f4; + bit<8> b1; + bit<8> b2; +} + +header data1_t { + bit<128> f1; +} + +header data2_t { + bit<128> f2; +} + +header data3_t { + bit<128> f3; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; + @name("data1") + data1_t data1; + @name("data2") + data2_t data2; + @name("data3") + data3_t data3; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("d2") state d2 { + packet.extract(hdr.data2); + transition d3; + } + @name("d3") state d3 { + packet.extract(hdr.data3); + transition more; + } + @name("more") state more { + packet.extract(hdr.data); + transition accept; + } + @name("start") state start { + packet.extract(hdr.data1); + transition d2; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("setb1") action setb1_0(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop_0() { + } + @name("test1") table test1_0() { + actions = { + setb1_0; + noop_0; + NoAction_0; + } + key = { + hdr.data1.f1: exact; + hdr.data2.f2: exact; + hdr.data3.f3: exact; + } + size = 100000; + default_action = NoAction_0(); + } + apply { + test1_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data1); + packet.emit(hdr.data2); + packet.emit(hdr.data3); + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match5-fe.p4 b/testdata/v1_samples_outputs/exact_match5-fe.p4 deleted file mode 100644 index 59e82caa37d..00000000000 --- a/testdata/v1_samples_outputs/exact_match5-fe.p4 +++ /dev/null @@ -1,106 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<128> f4; - bit<8> b1; - bit<8> b2; -} - -header data1_t { - bit<128> f1; -} - -header data2_t { - bit<128> f2; -} - -header data3_t { - bit<128> f3; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; - @name("data1") - data1_t data1; - @name("data2") - data2_t data2; - @name("data3") - data3_t data3; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("d2") state d2 { - packet.extract(hdr.data2); - transition d3; - } - @name("d3") state d3 { - packet.extract(hdr.data3); - transition more; - } - @name("more") state more { - packet.extract(hdr.data); - transition accept; - } - @name("start") state start { - packet.extract(hdr.data1); - transition d2; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data1.f1: exact; - hdr.data2.f2: exact; - hdr.data3.f3: exact; - } - size = 100000; - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data1); - packet.emit(hdr.data2); - packet.emit(hdr.data3); - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match5-last.p4 b/testdata/v1_samples_outputs/exact_match5-last.p4 deleted file mode 100644 index 59e82caa37d..00000000000 --- a/testdata/v1_samples_outputs/exact_match5-last.p4 +++ /dev/null @@ -1,106 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<128> f4; - bit<8> b1; - bit<8> b2; -} - -header data1_t { - bit<128> f1; -} - -header data2_t { - bit<128> f2; -} - -header data3_t { - bit<128> f3; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; - @name("data1") - data1_t data1; - @name("data2") - data2_t data2; - @name("data3") - data3_t data3; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("d2") state d2 { - packet.extract(hdr.data2); - transition d3; - } - @name("d3") state d3 { - packet.extract(hdr.data3); - transition more; - } - @name("more") state more { - packet.extract(hdr.data); - transition accept; - } - @name("start") state start { - packet.extract(hdr.data1); - transition d2; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data1.f1: exact; - hdr.data2.f2: exact; - hdr.data3.f3: exact; - } - size = 100000; - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data1); - packet.emit(hdr.data2); - packet.emit(hdr.data3); - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match5-midend.p4 b/testdata/v1_samples_outputs/exact_match5-midend.p4 deleted file mode 100644 index 7e92e718699..00000000000 --- a/testdata/v1_samples_outputs/exact_match5-midend.p4 +++ /dev/null @@ -1,107 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<128> f4; - bit<8> b1; - bit<8> b2; -} - -header data1_t { - bit<128> f1; -} - -header data2_t { - bit<128> f2; -} - -header data3_t { - bit<128> f3; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; - @name("data1") - data1_t data1; - @name("data2") - data2_t data2; - @name("data3") - data3_t data3; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("d2") state d2 { - packet.extract(hdr.data2); - transition d3; - } - @name("d3") state d3 { - packet.extract(hdr.data3); - transition more; - } - @name("more") state more { - packet.extract(hdr.data); - transition accept; - } - @name("start") state start { - packet.extract(hdr.data1); - transition d2; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("setb1") action setb1_0(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop_0() { - } - @name("test1") table test1_0() { - actions = { - setb1_0; - noop_0; - NoAction_0; - } - key = { - hdr.data1.f1: exact; - hdr.data2.f2: exact; - hdr.data3.f3: exact; - } - size = 100000; - default_action = NoAction_0(); - } - apply { - test1_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data1); - packet.emit(hdr.data2); - packet.emit(hdr.data3); - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match5.p4 b/testdata/v1_samples_outputs/exact_match5.p4 index 59e82caa37d..530dbc45652 100644 --- a/testdata/v1_samples_outputs/exact_match5.p4 +++ b/testdata/v1_samples_outputs/exact_match5.p4 @@ -73,7 +73,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 100000; default_action = NoAction(); } - apply { test1.apply(); } diff --git a/testdata/v1_samples_outputs/exact_match6-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/exact_match6-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..ab22804c1e9 --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match6-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,199 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct meta_t { + bit<32> sum; +} + +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { + @name("meta") + meta_t meta; +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("addf2") action addf2() { + meta.meta.sum = hdr.data.f2 + 32w100; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + addf2; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match6-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/exact_match6-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..9a87002b35f --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match6-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,183 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct meta_t { + bit<32> sum; +} + +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { + @name("meta") + meta_t meta; +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("addf2") action addf2() { + meta.meta.sum = hdr.data.f2 + 32w100; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + addf2; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match6-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/exact_match6-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..31f10597d5d --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match6-MidEnd_25_Evaluator.p4 @@ -0,0 +1,183 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct meta_t { + bit<32> sum; +} + +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { + @name("meta") + meta_t meta; +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("addf2") action addf2_0() { + meta.meta.sum = hdr.data.f2 + 32w100; + } + @name("noop") action noop_0() { + } + @name("test1") table test1_0() { + actions = { + addf2_0; + noop_0; + NoAction_0; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction_0(); + } + apply { + test1_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match6-fe.p4 b/testdata/v1_samples_outputs/exact_match6-fe.p4 deleted file mode 100644 index f90701be129..00000000000 --- a/testdata/v1_samples_outputs/exact_match6-fe.p4 +++ /dev/null @@ -1,80 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct meta_t { - bit<32> sum; -} - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { - @name("meta") - meta_t meta; -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("addf2") action addf2() { - meta.meta.sum = hdr.data.f2 + 32w100; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - addf2; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match6-last.p4 b/testdata/v1_samples_outputs/exact_match6-last.p4 deleted file mode 100644 index f90701be129..00000000000 --- a/testdata/v1_samples_outputs/exact_match6-last.p4 +++ /dev/null @@ -1,80 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct meta_t { - bit<32> sum; -} - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { - @name("meta") - meta_t meta; -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("addf2") action addf2() { - meta.meta.sum = hdr.data.f2 + 32w100; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - addf2; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match6-midend.p4 b/testdata/v1_samples_outputs/exact_match6-midend.p4 deleted file mode 100644 index b9d0507a9f3..00000000000 --- a/testdata/v1_samples_outputs/exact_match6-midend.p4 +++ /dev/null @@ -1,81 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct meta_t { - bit<32> sum; -} - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { - @name("meta") - meta_t meta; -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("addf2") action addf2_0() { - meta.meta.sum = hdr.data.f2 + 32w100; - } - @name("noop") action noop_0() { - } - @name("test1") table test1_0() { - actions = { - addf2_0; - noop_0; - NoAction_0; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction_0(); - } - apply { - test1_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match6.p4 b/testdata/v1_samples_outputs/exact_match6.p4 index f90701be129..d82bdefc01d 100644 --- a/testdata/v1_samples_outputs/exact_match6.p4 +++ b/testdata/v1_samples_outputs/exact_match6.p4 @@ -50,7 +50,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { test1.apply(); } diff --git a/testdata/v1_samples_outputs/exact_match7-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/exact_match7-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..2239ba619bd --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match7-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,198 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<3> x1; + bit<7> f1; + bit<6> x2; + bit<32> f2; + bit<5> x3; + bit<20> f3; + bit<7> x4; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val) { + hdr.data.b1 = val; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + hdr.data.f3: exact; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match7-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/exact_match7-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..63e000262d9 --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match7-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,182 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<3> x1; + bit<7> f1; + bit<6> x2; + bit<32> f2; + bit<5> x3; + bit<20> f3; + bit<7> x4; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val) { + hdr.data.b1 = val; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + hdr.data.f3: exact; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match7-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/exact_match7-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..59de4133b0e --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match7-MidEnd_25_Evaluator.p4 @@ -0,0 +1,182 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<3> x1; + bit<7> f1; + bit<6> x2; + bit<32> f2; + bit<5> x3; + bit<20> f3; + bit<7> x4; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("setb1") action setb1_0(bit<8> val) { + hdr.data.b1 = val; + } + @name("noop") action noop_0() { + } + @name("test1") table test1_0() { + actions = { + setb1_0; + noop_0; + NoAction_0; + } + key = { + hdr.data.f1: exact; + hdr.data.f3: exact; + } + default_action = NoAction_0(); + } + apply { + test1_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match7-fe.p4 b/testdata/v1_samples_outputs/exact_match7-fe.p4 deleted file mode 100644 index 9a80e6c6bcf..00000000000 --- a/testdata/v1_samples_outputs/exact_match7-fe.p4 +++ /dev/null @@ -1,79 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<3> x1; - bit<7> f1; - bit<6> x2; - bit<32> f2; - bit<5> x3; - bit<20> f3; - bit<7> x4; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val) { - hdr.data.b1 = val; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - hdr.data.f3: exact; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match7-last.p4 b/testdata/v1_samples_outputs/exact_match7-last.p4 deleted file mode 100644 index 9a80e6c6bcf..00000000000 --- a/testdata/v1_samples_outputs/exact_match7-last.p4 +++ /dev/null @@ -1,79 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<3> x1; - bit<7> f1; - bit<6> x2; - bit<32> f2; - bit<5> x3; - bit<20> f3; - bit<7> x4; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val) { - hdr.data.b1 = val; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - hdr.data.f3: exact; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match7-midend.p4 b/testdata/v1_samples_outputs/exact_match7-midend.p4 deleted file mode 100644 index c22e711cffc..00000000000 --- a/testdata/v1_samples_outputs/exact_match7-midend.p4 +++ /dev/null @@ -1,80 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<3> x1; - bit<7> f1; - bit<6> x2; - bit<32> f2; - bit<5> x3; - bit<20> f3; - bit<7> x4; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("setb1") action setb1_0(bit<8> val) { - hdr.data.b1 = val; - } - @name("noop") action noop_0() { - } - @name("test1") table test1_0() { - actions = { - setb1_0; - noop_0; - NoAction_0; - } - key = { - hdr.data.f1: exact; - hdr.data.f3: exact; - } - default_action = NoAction_0(); - } - apply { - test1_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match7.p4 b/testdata/v1_samples_outputs/exact_match7.p4 index 9a80e6c6bcf..6815a03aa29 100644 --- a/testdata/v1_samples_outputs/exact_match7.p4 +++ b/testdata/v1_samples_outputs/exact_match7.p4 @@ -49,7 +49,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { test1.apply(); } diff --git a/testdata/v1_samples_outputs/exact_match8-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/exact_match8-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..30896c168c4 --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match8-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,235 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("noop") action noop() { + } + @name("setb1") action setb1(bit<8> val) { + hdr.data.b1 = val; + } + @name("setb2") action setb2(bit<8> val) { + hdr.data.b2 = val; + } + @name("setb3") action setb3(bit<8> val) { + hdr.data.b3 = val; + } + @name("setb4") action setb4(bit<8> val) { + hdr.data.b4 = val; + } + @name("setb12") action setb12(bit<8> v1, bit<8> v2) { + hdr.data.b1 = v1; + hdr.data.b2 = v2; + } + @name("setb13") action setb13(bit<8> v1, bit<8> v2) { + hdr.data.b1 = v1; + hdr.data.b3 = v2; + } + @name("setb14") action setb14(bit<8> v1, bit<8> v2) { + hdr.data.b1 = v1; + hdr.data.b4 = v2; + } + @name("setb23") action setb23(bit<8> v1, bit<8> v2) { + hdr.data.b2 = v1; + hdr.data.b3 = v2; + } + @name("setb24") action setb24(bit<8> v1, bit<8> v2) { + hdr.data.b2 = v1; + hdr.data.b4 = v2; + } + @name("setb34") action setb34(bit<8> v1, bit<8> v2) { + hdr.data.b3 = v1; + hdr.data.b4 = v2; + } + @name("test1") table test1() { + actions = { + noop; + setb1; + setb2; + setb3; + setb4; + setb12; + setb13; + setb14; + setb23; + setb24; + setb34; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match8-last.p4 b/testdata/v1_samples_outputs/exact_match8-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 53% rename from testdata/v1_samples_outputs/exact_match8-last.p4 rename to testdata/v1_samples_outputs/exact_match8-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index de7bfc31e06..2f861d20b53 100644 --- a/testdata/v1_samples_outputs/exact_match8-last.p4 +++ b/testdata/v1_samples_outputs/exact_match8-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header data_t { bit<32> f1; bit<32> f2; @@ -86,7 +190,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { test1.apply(); } diff --git a/testdata/v1_samples_outputs/exact_match8-midend.p4 b/testdata/v1_samples_outputs/exact_match8-MidEnd_25_Evaluator.p4 similarity index 54% rename from testdata/v1_samples_outputs/exact_match8-midend.p4 rename to testdata/v1_samples_outputs/exact_match8-MidEnd_25_Evaluator.p4 index 401de3b9381..181aeccecc8 100644 --- a/testdata/v1_samples_outputs/exact_match8-midend.p4 +++ b/testdata/v1_samples_outputs/exact_match8-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header data_t { bit<32> f1; bit<32> f2; diff --git a/testdata/v1_samples_outputs/exact_match8-fe.p4 b/testdata/v1_samples_outputs/exact_match8-fe.p4 deleted file mode 100644 index de7bfc31e06..00000000000 --- a/testdata/v1_samples_outputs/exact_match8-fe.p4 +++ /dev/null @@ -1,116 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("noop") action noop() { - } - @name("setb1") action setb1(bit<8> val) { - hdr.data.b1 = val; - } - @name("setb2") action setb2(bit<8> val) { - hdr.data.b2 = val; - } - @name("setb3") action setb3(bit<8> val) { - hdr.data.b3 = val; - } - @name("setb4") action setb4(bit<8> val) { - hdr.data.b4 = val; - } - @name("setb12") action setb12(bit<8> v1, bit<8> v2) { - hdr.data.b1 = v1; - hdr.data.b2 = v2; - } - @name("setb13") action setb13(bit<8> v1, bit<8> v2) { - hdr.data.b1 = v1; - hdr.data.b3 = v2; - } - @name("setb14") action setb14(bit<8> v1, bit<8> v2) { - hdr.data.b1 = v1; - hdr.data.b4 = v2; - } - @name("setb23") action setb23(bit<8> v1, bit<8> v2) { - hdr.data.b2 = v1; - hdr.data.b3 = v2; - } - @name("setb24") action setb24(bit<8> v1, bit<8> v2) { - hdr.data.b2 = v1; - hdr.data.b4 = v2; - } - @name("setb34") action setb34(bit<8> v1, bit<8> v2) { - hdr.data.b3 = v1; - hdr.data.b4 = v2; - } - @name("test1") table test1() { - actions = { - noop; - setb1; - setb2; - setb3; - setb4; - setb12; - setb13; - setb14; - setb23; - setb24; - setb34; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match8.p4 b/testdata/v1_samples_outputs/exact_match8.p4 index de7bfc31e06..c62b883152e 100644 --- a/testdata/v1_samples_outputs/exact_match8.p4 +++ b/testdata/v1_samples_outputs/exact_match8.p4 @@ -86,7 +86,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { test1.apply(); } diff --git a/testdata/v1_samples_outputs/exact_match9-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/exact_match9-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..30449085212 --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match9-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,206 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("noop") action noop() { + } + @name("setb1") action setb1(bit<8> val) { + hdr.data.b1 = val; + } + @name("setb2") action setb2(bit<8> val) { + hdr.data.b2 = val; + } + @name("setb3") action setb3(bit<8> val) { + hdr.data.b3 = val; + } + @name("setb4") action setb4(bit<8> val) { + hdr.data.b4 = val; + } + @name("test1") table test1() { + actions = { + noop; + setb1; + setb2; + setb3; + setb4; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + apply { + if (hdr.data.f2 != 32w0) + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match9-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/exact_match9-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..ef440480b6c --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match9-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,190 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("noop") action noop() { + } + @name("setb1") action setb1(bit<8> val) { + hdr.data.b1 = val; + } + @name("setb2") action setb2(bit<8> val) { + hdr.data.b2 = val; + } + @name("setb3") action setb3(bit<8> val) { + hdr.data.b3 = val; + } + @name("setb4") action setb4(bit<8> val) { + hdr.data.b4 = val; + } + @name("test1") table test1() { + actions = { + noop; + setb1; + setb2; + setb3; + setb4; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + apply { + if (hdr.data.f2 != 32w0) + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match9-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/exact_match9-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..dbff69cdb6a --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match9-MidEnd_25_Evaluator.p4 @@ -0,0 +1,190 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("noop") action noop_0() { + } + @name("setb1") action setb1_0(bit<8> val) { + hdr.data.b1 = val; + } + @name("setb2") action setb2_0(bit<8> val) { + hdr.data.b2 = val; + } + @name("setb3") action setb3_0(bit<8> val) { + hdr.data.b3 = val; + } + @name("setb4") action setb4_0(bit<8> val) { + hdr.data.b4 = val; + } + @name("test1") table test1_0() { + actions = { + noop_0; + setb1_0; + setb2_0; + setb3_0; + setb4_0; + NoAction_0; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction_0(); + } + apply { + if (hdr.data.f2 != 32w0) + test1_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match9-fe.p4 b/testdata/v1_samples_outputs/exact_match9-fe.p4 deleted file mode 100644 index c28a6c49f05..00000000000 --- a/testdata/v1_samples_outputs/exact_match9-fe.p4 +++ /dev/null @@ -1,87 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("noop") action noop() { - } - @name("setb1") action setb1(bit<8> val) { - hdr.data.b1 = val; - } - @name("setb2") action setb2(bit<8> val) { - hdr.data.b2 = val; - } - @name("setb3") action setb3(bit<8> val) { - hdr.data.b3 = val; - } - @name("setb4") action setb4(bit<8> val) { - hdr.data.b4 = val; - } - @name("test1") table test1() { - actions = { - noop; - setb1; - setb2; - setb3; - setb4; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - apply { - if (hdr.data.f2 != 32w0) - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match9-last.p4 b/testdata/v1_samples_outputs/exact_match9-last.p4 deleted file mode 100644 index c28a6c49f05..00000000000 --- a/testdata/v1_samples_outputs/exact_match9-last.p4 +++ /dev/null @@ -1,87 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("noop") action noop() { - } - @name("setb1") action setb1(bit<8> val) { - hdr.data.b1 = val; - } - @name("setb2") action setb2(bit<8> val) { - hdr.data.b2 = val; - } - @name("setb3") action setb3(bit<8> val) { - hdr.data.b3 = val; - } - @name("setb4") action setb4(bit<8> val) { - hdr.data.b4 = val; - } - @name("test1") table test1() { - actions = { - noop; - setb1; - setb2; - setb3; - setb4; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - apply { - if (hdr.data.f2 != 32w0) - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match9-midend.p4 b/testdata/v1_samples_outputs/exact_match9-midend.p4 deleted file mode 100644 index b2c120d9191..00000000000 --- a/testdata/v1_samples_outputs/exact_match9-midend.p4 +++ /dev/null @@ -1,88 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("noop") action noop_0() { - } - @name("setb1") action setb1_0(bit<8> val) { - hdr.data.b1 = val; - } - @name("setb2") action setb2_0(bit<8> val) { - hdr.data.b2 = val; - } - @name("setb3") action setb3_0(bit<8> val) { - hdr.data.b3 = val; - } - @name("setb4") action setb4_0(bit<8> val) { - hdr.data.b4 = val; - } - @name("test1") table test1_0() { - actions = { - noop_0; - setb1_0; - setb2_0; - setb3_0; - setb4_0; - NoAction_0; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction_0(); - } - apply { - if (hdr.data.f2 != 32w0) - test1_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match9.p4 b/testdata/v1_samples_outputs/exact_match9.p4 index eadba72d031..446a1f5265f 100644 --- a/testdata/v1_samples_outputs/exact_match9.p4 +++ b/testdata/v1_samples_outputs/exact_match9.p4 @@ -56,7 +56,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (hdr.data.f2 != 32w0) { test1.apply(); diff --git a/testdata/v1_samples_outputs/exact_match_valid1-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/exact_match_valid1-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..9026ce2bc1e --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match_valid1-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,204 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; + @name("data2") + data_t data2; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_data2") state parse_data2 { + packet.extract(hdr.data2); + transition accept; + } + @name("start") state start { + packet.extract(hdr.data); + transition select(hdr.data.f2) { + 32w0xf0000000 &&& 32w0xf0000000: parse_data2; + default: accept; + } + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val) { + hdr.data2.b1 = val; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.isValid() : exact; + hdr.data2.isValid(): exact; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + packet.emit(hdr.data2); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match_valid1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/exact_match_valid1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..34bb9269c41 --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match_valid1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,188 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; + @name("data2") + data_t data2; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_data2") state parse_data2 { + packet.extract(hdr.data2); + transition accept; + } + @name("start") state start { + packet.extract(hdr.data); + transition select(hdr.data.f2) { + 32w0xf0000000 &&& 32w0xf0000000: parse_data2; + default: accept; + } + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val) { + hdr.data2.b1 = val; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.isValid() : exact; + hdr.data2.isValid(): exact; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + packet.emit(hdr.data2); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match_valid1-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/exact_match_valid1-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..362e68e7b55 --- /dev/null +++ b/testdata/v1_samples_outputs/exact_match_valid1-MidEnd_25_Evaluator.p4 @@ -0,0 +1,188 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; + @name("data2") + data_t data2; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_data2") state parse_data2 { + packet.extract(hdr.data2); + transition accept; + } + @name("start") state start { + packet.extract(hdr.data); + transition select(hdr.data.f2) { + 32w0xf0000000 &&& 32w0xf0000000: parse_data2; + default: accept; + } + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("setb1") action setb1_0(bit<8> val) { + hdr.data2.b1 = val; + } + @name("noop") action noop_0() { + } + @name("test1") table test1_0() { + actions = { + setb1_0; + noop_0; + NoAction_0; + } + key = { + hdr.data.isValid() : exact; + hdr.data2.isValid(): exact; + } + default_action = NoAction_0(); + } + apply { + test1_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + packet.emit(hdr.data2); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match_valid1-fe.p4 b/testdata/v1_samples_outputs/exact_match_valid1-fe.p4 deleted file mode 100644 index 1af7a35d1e3..00000000000 --- a/testdata/v1_samples_outputs/exact_match_valid1-fe.p4 +++ /dev/null @@ -1,85 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; - @name("data2") - data_t data2; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("parse_data2") state parse_data2 { - packet.extract(hdr.data2); - transition accept; - } - @name("start") state start { - packet.extract(hdr.data); - transition select(hdr.data.f2) { - 32w0xf0000000 &&& 32w0xf0000000: parse_data2; - default: accept; - } - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val) { - hdr.data2.b1 = val; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.isValid() : exact; - hdr.data2.isValid(): exact; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - packet.emit(hdr.data2); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match_valid1-last.p4 b/testdata/v1_samples_outputs/exact_match_valid1-last.p4 deleted file mode 100644 index 1af7a35d1e3..00000000000 --- a/testdata/v1_samples_outputs/exact_match_valid1-last.p4 +++ /dev/null @@ -1,85 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; - @name("data2") - data_t data2; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("parse_data2") state parse_data2 { - packet.extract(hdr.data2); - transition accept; - } - @name("start") state start { - packet.extract(hdr.data); - transition select(hdr.data.f2) { - 32w0xf0000000 &&& 32w0xf0000000: parse_data2; - default: accept; - } - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val) { - hdr.data2.b1 = val; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.isValid() : exact; - hdr.data2.isValid(): exact; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - packet.emit(hdr.data2); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match_valid1-midend.p4 b/testdata/v1_samples_outputs/exact_match_valid1-midend.p4 deleted file mode 100644 index cd9c0cbf00d..00000000000 --- a/testdata/v1_samples_outputs/exact_match_valid1-midend.p4 +++ /dev/null @@ -1,86 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; - @name("data2") - data_t data2; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("parse_data2") state parse_data2 { - packet.extract(hdr.data2); - transition accept; - } - @name("start") state start { - packet.extract(hdr.data); - transition select(hdr.data.f2) { - 32w0xf0000000 &&& 32w0xf0000000: parse_data2; - default: accept; - } - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("setb1") action setb1_0(bit<8> val) { - hdr.data2.b1 = val; - } - @name("noop") action noop_0() { - } - @name("test1") table test1_0() { - actions = { - setb1_0; - noop_0; - NoAction_0; - } - key = { - hdr.data.isValid() : exact; - hdr.data2.isValid(): exact; - } - default_action = NoAction_0(); - } - apply { - test1_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - packet.emit(hdr.data2); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/exact_match_valid1.p4 b/testdata/v1_samples_outputs/exact_match_valid1.p4 index 1af7a35d1e3..1da8efac25b 100644 --- a/testdata/v1_samples_outputs/exact_match_valid1.p4 +++ b/testdata/v1_samples_outputs/exact_match_valid1.p4 @@ -54,7 +54,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { test1.apply(); } diff --git a/testdata/v1_samples_outputs/flowlet_switching-last.p4 b/testdata/v1_samples_outputs/flowlet_switching-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 71% rename from testdata/v1_samples_outputs/flowlet_switching-last.p4 rename to testdata/v1_samples_outputs/flowlet_switching-FrontEnd_11_SimplifyControlFlowE.p4 index 6b2cd294c16..cf78c62ead6 100644 --- a/testdata/v1_samples_outputs/flowlet_switching-last.p4 +++ b/testdata/v1_samples_outputs/flowlet_switching-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<32> flow_ipg; bit<13> flowlet_map_index; diff --git a/testdata/v1_samples_outputs/flowlet_switching-fe.p4 b/testdata/v1_samples_outputs/flowlet_switching-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 74% rename from testdata/v1_samples_outputs/flowlet_switching-fe.p4 rename to testdata/v1_samples_outputs/flowlet_switching-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 6b2cd294c16..614d7222fa9 100644 --- a/testdata/v1_samples_outputs/flowlet_switching-fe.p4 +++ b/testdata/v1_samples_outputs/flowlet_switching-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,112 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<32> flow_ipg; bit<13> flowlet_map_index; diff --git a/testdata/v1_samples_outputs/flowlet_switching-midend.p4 b/testdata/v1_samples_outputs/flowlet_switching-MidEnd_25_Evaluator.p4 similarity index 76% rename from testdata/v1_samples_outputs/flowlet_switching-midend.p4 rename to testdata/v1_samples_outputs/flowlet_switching-MidEnd_25_Evaluator.p4 index 0738b90e7e8..78e41067bab 100644 --- a/testdata/v1_samples_outputs/flowlet_switching-midend.p4 +++ b/testdata/v1_samples_outputs/flowlet_switching-MidEnd_25_Evaluator.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<32> flow_ipg; bit<13> flowlet_map_index; diff --git a/testdata/v1_samples_outputs/gateway1-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/gateway1-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..ce2b21ea010 --- /dev/null +++ b/testdata/v1_samples_outputs/gateway1-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,204 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<8> b1; + bit<8> b2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + @name("test2") table test2() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f2: exact; + } + default_action = NoAction(); + } + apply { + if (hdr.data.b2 == 8w1) + test1.apply(); + else + test2.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/gateway1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..58b73e97424 --- /dev/null +++ b/testdata/v1_samples_outputs/gateway1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,188 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<8> b1; + bit<8> b2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + @name("test2") table test2() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f2: exact; + } + default_action = NoAction(); + } + apply { + if (hdr.data.b2 == 8w1) + test1.apply(); + else + test2.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway1-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/gateway1-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..cae2ac1018a --- /dev/null +++ b/testdata/v1_samples_outputs/gateway1-MidEnd_25_Evaluator.p4 @@ -0,0 +1,196 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<8> b1; + bit<8> b2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + action NoAction_1() { + } + @name("setb1") action setb1_0(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop_0() { + } + @name("noop") action noop() { + } + @name("test1") table test1_0() { + actions = { + setb1_0; + noop_0; + NoAction_0; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction_0(); + } + @name("test2") table test2_0() { + actions = { + setb1; + noop; + NoAction_1; + } + key = { + hdr.data.f2: exact; + } + default_action = NoAction_0(); + } + apply { + if (hdr.data.b2 == 8w1) + test1_0.apply(); + else + test2_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway1-fe.p4 b/testdata/v1_samples_outputs/gateway1-fe.p4 deleted file mode 100644 index 67289783fad..00000000000 --- a/testdata/v1_samples_outputs/gateway1-fe.p4 +++ /dev/null @@ -1,86 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<8> b1; - bit<8> b2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - @name("test2") table test2() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f2: exact; - } - default_action = NoAction(); - } - - apply { - if (hdr.data.b2 == 8w1) - test1.apply(); - else - test2.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway1-last.p4 b/testdata/v1_samples_outputs/gateway1-last.p4 deleted file mode 100644 index 67289783fad..00000000000 --- a/testdata/v1_samples_outputs/gateway1-last.p4 +++ /dev/null @@ -1,86 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<8> b1; - bit<8> b2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - @name("test2") table test2() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f2: exact; - } - default_action = NoAction(); - } - - apply { - if (hdr.data.b2 == 8w1) - test1.apply(); - else - test2.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway1-midend.p4 b/testdata/v1_samples_outputs/gateway1-midend.p4 deleted file mode 100644 index 64a437b8c65..00000000000 --- a/testdata/v1_samples_outputs/gateway1-midend.p4 +++ /dev/null @@ -1,94 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<8> b1; - bit<8> b2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - action NoAction_1() { - } - @name("setb1") action setb1_0(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop_0() { - } - @name("noop") action noop() { - } - @name("test1") table test1_0() { - actions = { - setb1_0; - noop_0; - NoAction_0; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction_0(); - } - @name("test2") table test2_0() { - actions = { - setb1; - noop; - NoAction_1; - } - key = { - hdr.data.f2: exact; - } - default_action = NoAction_0(); - } - apply { - if (hdr.data.b2 == 8w1) - test1_0.apply(); - else - test2_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway1.p4 b/testdata/v1_samples_outputs/gateway1.p4 index 3b2c9149f14..cacfe5297bc 100644 --- a/testdata/v1_samples_outputs/gateway1.p4 +++ b/testdata/v1_samples_outputs/gateway1.p4 @@ -41,7 +41,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("test2") table test2() { actions = { setb1; @@ -53,7 +52,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (hdr.data.b2 == 8w1) { test1.apply(); diff --git a/testdata/v1_samples_outputs/gateway2-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/gateway2-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..633e9438891 --- /dev/null +++ b/testdata/v1_samples_outputs/gateway2-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,206 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + @name("test2") table test2() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f2: exact; + } + default_action = NoAction(); + } + apply { + if (hdr.data.b2 == hdr.data.b3 && hdr.data.b4 == 8w10) + test1.apply(); + else + test2.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/gateway2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..23a439cbf44 --- /dev/null +++ b/testdata/v1_samples_outputs/gateway2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,190 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + @name("test2") table test2() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f2: exact; + } + default_action = NoAction(); + } + apply { + if (hdr.data.b2 == hdr.data.b3 && hdr.data.b4 == 8w10) + test1.apply(); + else + test2.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway2-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/gateway2-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..458e88916b1 --- /dev/null +++ b/testdata/v1_samples_outputs/gateway2-MidEnd_25_Evaluator.p4 @@ -0,0 +1,198 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + action NoAction_1() { + } + @name("setb1") action setb1_0(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop_0() { + } + @name("noop") action noop() { + } + @name("test1") table test1_0() { + actions = { + setb1_0; + noop_0; + NoAction_0; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction_0(); + } + @name("test2") table test2_0() { + actions = { + setb1; + noop; + NoAction_1; + } + key = { + hdr.data.f2: exact; + } + default_action = NoAction_0(); + } + apply { + if (hdr.data.b2 == hdr.data.b3 && hdr.data.b4 == 8w10) + test1_0.apply(); + else + test2_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway2-fe.p4 b/testdata/v1_samples_outputs/gateway2-fe.p4 deleted file mode 100644 index 89320c6bc2f..00000000000 --- a/testdata/v1_samples_outputs/gateway2-fe.p4 +++ /dev/null @@ -1,88 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - @name("test2") table test2() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f2: exact; - } - default_action = NoAction(); - } - - apply { - if (hdr.data.b2 == hdr.data.b3 && hdr.data.b4 == 8w10) - test1.apply(); - else - test2.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway2-last.p4 b/testdata/v1_samples_outputs/gateway2-last.p4 deleted file mode 100644 index 89320c6bc2f..00000000000 --- a/testdata/v1_samples_outputs/gateway2-last.p4 +++ /dev/null @@ -1,88 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - @name("test2") table test2() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f2: exact; - } - default_action = NoAction(); - } - - apply { - if (hdr.data.b2 == hdr.data.b3 && hdr.data.b4 == 8w10) - test1.apply(); - else - test2.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway2-midend.p4 b/testdata/v1_samples_outputs/gateway2-midend.p4 deleted file mode 100644 index f0832053813..00000000000 --- a/testdata/v1_samples_outputs/gateway2-midend.p4 +++ /dev/null @@ -1,96 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - action NoAction_1() { - } - @name("setb1") action setb1_0(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop_0() { - } - @name("noop") action noop() { - } - @name("test1") table test1_0() { - actions = { - setb1_0; - noop_0; - NoAction_0; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction_0(); - } - @name("test2") table test2_0() { - actions = { - setb1; - noop; - NoAction_1; - } - key = { - hdr.data.f2: exact; - } - default_action = NoAction_0(); - } - apply { - if (hdr.data.b2 == hdr.data.b3 && hdr.data.b4 == 8w10) - test1_0.apply(); - else - test2_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway2.p4 b/testdata/v1_samples_outputs/gateway2.p4 index f1c4fbdd29c..1ff0aeb3261 100644 --- a/testdata/v1_samples_outputs/gateway2.p4 +++ b/testdata/v1_samples_outputs/gateway2.p4 @@ -43,7 +43,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("test2") table test2() { actions = { setb1; @@ -55,7 +54,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (hdr.data.b2 == hdr.data.b3 && hdr.data.b4 == 8w10) { test1.apply(); diff --git a/testdata/v1_samples_outputs/gateway3-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/gateway3-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..ebe1a1ce2fd --- /dev/null +++ b/testdata/v1_samples_outputs/gateway3-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,208 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + @name("test2") table test2() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f2: exact; + } + default_action = NoAction(); + } + apply { + if (hdr.data.b2 == hdr.data.b3 || hdr.data.b4 == 8w10) + if (hdr.data.b1 == hdr.data.b2 && hdr.data.b4 == 8w10) + test1.apply(); + else + if (hdr.data.b1 != hdr.data.b2) + test2.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/gateway3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..77dfcf119df --- /dev/null +++ b/testdata/v1_samples_outputs/gateway3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,192 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + @name("test2") table test2() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f2: exact; + } + default_action = NoAction(); + } + apply { + if (hdr.data.b2 == hdr.data.b3 || hdr.data.b4 == 8w10) + if (hdr.data.b1 == hdr.data.b2 && hdr.data.b4 == 8w10) + test1.apply(); + else + if (hdr.data.b1 != hdr.data.b2) + test2.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway3-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/gateway3-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..826e546d431 --- /dev/null +++ b/testdata/v1_samples_outputs/gateway3-MidEnd_25_Evaluator.p4 @@ -0,0 +1,200 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + action NoAction_1() { + } + @name("setb1") action setb1_0(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop_0() { + } + @name("noop") action noop() { + } + @name("test1") table test1_0() { + actions = { + setb1_0; + noop_0; + NoAction_0; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction_0(); + } + @name("test2") table test2_0() { + actions = { + setb1; + noop; + NoAction_1; + } + key = { + hdr.data.f2: exact; + } + default_action = NoAction_0(); + } + apply { + if (hdr.data.b2 == hdr.data.b3 || hdr.data.b4 == 8w10) + if (hdr.data.b1 == hdr.data.b2 && hdr.data.b4 == 8w10) + test1_0.apply(); + else + if (hdr.data.b1 != hdr.data.b2) + test2_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway3-fe.p4 b/testdata/v1_samples_outputs/gateway3-fe.p4 deleted file mode 100644 index d398a85074b..00000000000 --- a/testdata/v1_samples_outputs/gateway3-fe.p4 +++ /dev/null @@ -1,90 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - @name("test2") table test2() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f2: exact; - } - default_action = NoAction(); - } - - apply { - if (hdr.data.b2 == hdr.data.b3 || hdr.data.b4 == 8w10) - if (hdr.data.b1 == hdr.data.b2 && hdr.data.b4 == 8w10) - test1.apply(); - else - if (hdr.data.b1 != hdr.data.b2) - test2.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway3-last.p4 b/testdata/v1_samples_outputs/gateway3-last.p4 deleted file mode 100644 index d398a85074b..00000000000 --- a/testdata/v1_samples_outputs/gateway3-last.p4 +++ /dev/null @@ -1,90 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - @name("test2") table test2() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f2: exact; - } - default_action = NoAction(); - } - - apply { - if (hdr.data.b2 == hdr.data.b3 || hdr.data.b4 == 8w10) - if (hdr.data.b1 == hdr.data.b2 && hdr.data.b4 == 8w10) - test1.apply(); - else - if (hdr.data.b1 != hdr.data.b2) - test2.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway3-midend.p4 b/testdata/v1_samples_outputs/gateway3-midend.p4 deleted file mode 100644 index c3e201537e1..00000000000 --- a/testdata/v1_samples_outputs/gateway3-midend.p4 +++ /dev/null @@ -1,98 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - action NoAction_1() { - } - @name("setb1") action setb1_0(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop_0() { - } - @name("noop") action noop() { - } - @name("test1") table test1_0() { - actions = { - setb1_0; - noop_0; - NoAction_0; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction_0(); - } - @name("test2") table test2_0() { - actions = { - setb1; - noop; - NoAction_1; - } - key = { - hdr.data.f2: exact; - } - default_action = NoAction_0(); - } - apply { - if (hdr.data.b2 == hdr.data.b3 || hdr.data.b4 == 8w10) - if (hdr.data.b1 == hdr.data.b2 && hdr.data.b4 == 8w10) - test1_0.apply(); - else - if (hdr.data.b1 != hdr.data.b2) - test2_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway3.p4 b/testdata/v1_samples_outputs/gateway3.p4 index 2e71bce0983..de7704e6339 100644 --- a/testdata/v1_samples_outputs/gateway3.p4 +++ b/testdata/v1_samples_outputs/gateway3.p4 @@ -43,7 +43,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("test2") table test2() { actions = { setb1; @@ -55,7 +54,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (hdr.data.b2 == hdr.data.b3 || hdr.data.b4 == 8w10) { if (hdr.data.b1 == hdr.data.b2 && hdr.data.b4 == 8w10) { diff --git a/testdata/v1_samples_outputs/gateway4-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/gateway4-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..8e1ddfdd4f1 --- /dev/null +++ b/testdata/v1_samples_outputs/gateway4-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,220 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +header data2_t { + bit<8> x1; + bit<8> x2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; + @name("data2") + data2_t data2; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_data2") state parse_data2 { + packet.extract(hdr.data2); + transition accept; + } + @name("start") state start { + packet.extract(hdr.data); + transition select(hdr.data.b1) { + 8w0x1: parse_data2; + default: accept; + } + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + @name("test2") table test2() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f2: exact; + } + default_action = NoAction(); + } + apply { + if (hdr.data2.isValid()) + test1.apply(); + test2.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + packet.emit(hdr.data2); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/gateway4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..859eac7c6eb --- /dev/null +++ b/testdata/v1_samples_outputs/gateway4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,204 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +header data2_t { + bit<8> x1; + bit<8> x2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; + @name("data2") + data2_t data2; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_data2") state parse_data2 { + packet.extract(hdr.data2); + transition accept; + } + @name("start") state start { + packet.extract(hdr.data); + transition select(hdr.data.b1) { + 8w0x1: parse_data2; + default: accept; + } + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + @name("test2") table test2() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f2: exact; + } + default_action = NoAction(); + } + apply { + if (hdr.data2.isValid()) + test1.apply(); + test2.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + packet.emit(hdr.data2); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway4-midend.p4 b/testdata/v1_samples_outputs/gateway4-MidEnd_25_Evaluator.p4 similarity index 51% rename from testdata/v1_samples_outputs/gateway4-midend.p4 rename to testdata/v1_samples_outputs/gateway4-MidEnd_25_Evaluator.p4 index 1213f526f40..d622a77572a 100644 --- a/testdata/v1_samples_outputs/gateway4-midend.p4 +++ b/testdata/v1_samples_outputs/gateway4-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header data_t { bit<32> f1; bit<32> f2; diff --git a/testdata/v1_samples_outputs/gateway4-fe.p4 b/testdata/v1_samples_outputs/gateway4-fe.p4 deleted file mode 100644 index c8d4723b156..00000000000 --- a/testdata/v1_samples_outputs/gateway4-fe.p4 +++ /dev/null @@ -1,102 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -header data2_t { - bit<8> x1; - bit<8> x2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; - @name("data2") - data2_t data2; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("parse_data2") state parse_data2 { - packet.extract(hdr.data2); - transition accept; - } - @name("start") state start { - packet.extract(hdr.data); - transition select(hdr.data.b1) { - 8w0x1: parse_data2; - default: accept; - } - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - @name("test2") table test2() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f2: exact; - } - default_action = NoAction(); - } - - apply { - if (hdr.data2.isValid()) - test1.apply(); - test2.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - packet.emit(hdr.data2); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway4-last.p4 b/testdata/v1_samples_outputs/gateway4-last.p4 deleted file mode 100644 index c8d4723b156..00000000000 --- a/testdata/v1_samples_outputs/gateway4-last.p4 +++ /dev/null @@ -1,102 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -header data2_t { - bit<8> x1; - bit<8> x2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; - @name("data2") - data2_t data2; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("parse_data2") state parse_data2 { - packet.extract(hdr.data2); - transition accept; - } - @name("start") state start { - packet.extract(hdr.data); - transition select(hdr.data.b1) { - 8w0x1: parse_data2; - default: accept; - } - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - @name("test2") table test2() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f2: exact; - } - default_action = NoAction(); - } - - apply { - if (hdr.data2.isValid()) - test1.apply(); - test2.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - packet.emit(hdr.data2); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway4.p4 b/testdata/v1_samples_outputs/gateway4.p4 index 37fcf8005a5..e12d1676f16 100644 --- a/testdata/v1_samples_outputs/gateway4.p4 +++ b/testdata/v1_samples_outputs/gateway4.p4 @@ -57,7 +57,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("test2") table test2() { actions = { setb1; @@ -69,7 +68,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (hdr.data2.isValid()) { test1.apply(); diff --git a/testdata/v1_samples_outputs/gateway5-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/gateway5-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..e699e0463bf --- /dev/null +++ b/testdata/v1_samples_outputs/gateway5-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,213 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<2> x1; + bit<3> pad0; + bit<2> x2; + bit<5> pad1; + bit<1> x3; + bit<2> pad2; + bit<32> skip; + bit<1> x4; + bit<1> x5; + bit<6> pad3; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setf4") action setf4(bit<32> val) { + hdr.data.f4 = val; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setf4; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + @name("test2") table test2() { + actions = { + setf4; + noop; + NoAction; + } + key = { + hdr.data.f2: exact; + } + default_action = NoAction(); + } + apply { + if (hdr.data.x1 == 2w1 && hdr.data.x4 == 1w0) + test1.apply(); + else + test2.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway5-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/gateway5-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..8a5f844617e --- /dev/null +++ b/testdata/v1_samples_outputs/gateway5-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,197 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<2> x1; + bit<3> pad0; + bit<2> x2; + bit<5> pad1; + bit<1> x3; + bit<2> pad2; + bit<32> skip; + bit<1> x4; + bit<1> x5; + bit<6> pad3; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setf4") action setf4(bit<32> val) { + hdr.data.f4 = val; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setf4; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + @name("test2") table test2() { + actions = { + setf4; + noop; + NoAction; + } + key = { + hdr.data.f2: exact; + } + default_action = NoAction(); + } + apply { + if (hdr.data.x1 == 2w1 && hdr.data.x4 == 1w0) + test1.apply(); + else + test2.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway5-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/gateway5-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..875aeaab940 --- /dev/null +++ b/testdata/v1_samples_outputs/gateway5-MidEnd_25_Evaluator.p4 @@ -0,0 +1,204 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<2> x1; + bit<3> pad0; + bit<2> x2; + bit<5> pad1; + bit<1> x3; + bit<2> pad2; + bit<32> skip; + bit<1> x4; + bit<1> x5; + bit<6> pad3; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + action NoAction_1() { + } + @name("setf4") action setf4_0(bit<32> val) { + hdr.data.f4 = val; + } + @name("setf4") action setf4(bit<32> val) { + hdr.data.f4 = val; + } + @name("noop") action noop_0() { + } + @name("noop") action noop() { + } + @name("test1") table test1_0() { + actions = { + setf4_0; + noop_0; + NoAction_0; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction_0(); + } + @name("test2") table test2_0() { + actions = { + setf4; + noop; + NoAction_1; + } + key = { + hdr.data.f2: exact; + } + default_action = NoAction_0(); + } + apply { + if (hdr.data.x1 == 2w1 && hdr.data.x4 == 1w0) + test1_0.apply(); + else + test2_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway5-fe.p4 b/testdata/v1_samples_outputs/gateway5-fe.p4 deleted file mode 100644 index 3e76f2457d6..00000000000 --- a/testdata/v1_samples_outputs/gateway5-fe.p4 +++ /dev/null @@ -1,95 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<2> x1; - bit<3> pad0; - bit<2> x2; - bit<5> pad1; - bit<1> x3; - bit<2> pad2; - bit<32> skip; - bit<1> x4; - bit<1> x5; - bit<6> pad3; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setf4") action setf4(bit<32> val) { - hdr.data.f4 = val; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setf4; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - @name("test2") table test2() { - actions = { - setf4; - noop; - NoAction; - } - key = { - hdr.data.f2: exact; - } - default_action = NoAction(); - } - - apply { - if (hdr.data.x1 == 2w1 && hdr.data.x4 == 1w0) - test1.apply(); - else - test2.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway5-last.p4 b/testdata/v1_samples_outputs/gateway5-last.p4 deleted file mode 100644 index 3e76f2457d6..00000000000 --- a/testdata/v1_samples_outputs/gateway5-last.p4 +++ /dev/null @@ -1,95 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<2> x1; - bit<3> pad0; - bit<2> x2; - bit<5> pad1; - bit<1> x3; - bit<2> pad2; - bit<32> skip; - bit<1> x4; - bit<1> x5; - bit<6> pad3; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setf4") action setf4(bit<32> val) { - hdr.data.f4 = val; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setf4; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - @name("test2") table test2() { - actions = { - setf4; - noop; - NoAction; - } - key = { - hdr.data.f2: exact; - } - default_action = NoAction(); - } - - apply { - if (hdr.data.x1 == 2w1 && hdr.data.x4 == 1w0) - test1.apply(); - else - test2.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway5-midend.p4 b/testdata/v1_samples_outputs/gateway5-midend.p4 deleted file mode 100644 index 291f41141f1..00000000000 --- a/testdata/v1_samples_outputs/gateway5-midend.p4 +++ /dev/null @@ -1,102 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<2> x1; - bit<3> pad0; - bit<2> x2; - bit<5> pad1; - bit<1> x3; - bit<2> pad2; - bit<32> skip; - bit<1> x4; - bit<1> x5; - bit<6> pad3; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - action NoAction_1() { - } - @name("setf4") action setf4_0(bit<32> val) { - hdr.data.f4 = val; - } - @name("setf4") action setf4(bit<32> val) { - hdr.data.f4 = val; - } - @name("noop") action noop_0() { - } - @name("noop") action noop() { - } - @name("test1") table test1_0() { - actions = { - setf4_0; - noop_0; - NoAction_0; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction_0(); - } - @name("test2") table test2_0() { - actions = { - setf4; - noop; - NoAction_1; - } - key = { - hdr.data.f2: exact; - } - default_action = NoAction_0(); - } - apply { - if (hdr.data.x1 == 2w1 && hdr.data.x4 == 1w0) - test1_0.apply(); - else - test2_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway5.p4 b/testdata/v1_samples_outputs/gateway5.p4 index 124faf08729..fbb6d475105 100644 --- a/testdata/v1_samples_outputs/gateway5.p4 +++ b/testdata/v1_samples_outputs/gateway5.p4 @@ -50,7 +50,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("test2") table test2() { actions = { setf4; @@ -62,7 +61,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (hdr.data.x1 == 2w1 && hdr.data.x4 == 1w0) { test1.apply(); diff --git a/testdata/v1_samples_outputs/gateway6-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/gateway6-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..97af1efaf7f --- /dev/null +++ b/testdata/v1_samples_outputs/gateway6-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,207 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val) { + hdr.data.b1 = val; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + @name("test2") table test2() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f2: exact; + } + default_action = NoAction(); + } + apply { + if (8w1 == (8w15 & hdr.data.b2)) + test1.apply(); + else + test2.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway6-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/gateway6-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..94f29c0b12c --- /dev/null +++ b/testdata/v1_samples_outputs/gateway6-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,191 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val) { + hdr.data.b1 = val; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + @name("test2") table test2() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f2: exact; + } + default_action = NoAction(); + } + apply { + if (8w1 == (8w15 & hdr.data.b2)) + test1.apply(); + else + test2.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway6-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/gateway6-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..9164b183072 --- /dev/null +++ b/testdata/v1_samples_outputs/gateway6-MidEnd_25_Evaluator.p4 @@ -0,0 +1,198 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + action NoAction_1() { + } + @name("setb1") action setb1_0(bit<8> val) { + hdr.data.b1 = val; + } + @name("setb1") action setb1(bit<8> val) { + hdr.data.b1 = val; + } + @name("noop") action noop_0() { + } + @name("noop") action noop() { + } + @name("test1") table test1_0() { + actions = { + setb1_0; + noop_0; + NoAction_0; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction_0(); + } + @name("test2") table test2_0() { + actions = { + setb1; + noop; + NoAction_1; + } + key = { + hdr.data.f2: exact; + } + default_action = NoAction_0(); + } + apply { + if (8w1 == (8w15 & hdr.data.b2)) + test1_0.apply(); + else + test2_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway6-fe.p4 b/testdata/v1_samples_outputs/gateway6-fe.p4 deleted file mode 100644 index f1146d7fa70..00000000000 --- a/testdata/v1_samples_outputs/gateway6-fe.p4 +++ /dev/null @@ -1,89 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val) { - hdr.data.b1 = val; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - @name("test2") table test2() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f2: exact; - } - default_action = NoAction(); - } - - apply { - if (8w1 == (8w15 & hdr.data.b2)) - test1.apply(); - else - test2.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway6-last.p4 b/testdata/v1_samples_outputs/gateway6-last.p4 deleted file mode 100644 index f1146d7fa70..00000000000 --- a/testdata/v1_samples_outputs/gateway6-last.p4 +++ /dev/null @@ -1,89 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val) { - hdr.data.b1 = val; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - @name("test2") table test2() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f2: exact; - } - default_action = NoAction(); - } - - apply { - if (8w1 == (8w15 & hdr.data.b2)) - test1.apply(); - else - test2.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway6-midend.p4 b/testdata/v1_samples_outputs/gateway6-midend.p4 deleted file mode 100644 index 225dd0b1c93..00000000000 --- a/testdata/v1_samples_outputs/gateway6-midend.p4 +++ /dev/null @@ -1,96 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - action NoAction_1() { - } - @name("setb1") action setb1_0(bit<8> val) { - hdr.data.b1 = val; - } - @name("setb1") action setb1(bit<8> val) { - hdr.data.b1 = val; - } - @name("noop") action noop_0() { - } - @name("noop") action noop() { - } - @name("test1") table test1_0() { - actions = { - setb1_0; - noop_0; - NoAction_0; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction_0(); - } - @name("test2") table test2_0() { - actions = { - setb1; - noop; - NoAction_1; - } - key = { - hdr.data.f2: exact; - } - default_action = NoAction_0(); - } - apply { - if (8w1 == (8w15 & hdr.data.b2)) - test1_0.apply(); - else - test2_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway6.p4 b/testdata/v1_samples_outputs/gateway6.p4 index a3906157237..cfdd63f20ca 100644 --- a/testdata/v1_samples_outputs/gateway6.p4 +++ b/testdata/v1_samples_outputs/gateway6.p4 @@ -44,7 +44,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("test2") table test2() { actions = { setb1; @@ -56,7 +55,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (8w1 == (8w15 & hdr.data.b2)) { test1.apply(); diff --git a/testdata/v1_samples_outputs/gateway7-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/gateway7-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..45d0eaa97a3 --- /dev/null +++ b/testdata/v1_samples_outputs/gateway7-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,207 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val) { + hdr.data.b1 = val; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + @name("test2") table test2() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f2: exact; + } + default_action = NoAction(); + } + apply { + if (hdr.data.b2 > 8w50) + test1.apply(); + else + test2.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway7-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/gateway7-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..b9d8633eed1 --- /dev/null +++ b/testdata/v1_samples_outputs/gateway7-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,191 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val) { + hdr.data.b1 = val; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + @name("test2") table test2() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f2: exact; + } + default_action = NoAction(); + } + apply { + if (hdr.data.b2 > 8w50) + test1.apply(); + else + test2.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway7-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/gateway7-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..52b114936e0 --- /dev/null +++ b/testdata/v1_samples_outputs/gateway7-MidEnd_25_Evaluator.p4 @@ -0,0 +1,198 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + action NoAction_1() { + } + @name("setb1") action setb1_0(bit<8> val) { + hdr.data.b1 = val; + } + @name("setb1") action setb1(bit<8> val) { + hdr.data.b1 = val; + } + @name("noop") action noop_0() { + } + @name("noop") action noop() { + } + @name("test1") table test1_0() { + actions = { + setb1_0; + noop_0; + NoAction_0; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction_0(); + } + @name("test2") table test2_0() { + actions = { + setb1; + noop; + NoAction_1; + } + key = { + hdr.data.f2: exact; + } + default_action = NoAction_0(); + } + apply { + if (hdr.data.b2 > 8w50) + test1_0.apply(); + else + test2_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway7-fe.p4 b/testdata/v1_samples_outputs/gateway7-fe.p4 deleted file mode 100644 index 134ecdae355..00000000000 --- a/testdata/v1_samples_outputs/gateway7-fe.p4 +++ /dev/null @@ -1,89 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val) { - hdr.data.b1 = val; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - @name("test2") table test2() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f2: exact; - } - default_action = NoAction(); - } - - apply { - if (hdr.data.b2 > 8w50) - test1.apply(); - else - test2.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway7-last.p4 b/testdata/v1_samples_outputs/gateway7-last.p4 deleted file mode 100644 index 134ecdae355..00000000000 --- a/testdata/v1_samples_outputs/gateway7-last.p4 +++ /dev/null @@ -1,89 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val) { - hdr.data.b1 = val; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - @name("test2") table test2() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f2: exact; - } - default_action = NoAction(); - } - - apply { - if (hdr.data.b2 > 8w50) - test1.apply(); - else - test2.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway7-midend.p4 b/testdata/v1_samples_outputs/gateway7-midend.p4 deleted file mode 100644 index 4a023bccaed..00000000000 --- a/testdata/v1_samples_outputs/gateway7-midend.p4 +++ /dev/null @@ -1,96 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - action NoAction_1() { - } - @name("setb1") action setb1_0(bit<8> val) { - hdr.data.b1 = val; - } - @name("setb1") action setb1(bit<8> val) { - hdr.data.b1 = val; - } - @name("noop") action noop_0() { - } - @name("noop") action noop() { - } - @name("test1") table test1_0() { - actions = { - setb1_0; - noop_0; - NoAction_0; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction_0(); - } - @name("test2") table test2_0() { - actions = { - setb1; - noop; - NoAction_1; - } - key = { - hdr.data.f2: exact; - } - default_action = NoAction_0(); - } - apply { - if (hdr.data.b2 > 8w50) - test1_0.apply(); - else - test2_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/gateway7.p4 b/testdata/v1_samples_outputs/gateway7.p4 index bfbe4fbee03..caa7c4abf16 100644 --- a/testdata/v1_samples_outputs/gateway7.p4 +++ b/testdata/v1_samples_outputs/gateway7.p4 @@ -44,7 +44,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("test2") table test2() { actions = { setb1; @@ -56,7 +55,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (hdr.data.b2 > 8w50) { test1.apply(); diff --git a/testdata/v1_samples_outputs/hit-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/hit-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..e4ba8152cd8 --- /dev/null +++ b/testdata/v1_samples_outputs/hit-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,213 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<16> h1; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: ternary; + } + default_action = NoAction(); + } + @name("test2") table test2() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f2: ternary; + } + default_action = NoAction(); + } + @name("test4") table test4() { + actions = { + noop; + NoAction; + } + default_action = NoAction(); + } + apply { + if (test1.apply().hit) + test2.apply(); + test4.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/hit-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/hit-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..6a586d2791b --- /dev/null +++ b/testdata/v1_samples_outputs/hit-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,197 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<16> h1; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: ternary; + } + default_action = NoAction(); + } + @name("test2") table test2() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f2: ternary; + } + default_action = NoAction(); + } + @name("test4") table test4() { + actions = { + noop; + NoAction; + } + default_action = NoAction(); + } + apply { + if (test1.apply().hit) + test2.apply(); + test4.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/hit-midend.p4 b/testdata/v1_samples_outputs/hit-MidEnd_25_Evaluator.p4 similarity index 50% rename from testdata/v1_samples_outputs/hit-midend.p4 rename to testdata/v1_samples_outputs/hit-MidEnd_25_Evaluator.p4 index 8f4e47666ed..47a5890dd68 100644 --- a/testdata/v1_samples_outputs/hit-midend.p4 +++ b/testdata/v1_samples_outputs/hit-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header data_t { bit<32> f1; bit<32> f2; diff --git a/testdata/v1_samples_outputs/hit-fe.p4 b/testdata/v1_samples_outputs/hit-fe.p4 deleted file mode 100644 index 0b58f9d3053..00000000000 --- a/testdata/v1_samples_outputs/hit-fe.p4 +++ /dev/null @@ -1,96 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<16> h1; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: ternary; - } - default_action = NoAction(); - } - - @name("test2") table test2() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f2: ternary; - } - default_action = NoAction(); - } - - @name("test4") table test4() { - actions = { - noop; - NoAction; - } - default_action = NoAction(); - } - - apply { - if (test1.apply().hit) - test2.apply(); - test4.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/hit-last.p4 b/testdata/v1_samples_outputs/hit-last.p4 deleted file mode 100644 index 0b58f9d3053..00000000000 --- a/testdata/v1_samples_outputs/hit-last.p4 +++ /dev/null @@ -1,96 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<16> h1; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: ternary; - } - default_action = NoAction(); - } - - @name("test2") table test2() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f2: ternary; - } - default_action = NoAction(); - } - - @name("test4") table test4() { - actions = { - noop; - NoAction; - } - default_action = NoAction(); - } - - apply { - if (test1.apply().hit) - test2.apply(); - test4.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/hit.p4 b/testdata/v1_samples_outputs/hit.p4 index 335e4d3d71e..5c9150191cb 100644 --- a/testdata/v1_samples_outputs/hit.p4 +++ b/testdata/v1_samples_outputs/hit.p4 @@ -44,7 +44,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("test2") table test2() { actions = { setb1; @@ -56,7 +55,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("test4") table test4() { actions = { noop; @@ -64,7 +62,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (test1.apply().hit) { test2.apply(); diff --git a/testdata/v1_samples_outputs/hitmiss-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/hitmiss-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..96d706b40d6 --- /dev/null +++ b/testdata/v1_samples_outputs/hitmiss-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,218 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<16> h1; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: ternary; + } + default_action = NoAction(); + } + @name("test2") table test2() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f2: ternary; + } + default_action = NoAction(); + } + @name("test3") table test3() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f3: ternary; + } + default_action = NoAction(); + } + apply { + if (test1.apply().hit) + test2.apply(); + else + test3.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/hitmiss-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/hitmiss-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..5e85a2007bb --- /dev/null +++ b/testdata/v1_samples_outputs/hitmiss-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,202 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<16> h1; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: ternary; + } + default_action = NoAction(); + } + @name("test2") table test2() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f2: ternary; + } + default_action = NoAction(); + } + @name("test3") table test3() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f3: ternary; + } + default_action = NoAction(); + } + apply { + if (test1.apply().hit) + test2.apply(); + else + test3.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/hitmiss-midend.p4 b/testdata/v1_samples_outputs/hitmiss-MidEnd_25_Evaluator.p4 similarity index 53% rename from testdata/v1_samples_outputs/hitmiss-midend.p4 rename to testdata/v1_samples_outputs/hitmiss-MidEnd_25_Evaluator.p4 index 8809bbdd130..c3bb8cb1ab1 100644 --- a/testdata/v1_samples_outputs/hitmiss-midend.p4 +++ b/testdata/v1_samples_outputs/hitmiss-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header data_t { bit<32> f1; bit<32> f2; diff --git a/testdata/v1_samples_outputs/hitmiss-fe.p4 b/testdata/v1_samples_outputs/hitmiss-fe.p4 deleted file mode 100644 index 65965d4d408..00000000000 --- a/testdata/v1_samples_outputs/hitmiss-fe.p4 +++ /dev/null @@ -1,101 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<16> h1; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: ternary; - } - default_action = NoAction(); - } - - @name("test2") table test2() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f2: ternary; - } - default_action = NoAction(); - } - - @name("test3") table test3() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f3: ternary; - } - default_action = NoAction(); - } - - apply { - if (test1.apply().hit) - test2.apply(); - else - test3.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/hitmiss-last.p4 b/testdata/v1_samples_outputs/hitmiss-last.p4 deleted file mode 100644 index 65965d4d408..00000000000 --- a/testdata/v1_samples_outputs/hitmiss-last.p4 +++ /dev/null @@ -1,101 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<16> h1; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: ternary; - } - default_action = NoAction(); - } - - @name("test2") table test2() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f2: ternary; - } - default_action = NoAction(); - } - - @name("test3") table test3() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f3: ternary; - } - default_action = NoAction(); - } - - apply { - if (test1.apply().hit) - test2.apply(); - else - test3.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/hitmiss.p4 b/testdata/v1_samples_outputs/hitmiss.p4 index 2b5ad462861..da95fb5fc52 100644 --- a/testdata/v1_samples_outputs/hitmiss.p4 +++ b/testdata/v1_samples_outputs/hitmiss.p4 @@ -44,7 +44,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("test2") table test2() { actions = { setb1; @@ -56,7 +55,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("test3") table test3() { actions = { setb1; @@ -68,7 +66,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (test1.apply().hit) { test2.apply(); diff --git a/testdata/v1_samples_outputs/inline-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/inline-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..1c114d58400 --- /dev/null +++ b/testdata/v1_samples_outputs/inline-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,192 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct h { + bit<1> b; +} + +struct metadata { + @name("m") + h m; +} + +struct headers { +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + transition accept; + } +} + +control c(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("x") action x() { + } + @name("t") table t() { + actions = { + x; + NoAction; + } + default_action = NoAction(); + } + apply { + if (meta.m.b == 1w1) + t.apply(); + } +} + +control d(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + c() @name("c") c_0; + apply { + c_0.apply(hdr, meta, standard_metadata); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + d() @name("d") d_0; + apply { + d_0.apply(hdr, meta, standard_metadata); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/inline-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/inline-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..df497448bda --- /dev/null +++ b/testdata/v1_samples_outputs/inline-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,176 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct h { + bit<1> b; +} + +struct metadata { + @name("m") + h m; +} + +struct headers { +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + transition accept; + } +} + +control c(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("x") action x() { + } + @name("t") table t() { + actions = { + x; + NoAction; + } + default_action = NoAction(); + } + apply { + if (meta.m.b == 1w1) + t.apply(); + } +} + +control d(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + c() @name("c") c_0; + apply { + c_0.apply(hdr, meta, standard_metadata); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + d() @name("d") d_0; + apply { + d_0.apply(hdr, meta, standard_metadata); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/inline-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/inline-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..ed996b661ea --- /dev/null +++ b/testdata/v1_samples_outputs/inline-MidEnd_25_Evaluator.p4 @@ -0,0 +1,198 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct h { + bit<1> b; +} + +struct metadata { + @name("m") + h m; +} + +struct headers { +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + headers hdr_1; + metadata meta_1; + standard_metadata_t standard_metadata_1; + headers hdr_0; + metadata meta_0; + standard_metadata_t standard_metadata_0; + action NoAction_0() { + } + @name("d.c.x") action d_c.x() { + } + @name("d.c.t") table d_c.t() { + actions = { + d_c.x; + NoAction_0; + } + default_action = NoAction_0(); + } + action act() { + hdr_1 = hdr; + meta_1 = meta; + standard_metadata_1 = standard_metadata; + hdr_0 = hdr_1; + meta_0 = meta_1; + standard_metadata_0 = standard_metadata_1; + } + action act_0() { + hdr_1 = hdr_0; + meta_1 = meta_0; + standard_metadata_1 = standard_metadata_0; + hdr = hdr_1; + meta = meta_1; + standard_metadata = standard_metadata_1; + } + table tbl_act() { + actions = { + act; + } + const default_action = act(); + } + table tbl_act_0() { + actions = { + act_0; + } + const default_action = act_0(); + } + apply { + tbl_act.apply(); + if (meta_0.m.b == 1w1) + d_c.t.apply(); + tbl_act_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/inline-fe.p4 b/testdata/v1_samples_outputs/inline-fe.p4 deleted file mode 100644 index 06598348da0..00000000000 --- a/testdata/v1_samples_outputs/inline-fe.p4 +++ /dev/null @@ -1,72 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct h { - bit<1> b; -} - -struct metadata { - @name("m") - h m; -} - -struct headers { -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - transition accept; - } -} - -control c(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("x") action x() { - } - @name("t") table t() { - actions = { - x; - NoAction; - } - default_action = NoAction(); - } - apply { - if (meta.m.b == 1w1) - t.apply(); - } -} - -control d(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - c() @name("c") c_0; - apply { - c_0.apply(hdr, meta, standard_metadata); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - d() @name("d") d_0; - apply { - d_0.apply(hdr, meta, standard_metadata); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/inline-last.p4 b/testdata/v1_samples_outputs/inline-last.p4 deleted file mode 100644 index 06598348da0..00000000000 --- a/testdata/v1_samples_outputs/inline-last.p4 +++ /dev/null @@ -1,72 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct h { - bit<1> b; -} - -struct metadata { - @name("m") - h m; -} - -struct headers { -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - transition accept; - } -} - -control c(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("x") action x() { - } - @name("t") table t() { - actions = { - x; - NoAction; - } - default_action = NoAction(); - } - apply { - if (meta.m.b == 1w1) - t.apply(); - } -} - -control d(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - c() @name("c") c_0; - apply { - c_0.apply(hdr, meta, standard_metadata); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - d() @name("d") d_0; - apply { - d_0.apply(hdr, meta, standard_metadata); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/inline-midend.p4 b/testdata/v1_samples_outputs/inline-midend.p4 deleted file mode 100644 index eb6f23b2813..00000000000 --- a/testdata/v1_samples_outputs/inline-midend.p4 +++ /dev/null @@ -1,96 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct h { - bit<1> b; -} - -struct metadata { - @name("m") - h m; -} - -struct headers { -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - headers hdr_1; - metadata meta_1; - standard_metadata_t standard_metadata_1; - headers hdr_0; - metadata meta_0; - standard_metadata_t standard_metadata_0; - action NoAction_0() { - } - @name("d.c.x") action d_c.x() { - } - @name("d.c.t") table d_c.t() { - actions = { - d_c.x; - NoAction_0; - } - default_action = NoAction_0(); - } - action act() { - hdr_1 = hdr; - meta_1 = meta; - standard_metadata_1 = standard_metadata; - hdr_0 = hdr_1; - meta_0 = meta_1; - standard_metadata_0 = standard_metadata_1; - } - action act_0() { - hdr_1 = hdr_0; - meta_1 = meta_0; - standard_metadata_1 = standard_metadata_0; - hdr = hdr_1; - meta = meta_1; - standard_metadata = standard_metadata_1; - } - table tbl_act() { - actions = { - act; - } - const default_action = act(); - } - table tbl_act_0() { - actions = { - act_0; - } - const default_action = act_0(); - } - apply { - tbl_act.apply(); - if (meta_0.m.b == 1w1) - d_c.t.apply(); - tbl_act_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct1-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/instruct1-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..f5514c95bf9 --- /dev/null +++ b/testdata/v1_samples_outputs/instruct1-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,219 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +header data2_t { + bit<16> x1; + bit<16> x2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; + @name("hdr1") + data2_t hdr1; + @name("hdr2") + data2_t hdr2; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_data2") state parse_data2 { + packet.extract(hdr.hdr1); + transition select(hdr.hdr1.x1) { + 16w1 &&& 16w1: parse_hdr2; + default: accept; + } + } + @name("parse_hdr2") state parse_hdr2 { + packet.extract(hdr.hdr2); + transition accept; + } + @name("start") state start { + packet.extract(hdr.data); + transition select(hdr.data.b1) { + 8w0x0: parse_data2; + default: accept; + } + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("decap") action decap() { + hdr.hdr1 = hdr.hdr2; + hdr.hdr2.setValid(false); + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + decap; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + packet.emit(hdr.hdr1); + packet.emit(hdr.hdr2); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/instruct1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..8cd7d75ccd4 --- /dev/null +++ b/testdata/v1_samples_outputs/instruct1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,203 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +header data2_t { + bit<16> x1; + bit<16> x2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; + @name("hdr1") + data2_t hdr1; + @name("hdr2") + data2_t hdr2; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_data2") state parse_data2 { + packet.extract(hdr.hdr1); + transition select(hdr.hdr1.x1) { + 16w1 &&& 16w1: parse_hdr2; + default: accept; + } + } + @name("parse_hdr2") state parse_hdr2 { + packet.extract(hdr.hdr2); + transition accept; + } + @name("start") state start { + packet.extract(hdr.data); + transition select(hdr.data.b1) { + 8w0x0: parse_data2; + default: accept; + } + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("decap") action decap() { + hdr.hdr1 = hdr.hdr2; + hdr.hdr2.setValid(false); + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + decap; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + packet.emit(hdr.hdr1); + packet.emit(hdr.hdr2); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct1-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/instruct1-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..5732fe169bb --- /dev/null +++ b/testdata/v1_samples_outputs/instruct1-MidEnd_25_Evaluator.p4 @@ -0,0 +1,203 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +header data2_t { + bit<16> x1; + bit<16> x2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; + @name("hdr1") + data2_t hdr1; + @name("hdr2") + data2_t hdr2; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_data2") state parse_data2 { + packet.extract(hdr.hdr1); + transition select(hdr.hdr1.x1) { + 16w1 &&& 16w1: parse_hdr2; + default: accept; + } + } + @name("parse_hdr2") state parse_hdr2 { + packet.extract(hdr.hdr2); + transition accept; + } + @name("start") state start { + packet.extract(hdr.data); + transition select(hdr.data.b1) { + 8w0x0: parse_data2; + default: accept; + } + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("decap") action decap_0() { + hdr.hdr1 = hdr.hdr2; + hdr.hdr2.setValid(false); + } + @name("noop") action noop_0() { + } + @name("test1") table test1_0() { + actions = { + decap_0; + noop_0; + NoAction_0; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction_0(); + } + apply { + test1_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + packet.emit(hdr.hdr1); + packet.emit(hdr.hdr2); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct1-fe.p4 b/testdata/v1_samples_outputs/instruct1-fe.p4 deleted file mode 100644 index af2f95c56fa..00000000000 --- a/testdata/v1_samples_outputs/instruct1-fe.p4 +++ /dev/null @@ -1,100 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -header data2_t { - bit<16> x1; - bit<16> x2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; - @name("hdr1") - data2_t hdr1; - @name("hdr2") - data2_t hdr2; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("parse_data2") state parse_data2 { - packet.extract(hdr.hdr1); - transition select(hdr.hdr1.x1) { - 16w1 &&& 16w1: parse_hdr2; - default: accept; - } - } - @name("parse_hdr2") state parse_hdr2 { - packet.extract(hdr.hdr2); - transition accept; - } - @name("start") state start { - packet.extract(hdr.data); - transition select(hdr.data.b1) { - 8w0x0: parse_data2; - default: accept; - } - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("decap") action decap() { - hdr.hdr1 = hdr.hdr2; - hdr.hdr2.setValid(false); - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - decap; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - packet.emit(hdr.hdr1); - packet.emit(hdr.hdr2); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct1-last.p4 b/testdata/v1_samples_outputs/instruct1-last.p4 deleted file mode 100644 index af2f95c56fa..00000000000 --- a/testdata/v1_samples_outputs/instruct1-last.p4 +++ /dev/null @@ -1,100 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -header data2_t { - bit<16> x1; - bit<16> x2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; - @name("hdr1") - data2_t hdr1; - @name("hdr2") - data2_t hdr2; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("parse_data2") state parse_data2 { - packet.extract(hdr.hdr1); - transition select(hdr.hdr1.x1) { - 16w1 &&& 16w1: parse_hdr2; - default: accept; - } - } - @name("parse_hdr2") state parse_hdr2 { - packet.extract(hdr.hdr2); - transition accept; - } - @name("start") state start { - packet.extract(hdr.data); - transition select(hdr.data.b1) { - 8w0x0: parse_data2; - default: accept; - } - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("decap") action decap() { - hdr.hdr1 = hdr.hdr2; - hdr.hdr2.setValid(false); - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - decap; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - packet.emit(hdr.hdr1); - packet.emit(hdr.hdr2); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct1-midend.p4 b/testdata/v1_samples_outputs/instruct1-midend.p4 deleted file mode 100644 index 99321e7c9ad..00000000000 --- a/testdata/v1_samples_outputs/instruct1-midend.p4 +++ /dev/null @@ -1,101 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -header data2_t { - bit<16> x1; - bit<16> x2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; - @name("hdr1") - data2_t hdr1; - @name("hdr2") - data2_t hdr2; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("parse_data2") state parse_data2 { - packet.extract(hdr.hdr1); - transition select(hdr.hdr1.x1) { - 16w1 &&& 16w1: parse_hdr2; - default: accept; - } - } - @name("parse_hdr2") state parse_hdr2 { - packet.extract(hdr.hdr2); - transition accept; - } - @name("start") state start { - packet.extract(hdr.data); - transition select(hdr.data.b1) { - 8w0x0: parse_data2; - default: accept; - } - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("decap") action decap_0() { - hdr.hdr1 = hdr.hdr2; - hdr.hdr2.setValid(false); - } - @name("noop") action noop_0() { - } - @name("test1") table test1_0() { - actions = { - decap_0; - noop_0; - NoAction_0; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction_0(); - } - apply { - test1_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - packet.emit(hdr.hdr1); - packet.emit(hdr.hdr2); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct1.p4 b/testdata/v1_samples_outputs/instruct1.p4 index af2f95c56fa..dc6e5e940c9 100644 --- a/testdata/v1_samples_outputs/instruct1.p4 +++ b/testdata/v1_samples_outputs/instruct1.p4 @@ -68,7 +68,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { test1.apply(); } diff --git a/testdata/v1_samples_outputs/instruct2-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/instruct2-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..78c5c2b33a8 --- /dev/null +++ b/testdata/v1_samples_outputs/instruct2-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,202 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("do_add") action do_add() { + hdr.data.b3 = hdr.data.b1 + hdr.data.b2; + } + @name("do_and") action do_and() { + hdr.data.b2 = hdr.data.b3 & hdr.data.b4; + } + @name("do_or") action do_or() { + hdr.data.b4 = hdr.data.b3 | hdr.data.b1; + } + @name("do_xor") action do_xor() { + hdr.data.b1 = hdr.data.b2 ^ hdr.data.b3; + } + @name("test1") table test1() { + actions = { + do_add; + do_and; + do_or; + do_xor; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/instruct2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..2e11415bdff --- /dev/null +++ b/testdata/v1_samples_outputs/instruct2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,186 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("do_add") action do_add() { + hdr.data.b3 = hdr.data.b1 + hdr.data.b2; + } + @name("do_and") action do_and() { + hdr.data.b2 = hdr.data.b3 & hdr.data.b4; + } + @name("do_or") action do_or() { + hdr.data.b4 = hdr.data.b3 | hdr.data.b1; + } + @name("do_xor") action do_xor() { + hdr.data.b1 = hdr.data.b2 ^ hdr.data.b3; + } + @name("test1") table test1() { + actions = { + do_add; + do_and; + do_or; + do_xor; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct2-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/instruct2-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..9aae60c6ddb --- /dev/null +++ b/testdata/v1_samples_outputs/instruct2-MidEnd_25_Evaluator.p4 @@ -0,0 +1,186 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("do_add") action do_add_0() { + hdr.data.b3 = hdr.data.b1 + hdr.data.b2; + } + @name("do_and") action do_and_0() { + hdr.data.b2 = hdr.data.b3 & hdr.data.b4; + } + @name("do_or") action do_or_0() { + hdr.data.b4 = hdr.data.b3 | hdr.data.b1; + } + @name("do_xor") action do_xor_0() { + hdr.data.b1 = hdr.data.b2 ^ hdr.data.b3; + } + @name("test1") table test1_0() { + actions = { + do_add_0; + do_and_0; + do_or_0; + do_xor_0; + NoAction_0; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction_0(); + } + apply { + test1_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct2-fe.p4 b/testdata/v1_samples_outputs/instruct2-fe.p4 deleted file mode 100644 index d3397a95db5..00000000000 --- a/testdata/v1_samples_outputs/instruct2-fe.p4 +++ /dev/null @@ -1,83 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("do_add") action do_add() { - hdr.data.b3 = hdr.data.b1 + hdr.data.b2; - } - @name("do_and") action do_and() { - hdr.data.b2 = hdr.data.b3 & hdr.data.b4; - } - @name("do_or") action do_or() { - hdr.data.b4 = hdr.data.b3 | hdr.data.b1; - } - @name("do_xor") action do_xor() { - hdr.data.b1 = hdr.data.b2 ^ hdr.data.b3; - } - @name("test1") table test1() { - actions = { - do_add; - do_and; - do_or; - do_xor; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct2-last.p4 b/testdata/v1_samples_outputs/instruct2-last.p4 deleted file mode 100644 index d3397a95db5..00000000000 --- a/testdata/v1_samples_outputs/instruct2-last.p4 +++ /dev/null @@ -1,83 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("do_add") action do_add() { - hdr.data.b3 = hdr.data.b1 + hdr.data.b2; - } - @name("do_and") action do_and() { - hdr.data.b2 = hdr.data.b3 & hdr.data.b4; - } - @name("do_or") action do_or() { - hdr.data.b4 = hdr.data.b3 | hdr.data.b1; - } - @name("do_xor") action do_xor() { - hdr.data.b1 = hdr.data.b2 ^ hdr.data.b3; - } - @name("test1") table test1() { - actions = { - do_add; - do_and; - do_or; - do_xor; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct2-midend.p4 b/testdata/v1_samples_outputs/instruct2-midend.p4 deleted file mode 100644 index f86d36b6ebc..00000000000 --- a/testdata/v1_samples_outputs/instruct2-midend.p4 +++ /dev/null @@ -1,84 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("do_add") action do_add_0() { - hdr.data.b3 = hdr.data.b1 + hdr.data.b2; - } - @name("do_and") action do_and_0() { - hdr.data.b2 = hdr.data.b3 & hdr.data.b4; - } - @name("do_or") action do_or_0() { - hdr.data.b4 = hdr.data.b3 | hdr.data.b1; - } - @name("do_xor") action do_xor_0() { - hdr.data.b1 = hdr.data.b2 ^ hdr.data.b3; - } - @name("test1") table test1_0() { - actions = { - do_add_0; - do_and_0; - do_or_0; - do_xor_0; - NoAction_0; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction_0(); - } - apply { - test1_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct2.p4 b/testdata/v1_samples_outputs/instruct2.p4 index d3397a95db5..fca6ec57475 100644 --- a/testdata/v1_samples_outputs/instruct2.p4 +++ b/testdata/v1_samples_outputs/instruct2.p4 @@ -53,7 +53,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { test1.apply(); } diff --git a/testdata/v1_samples_outputs/instruct3-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/instruct3-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..523e26d6369 --- /dev/null +++ b/testdata/v1_samples_outputs/instruct3-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,192 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<2> x1; + bit<2> x2; + bit<2> x3; + bit<2> x4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setx") action setx() { + hdr.data.x2 = 2w2; + hdr.data.x4 = 2w1; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setx; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/instruct3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..7180f91f38e --- /dev/null +++ b/testdata/v1_samples_outputs/instruct3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,176 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<2> x1; + bit<2> x2; + bit<2> x3; + bit<2> x4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setx") action setx() { + hdr.data.x2 = 2w2; + hdr.data.x4 = 2w1; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setx; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct3-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/instruct3-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..b34e6d6574f --- /dev/null +++ b/testdata/v1_samples_outputs/instruct3-MidEnd_25_Evaluator.p4 @@ -0,0 +1,176 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<2> x1; + bit<2> x2; + bit<2> x3; + bit<2> x4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("setx") action setx_0() { + hdr.data.x2 = 2w2; + hdr.data.x4 = 2w1; + } + @name("noop") action noop_0() { + } + @name("test1") table test1_0() { + actions = { + setx_0; + noop_0; + NoAction_0; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction_0(); + } + apply { + test1_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct3-fe.p4 b/testdata/v1_samples_outputs/instruct3-fe.p4 deleted file mode 100644 index e3950ba4159..00000000000 --- a/testdata/v1_samples_outputs/instruct3-fe.p4 +++ /dev/null @@ -1,73 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<2> x1; - bit<2> x2; - bit<2> x3; - bit<2> x4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setx") action setx() { - hdr.data.x2 = 2w2; - hdr.data.x4 = 2w1; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setx; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct3-last.p4 b/testdata/v1_samples_outputs/instruct3-last.p4 deleted file mode 100644 index e3950ba4159..00000000000 --- a/testdata/v1_samples_outputs/instruct3-last.p4 +++ /dev/null @@ -1,73 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<2> x1; - bit<2> x2; - bit<2> x3; - bit<2> x4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setx") action setx() { - hdr.data.x2 = 2w2; - hdr.data.x4 = 2w1; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setx; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct3-midend.p4 b/testdata/v1_samples_outputs/instruct3-midend.p4 deleted file mode 100644 index 0d43c60c5c0..00000000000 --- a/testdata/v1_samples_outputs/instruct3-midend.p4 +++ /dev/null @@ -1,74 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<2> x1; - bit<2> x2; - bit<2> x3; - bit<2> x4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("setx") action setx_0() { - hdr.data.x2 = 2w2; - hdr.data.x4 = 2w1; - } - @name("noop") action noop_0() { - } - @name("test1") table test1_0() { - actions = { - setx_0; - noop_0; - NoAction_0; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction_0(); - } - apply { - test1_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct3.p4 b/testdata/v1_samples_outputs/instruct3.p4 index e3950ba4159..5f241738fa7 100644 --- a/testdata/v1_samples_outputs/instruct3.p4 +++ b/testdata/v1_samples_outputs/instruct3.p4 @@ -43,7 +43,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { test1.apply(); } diff --git a/testdata/v1_samples_outputs/instruct4-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/instruct4-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..e81ab2c77cb --- /dev/null +++ b/testdata/v1_samples_outputs/instruct4-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,193 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setf4") action setf4() { + hdr.data.f4 = 32w0x70a50; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setf4; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/instruct4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..2a91783c1eb --- /dev/null +++ b/testdata/v1_samples_outputs/instruct4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,177 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setf4") action setf4() { + hdr.data.f4 = 32w0x70a50; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setf4; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct4-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/instruct4-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..c76e6ef6d3c --- /dev/null +++ b/testdata/v1_samples_outputs/instruct4-MidEnd_25_Evaluator.p4 @@ -0,0 +1,177 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("setf4") action setf4_0() { + hdr.data.f4 = 32w0x70a50; + } + @name("noop") action noop_0() { + } + @name("test1") table test1_0() { + actions = { + setf4_0; + noop_0; + NoAction_0; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction_0(); + } + apply { + test1_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct4-fe.p4 b/testdata/v1_samples_outputs/instruct4-fe.p4 deleted file mode 100644 index ae1052c262a..00000000000 --- a/testdata/v1_samples_outputs/instruct4-fe.p4 +++ /dev/null @@ -1,74 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setf4") action setf4() { - hdr.data.f4 = 32w0x70a50; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setf4; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct4-last.p4 b/testdata/v1_samples_outputs/instruct4-last.p4 deleted file mode 100644 index ae1052c262a..00000000000 --- a/testdata/v1_samples_outputs/instruct4-last.p4 +++ /dev/null @@ -1,74 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setf4") action setf4() { - hdr.data.f4 = 32w0x70a50; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setf4; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct4-midend.p4 b/testdata/v1_samples_outputs/instruct4-midend.p4 deleted file mode 100644 index df8d78080e3..00000000000 --- a/testdata/v1_samples_outputs/instruct4-midend.p4 +++ /dev/null @@ -1,75 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("setf4") action setf4_0() { - hdr.data.f4 = 32w0x70a50; - } - @name("noop") action noop_0() { - } - @name("test1") table test1_0() { - actions = { - setf4_0; - noop_0; - NoAction_0; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction_0(); - } - apply { - test1_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct4.p4 b/testdata/v1_samples_outputs/instruct4.p4 index ae1052c262a..a2a3e45d711 100644 --- a/testdata/v1_samples_outputs/instruct4.p4 +++ b/testdata/v1_samples_outputs/instruct4.p4 @@ -44,7 +44,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { test1.apply(); } diff --git a/testdata/v1_samples_outputs/instruct5-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/instruct5-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..ce89ae48797 --- /dev/null +++ b/testdata/v1_samples_outputs/instruct5-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,215 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +header data2_t { + bit<16> x1; + bit<16> x2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; + @name("extra") + data2_t[4] extra; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_extra") state parse_extra { + packet.extract(hdr.extra.next); + transition select(hdr.extra.last.x1) { + 16w1 &&& 16w1: parse_extra; + default: accept; + } + } + @name("start") state start { + packet.extract(hdr.data); + transition select(hdr.data.b1) { + 8w0x0: parse_extra; + default: accept; + } + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("noop") action noop() { + } + @name("push1") action push1() { + hdr.extra.push_front(1); + } + @name("push2") action push2() { + hdr.extra.push_front(2); + } + @name("test1") table test1() { + actions = { + noop; + push1; + push2; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + packet.emit(hdr.extra); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct5-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/instruct5-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..82f7e6c86c1 --- /dev/null +++ b/testdata/v1_samples_outputs/instruct5-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,199 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +header data2_t { + bit<16> x1; + bit<16> x2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; + @name("extra") + data2_t[4] extra; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_extra") state parse_extra { + packet.extract(hdr.extra.next); + transition select(hdr.extra.last.x1) { + 16w1 &&& 16w1: parse_extra; + default: accept; + } + } + @name("start") state start { + packet.extract(hdr.data); + transition select(hdr.data.b1) { + 8w0x0: parse_extra; + default: accept; + } + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("noop") action noop() { + } + @name("push1") action push1() { + hdr.extra.push_front(1); + } + @name("push2") action push2() { + hdr.extra.push_front(2); + } + @name("test1") table test1() { + actions = { + noop; + push1; + push2; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + packet.emit(hdr.extra); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct5-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/instruct5-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..300e7905b88 --- /dev/null +++ b/testdata/v1_samples_outputs/instruct5-MidEnd_25_Evaluator.p4 @@ -0,0 +1,199 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +header data2_t { + bit<16> x1; + bit<16> x2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; + @name("extra") + data2_t[4] extra; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_extra") state parse_extra { + packet.extract(hdr.extra.next); + transition select(hdr.extra.last.x1) { + 16w1 &&& 16w1: parse_extra; + default: accept; + } + } + @name("start") state start { + packet.extract(hdr.data); + transition select(hdr.data.b1) { + 8w0x0: parse_extra; + default: accept; + } + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("noop") action noop_0() { + } + @name("push1") action push1_0() { + hdr.extra.push_front(1); + } + @name("push2") action push2_0() { + hdr.extra.push_front(2); + } + @name("test1") table test1_0() { + actions = { + noop_0; + push1_0; + push2_0; + NoAction_0; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction_0(); + } + apply { + test1_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + packet.emit(hdr.extra); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct5-fe.p4 b/testdata/v1_samples_outputs/instruct5-fe.p4 deleted file mode 100644 index ceb34bd02de..00000000000 --- a/testdata/v1_samples_outputs/instruct5-fe.p4 +++ /dev/null @@ -1,96 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -header data2_t { - bit<16> x1; - bit<16> x2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; - @name("extra") - data2_t[4] extra; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("parse_extra") state parse_extra { - packet.extract(hdr.extra.next); - transition select(hdr.extra.last.x1) { - 16w1 &&& 16w1: parse_extra; - default: accept; - } - } - @name("start") state start { - packet.extract(hdr.data); - transition select(hdr.data.b1) { - 8w0x0: parse_extra; - default: accept; - } - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("noop") action noop() { - } - @name("push1") action push1() { - hdr.extra.push_front(1); - } - @name("push2") action push2() { - hdr.extra.push_front(2); - } - @name("test1") table test1() { - actions = { - noop; - push1; - push2; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - packet.emit(hdr.extra); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct5-last.p4 b/testdata/v1_samples_outputs/instruct5-last.p4 deleted file mode 100644 index ceb34bd02de..00000000000 --- a/testdata/v1_samples_outputs/instruct5-last.p4 +++ /dev/null @@ -1,96 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -header data2_t { - bit<16> x1; - bit<16> x2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; - @name("extra") - data2_t[4] extra; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("parse_extra") state parse_extra { - packet.extract(hdr.extra.next); - transition select(hdr.extra.last.x1) { - 16w1 &&& 16w1: parse_extra; - default: accept; - } - } - @name("start") state start { - packet.extract(hdr.data); - transition select(hdr.data.b1) { - 8w0x0: parse_extra; - default: accept; - } - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("noop") action noop() { - } - @name("push1") action push1() { - hdr.extra.push_front(1); - } - @name("push2") action push2() { - hdr.extra.push_front(2); - } - @name("test1") table test1() { - actions = { - noop; - push1; - push2; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - packet.emit(hdr.extra); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct5-midend.p4 b/testdata/v1_samples_outputs/instruct5-midend.p4 deleted file mode 100644 index 0414a503fbf..00000000000 --- a/testdata/v1_samples_outputs/instruct5-midend.p4 +++ /dev/null @@ -1,97 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -header data2_t { - bit<16> x1; - bit<16> x2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; - @name("extra") - data2_t[4] extra; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("parse_extra") state parse_extra { - packet.extract(hdr.extra.next); - transition select(hdr.extra.last.x1) { - 16w1 &&& 16w1: parse_extra; - default: accept; - } - } - @name("start") state start { - packet.extract(hdr.data); - transition select(hdr.data.b1) { - 8w0x0: parse_extra; - default: accept; - } - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("noop") action noop_0() { - } - @name("push1") action push1_0() { - hdr.extra.push_front(1); - } - @name("push2") action push2_0() { - hdr.extra.push_front(2); - } - @name("test1") table test1_0() { - actions = { - noop_0; - push1_0; - push2_0; - NoAction_0; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction_0(); - } - apply { - test1_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - packet.emit(hdr.extra); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/instruct5.p4 b/testdata/v1_samples_outputs/instruct5.p4 index ceb34bd02de..c711de1c2c8 100644 --- a/testdata/v1_samples_outputs/instruct5.p4 +++ b/testdata/v1_samples_outputs/instruct5.p4 @@ -65,7 +65,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { test1.apply(); } diff --git a/testdata/v1_samples_outputs/mac_rewrite-last.p4 b/testdata/v1_samples_outputs/mac_rewrite-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 62% rename from testdata/v1_samples_outputs/mac_rewrite-last.p4 rename to testdata/v1_samples_outputs/mac_rewrite-FrontEnd_11_SimplifyControlFlowE.p4 index 8d26fbefe97..abc59f0be4b 100644 --- a/testdata/v1_samples_outputs/mac_rewrite-last.p4 +++ b/testdata/v1_samples_outputs/mac_rewrite-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct egress_metadata_t { bit<16> payload_length; bit<9> smac_idx; @@ -124,7 +244,6 @@ control process_mac_rewrite(inout headers hdr, inout metadata meta, inout standa size = 512; default_action = NoAction(); } - apply { if (meta.egress_metadata.routed == 1w1) mac_rewrite.apply(); @@ -147,7 +266,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - process_mac_rewrite() @name("process_mac_rewrite") process_mac_rewrite_0; apply { setup.apply(); diff --git a/testdata/v1_samples_outputs/mac_rewrite-fe.p4 b/testdata/v1_samples_outputs/mac_rewrite-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 68% rename from testdata/v1_samples_outputs/mac_rewrite-fe.p4 rename to testdata/v1_samples_outputs/mac_rewrite-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 8d26fbefe97..6263443cde9 100644 --- a/testdata/v1_samples_outputs/mac_rewrite-fe.p4 +++ b/testdata/v1_samples_outputs/mac_rewrite-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct egress_metadata_t { bit<16> payload_length; bit<9> smac_idx; @@ -124,7 +228,6 @@ control process_mac_rewrite(inout headers hdr, inout metadata meta, inout standa size = 512; default_action = NoAction(); } - apply { if (meta.egress_metadata.routed == 1w1) mac_rewrite.apply(); @@ -147,7 +250,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - process_mac_rewrite() @name("process_mac_rewrite") process_mac_rewrite_0; apply { setup.apply(); diff --git a/testdata/v1_samples_outputs/mac_rewrite-midend.p4 b/testdata/v1_samples_outputs/mac_rewrite-MidEnd_25_Evaluator.p4 similarity index 71% rename from testdata/v1_samples_outputs/mac_rewrite-midend.p4 rename to testdata/v1_samples_outputs/mac_rewrite-MidEnd_25_Evaluator.p4 index 3a6bbb2c6eb..edd036896d1 100644 --- a/testdata/v1_samples_outputs/mac_rewrite-midend.p4 +++ b/testdata/v1_samples_outputs/mac_rewrite-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct egress_metadata_t { bit<16> payload_length; bit<9> smac_idx; diff --git a/testdata/v1_samples_outputs/mac_rewrite.p4 b/testdata/v1_samples_outputs/mac_rewrite.p4 index d8203feeb21..1e980750656 100644 --- a/testdata/v1_samples_outputs/mac_rewrite.p4 +++ b/testdata/v1_samples_outputs/mac_rewrite.p4 @@ -124,7 +124,6 @@ control process_mac_rewrite(inout headers hdr, inout metadata meta, inout standa size = 512; default_action = NoAction(); } - apply { if (meta.egress_metadata.routed == 1w1) { mac_rewrite.apply(); @@ -148,7 +147,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - process_mac_rewrite() @name("process_mac_rewrite") process_mac_rewrite_0; apply { setup.apply(); diff --git a/testdata/v1_samples_outputs/meter-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/meter-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..237048dc9f5 --- /dev/null +++ b/testdata/v1_samples_outputs/meter-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,225 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct intrinsic_metadata_t { + bit<4> mcast_grp; + bit<4> egress_rid; + bit<16> mcast_hash; + bit<32> lf_field_list; +} + +struct meta_t { + bit<32> meter_tag; +} + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +struct metadata { + @name("intrinsic_metadata") + intrinsic_metadata_t intrinsic_metadata; + @name("meta") + meta_t meta; +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +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 accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + Meter(32w16384, CounterType.Packets) @name("my_meter") my_meter; + @name("_drop") action _drop() { + mark_to_drop(); + } + @name("_nop") action _nop() { + } + @name("m_action") action m_action(bit<8> meter_idx) { + my_meter.meter((bit<32>)meter_idx, meta.meta.meter_tag); + standard_metadata.egress_spec = 9w1; + } + @name("m_filter") table m_filter() { + actions = { + _drop; + _nop; + NoAction; + } + key = { + meta.meta.meter_tag: exact; + } + size = 16; + default_action = NoAction(); + } + @name("m_table") table m_table() { + actions = { + m_action; + _nop; + NoAction; + } + key = { + hdr.ethernet.srcAddr: exact; + } + size = 16384; + default_action = NoAction(); + } + apply { + m_table.apply(); + m_filter.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/meter-last.p4 b/testdata/v1_samples_outputs/meter-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 51% rename from testdata/v1_samples_outputs/meter-last.p4 rename to testdata/v1_samples_outputs/meter-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index b1bc3ad97c0..d9196b2f158 100644 --- a/testdata/v1_samples_outputs/meter-last.p4 +++ b/testdata/v1_samples_outputs/meter-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,111 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; @@ -68,7 +173,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 16; default_action = NoAction(); } - @name("m_table") table m_table() { actions = { m_action; @@ -81,7 +185,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 16384; default_action = NoAction(); } - apply { m_table.apply(); m_filter.apply(); diff --git a/testdata/v1_samples_outputs/meter-midend.p4 b/testdata/v1_samples_outputs/meter-MidEnd_25_Evaluator.p4 similarity index 52% rename from testdata/v1_samples_outputs/meter-midend.p4 rename to testdata/v1_samples_outputs/meter-MidEnd_25_Evaluator.p4 index 47c3d18cb7e..3ba7a4773e4 100644 --- a/testdata/v1_samples_outputs/meter-midend.p4 +++ b/testdata/v1_samples_outputs/meter-MidEnd_25_Evaluator.p4 @@ -1,6 +1,109 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; diff --git a/testdata/v1_samples_outputs/meter-fe.p4 b/testdata/v1_samples_outputs/meter-fe.p4 deleted file mode 100644 index b1bc3ad97c0..00000000000 --- a/testdata/v1_samples_outputs/meter-fe.p4 +++ /dev/null @@ -1,107 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct intrinsic_metadata_t { - bit<4> mcast_grp; - bit<4> egress_rid; - bit<16> mcast_hash; - bit<32> lf_field_list; -} - -struct meta_t { - bit<32> meter_tag; -} - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> etherType; -} - -struct metadata { - @name("intrinsic_metadata") - intrinsic_metadata_t intrinsic_metadata; - @name("meta") - meta_t meta; -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -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 accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - Meter(32w16384, CounterType.Packets) @name("my_meter") my_meter; - @name("_drop") action _drop() { - mark_to_drop(); - } - @name("_nop") action _nop() { - } - @name("m_action") action m_action(bit<8> meter_idx) { - my_meter.meter((bit<32>)meter_idx, meta.meta.meter_tag); - standard_metadata.egress_spec = 9w1; - } - @name("m_filter") table m_filter() { - actions = { - _drop; - _nop; - NoAction; - } - key = { - meta.meta.meter_tag: exact; - } - size = 16; - default_action = NoAction(); - } - - @name("m_table") table m_table() { - actions = { - m_action; - _nop; - NoAction; - } - key = { - hdr.ethernet.srcAddr: exact; - } - size = 16384; - default_action = NoAction(); - } - - apply { - m_table.apply(); - m_filter.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/meter.p4 b/testdata/v1_samples_outputs/meter.p4 index b1bc3ad97c0..5e9059f35a1 100644 --- a/testdata/v1_samples_outputs/meter.p4 +++ b/testdata/v1_samples_outputs/meter.p4 @@ -68,7 +68,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 16; default_action = NoAction(); } - @name("m_table") table m_table() { actions = { m_action; @@ -81,7 +80,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 16384; default_action = NoAction(); } - apply { m_table.apply(); m_filter.apply(); diff --git a/testdata/v1_samples_outputs/meter1-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/meter1-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..3d8b969340a --- /dev/null +++ b/testdata/v1_samples_outputs/meter1-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,234 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct intrinsic_metadata_t { + bit<4> mcast_grp; + bit<4> egress_rid; + bit<16> mcast_hash; + bit<32> lf_field_list; +} + +struct meta_t { + bit<32> meter_tag; +} + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +struct metadata { + @name("intrinsic_metadata") + intrinsic_metadata_t intrinsic_metadata; + @name("meta") + meta_t meta; +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +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 accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + DirectMeter>(CounterType.Packets) @name("my_meter") my_meter; + @name("_drop") action _drop() { + mark_to_drop(); + } + @name("_nop") action _nop() { + } + @name("m_action") action m_action(bit<9> meter_idx) { + standard_metadata.egress_spec = meter_idx; + standard_metadata.egress_spec = 9w1; + } + @name("m_filter") table m_filter() { + actions = { + _drop; + _nop; + NoAction; + } + key = { + meta.meta.meter_tag: exact; + } + size = 16; + default_action = NoAction(); + } + @name("m_action") action m_action_0(bit<9> meter_idx) { + standard_metadata.egress_spec = meter_idx; + standard_metadata.egress_spec = 9w1; + my_meter.read(meta.meta.meter_tag); + } + @name("_nop") action _nop_0() { + my_meter.read(meta.meta.meter_tag); + } + @name("m_table") table m_table() { + actions = { + m_action_0; + _nop_0; + NoAction; + } + key = { + hdr.ethernet.srcAddr: exact; + } + size = 16384; + default_action = NoAction(); + meters = my_meter; + } + apply { + m_table.apply(); + m_filter.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/meter1-last.p4 b/testdata/v1_samples_outputs/meter1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 52% rename from testdata/v1_samples_outputs/meter1-last.p4 rename to testdata/v1_samples_outputs/meter1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index ea61bcb06cc..7d00659d15a 100644 --- a/testdata/v1_samples_outputs/meter1-last.p4 +++ b/testdata/v1_samples_outputs/meter1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,111 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; @@ -64,7 +169,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 16; default_action = NoAction(); } - @name("m_action") action m_action_0(bit<9> meter_idx) { standard_metadata.egress_spec = meter_idx; standard_metadata.egress_spec = 9w1; @@ -86,7 +190,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ default_action = NoAction(); meters = my_meter; } - apply { m_table.apply(); m_filter.apply(); diff --git a/testdata/v1_samples_outputs/meter1-midend.p4 b/testdata/v1_samples_outputs/meter1-MidEnd_25_Evaluator.p4 similarity index 53% rename from testdata/v1_samples_outputs/meter1-midend.p4 rename to testdata/v1_samples_outputs/meter1-MidEnd_25_Evaluator.p4 index 4dc5fa293b9..c19a988fdcf 100644 --- a/testdata/v1_samples_outputs/meter1-midend.p4 +++ b/testdata/v1_samples_outputs/meter1-MidEnd_25_Evaluator.p4 @@ -1,6 +1,109 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; diff --git a/testdata/v1_samples_outputs/meter1-fe.p4 b/testdata/v1_samples_outputs/meter1-fe.p4 deleted file mode 100644 index dfbc5869a24..00000000000 --- a/testdata/v1_samples_outputs/meter1-fe.p4 +++ /dev/null @@ -1,116 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct intrinsic_metadata_t { - bit<4> mcast_grp; - bit<4> egress_rid; - bit<16> mcast_hash; - bit<32> lf_field_list; -} - -struct meta_t { - bit<32> meter_tag; -} - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> etherType; -} - -struct metadata { - @name("intrinsic_metadata") - intrinsic_metadata_t intrinsic_metadata; - @name("meta") - meta_t meta; -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -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 accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - DirectMeter>(CounterType.Packets) @name("my_meter") my_meter; - @name("_drop") action _drop() { - mark_to_drop(); - } - @name("_nop") action _nop() { - } - @name("m_action") action m_action(bit<9> meter_idx) { - standard_metadata.egress_spec = meter_idx; - standard_metadata.egress_spec = 9w1; - } - @name("m_filter") table m_filter() { - actions = { - _drop; - _nop; - NoAction; - } - key = { - meta.meta.meter_tag: exact; - } - size = 16; - default_action = NoAction(); - } - - @name("m_action") action m_action_0(bit<9> meter_idx) { - standard_metadata.egress_spec = meter_idx; - standard_metadata.egress_spec = 9w1; - my_meter.read(meta.meta.meter_tag); - } - @name("_nop") action _nop_0() { - my_meter.read(meta.meta.meter_tag); - } - @name("m_table") table m_table() { - actions = { - m_action_0; - _nop_0; - NoAction; - } - key = { - hdr.ethernet.srcAddr: exact; - } - size = 16384; - default_action = NoAction(); - meters = my_meter; - } - - apply { - m_table.apply(); - m_filter.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/meter1.p4 b/testdata/v1_samples_outputs/meter1.p4 index dfbc5869a24..34f578f74fa 100644 --- a/testdata/v1_samples_outputs/meter1.p4 +++ b/testdata/v1_samples_outputs/meter1.p4 @@ -68,7 +68,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 16; default_action = NoAction(); } - @name("m_action") action m_action_0(bit<9> meter_idx) { standard_metadata.egress_spec = meter_idx; standard_metadata.egress_spec = 9w1; @@ -90,7 +89,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ default_action = NoAction(); meters = my_meter; } - apply { m_table.apply(); m_filter.apply(); diff --git a/testdata/v1_samples_outputs/miss-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/miss-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..22927ca5d65 --- /dev/null +++ b/testdata/v1_samples_outputs/miss-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,215 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<16> h1; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: ternary; + } + default_action = NoAction(); + } + @name("test3") table test3() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f3: ternary; + } + default_action = NoAction(); + } + @name("test4") table test4() { + actions = { + noop; + NoAction; + } + default_action = NoAction(); + } + apply { + if (test1.apply().hit) + ; + else + test3.apply(); + test4.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/miss-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/miss-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..6c9b9792d58 --- /dev/null +++ b/testdata/v1_samples_outputs/miss-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,199 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<16> h1; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: ternary; + } + default_action = NoAction(); + } + @name("test3") table test3() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f3: ternary; + } + default_action = NoAction(); + } + @name("test4") table test4() { + actions = { + noop; + NoAction; + } + default_action = NoAction(); + } + apply { + if (test1.apply().hit) + ; + else + test3.apply(); + test4.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/miss-midend.p4 b/testdata/v1_samples_outputs/miss-MidEnd_25_Evaluator.p4 similarity index 51% rename from testdata/v1_samples_outputs/miss-midend.p4 rename to testdata/v1_samples_outputs/miss-MidEnd_25_Evaluator.p4 index 1435c7e4376..5c28720cc05 100644 --- a/testdata/v1_samples_outputs/miss-midend.p4 +++ b/testdata/v1_samples_outputs/miss-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header data_t { bit<32> f1; bit<32> f2; diff --git a/testdata/v1_samples_outputs/miss-fe.p4 b/testdata/v1_samples_outputs/miss-fe.p4 deleted file mode 100644 index a6f2a6cb310..00000000000 --- a/testdata/v1_samples_outputs/miss-fe.p4 +++ /dev/null @@ -1,98 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<16> h1; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: ternary; - } - default_action = NoAction(); - } - - @name("test3") table test3() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f3: ternary; - } - default_action = NoAction(); - } - - @name("test4") table test4() { - actions = { - noop; - NoAction; - } - default_action = NoAction(); - } - - apply { - if (test1.apply().hit) - ; - else - test3.apply(); - test4.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/miss-last.p4 b/testdata/v1_samples_outputs/miss-last.p4 deleted file mode 100644 index a6f2a6cb310..00000000000 --- a/testdata/v1_samples_outputs/miss-last.p4 +++ /dev/null @@ -1,98 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<16> h1; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: ternary; - } - default_action = NoAction(); - } - - @name("test3") table test3() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f3: ternary; - } - default_action = NoAction(); - } - - @name("test4") table test4() { - actions = { - noop; - NoAction; - } - default_action = NoAction(); - } - - apply { - if (test1.apply().hit) - ; - else - test3.apply(); - test4.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/miss.p4 b/testdata/v1_samples_outputs/miss.p4 index 85f96fd28e3..65fc176e636 100644 --- a/testdata/v1_samples_outputs/miss.p4 +++ b/testdata/v1_samples_outputs/miss.p4 @@ -44,7 +44,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("test3") table test3() { actions = { setb1; @@ -56,7 +55,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("test4") table test4() { actions = { noop; @@ -64,7 +62,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (test1.apply().hit) ; diff --git a/testdata/v1_samples_outputs/overflow-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/overflow-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..28978f9cd91 --- /dev/null +++ b/testdata/v1_samples_outputs/overflow-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,182 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct metadata_t { + bit<1> field_1_1_1; + bit<1> field_2_1_1; +} + +struct metadata { + @name("md") + metadata_t md; +} + +struct headers { +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("action_1_1") action action_1_1(bit<1> value) { + meta.md.field_1_1_1 = value; + meta.md.field_2_1_1 = 1w1; + } + @name("dmac") table dmac() { + actions = { + action_1_1; + NoAction; + } + key = { + } + default_action = NoAction(); + } + apply { + dmac.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/overflow-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/overflow-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..b3a1038b4d2 --- /dev/null +++ b/testdata/v1_samples_outputs/overflow-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,166 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct metadata_t { + bit<1> field_1_1_1; + bit<1> field_2_1_1; +} + +struct metadata { + @name("md") + metadata_t md; +} + +struct headers { +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("action_1_1") action action_1_1(bit<1> value) { + meta.md.field_1_1_1 = value; + meta.md.field_2_1_1 = 1w1; + } + @name("dmac") table dmac() { + actions = { + action_1_1; + NoAction; + } + key = { + } + default_action = NoAction(); + } + apply { + dmac.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/overflow-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/overflow-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..bc8caf1c308 --- /dev/null +++ b/testdata/v1_samples_outputs/overflow-MidEnd_25_Evaluator.p4 @@ -0,0 +1,166 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct metadata_t { + bit<1> field_1_1_1; + bit<1> field_2_1_1; +} + +struct metadata { + @name("md") + metadata_t md; +} + +struct headers { +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("action_1_1") action action_1(bit<1> value) { + meta.md.field_1_1_1 = value; + meta.md.field_2_1_1 = 1w1; + } + @name("dmac") table dmac_0() { + actions = { + action_1; + NoAction_0; + } + key = { + } + default_action = NoAction_0(); + } + apply { + dmac_0.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/overflow-fe.p4 b/testdata/v1_samples_outputs/overflow-fe.p4 deleted file mode 100644 index 0a2f4df9372..00000000000 --- a/testdata/v1_samples_outputs/overflow-fe.p4 +++ /dev/null @@ -1,63 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct metadata_t { - bit<1> field_1_1_1; - bit<1> field_2_1_1; -} - -struct metadata { - @name("md") - metadata_t md; -} - -struct headers { -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("action_1_1") action action_1_1(bit<1> value) { - meta.md.field_1_1_1 = value; - meta.md.field_2_1_1 = 1w1; - } - @name("dmac") table dmac() { - actions = { - action_1_1; - NoAction; - } - key = { - } - default_action = NoAction(); - } - - apply { - dmac.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/overflow-last.p4 b/testdata/v1_samples_outputs/overflow-last.p4 deleted file mode 100644 index 0a2f4df9372..00000000000 --- a/testdata/v1_samples_outputs/overflow-last.p4 +++ /dev/null @@ -1,63 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct metadata_t { - bit<1> field_1_1_1; - bit<1> field_2_1_1; -} - -struct metadata { - @name("md") - metadata_t md; -} - -struct headers { -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("action_1_1") action action_1_1(bit<1> value) { - meta.md.field_1_1_1 = value; - meta.md.field_2_1_1 = 1w1; - } - @name("dmac") table dmac() { - actions = { - action_1_1; - NoAction; - } - key = { - } - default_action = NoAction(); - } - - apply { - dmac.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/overflow-midend.p4 b/testdata/v1_samples_outputs/overflow-midend.p4 deleted file mode 100644 index b3afac31f0f..00000000000 --- a/testdata/v1_samples_outputs/overflow-midend.p4 +++ /dev/null @@ -1,64 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct metadata_t { - bit<1> field_1_1_1; - bit<1> field_2_1_1; -} - -struct metadata { - @name("md") - metadata_t md; -} - -struct headers { -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("action_1_1") action action_1(bit<1> value) { - meta.md.field_1_1_1 = value; - meta.md.field_2_1_1 = 1w1; - } - @name("dmac") table dmac_0() { - actions = { - action_1; - NoAction_0; - } - key = { - } - default_action = NoAction_0(); - } - apply { - dmac_0.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/overflow.p4 b/testdata/v1_samples_outputs/overflow.p4 index 0a2f4df9372..4a3bd83258f 100644 --- a/testdata/v1_samples_outputs/overflow.p4 +++ b/testdata/v1_samples_outputs/overflow.p4 @@ -39,7 +39,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { dmac.apply(); } diff --git a/testdata/v1_samples_outputs/packet_redirect-last.p4 b/testdata/v1_samples_outputs/packet_redirect-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 54% rename from testdata/v1_samples_outputs/packet_redirect-last.p4 rename to testdata/v1_samples_outputs/packet_redirect-FrontEnd_11_SimplifyControlFlowE.p4 index d0d72ca198f..115a8b4651b 100644 --- a/testdata/v1_samples_outputs/packet_redirect-last.p4 +++ b/testdata/v1_samples_outputs/packet_redirect-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; @@ -70,7 +190,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t size = 128; default_action = NoAction(); } - apply { t_egress.apply(); } @@ -106,7 +225,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 128; default_action = NoAction(); } - @name("t_ingress_2") table t_ingress_2() { actions = { _nop; @@ -121,7 +239,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 128; default_action = NoAction(); } - apply { t_ingress_1.apply(); t_ingress_2.apply(); diff --git a/testdata/v1_samples_outputs/packet_redirect-fe.p4 b/testdata/v1_samples_outputs/packet_redirect-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 58% rename from testdata/v1_samples_outputs/packet_redirect-fe.p4 rename to testdata/v1_samples_outputs/packet_redirect-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index d0d72ca198f..c16d484540a 100644 --- a/testdata/v1_samples_outputs/packet_redirect-fe.p4 +++ b/testdata/v1_samples_outputs/packet_redirect-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,118 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; @@ -70,7 +182,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t size = 128; default_action = NoAction(); } - apply { t_egress.apply(); } @@ -106,7 +217,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 128; default_action = NoAction(); } - @name("t_ingress_2") table t_ingress_2() { actions = { _nop; @@ -121,7 +231,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 128; default_action = NoAction(); } - apply { t_ingress_1.apply(); t_ingress_2.apply(); diff --git a/testdata/v1_samples_outputs/packet_redirect-midend.p4 b/testdata/v1_samples_outputs/packet_redirect-MidEnd_25_Evaluator.p4 similarity index 60% rename from testdata/v1_samples_outputs/packet_redirect-midend.p4 rename to testdata/v1_samples_outputs/packet_redirect-MidEnd_25_Evaluator.p4 index 8c78b1111bd..7c11d9a448e 100644 --- a/testdata/v1_samples_outputs/packet_redirect-midend.p4 +++ b/testdata/v1_samples_outputs/packet_redirect-MidEnd_25_Evaluator.p4 @@ -1,6 +1,116 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; diff --git a/testdata/v1_samples_outputs/packet_redirect.p4 b/testdata/v1_samples_outputs/packet_redirect.p4 index d0d72ca198f..4c520784c27 100644 --- a/testdata/v1_samples_outputs/packet_redirect.p4 +++ b/testdata/v1_samples_outputs/packet_redirect.p4 @@ -70,7 +70,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t size = 128; default_action = NoAction(); } - apply { t_egress.apply(); } @@ -106,7 +105,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 128; default_action = NoAction(); } - @name("t_ingress_2") table t_ingress_2() { actions = { _nop; @@ -121,7 +119,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 128; default_action = NoAction(); } - apply { t_ingress_1.apply(); t_ingress_2.apply(); diff --git a/testdata/v1_samples_outputs/parser1-last.p4 b/testdata/v1_samples_outputs/parser1-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 55% rename from testdata/v1_samples_outputs/parser1-last.p4 rename to testdata/v1_samples_outputs/parser1-FrontEnd_11_SimplifyControlFlowE.p4 index 86aff4f01d3..08e58f1f5b3 100644 --- a/testdata/v1_samples_outputs/parser1-last.p4 +++ b/testdata/v1_samples_outputs/parser1-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; @@ -117,7 +237,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { do_nothing.apply(); } diff --git a/testdata/v1_samples_outputs/parser1-fe.p4 b/testdata/v1_samples_outputs/parser1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 61% rename from testdata/v1_samples_outputs/parser1-fe.p4 rename to testdata/v1_samples_outputs/parser1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 86aff4f01d3..653b2a28b3b 100644 --- a/testdata/v1_samples_outputs/parser1-fe.p4 +++ b/testdata/v1_samples_outputs/parser1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; @@ -117,7 +221,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { do_nothing.apply(); } diff --git a/testdata/v1_samples_outputs/parser1-midend.p4 b/testdata/v1_samples_outputs/parser1-MidEnd_25_Evaluator.p4 similarity index 62% rename from testdata/v1_samples_outputs/parser1-midend.p4 rename to testdata/v1_samples_outputs/parser1-MidEnd_25_Evaluator.p4 index 39d5d27ebb6..abea42ece40 100644 --- a/testdata/v1_samples_outputs/parser1-midend.p4 +++ b/testdata/v1_samples_outputs/parser1-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; diff --git a/testdata/v1_samples_outputs/parser1.p4 b/testdata/v1_samples_outputs/parser1.p4 index 86aff4f01d3..c7aabff82f6 100644 --- a/testdata/v1_samples_outputs/parser1.p4 +++ b/testdata/v1_samples_outputs/parser1.p4 @@ -117,7 +117,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { do_nothing.apply(); } diff --git a/testdata/v1_samples_outputs/parser2-last.p4 b/testdata/v1_samples_outputs/parser2-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 66% rename from testdata/v1_samples_outputs/parser2-last.p4 rename to testdata/v1_samples_outputs/parser2-FrontEnd_11_SimplifyControlFlowE.p4 index b24106f3835..fc6290262a8 100644 --- a/testdata/v1_samples_outputs/parser2-last.p4 +++ b/testdata/v1_samples_outputs/parser2-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; @@ -203,7 +323,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { do_nothing.apply(); } diff --git a/testdata/v1_samples_outputs/parser2-fe.p4 b/testdata/v1_samples_outputs/parser2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 71% rename from testdata/v1_samples_outputs/parser2-fe.p4 rename to testdata/v1_samples_outputs/parser2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index b24106f3835..b00a41a27aa 100644 --- a/testdata/v1_samples_outputs/parser2-fe.p4 +++ b/testdata/v1_samples_outputs/parser2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; @@ -203,7 +307,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { do_nothing.apply(); } diff --git a/testdata/v1_samples_outputs/parser2-midend.p4 b/testdata/v1_samples_outputs/parser2-MidEnd_25_Evaluator.p4 similarity index 71% rename from testdata/v1_samples_outputs/parser2-midend.p4 rename to testdata/v1_samples_outputs/parser2-MidEnd_25_Evaluator.p4 index 95b036e0289..b4b753da00d 100644 --- a/testdata/v1_samples_outputs/parser2-midend.p4 +++ b/testdata/v1_samples_outputs/parser2-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; diff --git a/testdata/v1_samples_outputs/parser2.p4 b/testdata/v1_samples_outputs/parser2.p4 index b24106f3835..69ea1b89cb8 100644 --- a/testdata/v1_samples_outputs/parser2.p4 +++ b/testdata/v1_samples_outputs/parser2.p4 @@ -203,7 +203,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { do_nothing.apply(); } diff --git a/testdata/v1_samples_outputs/parser3-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/parser3-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..c6f568330de --- /dev/null +++ b/testdata/v1_samples_outputs/parser3-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,209 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data1_t { + bit<32> f1; + bit<2> x1; + bit<4> x2; + bit<4> x3; + bit<4> x4; + bit<2> x5; + bit<5> x6; + bit<2> x7; + bit<1> x8; +} + +header data2_t { + bit<8> a1; + bit<4> a2; + bit<4> a3; + bit<8> a4; + bit<4> a5; + bit<4> a6; +} + +struct metadata { +} + +struct headers { + @name("data1") + data1_t data1; + @name("data2") + data2_t data2; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_data2") state parse_data2 { + packet.extract(hdr.data2); + transition accept; + } + @name("start") state start { + packet.extract(hdr.data1); + transition select(hdr.data1.x3, hdr.data1.x1, hdr.data1.x7) { + (4w0xe, 2w0x1, 2w0x0): parse_data2; + default: accept; + } + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + noop; + NoAction; + } + key = { + hdr.data1.f1: exact; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data1); + packet.emit(hdr.data2); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/parser3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/parser3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..4a2c7830fe5 --- /dev/null +++ b/testdata/v1_samples_outputs/parser3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,193 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data1_t { + bit<32> f1; + bit<2> x1; + bit<4> x2; + bit<4> x3; + bit<4> x4; + bit<2> x5; + bit<5> x6; + bit<2> x7; + bit<1> x8; +} + +header data2_t { + bit<8> a1; + bit<4> a2; + bit<4> a3; + bit<8> a4; + bit<4> a5; + bit<4> a6; +} + +struct metadata { +} + +struct headers { + @name("data1") + data1_t data1; + @name("data2") + data2_t data2; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_data2") state parse_data2 { + packet.extract(hdr.data2); + transition accept; + } + @name("start") state start { + packet.extract(hdr.data1); + transition select(hdr.data1.x3, hdr.data1.x1, hdr.data1.x7) { + (4w0xe, 2w0x1, 2w0x0): parse_data2; + default: accept; + } + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + noop; + NoAction; + } + key = { + hdr.data1.f1: exact; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data1); + packet.emit(hdr.data2); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/parser3-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/parser3-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..e473e4699e1 --- /dev/null +++ b/testdata/v1_samples_outputs/parser3-MidEnd_25_Evaluator.p4 @@ -0,0 +1,193 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data1_t { + bit<32> f1; + bit<2> x1; + bit<4> x2; + bit<4> x3; + bit<4> x4; + bit<2> x5; + bit<5> x6; + bit<2> x7; + bit<1> x8; +} + +header data2_t { + bit<8> a1; + bit<4> a2; + bit<4> a3; + bit<8> a4; + bit<4> a5; + bit<4> a6; +} + +struct metadata { +} + +struct headers { + @name("data1") + data1_t data1; + @name("data2") + data2_t data2; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_data2") state parse_data2 { + packet.extract(hdr.data2); + transition accept; + } + @name("start") state start { + packet.extract(hdr.data1); + transition select(hdr.data1.x3, hdr.data1.x1, hdr.data1.x7) { + (4w0xe, 2w0x1, 2w0x0): parse_data2; + default: accept; + } + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("noop") action noop_0() { + } + @name("test1") table test1_0() { + actions = { + noop_0; + NoAction_0; + } + key = { + hdr.data1.f1: exact; + } + default_action = NoAction_0(); + } + apply { + test1_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data1); + packet.emit(hdr.data2); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/parser3-fe.p4 b/testdata/v1_samples_outputs/parser3-fe.p4 deleted file mode 100644 index 275979143cc..00000000000 --- a/testdata/v1_samples_outputs/parser3-fe.p4 +++ /dev/null @@ -1,90 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data1_t { - bit<32> f1; - bit<2> x1; - bit<4> x2; - bit<4> x3; - bit<4> x4; - bit<2> x5; - bit<5> x6; - bit<2> x7; - bit<1> x8; -} - -header data2_t { - bit<8> a1; - bit<4> a2; - bit<4> a3; - bit<8> a4; - bit<4> a5; - bit<4> a6; -} - -struct metadata { -} - -struct headers { - @name("data1") - data1_t data1; - @name("data2") - data2_t data2; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("parse_data2") state parse_data2 { - packet.extract(hdr.data2); - transition accept; - } - @name("start") state start { - packet.extract(hdr.data1); - transition select(hdr.data1.x3, hdr.data1.x1, hdr.data1.x7) { - (4w0xe, 2w0x1, 2w0x0): parse_data2; - default: accept; - } - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - noop; - NoAction; - } - key = { - hdr.data1.f1: exact; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data1); - packet.emit(hdr.data2); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/parser3-last.p4 b/testdata/v1_samples_outputs/parser3-last.p4 deleted file mode 100644 index 275979143cc..00000000000 --- a/testdata/v1_samples_outputs/parser3-last.p4 +++ /dev/null @@ -1,90 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data1_t { - bit<32> f1; - bit<2> x1; - bit<4> x2; - bit<4> x3; - bit<4> x4; - bit<2> x5; - bit<5> x6; - bit<2> x7; - bit<1> x8; -} - -header data2_t { - bit<8> a1; - bit<4> a2; - bit<4> a3; - bit<8> a4; - bit<4> a5; - bit<4> a6; -} - -struct metadata { -} - -struct headers { - @name("data1") - data1_t data1; - @name("data2") - data2_t data2; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("parse_data2") state parse_data2 { - packet.extract(hdr.data2); - transition accept; - } - @name("start") state start { - packet.extract(hdr.data1); - transition select(hdr.data1.x3, hdr.data1.x1, hdr.data1.x7) { - (4w0xe, 2w0x1, 2w0x0): parse_data2; - default: accept; - } - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - noop; - NoAction; - } - key = { - hdr.data1.f1: exact; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data1); - packet.emit(hdr.data2); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/parser3-midend.p4 b/testdata/v1_samples_outputs/parser3-midend.p4 deleted file mode 100644 index 5d5f450bc2a..00000000000 --- a/testdata/v1_samples_outputs/parser3-midend.p4 +++ /dev/null @@ -1,91 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data1_t { - bit<32> f1; - bit<2> x1; - bit<4> x2; - bit<4> x3; - bit<4> x4; - bit<2> x5; - bit<5> x6; - bit<2> x7; - bit<1> x8; -} - -header data2_t { - bit<8> a1; - bit<4> a2; - bit<4> a3; - bit<8> a4; - bit<4> a5; - bit<4> a6; -} - -struct metadata { -} - -struct headers { - @name("data1") - data1_t data1; - @name("data2") - data2_t data2; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("parse_data2") state parse_data2 { - packet.extract(hdr.data2); - transition accept; - } - @name("start") state start { - packet.extract(hdr.data1); - transition select(hdr.data1.x3, hdr.data1.x1, hdr.data1.x7) { - (4w0xe, 2w0x1, 2w0x0): parse_data2; - default: accept; - } - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("noop") action noop_0() { - } - @name("test1") table test1_0() { - actions = { - noop_0; - NoAction_0; - } - key = { - hdr.data1.f1: exact; - } - default_action = NoAction_0(); - } - apply { - test1_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data1); - packet.emit(hdr.data2); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/parser3.p4 b/testdata/v1_samples_outputs/parser3.p4 index 275979143cc..f6d5204d8a9 100644 --- a/testdata/v1_samples_outputs/parser3.p4 +++ b/testdata/v1_samples_outputs/parser3.p4 @@ -59,7 +59,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { test1.apply(); } diff --git a/testdata/v1_samples_outputs/parser4-last.p4 b/testdata/v1_samples_outputs/parser4-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 56% rename from testdata/v1_samples_outputs/parser4-last.p4 rename to testdata/v1_samples_outputs/parser4-FrontEnd_11_SimplifyControlFlowE.p4 index 08f85c775a0..c2603fce2fd 100644 --- a/testdata/v1_samples_outputs/parser4-last.p4 +++ b/testdata/v1_samples_outputs/parser4-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; @@ -119,7 +239,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { do_nothing.apply(); } diff --git a/testdata/v1_samples_outputs/parser4-fe.p4 b/testdata/v1_samples_outputs/parser4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 62% rename from testdata/v1_samples_outputs/parser4-fe.p4 rename to testdata/v1_samples_outputs/parser4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 08f85c775a0..a3da52d52d1 100644 --- a/testdata/v1_samples_outputs/parser4-fe.p4 +++ b/testdata/v1_samples_outputs/parser4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; @@ -119,7 +223,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { do_nothing.apply(); } diff --git a/testdata/v1_samples_outputs/parser4-midend.p4 b/testdata/v1_samples_outputs/parser4-MidEnd_25_Evaluator.p4 similarity index 62% rename from testdata/v1_samples_outputs/parser4-midend.p4 rename to testdata/v1_samples_outputs/parser4-MidEnd_25_Evaluator.p4 index 8e2664d1f18..b46bfdba9e2 100644 --- a/testdata/v1_samples_outputs/parser4-midend.p4 +++ b/testdata/v1_samples_outputs/parser4-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; diff --git a/testdata/v1_samples_outputs/parser4.p4 b/testdata/v1_samples_outputs/parser4.p4 index 08f85c775a0..445e1c7515c 100644 --- a/testdata/v1_samples_outputs/parser4.p4 +++ b/testdata/v1_samples_outputs/parser4.p4 @@ -119,7 +119,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { do_nothing.apply(); } diff --git a/testdata/v1_samples_outputs/parser_dc_full-fe.p4 b/testdata/v1_samples_outputs/parser_dc_full-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 86% rename from testdata/v1_samples_outputs/parser_dc_full-fe.p4 rename to testdata/v1_samples_outputs/parser_dc_full-FrontEnd_11_SimplifyControlFlowE.p4 index 224dab9a2c7..56872ec114f 100644 --- a/testdata/v1_samples_outputs/parser_dc_full-fe.p4 +++ b/testdata/v1_samples_outputs/parser_dc_full-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header arp_rarp_t { bit<16> hwType; bit<16> protoType; @@ -623,7 +743,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { do_nothing.apply(); } diff --git a/testdata/v1_samples_outputs/parser_dc_full-last.p4 b/testdata/v1_samples_outputs/parser_dc_full-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 89% rename from testdata/v1_samples_outputs/parser_dc_full-last.p4 rename to testdata/v1_samples_outputs/parser_dc_full-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 5471a77244f..909eb8cbff7 100644 --- a/testdata/v1_samples_outputs/parser_dc_full-last.p4 +++ b/testdata/v1_samples_outputs/parser_dc_full-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header arp_rarp_t { bit<16> hwType; bit<16> protoType; @@ -615,7 +719,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { do_nothing.apply(); } diff --git a/testdata/v1_samples_outputs/parser_dc_full-midend.p4 b/testdata/v1_samples_outputs/parser_dc_full-MidEnd_25_Evaluator.p4 similarity index 89% rename from testdata/v1_samples_outputs/parser_dc_full-midend.p4 rename to testdata/v1_samples_outputs/parser_dc_full-MidEnd_25_Evaluator.p4 index cb3fb74218c..5014be60c87 100644 --- a/testdata/v1_samples_outputs/parser_dc_full-midend.p4 +++ b/testdata/v1_samples_outputs/parser_dc_full-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header arp_rarp_t { bit<16> hwType; bit<16> protoType; diff --git a/testdata/v1_samples_outputs/parser_dc_full.p4 b/testdata/v1_samples_outputs/parser_dc_full.p4 index 42b7e7d2c75..5e8067b5abf 100644 --- a/testdata/v1_samples_outputs/parser_dc_full.p4 +++ b/testdata/v1_samples_outputs/parser_dc_full.p4 @@ -623,7 +623,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { do_nothing.apply(); } diff --git a/testdata/v1_samples_outputs/port_vlan_mapping-fe.p4 b/testdata/v1_samples_outputs/port_vlan_mapping-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 91% rename from testdata/v1_samples_outputs/port_vlan_mapping-fe.p4 rename to testdata/v1_samples_outputs/port_vlan_mapping-FrontEnd_11_SimplifyControlFlowE.p4 index 3bd809e91c5..5ca9ddabbdd 100644 --- a/testdata/v1_samples_outputs/port_vlan_mapping-fe.p4 +++ b/testdata/v1_samples_outputs/port_vlan_mapping-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<3> lkp_pkt_type; bit<48> lkp_mac_sa; @@ -857,7 +977,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ default_action = NoAction(); @name("outer_bd_action_profile") implementation = ActionProfile(32w256); } - apply { port_vlan_mapping.apply(); } diff --git a/testdata/v1_samples_outputs/port_vlan_mapping-last.p4 b/testdata/v1_samples_outputs/port_vlan_mapping-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 93% rename from testdata/v1_samples_outputs/port_vlan_mapping-last.p4 rename to testdata/v1_samples_outputs/port_vlan_mapping-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 57bc4ce72a6..ff5cf940256 100644 --- a/testdata/v1_samples_outputs/port_vlan_mapping-last.p4 +++ b/testdata/v1_samples_outputs/port_vlan_mapping-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<3> lkp_pkt_type; bit<48> lkp_mac_sa; @@ -849,7 +953,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ default_action = NoAction(); @name("outer_bd_action_profile") implementation = ActionProfile(32w256); } - apply { port_vlan_mapping.apply(); } diff --git a/testdata/v1_samples_outputs/port_vlan_mapping-midend.p4 b/testdata/v1_samples_outputs/port_vlan_mapping-MidEnd_25_Evaluator.p4 similarity index 93% rename from testdata/v1_samples_outputs/port_vlan_mapping-midend.p4 rename to testdata/v1_samples_outputs/port_vlan_mapping-MidEnd_25_Evaluator.p4 index 9f4bc24166d..5c00a0645b9 100644 --- a/testdata/v1_samples_outputs/port_vlan_mapping-midend.p4 +++ b/testdata/v1_samples_outputs/port_vlan_mapping-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<3> lkp_pkt_type; bit<48> lkp_mac_sa; diff --git a/testdata/v1_samples_outputs/port_vlan_mapping.p4 b/testdata/v1_samples_outputs/port_vlan_mapping.p4 index bc44bc142e5..fd5a0b22ddc 100644 --- a/testdata/v1_samples_outputs/port_vlan_mapping.p4 +++ b/testdata/v1_samples_outputs/port_vlan_mapping.p4 @@ -857,7 +857,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ default_action = NoAction(); @name("outer_bd_action_profile") implementation = ActionProfile(32w256); } - apply { port_vlan_mapping.apply(); } diff --git a/testdata/v1_samples_outputs/queueing-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/queueing-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..0edef16285d --- /dev/null +++ b/testdata/v1_samples_outputs/queueing-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,230 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +@name("queueing_metadata_t") struct queueing_metadata_t_0 { + bit<48> enq_timestamp; + bit<24> enq_qdepth; + bit<32> deq_timedelta; + bit<24> deq_qdepth; +} + +header hdr1_t { + bit<8> f1; + bit<8> f2; +} + +header queueing_metadata_t { + bit<48> enq_timestamp; + bit<24> enq_qdepth; + bit<32> deq_timedelta; + bit<24> deq_qdepth; +} + +struct metadata { + @name("queueing_metadata") + queueing_metadata_t_0 queueing_metadata; +} + +struct headers { + @name("hdr1") + hdr1_t hdr1; + @name("queueing_hdr") + queueing_metadata_t queueing_hdr; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("queueing_dummy") state queueing_dummy { + packet.extract(hdr.queueing_hdr); + transition accept; + } + @name("start") state start { + packet.extract(hdr.hdr1); + transition select(standard_metadata.packet_length) { + 32w0: queueing_dummy; + default: accept; + } + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("copy_queueing_data") action copy_queueing_data() { + hdr.queueing_hdr.setValid(true); + hdr.queueing_hdr.enq_timestamp = meta.queueing_metadata.enq_timestamp; + hdr.queueing_hdr.enq_qdepth = meta.queueing_metadata.enq_qdepth; + hdr.queueing_hdr.deq_timedelta = meta.queueing_metadata.deq_timedelta; + hdr.queueing_hdr.deq_qdepth = meta.queueing_metadata.deq_qdepth; + } + @name("t_egress") table t_egress() { + actions = { + copy_queueing_data; + NoAction; + } + default_action = NoAction(); + } + apply { + t_egress.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("set_port") action set_port(bit<9> port) { + standard_metadata.egress_spec = port; + } + @name("_drop") action _drop() { + mark_to_drop(); + } + @name("t_ingress") table t_ingress() { + actions = { + set_port; + _drop; + NoAction; + } + key = { + hdr.hdr1.f1: exact; + } + size = 128; + default_action = NoAction(); + } + apply { + t_ingress.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.hdr1); + packet.emit(hdr.queueing_hdr); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/queueing-fe.p4 b/testdata/v1_samples_outputs/queueing-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 55% rename from testdata/v1_samples_outputs/queueing-fe.p4 rename to testdata/v1_samples_outputs/queueing-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index a96064e1241..3facfcdb7b5 100644 --- a/testdata/v1_samples_outputs/queueing-fe.p4 +++ b/testdata/v1_samples_outputs/queueing-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,111 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); @name("queueing_metadata_t") struct queueing_metadata_t_0 { bit<48> enq_timestamp; bit<24> enq_qdepth; @@ -61,7 +166,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { t_egress.apply(); } @@ -86,7 +190,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 128; default_action = NoAction(); } - apply { t_ingress.apply(); } diff --git a/testdata/v1_samples_outputs/queueing-midend.p4 b/testdata/v1_samples_outputs/queueing-MidEnd_25_Evaluator.p4 similarity index 56% rename from testdata/v1_samples_outputs/queueing-midend.p4 rename to testdata/v1_samples_outputs/queueing-MidEnd_25_Evaluator.p4 index 11b36e0325d..e86571dcd6e 100644 --- a/testdata/v1_samples_outputs/queueing-midend.p4 +++ b/testdata/v1_samples_outputs/queueing-MidEnd_25_Evaluator.p4 @@ -1,6 +1,109 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); @name("queueing_metadata_t") struct queueing_metadata_t_0 { bit<48> enq_timestamp; bit<24> enq_qdepth; diff --git a/testdata/v1_samples_outputs/queueing-last.p4 b/testdata/v1_samples_outputs/queueing-last.p4 deleted file mode 100644 index a96064e1241..00000000000 --- a/testdata/v1_samples_outputs/queueing-last.p4 +++ /dev/null @@ -1,112 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -@name("queueing_metadata_t") struct queueing_metadata_t_0 { - bit<48> enq_timestamp; - bit<24> enq_qdepth; - bit<32> deq_timedelta; - bit<24> deq_qdepth; -} - -header hdr1_t { - bit<8> f1; - bit<8> f2; -} - -header queueing_metadata_t { - bit<48> enq_timestamp; - bit<24> enq_qdepth; - bit<32> deq_timedelta; - bit<24> deq_qdepth; -} - -struct metadata { - @name("queueing_metadata") - queueing_metadata_t_0 queueing_metadata; -} - -struct headers { - @name("hdr1") - hdr1_t hdr1; - @name("queueing_hdr") - queueing_metadata_t queueing_hdr; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("queueing_dummy") state queueing_dummy { - packet.extract(hdr.queueing_hdr); - transition accept; - } - @name("start") state start { - packet.extract(hdr.hdr1); - transition select(standard_metadata.packet_length) { - 32w0: queueing_dummy; - default: accept; - } - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("copy_queueing_data") action copy_queueing_data() { - hdr.queueing_hdr.setValid(true); - hdr.queueing_hdr.enq_timestamp = meta.queueing_metadata.enq_timestamp; - hdr.queueing_hdr.enq_qdepth = meta.queueing_metadata.enq_qdepth; - hdr.queueing_hdr.deq_timedelta = meta.queueing_metadata.deq_timedelta; - hdr.queueing_hdr.deq_qdepth = meta.queueing_metadata.deq_qdepth; - } - @name("t_egress") table t_egress() { - actions = { - copy_queueing_data; - NoAction; - } - default_action = NoAction(); - } - - apply { - t_egress.apply(); - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("set_port") action set_port(bit<9> port) { - standard_metadata.egress_spec = port; - } - @name("_drop") action _drop() { - mark_to_drop(); - } - @name("t_ingress") table t_ingress() { - actions = { - set_port; - _drop; - NoAction; - } - key = { - hdr.hdr1.f1: exact; - } - size = 128; - default_action = NoAction(); - } - - apply { - t_ingress.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.hdr1); - packet.emit(hdr.queueing_hdr); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/queueing.p4 b/testdata/v1_samples_outputs/queueing.p4 index a96064e1241..2c8d6ff4d70 100644 --- a/testdata/v1_samples_outputs/queueing.p4 +++ b/testdata/v1_samples_outputs/queueing.p4 @@ -61,7 +61,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { t_egress.apply(); } @@ -86,7 +85,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 128; default_action = NoAction(); } - apply { t_ingress.apply(); } diff --git a/testdata/v1_samples_outputs/register-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/register-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..51a81f7b951 --- /dev/null +++ b/testdata/v1_samples_outputs/register-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,208 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct intrinsic_metadata_t { + bit<4> mcast_grp; + bit<4> egress_rid; + bit<16> mcast_hash; + bit<32> lf_field_list; +} + +struct meta_t { + bit<32> register_tmp; +} + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +struct metadata { + @name("intrinsic_metadata") + intrinsic_metadata_t intrinsic_metadata; + @name("meta") + meta_t meta; +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +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 accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + Register>(32w16384) @name("my_register") my_register; + @name("m_action") action m_action(bit<8> register_idx) { + my_register.read(meta.meta.register_tmp, (bit<32>)register_idx); + } + @name("_nop") action _nop() { + } + @name("m_table") table m_table() { + actions = { + m_action; + _nop; + NoAction; + } + key = { + hdr.ethernet.srcAddr: exact; + } + size = 16384; + default_action = NoAction(); + } + apply { + m_table.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/register-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/register-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..f34d3642fee --- /dev/null +++ b/testdata/v1_samples_outputs/register-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,192 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct intrinsic_metadata_t { + bit<4> mcast_grp; + bit<4> egress_rid; + bit<16> mcast_hash; + bit<32> lf_field_list; +} + +struct meta_t { + bit<32> register_tmp; +} + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +struct metadata { + @name("intrinsic_metadata") + intrinsic_metadata_t intrinsic_metadata; + @name("meta") + meta_t meta; +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +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 accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + Register>(32w16384) @name("my_register") my_register; + @name("m_action") action m_action(bit<8> register_idx) { + my_register.read(meta.meta.register_tmp, (bit<32>)register_idx); + } + @name("_nop") action _nop() { + } + @name("m_table") table m_table() { + actions = { + m_action; + _nop; + NoAction; + } + key = { + hdr.ethernet.srcAddr: exact; + } + size = 16384; + default_action = NoAction(); + } + apply { + m_table.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/register-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/register-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..3cdc690401b --- /dev/null +++ b/testdata/v1_samples_outputs/register-MidEnd_25_Evaluator.p4 @@ -0,0 +1,192 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct intrinsic_metadata_t { + bit<4> mcast_grp; + bit<4> egress_rid; + bit<16> mcast_hash; + bit<32> lf_field_list; +} + +struct meta_t { + bit<32> register_tmp; +} + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +struct metadata { + @name("intrinsic_metadata") + intrinsic_metadata_t intrinsic_metadata; + @name("meta") + meta_t meta; +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +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 accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + Register>(32w16384) @name("my_register") my_register_0; + @name("m_action") action m_action_0(bit<8> register_idx) { + my_register_0.read(meta.meta.register_tmp, (bit<32>)register_idx); + } + @name("_nop") action _nop_0() { + } + @name("m_table") table m_table_0() { + actions = { + m_action_0; + _nop_0; + NoAction_0; + } + key = { + hdr.ethernet.srcAddr: exact; + } + size = 16384; + default_action = NoAction_0(); + } + apply { + m_table_0.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/register-fe.p4 b/testdata/v1_samples_outputs/register-fe.p4 deleted file mode 100644 index 39eb60e762b..00000000000 --- a/testdata/v1_samples_outputs/register-fe.p4 +++ /dev/null @@ -1,89 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct intrinsic_metadata_t { - bit<4> mcast_grp; - bit<4> egress_rid; - bit<16> mcast_hash; - bit<32> lf_field_list; -} - -struct meta_t { - bit<32> register_tmp; -} - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> etherType; -} - -struct metadata { - @name("intrinsic_metadata") - intrinsic_metadata_t intrinsic_metadata; - @name("meta") - meta_t meta; -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -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 accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - Register>(32w16384) @name("my_register") my_register; - @name("m_action") action m_action(bit<8> register_idx) { - my_register.read(meta.meta.register_tmp, (bit<32>)register_idx); - } - @name("_nop") action _nop() { - } - @name("m_table") table m_table() { - actions = { - m_action; - _nop; - NoAction; - } - key = { - hdr.ethernet.srcAddr: exact; - } - size = 16384; - default_action = NoAction(); - } - - apply { - m_table.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/register-last.p4 b/testdata/v1_samples_outputs/register-last.p4 deleted file mode 100644 index 39eb60e762b..00000000000 --- a/testdata/v1_samples_outputs/register-last.p4 +++ /dev/null @@ -1,89 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct intrinsic_metadata_t { - bit<4> mcast_grp; - bit<4> egress_rid; - bit<16> mcast_hash; - bit<32> lf_field_list; -} - -struct meta_t { - bit<32> register_tmp; -} - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> etherType; -} - -struct metadata { - @name("intrinsic_metadata") - intrinsic_metadata_t intrinsic_metadata; - @name("meta") - meta_t meta; -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -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 accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - Register>(32w16384) @name("my_register") my_register; - @name("m_action") action m_action(bit<8> register_idx) { - my_register.read(meta.meta.register_tmp, (bit<32>)register_idx); - } - @name("_nop") action _nop() { - } - @name("m_table") table m_table() { - actions = { - m_action; - _nop; - NoAction; - } - key = { - hdr.ethernet.srcAddr: exact; - } - size = 16384; - default_action = NoAction(); - } - - apply { - m_table.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/register-midend.p4 b/testdata/v1_samples_outputs/register-midend.p4 deleted file mode 100644 index a905fae9583..00000000000 --- a/testdata/v1_samples_outputs/register-midend.p4 +++ /dev/null @@ -1,90 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct intrinsic_metadata_t { - bit<4> mcast_grp; - bit<4> egress_rid; - bit<16> mcast_hash; - bit<32> lf_field_list; -} - -struct meta_t { - bit<32> register_tmp; -} - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> etherType; -} - -struct metadata { - @name("intrinsic_metadata") - intrinsic_metadata_t intrinsic_metadata; - @name("meta") - meta_t meta; -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -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 accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - Register>(32w16384) @name("my_register") my_register_0; - @name("m_action") action m_action_0(bit<8> register_idx) { - my_register_0.read(meta.meta.register_tmp, (bit<32>)register_idx); - } - @name("_nop") action _nop_0() { - } - @name("m_table") table m_table_0() { - actions = { - m_action_0; - _nop_0; - NoAction_0; - } - key = { - hdr.ethernet.srcAddr: exact; - } - size = 16384; - default_action = NoAction_0(); - } - apply { - m_table_0.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/register.p4 b/testdata/v1_samples_outputs/register.p4 index 39eb60e762b..1a3a2f3eddc 100644 --- a/testdata/v1_samples_outputs/register.p4 +++ b/testdata/v1_samples_outputs/register.p4 @@ -64,7 +64,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 16384; default_action = NoAction(); } - apply { m_table.apply(); } diff --git a/testdata/v1_samples_outputs/resubmit-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/resubmit-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..4f0577acced --- /dev/null +++ b/testdata/v1_samples_outputs/resubmit-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,225 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct intrinsic_metadata_t { + bit<4> mcast_grp; + bit<4> egress_rid; + bit<16> mcast_hash; + bit<32> lf_field_list; + bit<16> resubmit_flag; +} + +struct mymeta_t { + bit<8> f1; +} + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +struct metadata { + @name("intrinsic_metadata") + intrinsic_metadata_t intrinsic_metadata; + @name("mymeta") + mymeta_t mymeta; +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +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 accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("_nop") action _nop() { + } + @name("set_port") action set_port(bit<9> port) { + standard_metadata.egress_spec = port; + } + @name("_resubmit") action _resubmit() { + meta.mymeta.f1 = 8w1; + resubmit({ standard_metadata, meta.mymeta }); + } + @name("t_ingress_1") table t_ingress_1() { + actions = { + _nop; + set_port; + NoAction; + } + key = { + meta.mymeta.f1: exact; + } + size = 128; + default_action = NoAction(); + } + @name("t_ingress_2") table t_ingress_2() { + actions = { + _nop; + _resubmit; + NoAction; + } + key = { + meta.mymeta.f1: exact; + } + size = 128; + default_action = NoAction(); + } + apply { + t_ingress_1.apply(); + t_ingress_2.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/resubmit-fe.p4 b/testdata/v1_samples_outputs/resubmit-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 50% rename from testdata/v1_samples_outputs/resubmit-fe.p4 rename to testdata/v1_samples_outputs/resubmit-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index c6e2a29e47d..8bd306c1ec7 100644 --- a/testdata/v1_samples_outputs/resubmit-fe.p4 +++ b/testdata/v1_samples_outputs/resubmit-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,111 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +extern void resubmit(in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; @@ -68,7 +173,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 128; default_action = NoAction(); } - @name("t_ingress_2") table t_ingress_2() { actions = { _nop; @@ -81,7 +185,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 128; default_action = NoAction(); } - apply { t_ingress_1.apply(); t_ingress_2.apply(); diff --git a/testdata/v1_samples_outputs/resubmit-midend.p4 b/testdata/v1_samples_outputs/resubmit-MidEnd_25_Evaluator.p4 similarity index 52% rename from testdata/v1_samples_outputs/resubmit-midend.p4 rename to testdata/v1_samples_outputs/resubmit-MidEnd_25_Evaluator.p4 index f6338931e11..6612f6488cc 100644 --- a/testdata/v1_samples_outputs/resubmit-midend.p4 +++ b/testdata/v1_samples_outputs/resubmit-MidEnd_25_Evaluator.p4 @@ -1,6 +1,109 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +extern void resubmit(in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; diff --git a/testdata/v1_samples_outputs/resubmit-last.p4 b/testdata/v1_samples_outputs/resubmit-last.p4 deleted file mode 100644 index c6e2a29e47d..00000000000 --- a/testdata/v1_samples_outputs/resubmit-last.p4 +++ /dev/null @@ -1,107 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct intrinsic_metadata_t { - bit<4> mcast_grp; - bit<4> egress_rid; - bit<16> mcast_hash; - bit<32> lf_field_list; - bit<16> resubmit_flag; -} - -struct mymeta_t { - bit<8> f1; -} - -header ethernet_t { - bit<48> dstAddr; - bit<48> srcAddr; - bit<16> etherType; -} - -struct metadata { - @name("intrinsic_metadata") - intrinsic_metadata_t intrinsic_metadata; - @name("mymeta") - mymeta_t mymeta; -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -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 accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("_nop") action _nop() { - } - @name("set_port") action set_port(bit<9> port) { - standard_metadata.egress_spec = port; - } - @name("_resubmit") action _resubmit() { - meta.mymeta.f1 = 8w1; - resubmit({ standard_metadata, meta.mymeta }); - } - @name("t_ingress_1") table t_ingress_1() { - actions = { - _nop; - set_port; - NoAction; - } - key = { - meta.mymeta.f1: exact; - } - size = 128; - default_action = NoAction(); - } - - @name("t_ingress_2") table t_ingress_2() { - actions = { - _nop; - _resubmit; - NoAction; - } - key = { - meta.mymeta.f1: exact; - } - size = 128; - default_action = NoAction(); - } - - apply { - t_ingress_1.apply(); - t_ingress_2.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/resubmit.p4 b/testdata/v1_samples_outputs/resubmit.p4 index c6e2a29e47d..e8d973df910 100644 --- a/testdata/v1_samples_outputs/resubmit.p4 +++ b/testdata/v1_samples_outputs/resubmit.p4 @@ -68,7 +68,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 128; default_action = NoAction(); } - @name("t_ingress_2") table t_ingress_2() { actions = { _nop; @@ -81,7 +80,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 128; default_action = NoAction(); } - apply { t_ingress_1.apply(); t_ingress_2.apply(); diff --git a/testdata/v1_samples_outputs/sai_p4-fe.p4 b/testdata/v1_samples_outputs/sai_p4-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 81% rename from testdata/v1_samples_outputs/sai_p4-fe.p4 rename to testdata/v1_samples_outputs/sai_p4-FrontEnd_11_SimplifyControlFlowE.p4 index dcb0780b28c..a3dfe769e36 100644 --- a/testdata/v1_samples_outputs/sai_p4-fe.p4 +++ b/testdata/v1_samples_outputs/sai_p4-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct egress_metadata_t { bit<16> mirror_port; } @@ -231,7 +351,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("learn_notify") table learn_notify() { actions = { nop; @@ -245,7 +364,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("neighbor") table neighbor() { actions = { set_dmac; @@ -258,7 +376,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("next_hop") table next_hop() { actions = { set_next_hop; @@ -269,7 +386,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("port") table port() { actions = { set_in_port; @@ -281,7 +397,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ default_action = NoAction(); @name("port_counters") counters = DirectCounter(CounterType.Packets); } - @name("route") table route() { actions = { route_set_trap; @@ -295,7 +410,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("router_interface") table router_interface() { actions = { set_router_interface; @@ -307,7 +421,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("switch") table switch_0() { actions = { set_switch; @@ -315,7 +428,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("virtual_router") table virtual_router() { actions = { set_router; @@ -326,7 +438,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { switch_0.apply(); port.apply(); diff --git a/testdata/v1_samples_outputs/sai_p4-last.p4 b/testdata/v1_samples_outputs/sai_p4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 84% rename from testdata/v1_samples_outputs/sai_p4-last.p4 rename to testdata/v1_samples_outputs/sai_p4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index dcb0780b28c..61a1a0fffce 100644 --- a/testdata/v1_samples_outputs/sai_p4-last.p4 +++ b/testdata/v1_samples_outputs/sai_p4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,111 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct egress_metadata_t { bit<16> mirror_port; } @@ -231,7 +336,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("learn_notify") table learn_notify() { actions = { nop; @@ -245,7 +349,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("neighbor") table neighbor() { actions = { set_dmac; @@ -258,7 +361,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("next_hop") table next_hop() { actions = { set_next_hop; @@ -269,7 +371,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("port") table port() { actions = { set_in_port; @@ -281,7 +382,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ default_action = NoAction(); @name("port_counters") counters = DirectCounter(CounterType.Packets); } - @name("route") table route() { actions = { route_set_trap; @@ -295,7 +395,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("router_interface") table router_interface() { actions = { set_router_interface; @@ -307,7 +406,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("switch") table switch_0() { actions = { set_switch; @@ -315,7 +413,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("virtual_router") table virtual_router() { actions = { set_router; @@ -326,7 +423,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { switch_0.apply(); port.apply(); diff --git a/testdata/v1_samples_outputs/sai_p4-midend.p4 b/testdata/v1_samples_outputs/sai_p4-MidEnd_25_Evaluator.p4 similarity index 85% rename from testdata/v1_samples_outputs/sai_p4-midend.p4 rename to testdata/v1_samples_outputs/sai_p4-MidEnd_25_Evaluator.p4 index 7d7db8311d5..4a0869a2176 100644 --- a/testdata/v1_samples_outputs/sai_p4-midend.p4 +++ b/testdata/v1_samples_outputs/sai_p4-MidEnd_25_Evaluator.p4 @@ -1,6 +1,109 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct egress_metadata_t { bit<16> mirror_port; } diff --git a/testdata/v1_samples_outputs/sai_p4.p4 b/testdata/v1_samples_outputs/sai_p4.p4 index 0b63ecc1093..60e213638f8 100644 --- a/testdata/v1_samples_outputs/sai_p4.p4 +++ b/testdata/v1_samples_outputs/sai_p4.p4 @@ -232,7 +232,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("learn_notify") table learn_notify() { actions = { nop; @@ -246,7 +245,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("neighbor") table neighbor() { actions = { set_dmac; @@ -259,7 +257,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("next_hop") table next_hop() { actions = { set_next_hop; @@ -270,7 +267,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("port") table port() { actions = { set_in_port; @@ -282,7 +278,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ default_action = NoAction(); @name("port_counters") counters = DirectCounter(CounterType.Packets); } - @name("route") table route() { actions = { route_set_trap; @@ -296,7 +291,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("router_interface") table router_interface() { actions = { set_router_interface; @@ -308,7 +302,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("switch") table switch_0() { actions = { set_switch; @@ -316,7 +309,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("virtual_router") table virtual_router() { actions = { set_router; @@ -327,7 +319,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { switch_0.apply(); port.apply(); diff --git a/testdata/v1_samples_outputs/selector0-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/selector0-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..c924a9275a7 --- /dev/null +++ b/testdata/v1_samples_outputs/selector0-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,195 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + noop; + NoAction; + } + key = { + hdr.data.b1: exact; + hdr.data.f1: selector; + hdr.data.f2: selector; + hdr.data.f3: selector; + hdr.data.f4: selector; + } + size = 1024; + default_action = NoAction(); + @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/selector0-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/selector0-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..4efe020dec9 --- /dev/null +++ b/testdata/v1_samples_outputs/selector0-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,179 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + noop; + NoAction; + } + key = { + hdr.data.b1: exact; + hdr.data.f1: selector; + hdr.data.f2: selector; + hdr.data.f3: selector; + hdr.data.f4: selector; + } + size = 1024; + default_action = NoAction(); + @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/selector0-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/selector0-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..376ae9ff1d2 --- /dev/null +++ b/testdata/v1_samples_outputs/selector0-MidEnd_25_Evaluator.p4 @@ -0,0 +1,179 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("noop") action noop_0() { + } + @name("test1") table test1_0() { + actions = { + noop_0; + NoAction_0; + } + key = { + hdr.data.b1: exact; + hdr.data.f1: selector; + hdr.data.f2: selector; + hdr.data.f3: selector; + hdr.data.f4: selector; + } + size = 1024; + default_action = NoAction_0(); + @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); + } + apply { + test1_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/selector0-fe.p4 b/testdata/v1_samples_outputs/selector0-fe.p4 deleted file mode 100644 index cb959fafde3..00000000000 --- a/testdata/v1_samples_outputs/selector0-fe.p4 +++ /dev/null @@ -1,76 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - noop; - NoAction; - } - key = { - hdr.data.b1: exact; - hdr.data.f1: selector; - hdr.data.f2: selector; - hdr.data.f3: selector; - hdr.data.f4: selector; - } - size = 1024; - default_action = NoAction(); - @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/selector0-last.p4 b/testdata/v1_samples_outputs/selector0-last.p4 deleted file mode 100644 index cb959fafde3..00000000000 --- a/testdata/v1_samples_outputs/selector0-last.p4 +++ /dev/null @@ -1,76 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - noop; - NoAction; - } - key = { - hdr.data.b1: exact; - hdr.data.f1: selector; - hdr.data.f2: selector; - hdr.data.f3: selector; - hdr.data.f4: selector; - } - size = 1024; - default_action = NoAction(); - @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/selector0-midend.p4 b/testdata/v1_samples_outputs/selector0-midend.p4 deleted file mode 100644 index 63729a5aa34..00000000000 --- a/testdata/v1_samples_outputs/selector0-midend.p4 +++ /dev/null @@ -1,77 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("noop") action noop_0() { - } - @name("test1") table test1_0() { - actions = { - noop_0; - NoAction_0; - } - key = { - hdr.data.b1: exact; - hdr.data.f1: selector; - hdr.data.f2: selector; - hdr.data.f3: selector; - hdr.data.f4: selector; - } - size = 1024; - default_action = NoAction_0(); - @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); - } - apply { - test1_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/selector0.p4 b/testdata/v1_samples_outputs/selector0.p4 index cb959fafde3..45ad55f8cfe 100644 --- a/testdata/v1_samples_outputs/selector0.p4 +++ b/testdata/v1_samples_outputs/selector0.p4 @@ -46,7 +46,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ default_action = NoAction(); @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); } - apply { test1.apply(); } diff --git a/testdata/v1_samples_outputs/selector1-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/selector1-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..b7eb3cdb0a0 --- /dev/null +++ b/testdata/v1_samples_outputs/selector1-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,199 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("noop") action noop() { + } + @name("setf1") action setf1(bit<32> val) { + hdr.data.f1 = val; + } + @name("test1") table test1() { + actions = { + noop; + setf1; + NoAction; + } + key = { + hdr.data.b1: exact; + hdr.data.f1: selector; + hdr.data.f2: selector; + hdr.data.f3: selector; + hdr.data.f4: selector; + } + size = 1024; + default_action = NoAction(); + @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/selector1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/selector1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..805e6366e50 --- /dev/null +++ b/testdata/v1_samples_outputs/selector1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,183 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("noop") action noop() { + } + @name("setf1") action setf1(bit<32> val) { + hdr.data.f1 = val; + } + @name("test1") table test1() { + actions = { + noop; + setf1; + NoAction; + } + key = { + hdr.data.b1: exact; + hdr.data.f1: selector; + hdr.data.f2: selector; + hdr.data.f3: selector; + hdr.data.f4: selector; + } + size = 1024; + default_action = NoAction(); + @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/selector1-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/selector1-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..2767cac5855 --- /dev/null +++ b/testdata/v1_samples_outputs/selector1-MidEnd_25_Evaluator.p4 @@ -0,0 +1,183 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("noop") action noop_0() { + } + @name("setf1") action setf1_0(bit<32> val) { + hdr.data.f1 = val; + } + @name("test1") table test1_0() { + actions = { + noop_0; + setf1_0; + NoAction_0; + } + key = { + hdr.data.b1: exact; + hdr.data.f1: selector; + hdr.data.f2: selector; + hdr.data.f3: selector; + hdr.data.f4: selector; + } + size = 1024; + default_action = NoAction_0(); + @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); + } + apply { + test1_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/selector1-fe.p4 b/testdata/v1_samples_outputs/selector1-fe.p4 deleted file mode 100644 index 2be314ccce7..00000000000 --- a/testdata/v1_samples_outputs/selector1-fe.p4 +++ /dev/null @@ -1,80 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("noop") action noop() { - } - @name("setf1") action setf1(bit<32> val) { - hdr.data.f1 = val; - } - @name("test1") table test1() { - actions = { - noop; - setf1; - NoAction; - } - key = { - hdr.data.b1: exact; - hdr.data.f1: selector; - hdr.data.f2: selector; - hdr.data.f3: selector; - hdr.data.f4: selector; - } - size = 1024; - default_action = NoAction(); - @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/selector1-last.p4 b/testdata/v1_samples_outputs/selector1-last.p4 deleted file mode 100644 index 2be314ccce7..00000000000 --- a/testdata/v1_samples_outputs/selector1-last.p4 +++ /dev/null @@ -1,80 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("noop") action noop() { - } - @name("setf1") action setf1(bit<32> val) { - hdr.data.f1 = val; - } - @name("test1") table test1() { - actions = { - noop; - setf1; - NoAction; - } - key = { - hdr.data.b1: exact; - hdr.data.f1: selector; - hdr.data.f2: selector; - hdr.data.f3: selector; - hdr.data.f4: selector; - } - size = 1024; - default_action = NoAction(); - @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/selector1-midend.p4 b/testdata/v1_samples_outputs/selector1-midend.p4 deleted file mode 100644 index 27ff1fb1f27..00000000000 --- a/testdata/v1_samples_outputs/selector1-midend.p4 +++ /dev/null @@ -1,81 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("noop") action noop_0() { - } - @name("setf1") action setf1_0(bit<32> val) { - hdr.data.f1 = val; - } - @name("test1") table test1_0() { - actions = { - noop_0; - setf1_0; - NoAction_0; - } - key = { - hdr.data.b1: exact; - hdr.data.f1: selector; - hdr.data.f2: selector; - hdr.data.f3: selector; - hdr.data.f4: selector; - } - size = 1024; - default_action = NoAction_0(); - @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); - } - apply { - test1_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/selector1.p4 b/testdata/v1_samples_outputs/selector1.p4 index 2be314ccce7..355c20423fc 100644 --- a/testdata/v1_samples_outputs/selector1.p4 +++ b/testdata/v1_samples_outputs/selector1.p4 @@ -50,7 +50,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ default_action = NoAction(); @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); } - apply { test1.apply(); } diff --git a/testdata/v1_samples_outputs/selector2-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/selector2-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..7b2382e7b96 --- /dev/null +++ b/testdata/v1_samples_outputs/selector2-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,199 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("noop") action noop() { + } + @name("setf1") action setf1(bit<32> val) { + hdr.data.f1 = val; + } + @name("test1") table test1() { + actions = { + noop; + setf1; + NoAction; + } + key = { + hdr.data.b1: ternary; + hdr.data.f1: selector; + hdr.data.f2: selector; + hdr.data.f3: selector; + hdr.data.f4: selector; + } + size = 1024; + default_action = NoAction(); + @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/selector2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/selector2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..27f9c283bdc --- /dev/null +++ b/testdata/v1_samples_outputs/selector2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,183 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("noop") action noop() { + } + @name("setf1") action setf1(bit<32> val) { + hdr.data.f1 = val; + } + @name("test1") table test1() { + actions = { + noop; + setf1; + NoAction; + } + key = { + hdr.data.b1: ternary; + hdr.data.f1: selector; + hdr.data.f2: selector; + hdr.data.f3: selector; + hdr.data.f4: selector; + } + size = 1024; + default_action = NoAction(); + @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/selector2-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/selector2-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..164ebab633b --- /dev/null +++ b/testdata/v1_samples_outputs/selector2-MidEnd_25_Evaluator.p4 @@ -0,0 +1,183 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("noop") action noop_0() { + } + @name("setf1") action setf1_0(bit<32> val) { + hdr.data.f1 = val; + } + @name("test1") table test1_0() { + actions = { + noop_0; + setf1_0; + NoAction_0; + } + key = { + hdr.data.b1: ternary; + hdr.data.f1: selector; + hdr.data.f2: selector; + hdr.data.f3: selector; + hdr.data.f4: selector; + } + size = 1024; + default_action = NoAction_0(); + @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); + } + apply { + test1_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/selector2-fe.p4 b/testdata/v1_samples_outputs/selector2-fe.p4 deleted file mode 100644 index b57f9f66b74..00000000000 --- a/testdata/v1_samples_outputs/selector2-fe.p4 +++ /dev/null @@ -1,80 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("noop") action noop() { - } - @name("setf1") action setf1(bit<32> val) { - hdr.data.f1 = val; - } - @name("test1") table test1() { - actions = { - noop; - setf1; - NoAction; - } - key = { - hdr.data.b1: ternary; - hdr.data.f1: selector; - hdr.data.f2: selector; - hdr.data.f3: selector; - hdr.data.f4: selector; - } - size = 1024; - default_action = NoAction(); - @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/selector2-last.p4 b/testdata/v1_samples_outputs/selector2-last.p4 deleted file mode 100644 index b57f9f66b74..00000000000 --- a/testdata/v1_samples_outputs/selector2-last.p4 +++ /dev/null @@ -1,80 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("noop") action noop() { - } - @name("setf1") action setf1(bit<32> val) { - hdr.data.f1 = val; - } - @name("test1") table test1() { - actions = { - noop; - setf1; - NoAction; - } - key = { - hdr.data.b1: ternary; - hdr.data.f1: selector; - hdr.data.f2: selector; - hdr.data.f3: selector; - hdr.data.f4: selector; - } - size = 1024; - default_action = NoAction(); - @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/selector2-midend.p4 b/testdata/v1_samples_outputs/selector2-midend.p4 deleted file mode 100644 index e070e4f7363..00000000000 --- a/testdata/v1_samples_outputs/selector2-midend.p4 +++ /dev/null @@ -1,81 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("noop") action noop_0() { - } - @name("setf1") action setf1_0(bit<32> val) { - hdr.data.f1 = val; - } - @name("test1") table test1_0() { - actions = { - noop_0; - setf1_0; - NoAction_0; - } - key = { - hdr.data.b1: ternary; - hdr.data.f1: selector; - hdr.data.f2: selector; - hdr.data.f3: selector; - hdr.data.f4: selector; - } - size = 1024; - default_action = NoAction_0(); - @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); - } - apply { - test1_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/selector2.p4 b/testdata/v1_samples_outputs/selector2.p4 index b57f9f66b74..b6e101d9c20 100644 --- a/testdata/v1_samples_outputs/selector2.p4 +++ b/testdata/v1_samples_outputs/selector2.p4 @@ -50,7 +50,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ default_action = NoAction(); @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); } - apply { test1.apply(); } diff --git a/testdata/v1_samples_outputs/selector3-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/selector3-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..88b744bfdc4 --- /dev/null +++ b/testdata/v1_samples_outputs/selector3-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,206 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("noop") action noop() { + } + @name("setf1") action setf1(bit<32> val) { + hdr.data.f1 = val; + } + @name("setall") action setall(bit<32> v1, bit<32> v2, bit<32> v3, bit<32> v4) { + hdr.data.f1 = v1; + hdr.data.f2 = v2; + hdr.data.f3 = v3; + hdr.data.f4 = v4; + } + @name("test1") table test1() { + actions = { + noop; + setf1; + setall; + NoAction; + } + key = { + hdr.data.b1: exact; + hdr.data.f1: selector; + hdr.data.f2: selector; + hdr.data.f3: selector; + hdr.data.f4: selector; + } + size = 1024; + default_action = NoAction(); + @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/selector3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/selector3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..273435eb3ec --- /dev/null +++ b/testdata/v1_samples_outputs/selector3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,190 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("noop") action noop() { + } + @name("setf1") action setf1(bit<32> val) { + hdr.data.f1 = val; + } + @name("setall") action setall(bit<32> v1, bit<32> v2, bit<32> v3, bit<32> v4) { + hdr.data.f1 = v1; + hdr.data.f2 = v2; + hdr.data.f3 = v3; + hdr.data.f4 = v4; + } + @name("test1") table test1() { + actions = { + noop; + setf1; + setall; + NoAction; + } + key = { + hdr.data.b1: exact; + hdr.data.f1: selector; + hdr.data.f2: selector; + hdr.data.f3: selector; + hdr.data.f4: selector; + } + size = 1024; + default_action = NoAction(); + @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/selector3-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/selector3-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..2b559538331 --- /dev/null +++ b/testdata/v1_samples_outputs/selector3-MidEnd_25_Evaluator.p4 @@ -0,0 +1,190 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("noop") action noop_0() { + } + @name("setf1") action setf1_0(bit<32> val) { + hdr.data.f1 = val; + } + @name("setall") action setall_0(bit<32> v1, bit<32> v2, bit<32> v3, bit<32> v4) { + hdr.data.f1 = v1; + hdr.data.f2 = v2; + hdr.data.f3 = v3; + hdr.data.f4 = v4; + } + @name("test1") table test1_0() { + actions = { + noop_0; + setf1_0; + setall_0; + NoAction_0; + } + key = { + hdr.data.b1: exact; + hdr.data.f1: selector; + hdr.data.f2: selector; + hdr.data.f3: selector; + hdr.data.f4: selector; + } + size = 1024; + default_action = NoAction_0(); + @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); + } + apply { + test1_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/selector3-fe.p4 b/testdata/v1_samples_outputs/selector3-fe.p4 deleted file mode 100644 index f5a5f79d4e4..00000000000 --- a/testdata/v1_samples_outputs/selector3-fe.p4 +++ /dev/null @@ -1,87 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("noop") action noop() { - } - @name("setf1") action setf1(bit<32> val) { - hdr.data.f1 = val; - } - @name("setall") action setall(bit<32> v1, bit<32> v2, bit<32> v3, bit<32> v4) { - hdr.data.f1 = v1; - hdr.data.f2 = v2; - hdr.data.f3 = v3; - hdr.data.f4 = v4; - } - @name("test1") table test1() { - actions = { - noop; - setf1; - setall; - NoAction; - } - key = { - hdr.data.b1: exact; - hdr.data.f1: selector; - hdr.data.f2: selector; - hdr.data.f3: selector; - hdr.data.f4: selector; - } - size = 1024; - default_action = NoAction(); - @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/selector3-last.p4 b/testdata/v1_samples_outputs/selector3-last.p4 deleted file mode 100644 index f5a5f79d4e4..00000000000 --- a/testdata/v1_samples_outputs/selector3-last.p4 +++ /dev/null @@ -1,87 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("noop") action noop() { - } - @name("setf1") action setf1(bit<32> val) { - hdr.data.f1 = val; - } - @name("setall") action setall(bit<32> v1, bit<32> v2, bit<32> v3, bit<32> v4) { - hdr.data.f1 = v1; - hdr.data.f2 = v2; - hdr.data.f3 = v3; - hdr.data.f4 = v4; - } - @name("test1") table test1() { - actions = { - noop; - setf1; - setall; - NoAction; - } - key = { - hdr.data.b1: exact; - hdr.data.f1: selector; - hdr.data.f2: selector; - hdr.data.f3: selector; - hdr.data.f4: selector; - } - size = 1024; - default_action = NoAction(); - @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/selector3-midend.p4 b/testdata/v1_samples_outputs/selector3-midend.p4 deleted file mode 100644 index 80ce3c2f775..00000000000 --- a/testdata/v1_samples_outputs/selector3-midend.p4 +++ /dev/null @@ -1,88 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("noop") action noop_0() { - } - @name("setf1") action setf1_0(bit<32> val) { - hdr.data.f1 = val; - } - @name("setall") action setall_0(bit<32> v1, bit<32> v2, bit<32> v3, bit<32> v4) { - hdr.data.f1 = v1; - hdr.data.f2 = v2; - hdr.data.f3 = v3; - hdr.data.f4 = v4; - } - @name("test1") table test1_0() { - actions = { - noop_0; - setf1_0; - setall_0; - NoAction_0; - } - key = { - hdr.data.b1: exact; - hdr.data.f1: selector; - hdr.data.f2: selector; - hdr.data.f3: selector; - hdr.data.f4: selector; - } - size = 1024; - default_action = NoAction_0(); - @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); - } - apply { - test1_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/selector3.p4 b/testdata/v1_samples_outputs/selector3.p4 index f5a5f79d4e4..95c4ca0f419 100644 --- a/testdata/v1_samples_outputs/selector3.p4 +++ b/testdata/v1_samples_outputs/selector3.p4 @@ -57,7 +57,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ default_action = NoAction(); @name("sel_profile") implementation = ActionSelector(HashAlgorithm.crc16, 32w16384, 32w14); } - apply { test1.apply(); } diff --git a/testdata/v1_samples_outputs/simple_nat-fe.p4 b/testdata/v1_samples_outputs/simple_nat-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 75% rename from testdata/v1_samples_outputs/simple_nat-fe.p4 rename to testdata/v1_samples_outputs/simple_nat-FrontEnd_11_SimplifyControlFlowE.p4 index 194ea1b7737..d9f46dfb654 100644 --- a/testdata/v1_samples_outputs/simple_nat-fe.p4 +++ b/testdata/v1_samples_outputs/simple_nat-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; @@ -150,7 +270,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t size = 256; default_action = NoAction(); } - @name("send_to_cpu") table send_to_cpu() { actions = { do_cpu_encap; @@ -158,7 +277,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { if (standard_metadata.instance_type == 32w0) send_frame.apply(); @@ -216,7 +334,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 512; default_action = NoAction(); } - @name("if_info") table if_info() { actions = { _drop; @@ -228,7 +345,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("ipv4_lpm") table ipv4_lpm() { actions = { set_nhop; @@ -241,7 +357,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 1024; default_action = NoAction(); } - @name("nat") table nat() { actions = { _drop; @@ -264,7 +379,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 128; default_action = NoAction(); } - apply { if_info.apply(); nat.apply(); diff --git a/testdata/v1_samples_outputs/simple_nat-last.p4 b/testdata/v1_samples_outputs/simple_nat-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 79% rename from testdata/v1_samples_outputs/simple_nat-last.p4 rename to testdata/v1_samples_outputs/simple_nat-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 194ea1b7737..8896290d781 100644 --- a/testdata/v1_samples_outputs/simple_nat-last.p4 +++ b/testdata/v1_samples_outputs/simple_nat-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,117 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} +extern void mark_to_drop(); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; @@ -150,7 +261,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t size = 256; default_action = NoAction(); } - @name("send_to_cpu") table send_to_cpu() { actions = { do_cpu_encap; @@ -158,7 +268,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { if (standard_metadata.instance_type == 32w0) send_frame.apply(); @@ -216,7 +325,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 512; default_action = NoAction(); } - @name("if_info") table if_info() { actions = { _drop; @@ -228,7 +336,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("ipv4_lpm") table ipv4_lpm() { actions = { set_nhop; @@ -241,7 +348,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 1024; default_action = NoAction(); } - @name("nat") table nat() { actions = { _drop; @@ -264,7 +370,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 128; default_action = NoAction(); } - apply { if_info.apply(); nat.apply(); diff --git a/testdata/v1_samples_outputs/simple_nat-midend.p4 b/testdata/v1_samples_outputs/simple_nat-MidEnd_25_Evaluator.p4 similarity index 81% rename from testdata/v1_samples_outputs/simple_nat-midend.p4 rename to testdata/v1_samples_outputs/simple_nat-MidEnd_25_Evaluator.p4 index f71422c067d..d1a4cfa5ce6 100644 --- a/testdata/v1_samples_outputs/simple_nat-midend.p4 +++ b/testdata/v1_samples_outputs/simple_nat-MidEnd_25_Evaluator.p4 @@ -1,6 +1,115 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct intrinsic_metadata_t { bit<4> mcast_grp; bit<4> egress_rid; diff --git a/testdata/v1_samples_outputs/simple_nat.p4 b/testdata/v1_samples_outputs/simple_nat.p4 index a964d1d64eb..1b348b66202 100644 --- a/testdata/v1_samples_outputs/simple_nat.p4 +++ b/testdata/v1_samples_outputs/simple_nat.p4 @@ -150,7 +150,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t size = 256; default_action = NoAction(); } - @name("send_to_cpu") table send_to_cpu() { actions = { do_cpu_encap; @@ -158,7 +157,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { if (standard_metadata.instance_type == 32w0) { send_frame.apply(); @@ -218,7 +216,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 512; default_action = NoAction(); } - @name("if_info") table if_info() { actions = { _drop; @@ -230,7 +227,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("ipv4_lpm") table ipv4_lpm() { actions = { set_nhop; @@ -243,7 +239,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 1024; default_action = NoAction(); } - @name("nat") table nat() { actions = { _drop; @@ -266,7 +261,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 128; default_action = NoAction(); } - apply { if_info.apply(); nat.apply(); diff --git a/testdata/v1_samples_outputs/simple_router-last.p4 b/testdata/v1_samples_outputs/simple_router-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 58% rename from testdata/v1_samples_outputs/simple_router-last.p4 rename to testdata/v1_samples_outputs/simple_router-FrontEnd_11_SimplifyControlFlowE.p4 index 0e3483c5c3f..bae2c1647e0 100644 --- a/testdata/v1_samples_outputs/simple_router-last.p4 +++ b/testdata/v1_samples_outputs/simple_router-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct routing_metadata_t { bit<32> nhop_ipv4; } @@ -74,7 +194,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t size = 256; default_action = NoAction(); } - apply { send_frame.apply(); } @@ -104,7 +223,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 512; default_action = NoAction(); } - @name("ipv4_lpm") table ipv4_lpm() { actions = { set_nhop; @@ -117,7 +235,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 1024; default_action = NoAction(); } - apply { if (hdr.ipv4.isValid() && hdr.ipv4.ttl > 8w0) { ipv4_lpm.apply(); diff --git a/testdata/v1_samples_outputs/simple_router-fe.p4 b/testdata/v1_samples_outputs/simple_router-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 63% rename from testdata/v1_samples_outputs/simple_router-fe.p4 rename to testdata/v1_samples_outputs/simple_router-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 0e3483c5c3f..3605216a787 100644 --- a/testdata/v1_samples_outputs/simple_router-fe.p4 +++ b/testdata/v1_samples_outputs/simple_router-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,111 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct routing_metadata_t { bit<32> nhop_ipv4; } @@ -74,7 +179,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t size = 256; default_action = NoAction(); } - apply { send_frame.apply(); } @@ -104,7 +208,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 512; default_action = NoAction(); } - @name("ipv4_lpm") table ipv4_lpm() { actions = { set_nhop; @@ -117,7 +220,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 1024; default_action = NoAction(); } - apply { if (hdr.ipv4.isValid() && hdr.ipv4.ttl > 8w0) { ipv4_lpm.apply(); diff --git a/testdata/v1_samples_outputs/simple_router-midend.p4 b/testdata/v1_samples_outputs/simple_router-MidEnd_25_Evaluator.p4 similarity index 66% rename from testdata/v1_samples_outputs/simple_router-midend.p4 rename to testdata/v1_samples_outputs/simple_router-MidEnd_25_Evaluator.p4 index 97477e3ea16..b6b88dfff6a 100644 --- a/testdata/v1_samples_outputs/simple_router-midend.p4 +++ b/testdata/v1_samples_outputs/simple_router-MidEnd_25_Evaluator.p4 @@ -1,6 +1,109 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct routing_metadata_t { bit<32> nhop_ipv4; } diff --git a/testdata/v1_samples_outputs/simple_router.p4 b/testdata/v1_samples_outputs/simple_router.p4 index 67b4be11726..e3ce3e9a02b 100644 --- a/testdata/v1_samples_outputs/simple_router.p4 +++ b/testdata/v1_samples_outputs/simple_router.p4 @@ -74,7 +74,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t size = 256; default_action = NoAction(); } - apply { send_frame.apply(); } @@ -104,7 +103,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 512; default_action = NoAction(); } - @name("ipv4_lpm") table ipv4_lpm() { actions = { set_nhop; @@ -117,7 +115,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 1024; default_action = NoAction(); } - apply { if (hdr.ipv4.isValid() && hdr.ipv4.ttl > 8w0) { ipv4_lpm.apply(); diff --git a/testdata/v1_samples_outputs/source_routing-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/source_routing-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..bf5d4ab1e7d --- /dev/null +++ b/testdata/v1_samples_outputs/source_routing-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,211 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header easyroute_head_t { + bit<64> preamble; + bit<32> num_valid; +} + +header easyroute_port_t { + bit<8> port; +} + +struct metadata { +} + +struct headers { + @name("easyroute_head") + easyroute_head_t easyroute_head; + @name("easyroute_port") + easyroute_port_t easyroute_port; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_head") state parse_head { + packet.extract(hdr.easyroute_head); + transition select(hdr.easyroute_head.num_valid) { + 32w0: accept; + default: parse_port; + } + } + @name("parse_port") state parse_port { + packet.extract(hdr.easyroute_port); + transition accept; + } + @name("start") state start { + transition select(packet.lookahead>()[63:0]) { + 64w0: parse_head; + default: accept; + } + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("_drop") action _drop() { + mark_to_drop(); + } + @name("route") action route() { + standard_metadata.egress_spec = (bit<9>)hdr.easyroute_port.port; + hdr.easyroute_head.num_valid = hdr.easyroute_head.num_valid + 32w4294967295; + hdr.easyroute_port.setValid(false); + } + @name("route_pkt") table route_pkt() { + actions = { + _drop; + route; + NoAction; + } + key = { + hdr.easyroute_port.isValid(): exact; + } + size = 1; + default_action = NoAction(); + } + apply { + route_pkt.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.easyroute_head); + packet.emit(hdr.easyroute_port); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/source_routing-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/source_routing-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..9e8348d7224 --- /dev/null +++ b/testdata/v1_samples_outputs/source_routing-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,196 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header easyroute_head_t { + bit<64> preamble; + bit<32> num_valid; +} + +header easyroute_port_t { + bit<8> port; +} + +struct metadata { +} + +struct headers { + @name("easyroute_head") + easyroute_head_t easyroute_head; + @name("easyroute_port") + easyroute_port_t easyroute_port; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_head") state parse_head { + packet.extract(hdr.easyroute_head); + transition select(hdr.easyroute_head.num_valid) { + 32w0: accept; + default: parse_port; + } + } + @name("parse_port") state parse_port { + packet.extract(hdr.easyroute_port); + transition accept; + } + @name("start") state start { + transition select(packet.lookahead>()[63:0]) { + 64w0: parse_head; + default: accept; + } + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("_drop") action _drop() { + mark_to_drop(); + } + @name("route") action route() { + standard_metadata.egress_spec = (bit<9>)hdr.easyroute_port.port; + hdr.easyroute_head.num_valid = hdr.easyroute_head.num_valid + 32w4294967295; + hdr.easyroute_port.setValid(false); + } + @name("route_pkt") table route_pkt() { + actions = { + _drop; + route; + NoAction; + } + key = { + hdr.easyroute_port.isValid(): exact; + } + size = 1; + default_action = NoAction(); + } + apply { + route_pkt.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.easyroute_head); + packet.emit(hdr.easyroute_port); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/source_routing-midend.p4 b/testdata/v1_samples_outputs/source_routing-MidEnd_25_Evaluator.p4 similarity index 50% rename from testdata/v1_samples_outputs/source_routing-midend.p4 rename to testdata/v1_samples_outputs/source_routing-MidEnd_25_Evaluator.p4 index 6d9ebe75478..2ac91d49a96 100644 --- a/testdata/v1_samples_outputs/source_routing-midend.p4 +++ b/testdata/v1_samples_outputs/source_routing-MidEnd_25_Evaluator.p4 @@ -1,6 +1,109 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header easyroute_head_t { bit<64> preamble; bit<32> num_valid; diff --git a/testdata/v1_samples_outputs/source_routing-fe.p4 b/testdata/v1_samples_outputs/source_routing-fe.p4 deleted file mode 100644 index 622021127c8..00000000000 --- a/testdata/v1_samples_outputs/source_routing-fe.p4 +++ /dev/null @@ -1,92 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header easyroute_head_t { - bit<64> preamble; - bit<32> num_valid; -} - -header easyroute_port_t { - bit<8> port; -} - -struct metadata { -} - -struct headers { - @name("easyroute_head") - easyroute_head_t easyroute_head; - @name("easyroute_port") - easyroute_port_t easyroute_port; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("parse_head") state parse_head { - packet.extract(hdr.easyroute_head); - transition select(hdr.easyroute_head.num_valid) { - 32w0: accept; - default: parse_port; - } - } - @name("parse_port") state parse_port { - packet.extract(hdr.easyroute_port); - transition accept; - } - @name("start") state start { - transition select(packet.lookahead>()[63:0]) { - 64w0: parse_head; - default: accept; - } - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("_drop") action _drop() { - mark_to_drop(); - } - @name("route") action route() { - standard_metadata.egress_spec = (bit<9>)hdr.easyroute_port.port; - hdr.easyroute_head.num_valid = hdr.easyroute_head.num_valid + 32w4294967295; - hdr.easyroute_port.setValid(false); - } - @name("route_pkt") table route_pkt() { - actions = { - _drop; - route; - NoAction; - } - key = { - hdr.easyroute_port.isValid(): exact; - } - size = 1; - default_action = NoAction(); - } - - apply { - route_pkt.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.easyroute_head); - packet.emit(hdr.easyroute_port); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/source_routing-last.p4 b/testdata/v1_samples_outputs/source_routing-last.p4 deleted file mode 100644 index 622021127c8..00000000000 --- a/testdata/v1_samples_outputs/source_routing-last.p4 +++ /dev/null @@ -1,92 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header easyroute_head_t { - bit<64> preamble; - bit<32> num_valid; -} - -header easyroute_port_t { - bit<8> port; -} - -struct metadata { -} - -struct headers { - @name("easyroute_head") - easyroute_head_t easyroute_head; - @name("easyroute_port") - easyroute_port_t easyroute_port; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("parse_head") state parse_head { - packet.extract(hdr.easyroute_head); - transition select(hdr.easyroute_head.num_valid) { - 32w0: accept; - default: parse_port; - } - } - @name("parse_port") state parse_port { - packet.extract(hdr.easyroute_port); - transition accept; - } - @name("start") state start { - transition select(packet.lookahead>()[63:0]) { - 64w0: parse_head; - default: accept; - } - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("_drop") action _drop() { - mark_to_drop(); - } - @name("route") action route() { - standard_metadata.egress_spec = (bit<9>)hdr.easyroute_port.port; - hdr.easyroute_head.num_valid = hdr.easyroute_head.num_valid + 32w4294967295; - hdr.easyroute_port.setValid(false); - } - @name("route_pkt") table route_pkt() { - actions = { - _drop; - route; - NoAction; - } - key = { - hdr.easyroute_port.isValid(): exact; - } - size = 1; - default_action = NoAction(); - } - - apply { - route_pkt.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.easyroute_head); - packet.emit(hdr.easyroute_port); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/source_routing.p4 b/testdata/v1_samples_outputs/source_routing.p4 index 2bc990e7916..d43faad5eae 100644 --- a/testdata/v1_samples_outputs/source_routing.p4 +++ b/testdata/v1_samples_outputs/source_routing.p4 @@ -66,7 +66,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 1; default_action = NoAction(); } - apply { route_pkt.apply(); } diff --git a/testdata/v1_samples_outputs/swap_1-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/swap_1-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..24849e57a54 --- /dev/null +++ b/testdata/v1_samples_outputs/swap_1-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,189 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr1_t { + bit<8> f1; + bit<8> f2; +} + +struct metadata { +} + +struct headers { + @name("hdr1") + hdr1_t hdr1; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.hdr1); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("a11") action a11() { + standard_metadata.egress_spec = 9w1; + } + @name("a12") action a12() { + standard_metadata.egress_spec = 9w2; + } + @name("t_ingress_1") table t_ingress_1() { + actions = { + a11; + a12; + NoAction; + } + key = { + hdr.hdr1.f1: exact; + } + size = 128; + default_action = NoAction(); + } + apply { + t_ingress_1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.hdr1); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/swap_1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/swap_1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..5f2d7937bdb --- /dev/null +++ b/testdata/v1_samples_outputs/swap_1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,173 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr1_t { + bit<8> f1; + bit<8> f2; +} + +struct metadata { +} + +struct headers { + @name("hdr1") + hdr1_t hdr1; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.hdr1); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("a11") action a11() { + standard_metadata.egress_spec = 9w1; + } + @name("a12") action a12() { + standard_metadata.egress_spec = 9w2; + } + @name("t_ingress_1") table t_ingress_1() { + actions = { + a11; + a12; + NoAction; + } + key = { + hdr.hdr1.f1: exact; + } + size = 128; + default_action = NoAction(); + } + apply { + t_ingress_1.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.hdr1); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/swap_1-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/swap_1-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..b34af79465e --- /dev/null +++ b/testdata/v1_samples_outputs/swap_1-MidEnd_25_Evaluator.p4 @@ -0,0 +1,173 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr1_t { + bit<8> f1; + bit<8> f2; +} + +struct metadata { +} + +struct headers { + @name("hdr1") + hdr1_t hdr1; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.hdr1); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("a11") action a11_0() { + standard_metadata.egress_spec = 9w1; + } + @name("a12") action a12_0() { + standard_metadata.egress_spec = 9w2; + } + @name("t_ingress_1") table t_ingress() { + actions = { + a11_0; + a12_0; + NoAction_0; + } + key = { + hdr.hdr1.f1: exact; + } + size = 128; + default_action = NoAction_0(); + } + apply { + t_ingress.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.hdr1); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/swap_1-fe.p4 b/testdata/v1_samples_outputs/swap_1-fe.p4 deleted file mode 100644 index 16a46f2a7ff..00000000000 --- a/testdata/v1_samples_outputs/swap_1-fe.p4 +++ /dev/null @@ -1,70 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr1_t { - bit<8> f1; - bit<8> f2; -} - -struct metadata { -} - -struct headers { - @name("hdr1") - hdr1_t hdr1; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.hdr1); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("a11") action a11() { - standard_metadata.egress_spec = 9w1; - } - @name("a12") action a12() { - standard_metadata.egress_spec = 9w2; - } - @name("t_ingress_1") table t_ingress_1() { - actions = { - a11; - a12; - NoAction; - } - key = { - hdr.hdr1.f1: exact; - } - size = 128; - default_action = NoAction(); - } - - apply { - t_ingress_1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.hdr1); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/swap_1-last.p4 b/testdata/v1_samples_outputs/swap_1-last.p4 deleted file mode 100644 index 16a46f2a7ff..00000000000 --- a/testdata/v1_samples_outputs/swap_1-last.p4 +++ /dev/null @@ -1,70 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr1_t { - bit<8> f1; - bit<8> f2; -} - -struct metadata { -} - -struct headers { - @name("hdr1") - hdr1_t hdr1; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.hdr1); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("a11") action a11() { - standard_metadata.egress_spec = 9w1; - } - @name("a12") action a12() { - standard_metadata.egress_spec = 9w2; - } - @name("t_ingress_1") table t_ingress_1() { - actions = { - a11; - a12; - NoAction; - } - key = { - hdr.hdr1.f1: exact; - } - size = 128; - default_action = NoAction(); - } - - apply { - t_ingress_1.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.hdr1); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/swap_1-midend.p4 b/testdata/v1_samples_outputs/swap_1-midend.p4 deleted file mode 100644 index 50850b3564f..00000000000 --- a/testdata/v1_samples_outputs/swap_1-midend.p4 +++ /dev/null @@ -1,71 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr1_t { - bit<8> f1; - bit<8> f2; -} - -struct metadata { -} - -struct headers { - @name("hdr1") - hdr1_t hdr1; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.hdr1); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("a11") action a11_0() { - standard_metadata.egress_spec = 9w1; - } - @name("a12") action a12_0() { - standard_metadata.egress_spec = 9w2; - } - @name("t_ingress_1") table t_ingress() { - actions = { - a11_0; - a12_0; - NoAction_0; - } - key = { - hdr.hdr1.f1: exact; - } - size = 128; - default_action = NoAction_0(); - } - apply { - t_ingress.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.hdr1); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/swap_1.p4 b/testdata/v1_samples_outputs/swap_1.p4 index 16a46f2a7ff..3e44d24353f 100644 --- a/testdata/v1_samples_outputs/swap_1.p4 +++ b/testdata/v1_samples_outputs/swap_1.p4 @@ -45,7 +45,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 128; default_action = NoAction(); } - apply { t_ingress_1.apply(); } diff --git a/testdata/v1_samples_outputs/swap_2-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/swap_2-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..e973fbcd58d --- /dev/null +++ b/testdata/v1_samples_outputs/swap_2-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,190 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr2_t { + bit<8> f1; + bit<8> f2; + bit<16> f3; +} + +struct metadata { +} + +struct headers { + @name("hdr2") + hdr2_t hdr2; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.hdr2); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("a21") action a21() { + standard_metadata.egress_spec = 9w3; + } + @name("a22") action a22() { + standard_metadata.egress_spec = 9w4; + } + @name("t_ingress_2") table t_ingress_2() { + actions = { + a21; + a22; + NoAction; + } + key = { + hdr.hdr2.f1: exact; + } + size = 64; + default_action = NoAction(); + } + apply { + t_ingress_2.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.hdr2); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/swap_2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/swap_2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..f4b2aec9eef --- /dev/null +++ b/testdata/v1_samples_outputs/swap_2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,174 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr2_t { + bit<8> f1; + bit<8> f2; + bit<16> f3; +} + +struct metadata { +} + +struct headers { + @name("hdr2") + hdr2_t hdr2; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.hdr2); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("a21") action a21() { + standard_metadata.egress_spec = 9w3; + } + @name("a22") action a22() { + standard_metadata.egress_spec = 9w4; + } + @name("t_ingress_2") table t_ingress_2() { + actions = { + a21; + a22; + NoAction; + } + key = { + hdr.hdr2.f1: exact; + } + size = 64; + default_action = NoAction(); + } + apply { + t_ingress_2.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.hdr2); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/swap_2-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/swap_2-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..0f83287dd88 --- /dev/null +++ b/testdata/v1_samples_outputs/swap_2-MidEnd_25_Evaluator.p4 @@ -0,0 +1,174 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header hdr2_t { + bit<8> f1; + bit<8> f2; + bit<16> f3; +} + +struct metadata { +} + +struct headers { + @name("hdr2") + hdr2_t hdr2; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.hdr2); + transition accept; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("a21") action a21_0() { + standard_metadata.egress_spec = 9w3; + } + @name("a22") action a22_0() { + standard_metadata.egress_spec = 9w4; + } + @name("t_ingress_2") table t_ingress() { + actions = { + a21_0; + a22_0; + NoAction_0; + } + key = { + hdr.hdr2.f1: exact; + } + size = 64; + default_action = NoAction_0(); + } + apply { + t_ingress.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.hdr2); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/swap_2-fe.p4 b/testdata/v1_samples_outputs/swap_2-fe.p4 deleted file mode 100644 index df756d645af..00000000000 --- a/testdata/v1_samples_outputs/swap_2-fe.p4 +++ /dev/null @@ -1,71 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr2_t { - bit<8> f1; - bit<8> f2; - bit<16> f3; -} - -struct metadata { -} - -struct headers { - @name("hdr2") - hdr2_t hdr2; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.hdr2); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("a21") action a21() { - standard_metadata.egress_spec = 9w3; - } - @name("a22") action a22() { - standard_metadata.egress_spec = 9w4; - } - @name("t_ingress_2") table t_ingress_2() { - actions = { - a21; - a22; - NoAction; - } - key = { - hdr.hdr2.f1: exact; - } - size = 64; - default_action = NoAction(); - } - - apply { - t_ingress_2.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.hdr2); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/swap_2-last.p4 b/testdata/v1_samples_outputs/swap_2-last.p4 deleted file mode 100644 index df756d645af..00000000000 --- a/testdata/v1_samples_outputs/swap_2-last.p4 +++ /dev/null @@ -1,71 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr2_t { - bit<8> f1; - bit<8> f2; - bit<16> f3; -} - -struct metadata { -} - -struct headers { - @name("hdr2") - hdr2_t hdr2; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.hdr2); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("a21") action a21() { - standard_metadata.egress_spec = 9w3; - } - @name("a22") action a22() { - standard_metadata.egress_spec = 9w4; - } - @name("t_ingress_2") table t_ingress_2() { - actions = { - a21; - a22; - NoAction; - } - key = { - hdr.hdr2.f1: exact; - } - size = 64; - default_action = NoAction(); - } - - apply { - t_ingress_2.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.hdr2); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/swap_2-midend.p4 b/testdata/v1_samples_outputs/swap_2-midend.p4 deleted file mode 100644 index e3ecdd19e7d..00000000000 --- a/testdata/v1_samples_outputs/swap_2-midend.p4 +++ /dev/null @@ -1,72 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header hdr2_t { - bit<8> f1; - bit<8> f2; - bit<16> f3; -} - -struct metadata { -} - -struct headers { - @name("hdr2") - hdr2_t hdr2; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.hdr2); - transition accept; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("a21") action a21_0() { - standard_metadata.egress_spec = 9w3; - } - @name("a22") action a22_0() { - standard_metadata.egress_spec = 9w4; - } - @name("t_ingress_2") table t_ingress() { - actions = { - a21_0; - a22_0; - NoAction_0; - } - key = { - hdr.hdr2.f1: exact; - } - size = 64; - default_action = NoAction_0(); - } - apply { - t_ingress.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.hdr2); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/swap_2.p4 b/testdata/v1_samples_outputs/swap_2.p4 index df756d645af..deb02b9cf84 100644 --- a/testdata/v1_samples_outputs/swap_2.p4 +++ b/testdata/v1_samples_outputs/swap_2.p4 @@ -46,7 +46,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 64; default_action = NoAction(); } - apply { t_ingress_2.apply(); } diff --git a/testdata/v1_samples_outputs/switch-fe.p4 b/testdata/v1_samples_outputs/switch-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 98% rename from testdata/v1_samples_outputs/switch-fe.p4 rename to testdata/v1_samples_outputs/switch-FrontEnd_11_SimplifyControlFlowE.p4 index 46f50f41f0a..4953b15330b 100644 --- a/testdata/v1_samples_outputs/switch-fe.p4 +++ b/testdata/v1_samples_outputs/switch-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/cdodd/p4c/build/../p4include/core.p4" -#include "/home/cdodd/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct acl_metadata_t { bit<1> acl_deny; bit<1> racl_deny; diff --git a/testdata/v1_samples_outputs/switch-last.p4 b/testdata/v1_samples_outputs/switch-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 98% rename from testdata/v1_samples_outputs/switch-last.p4 rename to testdata/v1_samples_outputs/switch-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index cf1fc95d206..fb1d0e68248 100644 --- a/testdata/v1_samples_outputs/switch-last.p4 +++ b/testdata/v1_samples_outputs/switch-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,119 @@ -#include "/home/cdodd/p4c/build/../p4include/core.p4" -#include "/home/cdodd/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct acl_metadata_t { bit<1> acl_deny; bit<1> racl_deny; diff --git a/testdata/v1_samples_outputs/switch-midend.p4 b/testdata/v1_samples_outputs/switch-MidEnd_25_Evaluator.p4 similarity index 99% rename from testdata/v1_samples_outputs/switch-midend.p4 rename to testdata/v1_samples_outputs/switch-MidEnd_25_Evaluator.p4 index 4e37a01f4e5..32054613725 100644 --- a/testdata/v1_samples_outputs/switch-midend.p4 +++ b/testdata/v1_samples_outputs/switch-MidEnd_25_Evaluator.p4 @@ -1,6 +1,117 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct acl_metadata_t { bit<1> acl_deny; bit<1> racl_deny; diff --git a/testdata/v1_samples_outputs/switch.p4 b/testdata/v1_samples_outputs/switch.p4 index a5eb571ac54..132b2234cdb 100644 --- a/testdata/v1_samples_outputs/switch.p4 +++ b/testdata/v1_samples_outputs/switch.p4 @@ -1,5 +1,5 @@ -#include "/home/cdodd/p4c/build/../p4include/core.p4" -#include "/home/cdodd/p4c/build/../p4include/v1model.p4" +#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" +#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" struct acl_metadata_t { bit<1> acl_deny; diff --git a/testdata/v1_samples_outputs/ternary_match0-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/ternary_match0-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..552c9697279 --- /dev/null +++ b/testdata/v1_samples_outputs/ternary_match0-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,189 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + noop; + NoAction; + } + key = { + hdr.data.f1: ternary; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match0-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/ternary_match0-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..f3a5e684263 --- /dev/null +++ b/testdata/v1_samples_outputs/ternary_match0-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,173 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + noop; + NoAction; + } + key = { + hdr.data.f1: ternary; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match0-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/ternary_match0-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..a26ba95b4ac --- /dev/null +++ b/testdata/v1_samples_outputs/ternary_match0-MidEnd_25_Evaluator.p4 @@ -0,0 +1,173 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("noop") action noop_0() { + } + @name("test1") table test1_0() { + actions = { + noop_0; + NoAction_0; + } + key = { + hdr.data.f1: ternary; + } + default_action = NoAction_0(); + } + apply { + test1_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match0-fe.p4 b/testdata/v1_samples_outputs/ternary_match0-fe.p4 deleted file mode 100644 index 42590067a57..00000000000 --- a/testdata/v1_samples_outputs/ternary_match0-fe.p4 +++ /dev/null @@ -1,70 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - noop; - NoAction; - } - key = { - hdr.data.f1: ternary; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match0-last.p4 b/testdata/v1_samples_outputs/ternary_match0-last.p4 deleted file mode 100644 index 42590067a57..00000000000 --- a/testdata/v1_samples_outputs/ternary_match0-last.p4 +++ /dev/null @@ -1,70 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - noop; - NoAction; - } - key = { - hdr.data.f1: ternary; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match0-midend.p4 b/testdata/v1_samples_outputs/ternary_match0-midend.p4 deleted file mode 100644 index 6cd9e7735d0..00000000000 --- a/testdata/v1_samples_outputs/ternary_match0-midend.p4 +++ /dev/null @@ -1,71 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("noop") action noop_0() { - } - @name("test1") table test1_0() { - actions = { - noop_0; - NoAction_0; - } - key = { - hdr.data.f1: ternary; - } - default_action = NoAction_0(); - } - apply { - test1_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match0.p4 b/testdata/v1_samples_outputs/ternary_match0.p4 index 42590067a57..1058f5720f8 100644 --- a/testdata/v1_samples_outputs/ternary_match0.p4 +++ b/testdata/v1_samples_outputs/ternary_match0.p4 @@ -40,7 +40,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { test1.apply(); } diff --git a/testdata/v1_samples_outputs/ternary_match1-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/ternary_match1-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..e68ed443257 --- /dev/null +++ b/testdata/v1_samples_outputs/ternary_match1-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,193 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<16> h1; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: ternary; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/ternary_match1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..565e3ac15b0 --- /dev/null +++ b/testdata/v1_samples_outputs/ternary_match1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,177 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<16> h1; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: ternary; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match1-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/ternary_match1-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..ffc671a3b86 --- /dev/null +++ b/testdata/v1_samples_outputs/ternary_match1-MidEnd_25_Evaluator.p4 @@ -0,0 +1,177 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<16> h1; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("setb1") action setb1_0(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop_0() { + } + @name("test1") table test1_0() { + actions = { + setb1_0; + noop_0; + NoAction_0; + } + key = { + hdr.data.f1: ternary; + } + default_action = NoAction_0(); + } + apply { + test1_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match1-fe.p4 b/testdata/v1_samples_outputs/ternary_match1-fe.p4 deleted file mode 100644 index 65d8574b309..00000000000 --- a/testdata/v1_samples_outputs/ternary_match1-fe.p4 +++ /dev/null @@ -1,74 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<16> h1; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: ternary; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match1-last.p4 b/testdata/v1_samples_outputs/ternary_match1-last.p4 deleted file mode 100644 index 65d8574b309..00000000000 --- a/testdata/v1_samples_outputs/ternary_match1-last.p4 +++ /dev/null @@ -1,74 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<16> h1; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: ternary; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match1-midend.p4 b/testdata/v1_samples_outputs/ternary_match1-midend.p4 deleted file mode 100644 index e82a23242b7..00000000000 --- a/testdata/v1_samples_outputs/ternary_match1-midend.p4 +++ /dev/null @@ -1,75 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<16> h1; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("setb1") action setb1_0(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop_0() { - } - @name("test1") table test1_0() { - actions = { - setb1_0; - noop_0; - NoAction_0; - } - key = { - hdr.data.f1: ternary; - } - default_action = NoAction_0(); - } - apply { - test1_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match1.p4 b/testdata/v1_samples_outputs/ternary_match1.p4 index 65d8574b309..ed77786dfc5 100644 --- a/testdata/v1_samples_outputs/ternary_match1.p4 +++ b/testdata/v1_samples_outputs/ternary_match1.p4 @@ -44,7 +44,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { test1.apply(); } diff --git a/testdata/v1_samples_outputs/ternary_match2-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/ternary_match2-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..f67aac30fff --- /dev/null +++ b/testdata/v1_samples_outputs/ternary_match2-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,193 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: ternary; + } + size = 10000; + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/ternary_match2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..272d716ea0d --- /dev/null +++ b/testdata/v1_samples_outputs/ternary_match2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,177 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: ternary; + } + size = 10000; + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match2-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/ternary_match2-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..c7d237ad564 --- /dev/null +++ b/testdata/v1_samples_outputs/ternary_match2-MidEnd_25_Evaluator.p4 @@ -0,0 +1,177 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("setb1") action setb1_0(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop_0() { + } + @name("test1") table test1_0() { + actions = { + setb1_0; + noop_0; + NoAction_0; + } + key = { + hdr.data.f1: ternary; + } + size = 10000; + default_action = NoAction_0(); + } + apply { + test1_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match2-fe.p4 b/testdata/v1_samples_outputs/ternary_match2-fe.p4 deleted file mode 100644 index 7a2acd1d081..00000000000 --- a/testdata/v1_samples_outputs/ternary_match2-fe.p4 +++ /dev/null @@ -1,74 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: ternary; - } - size = 10000; - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match2-last.p4 b/testdata/v1_samples_outputs/ternary_match2-last.p4 deleted file mode 100644 index 7a2acd1d081..00000000000 --- a/testdata/v1_samples_outputs/ternary_match2-last.p4 +++ /dev/null @@ -1,74 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: ternary; - } - size = 10000; - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match2-midend.p4 b/testdata/v1_samples_outputs/ternary_match2-midend.p4 deleted file mode 100644 index 0d881adacf2..00000000000 --- a/testdata/v1_samples_outputs/ternary_match2-midend.p4 +++ /dev/null @@ -1,75 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("setb1") action setb1_0(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop_0() { - } - @name("test1") table test1_0() { - actions = { - setb1_0; - noop_0; - NoAction_0; - } - key = { - hdr.data.f1: ternary; - } - size = 10000; - default_action = NoAction_0(); - } - apply { - test1_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match2.p4 b/testdata/v1_samples_outputs/ternary_match2.p4 index 7a2acd1d081..ae0bf257239 100644 --- a/testdata/v1_samples_outputs/ternary_match2.p4 +++ b/testdata/v1_samples_outputs/ternary_match2.p4 @@ -44,7 +44,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 10000; default_action = NoAction(); } - apply { test1.apply(); } diff --git a/testdata/v1_samples_outputs/ternary_match3-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/ternary_match3-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..c2b81952b45 --- /dev/null +++ b/testdata/v1_samples_outputs/ternary_match3-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,195 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: ternary; + hdr.data.f2: ternary; + hdr.data.f3: ternary; + hdr.data.f4: ternary; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/ternary_match3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..695e45609dc --- /dev/null +++ b/testdata/v1_samples_outputs/ternary_match3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,179 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: ternary; + hdr.data.f2: ternary; + hdr.data.f3: ternary; + hdr.data.f4: ternary; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match3-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/ternary_match3-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..67e5ecbed91 --- /dev/null +++ b/testdata/v1_samples_outputs/ternary_match3-MidEnd_25_Evaluator.p4 @@ -0,0 +1,179 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("setb1") action setb1_0(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop_0() { + } + @name("test1") table test1_0() { + actions = { + setb1_0; + noop_0; + NoAction_0; + } + key = { + hdr.data.f1: ternary; + hdr.data.f2: ternary; + hdr.data.f3: ternary; + hdr.data.f4: ternary; + } + default_action = NoAction_0(); + } + apply { + test1_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match3-fe.p4 b/testdata/v1_samples_outputs/ternary_match3-fe.p4 deleted file mode 100644 index e19a3f112d1..00000000000 --- a/testdata/v1_samples_outputs/ternary_match3-fe.p4 +++ /dev/null @@ -1,76 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: ternary; - hdr.data.f2: ternary; - hdr.data.f3: ternary; - hdr.data.f4: ternary; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match3-last.p4 b/testdata/v1_samples_outputs/ternary_match3-last.p4 deleted file mode 100644 index e19a3f112d1..00000000000 --- a/testdata/v1_samples_outputs/ternary_match3-last.p4 +++ /dev/null @@ -1,76 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: ternary; - hdr.data.f2: ternary; - hdr.data.f3: ternary; - hdr.data.f4: ternary; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match3-midend.p4 b/testdata/v1_samples_outputs/ternary_match3-midend.p4 deleted file mode 100644 index 38a326acf70..00000000000 --- a/testdata/v1_samples_outputs/ternary_match3-midend.p4 +++ /dev/null @@ -1,77 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("setb1") action setb1_0(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop_0() { - } - @name("test1") table test1_0() { - actions = { - setb1_0; - noop_0; - NoAction_0; - } - key = { - hdr.data.f1: ternary; - hdr.data.f2: ternary; - hdr.data.f3: ternary; - hdr.data.f4: ternary; - } - default_action = NoAction_0(); - } - apply { - test1_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match3.p4 b/testdata/v1_samples_outputs/ternary_match3.p4 index e19a3f112d1..ca9cde67ba7 100644 --- a/testdata/v1_samples_outputs/ternary_match3.p4 +++ b/testdata/v1_samples_outputs/ternary_match3.p4 @@ -46,7 +46,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { test1.apply(); } diff --git a/testdata/v1_samples_outputs/ternary_match4-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/ternary_match4-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..bb3a17232fc --- /dev/null +++ b/testdata/v1_samples_outputs/ternary_match4-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,196 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: ternary; + hdr.data.f2: ternary; + hdr.data.f3: ternary; + hdr.data.f4: ternary; + } + size = 10000; + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/ternary_match4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..8176f69ca4d --- /dev/null +++ b/testdata/v1_samples_outputs/ternary_match4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,180 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop() { + } + @name("test1") table test1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: ternary; + hdr.data.f2: ternary; + hdr.data.f3: ternary; + hdr.data.f4: ternary; + } + size = 10000; + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match4-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/ternary_match4-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..4e5edc96172 --- /dev/null +++ b/testdata/v1_samples_outputs/ternary_match4-MidEnd_25_Evaluator.p4 @@ -0,0 +1,180 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("setb1") action setb1_0(bit<8> val, bit<9> port) { + hdr.data.b1 = val; + standard_metadata.egress_spec = port; + } + @name("noop") action noop_0() { + } + @name("test1") table test1_0() { + actions = { + setb1_0; + noop_0; + NoAction_0; + } + key = { + hdr.data.f1: ternary; + hdr.data.f2: ternary; + hdr.data.f3: ternary; + hdr.data.f4: ternary; + } + size = 10000; + default_action = NoAction_0(); + } + apply { + test1_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match4-fe.p4 b/testdata/v1_samples_outputs/ternary_match4-fe.p4 deleted file mode 100644 index febbbf737a7..00000000000 --- a/testdata/v1_samples_outputs/ternary_match4-fe.p4 +++ /dev/null @@ -1,77 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: ternary; - hdr.data.f2: ternary; - hdr.data.f3: ternary; - hdr.data.f4: ternary; - } - size = 10000; - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match4-last.p4 b/testdata/v1_samples_outputs/ternary_match4-last.p4 deleted file mode 100644 index febbbf737a7..00000000000 --- a/testdata/v1_samples_outputs/ternary_match4-last.p4 +++ /dev/null @@ -1,77 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop() { - } - @name("test1") table test1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: ternary; - hdr.data.f2: ternary; - hdr.data.f3: ternary; - hdr.data.f4: ternary; - } - size = 10000; - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match4-midend.p4 b/testdata/v1_samples_outputs/ternary_match4-midend.p4 deleted file mode 100644 index 83967d8d195..00000000000 --- a/testdata/v1_samples_outputs/ternary_match4-midend.p4 +++ /dev/null @@ -1,78 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("setb1") action setb1_0(bit<8> val, bit<9> port) { - hdr.data.b1 = val; - standard_metadata.egress_spec = port; - } - @name("noop") action noop_0() { - } - @name("test1") table test1_0() { - actions = { - setb1_0; - noop_0; - NoAction_0; - } - key = { - hdr.data.f1: ternary; - hdr.data.f2: ternary; - hdr.data.f3: ternary; - hdr.data.f4: ternary; - } - size = 10000; - default_action = NoAction_0(); - } - apply { - test1_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/ternary_match4.p4 b/testdata/v1_samples_outputs/ternary_match4.p4 index febbbf737a7..e270b34a28c 100644 --- a/testdata/v1_samples_outputs/ternary_match4.p4 +++ b/testdata/v1_samples_outputs/ternary_match4.p4 @@ -47,7 +47,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 10000; default_action = NoAction(); } - apply { test1.apply(); } diff --git a/testdata/v1_samples_outputs/test_7_storm_control-last.p4 b/testdata/v1_samples_outputs/test_7_storm_control-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 55% rename from testdata/v1_samples_outputs/test_7_storm_control-last.p4 rename to testdata/v1_samples_outputs/test_7_storm_control-FrontEnd_11_SimplifyControlFlowE.p4 index e23ff3e6ba1..55734f9726a 100644 --- a/testdata/v1_samples_outputs/test_7_storm_control-last.p4 +++ b/testdata/v1_samples_outputs/test_7_storm_control-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<16> bd; bit<12> vrf; @@ -121,7 +241,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 8192; default_action = NoAction(); } - apply { storm_control.apply(); } diff --git a/testdata/v1_samples_outputs/test_7_storm_control-fe.p4 b/testdata/v1_samples_outputs/test_7_storm_control-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 60% rename from testdata/v1_samples_outputs/test_7_storm_control-fe.p4 rename to testdata/v1_samples_outputs/test_7_storm_control-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index e23ff3e6ba1..9d1ea604fde 100644 --- a/testdata/v1_samples_outputs/test_7_storm_control-fe.p4 +++ b/testdata/v1_samples_outputs/test_7_storm_control-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<16> bd; bit<12> vrf; @@ -121,7 +225,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 8192; default_action = NoAction(); } - apply { storm_control.apply(); } diff --git a/testdata/v1_samples_outputs/test_7_storm_control-midend.p4 b/testdata/v1_samples_outputs/test_7_storm_control-MidEnd_25_Evaluator.p4 similarity index 61% rename from testdata/v1_samples_outputs/test_7_storm_control-midend.p4 rename to testdata/v1_samples_outputs/test_7_storm_control-MidEnd_25_Evaluator.p4 index ba8cf0da39f..443f24904a0 100644 --- a/testdata/v1_samples_outputs/test_7_storm_control-midend.p4 +++ b/testdata/v1_samples_outputs/test_7_storm_control-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<16> bd; bit<12> vrf; diff --git a/testdata/v1_samples_outputs/test_7_storm_control.p4 b/testdata/v1_samples_outputs/test_7_storm_control.p4 index f22f32924c8..a96882b302d 100644 --- a/testdata/v1_samples_outputs/test_7_storm_control.p4 +++ b/testdata/v1_samples_outputs/test_7_storm_control.p4 @@ -122,7 +122,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 8192; default_action = NoAction(); } - apply { storm_control.apply(); } diff --git a/testdata/v1_samples_outputs/test_config_175_match_table_with_no_key-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/test_config_175_match_table_with_no_key-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..c803429390f --- /dev/null +++ b/testdata/v1_samples_outputs/test_config_175_match_table_with_no_key-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,217 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header pkt_t { + bit<32> field_a_32; + int<32> field_b_32; + bit<32> field_c_32; + bit<32> field_d_32; + bit<16> field_e_16; + bit<16> field_f_16; + bit<16> field_g_16; + bit<16> field_h_16; + bit<8> field_i_8; + bit<8> field_j_8; + bit<8> field_k_8; + bit<8> field_l_8; + int<32> field_x_32; +} + +struct metadata { +} + +struct headers { + @name("pkt") + pkt_t pkt; +} + +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.pkt); + transition accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("action_0") action action_0() { + hdr.pkt.field_a_32 = (bit<32>)~(hdr.pkt.field_b_32 | (int<32>)hdr.pkt.field_c_32); + } + @name("action_1") action action_1(int<32> param0) { + hdr.pkt.field_b_32 = ~param0 | (int<32>)hdr.pkt.field_c_32; + } + @name("do_nothing") action do_nothing() { + } + @name("table_0") table table_0() { + actions = { + action_0; + NoAction; + } + default_action = NoAction(); + } + @name("table_1") table table_1() { + actions = { + action_1; + NoAction; + } + default_action = NoAction(); + } + @name("table_2") table table_2() { + actions = { + do_nothing; + NoAction; + } + default_action = NoAction(); + } + apply { + table_0.apply(); + table_1.apply(); + if (hdr.pkt.field_i_8 == 8w0) + table_2.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.pkt); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/test_config_175_match_table_with_no_key-fe.p4 b/testdata/v1_samples_outputs/test_config_175_match_table_with_no_key-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 50% rename from testdata/v1_samples_outputs/test_config_175_match_table_with_no_key-fe.p4 rename to testdata/v1_samples_outputs/test_config_175_match_table_with_no_key-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 1d38f5f4aa6..2c1d4428239 100644 --- a/testdata/v1_samples_outputs/test_config_175_match_table_with_no_key-fe.p4 +++ b/testdata/v1_samples_outputs/test_config_175_match_table_with_no_key-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header pkt_t { bit<32> field_a_32; int<32> field_b_32; @@ -51,7 +155,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("table_1") table table_1() { actions = { action_1; @@ -59,7 +162,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("table_2") table table_2() { actions = { do_nothing; @@ -67,7 +169,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { table_0.apply(); table_1.apply(); diff --git a/testdata/v1_samples_outputs/test_config_175_match_table_with_no_key-midend.p4 b/testdata/v1_samples_outputs/test_config_175_match_table_with_no_key-MidEnd_25_Evaluator.p4 similarity index 51% rename from testdata/v1_samples_outputs/test_config_175_match_table_with_no_key-midend.p4 rename to testdata/v1_samples_outputs/test_config_175_match_table_with_no_key-MidEnd_25_Evaluator.p4 index f3bcb98013b..8e115371584 100644 --- a/testdata/v1_samples_outputs/test_config_175_match_table_with_no_key-midend.p4 +++ b/testdata/v1_samples_outputs/test_config_175_match_table_with_no_key-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header pkt_t { bit<32> field_a_32; int<32> field_b_32; diff --git a/testdata/v1_samples_outputs/test_config_175_match_table_with_no_key-last.p4 b/testdata/v1_samples_outputs/test_config_175_match_table_with_no_key-last.p4 deleted file mode 100644 index 1d38f5f4aa6..00000000000 --- a/testdata/v1_samples_outputs/test_config_175_match_table_with_no_key-last.p4 +++ /dev/null @@ -1,100 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header pkt_t { - bit<32> field_a_32; - int<32> field_b_32; - bit<32> field_c_32; - bit<32> field_d_32; - bit<16> field_e_16; - bit<16> field_f_16; - bit<16> field_g_16; - bit<16> field_h_16; - bit<8> field_i_8; - bit<8> field_j_8; - bit<8> field_k_8; - bit<8> field_l_8; - int<32> field_x_32; -} - -struct metadata { -} - -struct headers { - @name("pkt") - pkt_t pkt; -} - -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.pkt); - transition accept; - } - @name("start") state start { - transition parse_ethernet; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("action_0") action action_0() { - hdr.pkt.field_a_32 = (bit<32>)~(hdr.pkt.field_b_32 | (int<32>)hdr.pkt.field_c_32); - } - @name("action_1") action action_1(int<32> param0) { - hdr.pkt.field_b_32 = ~param0 | (int<32>)hdr.pkt.field_c_32; - } - @name("do_nothing") action do_nothing() { - } - @name("table_0") table table_0() { - actions = { - action_0; - NoAction; - } - default_action = NoAction(); - } - - @name("table_1") table table_1() { - actions = { - action_1; - NoAction; - } - default_action = NoAction(); - } - - @name("table_2") table table_2() { - actions = { - do_nothing; - NoAction; - } - default_action = NoAction(); - } - - apply { - table_0.apply(); - table_1.apply(); - if (hdr.pkt.field_i_8 == 8w0) - table_2.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.pkt); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/test_config_175_match_table_with_no_key.p4 b/testdata/v1_samples_outputs/test_config_175_match_table_with_no_key.p4 index a03f1e1ebe7..d21350e3c8b 100644 --- a/testdata/v1_samples_outputs/test_config_175_match_table_with_no_key.p4 +++ b/testdata/v1_samples_outputs/test_config_175_match_table_with_no_key.p4 @@ -51,7 +51,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("table_1") table table_1() { actions = { action_1; @@ -59,7 +58,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("table_2") table table_2() { actions = { do_nothing; @@ -67,7 +65,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { table_0.apply(); table_1.apply(); diff --git a/testdata/v1_samples_outputs/testgw-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/testgw-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..a75d0a899f0 --- /dev/null +++ b/testdata/v1_samples_outputs/testgw-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,239 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<16> f3; + bit<16> f4; + bit<8> f5; + bit<8> f6; + bit<4> f7; + bit<4> f8; +} + +header ethernet_t { + bit<48> dst_addr; + bit<48> src_addr; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; + @name("ethernet") + ethernet_t ethernet; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("data") state data { + packet.extract(hdr.data); + transition accept; + } + @name("start") state start { + packet.extract(hdr.ethernet); + transition data; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("route_eth") action route_eth(bit<9> egress_spec, bit<48> src_addr) { + standard_metadata.egress_spec = egress_spec; + hdr.ethernet.src_addr = src_addr; + } + @name("noop") action noop() { + } + @name("setf2") action setf2(bit<32> val) { + hdr.data.f2 = val; + } + @name("setf1") action setf1(bit<32> val) { + hdr.data.f1 = val; + } + @name("routing") table routing() { + actions = { + route_eth; + noop; + NoAction; + } + key = { + hdr.ethernet.dst_addr: lpm; + } + default_action = NoAction(); + } + @name("test1") table test1() { + actions = { + setf2; + noop; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + @name("test2") table test2() { + actions = { + setf1; + noop; + NoAction; + } + key = { + hdr.data.f2: exact; + } + default_action = NoAction(); + } + apply { + routing.apply(); + if (hdr.data.f5 != hdr.data.f6) + test1.apply(); + else + test2.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/testgw-fe.p4 b/testdata/v1_samples_outputs/testgw-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 53% rename from testdata/v1_samples_outputs/testgw-fe.p4 rename to testdata/v1_samples_outputs/testgw-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 706429f8552..83a82cfda68 100644 --- a/testdata/v1_samples_outputs/testgw-fe.p4 +++ b/testdata/v1_samples_outputs/testgw-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header data_t { bit<32> f1; bit<32> f2; @@ -68,7 +172,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("test1") table test1() { actions = { setf2; @@ -80,7 +183,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("test2") table test2() { actions = { setf1; @@ -92,7 +194,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { routing.apply(); if (hdr.data.f5 != hdr.data.f6) diff --git a/testdata/v1_samples_outputs/testgw-midend.p4 b/testdata/v1_samples_outputs/testgw-MidEnd_25_Evaluator.p4 similarity index 55% rename from testdata/v1_samples_outputs/testgw-midend.p4 rename to testdata/v1_samples_outputs/testgw-MidEnd_25_Evaluator.p4 index d967951611f..92c654f70ed 100644 --- a/testdata/v1_samples_outputs/testgw-midend.p4 +++ b/testdata/v1_samples_outputs/testgw-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header data_t { bit<32> f1; bit<32> f2; diff --git a/testdata/v1_samples_outputs/testgw-last.p4 b/testdata/v1_samples_outputs/testgw-last.p4 deleted file mode 100644 index 706429f8552..00000000000 --- a/testdata/v1_samples_outputs/testgw-last.p4 +++ /dev/null @@ -1,122 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<16> f3; - bit<16> f4; - bit<8> f5; - bit<8> f6; - bit<4> f7; - bit<4> f8; -} - -header ethernet_t { - bit<48> dst_addr; - bit<48> src_addr; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; - @name("ethernet") - ethernet_t ethernet; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("data") state data { - packet.extract(hdr.data); - transition accept; - } - @name("start") state start { - packet.extract(hdr.ethernet); - transition data; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("route_eth") action route_eth(bit<9> egress_spec, bit<48> src_addr) { - standard_metadata.egress_spec = egress_spec; - hdr.ethernet.src_addr = src_addr; - } - @name("noop") action noop() { - } - @name("setf2") action setf2(bit<32> val) { - hdr.data.f2 = val; - } - @name("setf1") action setf1(bit<32> val) { - hdr.data.f1 = val; - } - @name("routing") table routing() { - actions = { - route_eth; - noop; - NoAction; - } - key = { - hdr.ethernet.dst_addr: lpm; - } - default_action = NoAction(); - } - - @name("test1") table test1() { - actions = { - setf2; - noop; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - @name("test2") table test2() { - actions = { - setf1; - noop; - NoAction; - } - key = { - hdr.data.f2: exact; - } - default_action = NoAction(); - } - - apply { - routing.apply(); - if (hdr.data.f5 != hdr.data.f6) - test1.apply(); - else - test2.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/testgw.p4 b/testdata/v1_samples_outputs/testgw.p4 index acecec0c62a..30508a2e528 100644 --- a/testdata/v1_samples_outputs/testgw.p4 +++ b/testdata/v1_samples_outputs/testgw.p4 @@ -68,7 +68,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("test1") table test1() { actions = { setf2; @@ -80,7 +79,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("test2") table test2() { actions = { setf1; @@ -92,7 +90,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { routing.apply(); if (hdr.data.f5 != hdr.data.f6) { diff --git a/testdata/v1_samples_outputs/tp2a-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/tp2a-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..fb13649b9e6 --- /dev/null +++ b/testdata/v1_samples_outputs/tp2a-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,240 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<32> b1; + bit<32> b2; + bit<32> b3; + bit<32> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<32> val) { + hdr.data.b1 = val; + } + @name("noop") action noop() { + } + @name("setb3") action setb3(bit<32> val) { + hdr.data.b3 = val; + } + @name("setb2") action setb2(bit<32> val) { + hdr.data.b2 = val; + } + @name("setb4") action setb4(bit<32> val) { + hdr.data.b4 = val; + } + @name("A1") table A1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: ternary; + } + default_action = NoAction(); + } + @name("A2") table A2() { + actions = { + setb3; + noop; + NoAction; + } + key = { + hdr.data.b1: ternary; + } + default_action = NoAction(); + } + @name("B1") table B1() { + actions = { + setb2; + noop; + NoAction; + } + key = { + hdr.data.f2: ternary; + } + default_action = NoAction(); + } + @name("B2") table B2() { + actions = { + setb4; + noop; + NoAction; + } + key = { + hdr.data.b2: ternary; + } + default_action = NoAction(); + } + apply { + if (hdr.data.b1 == 32w0) { + A1.apply(); + A2.apply(); + } + B1.apply(); + B2.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/tp2a-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/tp2a-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..6fd5a5b7b49 --- /dev/null +++ b/testdata/v1_samples_outputs/tp2a-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,224 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<32> b1; + bit<32> b2; + bit<32> b3; + bit<32> b4; +} + +struct metadata { +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setb1") action setb1(bit<32> val) { + hdr.data.b1 = val; + } + @name("noop") action noop() { + } + @name("setb3") action setb3(bit<32> val) { + hdr.data.b3 = val; + } + @name("setb2") action setb2(bit<32> val) { + hdr.data.b2 = val; + } + @name("setb4") action setb4(bit<32> val) { + hdr.data.b4 = val; + } + @name("A1") table A1() { + actions = { + setb1; + noop; + NoAction; + } + key = { + hdr.data.f1: ternary; + } + default_action = NoAction(); + } + @name("A2") table A2() { + actions = { + setb3; + noop; + NoAction; + } + key = { + hdr.data.b1: ternary; + } + default_action = NoAction(); + } + @name("B1") table B1() { + actions = { + setb2; + noop; + NoAction; + } + key = { + hdr.data.f2: ternary; + } + default_action = NoAction(); + } + @name("B2") table B2() { + actions = { + setb4; + noop; + NoAction; + } + key = { + hdr.data.b2: ternary; + } + default_action = NoAction(); + } + apply { + if (hdr.data.b1 == 32w0) { + A1.apply(); + A2.apply(); + } + B1.apply(); + B2.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/tp2a-midend.p4 b/testdata/v1_samples_outputs/tp2a-MidEnd_25_Evaluator.p4 similarity index 55% rename from testdata/v1_samples_outputs/tp2a-midend.p4 rename to testdata/v1_samples_outputs/tp2a-MidEnd_25_Evaluator.p4 index ec82aeb71fd..2d2fcc01cf9 100644 --- a/testdata/v1_samples_outputs/tp2a-midend.p4 +++ b/testdata/v1_samples_outputs/tp2a-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header data_t { bit<32> f1; bit<32> f2; diff --git a/testdata/v1_samples_outputs/tp2a-fe.p4 b/testdata/v1_samples_outputs/tp2a-fe.p4 deleted file mode 100644 index cd10531d5a4..00000000000 --- a/testdata/v1_samples_outputs/tp2a-fe.p4 +++ /dev/null @@ -1,124 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<32> b1; - bit<32> b2; - bit<32> b3; - bit<32> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<32> val) { - hdr.data.b1 = val; - } - @name("noop") action noop() { - } - @name("setb3") action setb3(bit<32> val) { - hdr.data.b3 = val; - } - @name("setb2") action setb2(bit<32> val) { - hdr.data.b2 = val; - } - @name("setb4") action setb4(bit<32> val) { - hdr.data.b4 = val; - } - @name("A1") table A1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: ternary; - } - default_action = NoAction(); - } - - @name("A2") table A2() { - actions = { - setb3; - noop; - NoAction; - } - key = { - hdr.data.b1: ternary; - } - default_action = NoAction(); - } - - @name("B1") table B1() { - actions = { - setb2; - noop; - NoAction; - } - key = { - hdr.data.f2: ternary; - } - default_action = NoAction(); - } - - @name("B2") table B2() { - actions = { - setb4; - noop; - NoAction; - } - key = { - hdr.data.b2: ternary; - } - default_action = NoAction(); - } - - apply { - if (hdr.data.b1 == 32w0) { - A1.apply(); - A2.apply(); - } - B1.apply(); - B2.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/tp2a-last.p4 b/testdata/v1_samples_outputs/tp2a-last.p4 deleted file mode 100644 index cd10531d5a4..00000000000 --- a/testdata/v1_samples_outputs/tp2a-last.p4 +++ /dev/null @@ -1,124 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<32> b1; - bit<32> b2; - bit<32> b3; - bit<32> b4; -} - -struct metadata { -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setb1") action setb1(bit<32> val) { - hdr.data.b1 = val; - } - @name("noop") action noop() { - } - @name("setb3") action setb3(bit<32> val) { - hdr.data.b3 = val; - } - @name("setb2") action setb2(bit<32> val) { - hdr.data.b2 = val; - } - @name("setb4") action setb4(bit<32> val) { - hdr.data.b4 = val; - } - @name("A1") table A1() { - actions = { - setb1; - noop; - NoAction; - } - key = { - hdr.data.f1: ternary; - } - default_action = NoAction(); - } - - @name("A2") table A2() { - actions = { - setb3; - noop; - NoAction; - } - key = { - hdr.data.b1: ternary; - } - default_action = NoAction(); - } - - @name("B1") table B1() { - actions = { - setb2; - noop; - NoAction; - } - key = { - hdr.data.f2: ternary; - } - default_action = NoAction(); - } - - @name("B2") table B2() { - actions = { - setb4; - noop; - NoAction; - } - key = { - hdr.data.b2: ternary; - } - default_action = NoAction(); - } - - apply { - if (hdr.data.b1 == 32w0) { - A1.apply(); - A2.apply(); - } - B1.apply(); - B2.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/tp2a.p4 b/testdata/v1_samples_outputs/tp2a.p4 index cd10531d5a4..2f59ce90bb7 100644 --- a/testdata/v1_samples_outputs/tp2a.p4 +++ b/testdata/v1_samples_outputs/tp2a.p4 @@ -53,7 +53,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("A2") table A2() { actions = { setb3; @@ -65,7 +64,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("B1") table B1() { actions = { setb2; @@ -77,7 +75,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("B2") table B2() { actions = { setb4; @@ -89,7 +86,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (hdr.data.b1 == 32w0) { A1.apply(); diff --git a/testdata/v1_samples_outputs/tp2b-last.p4 b/testdata/v1_samples_outputs/tp2b-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 55% rename from testdata/v1_samples_outputs/tp2b-last.p4 rename to testdata/v1_samples_outputs/tp2b-FrontEnd_11_SimplifyControlFlowE.p4 index a4205749bbb..9044b91ee71 100644 --- a/testdata/v1_samples_outputs/tp2b-last.p4 +++ b/testdata/v1_samples_outputs/tp2b-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header data_t { bit<32> f1; bit<32> f2; @@ -50,7 +170,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - @name("EA") table EA() { actions = { setb1; @@ -62,7 +181,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - @name("EB") table EB() { actions = { setb2; @@ -74,7 +192,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { E1.apply(); if (hdr.data.f1 == 32w0) @@ -110,7 +227,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("A2") table A2() { actions = { setb3; @@ -122,7 +238,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("B1") table B1() { actions = { setb2; @@ -134,7 +249,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("B2") table B2() { actions = { setb4; @@ -146,7 +260,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (hdr.data.b1 == 32w0) { A1.apply(); diff --git a/testdata/v1_samples_outputs/tp2b-fe.p4 b/testdata/v1_samples_outputs/tp2b-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 61% rename from testdata/v1_samples_outputs/tp2b-fe.p4 rename to testdata/v1_samples_outputs/tp2b-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index a4205749bbb..6636c59cba3 100644 --- a/testdata/v1_samples_outputs/tp2b-fe.p4 +++ b/testdata/v1_samples_outputs/tp2b-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header data_t { bit<32> f1; bit<32> f2; @@ -50,7 +154,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - @name("EA") table EA() { actions = { setb1; @@ -62,7 +165,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - @name("EB") table EB() { actions = { setb2; @@ -74,7 +176,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { E1.apply(); if (hdr.data.f1 == 32w0) @@ -110,7 +211,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("A2") table A2() { actions = { setb3; @@ -122,7 +222,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("B1") table B1() { actions = { setb2; @@ -134,7 +233,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("B2") table B2() { actions = { setb4; @@ -146,7 +244,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (hdr.data.b1 == 32w0) { A1.apply(); diff --git a/testdata/v1_samples_outputs/tp2b-midend.p4 b/testdata/v1_samples_outputs/tp2b-MidEnd_25_Evaluator.p4 similarity index 64% rename from testdata/v1_samples_outputs/tp2b-midend.p4 rename to testdata/v1_samples_outputs/tp2b-MidEnd_25_Evaluator.p4 index e112d946e9e..896b993725f 100644 --- a/testdata/v1_samples_outputs/tp2b-midend.p4 +++ b/testdata/v1_samples_outputs/tp2b-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header data_t { bit<32> f1; bit<32> f2; diff --git a/testdata/v1_samples_outputs/tp2b.p4 b/testdata/v1_samples_outputs/tp2b.p4 index a1f522c296e..f5b89414ed2 100644 --- a/testdata/v1_samples_outputs/tp2b.p4 +++ b/testdata/v1_samples_outputs/tp2b.p4 @@ -50,7 +50,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - @name("EA") table EA() { actions = { setb1; @@ -62,7 +61,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - @name("EB") table EB() { actions = { setb2; @@ -74,7 +72,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { E1.apply(); if (hdr.data.f1 == 32w0) { @@ -112,7 +109,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("A2") table A2() { actions = { setb3; @@ -124,7 +120,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("B1") table B1() { actions = { setb2; @@ -136,7 +131,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("B2") table B2() { actions = { setb4; @@ -148,7 +142,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (hdr.data.b1 == 32w0) { A1.apply(); diff --git a/testdata/v1_samples_outputs/tp2c-last.p4 b/testdata/v1_samples_outputs/tp2c-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 52% rename from testdata/v1_samples_outputs/tp2c-last.p4 rename to testdata/v1_samples_outputs/tp2c-FrontEnd_11_SimplifyControlFlowE.p4 index 5444c9e6753..1f709433669 100644 --- a/testdata/v1_samples_outputs/tp2c-last.p4 +++ b/testdata/v1_samples_outputs/tp2c-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header data_t { bit<32> f1; bit<32> f2; @@ -57,7 +177,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("A2") table A2() { actions = { setb3; @@ -69,7 +188,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("A3") table A3() { actions = { on_hit; @@ -81,7 +199,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("A4") table A4() { actions = { on_hit; @@ -93,7 +210,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("B1") table B1() { actions = { setb2; @@ -105,7 +221,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("B2") table B2() { actions = { setb4; @@ -117,7 +232,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (hdr.data.b1 == 32w0) { A1.apply(); diff --git a/testdata/v1_samples_outputs/tp2c-fe.p4 b/testdata/v1_samples_outputs/tp2c-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 58% rename from testdata/v1_samples_outputs/tp2c-fe.p4 rename to testdata/v1_samples_outputs/tp2c-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 5444c9e6753..3524cb6b51f 100644 --- a/testdata/v1_samples_outputs/tp2c-fe.p4 +++ b/testdata/v1_samples_outputs/tp2c-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header data_t { bit<32> f1; bit<32> f2; @@ -57,7 +161,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("A2") table A2() { actions = { setb3; @@ -69,7 +172,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("A3") table A3() { actions = { on_hit; @@ -81,7 +183,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("A4") table A4() { actions = { on_hit; @@ -93,7 +194,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("B1") table B1() { actions = { setb2; @@ -105,7 +205,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("B2") table B2() { actions = { setb4; @@ -117,7 +216,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (hdr.data.b1 == 32w0) { A1.apply(); diff --git a/testdata/v1_samples_outputs/tp2c-midend.p4 b/testdata/v1_samples_outputs/tp2c-MidEnd_25_Evaluator.p4 similarity index 62% rename from testdata/v1_samples_outputs/tp2c-midend.p4 rename to testdata/v1_samples_outputs/tp2c-MidEnd_25_Evaluator.p4 index 9c3f6400ccc..f59e239a781 100644 --- a/testdata/v1_samples_outputs/tp2c-midend.p4 +++ b/testdata/v1_samples_outputs/tp2c-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header data_t { bit<32> f1; bit<32> f2; diff --git a/testdata/v1_samples_outputs/tp2c.p4 b/testdata/v1_samples_outputs/tp2c.p4 index 5963e3525fc..cca85f3d8a1 100644 --- a/testdata/v1_samples_outputs/tp2c.p4 +++ b/testdata/v1_samples_outputs/tp2c.p4 @@ -57,7 +57,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("A2") table A2() { actions = { setb3; @@ -69,7 +68,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("A3") table A3() { actions = { on_hit; @@ -81,7 +79,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("A4") table A4() { actions = { on_hit; @@ -93,7 +90,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("B1") table B1() { actions = { setb2; @@ -105,7 +101,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("B2") table B2() { actions = { setb4; @@ -117,7 +112,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (hdr.data.b1 == 32w0) { A1.apply(); diff --git a/testdata/v1_samples_outputs/tp3a-last.p4 b/testdata/v1_samples_outputs/tp3a-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 58% rename from testdata/v1_samples_outputs/tp3a-last.p4 rename to testdata/v1_samples_outputs/tp3a-FrontEnd_11_SimplifyControlFlowE.p4 index bb280e61912..01c5a22e0fa 100644 --- a/testdata/v1_samples_outputs/tp3a-last.p4 +++ b/testdata/v1_samples_outputs/tp3a-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header data_t { bit<32> f1; bit<32> f2; @@ -50,7 +170,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - @name("E2") table E2() { actions = { setb4; @@ -62,7 +181,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - @name("EA") table EA() { actions = { setb1; @@ -74,7 +192,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - @name("EB") table EB() { actions = { setb1; @@ -86,7 +203,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { E1.apply(); if (hdr.data.f1 == 32w0) @@ -123,7 +239,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("A2") table A2() { actions = { setb3; @@ -135,7 +250,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("A3") table A3() { actions = { setb1; @@ -147,7 +261,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("B1") table B1() { actions = { setb2; @@ -159,7 +272,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("B2") table B2() { actions = { setb4; @@ -171,7 +283,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (hdr.data.b1 == 32w0) { A1.apply(); diff --git a/testdata/v1_samples_outputs/tp3a-fe.p4 b/testdata/v1_samples_outputs/tp3a-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 64% rename from testdata/v1_samples_outputs/tp3a-fe.p4 rename to testdata/v1_samples_outputs/tp3a-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index bb280e61912..39712e16d8f 100644 --- a/testdata/v1_samples_outputs/tp3a-fe.p4 +++ b/testdata/v1_samples_outputs/tp3a-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header data_t { bit<32> f1; bit<32> f2; @@ -50,7 +154,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - @name("E2") table E2() { actions = { setb4; @@ -62,7 +165,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - @name("EA") table EA() { actions = { setb1; @@ -74,7 +176,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - @name("EB") table EB() { actions = { setb1; @@ -86,7 +187,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { E1.apply(); if (hdr.data.f1 == 32w0) @@ -123,7 +223,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("A2") table A2() { actions = { setb3; @@ -135,7 +234,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("A3") table A3() { actions = { setb1; @@ -147,7 +245,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("B1") table B1() { actions = { setb2; @@ -159,7 +256,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("B2") table B2() { actions = { setb4; @@ -171,7 +267,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (hdr.data.b1 == 32w0) { A1.apply(); diff --git a/testdata/v1_samples_outputs/tp3a-midend.p4 b/testdata/v1_samples_outputs/tp3a-MidEnd_25_Evaluator.p4 similarity index 68% rename from testdata/v1_samples_outputs/tp3a-midend.p4 rename to testdata/v1_samples_outputs/tp3a-MidEnd_25_Evaluator.p4 index 9f4bdb2884b..84f9351ad98 100644 --- a/testdata/v1_samples_outputs/tp3a-midend.p4 +++ b/testdata/v1_samples_outputs/tp3a-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); header data_t { bit<32> f1; bit<32> f2; diff --git a/testdata/v1_samples_outputs/tp3a.p4 b/testdata/v1_samples_outputs/tp3a.p4 index 44947ea5203..74f29b37f80 100644 --- a/testdata/v1_samples_outputs/tp3a.p4 +++ b/testdata/v1_samples_outputs/tp3a.p4 @@ -50,7 +50,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - @name("E2") table E2() { actions = { setb4; @@ -62,7 +61,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - @name("EA") table EA() { actions = { setb1; @@ -74,7 +72,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - @name("EB") table EB() { actions = { setb1; @@ -86,7 +83,6 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } default_action = NoAction(); } - apply { E1.apply(); if (hdr.data.f1 == 32w0) { @@ -125,7 +121,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("A2") table A2() { actions = { setb3; @@ -137,7 +132,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("A3") table A3() { actions = { setb1; @@ -149,7 +143,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("B1") table B1() { actions = { setb2; @@ -161,7 +154,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - @name("B2") table B2() { actions = { setb4; @@ -173,7 +165,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { if (hdr.data.b1 == 32w0) { A1.apply(); diff --git a/testdata/v1_samples_outputs/triv_eth-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/triv_eth-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..e02d32571b2 --- /dev/null +++ b/testdata/v1_samples_outputs/triv_eth-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,189 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dst_addr; + bit<48> src_addr; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.ethernet); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("route_eth") action route_eth(bit<9> egress_spec, bit<48> src_addr) { + standard_metadata.egress_spec = egress_spec; + hdr.ethernet.src_addr = src_addr; + } + @name("noop") action noop() { + } + @name("routing") table routing() { + actions = { + route_eth; + noop; + NoAction; + } + key = { + hdr.ethernet.dst_addr: lpm; + } + default_action = NoAction(); + } + apply { + routing.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/triv_eth-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/triv_eth-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..cd0d9cc93e8 --- /dev/null +++ b/testdata/v1_samples_outputs/triv_eth-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,173 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dst_addr; + bit<48> src_addr; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.ethernet); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("route_eth") action route_eth(bit<9> egress_spec, bit<48> src_addr) { + standard_metadata.egress_spec = egress_spec; + hdr.ethernet.src_addr = src_addr; + } + @name("noop") action noop() { + } + @name("routing") table routing() { + actions = { + route_eth; + noop; + NoAction; + } + key = { + hdr.ethernet.dst_addr: lpm; + } + default_action = NoAction(); + } + apply { + routing.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/triv_eth-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/triv_eth-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..e7f7d9d1439 --- /dev/null +++ b/testdata/v1_samples_outputs/triv_eth-MidEnd_25_Evaluator.p4 @@ -0,0 +1,173 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dst_addr; + bit<48> src_addr; + bit<16> ethertype; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.ethernet); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("route_eth") action route_eth_0(bit<9> egress_spec, bit<48> src_addr) { + standard_metadata.egress_spec = egress_spec; + hdr.ethernet.src_addr = src_addr; + } + @name("noop") action noop_0() { + } + @name("routing") table routing_0() { + actions = { + route_eth_0; + noop_0; + NoAction_0; + } + key = { + hdr.ethernet.dst_addr: lpm; + } + default_action = NoAction_0(); + } + apply { + routing_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/triv_eth-fe.p4 b/testdata/v1_samples_outputs/triv_eth-fe.p4 deleted file mode 100644 index e53c6fc604d..00000000000 --- a/testdata/v1_samples_outputs/triv_eth-fe.p4 +++ /dev/null @@ -1,70 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dst_addr; - bit<48> src_addr; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.ethernet); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("route_eth") action route_eth(bit<9> egress_spec, bit<48> src_addr) { - standard_metadata.egress_spec = egress_spec; - hdr.ethernet.src_addr = src_addr; - } - @name("noop") action noop() { - } - @name("routing") table routing() { - actions = { - route_eth; - noop; - NoAction; - } - key = { - hdr.ethernet.dst_addr: lpm; - } - default_action = NoAction(); - } - - apply { - routing.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/triv_eth-last.p4 b/testdata/v1_samples_outputs/triv_eth-last.p4 deleted file mode 100644 index e53c6fc604d..00000000000 --- a/testdata/v1_samples_outputs/triv_eth-last.p4 +++ /dev/null @@ -1,70 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dst_addr; - bit<48> src_addr; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.ethernet); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("route_eth") action route_eth(bit<9> egress_spec, bit<48> src_addr) { - standard_metadata.egress_spec = egress_spec; - hdr.ethernet.src_addr = src_addr; - } - @name("noop") action noop() { - } - @name("routing") table routing() { - actions = { - route_eth; - noop; - NoAction; - } - key = { - hdr.ethernet.dst_addr: lpm; - } - default_action = NoAction(); - } - - apply { - routing.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/triv_eth-midend.p4 b/testdata/v1_samples_outputs/triv_eth-midend.p4 deleted file mode 100644 index 2e12fd984dd..00000000000 --- a/testdata/v1_samples_outputs/triv_eth-midend.p4 +++ /dev/null @@ -1,71 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dst_addr; - bit<48> src_addr; - bit<16> ethertype; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.ethernet); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("route_eth") action route_eth_0(bit<9> egress_spec, bit<48> src_addr) { - standard_metadata.egress_spec = egress_spec; - hdr.ethernet.src_addr = src_addr; - } - @name("noop") action noop_0() { - } - @name("routing") table routing_0() { - actions = { - route_eth_0; - noop_0; - NoAction_0; - } - key = { - hdr.ethernet.dst_addr: lpm; - } - default_action = NoAction_0(); - } - apply { - routing_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/triv_eth.p4 b/testdata/v1_samples_outputs/triv_eth.p4 index e53c6fc604d..7adf44ad918 100644 --- a/testdata/v1_samples_outputs/triv_eth.p4 +++ b/testdata/v1_samples_outputs/triv_eth.p4 @@ -40,7 +40,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { routing.apply(); } diff --git a/testdata/v1_samples_outputs/triv_ipv4-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/triv_ipv4-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..84aef2cc451 --- /dev/null +++ b/testdata/v1_samples_outputs/triv_ipv4-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,217 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dst_addr; + bit<48> src_addr; + 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; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("ipv4") + ipv4_t ipv4; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("ethernet") state ethernet { + packet.extract(hdr.ethernet); + transition select(hdr.ethernet.ethertype) { + 16w0x800: ipv4; + } + } + @name("ipv4") state ipv4 { + packet.extract(hdr.ipv4); + transition accept; + } + @name("start") state start { + transition ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("do_drop") action do_drop() { + } + @name("route_ipv4") action route_ipv4(bit<9> egress_spec) { + hdr.ipv4.ttl = hdr.ipv4.ttl + 8w255; + standard_metadata.egress_spec = egress_spec; + } + @name("routing") table routing() { + actions = { + do_drop; + route_ipv4; + NoAction; + } + key = { + hdr.ipv4.dstAddr: lpm; + } + size = 2048; + default_action = NoAction(); + } + apply { + routing.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.ipv4); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/triv_ipv4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/triv_ipv4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..5feb22ad365 --- /dev/null +++ b/testdata/v1_samples_outputs/triv_ipv4-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,201 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dst_addr; + bit<48> src_addr; + 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; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("ipv4") + ipv4_t ipv4; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("ethernet") state ethernet { + packet.extract(hdr.ethernet); + transition select(hdr.ethernet.ethertype) { + 16w0x800: ipv4; + } + } + @name("ipv4") state ipv4 { + packet.extract(hdr.ipv4); + transition accept; + } + @name("start") state start { + transition ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("do_drop") action do_drop() { + } + @name("route_ipv4") action route_ipv4(bit<9> egress_spec) { + hdr.ipv4.ttl = hdr.ipv4.ttl + 8w255; + standard_metadata.egress_spec = egress_spec; + } + @name("routing") table routing() { + actions = { + do_drop; + route_ipv4; + NoAction; + } + key = { + hdr.ipv4.dstAddr: lpm; + } + size = 2048; + default_action = NoAction(); + } + apply { + routing.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.ipv4); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/triv_ipv4-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/triv_ipv4-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..2658b90af47 --- /dev/null +++ b/testdata/v1_samples_outputs/triv_ipv4-MidEnd_25_Evaluator.p4 @@ -0,0 +1,201 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +header ethernet_t { + bit<48> dst_addr; + bit<48> src_addr; + 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; +} + +struct metadata { +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("ipv4") + ipv4_t ipv4; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("ethernet") state ethernet { + packet.extract(hdr.ethernet); + transition select(hdr.ethernet.ethertype) { + 16w0x800: ipv4; + } + } + @name("ipv4") state ipv4 { + packet.extract(hdr.ipv4); + transition accept; + } + @name("start") state start { + transition ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("do_drop") action do_drop_0() { + } + @name("route_ipv4") action route_ipv4_0(bit<9> egress_spec) { + hdr.ipv4.ttl = hdr.ipv4.ttl + 8w255; + standard_metadata.egress_spec = egress_spec; + } + @name("routing") table routing_0() { + actions = { + do_drop_0; + route_ipv4_0; + NoAction_0; + } + key = { + hdr.ipv4.dstAddr: lpm; + } + size = 2048; + default_action = NoAction_0(); + } + apply { + routing_0.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.ipv4); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/triv_ipv4-fe.p4 b/testdata/v1_samples_outputs/triv_ipv4-fe.p4 deleted file mode 100644 index 46c9438858b..00000000000 --- a/testdata/v1_samples_outputs/triv_ipv4-fe.p4 +++ /dev/null @@ -1,98 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dst_addr; - bit<48> src_addr; - 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; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; - @name("ipv4") - ipv4_t ipv4; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("ethernet") state ethernet { - packet.extract(hdr.ethernet); - transition select(hdr.ethernet.ethertype) { - 16w0x800: ipv4; - } - } - @name("ipv4") state ipv4 { - packet.extract(hdr.ipv4); - transition accept; - } - @name("start") state start { - transition ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("do_drop") action do_drop() { - } - @name("route_ipv4") action route_ipv4(bit<9> egress_spec) { - hdr.ipv4.ttl = hdr.ipv4.ttl + 8w255; - standard_metadata.egress_spec = egress_spec; - } - @name("routing") table routing() { - actions = { - do_drop; - route_ipv4; - NoAction; - } - key = { - hdr.ipv4.dstAddr: lpm; - } - size = 2048; - default_action = NoAction(); - } - - apply { - routing.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - packet.emit(hdr.ipv4); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/triv_ipv4-last.p4 b/testdata/v1_samples_outputs/triv_ipv4-last.p4 deleted file mode 100644 index 46c9438858b..00000000000 --- a/testdata/v1_samples_outputs/triv_ipv4-last.p4 +++ /dev/null @@ -1,98 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dst_addr; - bit<48> src_addr; - 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; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; - @name("ipv4") - ipv4_t ipv4; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("ethernet") state ethernet { - packet.extract(hdr.ethernet); - transition select(hdr.ethernet.ethertype) { - 16w0x800: ipv4; - } - } - @name("ipv4") state ipv4 { - packet.extract(hdr.ipv4); - transition accept; - } - @name("start") state start { - transition ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("do_drop") action do_drop() { - } - @name("route_ipv4") action route_ipv4(bit<9> egress_spec) { - hdr.ipv4.ttl = hdr.ipv4.ttl + 8w255; - standard_metadata.egress_spec = egress_spec; - } - @name("routing") table routing() { - actions = { - do_drop; - route_ipv4; - NoAction; - } - key = { - hdr.ipv4.dstAddr: lpm; - } - size = 2048; - default_action = NoAction(); - } - - apply { - routing.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - packet.emit(hdr.ipv4); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/triv_ipv4-midend.p4 b/testdata/v1_samples_outputs/triv_ipv4-midend.p4 deleted file mode 100644 index e4738b321fe..00000000000 --- a/testdata/v1_samples_outputs/triv_ipv4-midend.p4 +++ /dev/null @@ -1,99 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -header ethernet_t { - bit<48> dst_addr; - bit<48> src_addr; - 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; -} - -struct metadata { -} - -struct headers { - @name("ethernet") - ethernet_t ethernet; - @name("ipv4") - ipv4_t ipv4; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("ethernet") state ethernet { - packet.extract(hdr.ethernet); - transition select(hdr.ethernet.ethertype) { - 16w0x800: ipv4; - } - } - @name("ipv4") state ipv4 { - packet.extract(hdr.ipv4); - transition accept; - } - @name("start") state start { - transition ethernet; - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("do_drop") action do_drop_0() { - } - @name("route_ipv4") action route_ipv4_0(bit<9> egress_spec) { - hdr.ipv4.ttl = hdr.ipv4.ttl + 8w255; - standard_metadata.egress_spec = egress_spec; - } - @name("routing") table routing_0() { - actions = { - do_drop_0; - route_ipv4_0; - NoAction_0; - } - key = { - hdr.ipv4.dstAddr: lpm; - } - size = 2048; - default_action = NoAction_0(); - } - apply { - routing_0.apply(); - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.ethernet); - packet.emit(hdr.ipv4); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/triv_ipv4.p4 b/testdata/v1_samples_outputs/triv_ipv4.p4 index 46c9438858b..cf1a4022090 100644 --- a/testdata/v1_samples_outputs/triv_ipv4.p4 +++ b/testdata/v1_samples_outputs/triv_ipv4.p4 @@ -72,7 +72,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 2048; default_action = NoAction(); } - apply { routing.apply(); } diff --git a/testdata/v1_samples_outputs/validate_outer_ethernet-fe.p4 b/testdata/v1_samples_outputs/validate_outer_ethernet-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 72% rename from testdata/v1_samples_outputs/validate_outer_ethernet-fe.p4 rename to testdata/v1_samples_outputs/validate_outer_ethernet-FrontEnd_11_SimplifyControlFlowE.p4 index a91ca6246a8..c7fbf31c5e9 100644 --- a/testdata/v1_samples_outputs/validate_outer_ethernet-fe.p4 +++ b/testdata/v1_samples_outputs/validate_outer_ethernet-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<3> lkp_pkt_type; bit<48> lkp_mac_sa; @@ -156,7 +276,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 64; default_action = NoAction(); } - apply { validate_outer_ethernet.apply(); } diff --git a/testdata/v1_samples_outputs/validate_outer_ethernet-last.p4 b/testdata/v1_samples_outputs/validate_outer_ethernet-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 77% rename from testdata/v1_samples_outputs/validate_outer_ethernet-last.p4 rename to testdata/v1_samples_outputs/validate_outer_ethernet-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index a91ca6246a8..4517a1930ea 100644 --- a/testdata/v1_samples_outputs/validate_outer_ethernet-last.p4 +++ b/testdata/v1_samples_outputs/validate_outer_ethernet-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<3> lkp_pkt_type; bit<48> lkp_mac_sa; @@ -156,7 +260,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 64; default_action = NoAction(); } - apply { validate_outer_ethernet.apply(); } diff --git a/testdata/v1_samples_outputs/validate_outer_ethernet-midend.p4 b/testdata/v1_samples_outputs/validate_outer_ethernet-MidEnd_25_Evaluator.p4 similarity index 77% rename from testdata/v1_samples_outputs/validate_outer_ethernet-midend.p4 rename to testdata/v1_samples_outputs/validate_outer_ethernet-MidEnd_25_Evaluator.p4 index cd63cd12f44..aee39bff087 100644 --- a/testdata/v1_samples_outputs/validate_outer_ethernet-midend.p4 +++ b/testdata/v1_samples_outputs/validate_outer_ethernet-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<3> lkp_pkt_type; bit<48> lkp_mac_sa; diff --git a/testdata/v1_samples_outputs/validate_outer_ethernet.p4 b/testdata/v1_samples_outputs/validate_outer_ethernet.p4 index a91ca6246a8..ab7148abbea 100644 --- a/testdata/v1_samples_outputs/validate_outer_ethernet.p4 +++ b/testdata/v1_samples_outputs/validate_outer_ethernet.p4 @@ -156,7 +156,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 64; default_action = NoAction(); } - apply { validate_outer_ethernet.apply(); } diff --git a/testdata/v1_samples_outputs/wide_action1-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/wide_action1-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..68a86ff1c7b --- /dev/null +++ b/testdata/v1_samples_outputs/wide_action1-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,216 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct metadata_t { + bit<32> m0; + bit<32> m1; + bit<32> m2; + bit<32> m3; + bit<32> m4; + bit<16> m5; + bit<16> m6; + bit<16> m7; + bit<16> m8; + bit<16> m9; + bit<8> m10; + bit<8> m11; + bit<8> m12; + bit<8> m13; + bit<8> m14; +} + +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { + @name("m") + metadata_t m; +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setmeta") action setmeta(bit<32> v0, bit<32> v1, bit<32> v2, bit<32> v3, bit<32> v4, bit<16> v5, bit<16> v6) { + meta.m.m0 = v0; + meta.m.m1 = v1; + meta.m.m2 = v2; + meta.m.m3 = v3; + meta.m.m4 = v4; + meta.m.m5 = v5; + meta.m.m6 = v6; + } + @name("test1") table test1() { + actions = { + setmeta; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/wide_action1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/wide_action1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..d7c46f2f7da --- /dev/null +++ b/testdata/v1_samples_outputs/wide_action1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,200 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct metadata_t { + bit<32> m0; + bit<32> m1; + bit<32> m2; + bit<32> m3; + bit<32> m4; + bit<16> m5; + bit<16> m6; + bit<16> m7; + bit<16> m8; + bit<16> m9; + bit<8> m10; + bit<8> m11; + bit<8> m12; + bit<8> m13; + bit<8> m14; +} + +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { + @name("m") + metadata_t m; +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setmeta") action setmeta(bit<32> v0, bit<32> v1, bit<32> v2, bit<32> v3, bit<32> v4, bit<16> v5, bit<16> v6) { + meta.m.m0 = v0; + meta.m.m1 = v1; + meta.m.m2 = v2; + meta.m.m3 = v3; + meta.m.m4 = v4; + meta.m.m5 = v5; + meta.m.m6 = v6; + } + @name("test1") table test1() { + actions = { + setmeta; + NoAction; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/wide_action1-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/wide_action1-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..9a772918596 --- /dev/null +++ b/testdata/v1_samples_outputs/wide_action1-MidEnd_25_Evaluator.p4 @@ -0,0 +1,200 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct metadata_t { + bit<32> m0; + bit<32> m1; + bit<32> m2; + bit<32> m3; + bit<32> m4; + bit<16> m5; + bit<16> m6; + bit<16> m7; + bit<16> m8; + bit<16> m9; + bit<8> m10; + bit<8> m11; + bit<8> m12; + bit<8> m13; + bit<8> m14; +} + +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { + @name("m") + metadata_t m; +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("setmeta") action setmeta_0(bit<32> v0, bit<32> v1, bit<32> v2, bit<32> v3, bit<32> v4, bit<16> v5, bit<16> v6) { + meta.m.m0 = v0; + meta.m.m1 = v1; + meta.m.m2 = v2; + meta.m.m3 = v3; + meta.m.m4 = v4; + meta.m.m5 = v5; + meta.m.m6 = v6; + } + @name("test1") table test1_0() { + actions = { + setmeta_0; + NoAction_0; + } + key = { + hdr.data.f1: exact; + } + default_action = NoAction_0(); + } + apply { + test1_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/wide_action1-fe.p4 b/testdata/v1_samples_outputs/wide_action1-fe.p4 deleted file mode 100644 index e45744e659f..00000000000 --- a/testdata/v1_samples_outputs/wide_action1-fe.p4 +++ /dev/null @@ -1,97 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct metadata_t { - bit<32> m0; - bit<32> m1; - bit<32> m2; - bit<32> m3; - bit<32> m4; - bit<16> m5; - bit<16> m6; - bit<16> m7; - bit<16> m8; - bit<16> m9; - bit<8> m10; - bit<8> m11; - bit<8> m12; - bit<8> m13; - bit<8> m14; -} - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { - @name("m") - metadata_t m; -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setmeta") action setmeta(bit<32> v0, bit<32> v1, bit<32> v2, bit<32> v3, bit<32> v4, bit<16> v5, bit<16> v6) { - meta.m.m0 = v0; - meta.m.m1 = v1; - meta.m.m2 = v2; - meta.m.m3 = v3; - meta.m.m4 = v4; - meta.m.m5 = v5; - meta.m.m6 = v6; - } - @name("test1") table test1() { - actions = { - setmeta; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/wide_action1-last.p4 b/testdata/v1_samples_outputs/wide_action1-last.p4 deleted file mode 100644 index e45744e659f..00000000000 --- a/testdata/v1_samples_outputs/wide_action1-last.p4 +++ /dev/null @@ -1,97 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct metadata_t { - bit<32> m0; - bit<32> m1; - bit<32> m2; - bit<32> m3; - bit<32> m4; - bit<16> m5; - bit<16> m6; - bit<16> m7; - bit<16> m8; - bit<16> m9; - bit<8> m10; - bit<8> m11; - bit<8> m12; - bit<8> m13; - bit<8> m14; -} - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { - @name("m") - metadata_t m; -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setmeta") action setmeta(bit<32> v0, bit<32> v1, bit<32> v2, bit<32> v3, bit<32> v4, bit<16> v5, bit<16> v6) { - meta.m.m0 = v0; - meta.m.m1 = v1; - meta.m.m2 = v2; - meta.m.m3 = v3; - meta.m.m4 = v4; - meta.m.m5 = v5; - meta.m.m6 = v6; - } - @name("test1") table test1() { - actions = { - setmeta; - NoAction; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/wide_action1-midend.p4 b/testdata/v1_samples_outputs/wide_action1-midend.p4 deleted file mode 100644 index 11b9749f51f..00000000000 --- a/testdata/v1_samples_outputs/wide_action1-midend.p4 +++ /dev/null @@ -1,98 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct metadata_t { - bit<32> m0; - bit<32> m1; - bit<32> m2; - bit<32> m3; - bit<32> m4; - bit<16> m5; - bit<16> m6; - bit<16> m7; - bit<16> m8; - bit<16> m9; - bit<8> m10; - bit<8> m11; - bit<8> m12; - bit<8> m13; - bit<8> m14; -} - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { - @name("m") - metadata_t m; -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("setmeta") action setmeta_0(bit<32> v0, bit<32> v1, bit<32> v2, bit<32> v3, bit<32> v4, bit<16> v5, bit<16> v6) { - meta.m.m0 = v0; - meta.m.m1 = v1; - meta.m.m2 = v2; - meta.m.m3 = v3; - meta.m.m4 = v4; - meta.m.m5 = v5; - meta.m.m6 = v6; - } - @name("test1") table test1_0() { - actions = { - setmeta_0; - NoAction_0; - } - key = { - hdr.data.f1: exact; - } - default_action = NoAction_0(); - } - apply { - test1_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/wide_action1.p4 b/testdata/v1_samples_outputs/wide_action1.p4 index e45744e659f..931cac0b50c 100644 --- a/testdata/v1_samples_outputs/wide_action1.p4 +++ b/testdata/v1_samples_outputs/wide_action1.p4 @@ -67,7 +67,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } default_action = NoAction(); } - apply { test1.apply(); } diff --git a/testdata/v1_samples_outputs/wide_action2-last.p4 b/testdata/v1_samples_outputs/wide_action2-FrontEnd_11_SimplifyControlFlowE.p4 similarity index 54% rename from testdata/v1_samples_outputs/wide_action2-last.p4 rename to testdata/v1_samples_outputs/wide_action2-FrontEnd_11_SimplifyControlFlowE.p4 index 0f64c9b7558..03d0bb2fea4 100644 --- a/testdata/v1_samples_outputs/wide_action2-last.p4 +++ b/testdata/v1_samples_outputs/wide_action2-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1,6 +1,126 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<16> bd; bit<12> vrf; @@ -79,7 +199,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 16384; default_action = NoAction(); } - apply { bd.apply(); } diff --git a/testdata/v1_samples_outputs/wide_action2-fe.p4 b/testdata/v1_samples_outputs/wide_action2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 similarity index 60% rename from testdata/v1_samples_outputs/wide_action2-fe.p4 rename to testdata/v1_samples_outputs/wide_action2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 0f64c9b7558..cf84acc2a51 100644 --- a/testdata/v1_samples_outputs/wide_action2-fe.p4 +++ b/testdata/v1_samples_outputs/wide_action2-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1,6 +1,110 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<16> bd; bit<12> vrf; @@ -79,7 +183,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 16384; default_action = NoAction(); } - apply { bd.apply(); } diff --git a/testdata/v1_samples_outputs/wide_action2-midend.p4 b/testdata/v1_samples_outputs/wide_action2-MidEnd_25_Evaluator.p4 similarity index 61% rename from testdata/v1_samples_outputs/wide_action2-midend.p4 rename to testdata/v1_samples_outputs/wide_action2-MidEnd_25_Evaluator.p4 index ff9b3370eb3..51661a7a24d 100644 --- a/testdata/v1_samples_outputs/wide_action2-midend.p4 +++ b/testdata/v1_samples_outputs/wide_action2-MidEnd_25_Evaluator.p4 @@ -1,6 +1,108 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); struct ingress_metadata_t { bit<16> bd; bit<12> vrf; diff --git a/testdata/v1_samples_outputs/wide_action2.p4 b/testdata/v1_samples_outputs/wide_action2.p4 index 0f64c9b7558..b7f7fa86715 100644 --- a/testdata/v1_samples_outputs/wide_action2.p4 +++ b/testdata/v1_samples_outputs/wide_action2.p4 @@ -79,7 +79,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 16384; default_action = NoAction(); } - apply { bd.apply(); } diff --git a/testdata/v1_samples_outputs/wide_action3-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/wide_action3-FrontEnd_11_SimplifyControlFlowE.p4 new file mode 100644 index 00000000000..57ffd4ddff7 --- /dev/null +++ b/testdata/v1_samples_outputs/wide_action3-FrontEnd_11_SimplifyControlFlowE.p4 @@ -0,0 +1,217 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +const Version P4_VERSION = { 8w1, 8w2 }; +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +extern void verify(in bool check, in error toSignal); +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +const Version v1modelVersion = { 8w0, 8w1 }; +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +extern bit<32> random(in bit<5> logRange); +extern void digest(in bit<32> receiver, in T data); +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern void mark_to_drop(); +extern void hash(out O result, in HashAlgorithm algo, in T base, in D data, in M max); +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +enum CloneType { + I2E, + E2E +} + +extern void resubmit(in T data); +extern void recirculate(in T data); +extern void clone(in CloneType type, in bit<32> session); +extern void clone3(in CloneType type, in bit<32> session, in T data); +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct metadata_t { + bit<32> m0; + bit<32> m1; + bit<32> m2; + bit<32> m3; + bit<32> m4; + bit<16> m5; + bit<16> m6; + bit<16> m7; + bit<16> m8; + bit<16> m9; + bit<8> m10; + bit<8> m11; + bit<8> m12; + bit<8> m13; + bit<8> m14; +} + +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { + @name("m") + metadata_t m; +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setmeta") action setmeta(bit<8> v0, bit<32> v1, bit<32> v2, bit<32> v3, bit<32> v4, bit<16> v5, bit<16> v6) { + meta.m.m10 = v0; + meta.m.m1 = v1; + meta.m.m2 = v2; + meta.m.m3 = v3; + meta.m.m4 = v4; + meta.m.m5 = v5; + meta.m.m6 = v6; + } + @name("test1") table test1() { + actions = { + setmeta; + NoAction; + } + key = { + hdr.data.f1: exact; + } + size = 8192; + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/wide_action3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/wide_action3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 new file mode 100644 index 00000000000..e2029306fb3 --- /dev/null +++ b/testdata/v1_samples_outputs/wide_action3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -0,0 +1,201 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +action NoAction() { +} +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct metadata_t { + bit<32> m0; + bit<32> m1; + bit<32> m2; + bit<32> m3; + bit<32> m4; + bit<16> m5; + bit<16> m6; + bit<16> m7; + bit<16> m8; + bit<16> m9; + bit<8> m10; + bit<8> m11; + bit<8> m12; + bit<8> m13; + bit<8> m14; +} + +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { + @name("m") + metadata_t m; +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("setmeta") action setmeta(bit<8> v0, bit<32> v1, bit<32> v2, bit<32> v3, bit<32> v4, bit<16> v5, bit<16> v6) { + meta.m.m10 = v0; + meta.m.m1 = v1; + meta.m.m2 = v2; + meta.m.m3 = v3; + meta.m.m4 = v4; + meta.m.m5 = v5; + meta.m.m6 = v6; + } + @name("test1") table test1() { + actions = { + setmeta; + NoAction; + } + key = { + hdr.data.f1: exact; + } + size = 8192; + default_action = NoAction(); + } + apply { + test1.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/wide_action3-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/wide_action3-MidEnd_25_Evaluator.p4 new file mode 100644 index 00000000000..63c19f64758 --- /dev/null +++ b/testdata/v1_samples_outputs/wide_action3-MidEnd_25_Evaluator.p4 @@ -0,0 +1,201 @@ +struct Version { + bit<8> major; + bit<8> minor; +} + +error { + NoError, + PacketTooShort, + NoMatch, + EmptyStack, + FullStack, + OverwritingHeader +} + +extern packet_in { + void extract(out T hdr); + void extract(out T variableSizeHeader, in bit<32> sizeInBits); + T lookahead(); + void advance(in bit<32> sizeInBits); + bit<32> length(); +} + +extern packet_out { + void emit(in T hdr); +} + +match_kind { + exact, + ternary, + lpm +} + +match_kind { + range, + selector +} + +struct standard_metadata_t { + bit<9> ingress_port; + bit<9> egress_spec; + bit<9> egress_port; + bit<32> clone_spec; + bit<32> instance_type; + bit<1> drop; + bit<16> recirculate_port; + bit<32> packet_length; +} + +extern Checksum16 { + bit<16> get(in D data); +} + +enum CounterType { + Packets, + Bytes, + Both +} + +extern Counter { + Counter(bit<32> size, CounterType type); + void increment(in bit<32> index); +} + +extern DirectCounter { + DirectCounter(CounterType type); +} + +extern Meter { + Meter(bit<32> size, CounterType type); + void meter(in bit<32> index, out T result); +} + +extern DirectMeter { + DirectMeter(CounterType type); + void read(out T result); +} + +extern Register { + Register(bit<32> size); + void read(out T result, in bit<32> index); + void write(in bit<32> index, in T value); +} + +extern ActionProfile { + ActionProfile(bit<32> size); +} + +enum HashAlgorithm { + crc32, + crc16, + random, + identity +} + +extern ActionSelector { + ActionSelector(HashAlgorithm algorithm, bit<32> size, bit<32> outputWidth); +} + +parser Parser(packet_in b, out H parsedHdr, inout M meta, inout standard_metadata_t standard_metadata); +control VerifyChecksum(in H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Ingress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control Egress(inout H hdr, inout M meta, inout standard_metadata_t standard_metadata); +control ComputeCkecksum(inout H hdr, inout M meta); +control Deparser(packet_out b, in H hdr); +package V1Switch(Parser p, VerifyChecksum vr, Ingress ig, Egress eg, ComputeCkecksum ck, Deparser dep); +struct metadata_t { + bit<32> m0; + bit<32> m1; + bit<32> m2; + bit<32> m3; + bit<32> m4; + bit<16> m5; + bit<16> m6; + bit<16> m7; + bit<16> m8; + bit<16> m9; + bit<8> m10; + bit<8> m11; + bit<8> m12; + bit<8> m13; + bit<8> m14; +} + +header data_t { + bit<32> f1; + bit<32> f2; + bit<32> f3; + bit<32> f4; + bit<8> b1; + bit<8> b2; + bit<8> b3; + bit<8> b4; +} + +struct metadata { + @name("m") + metadata_t m; +} + +struct headers { + @name("data") + data_t data; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("start") state start { + packet.extract(hdr.data); + transition accept; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action NoAction_0() { + } + @name("setmeta") action setmeta_0(bit<8> v0, bit<32> v1, bit<32> v2, bit<32> v3, bit<32> v4, bit<16> v5, bit<16> v6) { + meta.m.m10 = v0; + meta.m.m1 = v1; + meta.m.m2 = v2; + meta.m.m3 = v3; + meta.m.m4 = v4; + meta.m.m5 = v5; + meta.m.m6 = v6; + } + @name("test1") table test1_0() { + actions = { + setmeta_0; + NoAction_0; + } + key = { + hdr.data.f1: exact; + } + size = 8192; + default_action = NoAction_0(); + } + apply { + test1_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.data); + } +} + +control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/wide_action3-fe.p4 b/testdata/v1_samples_outputs/wide_action3-fe.p4 deleted file mode 100644 index 7f0aa05a2e5..00000000000 --- a/testdata/v1_samples_outputs/wide_action3-fe.p4 +++ /dev/null @@ -1,98 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct metadata_t { - bit<32> m0; - bit<32> m1; - bit<32> m2; - bit<32> m3; - bit<32> m4; - bit<16> m5; - bit<16> m6; - bit<16> m7; - bit<16> m8; - bit<16> m9; - bit<8> m10; - bit<8> m11; - bit<8> m12; - bit<8> m13; - bit<8> m14; -} - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { - @name("m") - metadata_t m; -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setmeta") action setmeta(bit<8> v0, bit<32> v1, bit<32> v2, bit<32> v3, bit<32> v4, bit<16> v5, bit<16> v6) { - meta.m.m10 = v0; - meta.m.m1 = v1; - meta.m.m2 = v2; - meta.m.m3 = v3; - meta.m.m4 = v4; - meta.m.m5 = v5; - meta.m.m6 = v6; - } - @name("test1") table test1() { - actions = { - setmeta; - NoAction; - } - key = { - hdr.data.f1: exact; - } - size = 8192; - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/wide_action3-last.p4 b/testdata/v1_samples_outputs/wide_action3-last.p4 deleted file mode 100644 index 7f0aa05a2e5..00000000000 --- a/testdata/v1_samples_outputs/wide_action3-last.p4 +++ /dev/null @@ -1,98 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct metadata_t { - bit<32> m0; - bit<32> m1; - bit<32> m2; - bit<32> m3; - bit<32> m4; - bit<16> m5; - bit<16> m6; - bit<16> m7; - bit<16> m8; - bit<16> m9; - bit<8> m10; - bit<8> m11; - bit<8> m12; - bit<8> m13; - bit<8> m14; -} - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { - @name("m") - metadata_t m; -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("setmeta") action setmeta(bit<8> v0, bit<32> v1, bit<32> v2, bit<32> v3, bit<32> v4, bit<16> v5, bit<16> v6) { - meta.m.m10 = v0; - meta.m.m1 = v1; - meta.m.m2 = v2; - meta.m.m3 = v3; - meta.m.m4 = v4; - meta.m.m5 = v5; - meta.m.m6 = v6; - } - @name("test1") table test1() { - actions = { - setmeta; - NoAction; - } - key = { - hdr.data.f1: exact; - } - size = 8192; - default_action = NoAction(); - } - - apply { - test1.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/wide_action3-midend.p4 b/testdata/v1_samples_outputs/wide_action3-midend.p4 deleted file mode 100644 index 087a32a7050..00000000000 --- a/testdata/v1_samples_outputs/wide_action3-midend.p4 +++ /dev/null @@ -1,99 +0,0 @@ -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/core.p4" -#include "/home/mbudiu/barefoot/git/p4c/build/../p4include/v1model.p4" - -struct metadata_t { - bit<32> m0; - bit<32> m1; - bit<32> m2; - bit<32> m3; - bit<32> m4; - bit<16> m5; - bit<16> m6; - bit<16> m7; - bit<16> m8; - bit<16> m9; - bit<8> m10; - bit<8> m11; - bit<8> m12; - bit<8> m13; - bit<8> m14; -} - -header data_t { - bit<32> f1; - bit<32> f2; - bit<32> f3; - bit<32> f4; - bit<8> b1; - bit<8> b2; - bit<8> b3; - bit<8> b4; -} - -struct metadata { - @name("m") - metadata_t m; -} - -struct headers { - @name("data") - data_t data; -} - -parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - @name("start") state start { - packet.extract(hdr.data); - transition accept; - } -} - -control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - action NoAction_0() { - } - @name("setmeta") action setmeta_0(bit<8> v0, bit<32> v1, bit<32> v2, bit<32> v3, bit<32> v4, bit<16> v5, bit<16> v6) { - meta.m.m10 = v0; - meta.m.m1 = v1; - meta.m.m2 = v2; - meta.m.m3 = v3; - meta.m.m4 = v4; - meta.m.m5 = v5; - meta.m.m6 = v6; - } - @name("test1") table test1_0() { - actions = { - setmeta_0; - NoAction_0; - } - key = { - hdr.data.f1: exact; - } - size = 8192; - default_action = NoAction_0(); - } - apply { - test1_0.apply(); - } -} - -control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control DeparserImpl(packet_out packet, in headers hdr) { - apply { - packet.emit(hdr.data); - } -} - -control verifyChecksum(in headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { - apply { - } -} - -control computeChecksum(inout headers hdr, inout metadata meta) { - apply { - } -} - -V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/v1_samples_outputs/wide_action3.p4 b/testdata/v1_samples_outputs/wide_action3.p4 index 7f0aa05a2e5..fcdcf25a64d 100644 --- a/testdata/v1_samples_outputs/wide_action3.p4 +++ b/testdata/v1_samples_outputs/wide_action3.p4 @@ -68,7 +68,6 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 8192; default_action = NoAction(); } - apply { test1.apply(); } From b9304c0ff7caf1b7d765b718c958b38b9770edf2 Mon Sep 17 00:00:00 2001 From: Mihai Budiu Date: Tue, 10 May 2016 09:39:57 -0700 Subject: [PATCH 2/2] Changed setValid(bool) to setValid() and setInvalid() --- backends/bmv2/jsonconverter.cpp | 18 +- frontends/p4/fromv1.0/programStructure.cpp | 12 +- frontends/p4/methodInstance.cpp | 1 + frontends/p4/methodInstance.h | 2 +- frontends/p4/typeChecking/typeChecker.cpp | 6 +- ir/type.cpp | 1 + ir/type.def | 1 + midend/moveDeclarations.cpp | 3 +- midend/removeReturns.cpp | 128 ++++- midend/removeReturns.h | 35 +- testdata/v1_2_samples/valid.p4 | 2 +- .../parser-locals-MidEnd_25_Evaluator.p4 | 4 +- .../valid-FrontEnd_11_SimplifyControlFlowE.p4 | 2 +- testdata/v1_2_samples_outputs/valid.p4 | 2 +- ...llTPHV-FrontEnd_11_SimplifyControlFlowE.p4 | 2 +- ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 2 +- .../05-FullTPHV-MidEnd_25_Evaluator.p4 | 2 +- testdata/v1_samples_outputs/05-FullTPHV.p4 | 2 +- ...lTPHV3-FrontEnd_11_SimplifyControlFlowE.p4 | 4 +- ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 4 +- .../08-FullTPHV3-MidEnd_25_Evaluator.p4 | 4 +- testdata/v1_samples_outputs/08-FullTPHV3.p4 | 4 +- ...to_cpu-FrontEnd_11_SimplifyControlFlowE.p4 | 2 +- ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 2 +- .../copy_to_cpu-MidEnd_25_Evaluator.p4 | 2 +- testdata/v1_samples_outputs/copy_to_cpu.p4 | 2 +- ...truct1-FrontEnd_11_SimplifyControlFlowE.p4 | 2 +- ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 2 +- .../instruct1-MidEnd_25_Evaluator.p4 | 2 +- testdata/v1_samples_outputs/instruct1.p4 | 2 +- ...eueing-FrontEnd_11_SimplifyControlFlowE.p4 | 2 +- ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 2 +- .../queueing-MidEnd_25_Evaluator.p4 | 2 +- testdata/v1_samples_outputs/queueing.p4 | 2 +- ...le_nat-FrontEnd_11_SimplifyControlFlowE.p4 | 4 +- ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 4 +- .../simple_nat-MidEnd_25_Evaluator.p4 | 4 +- testdata/v1_samples_outputs/simple_nat.p4 | 4 +- ...outing-FrontEnd_11_SimplifyControlFlowE.p4 | 2 +- ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 2 +- .../source_routing-MidEnd_25_Evaluator.p4 | 2 +- testdata/v1_samples_outputs/source_routing.p4 | 2 +- ...switch-FrontEnd_11_SimplifyControlFlowE.p4 | 310 ++++++------ ...FrontEnd_12_RemoveAllUnusedDeclarations.p4 | 310 ++++++------ .../switch-MidEnd_25_Evaluator.p4 | 464 +++++++++--------- testdata/v1_samples_outputs/switch.p4 | 310 ++++++------ 46 files changed, 921 insertions(+), 762 deletions(-) diff --git a/backends/bmv2/jsonconverter.cpp b/backends/bmv2/jsonconverter.cpp index 22d93514284..d8eaf215ff8 100644 --- a/backends/bmv2/jsonconverter.cpp +++ b/backends/bmv2/jsonconverter.cpp @@ -612,25 +612,21 @@ JsonConverter::convertActionBody(const IR::Vector* body, cstring prim; auto parameters = new Util::JsonArray(); - BUG_CHECK(mc->arguments->size() == 1, "Expected 1 argument for %1%", mc); - auto arg = conv->convert(mc->arguments->at(0)); auto obj = conv->convert(builtin->appliedTo); parameters->append(obj); if (builtin->name == IR::Type_Header::setValid) { - if (!mc->arguments->at(0)->is()) { - ::error("%1%: argument must be a constant for this target", mc); - continue; - } - auto bl = mc->arguments->at(0)->to(); - if (bl->value) - prim = "add_header"; - else - prim = "remove_header"; + prim = "add_header"; + } else if (builtin->name == IR::Type_Header::setInvalid) { + prim = "remove_header"; } else if (builtin->name == IR::Type_Stack::push_front) { + BUG_CHECK(mc->arguments->size() == 1, "Expected 1 argument for %1%", mc); + auto arg = conv->convert(mc->arguments->at(0)); prim = "push"; parameters->append(arg); } else if (builtin->name == IR::Type_Stack::pop_front) { + BUG_CHECK(mc->arguments->size() == 1, "Expected 1 argument for %1%", mc); + auto arg = conv->convert(mc->arguments->at(0)); prim = "pop"; parameters->append(arg); } else { diff --git a/frontends/p4/fromv1.0/programStructure.cpp b/frontends/p4/fromv1.0/programStructure.cpp index 3d9c45c1d54..dccfca365df 100644 --- a/frontends/p4/fromv1.0/programStructure.cpp +++ b/frontends/p4/fromv1.0/programStructure.cpp @@ -905,13 +905,19 @@ const IR::Statement* ProgramStructure::convertPrimitive(const IR::Primitive* pri else op = new IR::Sub(primitive->srcInfo, left, right); return new IR::AssignmentStatement(primitive->srcInfo, left, op); - } else if (primitive->name == "remove_header" || primitive->name == "add_header") { + } else if (primitive->name == "remove_header") { + OPS_CK(primitive, 1); + auto hdr = conv.convert(primitive->operands.at(0)); + auto method = new IR::Member(Util::SourceInfo(), hdr, IR::ID(IR::Type_Header::setInvalid)); + auto args = new IR::Vector(); + auto mc = new IR::MethodCallExpression(primitive->srcInfo, method, + emptyTypeArguments, args); + return new IR::MethodCallStatement(mc->srcInfo, mc); + } else if (primitive->name == "add_header") { OPS_CK(primitive, 1); auto hdr = conv.convert(primitive->operands.at(0)); auto method = new IR::Member(Util::SourceInfo(), hdr, IR::ID(IR::Type_Header::setValid)); auto args = new IR::Vector(); - bool value = primitive->name == "add_header"; - args->push_back(new IR::BoolLiteral(Util::SourceInfo(), value)); auto mc = new IR::MethodCallExpression(primitive->srcInfo, method, emptyTypeArguments, args); return new IR::MethodCallStatement(mc->srcInfo, mc); diff --git a/frontends/p4/methodInstance.cpp b/frontends/p4/methodInstance.cpp index ef38d74f8be..0a1883a1c31 100644 --- a/frontends/p4/methodInstance.cpp +++ b/frontends/p4/methodInstance.cpp @@ -19,6 +19,7 @@ MethodInstance::resolve(const IR::MethodCallExpression* mce, const P4::Reference basetype = mem->expr->type; if (basetype->is()) { if (mem->member == IR::Type_Header::setValid || + mem->member == IR::Type_Header::setInvalid || mem->member == IR::Type_Header::isValid) return new BuiltInMethod(mce, mem->member, mem->expr); } diff --git a/frontends/p4/methodInstance.h b/frontends/p4/methodInstance.h index 7f1a6b3d1a6..46de2b9585a 100644 --- a/frontends/p4/methodInstance.h +++ b/frontends/p4/methodInstance.h @@ -85,7 +85,7 @@ class ActionCall final : public MethodInstance { // A built-in method. // These methods are: -// header.setValid(bool), header.isValid(), stack.push(int), stack.pop(int) +// header.setValid(), header.setInvalid(), header.isValid(), stack.push(int), stack.pop(int) class BuiltInMethod final : public MethodInstance { friend class MethodInstance; BuiltInMethod(const IR::MethodCallExpression* expr, IR::ID name, diff --git a/frontends/p4/typeChecking/typeChecker.cpp b/frontends/p4/typeChecking/typeChecker.cpp index a53407b76c9..7b20c260ca4 100644 --- a/frontends/p4/typeChecking/typeChecker.cpp +++ b/frontends/p4/typeChecking/typeChecker.cpp @@ -1722,12 +1722,10 @@ const IR::Node* TypeInference::postorder(IR::Member* expression) { setType(getOriginal(), ctype); setType(expression, ctype); return expression; - } else if (expression->member.name == IR::Type_Header::setValid) { + } else if (expression->member.name == IR::Type_Header::setValid || + expression->member.name == IR::Type_Header::setInvalid) { // Built-in method auto params = new IR::IndexedVector(); - params->push_back(new IR::Parameter( - Util::SourceInfo(), IR::ID("value"), IR::Annotations::empty, - IR::Direction::In, IR::Type_Boolean::get())); auto type = new IR::Type_Method( Util::SourceInfo(), new IR::TypeParameters(), IR::Type_Void::get(), new IR::ParameterList(Util::SourceInfo(), params)); diff --git a/ir/type.cpp b/ir/type.cpp index 85bc11ab61d..b465c19bf6c 100644 --- a/ir/type.cpp +++ b/ir/type.cpp @@ -12,6 +12,7 @@ const cstring IR::Type_Stack::push_front = "push_front"; const cstring IR::Type_Stack::pop_front = "pop_front"; const cstring IR::Type_Header::isValid = "isValid"; const cstring IR::Type_Header::setValid = "setValid"; +const cstring IR::Type_Header::setInvalid = "setInvalid"; const IR::ID IR::Type_Table::hit = ID("hit"); const IR::ID IR::Type_Table::action_run = ID("action_run"); diff --git a/ir/type.def b/ir/type.def index 8e8a2ca7928..7dbb41f6d9e 100644 --- a/ir/type.def +++ b/ir/type.def @@ -244,6 +244,7 @@ class Type_Union : Type_StructLike { class Type_Header : Type_StructLike { #emit const static cstring setValid; + const static cstring setInvalid; const static cstring isValid; #end #nodbprint diff --git a/midend/moveDeclarations.cpp b/midend/moveDeclarations.cpp index 3c71c765e5b..99bcd770431 100644 --- a/midend/moveDeclarations.cpp +++ b/midend/moveDeclarations.cpp @@ -12,9 +12,8 @@ void ResetHeaders::generateResets(const IR::Type* type, const IR::Expression* ex generateResets(ftype, member, resets); } } else if (type->is()) { - auto method = new IR::Member(expr->srcInfo, expr, IR::Type_Header::setValid); + auto method = new IR::Member(expr->srcInfo, expr, IR::Type_Header::setInvalid); auto args = new IR::Vector(); - args->push_back(new IR::BoolLiteral(Util::SourceInfo(), false)); auto mc = new IR::MethodCallExpression(expr->srcInfo, method, new IR::Vector(), args); auto stat = new IR::MethodCallStatement(mc->srcInfo, mc); diff --git a/midend/removeReturns.cpp b/midend/removeReturns.cpp index c02fa1b9a7d..5c718bcd52e 100644 --- a/midend/removeReturns.cpp +++ b/midend/removeReturns.cpp @@ -20,8 +20,6 @@ class HasExits : public Inspector { } // namespace const IR::Node* RemoveReturns::preorder(IR::P4Action* action) { - // FIXME: this is incorrect for exits: the - // 'hasExits' variable should be in the calling control. HasExits he; (void)action->apply(he); if (!he.hasReturns) { @@ -184,6 +182,7 @@ class CallsExit : public Inspector { } // namespace const IR::Node* RemoveExits::preorder(IR::ExitStatement* statement) { + set(Returns::Yes); auto action = findOrigCtxt(); if (action != nullptr) { LOG4(getOriginal() << " calls exit"); @@ -206,4 +205,129 @@ const IR::Node* RemoveExits::preorder(IR::P4Table* table) { return table; } +const IR::Node* RemoveExits::preorder(IR::P4Action* action) { + BUG_CHECK(stack.empty(), "Non-empty stack"); + push(); + visit(action->body); + pop(); + BUG_CHECK(stack.empty(), "Non-empty stack"); + prune(); + return action; +} + +const IR::Node* RemoveExits::preorder(IR::P4Control* control) { + HasExits he; + (void)control->body->apply(he); + if (!he.hasReturns) { + // don't pollute the code unnecessarily + prune(); + return control; + } + + cstring var = refMap->newName(variableName); + returnVar = IR::ID(var); + auto f = new IR::BoolLiteral(Util::SourceInfo(), false); + auto decl = new IR::Declaration_Variable(Util::SourceInfo(), returnVar, + IR::Annotations::empty, IR::Type_Boolean::get(), f); + BUG_CHECK(stack.empty(), "Non-empty stack"); + push(); + visit(control->body); + auto bodyContents = new IR::IndexedVector(); + bodyContents->push_back(decl); + bodyContents->append(*control->body->components); + auto body = new IR::BlockStatement(control->body->srcInfo, bodyContents); + auto result = new IR::P4Control(control->srcInfo, control->name, control->type, + control->constructorParams, control->stateful, body); + pop(); + BUG_CHECK(stack.empty(), "Non-empty stack"); + prune(); + return result; +} + +const IR::Node* RemoveExits::preorder(IR::ReturnStatement* statement) { + set(Returns::Yes); + auto left = new IR::PathExpression(returnVar); + return new IR::AssignmentStatement(statement->srcInfo, left, + new IR::BoolLiteral(Util::SourceInfo(), true)); + return statement; +} + +const IR::Node* RemoveExits::preorder(IR::BlockStatement* statement) { + auto body = new IR::IndexedVector(); + auto currentBody = body; + Returns ret = Returns::No; + for (auto s : *statement->components) { + push(); + visit(s); + currentBody->push_back(s); + Returns r = hasReturned(); + pop(); + if (r == Returns::Yes) { + ret = r; + break; + } else if (r == Returns::Maybe) { + auto newBody = new IR::IndexedVector(); + auto path = new IR::PathExpression(returnVar); + auto condition = new IR::LNot(Util::SourceInfo(), path); + auto newBlock = new IR::BlockStatement(Util::SourceInfo(), newBody); + auto ifstat = new IR::IfStatement(Util::SourceInfo(), condition, newBlock, nullptr); + body->push_back(ifstat); + currentBody = newBody; + ret = r; + } + } + set(ret); + prune(); + return new IR::BlockStatement(statement->srcInfo, body); +} + +const IR::Node* RemoveExits::preorder(IR::IfStatement* statement) { + push(); + visit(statement->ifTrue); + if (statement->ifTrue == nullptr) + statement->ifTrue = new IR::EmptyStatement(Util::SourceInfo()); + auto rt = hasReturned(); + auto rf = Returns::No; + pop(); + if (statement->ifFalse != nullptr) { + push(); + visit(statement->ifFalse); + rf = hasReturned(); + pop(); + } + if (rt == Returns::Yes && rf == Returns::Yes) + set(Returns::Yes); + else if (rt == Returns::No && rf == Returns::No) + set(Returns::No); + else + set(Returns::Maybe); + prune(); + return statement; +} + +const IR::Node* RemoveExits::preorder(IR::SwitchStatement* statement) { + auto r = Returns::No; + for (auto c : *statement->cases) { + push(); + visit(c); + if (hasReturned() != Returns::No) + // this is conservative: we don't check if we cover all labels. + r = Returns::Maybe; + pop(); + } + set(r); + prune(); + return statement; +} + +const IR::Node* RemoveExits::preorder(IR::AssignmentStatement* statement) { + // TODO + return statement; +} + +const IR::Node* RemoveExits::preorder(IR::MethodCallStatement* statement) { + // TODO + return statement; +} + } // namespace P4 diff --git a/midend/removeReturns.h b/midend/removeReturns.h index 3a2cae88094..d89acdd3881 100644 --- a/midend/removeReturns.h +++ b/midend/removeReturns.h @@ -7,7 +7,21 @@ namespace P4 { -// This replaces 'returns' and/or 'exits' by ifs +// This replaces 'returns' by ifs: +// e.g. +// control c(inout bit x) { apply { +// if (x) return; +// x = !x; +// }} +// becomes: +// control c(inout bit x) { +// bool hasReturned; +// apply { +// hasReturned = false; +// if (x) hasReturned = true; +// if (!hasReturned) +// x = !x; +// }} class RemoveReturns : public Transform { protected: P4::ReferenceMap* refMap; @@ -40,8 +54,17 @@ class RemoveReturns : public Transform { const IR::Node* preorder(IR::P4Action* action) override; const IR::Node* preorder(IR::P4Control* control) override; + const IR::Node* preorder(IR::P4Parser* parser) override + { prune(); return parser; } }; +// This removes "exit" calls. It is significantly more involved than return removal, +// since an exit in an action causes the calling control to terminate. +// This pass assumes that each statement in a control block can +// exit only once - so it should be run after a pass that enforces this. +// It also assumes that there are no global actions and that action calls have been inlined. +// (E.g., it does not handle: +// if (t1.apply().hit && t2.apply().hit) { ... } class RemoveExits : public RemoveReturns { std::set callsExit; // actions, tables TypeMap* typeMap; @@ -51,6 +74,16 @@ class RemoveExits : public RemoveReturns { const IR::Node* preorder(IR::ExitStatement* action) override; const IR::Node* preorder(IR::P4Table* table) override; + + const IR::Node* preorder(IR::BlockStatement* statement) override; + const IR::Node* preorder(IR::ReturnStatement* statement) override; + const IR::Node* preorder(IR::IfStatement* statement) override; + const IR::Node* preorder(IR::SwitchStatement* statement) override; + const IR::Node* preorder(IR::AssignmentStatement* statement) override; + const IR::Node* preorder(IR::MethodCallStatement* statement) override; + + const IR::Node* preorder(IR::P4Action* action) override; + const IR::Node* preorder(IR::P4Control* control) override; }; } // namespace P4 diff --git a/testdata/v1_2_samples/valid.p4 b/testdata/v1_2_samples/valid.p4 index 7d012960fc1..ad151f756bb 100644 --- a/testdata/v1_2_samples/valid.p4 +++ b/testdata/v1_2_samples/valid.p4 @@ -5,7 +5,7 @@ header h { control c(inout h hdr) { action a() { - hdr.setValid(false); + hdr.setInvalid(); } apply {} diff --git a/testdata/v1_2_samples_outputs/parser-locals-MidEnd_25_Evaluator.p4 b/testdata/v1_2_samples_outputs/parser-locals-MidEnd_25_Evaluator.p4 index c1fdc32c6af..58f75cfa546 100644 --- a/testdata/v1_2_samples_outputs/parser-locals-MidEnd_25_Evaluator.p4 +++ b/testdata/v1_2_samples_outputs/parser-locals-MidEnd_25_Evaluator.p4 @@ -12,8 +12,8 @@ struct S { parser p() { S s_0; state start { - s_0.h1.setValid(false); - s_0.h2.setValid(false); + s_0.h1.setInvalid(); + s_0.h2.setInvalid(); s_0.c = 32w0; transition accept; } diff --git a/testdata/v1_2_samples_outputs/valid-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_2_samples_outputs/valid-FrontEnd_11_SimplifyControlFlowE.p4 index 3dc6f250d90..fc50c760290 100644 --- a/testdata/v1_2_samples_outputs/valid-FrontEnd_11_SimplifyControlFlowE.p4 +++ b/testdata/v1_2_samples_outputs/valid-FrontEnd_11_SimplifyControlFlowE.p4 @@ -4,7 +4,7 @@ header h { control c(inout h hdr) { action a() { - hdr.setValid(false); + hdr.setInvalid(); } apply { } diff --git a/testdata/v1_2_samples_outputs/valid.p4 b/testdata/v1_2_samples_outputs/valid.p4 index 3dc6f250d90..fc50c760290 100644 --- a/testdata/v1_2_samples_outputs/valid.p4 +++ b/testdata/v1_2_samples_outputs/valid.p4 @@ -4,7 +4,7 @@ header h { control c(inout h hdr) { action a() { - hdr.setValid(false); + hdr.setInvalid(); } apply { } diff --git a/testdata/v1_samples_outputs/05-FullTPHV-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/05-FullTPHV-FrontEnd_11_SimplifyControlFlowE.p4 index 16821101794..e729c8effc0 100644 --- a/testdata/v1_samples_outputs/05-FullTPHV-FrontEnd_11_SimplifyControlFlowE.p4 +++ b/testdata/v1_samples_outputs/05-FullTPHV-FrontEnd_11_SimplifyControlFlowE.p4 @@ -654,7 +654,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ meta.m.field_32_61 = 32w61; meta.m.field_32_62 = 32w62; meta.m.field_32_63 = 32w63; - hdr.h.setValid(false); + hdr.h.setInvalid(); } @name("set_egress_spec") action set_egress_spec(bit<9> port) { standard_metadata.egress_spec = port; diff --git a/testdata/v1_samples_outputs/05-FullTPHV-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/05-FullTPHV-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 1bd604826c5..344360772af 100644 --- a/testdata/v1_samples_outputs/05-FullTPHV-FrontEnd_12_RemoveAllUnusedDeclarations.p4 +++ b/testdata/v1_samples_outputs/05-FullTPHV-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -638,7 +638,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ meta.m.field_32_61 = 32w61; meta.m.field_32_62 = 32w62; meta.m.field_32_63 = 32w63; - hdr.h.setValid(false); + hdr.h.setInvalid(); } @name("set_egress_spec") action set_egress_spec(bit<9> port) { standard_metadata.egress_spec = port; diff --git a/testdata/v1_samples_outputs/05-FullTPHV-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/05-FullTPHV-MidEnd_25_Evaluator.p4 index 08638f47c5f..bd3ea68e388 100644 --- a/testdata/v1_samples_outputs/05-FullTPHV-MidEnd_25_Evaluator.p4 +++ b/testdata/v1_samples_outputs/05-FullTPHV-MidEnd_25_Evaluator.p4 @@ -648,7 +648,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ meta.m.field_32_61 = 32w61; meta.m.field_32_62 = 32w62; meta.m.field_32_63 = 32w63; - hdr.h.setValid(false); + hdr.h.setInvalid(); } @name("set_egress_spec") action set_egress_spec_0(bit<9> port) { standard_metadata.egress_spec = port; diff --git a/testdata/v1_samples_outputs/05-FullTPHV.p4 b/testdata/v1_samples_outputs/05-FullTPHV.p4 index 6c41354f8d1..3dfd6fd50ef 100644 --- a/testdata/v1_samples_outputs/05-FullTPHV.p4 +++ b/testdata/v1_samples_outputs/05-FullTPHV.p4 @@ -534,7 +534,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ meta.m.field_32_61 = 32w61; meta.m.field_32_62 = 32w62; meta.m.field_32_63 = 32w63; - hdr.h.setValid(false); + hdr.h.setInvalid(); } @name("set_egress_spec") action set_egress_spec(bit<9> port) { standard_metadata.egress_spec = port; diff --git a/testdata/v1_samples_outputs/08-FullTPHV3-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/08-FullTPHV3-FrontEnd_11_SimplifyControlFlowE.p4 index bff9fcc6097..735896ad877 100644 --- a/testdata/v1_samples_outputs/08-FullTPHV3-FrontEnd_11_SimplifyControlFlowE.p4 +++ b/testdata/v1_samples_outputs/08-FullTPHV3-FrontEnd_11_SimplifyControlFlowE.p4 @@ -839,8 +839,8 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ meta.m.field_32_60 = 32w60; meta.m.field_32_61 = 32w61; meta.m.field_32_62 = 32w62; - hdr.h_8_2.setValid(false); - hdr.h_32_15.setValid(false); + hdr.h_8_2.setInvalid(); + hdr.h_32_15.setInvalid(); } @name("set_egress_spec") action set_egress_spec(bit<9> port) { standard_metadata.egress_spec = port; diff --git a/testdata/v1_samples_outputs/08-FullTPHV3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/08-FullTPHV3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 7ea89d7c7e2..3fda943332b 100644 --- a/testdata/v1_samples_outputs/08-FullTPHV3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 +++ b/testdata/v1_samples_outputs/08-FullTPHV3-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -823,8 +823,8 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ meta.m.field_32_60 = 32w60; meta.m.field_32_61 = 32w61; meta.m.field_32_62 = 32w62; - hdr.h_8_2.setValid(false); - hdr.h_32_15.setValid(false); + hdr.h_8_2.setInvalid(); + hdr.h_32_15.setInvalid(); } @name("set_egress_spec") action set_egress_spec(bit<9> port) { standard_metadata.egress_spec = port; diff --git a/testdata/v1_samples_outputs/08-FullTPHV3-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/08-FullTPHV3-MidEnd_25_Evaluator.p4 index 4761352d117..17d5f3d7465 100644 --- a/testdata/v1_samples_outputs/08-FullTPHV3-MidEnd_25_Evaluator.p4 +++ b/testdata/v1_samples_outputs/08-FullTPHV3-MidEnd_25_Evaluator.p4 @@ -833,8 +833,8 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ meta.m.field_32_60 = 32w60; meta.m.field_32_61 = 32w61; meta.m.field_32_62 = 32w62; - hdr.h_8_2.setValid(false); - hdr.h_32_15.setValid(false); + hdr.h_8_2.setInvalid(); + hdr.h_32_15.setInvalid(); } @name("set_egress_spec") action set_egress_spec_0(bit<9> port) { standard_metadata.egress_spec = port; diff --git a/testdata/v1_samples_outputs/08-FullTPHV3.p4 b/testdata/v1_samples_outputs/08-FullTPHV3.p4 index dd07761beae..fb2dfb43bcc 100644 --- a/testdata/v1_samples_outputs/08-FullTPHV3.p4 +++ b/testdata/v1_samples_outputs/08-FullTPHV3.p4 @@ -719,8 +719,8 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ meta.m.field_32_60 = 32w60; meta.m.field_32_61 = 32w61; meta.m.field_32_62 = 32w62; - hdr.h_8_2.setValid(false); - hdr.h_32_15.setValid(false); + hdr.h_8_2.setInvalid(); + hdr.h_32_15.setInvalid(); } @name("set_egress_spec") action set_egress_spec(bit<9> port) { standard_metadata.egress_spec = port; diff --git a/testdata/v1_samples_outputs/copy_to_cpu-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/copy_to_cpu-FrontEnd_11_SimplifyControlFlowE.p4 index a3e1620f27a..2f7631888fb 100644 --- a/testdata/v1_samples_outputs/copy_to_cpu-FrontEnd_11_SimplifyControlFlowE.p4 +++ b/testdata/v1_samples_outputs/copy_to_cpu-FrontEnd_11_SimplifyControlFlowE.p4 @@ -173,7 +173,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t mark_to_drop(); } @name("do_cpu_encap") action do_cpu_encap() { - hdr.cpu_header.setValid(true); + hdr.cpu_header.setValid(); hdr.cpu_header.device = 8w0; hdr.cpu_header.reason = 8w0xab; } diff --git a/testdata/v1_samples_outputs/copy_to_cpu-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/copy_to_cpu-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 7543b42ff5a..0e94ac2fdd2 100644 --- a/testdata/v1_samples_outputs/copy_to_cpu-FrontEnd_12_RemoveAllUnusedDeclarations.p4 +++ b/testdata/v1_samples_outputs/copy_to_cpu-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -164,7 +164,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t mark_to_drop(); } @name("do_cpu_encap") action do_cpu_encap() { - hdr.cpu_header.setValid(true); + hdr.cpu_header.setValid(); hdr.cpu_header.device = 8w0; hdr.cpu_header.reason = 8w0xab; } diff --git a/testdata/v1_samples_outputs/copy_to_cpu-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/copy_to_cpu-MidEnd_25_Evaluator.p4 index f123cd65d45..fef1f387c36 100644 --- a/testdata/v1_samples_outputs/copy_to_cpu-MidEnd_25_Evaluator.p4 +++ b/testdata/v1_samples_outputs/copy_to_cpu-MidEnd_25_Evaluator.p4 @@ -164,7 +164,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t mark_to_drop(); } @name("do_cpu_encap") action do_cpu_encap_0() { - hdr.cpu_header.setValid(true); + hdr.cpu_header.setValid(); hdr.cpu_header.device = 8w0; hdr.cpu_header.reason = 8w0xab; } diff --git a/testdata/v1_samples_outputs/copy_to_cpu.p4 b/testdata/v1_samples_outputs/copy_to_cpu.p4 index d83bad953f7..4c94790edf7 100644 --- a/testdata/v1_samples_outputs/copy_to_cpu.p4 +++ b/testdata/v1_samples_outputs/copy_to_cpu.p4 @@ -53,7 +53,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t mark_to_drop(); } @name("do_cpu_encap") action do_cpu_encap() { - hdr.cpu_header.setValid(true); + hdr.cpu_header.setValid(); hdr.cpu_header.device = 8w0; hdr.cpu_header.reason = 8w0xab; } diff --git a/testdata/v1_samples_outputs/instruct1-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/instruct1-FrontEnd_11_SimplifyControlFlowE.p4 index f5514c95bf9..6342d0b9221 100644 --- a/testdata/v1_samples_outputs/instruct1-FrontEnd_11_SimplifyControlFlowE.p4 +++ b/testdata/v1_samples_outputs/instruct1-FrontEnd_11_SimplifyControlFlowE.p4 @@ -173,7 +173,7 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("decap") action decap() { hdr.hdr1 = hdr.hdr2; - hdr.hdr2.setValid(false); + hdr.hdr2.setInvalid(); } @name("noop") action noop() { } diff --git a/testdata/v1_samples_outputs/instruct1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/instruct1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 8cd7d75ccd4..4fe980fe2d4 100644 --- a/testdata/v1_samples_outputs/instruct1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 +++ b/testdata/v1_samples_outputs/instruct1-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -157,7 +157,7 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("decap") action decap() { hdr.hdr1 = hdr.hdr2; - hdr.hdr2.setValid(false); + hdr.hdr2.setInvalid(); } @name("noop") action noop() { } diff --git a/testdata/v1_samples_outputs/instruct1-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/instruct1-MidEnd_25_Evaluator.p4 index 5732fe169bb..ad02e5d6dd2 100644 --- a/testdata/v1_samples_outputs/instruct1-MidEnd_25_Evaluator.p4 +++ b/testdata/v1_samples_outputs/instruct1-MidEnd_25_Evaluator.p4 @@ -157,7 +157,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ } @name("decap") action decap_0() { hdr.hdr1 = hdr.hdr2; - hdr.hdr2.setValid(false); + hdr.hdr2.setInvalid(); } @name("noop") action noop_0() { } diff --git a/testdata/v1_samples_outputs/instruct1.p4 b/testdata/v1_samples_outputs/instruct1.p4 index dc6e5e940c9..6a006c82cd1 100644 --- a/testdata/v1_samples_outputs/instruct1.p4 +++ b/testdata/v1_samples_outputs/instruct1.p4 @@ -53,7 +53,7 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("decap") action decap() { hdr.hdr1 = hdr.hdr2; - hdr.hdr2.setValid(false); + hdr.hdr2.setInvalid(); } @name("noop") action noop() { } diff --git a/testdata/v1_samples_outputs/queueing-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/queueing-FrontEnd_11_SimplifyControlFlowE.p4 index 0edef16285d..fbb2305d587 100644 --- a/testdata/v1_samples_outputs/queueing-FrontEnd_11_SimplifyControlFlowE.p4 +++ b/testdata/v1_samples_outputs/queueing-FrontEnd_11_SimplifyControlFlowE.p4 @@ -168,7 +168,7 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("copy_queueing_data") action copy_queueing_data() { - hdr.queueing_hdr.setValid(true); + hdr.queueing_hdr.setValid(); hdr.queueing_hdr.enq_timestamp = meta.queueing_metadata.enq_timestamp; hdr.queueing_hdr.enq_qdepth = meta.queueing_metadata.enq_qdepth; hdr.queueing_hdr.deq_timedelta = meta.queueing_metadata.deq_timedelta; diff --git a/testdata/v1_samples_outputs/queueing-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/queueing-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 3facfcdb7b5..15d45d6c2f8 100644 --- a/testdata/v1_samples_outputs/queueing-FrontEnd_12_RemoveAllUnusedDeclarations.p4 +++ b/testdata/v1_samples_outputs/queueing-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -153,7 +153,7 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("copy_queueing_data") action copy_queueing_data() { - hdr.queueing_hdr.setValid(true); + hdr.queueing_hdr.setValid(); hdr.queueing_hdr.enq_timestamp = meta.queueing_metadata.enq_timestamp; hdr.queueing_hdr.enq_qdepth = meta.queueing_metadata.enq_qdepth; hdr.queueing_hdr.deq_timedelta = meta.queueing_metadata.deq_timedelta; diff --git a/testdata/v1_samples_outputs/queueing-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/queueing-MidEnd_25_Evaluator.p4 index e86571dcd6e..8b05aabe9c6 100644 --- a/testdata/v1_samples_outputs/queueing-MidEnd_25_Evaluator.p4 +++ b/testdata/v1_samples_outputs/queueing-MidEnd_25_Evaluator.p4 @@ -153,7 +153,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t action NoAction_0() { } @name("copy_queueing_data") action copy_queueing_data_0() { - hdr.queueing_hdr.setValid(true); + hdr.queueing_hdr.setValid(); hdr.queueing_hdr.enq_timestamp = meta.queueing_metadata.enq_timestamp; hdr.queueing_hdr.enq_qdepth = meta.queueing_metadata.enq_qdepth; hdr.queueing_hdr.deq_timedelta = meta.queueing_metadata.deq_timedelta; diff --git a/testdata/v1_samples_outputs/queueing.p4 b/testdata/v1_samples_outputs/queueing.p4 index 2c8d6ff4d70..a912f3662d4 100644 --- a/testdata/v1_samples_outputs/queueing.p4 +++ b/testdata/v1_samples_outputs/queueing.p4 @@ -48,7 +48,7 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("copy_queueing_data") action copy_queueing_data() { - hdr.queueing_hdr.setValid(true); + hdr.queueing_hdr.setValid(); hdr.queueing_hdr.enq_timestamp = meta.queueing_metadata.enq_timestamp; hdr.queueing_hdr.enq_qdepth = meta.queueing_metadata.enq_qdepth; hdr.queueing_hdr.deq_timedelta = meta.queueing_metadata.deq_timedelta; diff --git a/testdata/v1_samples_outputs/simple_nat-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/simple_nat-FrontEnd_11_SimplifyControlFlowE.p4 index d9f46dfb654..e345a9a77a3 100644 --- a/testdata/v1_samples_outputs/simple_nat-FrontEnd_11_SimplifyControlFlowE.p4 +++ b/testdata/v1_samples_outputs/simple_nat-FrontEnd_11_SimplifyControlFlowE.p4 @@ -241,7 +241,7 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("do_rewrites") action do_rewrites(bit<48> smac) { - hdr.cpu_header.setValid(false); + hdr.cpu_header.setInvalid(); hdr.ethernet.srcAddr = smac; hdr.ipv4.srcAddr = meta.meta.ipv4_sa; hdr.ipv4.dstAddr = meta.meta.ipv4_da; @@ -252,7 +252,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t mark_to_drop(); } @name("do_cpu_encap") action do_cpu_encap() { - hdr.cpu_header.setValid(true); + hdr.cpu_header.setValid(); hdr.cpu_header.preamble = 64w0; hdr.cpu_header.device = 8w0; hdr.cpu_header.reason = 8w0xab; diff --git a/testdata/v1_samples_outputs/simple_nat-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/simple_nat-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 8896290d781..8ee7ed4a5ba 100644 --- a/testdata/v1_samples_outputs/simple_nat-FrontEnd_12_RemoveAllUnusedDeclarations.p4 +++ b/testdata/v1_samples_outputs/simple_nat-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -232,7 +232,7 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("do_rewrites") action do_rewrites(bit<48> smac) { - hdr.cpu_header.setValid(false); + hdr.cpu_header.setInvalid(); hdr.ethernet.srcAddr = smac; hdr.ipv4.srcAddr = meta.meta.ipv4_sa; hdr.ipv4.dstAddr = meta.meta.ipv4_da; @@ -243,7 +243,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t mark_to_drop(); } @name("do_cpu_encap") action do_cpu_encap() { - hdr.cpu_header.setValid(true); + hdr.cpu_header.setValid(); hdr.cpu_header.preamble = 64w0; hdr.cpu_header.device = 8w0; hdr.cpu_header.reason = 8w0xab; diff --git a/testdata/v1_samples_outputs/simple_nat-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/simple_nat-MidEnd_25_Evaluator.p4 index d1a4cfa5ce6..f7f916cbac3 100644 --- a/testdata/v1_samples_outputs/simple_nat-MidEnd_25_Evaluator.p4 +++ b/testdata/v1_samples_outputs/simple_nat-MidEnd_25_Evaluator.p4 @@ -234,7 +234,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t action NoAction_2() { } @name("do_rewrites") action do_rewrites_0(bit<48> smac) { - hdr.cpu_header.setValid(false); + hdr.cpu_header.setInvalid(); hdr.ethernet.srcAddr = smac; hdr.ipv4.srcAddr = meta.meta.ipv4_sa; hdr.ipv4.dstAddr = meta.meta.ipv4_da; @@ -245,7 +245,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t mark_to_drop(); } @name("do_cpu_encap") action do_cpu_encap_0() { - hdr.cpu_header.setValid(true); + hdr.cpu_header.setValid(); hdr.cpu_header.preamble = 64w0; hdr.cpu_header.device = 8w0; hdr.cpu_header.reason = 8w0xab; diff --git a/testdata/v1_samples_outputs/simple_nat.p4 b/testdata/v1_samples_outputs/simple_nat.p4 index 1b348b66202..377500b4c84 100644 --- a/testdata/v1_samples_outputs/simple_nat.p4 +++ b/testdata/v1_samples_outputs/simple_nat.p4 @@ -121,7 +121,7 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("do_rewrites") action do_rewrites(bit<48> smac) { - hdr.cpu_header.setValid(false); + hdr.cpu_header.setInvalid(); hdr.ethernet.srcAddr = smac; hdr.ipv4.srcAddr = meta.meta.ipv4_sa; hdr.ipv4.dstAddr = meta.meta.ipv4_da; @@ -132,7 +132,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t mark_to_drop(); } @name("do_cpu_encap") action do_cpu_encap() { - hdr.cpu_header.setValid(true); + hdr.cpu_header.setValid(); hdr.cpu_header.preamble = 64w0; hdr.cpu_header.device = 8w0; hdr.cpu_header.reason = 8w0xab; diff --git a/testdata/v1_samples_outputs/source_routing-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/source_routing-FrontEnd_11_SimplifyControlFlowE.p4 index bf5d4ab1e7d..d2b4b765c55 100644 --- a/testdata/v1_samples_outputs/source_routing-FrontEnd_11_SimplifyControlFlowE.p4 +++ b/testdata/v1_samples_outputs/source_routing-FrontEnd_11_SimplifyControlFlowE.p4 @@ -172,7 +172,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ @name("route") action route() { standard_metadata.egress_spec = (bit<9>)hdr.easyroute_port.port; hdr.easyroute_head.num_valid = hdr.easyroute_head.num_valid + 32w4294967295; - hdr.easyroute_port.setValid(false); + hdr.easyroute_port.setInvalid(); } @name("route_pkt") table route_pkt() { actions = { diff --git a/testdata/v1_samples_outputs/source_routing-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/source_routing-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index 9e8348d7224..f70a9e367f6 100644 --- a/testdata/v1_samples_outputs/source_routing-FrontEnd_12_RemoveAllUnusedDeclarations.p4 +++ b/testdata/v1_samples_outputs/source_routing-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -157,7 +157,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ @name("route") action route() { standard_metadata.egress_spec = (bit<9>)hdr.easyroute_port.port; hdr.easyroute_head.num_valid = hdr.easyroute_head.num_valid + 32w4294967295; - hdr.easyroute_port.setValid(false); + hdr.easyroute_port.setInvalid(); } @name("route_pkt") table route_pkt() { actions = { diff --git a/testdata/v1_samples_outputs/source_routing-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/source_routing-MidEnd_25_Evaluator.p4 index 2ac91d49a96..e7b1ccc048b 100644 --- a/testdata/v1_samples_outputs/source_routing-MidEnd_25_Evaluator.p4 +++ b/testdata/v1_samples_outputs/source_routing-MidEnd_25_Evaluator.p4 @@ -157,7 +157,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ @name("route") action route_0() { standard_metadata.egress_spec = (bit<9>)hdr.easyroute_port.port; hdr.easyroute_head.num_valid = hdr.easyroute_head.num_valid + 32w4294967295; - hdr.easyroute_port.setValid(false); + hdr.easyroute_port.setInvalid(); } @name("route_pkt") table route_pkt_0() { actions = { diff --git a/testdata/v1_samples_outputs/source_routing.p4 b/testdata/v1_samples_outputs/source_routing.p4 index d43faad5eae..c63f9dabdb3 100644 --- a/testdata/v1_samples_outputs/source_routing.p4 +++ b/testdata/v1_samples_outputs/source_routing.p4 @@ -52,7 +52,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ @name("route") action route() { standard_metadata.egress_spec = hdr.easyroute_port.port; hdr.easyroute_head.num_valid = hdr.easyroute_head.num_valid + 32w4294967295; - hdr.easyroute_port.setValid(false); + hdr.easyroute_port.setInvalid(); } @name("route_pkt") table route_pkt() { actions = { diff --git a/testdata/v1_samples_outputs/switch-FrontEnd_11_SimplifyControlFlowE.p4 b/testdata/v1_samples_outputs/switch-FrontEnd_11_SimplifyControlFlowE.p4 index 4953b15330b..83b73293e2d 100644 --- a/testdata/v1_samples_outputs/switch-FrontEnd_11_SimplifyControlFlowE.p4 +++ b/testdata/v1_samples_outputs/switch-FrontEnd_11_SimplifyControlFlowE.p4 @@ -1434,12 +1434,12 @@ control process_vlan_decap(inout headers hdr, inout metadata meta, inout standar } @name("remove_vlan_single_tagged") action remove_vlan_single_tagged() { hdr.ethernet.etherType = hdr.vlan_tag_[0].etherType; - hdr.vlan_tag_[0].setValid(false); + hdr.vlan_tag_[0].setInvalid(); } @name("remove_vlan_double_tagged") action remove_vlan_double_tagged() { hdr.ethernet.etherType = hdr.vlan_tag_[1].etherType; - hdr.vlan_tag_[0].setValid(false); - hdr.vlan_tag_[1].setValid(false); + hdr.vlan_tag_[0].setInvalid(); + hdr.vlan_tag_[1].setInvalid(); } @name("vlan_decap") table vlan_decap() { actions = { @@ -1463,211 +1463,211 @@ control process_vlan_decap(inout headers hdr, inout metadata meta, inout standar control process_tunnel_decap(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("decap_inner_udp") action decap_inner_udp() { hdr.udp = hdr.inner_udp; - hdr.inner_udp.setValid(false); + hdr.inner_udp.setInvalid(); } @name("decap_inner_tcp") action decap_inner_tcp() { hdr.tcp = hdr.inner_tcp; - hdr.inner_tcp.setValid(false); - hdr.udp.setValid(false); + hdr.inner_tcp.setInvalid(); + hdr.udp.setInvalid(); } @name("decap_inner_icmp") action decap_inner_icmp() { hdr.icmp = hdr.inner_icmp; - hdr.inner_icmp.setValid(false); - hdr.udp.setValid(false); + hdr.inner_icmp.setInvalid(); + hdr.udp.setInvalid(); } @name("decap_inner_unknown") action decap_inner_unknown() { - hdr.udp.setValid(false); + hdr.udp.setInvalid(); } @name("decap_vxlan_inner_ipv4") action decap_vxlan_inner_ipv4() { hdr.ethernet = hdr.inner_ethernet; hdr.ipv4 = hdr.inner_ipv4; - hdr.vxlan.setValid(false); - hdr.ipv6.setValid(false); - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv4.setValid(false); + hdr.vxlan.setInvalid(); + hdr.ipv6.setInvalid(); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv4.setInvalid(); } @name("decap_vxlan_inner_ipv6") action decap_vxlan_inner_ipv6() { hdr.ethernet = hdr.inner_ethernet; hdr.ipv6 = hdr.inner_ipv6; - hdr.vxlan.setValid(false); - hdr.ipv4.setValid(false); - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv6.setValid(false); + hdr.vxlan.setInvalid(); + hdr.ipv4.setInvalid(); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv6.setInvalid(); } @name("decap_vxlan_inner_non_ip") action decap_vxlan_inner_non_ip() { hdr.ethernet = hdr.inner_ethernet; - hdr.vxlan.setValid(false); - hdr.ipv4.setValid(false); - hdr.ipv6.setValid(false); + hdr.vxlan.setInvalid(); + hdr.ipv4.setInvalid(); + hdr.ipv6.setInvalid(); } @name("decap_genv_inner_ipv4") action decap_genv_inner_ipv4() { hdr.ethernet = hdr.inner_ethernet; hdr.ipv4 = hdr.inner_ipv4; - hdr.genv.setValid(false); - hdr.ipv6.setValid(false); - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv4.setValid(false); + hdr.genv.setInvalid(); + hdr.ipv6.setInvalid(); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv4.setInvalid(); } @name("decap_genv_inner_ipv6") action decap_genv_inner_ipv6() { hdr.ethernet = hdr.inner_ethernet; hdr.ipv6 = hdr.inner_ipv6; - hdr.genv.setValid(false); - hdr.ipv4.setValid(false); - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv6.setValid(false); + hdr.genv.setInvalid(); + hdr.ipv4.setInvalid(); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv6.setInvalid(); } @name("decap_genv_inner_non_ip") action decap_genv_inner_non_ip() { hdr.ethernet = hdr.inner_ethernet; - hdr.genv.setValid(false); - hdr.ipv4.setValid(false); - hdr.ipv6.setValid(false); + hdr.genv.setInvalid(); + hdr.ipv4.setInvalid(); + hdr.ipv6.setInvalid(); } @name("decap_nvgre_inner_ipv4") action decap_nvgre_inner_ipv4() { hdr.ethernet = hdr.inner_ethernet; hdr.ipv4 = hdr.inner_ipv4; - hdr.nvgre.setValid(false); - hdr.gre.setValid(false); - hdr.ipv6.setValid(false); - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv4.setValid(false); + hdr.nvgre.setInvalid(); + hdr.gre.setInvalid(); + hdr.ipv6.setInvalid(); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv4.setInvalid(); } @name("decap_nvgre_inner_ipv6") action decap_nvgre_inner_ipv6() { hdr.ethernet = hdr.inner_ethernet; hdr.ipv6 = hdr.inner_ipv6; - hdr.nvgre.setValid(false); - hdr.gre.setValid(false); - hdr.ipv4.setValid(false); - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv6.setValid(false); + hdr.nvgre.setInvalid(); + hdr.gre.setInvalid(); + hdr.ipv4.setInvalid(); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv6.setInvalid(); } @name("decap_nvgre_inner_non_ip") action decap_nvgre_inner_non_ip() { hdr.ethernet = hdr.inner_ethernet; - hdr.nvgre.setValid(false); - hdr.gre.setValid(false); - hdr.ipv4.setValid(false); - hdr.ipv6.setValid(false); + hdr.nvgre.setInvalid(); + hdr.gre.setInvalid(); + hdr.ipv4.setInvalid(); + hdr.ipv6.setInvalid(); } @name("decap_ip_inner_ipv4") action decap_ip_inner_ipv4() { hdr.ipv4 = hdr.inner_ipv4; - hdr.gre.setValid(false); - hdr.ipv6.setValid(false); - hdr.inner_ipv4.setValid(false); + hdr.gre.setInvalid(); + hdr.ipv6.setInvalid(); + hdr.inner_ipv4.setInvalid(); hdr.ethernet.etherType = 16w0x800; } @name("decap_ip_inner_ipv6") action decap_ip_inner_ipv6() { hdr.ipv6 = hdr.inner_ipv6; - hdr.gre.setValid(false); - hdr.ipv4.setValid(false); - hdr.inner_ipv6.setValid(false); + hdr.gre.setInvalid(); + hdr.ipv4.setInvalid(); + hdr.inner_ipv6.setInvalid(); hdr.ethernet.etherType = 16w0x86dd; } @name("decap_mpls_inner_ipv4_pop1") action decap_mpls_inner_ipv4_pop1() { - hdr.mpls[0].setValid(false); + hdr.mpls[0].setInvalid(); hdr.ipv4 = hdr.inner_ipv4; - hdr.inner_ipv4.setValid(false); + hdr.inner_ipv4.setInvalid(); hdr.ethernet.etherType = 16w0x800; } @name("decap_mpls_inner_ipv6_pop1") action decap_mpls_inner_ipv6_pop1() { - hdr.mpls[0].setValid(false); + hdr.mpls[0].setInvalid(); hdr.ipv6 = hdr.inner_ipv6; - hdr.inner_ipv6.setValid(false); + hdr.inner_ipv6.setInvalid(); hdr.ethernet.etherType = 16w0x86dd; } @name("decap_mpls_inner_ethernet_ipv4_pop1") action decap_mpls_inner_ethernet_ipv4_pop1() { - hdr.mpls[0].setValid(false); + hdr.mpls[0].setInvalid(); hdr.ethernet = hdr.inner_ethernet; hdr.ipv4 = hdr.inner_ipv4; - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv4.setValid(false); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv4.setInvalid(); } @name("decap_mpls_inner_ethernet_ipv6_pop1") action decap_mpls_inner_ethernet_ipv6_pop1() { - hdr.mpls[0].setValid(false); + hdr.mpls[0].setInvalid(); hdr.ethernet = hdr.inner_ethernet; hdr.ipv6 = hdr.inner_ipv6; - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv6.setValid(false); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv6.setInvalid(); } @name("decap_mpls_inner_ethernet_non_ip_pop1") action decap_mpls_inner_ethernet_non_ip_pop1() { - hdr.mpls[0].setValid(false); + hdr.mpls[0].setInvalid(); hdr.ethernet = hdr.inner_ethernet; - hdr.inner_ethernet.setValid(false); + hdr.inner_ethernet.setInvalid(); } @name("decap_mpls_inner_ipv4_pop2") action decap_mpls_inner_ipv4_pop2() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); hdr.ipv4 = hdr.inner_ipv4; - hdr.inner_ipv4.setValid(false); + hdr.inner_ipv4.setInvalid(); hdr.ethernet.etherType = 16w0x800; } @name("decap_mpls_inner_ipv6_pop2") action decap_mpls_inner_ipv6_pop2() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); hdr.ipv6 = hdr.inner_ipv6; - hdr.inner_ipv6.setValid(false); + hdr.inner_ipv6.setInvalid(); hdr.ethernet.etherType = 16w0x86dd; } @name("decap_mpls_inner_ethernet_ipv4_pop2") action decap_mpls_inner_ethernet_ipv4_pop2() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); hdr.ethernet = hdr.inner_ethernet; hdr.ipv4 = hdr.inner_ipv4; - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv4.setValid(false); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv4.setInvalid(); } @name("decap_mpls_inner_ethernet_ipv6_pop2") action decap_mpls_inner_ethernet_ipv6_pop2() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); hdr.ethernet = hdr.inner_ethernet; hdr.ipv6 = hdr.inner_ipv6; - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv6.setValid(false); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv6.setInvalid(); } @name("decap_mpls_inner_ethernet_non_ip_pop2") action decap_mpls_inner_ethernet_non_ip_pop2() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); hdr.ethernet = hdr.inner_ethernet; - hdr.inner_ethernet.setValid(false); + hdr.inner_ethernet.setInvalid(); } @name("decap_mpls_inner_ipv4_pop3") action decap_mpls_inner_ipv4_pop3() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); - hdr.mpls[2].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); + hdr.mpls[2].setInvalid(); hdr.ipv4 = hdr.inner_ipv4; - hdr.inner_ipv4.setValid(false); + hdr.inner_ipv4.setInvalid(); hdr.ethernet.etherType = 16w0x800; } @name("decap_mpls_inner_ipv6_pop3") action decap_mpls_inner_ipv6_pop3() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); - hdr.mpls[2].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); + hdr.mpls[2].setInvalid(); hdr.ipv6 = hdr.inner_ipv6; - hdr.inner_ipv6.setValid(false); + hdr.inner_ipv6.setInvalid(); hdr.ethernet.etherType = 16w0x86dd; } @name("decap_mpls_inner_ethernet_ipv4_pop3") action decap_mpls_inner_ethernet_ipv4_pop3() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); - hdr.mpls[2].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); + hdr.mpls[2].setInvalid(); hdr.ethernet = hdr.inner_ethernet; hdr.ipv4 = hdr.inner_ipv4; - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv4.setValid(false); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv4.setInvalid(); } @name("decap_mpls_inner_ethernet_ipv6_pop3") action decap_mpls_inner_ethernet_ipv6_pop3() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); - hdr.mpls[2].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); + hdr.mpls[2].setInvalid(); hdr.ethernet = hdr.inner_ethernet; hdr.ipv6 = hdr.inner_ipv6; - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv6.setValid(false); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv6.setInvalid(); } @name("decap_mpls_inner_ethernet_non_ip_pop3") action decap_mpls_inner_ethernet_non_ip_pop3() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); - hdr.mpls[2].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); + hdr.mpls[2].setInvalid(); hdr.ethernet = hdr.inner_ethernet; - hdr.inner_ethernet.setValid(false); + hdr.inner_ethernet.setInvalid(); } @name("tunnel_decap_process_inner") table tunnel_decap_process_inner() { actions = { @@ -1888,14 +1888,14 @@ control process_int_insertion(inout headers hdr, inout metadata meta, inout stan @name("int_set_header_0003_i0") action int_set_header_0003_i0() { } @name("int_set_header_3") action int_set_header_3() { - hdr.int_q_occupancy_header.setValid(true); + hdr.int_q_occupancy_header.setValid(); hdr.int_q_occupancy_header.q_occupancy = (bit<31>)meta.intrinsic_metadata.enq_qdepth; } @name("int_set_header_0003_i1") action int_set_header_0003_i1() { int_set_header_3(); } @name("int_set_header_2") action int_set_header_2() { - hdr.int_hop_latency_header.setValid(true); + hdr.int_hop_latency_header.setValid(); hdr.int_hop_latency_header.hop_latency = (bit<31>)meta.intrinsic_metadata.deq_timedelta; } @name("int_set_header_0003_i2") action int_set_header_0003_i2() { @@ -1906,7 +1906,7 @@ control process_int_insertion(inout headers hdr, inout metadata meta, inout stan int_set_header_2(); } @name("int_set_header_1") action int_set_header_1() { - hdr.int_ingress_port_id_header.setValid(true); + hdr.int_ingress_port_id_header.setValid(); hdr.int_ingress_port_id_header.ingress_port_id = (bit<31>)meta.ingress_metadata.ifindex; } @name("int_set_header_0003_i4") action int_set_header_0003_i4() { @@ -1926,7 +1926,7 @@ control process_int_insertion(inout headers hdr, inout metadata meta, inout stan int_set_header_1(); } @name("int_set_header_0") action int_set_header_0() { - hdr.int_switch_id_header.setValid(true); + hdr.int_switch_id_header.setValid(); hdr.int_switch_id_header.switch_id = (bit<31>)meta.int_metadata.switch_id; } @name("int_set_header_0003_i8") action int_set_header_0003_i8() { @@ -1968,14 +1968,14 @@ control process_int_insertion(inout headers hdr, inout metadata meta, inout stan @name("int_set_header_0407_i0") action int_set_header_0407_i0() { } @name("int_set_header_7") action int_set_header_7() { - hdr.int_egress_port_tx_utilization_header.setValid(true); + hdr.int_egress_port_tx_utilization_header.setValid(); hdr.int_egress_port_tx_utilization_header.egress_port_tx_utilization = 31w0x7fffffff; } @name("int_set_header_0407_i1") action int_set_header_0407_i1() { int_set_header_7(); } @name("int_set_header_6") action int_set_header_6() { - hdr.int_q_congestion_header.setValid(true); + hdr.int_q_congestion_header.setValid(); hdr.int_q_congestion_header.q_congestion = 31w0x7fffffff; } @name("int_set_header_0407_i2") action int_set_header_0407_i2() { @@ -1986,7 +1986,7 @@ control process_int_insertion(inout headers hdr, inout metadata meta, inout stan int_set_header_6(); } @name("int_set_header_5") action int_set_header_5() { - hdr.int_egress_port_id_header.setValid(true); + hdr.int_egress_port_id_header.setValid(); hdr.int_egress_port_id_header.egress_port_id = (bit<31>)standard_metadata.egress_port; } @name("int_set_header_0407_i4") action int_set_header_0407_i4() { @@ -2006,7 +2006,7 @@ control process_int_insertion(inout headers hdr, inout metadata meta, inout stan int_set_header_5(); } @name("int_set_header_4") action int_set_header_4() { - hdr.int_ingress_tstamp_header.setValid(true); + hdr.int_ingress_tstamp_header.setValid(); hdr.int_ingress_tstamp_header.ingress_tstamp = (bit<31>)meta.i2e_metadata.ingress_tstamp; } @name("int_set_header_0407_i8") action int_set_header_0407_i8() { @@ -2263,60 +2263,60 @@ control process_tunnel_encap(inout headers hdr, inout metadata meta, inout stand hdr.inner_ipv4 = hdr.ipv4; hdr.inner_udp = hdr.udp; meta.egress_metadata.payload_length = hdr.ipv4.totalLen; - hdr.udp.setValid(false); - hdr.ipv4.setValid(false); + hdr.udp.setInvalid(); + hdr.ipv4.setInvalid(); } @name("inner_ipv4_tcp_rewrite") action inner_ipv4_tcp_rewrite() { hdr.inner_ipv4 = hdr.ipv4; hdr.inner_tcp = hdr.tcp; meta.egress_metadata.payload_length = hdr.ipv4.totalLen; - hdr.tcp.setValid(false); - hdr.ipv4.setValid(false); + hdr.tcp.setInvalid(); + hdr.ipv4.setInvalid(); } @name("inner_ipv4_icmp_rewrite") action inner_ipv4_icmp_rewrite() { hdr.inner_ipv4 = hdr.ipv4; hdr.inner_icmp = hdr.icmp; meta.egress_metadata.payload_length = hdr.ipv4.totalLen; - hdr.icmp.setValid(false); - hdr.ipv4.setValid(false); + hdr.icmp.setInvalid(); + hdr.ipv4.setInvalid(); } @name("inner_ipv4_unknown_rewrite") action inner_ipv4_unknown_rewrite() { hdr.inner_ipv4 = hdr.ipv4; meta.egress_metadata.payload_length = hdr.ipv4.totalLen; - hdr.ipv4.setValid(false); + hdr.ipv4.setInvalid(); } @name("inner_ipv6_udp_rewrite") action inner_ipv6_udp_rewrite() { hdr.inner_ipv6 = hdr.ipv6; hdr.inner_udp = hdr.udp; meta.egress_metadata.payload_length = hdr.ipv6.payloadLen + 16w40; - hdr.ipv6.setValid(false); + hdr.ipv6.setInvalid(); } @name("inner_ipv6_tcp_rewrite") action inner_ipv6_tcp_rewrite() { hdr.inner_ipv6 = hdr.ipv6; hdr.inner_tcp = hdr.tcp; meta.egress_metadata.payload_length = hdr.ipv6.payloadLen + 16w40; - hdr.tcp.setValid(false); - hdr.ipv6.setValid(false); + hdr.tcp.setInvalid(); + hdr.ipv6.setInvalid(); } @name("inner_ipv6_icmp_rewrite") action inner_ipv6_icmp_rewrite() { hdr.inner_ipv6 = hdr.ipv6; hdr.inner_icmp = hdr.icmp; meta.egress_metadata.payload_length = hdr.ipv6.payloadLen + 16w40; - hdr.icmp.setValid(false); - hdr.ipv6.setValid(false); + hdr.icmp.setInvalid(); + hdr.ipv6.setInvalid(); } @name("inner_ipv6_unknown_rewrite") action inner_ipv6_unknown_rewrite() { hdr.inner_ipv6 = hdr.ipv6; meta.egress_metadata.payload_length = hdr.ipv6.payloadLen + 16w40; - hdr.ipv6.setValid(false); + hdr.ipv6.setInvalid(); } @name("inner_non_ip_rewrite") action inner_non_ip_rewrite() { meta.egress_metadata.payload_length = (bit<16>)(standard_metadata.packet_length + 32w65522); } @name("f_insert_vxlan_header") action f_insert_vxlan_header() { hdr.inner_ethernet = hdr.ethernet; - hdr.udp.setValid(true); - hdr.vxlan.setValid(true); + hdr.udp.setValid(); + hdr.vxlan.setValid(); hdr.udp.srcPort = meta.hash_metadata.entropy_hash; hdr.udp.dstPort = 16w4789; hdr.udp.checksum = 16w0; @@ -2327,7 +2327,7 @@ control process_tunnel_encap(inout headers hdr, inout metadata meta, inout stand hdr.vxlan.reserved2 = 8w0; } @name("f_insert_ipv4_header") action f_insert_ipv4_header(in bit<8> proto) { - hdr.ipv4.setValid(true); + hdr.ipv4.setValid(); hdr.ipv4.protocol = proto; hdr.ipv4.ttl = 8w64; hdr.ipv4.version = 4w0x4; @@ -2341,7 +2341,7 @@ control process_tunnel_encap(inout headers hdr, inout metadata meta, inout stand hdr.ethernet.etherType = 16w0x800; } @name("f_insert_ipv6_header") action f_insert_ipv6_header(in bit<8> proto) { - hdr.ipv6.setValid(true); + hdr.ipv6.setValid(); hdr.ipv6.version = 4w0x6; hdr.ipv6.nextHdr = proto; hdr.ipv6.hopLimit = 8w64; @@ -2356,8 +2356,8 @@ control process_tunnel_encap(inout headers hdr, inout metadata meta, inout stand } @name("f_insert_genv_header") action f_insert_genv_header() { hdr.inner_ethernet = hdr.ethernet; - hdr.udp.setValid(true); - hdr.genv.setValid(true); + hdr.udp.setValid(); + hdr.genv.setValid(); hdr.udp.srcPort = meta.hash_metadata.entropy_hash; hdr.udp.dstPort = 16w6081; hdr.udp.checksum = 16w0; @@ -2385,8 +2385,8 @@ control process_tunnel_encap(inout headers hdr, inout metadata meta, inout stand } @name("f_insert_nvgre_header") action f_insert_nvgre_header() { hdr.inner_ethernet = hdr.ethernet; - hdr.gre.setValid(true); - hdr.nvgre.setValid(true); + hdr.gre.setValid(); + hdr.nvgre.setValid(); hdr.gre.proto = 16w0x6558; hdr.gre.recurse = 3w0; hdr.gre.flags = 5w0; @@ -2412,7 +2412,7 @@ control process_tunnel_encap(inout headers hdr, inout metadata meta, inout stand hdr.ethernet.etherType = 16w0x86dd; } @name("f_insert_gre_header") action f_insert_gre_header() { - hdr.gre.setValid(true); + hdr.gre.setValid(); } @name("ipv4_gre_rewrite") action ipv4_gre_rewrite() { f_insert_gre_header(); @@ -2450,8 +2450,8 @@ control process_tunnel_encap(inout headers hdr, inout metadata meta, inout stand } @name("f_insert_erspan_t3_header") action f_insert_erspan_t3_header() { hdr.inner_ethernet = hdr.ethernet; - hdr.gre.setValid(true); - hdr.erspan_t3_header.setValid(true); + hdr.gre.setValid(); + hdr.erspan_t3_header.setValid(); hdr.gre.C = 1w0; hdr.gre.R = 1w0; hdr.gre.K = 1w0; @@ -2551,40 +2551,40 @@ control process_tunnel_encap(inout headers hdr, inout metadata meta, inout stand meta.tunnel_metadata.tunnel_dmac_index = dmac_idx; } @name("cpu_rx_rewrite") action cpu_rx_rewrite() { - hdr.fabric_header.setValid(true); + hdr.fabric_header.setValid(); hdr.fabric_header.headerVersion = 2w0; hdr.fabric_header.packetVersion = 2w0; hdr.fabric_header.pad1 = 1w0; hdr.fabric_header.packetType = 3w5; - hdr.fabric_header_cpu.setValid(true); + hdr.fabric_header_cpu.setValid(); hdr.fabric_header_cpu.ingressPort = (bit<16>)meta.ingress_metadata.ingress_port; hdr.fabric_header_cpu.ingressIfindex = meta.ingress_metadata.ifindex; hdr.fabric_header_cpu.ingressBd = meta.ingress_metadata.bd; hdr.fabric_header_cpu.reasonCode = meta.fabric_metadata.reason_code; - hdr.fabric_payload_header.setValid(true); + hdr.fabric_payload_header.setValid(); hdr.fabric_payload_header.etherType = hdr.ethernet.etherType; hdr.ethernet.etherType = 16w0x9000; } @name("fabric_unicast_rewrite") action fabric_unicast_rewrite() { - hdr.fabric_header.setValid(true); + hdr.fabric_header.setValid(); hdr.fabric_header.headerVersion = 2w0; hdr.fabric_header.packetVersion = 2w0; hdr.fabric_header.pad1 = 1w0; hdr.fabric_header.packetType = 3w1; hdr.fabric_header.dstDevice = meta.fabric_metadata.dst_device; hdr.fabric_header.dstPortOrGroup = meta.fabric_metadata.dst_port; - hdr.fabric_header_unicast.setValid(true); + hdr.fabric_header_unicast.setValid(); hdr.fabric_header_unicast.tunnelTerminate = meta.tunnel_metadata.tunnel_terminate; hdr.fabric_header_unicast.routed = meta.l3_metadata.routed; hdr.fabric_header_unicast.outerRouted = meta.l3_metadata.outer_routed; hdr.fabric_header_unicast.ingressTunnelType = meta.tunnel_metadata.ingress_tunnel_type; hdr.fabric_header_unicast.nexthopIndex = meta.l3_metadata.nexthop_index; - hdr.fabric_payload_header.setValid(true); + hdr.fabric_payload_header.setValid(); hdr.fabric_payload_header.etherType = hdr.ethernet.etherType; hdr.ethernet.etherType = 16w0x9000; } @name("fabric_multicast_rewrite") action fabric_multicast_rewrite(bit<16> fabric_mgid) { - hdr.fabric_header.setValid(true); + hdr.fabric_header.setValid(); hdr.fabric_header.headerVersion = 2w0; hdr.fabric_header.packetVersion = 2w0; hdr.fabric_header.pad1 = 1w0; @@ -2593,13 +2593,13 @@ control process_tunnel_encap(inout headers hdr, inout metadata meta, inout stand hdr.fabric_header.dstPortOrGroup = fabric_mgid; hdr.fabric_header_multicast.ingressIfindex = meta.ingress_metadata.ifindex; hdr.fabric_header_multicast.ingressBd = meta.ingress_metadata.bd; - hdr.fabric_header_multicast.setValid(true); + hdr.fabric_header_multicast.setValid(); hdr.fabric_header_multicast.tunnelTerminate = meta.tunnel_metadata.tunnel_terminate; hdr.fabric_header_multicast.routed = meta.l3_metadata.routed; hdr.fabric_header_multicast.outerRouted = meta.l3_metadata.outer_routed; hdr.fabric_header_multicast.ingressTunnelType = meta.tunnel_metadata.ingress_tunnel_type; hdr.fabric_header_multicast.mcastGrp = meta.multicast_metadata.mcast_grp; - hdr.fabric_payload_header.setValid(true); + hdr.fabric_payload_header.setValid(); hdr.fabric_payload_header.etherType = hdr.ethernet.etherType; hdr.ethernet.etherType = 16w0x9000; } @@ -2798,14 +2798,14 @@ control process_vlan_xlate(inout headers hdr, inout metadata meta, inout standar @name("set_egress_packet_vlan_untagged") action set_egress_packet_vlan_untagged() { } @name("set_egress_packet_vlan_tagged") action set_egress_packet_vlan_tagged(bit<12> vlan_id) { - hdr.vlan_tag_[0].setValid(true); + hdr.vlan_tag_[0].setValid(); hdr.vlan_tag_[0].etherType = hdr.ethernet.etherType; hdr.vlan_tag_[0].vid = vlan_id; hdr.ethernet.etherType = 16w0x8100; } @name("set_egress_packet_vlan_double_tagged") action set_egress_packet_vlan_double_tagged(bit<12> s_tag, bit<12> c_tag) { - hdr.vlan_tag_[1].setValid(true); - hdr.vlan_tag_[0].setValid(true); + hdr.vlan_tag_[1].setValid(); + hdr.vlan_tag_[0].setValid(); hdr.vlan_tag_[1].etherType = hdr.ethernet.etherType; hdr.vlan_tag_[1].vid = c_tag; hdr.vlan_tag_[0].etherType = 16w0x8100; @@ -4370,9 +4370,9 @@ control process_ingress_fabric(inout headers hdr, inout metadata meta, inout sta standard_metadata.egress_spec = (bit<9>)hdr.fabric_header.dstPortOrGroup; meta.egress_metadata.bypass = hdr.fabric_header_cpu.txBypass; hdr.ethernet.etherType = hdr.fabric_payload_header.etherType; - hdr.fabric_header.setValid(false); - hdr.fabric_header_cpu.setValid(false); - hdr.fabric_payload_header.setValid(false); + hdr.fabric_header.setInvalid(); + hdr.fabric_header_cpu.setInvalid(); + hdr.fabric_payload_header.setInvalid(); } @name("switch_fabric_unicast_packet") action switch_fabric_unicast_packet() { meta.fabric_metadata.fabric_header_present = 1w1; @@ -4387,9 +4387,9 @@ control process_ingress_fabric(inout headers hdr, inout metadata meta, inout sta meta.l3_metadata.routed = hdr.fabric_header_unicast.routed; meta.l3_metadata.outer_routed = hdr.fabric_header_unicast.outerRouted; hdr.ethernet.etherType = hdr.fabric_payload_header.etherType; - hdr.fabric_header.setValid(false); - hdr.fabric_header_unicast.setValid(false); - hdr.fabric_payload_header.setValid(false); + hdr.fabric_header.setInvalid(); + hdr.fabric_header_unicast.setInvalid(); + hdr.fabric_payload_header.setInvalid(); } @name("switch_fabric_multicast_packet") action switch_fabric_multicast_packet() { meta.fabric_metadata.fabric_header_present = 1w1; @@ -4403,9 +4403,9 @@ control process_ingress_fabric(inout headers hdr, inout metadata meta, inout sta meta.l3_metadata.outer_routed = hdr.fabric_header_multicast.outerRouted; meta.intrinsic_metadata.mcast_grp = hdr.fabric_header_multicast.mcastGrp; hdr.ethernet.etherType = hdr.fabric_payload_header.etherType; - hdr.fabric_header.setValid(false); - hdr.fabric_header_multicast.setValid(false); - hdr.fabric_payload_header.setValid(false); + hdr.fabric_header.setInvalid(); + hdr.fabric_header_multicast.setInvalid(); + hdr.fabric_payload_header.setInvalid(); } @name("set_ingress_ifindex_properties") action set_ingress_ifindex_properties() { } diff --git a/testdata/v1_samples_outputs/switch-FrontEnd_12_RemoveAllUnusedDeclarations.p4 b/testdata/v1_samples_outputs/switch-FrontEnd_12_RemoveAllUnusedDeclarations.p4 index fb1d0e68248..49b086bee0c 100644 --- a/testdata/v1_samples_outputs/switch-FrontEnd_12_RemoveAllUnusedDeclarations.p4 +++ b/testdata/v1_samples_outputs/switch-FrontEnd_12_RemoveAllUnusedDeclarations.p4 @@ -1335,12 +1335,12 @@ control process_vlan_decap(inout headers hdr, inout metadata meta, inout standar } @name("remove_vlan_single_tagged") action remove_vlan_single_tagged() { hdr.ethernet.etherType = hdr.vlan_tag_[0].etherType; - hdr.vlan_tag_[0].setValid(false); + hdr.vlan_tag_[0].setInvalid(); } @name("remove_vlan_double_tagged") action remove_vlan_double_tagged() { hdr.ethernet.etherType = hdr.vlan_tag_[1].etherType; - hdr.vlan_tag_[0].setValid(false); - hdr.vlan_tag_[1].setValid(false); + hdr.vlan_tag_[0].setInvalid(); + hdr.vlan_tag_[1].setInvalid(); } @name("vlan_decap") table vlan_decap() { actions = { @@ -1364,211 +1364,211 @@ control process_vlan_decap(inout headers hdr, inout metadata meta, inout standar control process_tunnel_decap(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("decap_inner_udp") action decap_inner_udp() { hdr.udp = hdr.inner_udp; - hdr.inner_udp.setValid(false); + hdr.inner_udp.setInvalid(); } @name("decap_inner_tcp") action decap_inner_tcp() { hdr.tcp = hdr.inner_tcp; - hdr.inner_tcp.setValid(false); - hdr.udp.setValid(false); + hdr.inner_tcp.setInvalid(); + hdr.udp.setInvalid(); } @name("decap_inner_icmp") action decap_inner_icmp() { hdr.icmp = hdr.inner_icmp; - hdr.inner_icmp.setValid(false); - hdr.udp.setValid(false); + hdr.inner_icmp.setInvalid(); + hdr.udp.setInvalid(); } @name("decap_inner_unknown") action decap_inner_unknown() { - hdr.udp.setValid(false); + hdr.udp.setInvalid(); } @name("decap_vxlan_inner_ipv4") action decap_vxlan_inner_ipv4() { hdr.ethernet = hdr.inner_ethernet; hdr.ipv4 = hdr.inner_ipv4; - hdr.vxlan.setValid(false); - hdr.ipv6.setValid(false); - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv4.setValid(false); + hdr.vxlan.setInvalid(); + hdr.ipv6.setInvalid(); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv4.setInvalid(); } @name("decap_vxlan_inner_ipv6") action decap_vxlan_inner_ipv6() { hdr.ethernet = hdr.inner_ethernet; hdr.ipv6 = hdr.inner_ipv6; - hdr.vxlan.setValid(false); - hdr.ipv4.setValid(false); - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv6.setValid(false); + hdr.vxlan.setInvalid(); + hdr.ipv4.setInvalid(); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv6.setInvalid(); } @name("decap_vxlan_inner_non_ip") action decap_vxlan_inner_non_ip() { hdr.ethernet = hdr.inner_ethernet; - hdr.vxlan.setValid(false); - hdr.ipv4.setValid(false); - hdr.ipv6.setValid(false); + hdr.vxlan.setInvalid(); + hdr.ipv4.setInvalid(); + hdr.ipv6.setInvalid(); } @name("decap_genv_inner_ipv4") action decap_genv_inner_ipv4() { hdr.ethernet = hdr.inner_ethernet; hdr.ipv4 = hdr.inner_ipv4; - hdr.genv.setValid(false); - hdr.ipv6.setValid(false); - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv4.setValid(false); + hdr.genv.setInvalid(); + hdr.ipv6.setInvalid(); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv4.setInvalid(); } @name("decap_genv_inner_ipv6") action decap_genv_inner_ipv6() { hdr.ethernet = hdr.inner_ethernet; hdr.ipv6 = hdr.inner_ipv6; - hdr.genv.setValid(false); - hdr.ipv4.setValid(false); - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv6.setValid(false); + hdr.genv.setInvalid(); + hdr.ipv4.setInvalid(); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv6.setInvalid(); } @name("decap_genv_inner_non_ip") action decap_genv_inner_non_ip() { hdr.ethernet = hdr.inner_ethernet; - hdr.genv.setValid(false); - hdr.ipv4.setValid(false); - hdr.ipv6.setValid(false); + hdr.genv.setInvalid(); + hdr.ipv4.setInvalid(); + hdr.ipv6.setInvalid(); } @name("decap_nvgre_inner_ipv4") action decap_nvgre_inner_ipv4() { hdr.ethernet = hdr.inner_ethernet; hdr.ipv4 = hdr.inner_ipv4; - hdr.nvgre.setValid(false); - hdr.gre.setValid(false); - hdr.ipv6.setValid(false); - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv4.setValid(false); + hdr.nvgre.setInvalid(); + hdr.gre.setInvalid(); + hdr.ipv6.setInvalid(); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv4.setInvalid(); } @name("decap_nvgre_inner_ipv6") action decap_nvgre_inner_ipv6() { hdr.ethernet = hdr.inner_ethernet; hdr.ipv6 = hdr.inner_ipv6; - hdr.nvgre.setValid(false); - hdr.gre.setValid(false); - hdr.ipv4.setValid(false); - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv6.setValid(false); + hdr.nvgre.setInvalid(); + hdr.gre.setInvalid(); + hdr.ipv4.setInvalid(); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv6.setInvalid(); } @name("decap_nvgre_inner_non_ip") action decap_nvgre_inner_non_ip() { hdr.ethernet = hdr.inner_ethernet; - hdr.nvgre.setValid(false); - hdr.gre.setValid(false); - hdr.ipv4.setValid(false); - hdr.ipv6.setValid(false); + hdr.nvgre.setInvalid(); + hdr.gre.setInvalid(); + hdr.ipv4.setInvalid(); + hdr.ipv6.setInvalid(); } @name("decap_ip_inner_ipv4") action decap_ip_inner_ipv4() { hdr.ipv4 = hdr.inner_ipv4; - hdr.gre.setValid(false); - hdr.ipv6.setValid(false); - hdr.inner_ipv4.setValid(false); + hdr.gre.setInvalid(); + hdr.ipv6.setInvalid(); + hdr.inner_ipv4.setInvalid(); hdr.ethernet.etherType = 16w0x800; } @name("decap_ip_inner_ipv6") action decap_ip_inner_ipv6() { hdr.ipv6 = hdr.inner_ipv6; - hdr.gre.setValid(false); - hdr.ipv4.setValid(false); - hdr.inner_ipv6.setValid(false); + hdr.gre.setInvalid(); + hdr.ipv4.setInvalid(); + hdr.inner_ipv6.setInvalid(); hdr.ethernet.etherType = 16w0x86dd; } @name("decap_mpls_inner_ipv4_pop1") action decap_mpls_inner_ipv4_pop1() { - hdr.mpls[0].setValid(false); + hdr.mpls[0].setInvalid(); hdr.ipv4 = hdr.inner_ipv4; - hdr.inner_ipv4.setValid(false); + hdr.inner_ipv4.setInvalid(); hdr.ethernet.etherType = 16w0x800; } @name("decap_mpls_inner_ipv6_pop1") action decap_mpls_inner_ipv6_pop1() { - hdr.mpls[0].setValid(false); + hdr.mpls[0].setInvalid(); hdr.ipv6 = hdr.inner_ipv6; - hdr.inner_ipv6.setValid(false); + hdr.inner_ipv6.setInvalid(); hdr.ethernet.etherType = 16w0x86dd; } @name("decap_mpls_inner_ethernet_ipv4_pop1") action decap_mpls_inner_ethernet_ipv4_pop1() { - hdr.mpls[0].setValid(false); + hdr.mpls[0].setInvalid(); hdr.ethernet = hdr.inner_ethernet; hdr.ipv4 = hdr.inner_ipv4; - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv4.setValid(false); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv4.setInvalid(); } @name("decap_mpls_inner_ethernet_ipv6_pop1") action decap_mpls_inner_ethernet_ipv6_pop1() { - hdr.mpls[0].setValid(false); + hdr.mpls[0].setInvalid(); hdr.ethernet = hdr.inner_ethernet; hdr.ipv6 = hdr.inner_ipv6; - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv6.setValid(false); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv6.setInvalid(); } @name("decap_mpls_inner_ethernet_non_ip_pop1") action decap_mpls_inner_ethernet_non_ip_pop1() { - hdr.mpls[0].setValid(false); + hdr.mpls[0].setInvalid(); hdr.ethernet = hdr.inner_ethernet; - hdr.inner_ethernet.setValid(false); + hdr.inner_ethernet.setInvalid(); } @name("decap_mpls_inner_ipv4_pop2") action decap_mpls_inner_ipv4_pop2() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); hdr.ipv4 = hdr.inner_ipv4; - hdr.inner_ipv4.setValid(false); + hdr.inner_ipv4.setInvalid(); hdr.ethernet.etherType = 16w0x800; } @name("decap_mpls_inner_ipv6_pop2") action decap_mpls_inner_ipv6_pop2() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); hdr.ipv6 = hdr.inner_ipv6; - hdr.inner_ipv6.setValid(false); + hdr.inner_ipv6.setInvalid(); hdr.ethernet.etherType = 16w0x86dd; } @name("decap_mpls_inner_ethernet_ipv4_pop2") action decap_mpls_inner_ethernet_ipv4_pop2() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); hdr.ethernet = hdr.inner_ethernet; hdr.ipv4 = hdr.inner_ipv4; - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv4.setValid(false); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv4.setInvalid(); } @name("decap_mpls_inner_ethernet_ipv6_pop2") action decap_mpls_inner_ethernet_ipv6_pop2() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); hdr.ethernet = hdr.inner_ethernet; hdr.ipv6 = hdr.inner_ipv6; - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv6.setValid(false); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv6.setInvalid(); } @name("decap_mpls_inner_ethernet_non_ip_pop2") action decap_mpls_inner_ethernet_non_ip_pop2() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); hdr.ethernet = hdr.inner_ethernet; - hdr.inner_ethernet.setValid(false); + hdr.inner_ethernet.setInvalid(); } @name("decap_mpls_inner_ipv4_pop3") action decap_mpls_inner_ipv4_pop3() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); - hdr.mpls[2].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); + hdr.mpls[2].setInvalid(); hdr.ipv4 = hdr.inner_ipv4; - hdr.inner_ipv4.setValid(false); + hdr.inner_ipv4.setInvalid(); hdr.ethernet.etherType = 16w0x800; } @name("decap_mpls_inner_ipv6_pop3") action decap_mpls_inner_ipv6_pop3() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); - hdr.mpls[2].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); + hdr.mpls[2].setInvalid(); hdr.ipv6 = hdr.inner_ipv6; - hdr.inner_ipv6.setValid(false); + hdr.inner_ipv6.setInvalid(); hdr.ethernet.etherType = 16w0x86dd; } @name("decap_mpls_inner_ethernet_ipv4_pop3") action decap_mpls_inner_ethernet_ipv4_pop3() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); - hdr.mpls[2].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); + hdr.mpls[2].setInvalid(); hdr.ethernet = hdr.inner_ethernet; hdr.ipv4 = hdr.inner_ipv4; - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv4.setValid(false); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv4.setInvalid(); } @name("decap_mpls_inner_ethernet_ipv6_pop3") action decap_mpls_inner_ethernet_ipv6_pop3() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); - hdr.mpls[2].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); + hdr.mpls[2].setInvalid(); hdr.ethernet = hdr.inner_ethernet; hdr.ipv6 = hdr.inner_ipv6; - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv6.setValid(false); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv6.setInvalid(); } @name("decap_mpls_inner_ethernet_non_ip_pop3") action decap_mpls_inner_ethernet_non_ip_pop3() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); - hdr.mpls[2].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); + hdr.mpls[2].setInvalid(); hdr.ethernet = hdr.inner_ethernet; - hdr.inner_ethernet.setValid(false); + hdr.inner_ethernet.setInvalid(); } @name("tunnel_decap_process_inner") table tunnel_decap_process_inner() { actions = { @@ -1789,14 +1789,14 @@ control process_int_insertion(inout headers hdr, inout metadata meta, inout stan @name("int_set_header_0003_i0") action int_set_header_0003_i0() { } @name("int_set_header_3") action int_set_header_3() { - hdr.int_q_occupancy_header.setValid(true); + hdr.int_q_occupancy_header.setValid(); hdr.int_q_occupancy_header.q_occupancy = (bit<31>)meta.intrinsic_metadata.enq_qdepth; } @name("int_set_header_0003_i1") action int_set_header_0003_i1() { int_set_header_3(); } @name("int_set_header_2") action int_set_header_2() { - hdr.int_hop_latency_header.setValid(true); + hdr.int_hop_latency_header.setValid(); hdr.int_hop_latency_header.hop_latency = (bit<31>)meta.intrinsic_metadata.deq_timedelta; } @name("int_set_header_0003_i2") action int_set_header_0003_i2() { @@ -1807,7 +1807,7 @@ control process_int_insertion(inout headers hdr, inout metadata meta, inout stan int_set_header_2(); } @name("int_set_header_1") action int_set_header_1() { - hdr.int_ingress_port_id_header.setValid(true); + hdr.int_ingress_port_id_header.setValid(); hdr.int_ingress_port_id_header.ingress_port_id = (bit<31>)meta.ingress_metadata.ifindex; } @name("int_set_header_0003_i4") action int_set_header_0003_i4() { @@ -1827,7 +1827,7 @@ control process_int_insertion(inout headers hdr, inout metadata meta, inout stan int_set_header_1(); } @name("int_set_header_0") action int_set_header_0() { - hdr.int_switch_id_header.setValid(true); + hdr.int_switch_id_header.setValid(); hdr.int_switch_id_header.switch_id = (bit<31>)meta.int_metadata.switch_id; } @name("int_set_header_0003_i8") action int_set_header_0003_i8() { @@ -1869,14 +1869,14 @@ control process_int_insertion(inout headers hdr, inout metadata meta, inout stan @name("int_set_header_0407_i0") action int_set_header_0407_i0() { } @name("int_set_header_7") action int_set_header_7() { - hdr.int_egress_port_tx_utilization_header.setValid(true); + hdr.int_egress_port_tx_utilization_header.setValid(); hdr.int_egress_port_tx_utilization_header.egress_port_tx_utilization = 31w0x7fffffff; } @name("int_set_header_0407_i1") action int_set_header_0407_i1() { int_set_header_7(); } @name("int_set_header_6") action int_set_header_6() { - hdr.int_q_congestion_header.setValid(true); + hdr.int_q_congestion_header.setValid(); hdr.int_q_congestion_header.q_congestion = 31w0x7fffffff; } @name("int_set_header_0407_i2") action int_set_header_0407_i2() { @@ -1887,7 +1887,7 @@ control process_int_insertion(inout headers hdr, inout metadata meta, inout stan int_set_header_6(); } @name("int_set_header_5") action int_set_header_5() { - hdr.int_egress_port_id_header.setValid(true); + hdr.int_egress_port_id_header.setValid(); hdr.int_egress_port_id_header.egress_port_id = (bit<31>)standard_metadata.egress_port; } @name("int_set_header_0407_i4") action int_set_header_0407_i4() { @@ -1907,7 +1907,7 @@ control process_int_insertion(inout headers hdr, inout metadata meta, inout stan int_set_header_5(); } @name("int_set_header_4") action int_set_header_4() { - hdr.int_ingress_tstamp_header.setValid(true); + hdr.int_ingress_tstamp_header.setValid(); hdr.int_ingress_tstamp_header.ingress_tstamp = (bit<31>)meta.i2e_metadata.ingress_tstamp; } @name("int_set_header_0407_i8") action int_set_header_0407_i8() { @@ -2164,60 +2164,60 @@ control process_tunnel_encap(inout headers hdr, inout metadata meta, inout stand hdr.inner_ipv4 = hdr.ipv4; hdr.inner_udp = hdr.udp; meta.egress_metadata.payload_length = hdr.ipv4.totalLen; - hdr.udp.setValid(false); - hdr.ipv4.setValid(false); + hdr.udp.setInvalid(); + hdr.ipv4.setInvalid(); } @name("inner_ipv4_tcp_rewrite") action inner_ipv4_tcp_rewrite() { hdr.inner_ipv4 = hdr.ipv4; hdr.inner_tcp = hdr.tcp; meta.egress_metadata.payload_length = hdr.ipv4.totalLen; - hdr.tcp.setValid(false); - hdr.ipv4.setValid(false); + hdr.tcp.setInvalid(); + hdr.ipv4.setInvalid(); } @name("inner_ipv4_icmp_rewrite") action inner_ipv4_icmp_rewrite() { hdr.inner_ipv4 = hdr.ipv4; hdr.inner_icmp = hdr.icmp; meta.egress_metadata.payload_length = hdr.ipv4.totalLen; - hdr.icmp.setValid(false); - hdr.ipv4.setValid(false); + hdr.icmp.setInvalid(); + hdr.ipv4.setInvalid(); } @name("inner_ipv4_unknown_rewrite") action inner_ipv4_unknown_rewrite() { hdr.inner_ipv4 = hdr.ipv4; meta.egress_metadata.payload_length = hdr.ipv4.totalLen; - hdr.ipv4.setValid(false); + hdr.ipv4.setInvalid(); } @name("inner_ipv6_udp_rewrite") action inner_ipv6_udp_rewrite() { hdr.inner_ipv6 = hdr.ipv6; hdr.inner_udp = hdr.udp; meta.egress_metadata.payload_length = hdr.ipv6.payloadLen + 16w40; - hdr.ipv6.setValid(false); + hdr.ipv6.setInvalid(); } @name("inner_ipv6_tcp_rewrite") action inner_ipv6_tcp_rewrite() { hdr.inner_ipv6 = hdr.ipv6; hdr.inner_tcp = hdr.tcp; meta.egress_metadata.payload_length = hdr.ipv6.payloadLen + 16w40; - hdr.tcp.setValid(false); - hdr.ipv6.setValid(false); + hdr.tcp.setInvalid(); + hdr.ipv6.setInvalid(); } @name("inner_ipv6_icmp_rewrite") action inner_ipv6_icmp_rewrite() { hdr.inner_ipv6 = hdr.ipv6; hdr.inner_icmp = hdr.icmp; meta.egress_metadata.payload_length = hdr.ipv6.payloadLen + 16w40; - hdr.icmp.setValid(false); - hdr.ipv6.setValid(false); + hdr.icmp.setInvalid(); + hdr.ipv6.setInvalid(); } @name("inner_ipv6_unknown_rewrite") action inner_ipv6_unknown_rewrite() { hdr.inner_ipv6 = hdr.ipv6; meta.egress_metadata.payload_length = hdr.ipv6.payloadLen + 16w40; - hdr.ipv6.setValid(false); + hdr.ipv6.setInvalid(); } @name("inner_non_ip_rewrite") action inner_non_ip_rewrite() { meta.egress_metadata.payload_length = (bit<16>)(standard_metadata.packet_length + 32w65522); } @name("f_insert_vxlan_header") action f_insert_vxlan_header() { hdr.inner_ethernet = hdr.ethernet; - hdr.udp.setValid(true); - hdr.vxlan.setValid(true); + hdr.udp.setValid(); + hdr.vxlan.setValid(); hdr.udp.srcPort = meta.hash_metadata.entropy_hash; hdr.udp.dstPort = 16w4789; hdr.udp.checksum = 16w0; @@ -2228,7 +2228,7 @@ control process_tunnel_encap(inout headers hdr, inout metadata meta, inout stand hdr.vxlan.reserved2 = 8w0; } @name("f_insert_ipv4_header") action f_insert_ipv4_header(in bit<8> proto) { - hdr.ipv4.setValid(true); + hdr.ipv4.setValid(); hdr.ipv4.protocol = proto; hdr.ipv4.ttl = 8w64; hdr.ipv4.version = 4w0x4; @@ -2242,7 +2242,7 @@ control process_tunnel_encap(inout headers hdr, inout metadata meta, inout stand hdr.ethernet.etherType = 16w0x800; } @name("f_insert_ipv6_header") action f_insert_ipv6_header(in bit<8> proto) { - hdr.ipv6.setValid(true); + hdr.ipv6.setValid(); hdr.ipv6.version = 4w0x6; hdr.ipv6.nextHdr = proto; hdr.ipv6.hopLimit = 8w64; @@ -2257,8 +2257,8 @@ control process_tunnel_encap(inout headers hdr, inout metadata meta, inout stand } @name("f_insert_genv_header") action f_insert_genv_header() { hdr.inner_ethernet = hdr.ethernet; - hdr.udp.setValid(true); - hdr.genv.setValid(true); + hdr.udp.setValid(); + hdr.genv.setValid(); hdr.udp.srcPort = meta.hash_metadata.entropy_hash; hdr.udp.dstPort = 16w6081; hdr.udp.checksum = 16w0; @@ -2286,8 +2286,8 @@ control process_tunnel_encap(inout headers hdr, inout metadata meta, inout stand } @name("f_insert_nvgre_header") action f_insert_nvgre_header() { hdr.inner_ethernet = hdr.ethernet; - hdr.gre.setValid(true); - hdr.nvgre.setValid(true); + hdr.gre.setValid(); + hdr.nvgre.setValid(); hdr.gre.proto = 16w0x6558; hdr.gre.recurse = 3w0; hdr.gre.flags = 5w0; @@ -2313,7 +2313,7 @@ control process_tunnel_encap(inout headers hdr, inout metadata meta, inout stand hdr.ethernet.etherType = 16w0x86dd; } @name("f_insert_gre_header") action f_insert_gre_header() { - hdr.gre.setValid(true); + hdr.gre.setValid(); } @name("ipv4_gre_rewrite") action ipv4_gre_rewrite() { f_insert_gre_header(); @@ -2351,8 +2351,8 @@ control process_tunnel_encap(inout headers hdr, inout metadata meta, inout stand } @name("f_insert_erspan_t3_header") action f_insert_erspan_t3_header() { hdr.inner_ethernet = hdr.ethernet; - hdr.gre.setValid(true); - hdr.erspan_t3_header.setValid(true); + hdr.gre.setValid(); + hdr.erspan_t3_header.setValid(); hdr.gre.C = 1w0; hdr.gre.R = 1w0; hdr.gre.K = 1w0; @@ -2452,40 +2452,40 @@ control process_tunnel_encap(inout headers hdr, inout metadata meta, inout stand meta.tunnel_metadata.tunnel_dmac_index = dmac_idx; } @name("cpu_rx_rewrite") action cpu_rx_rewrite() { - hdr.fabric_header.setValid(true); + hdr.fabric_header.setValid(); hdr.fabric_header.headerVersion = 2w0; hdr.fabric_header.packetVersion = 2w0; hdr.fabric_header.pad1 = 1w0; hdr.fabric_header.packetType = 3w5; - hdr.fabric_header_cpu.setValid(true); + hdr.fabric_header_cpu.setValid(); hdr.fabric_header_cpu.ingressPort = (bit<16>)meta.ingress_metadata.ingress_port; hdr.fabric_header_cpu.ingressIfindex = meta.ingress_metadata.ifindex; hdr.fabric_header_cpu.ingressBd = meta.ingress_metadata.bd; hdr.fabric_header_cpu.reasonCode = meta.fabric_metadata.reason_code; - hdr.fabric_payload_header.setValid(true); + hdr.fabric_payload_header.setValid(); hdr.fabric_payload_header.etherType = hdr.ethernet.etherType; hdr.ethernet.etherType = 16w0x9000; } @name("fabric_unicast_rewrite") action fabric_unicast_rewrite() { - hdr.fabric_header.setValid(true); + hdr.fabric_header.setValid(); hdr.fabric_header.headerVersion = 2w0; hdr.fabric_header.packetVersion = 2w0; hdr.fabric_header.pad1 = 1w0; hdr.fabric_header.packetType = 3w1; hdr.fabric_header.dstDevice = meta.fabric_metadata.dst_device; hdr.fabric_header.dstPortOrGroup = meta.fabric_metadata.dst_port; - hdr.fabric_header_unicast.setValid(true); + hdr.fabric_header_unicast.setValid(); hdr.fabric_header_unicast.tunnelTerminate = meta.tunnel_metadata.tunnel_terminate; hdr.fabric_header_unicast.routed = meta.l3_metadata.routed; hdr.fabric_header_unicast.outerRouted = meta.l3_metadata.outer_routed; hdr.fabric_header_unicast.ingressTunnelType = meta.tunnel_metadata.ingress_tunnel_type; hdr.fabric_header_unicast.nexthopIndex = meta.l3_metadata.nexthop_index; - hdr.fabric_payload_header.setValid(true); + hdr.fabric_payload_header.setValid(); hdr.fabric_payload_header.etherType = hdr.ethernet.etherType; hdr.ethernet.etherType = 16w0x9000; } @name("fabric_multicast_rewrite") action fabric_multicast_rewrite(bit<16> fabric_mgid) { - hdr.fabric_header.setValid(true); + hdr.fabric_header.setValid(); hdr.fabric_header.headerVersion = 2w0; hdr.fabric_header.packetVersion = 2w0; hdr.fabric_header.pad1 = 1w0; @@ -2494,13 +2494,13 @@ control process_tunnel_encap(inout headers hdr, inout metadata meta, inout stand hdr.fabric_header.dstPortOrGroup = fabric_mgid; hdr.fabric_header_multicast.ingressIfindex = meta.ingress_metadata.ifindex; hdr.fabric_header_multicast.ingressBd = meta.ingress_metadata.bd; - hdr.fabric_header_multicast.setValid(true); + hdr.fabric_header_multicast.setValid(); hdr.fabric_header_multicast.tunnelTerminate = meta.tunnel_metadata.tunnel_terminate; hdr.fabric_header_multicast.routed = meta.l3_metadata.routed; hdr.fabric_header_multicast.outerRouted = meta.l3_metadata.outer_routed; hdr.fabric_header_multicast.ingressTunnelType = meta.tunnel_metadata.ingress_tunnel_type; hdr.fabric_header_multicast.mcastGrp = meta.multicast_metadata.mcast_grp; - hdr.fabric_payload_header.setValid(true); + hdr.fabric_payload_header.setValid(); hdr.fabric_payload_header.etherType = hdr.ethernet.etherType; hdr.ethernet.etherType = 16w0x9000; } @@ -2699,14 +2699,14 @@ control process_vlan_xlate(inout headers hdr, inout metadata meta, inout standar @name("set_egress_packet_vlan_untagged") action set_egress_packet_vlan_untagged() { } @name("set_egress_packet_vlan_tagged") action set_egress_packet_vlan_tagged(bit<12> vlan_id) { - hdr.vlan_tag_[0].setValid(true); + hdr.vlan_tag_[0].setValid(); hdr.vlan_tag_[0].etherType = hdr.ethernet.etherType; hdr.vlan_tag_[0].vid = vlan_id; hdr.ethernet.etherType = 16w0x8100; } @name("set_egress_packet_vlan_double_tagged") action set_egress_packet_vlan_double_tagged(bit<12> s_tag, bit<12> c_tag) { - hdr.vlan_tag_[1].setValid(true); - hdr.vlan_tag_[0].setValid(true); + hdr.vlan_tag_[1].setValid(); + hdr.vlan_tag_[0].setValid(); hdr.vlan_tag_[1].etherType = hdr.ethernet.etherType; hdr.vlan_tag_[1].vid = c_tag; hdr.vlan_tag_[0].etherType = 16w0x8100; @@ -4271,9 +4271,9 @@ control process_ingress_fabric(inout headers hdr, inout metadata meta, inout sta standard_metadata.egress_spec = (bit<9>)hdr.fabric_header.dstPortOrGroup; meta.egress_metadata.bypass = hdr.fabric_header_cpu.txBypass; hdr.ethernet.etherType = hdr.fabric_payload_header.etherType; - hdr.fabric_header.setValid(false); - hdr.fabric_header_cpu.setValid(false); - hdr.fabric_payload_header.setValid(false); + hdr.fabric_header.setInvalid(); + hdr.fabric_header_cpu.setInvalid(); + hdr.fabric_payload_header.setInvalid(); } @name("switch_fabric_unicast_packet") action switch_fabric_unicast_packet() { meta.fabric_metadata.fabric_header_present = 1w1; @@ -4288,9 +4288,9 @@ control process_ingress_fabric(inout headers hdr, inout metadata meta, inout sta meta.l3_metadata.routed = hdr.fabric_header_unicast.routed; meta.l3_metadata.outer_routed = hdr.fabric_header_unicast.outerRouted; hdr.ethernet.etherType = hdr.fabric_payload_header.etherType; - hdr.fabric_header.setValid(false); - hdr.fabric_header_unicast.setValid(false); - hdr.fabric_payload_header.setValid(false); + hdr.fabric_header.setInvalid(); + hdr.fabric_header_unicast.setInvalid(); + hdr.fabric_payload_header.setInvalid(); } @name("switch_fabric_multicast_packet") action switch_fabric_multicast_packet() { meta.fabric_metadata.fabric_header_present = 1w1; @@ -4304,9 +4304,9 @@ control process_ingress_fabric(inout headers hdr, inout metadata meta, inout sta meta.l3_metadata.outer_routed = hdr.fabric_header_multicast.outerRouted; meta.intrinsic_metadata.mcast_grp = hdr.fabric_header_multicast.mcastGrp; hdr.ethernet.etherType = hdr.fabric_payload_header.etherType; - hdr.fabric_header.setValid(false); - hdr.fabric_header_multicast.setValid(false); - hdr.fabric_payload_header.setValid(false); + hdr.fabric_header.setInvalid(); + hdr.fabric_header_multicast.setInvalid(); + hdr.fabric_payload_header.setInvalid(); } @name("set_ingress_ifindex_properties") action set_ingress_ifindex_properties() { } diff --git a/testdata/v1_samples_outputs/switch-MidEnd_25_Evaluator.p4 b/testdata/v1_samples_outputs/switch-MidEnd_25_Evaluator.p4 index 32054613725..0ab2b1a90c5 100644 --- a/testdata/v1_samples_outputs/switch-MidEnd_25_Evaluator.p4 +++ b/testdata/v1_samples_outputs/switch-MidEnd_25_Evaluator.p4 @@ -1467,12 +1467,12 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } @name("process_vlan_decap.remove_vlan_single_tagged") action process_vlan_decap_remove_vlan_single_tagged() { hdr_8.ethernet.etherType = hdr_8.vlan_tag_[0].etherType; - hdr_8.vlan_tag_[0].setValid(false); + hdr_8.vlan_tag_[0].setInvalid(); } @name("process_vlan_decap.remove_vlan_double_tagged") action process_vlan_decap_remove_vlan_double_tagged() { hdr_8.ethernet.etherType = hdr_8.vlan_tag_[1].etherType; - hdr_8.vlan_tag_[0].setValid(false); - hdr_8.vlan_tag_[1].setValid(false); + hdr_8.vlan_tag_[0].setInvalid(); + hdr_8.vlan_tag_[1].setInvalid(); } @name("process_vlan_decap.vlan_decap") table process_vlan_decap_vlan_decap() { actions = { @@ -1490,211 +1490,211 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } @name("process_tunnel_decap.decap_inner_udp") action process_tunnel_decap_decap_inner_udp() { hdr_9.udp = hdr_9.inner_udp; - hdr_9.inner_udp.setValid(false); + hdr_9.inner_udp.setInvalid(); } @name("process_tunnel_decap.decap_inner_tcp") action process_tunnel_decap_decap_inner_tcp() { hdr_9.tcp = hdr_9.inner_tcp; - hdr_9.inner_tcp.setValid(false); - hdr_9.udp.setValid(false); + hdr_9.inner_tcp.setInvalid(); + hdr_9.udp.setInvalid(); } @name("process_tunnel_decap.decap_inner_icmp") action process_tunnel_decap_decap_inner_icmp() { hdr_9.icmp = hdr_9.inner_icmp; - hdr_9.inner_icmp.setValid(false); - hdr_9.udp.setValid(false); + hdr_9.inner_icmp.setInvalid(); + hdr_9.udp.setInvalid(); } @name("process_tunnel_decap.decap_inner_unknown") action process_tunnel_decap_decap_inner_unknown() { - hdr_9.udp.setValid(false); + hdr_9.udp.setInvalid(); } @name("process_tunnel_decap.decap_vxlan_inner_ipv4") action process_tunnel_decap_decap_vxlan_inner_ipv4() { hdr_9.ethernet = hdr_9.inner_ethernet; hdr_9.ipv4 = hdr_9.inner_ipv4; - hdr_9.vxlan.setValid(false); - hdr_9.ipv6.setValid(false); - hdr_9.inner_ethernet.setValid(false); - hdr_9.inner_ipv4.setValid(false); + hdr_9.vxlan.setInvalid(); + hdr_9.ipv6.setInvalid(); + hdr_9.inner_ethernet.setInvalid(); + hdr_9.inner_ipv4.setInvalid(); } @name("process_tunnel_decap.decap_vxlan_inner_ipv6") action process_tunnel_decap_decap_vxlan_inner_ipv6() { hdr_9.ethernet = hdr_9.inner_ethernet; hdr_9.ipv6 = hdr_9.inner_ipv6; - hdr_9.vxlan.setValid(false); - hdr_9.ipv4.setValid(false); - hdr_9.inner_ethernet.setValid(false); - hdr_9.inner_ipv6.setValid(false); + hdr_9.vxlan.setInvalid(); + hdr_9.ipv4.setInvalid(); + hdr_9.inner_ethernet.setInvalid(); + hdr_9.inner_ipv6.setInvalid(); } @name("process_tunnel_decap.decap_vxlan_inner_non_ip") action process_tunnel_decap_decap_vxlan_inner_non_ip() { hdr_9.ethernet = hdr_9.inner_ethernet; - hdr_9.vxlan.setValid(false); - hdr_9.ipv4.setValid(false); - hdr_9.ipv6.setValid(false); + hdr_9.vxlan.setInvalid(); + hdr_9.ipv4.setInvalid(); + hdr_9.ipv6.setInvalid(); } @name("process_tunnel_decap.decap_genv_inner_ipv4") action process_tunnel_decap_decap_genv_inner_ipv4() { hdr_9.ethernet = hdr_9.inner_ethernet; hdr_9.ipv4 = hdr_9.inner_ipv4; - hdr_9.genv.setValid(false); - hdr_9.ipv6.setValid(false); - hdr_9.inner_ethernet.setValid(false); - hdr_9.inner_ipv4.setValid(false); + hdr_9.genv.setInvalid(); + hdr_9.ipv6.setInvalid(); + hdr_9.inner_ethernet.setInvalid(); + hdr_9.inner_ipv4.setInvalid(); } @name("process_tunnel_decap.decap_genv_inner_ipv6") action process_tunnel_decap_decap_genv_inner_ipv6() { hdr_9.ethernet = hdr_9.inner_ethernet; hdr_9.ipv6 = hdr_9.inner_ipv6; - hdr_9.genv.setValid(false); - hdr_9.ipv4.setValid(false); - hdr_9.inner_ethernet.setValid(false); - hdr_9.inner_ipv6.setValid(false); + hdr_9.genv.setInvalid(); + hdr_9.ipv4.setInvalid(); + hdr_9.inner_ethernet.setInvalid(); + hdr_9.inner_ipv6.setInvalid(); } @name("process_tunnel_decap.decap_genv_inner_non_ip") action process_tunnel_decap_decap_genv_inner_non_ip() { hdr_9.ethernet = hdr_9.inner_ethernet; - hdr_9.genv.setValid(false); - hdr_9.ipv4.setValid(false); - hdr_9.ipv6.setValid(false); + hdr_9.genv.setInvalid(); + hdr_9.ipv4.setInvalid(); + hdr_9.ipv6.setInvalid(); } @name("process_tunnel_decap.decap_nvgre_inner_ipv4") action process_tunnel_decap_decap_nvgre_inner_ipv4() { hdr_9.ethernet = hdr_9.inner_ethernet; hdr_9.ipv4 = hdr_9.inner_ipv4; - hdr_9.nvgre.setValid(false); - hdr_9.gre.setValid(false); - hdr_9.ipv6.setValid(false); - hdr_9.inner_ethernet.setValid(false); - hdr_9.inner_ipv4.setValid(false); + hdr_9.nvgre.setInvalid(); + hdr_9.gre.setInvalid(); + hdr_9.ipv6.setInvalid(); + hdr_9.inner_ethernet.setInvalid(); + hdr_9.inner_ipv4.setInvalid(); } @name("process_tunnel_decap.decap_nvgre_inner_ipv6") action process_tunnel_decap_decap_nvgre_inner_ipv6() { hdr_9.ethernet = hdr_9.inner_ethernet; hdr_9.ipv6 = hdr_9.inner_ipv6; - hdr_9.nvgre.setValid(false); - hdr_9.gre.setValid(false); - hdr_9.ipv4.setValid(false); - hdr_9.inner_ethernet.setValid(false); - hdr_9.inner_ipv6.setValid(false); + hdr_9.nvgre.setInvalid(); + hdr_9.gre.setInvalid(); + hdr_9.ipv4.setInvalid(); + hdr_9.inner_ethernet.setInvalid(); + hdr_9.inner_ipv6.setInvalid(); } @name("process_tunnel_decap.decap_nvgre_inner_non_ip") action process_tunnel_decap_decap_nvgre_inner_non_ip() { hdr_9.ethernet = hdr_9.inner_ethernet; - hdr_9.nvgre.setValid(false); - hdr_9.gre.setValid(false); - hdr_9.ipv4.setValid(false); - hdr_9.ipv6.setValid(false); + hdr_9.nvgre.setInvalid(); + hdr_9.gre.setInvalid(); + hdr_9.ipv4.setInvalid(); + hdr_9.ipv6.setInvalid(); } @name("process_tunnel_decap.decap_ip_inner_ipv4") action process_tunnel_decap_decap_ip_inner_ipv4() { hdr_9.ipv4 = hdr_9.inner_ipv4; - hdr_9.gre.setValid(false); - hdr_9.ipv6.setValid(false); - hdr_9.inner_ipv4.setValid(false); + hdr_9.gre.setInvalid(); + hdr_9.ipv6.setInvalid(); + hdr_9.inner_ipv4.setInvalid(); hdr_9.ethernet.etherType = 16w0x800; } @name("process_tunnel_decap.decap_ip_inner_ipv6") action process_tunnel_decap_decap_ip_inner_ipv6() { hdr_9.ipv6 = hdr_9.inner_ipv6; - hdr_9.gre.setValid(false); - hdr_9.ipv4.setValid(false); - hdr_9.inner_ipv6.setValid(false); + hdr_9.gre.setInvalid(); + hdr_9.ipv4.setInvalid(); + hdr_9.inner_ipv6.setInvalid(); hdr_9.ethernet.etherType = 16w0x86dd; } @name("process_tunnel_decap.decap_mpls_inner_ipv4_pop1") action process_tunnel_decap_decap_mpls_inner_ipv4_pop1() { - hdr_9.mpls[0].setValid(false); + hdr_9.mpls[0].setInvalid(); hdr_9.ipv4 = hdr_9.inner_ipv4; - hdr_9.inner_ipv4.setValid(false); + hdr_9.inner_ipv4.setInvalid(); hdr_9.ethernet.etherType = 16w0x800; } @name("process_tunnel_decap.decap_mpls_inner_ipv6_pop1") action process_tunnel_decap_decap_mpls_inner_ipv6_pop1() { - hdr_9.mpls[0].setValid(false); + hdr_9.mpls[0].setInvalid(); hdr_9.ipv6 = hdr_9.inner_ipv6; - hdr_9.inner_ipv6.setValid(false); + hdr_9.inner_ipv6.setInvalid(); hdr_9.ethernet.etherType = 16w0x86dd; } @name("process_tunnel_decap.decap_mpls_inner_ethernet_ipv4_pop1") action process_tunnel_decap_decap_mpls_inner_ethernet_ipv4_pop1() { - hdr_9.mpls[0].setValid(false); + hdr_9.mpls[0].setInvalid(); hdr_9.ethernet = hdr_9.inner_ethernet; hdr_9.ipv4 = hdr_9.inner_ipv4; - hdr_9.inner_ethernet.setValid(false); - hdr_9.inner_ipv4.setValid(false); + hdr_9.inner_ethernet.setInvalid(); + hdr_9.inner_ipv4.setInvalid(); } @name("process_tunnel_decap.decap_mpls_inner_ethernet_ipv6_pop1") action process_tunnel_decap_decap_mpls_inner_ethernet_ipv6_pop1() { - hdr_9.mpls[0].setValid(false); + hdr_9.mpls[0].setInvalid(); hdr_9.ethernet = hdr_9.inner_ethernet; hdr_9.ipv6 = hdr_9.inner_ipv6; - hdr_9.inner_ethernet.setValid(false); - hdr_9.inner_ipv6.setValid(false); + hdr_9.inner_ethernet.setInvalid(); + hdr_9.inner_ipv6.setInvalid(); } @name("process_tunnel_decap.decap_mpls_inner_ethernet_non_ip_pop1") action process_tunnel_decap_decap_mpls_inner_ethernet_non_ip_pop1() { - hdr_9.mpls[0].setValid(false); + hdr_9.mpls[0].setInvalid(); hdr_9.ethernet = hdr_9.inner_ethernet; - hdr_9.inner_ethernet.setValid(false); + hdr_9.inner_ethernet.setInvalid(); } @name("process_tunnel_decap.decap_mpls_inner_ipv4_pop2") action process_tunnel_decap_decap_mpls_inner_ipv4_pop2() { - hdr_9.mpls[0].setValid(false); - hdr_9.mpls[1].setValid(false); + hdr_9.mpls[0].setInvalid(); + hdr_9.mpls[1].setInvalid(); hdr_9.ipv4 = hdr_9.inner_ipv4; - hdr_9.inner_ipv4.setValid(false); + hdr_9.inner_ipv4.setInvalid(); hdr_9.ethernet.etherType = 16w0x800; } @name("process_tunnel_decap.decap_mpls_inner_ipv6_pop2") action process_tunnel_decap_decap_mpls_inner_ipv6_pop2() { - hdr_9.mpls[0].setValid(false); - hdr_9.mpls[1].setValid(false); + hdr_9.mpls[0].setInvalid(); + hdr_9.mpls[1].setInvalid(); hdr_9.ipv6 = hdr_9.inner_ipv6; - hdr_9.inner_ipv6.setValid(false); + hdr_9.inner_ipv6.setInvalid(); hdr_9.ethernet.etherType = 16w0x86dd; } @name("process_tunnel_decap.decap_mpls_inner_ethernet_ipv4_pop2") action process_tunnel_decap_decap_mpls_inner_ethernet_ipv4_pop2() { - hdr_9.mpls[0].setValid(false); - hdr_9.mpls[1].setValid(false); + hdr_9.mpls[0].setInvalid(); + hdr_9.mpls[1].setInvalid(); hdr_9.ethernet = hdr_9.inner_ethernet; hdr_9.ipv4 = hdr_9.inner_ipv4; - hdr_9.inner_ethernet.setValid(false); - hdr_9.inner_ipv4.setValid(false); + hdr_9.inner_ethernet.setInvalid(); + hdr_9.inner_ipv4.setInvalid(); } @name("process_tunnel_decap.decap_mpls_inner_ethernet_ipv6_pop2") action process_tunnel_decap_decap_mpls_inner_ethernet_ipv6_pop2() { - hdr_9.mpls[0].setValid(false); - hdr_9.mpls[1].setValid(false); + hdr_9.mpls[0].setInvalid(); + hdr_9.mpls[1].setInvalid(); hdr_9.ethernet = hdr_9.inner_ethernet; hdr_9.ipv6 = hdr_9.inner_ipv6; - hdr_9.inner_ethernet.setValid(false); - hdr_9.inner_ipv6.setValid(false); + hdr_9.inner_ethernet.setInvalid(); + hdr_9.inner_ipv6.setInvalid(); } @name("process_tunnel_decap.decap_mpls_inner_ethernet_non_ip_pop2") action process_tunnel_decap_decap_mpls_inner_ethernet_non_ip_pop2() { - hdr_9.mpls[0].setValid(false); - hdr_9.mpls[1].setValid(false); + hdr_9.mpls[0].setInvalid(); + hdr_9.mpls[1].setInvalid(); hdr_9.ethernet = hdr_9.inner_ethernet; - hdr_9.inner_ethernet.setValid(false); + hdr_9.inner_ethernet.setInvalid(); } @name("process_tunnel_decap.decap_mpls_inner_ipv4_pop3") action process_tunnel_decap_decap_mpls_inner_ipv4_pop3() { - hdr_9.mpls[0].setValid(false); - hdr_9.mpls[1].setValid(false); - hdr_9.mpls[2].setValid(false); + hdr_9.mpls[0].setInvalid(); + hdr_9.mpls[1].setInvalid(); + hdr_9.mpls[2].setInvalid(); hdr_9.ipv4 = hdr_9.inner_ipv4; - hdr_9.inner_ipv4.setValid(false); + hdr_9.inner_ipv4.setInvalid(); hdr_9.ethernet.etherType = 16w0x800; } @name("process_tunnel_decap.decap_mpls_inner_ipv6_pop3") action process_tunnel_decap_decap_mpls_inner_ipv6_pop3() { - hdr_9.mpls[0].setValid(false); - hdr_9.mpls[1].setValid(false); - hdr_9.mpls[2].setValid(false); + hdr_9.mpls[0].setInvalid(); + hdr_9.mpls[1].setInvalid(); + hdr_9.mpls[2].setInvalid(); hdr_9.ipv6 = hdr_9.inner_ipv6; - hdr_9.inner_ipv6.setValid(false); + hdr_9.inner_ipv6.setInvalid(); hdr_9.ethernet.etherType = 16w0x86dd; } @name("process_tunnel_decap.decap_mpls_inner_ethernet_ipv4_pop3") action process_tunnel_decap_decap_mpls_inner_ethernet_ipv4_pop3() { - hdr_9.mpls[0].setValid(false); - hdr_9.mpls[1].setValid(false); - hdr_9.mpls[2].setValid(false); + hdr_9.mpls[0].setInvalid(); + hdr_9.mpls[1].setInvalid(); + hdr_9.mpls[2].setInvalid(); hdr_9.ethernet = hdr_9.inner_ethernet; hdr_9.ipv4 = hdr_9.inner_ipv4; - hdr_9.inner_ethernet.setValid(false); - hdr_9.inner_ipv4.setValid(false); + hdr_9.inner_ethernet.setInvalid(); + hdr_9.inner_ipv4.setInvalid(); } @name("process_tunnel_decap.decap_mpls_inner_ethernet_ipv6_pop3") action process_tunnel_decap_decap_mpls_inner_ethernet_ipv6_pop3() { - hdr_9.mpls[0].setValid(false); - hdr_9.mpls[1].setValid(false); - hdr_9.mpls[2].setValid(false); + hdr_9.mpls[0].setInvalid(); + hdr_9.mpls[1].setInvalid(); + hdr_9.mpls[2].setInvalid(); hdr_9.ethernet = hdr_9.inner_ethernet; hdr_9.ipv6 = hdr_9.inner_ipv6; - hdr_9.inner_ethernet.setValid(false); - hdr_9.inner_ipv6.setValid(false); + hdr_9.inner_ethernet.setInvalid(); + hdr_9.inner_ipv6.setInvalid(); } @name("process_tunnel_decap.decap_mpls_inner_ethernet_non_ip_pop3") action process_tunnel_decap_decap_mpls_inner_ethernet_non_ip_pop3() { - hdr_9.mpls[0].setValid(false); - hdr_9.mpls[1].setValid(false); - hdr_9.mpls[2].setValid(false); + hdr_9.mpls[0].setInvalid(); + hdr_9.mpls[1].setInvalid(); + hdr_9.mpls[2].setInvalid(); hdr_9.ethernet = hdr_9.inner_ethernet; - hdr_9.inner_ethernet.setValid(false); + hdr_9.inner_ethernet.setInvalid(); } @name("process_tunnel_decap.tunnel_decap_process_inner") table process_tunnel_decap_tunnel_decap_process_inner() { actions = { @@ -1897,193 +1897,193 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t @name("process_int_insertion.int_set_header_0003_i0") action process_int_insertion_int_set_header_0003_i0() { } @name("process_int_insertion.int_set_header_0003_i1") action process_int_insertion_int_set_header_0003_i1() { - hdr_12.int_q_occupancy_header.setValid(true); + hdr_12.int_q_occupancy_header.setValid(); hdr_12.int_q_occupancy_header.q_occupancy = (bit<31>)meta_12.intrinsic_metadata.enq_qdepth; } @name("process_int_insertion.int_set_header_0003_i2") action process_int_insertion_int_set_header_0003_i2() { - hdr_12.int_hop_latency_header.setValid(true); + hdr_12.int_hop_latency_header.setValid(); hdr_12.int_hop_latency_header.hop_latency = (bit<31>)meta_12.intrinsic_metadata.deq_timedelta; } @name("process_int_insertion.int_set_header_0003_i3") action process_int_insertion_int_set_header_0003_i3() { - hdr_12.int_q_occupancy_header.setValid(true); + hdr_12.int_q_occupancy_header.setValid(); hdr_12.int_q_occupancy_header.q_occupancy = (bit<31>)meta_12.intrinsic_metadata.enq_qdepth; - hdr_12.int_hop_latency_header.setValid(true); + hdr_12.int_hop_latency_header.setValid(); hdr_12.int_hop_latency_header.hop_latency = (bit<31>)meta_12.intrinsic_metadata.deq_timedelta; } @name("process_int_insertion.int_set_header_0003_i4") action process_int_insertion_int_set_header_0003_i4() { - hdr_12.int_ingress_port_id_header.setValid(true); + hdr_12.int_ingress_port_id_header.setValid(); hdr_12.int_ingress_port_id_header.ingress_port_id = (bit<31>)meta_12.ingress_metadata.ifindex; } @name("process_int_insertion.int_set_header_0003_i5") action process_int_insertion_int_set_header_0003_i5() { - hdr_12.int_q_occupancy_header.setValid(true); + hdr_12.int_q_occupancy_header.setValid(); hdr_12.int_q_occupancy_header.q_occupancy = (bit<31>)meta_12.intrinsic_metadata.enq_qdepth; - hdr_12.int_ingress_port_id_header.setValid(true); + hdr_12.int_ingress_port_id_header.setValid(); hdr_12.int_ingress_port_id_header.ingress_port_id = (bit<31>)meta_12.ingress_metadata.ifindex; } @name("process_int_insertion.int_set_header_0003_i6") action process_int_insertion_int_set_header_0003_i6() { - hdr_12.int_hop_latency_header.setValid(true); + hdr_12.int_hop_latency_header.setValid(); hdr_12.int_hop_latency_header.hop_latency = (bit<31>)meta_12.intrinsic_metadata.deq_timedelta; - hdr_12.int_ingress_port_id_header.setValid(true); + hdr_12.int_ingress_port_id_header.setValid(); hdr_12.int_ingress_port_id_header.ingress_port_id = (bit<31>)meta_12.ingress_metadata.ifindex; } @name("process_int_insertion.int_set_header_0003_i7") action process_int_insertion_int_set_header_0003_i7() { - hdr_12.int_q_occupancy_header.setValid(true); + hdr_12.int_q_occupancy_header.setValid(); hdr_12.int_q_occupancy_header.q_occupancy = (bit<31>)meta_12.intrinsic_metadata.enq_qdepth; - hdr_12.int_hop_latency_header.setValid(true); + hdr_12.int_hop_latency_header.setValid(); hdr_12.int_hop_latency_header.hop_latency = (bit<31>)meta_12.intrinsic_metadata.deq_timedelta; - hdr_12.int_ingress_port_id_header.setValid(true); + hdr_12.int_ingress_port_id_header.setValid(); hdr_12.int_ingress_port_id_header.ingress_port_id = (bit<31>)meta_12.ingress_metadata.ifindex; } @name("process_int_insertion.int_set_header_0003_i8") action process_int_insertion_int_set_header_0003_i8() { - hdr_12.int_switch_id_header.setValid(true); + hdr_12.int_switch_id_header.setValid(); hdr_12.int_switch_id_header.switch_id = (bit<31>)meta_12.int_metadata.switch_id; } @name("process_int_insertion.int_set_header_0003_i9") action process_int_insertion_int_set_header_0003_i9() { - hdr_12.int_q_occupancy_header.setValid(true); + hdr_12.int_q_occupancy_header.setValid(); hdr_12.int_q_occupancy_header.q_occupancy = (bit<31>)meta_12.intrinsic_metadata.enq_qdepth; - hdr_12.int_switch_id_header.setValid(true); + hdr_12.int_switch_id_header.setValid(); hdr_12.int_switch_id_header.switch_id = (bit<31>)meta_12.int_metadata.switch_id; } @name("process_int_insertion.int_set_header_0003_i10") action process_int_insertion_int_set_header_0003_i10() { - hdr_12.int_hop_latency_header.setValid(true); + hdr_12.int_hop_latency_header.setValid(); hdr_12.int_hop_latency_header.hop_latency = (bit<31>)meta_12.intrinsic_metadata.deq_timedelta; - hdr_12.int_switch_id_header.setValid(true); + hdr_12.int_switch_id_header.setValid(); hdr_12.int_switch_id_header.switch_id = (bit<31>)meta_12.int_metadata.switch_id; } @name("process_int_insertion.int_set_header_0003_i11") action process_int_insertion_int_set_header_0003_i11() { - hdr_12.int_q_occupancy_header.setValid(true); + hdr_12.int_q_occupancy_header.setValid(); hdr_12.int_q_occupancy_header.q_occupancy = (bit<31>)meta_12.intrinsic_metadata.enq_qdepth; - hdr_12.int_hop_latency_header.setValid(true); + hdr_12.int_hop_latency_header.setValid(); hdr_12.int_hop_latency_header.hop_latency = (bit<31>)meta_12.intrinsic_metadata.deq_timedelta; - hdr_12.int_switch_id_header.setValid(true); + hdr_12.int_switch_id_header.setValid(); hdr_12.int_switch_id_header.switch_id = (bit<31>)meta_12.int_metadata.switch_id; } @name("process_int_insertion.int_set_header_0003_i12") action process_int_insertion_int_set_header_0003_i12() { - hdr_12.int_ingress_port_id_header.setValid(true); + hdr_12.int_ingress_port_id_header.setValid(); hdr_12.int_ingress_port_id_header.ingress_port_id = (bit<31>)meta_12.ingress_metadata.ifindex; - hdr_12.int_switch_id_header.setValid(true); + hdr_12.int_switch_id_header.setValid(); hdr_12.int_switch_id_header.switch_id = (bit<31>)meta_12.int_metadata.switch_id; } @name("process_int_insertion.int_set_header_0003_i13") action process_int_insertion_int_set_header_0003_i13() { - hdr_12.int_q_occupancy_header.setValid(true); + hdr_12.int_q_occupancy_header.setValid(); hdr_12.int_q_occupancy_header.q_occupancy = (bit<31>)meta_12.intrinsic_metadata.enq_qdepth; - hdr_12.int_ingress_port_id_header.setValid(true); + hdr_12.int_ingress_port_id_header.setValid(); hdr_12.int_ingress_port_id_header.ingress_port_id = (bit<31>)meta_12.ingress_metadata.ifindex; - hdr_12.int_switch_id_header.setValid(true); + hdr_12.int_switch_id_header.setValid(); hdr_12.int_switch_id_header.switch_id = (bit<31>)meta_12.int_metadata.switch_id; } @name("process_int_insertion.int_set_header_0003_i14") action process_int_insertion_int_set_header_0003_i14() { - hdr_12.int_hop_latency_header.setValid(true); + hdr_12.int_hop_latency_header.setValid(); hdr_12.int_hop_latency_header.hop_latency = (bit<31>)meta_12.intrinsic_metadata.deq_timedelta; - hdr_12.int_ingress_port_id_header.setValid(true); + hdr_12.int_ingress_port_id_header.setValid(); hdr_12.int_ingress_port_id_header.ingress_port_id = (bit<31>)meta_12.ingress_metadata.ifindex; - hdr_12.int_switch_id_header.setValid(true); + hdr_12.int_switch_id_header.setValid(); hdr_12.int_switch_id_header.switch_id = (bit<31>)meta_12.int_metadata.switch_id; } @name("process_int_insertion.int_set_header_0003_i15") action process_int_insertion_int_set_header_0003_i15() { - hdr_12.int_q_occupancy_header.setValid(true); + hdr_12.int_q_occupancy_header.setValid(); hdr_12.int_q_occupancy_header.q_occupancy = (bit<31>)meta_12.intrinsic_metadata.enq_qdepth; - hdr_12.int_hop_latency_header.setValid(true); + hdr_12.int_hop_latency_header.setValid(); hdr_12.int_hop_latency_header.hop_latency = (bit<31>)meta_12.intrinsic_metadata.deq_timedelta; - hdr_12.int_ingress_port_id_header.setValid(true); + hdr_12.int_ingress_port_id_header.setValid(); hdr_12.int_ingress_port_id_header.ingress_port_id = (bit<31>)meta_12.ingress_metadata.ifindex; - hdr_12.int_switch_id_header.setValid(true); + hdr_12.int_switch_id_header.setValid(); hdr_12.int_switch_id_header.switch_id = (bit<31>)meta_12.int_metadata.switch_id; } @name("process_int_insertion.int_set_header_0407_i0") action process_int_insertion_int_set_header_0407_i0() { } @name("process_int_insertion.int_set_header_0407_i1") action process_int_insertion_int_set_header_0407_i1() { - hdr_12.int_egress_port_tx_utilization_header.setValid(true); + hdr_12.int_egress_port_tx_utilization_header.setValid(); hdr_12.int_egress_port_tx_utilization_header.egress_port_tx_utilization = 31w0x7fffffff; } @name("process_int_insertion.int_set_header_0407_i2") action process_int_insertion_int_set_header_0407_i2() { - hdr_12.int_q_congestion_header.setValid(true); + hdr_12.int_q_congestion_header.setValid(); hdr_12.int_q_congestion_header.q_congestion = 31w0x7fffffff; } @name("process_int_insertion.int_set_header_0407_i3") action process_int_insertion_int_set_header_0407_i3() { - hdr_12.int_egress_port_tx_utilization_header.setValid(true); + hdr_12.int_egress_port_tx_utilization_header.setValid(); hdr_12.int_egress_port_tx_utilization_header.egress_port_tx_utilization = 31w0x7fffffff; - hdr_12.int_q_congestion_header.setValid(true); + hdr_12.int_q_congestion_header.setValid(); hdr_12.int_q_congestion_header.q_congestion = 31w0x7fffffff; } @name("process_int_insertion.int_set_header_0407_i4") action process_int_insertion_int_set_header_0407_i4() { - hdr_12.int_egress_port_id_header.setValid(true); + hdr_12.int_egress_port_id_header.setValid(); hdr_12.int_egress_port_id_header.egress_port_id = (bit<31>)standard_metadata_12.egress_port; } @name("process_int_insertion.int_set_header_0407_i5") action process_int_insertion_int_set_header_0407_i5() { - hdr_12.int_egress_port_tx_utilization_header.setValid(true); + hdr_12.int_egress_port_tx_utilization_header.setValid(); hdr_12.int_egress_port_tx_utilization_header.egress_port_tx_utilization = 31w0x7fffffff; - hdr_12.int_egress_port_id_header.setValid(true); + hdr_12.int_egress_port_id_header.setValid(); hdr_12.int_egress_port_id_header.egress_port_id = (bit<31>)standard_metadata_12.egress_port; } @name("process_int_insertion.int_set_header_0407_i6") action process_int_insertion_int_set_header_0407_i6() { - hdr_12.int_q_congestion_header.setValid(true); + hdr_12.int_q_congestion_header.setValid(); hdr_12.int_q_congestion_header.q_congestion = 31w0x7fffffff; - hdr_12.int_egress_port_id_header.setValid(true); + hdr_12.int_egress_port_id_header.setValid(); hdr_12.int_egress_port_id_header.egress_port_id = (bit<31>)standard_metadata_12.egress_port; } @name("process_int_insertion.int_set_header_0407_i7") action process_int_insertion_int_set_header_0407_i7() { - hdr_12.int_egress_port_tx_utilization_header.setValid(true); + hdr_12.int_egress_port_tx_utilization_header.setValid(); hdr_12.int_egress_port_tx_utilization_header.egress_port_tx_utilization = 31w0x7fffffff; - hdr_12.int_q_congestion_header.setValid(true); + hdr_12.int_q_congestion_header.setValid(); hdr_12.int_q_congestion_header.q_congestion = 31w0x7fffffff; - hdr_12.int_egress_port_id_header.setValid(true); + hdr_12.int_egress_port_id_header.setValid(); hdr_12.int_egress_port_id_header.egress_port_id = (bit<31>)standard_metadata_12.egress_port; } @name("process_int_insertion.int_set_header_0407_i8") action process_int_insertion_int_set_header_0407_i8() { - hdr_12.int_ingress_tstamp_header.setValid(true); + hdr_12.int_ingress_tstamp_header.setValid(); hdr_12.int_ingress_tstamp_header.ingress_tstamp = (bit<31>)meta_12.i2e_metadata.ingress_tstamp; } @name("process_int_insertion.int_set_header_0407_i9") action process_int_insertion_int_set_header_0407_i9() { - hdr_12.int_egress_port_tx_utilization_header.setValid(true); + hdr_12.int_egress_port_tx_utilization_header.setValid(); hdr_12.int_egress_port_tx_utilization_header.egress_port_tx_utilization = 31w0x7fffffff; - hdr_12.int_ingress_tstamp_header.setValid(true); + hdr_12.int_ingress_tstamp_header.setValid(); hdr_12.int_ingress_tstamp_header.ingress_tstamp = (bit<31>)meta_12.i2e_metadata.ingress_tstamp; } @name("process_int_insertion.int_set_header_0407_i10") action process_int_insertion_int_set_header_0407_i10() { - hdr_12.int_q_congestion_header.setValid(true); + hdr_12.int_q_congestion_header.setValid(); hdr_12.int_q_congestion_header.q_congestion = 31w0x7fffffff; - hdr_12.int_ingress_tstamp_header.setValid(true); + hdr_12.int_ingress_tstamp_header.setValid(); hdr_12.int_ingress_tstamp_header.ingress_tstamp = (bit<31>)meta_12.i2e_metadata.ingress_tstamp; } @name("process_int_insertion.int_set_header_0407_i11") action process_int_insertion_int_set_header_0407_i11() { - hdr_12.int_egress_port_tx_utilization_header.setValid(true); + hdr_12.int_egress_port_tx_utilization_header.setValid(); hdr_12.int_egress_port_tx_utilization_header.egress_port_tx_utilization = 31w0x7fffffff; - hdr_12.int_q_congestion_header.setValid(true); + hdr_12.int_q_congestion_header.setValid(); hdr_12.int_q_congestion_header.q_congestion = 31w0x7fffffff; - hdr_12.int_ingress_tstamp_header.setValid(true); + hdr_12.int_ingress_tstamp_header.setValid(); hdr_12.int_ingress_tstamp_header.ingress_tstamp = (bit<31>)meta_12.i2e_metadata.ingress_tstamp; } @name("process_int_insertion.int_set_header_0407_i12") action process_int_insertion_int_set_header_0407_i12() { - hdr_12.int_egress_port_id_header.setValid(true); + hdr_12.int_egress_port_id_header.setValid(); hdr_12.int_egress_port_id_header.egress_port_id = (bit<31>)standard_metadata_12.egress_port; - hdr_12.int_ingress_tstamp_header.setValid(true); + hdr_12.int_ingress_tstamp_header.setValid(); hdr_12.int_ingress_tstamp_header.ingress_tstamp = (bit<31>)meta_12.i2e_metadata.ingress_tstamp; } @name("process_int_insertion.int_set_header_0407_i13") action process_int_insertion_int_set_header_0407_i13() { - hdr_12.int_egress_port_tx_utilization_header.setValid(true); + hdr_12.int_egress_port_tx_utilization_header.setValid(); hdr_12.int_egress_port_tx_utilization_header.egress_port_tx_utilization = 31w0x7fffffff; - hdr_12.int_egress_port_id_header.setValid(true); + hdr_12.int_egress_port_id_header.setValid(); hdr_12.int_egress_port_id_header.egress_port_id = (bit<31>)standard_metadata_12.egress_port; - hdr_12.int_ingress_tstamp_header.setValid(true); + hdr_12.int_ingress_tstamp_header.setValid(); hdr_12.int_ingress_tstamp_header.ingress_tstamp = (bit<31>)meta_12.i2e_metadata.ingress_tstamp; } @name("process_int_insertion.int_set_header_0407_i14") action process_int_insertion_int_set_header_0407_i14() { - hdr_12.int_q_congestion_header.setValid(true); + hdr_12.int_q_congestion_header.setValid(); hdr_12.int_q_congestion_header.q_congestion = 31w0x7fffffff; - hdr_12.int_egress_port_id_header.setValid(true); + hdr_12.int_egress_port_id_header.setValid(); hdr_12.int_egress_port_id_header.egress_port_id = (bit<31>)standard_metadata_12.egress_port; - hdr_12.int_ingress_tstamp_header.setValid(true); + hdr_12.int_ingress_tstamp_header.setValid(); hdr_12.int_ingress_tstamp_header.ingress_tstamp = (bit<31>)meta_12.i2e_metadata.ingress_tstamp; } @name("process_int_insertion.int_set_header_0407_i15") action process_int_insertion_int_set_header_0407_i15() { - hdr_12.int_egress_port_tx_utilization_header.setValid(true); + hdr_12.int_egress_port_tx_utilization_header.setValid(); hdr_12.int_egress_port_tx_utilization_header.egress_port_tx_utilization = 31w0x7fffffff; - hdr_12.int_q_congestion_header.setValid(true); + hdr_12.int_q_congestion_header.setValid(); hdr_12.int_q_congestion_header.q_congestion = 31w0x7fffffff; - hdr_12.int_egress_port_id_header.setValid(true); + hdr_12.int_egress_port_id_header.setValid(); hdr_12.int_egress_port_id_header.egress_port_id = (bit<31>)standard_metadata_12.egress_port; - hdr_12.int_ingress_tstamp_header.setValid(true); + hdr_12.int_ingress_tstamp_header.setValid(); hdr_12.int_ingress_tstamp_header.ingress_tstamp = (bit<31>)meta_12.i2e_metadata.ingress_tstamp; } @name("process_int_insertion.int_set_e_bit") action process_int_insertion_int_set_e_bit() { @@ -2291,60 +2291,60 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t hdr_14.inner_ipv4 = hdr_14.ipv4; hdr_14.inner_udp = hdr_14.udp; meta_14.egress_metadata.payload_length = hdr_14.ipv4.totalLen; - hdr_14.udp.setValid(false); - hdr_14.ipv4.setValid(false); + hdr_14.udp.setInvalid(); + hdr_14.ipv4.setInvalid(); } @name("process_tunnel_encap.inner_ipv4_tcp_rewrite") action process_tunnel_encap_inner_ipv4_tcp_rewrite() { hdr_14.inner_ipv4 = hdr_14.ipv4; hdr_14.inner_tcp = hdr_14.tcp; meta_14.egress_metadata.payload_length = hdr_14.ipv4.totalLen; - hdr_14.tcp.setValid(false); - hdr_14.ipv4.setValid(false); + hdr_14.tcp.setInvalid(); + hdr_14.ipv4.setInvalid(); } @name("process_tunnel_encap.inner_ipv4_icmp_rewrite") action process_tunnel_encap_inner_ipv4_icmp_rewrite() { hdr_14.inner_ipv4 = hdr_14.ipv4; hdr_14.inner_icmp = hdr_14.icmp; meta_14.egress_metadata.payload_length = hdr_14.ipv4.totalLen; - hdr_14.icmp.setValid(false); - hdr_14.ipv4.setValid(false); + hdr_14.icmp.setInvalid(); + hdr_14.ipv4.setInvalid(); } @name("process_tunnel_encap.inner_ipv4_unknown_rewrite") action process_tunnel_encap_inner_ipv4_unknown_rewrite() { hdr_14.inner_ipv4 = hdr_14.ipv4; meta_14.egress_metadata.payload_length = hdr_14.ipv4.totalLen; - hdr_14.ipv4.setValid(false); + hdr_14.ipv4.setInvalid(); } @name("process_tunnel_encap.inner_ipv6_udp_rewrite") action process_tunnel_encap_inner_ipv6_udp_rewrite() { hdr_14.inner_ipv6 = hdr_14.ipv6; hdr_14.inner_udp = hdr_14.udp; meta_14.egress_metadata.payload_length = hdr_14.ipv6.payloadLen + 16w40; - hdr_14.ipv6.setValid(false); + hdr_14.ipv6.setInvalid(); } @name("process_tunnel_encap.inner_ipv6_tcp_rewrite") action process_tunnel_encap_inner_ipv6_tcp_rewrite() { hdr_14.inner_ipv6 = hdr_14.ipv6; hdr_14.inner_tcp = hdr_14.tcp; meta_14.egress_metadata.payload_length = hdr_14.ipv6.payloadLen + 16w40; - hdr_14.tcp.setValid(false); - hdr_14.ipv6.setValid(false); + hdr_14.tcp.setInvalid(); + hdr_14.ipv6.setInvalid(); } @name("process_tunnel_encap.inner_ipv6_icmp_rewrite") action process_tunnel_encap_inner_ipv6_icmp_rewrite() { hdr_14.inner_ipv6 = hdr_14.ipv6; hdr_14.inner_icmp = hdr_14.icmp; meta_14.egress_metadata.payload_length = hdr_14.ipv6.payloadLen + 16w40; - hdr_14.icmp.setValid(false); - hdr_14.ipv6.setValid(false); + hdr_14.icmp.setInvalid(); + hdr_14.ipv6.setInvalid(); } @name("process_tunnel_encap.inner_ipv6_unknown_rewrite") action process_tunnel_encap_inner_ipv6_unknown_rewrite() { hdr_14.inner_ipv6 = hdr_14.ipv6; meta_14.egress_metadata.payload_length = hdr_14.ipv6.payloadLen + 16w40; - hdr_14.ipv6.setValid(false); + hdr_14.ipv6.setInvalid(); } @name("process_tunnel_encap.inner_non_ip_rewrite") action process_tunnel_encap_inner_non_ip_rewrite() { meta_14.egress_metadata.payload_length = (bit<16>)(standard_metadata_14.packet_length + 32w65522); } @name("process_tunnel_encap.ipv4_vxlan_rewrite") action process_tunnel_encap_ipv4_vxlan_rewrite() { hdr_14.inner_ethernet = hdr_14.ethernet; - hdr_14.udp.setValid(true); - hdr_14.vxlan.setValid(true); + hdr_14.udp.setValid(); + hdr_14.vxlan.setValid(); hdr_14.udp.srcPort = meta_14.hash_metadata.entropy_hash; hdr_14.udp.dstPort = 16w4789; hdr_14.udp.checksum = 16w0; @@ -2353,7 +2353,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t hdr_14.vxlan.reserved = 24w0; hdr_14.vxlan.vni = meta_14.tunnel_metadata.vnid; hdr_14.vxlan.reserved2 = 8w0; - hdr_14.ipv4.setValid(true); + hdr_14.ipv4.setValid(); hdr_14.ipv4.protocol = 8w17; hdr_14.ipv4.ttl = 8w64; hdr_14.ipv4.version = 4w0x4; @@ -2364,8 +2364,8 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } @name("process_tunnel_encap.ipv6_vxlan_rewrite") action process_tunnel_encap_ipv6_vxlan_rewrite() { hdr_14.inner_ethernet = hdr_14.ethernet; - hdr_14.udp.setValid(true); - hdr_14.vxlan.setValid(true); + hdr_14.udp.setValid(); + hdr_14.vxlan.setValid(); hdr_14.udp.srcPort = meta_14.hash_metadata.entropy_hash; hdr_14.udp.dstPort = 16w4789; hdr_14.udp.checksum = 16w0; @@ -2374,7 +2374,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t hdr_14.vxlan.reserved = 24w0; hdr_14.vxlan.vni = meta_14.tunnel_metadata.vnid; hdr_14.vxlan.reserved2 = 8w0; - hdr_14.ipv6.setValid(true); + hdr_14.ipv6.setValid(); hdr_14.ipv6.version = 4w0x6; hdr_14.ipv6.nextHdr = 8w17; hdr_14.ipv6.hopLimit = 8w64; @@ -2385,8 +2385,8 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } @name("process_tunnel_encap.ipv4_genv_rewrite") action process_tunnel_encap_ipv4_genv_rewrite() { hdr_14.inner_ethernet = hdr_14.ethernet; - hdr_14.udp.setValid(true); - hdr_14.genv.setValid(true); + hdr_14.udp.setValid(); + hdr_14.genv.setValid(); hdr_14.udp.srcPort = meta_14.hash_metadata.entropy_hash; hdr_14.udp.dstPort = 16w6081; hdr_14.udp.checksum = 16w0; @@ -2399,7 +2399,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t hdr_14.genv.vni = meta_14.tunnel_metadata.vnid; hdr_14.genv.reserved = 6w0; hdr_14.genv.reserved2 = 8w0; - hdr_14.ipv4.setValid(true); + hdr_14.ipv4.setValid(); hdr_14.ipv4.protocol = 8w17; hdr_14.ipv4.ttl = 8w64; hdr_14.ipv4.version = 4w0x4; @@ -2410,8 +2410,8 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } @name("process_tunnel_encap.ipv6_genv_rewrite") action process_tunnel_encap_ipv6_genv_rewrite() { hdr_14.inner_ethernet = hdr_14.ethernet; - hdr_14.udp.setValid(true); - hdr_14.genv.setValid(true); + hdr_14.udp.setValid(); + hdr_14.genv.setValid(); hdr_14.udp.srcPort = meta_14.hash_metadata.entropy_hash; hdr_14.udp.dstPort = 16w6081; hdr_14.udp.checksum = 16w0; @@ -2424,7 +2424,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t hdr_14.genv.vni = meta_14.tunnel_metadata.vnid; hdr_14.genv.reserved = 6w0; hdr_14.genv.reserved2 = 8w0; - hdr_14.ipv6.setValid(true); + hdr_14.ipv6.setValid(); hdr_14.ipv6.version = 4w0x6; hdr_14.ipv6.nextHdr = 8w17; hdr_14.ipv6.hopLimit = 8w64; @@ -2435,8 +2435,8 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } @name("process_tunnel_encap.ipv4_nvgre_rewrite") action process_tunnel_encap_ipv4_nvgre_rewrite() { hdr_14.inner_ethernet = hdr_14.ethernet; - hdr_14.gre.setValid(true); - hdr_14.nvgre.setValid(true); + hdr_14.gre.setValid(); + hdr_14.nvgre.setValid(); hdr_14.gre.proto = 16w0x6558; hdr_14.gre.recurse = 3w0; hdr_14.gre.flags = 5w0; @@ -2448,7 +2448,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t hdr_14.gre.s = 1w0; hdr_14.nvgre.tni = meta_14.tunnel_metadata.vnid; hdr_14.nvgre.flow_id[7:0] = meta_14.hash_metadata.entropy_hash[7:0]; - hdr_14.ipv4.setValid(true); + hdr_14.ipv4.setValid(); hdr_14.ipv4.protocol = 8w47; hdr_14.ipv4.ttl = 8w64; hdr_14.ipv4.version = 4w0x4; @@ -2459,8 +2459,8 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } @name("process_tunnel_encap.ipv6_nvgre_rewrite") action process_tunnel_encap_ipv6_nvgre_rewrite() { hdr_14.inner_ethernet = hdr_14.ethernet; - hdr_14.gre.setValid(true); - hdr_14.nvgre.setValid(true); + hdr_14.gre.setValid(); + hdr_14.nvgre.setValid(); hdr_14.gre.proto = 16w0x6558; hdr_14.gre.recurse = 3w0; hdr_14.gre.flags = 5w0; @@ -2472,7 +2472,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t hdr_14.gre.s = 1w0; hdr_14.nvgre.tni = meta_14.tunnel_metadata.vnid; hdr_14.nvgre.flow_id[7:0] = meta_14.hash_metadata.entropy_hash[7:0]; - hdr_14.ipv6.setValid(true); + hdr_14.ipv6.setValid(); hdr_14.ipv6.version = 4w0x6; hdr_14.ipv6.nextHdr = 8w47; hdr_14.ipv6.hopLimit = 8w64; @@ -2482,9 +2482,9 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t hdr_14.ethernet.etherType = 16w0x86dd; } @name("process_tunnel_encap.ipv4_gre_rewrite") action process_tunnel_encap_ipv4_gre_rewrite() { - hdr_14.gre.setValid(true); + hdr_14.gre.setValid(); hdr_14.gre.proto = hdr_14.ethernet.etherType; - hdr_14.ipv4.setValid(true); + hdr_14.ipv4.setValid(); hdr_14.ipv4.protocol = 8w47; hdr_14.ipv4.ttl = 8w64; hdr_14.ipv4.version = 4w0x4; @@ -2494,9 +2494,9 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t hdr_14.ethernet.etherType = 16w0x800; } @name("process_tunnel_encap.ipv6_gre_rewrite") action process_tunnel_encap_ipv6_gre_rewrite() { - hdr_14.gre.setValid(true); + hdr_14.gre.setValid(); hdr_14.gre.proto = 16w0x800; - hdr_14.ipv6.setValid(true); + hdr_14.ipv6.setValid(); hdr_14.ipv6.version = 4w0x6; hdr_14.ipv6.nextHdr = 8w47; hdr_14.ipv6.hopLimit = 8w64; @@ -2506,7 +2506,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t hdr_14.ethernet.etherType = 16w0x86dd; } @name("process_tunnel_encap.ipv4_ipv4_rewrite") action process_tunnel_encap_ipv4_ipv4_rewrite() { - hdr_14.ipv4.setValid(true); + hdr_14.ipv4.setValid(); hdr_14.ipv4.protocol = 8w4; hdr_14.ipv4.ttl = 8w64; hdr_14.ipv4.version = 4w0x4; @@ -2516,7 +2516,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t hdr_14.ethernet.etherType = 16w0x800; } @name("process_tunnel_encap.ipv4_ipv6_rewrite") action process_tunnel_encap_ipv4_ipv6_rewrite() { - hdr_14.ipv4.setValid(true); + hdr_14.ipv4.setValid(); hdr_14.ipv4.protocol = 8w41; hdr_14.ipv4.ttl = 8w64; hdr_14.ipv4.version = 4w0x4; @@ -2526,7 +2526,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t hdr_14.ethernet.etherType = 16w0x800; } @name("process_tunnel_encap.ipv6_ipv4_rewrite") action process_tunnel_encap_ipv6_ipv4_rewrite() { - hdr_14.ipv6.setValid(true); + hdr_14.ipv6.setValid(); hdr_14.ipv6.version = 4w0x6; hdr_14.ipv6.nextHdr = 8w4; hdr_14.ipv6.hopLimit = 8w64; @@ -2536,7 +2536,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t hdr_14.ethernet.etherType = 16w0x86dd; } @name("process_tunnel_encap.ipv6_ipv6_rewrite") action process_tunnel_encap_ipv6_ipv6_rewrite() { - hdr_14.ipv6.setValid(true); + hdr_14.ipv6.setValid(); hdr_14.ipv6.version = 4w0x6; hdr_14.ipv6.nextHdr = 8w41; hdr_14.ipv6.hopLimit = 8w64; @@ -2547,8 +2547,8 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } @name("process_tunnel_encap.ipv4_erspan_t3_rewrite") action process_tunnel_encap_ipv4_erspan_t3_rewrite() { hdr_14.inner_ethernet = hdr_14.ethernet; - hdr_14.gre.setValid(true); - hdr_14.erspan_t3_header.setValid(true); + hdr_14.gre.setValid(); + hdr_14.erspan_t3_header.setValid(); hdr_14.gre.C = 1w0; hdr_14.gre.R = 1w0; hdr_14.gre.K = 1w0; @@ -2562,7 +2562,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t hdr_14.erspan_t3_header.span_id = (bit<10>)meta_14.i2e_metadata.mirror_session_id; hdr_14.erspan_t3_header.version = 4w2; hdr_14.erspan_t3_header.sgt_other = 32w0; - hdr_14.ipv4.setValid(true); + hdr_14.ipv4.setValid(); hdr_14.ipv4.protocol = 8w47; hdr_14.ipv4.ttl = 8w64; hdr_14.ipv4.version = 4w0x4; @@ -2572,8 +2572,8 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t } @name("process_tunnel_encap.ipv6_erspan_t3_rewrite") action process_tunnel_encap_ipv6_erspan_t3_rewrite() { hdr_14.inner_ethernet = hdr_14.ethernet; - hdr_14.gre.setValid(true); - hdr_14.erspan_t3_header.setValid(true); + hdr_14.gre.setValid(); + hdr_14.erspan_t3_header.setValid(); hdr_14.gre.C = 1w0; hdr_14.gre.R = 1w0; hdr_14.gre.K = 1w0; @@ -2587,7 +2587,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t hdr_14.erspan_t3_header.span_id = (bit<10>)meta_14.i2e_metadata.mirror_session_id; hdr_14.erspan_t3_header.version = 4w2; hdr_14.erspan_t3_header.sgt_other = 32w0; - hdr_14.ipv6.setValid(true); + hdr_14.ipv6.setValid(); hdr_14.ipv6.version = 4w0x6; hdr_14.ipv6.nextHdr = 8w47; hdr_14.ipv6.hopLimit = 8w64; @@ -2670,40 +2670,40 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t meta_14.tunnel_metadata.tunnel_dmac_index = dmac_idx; } @name("process_tunnel_encap.cpu_rx_rewrite") action process_tunnel_encap_cpu_rx_rewrite() { - hdr_14.fabric_header.setValid(true); + hdr_14.fabric_header.setValid(); hdr_14.fabric_header.headerVersion = 2w0; hdr_14.fabric_header.packetVersion = 2w0; hdr_14.fabric_header.pad1 = 1w0; hdr_14.fabric_header.packetType = 3w5; - hdr_14.fabric_header_cpu.setValid(true); + hdr_14.fabric_header_cpu.setValid(); hdr_14.fabric_header_cpu.ingressPort = (bit<16>)meta_14.ingress_metadata.ingress_port; hdr_14.fabric_header_cpu.ingressIfindex = meta_14.ingress_metadata.ifindex; hdr_14.fabric_header_cpu.ingressBd = meta_14.ingress_metadata.bd; hdr_14.fabric_header_cpu.reasonCode = meta_14.fabric_metadata.reason_code; - hdr_14.fabric_payload_header.setValid(true); + hdr_14.fabric_payload_header.setValid(); hdr_14.fabric_payload_header.etherType = hdr_14.ethernet.etherType; hdr_14.ethernet.etherType = 16w0x9000; } @name("process_tunnel_encap.fabric_unicast_rewrite") action process_tunnel_encap_fabric_unicast_rewrite() { - hdr_14.fabric_header.setValid(true); + hdr_14.fabric_header.setValid(); hdr_14.fabric_header.headerVersion = 2w0; hdr_14.fabric_header.packetVersion = 2w0; hdr_14.fabric_header.pad1 = 1w0; hdr_14.fabric_header.packetType = 3w1; hdr_14.fabric_header.dstDevice = meta_14.fabric_metadata.dst_device; hdr_14.fabric_header.dstPortOrGroup = meta_14.fabric_metadata.dst_port; - hdr_14.fabric_header_unicast.setValid(true); + hdr_14.fabric_header_unicast.setValid(); hdr_14.fabric_header_unicast.tunnelTerminate = meta_14.tunnel_metadata.tunnel_terminate; hdr_14.fabric_header_unicast.routed = meta_14.l3_metadata.routed; hdr_14.fabric_header_unicast.outerRouted = meta_14.l3_metadata.outer_routed; hdr_14.fabric_header_unicast.ingressTunnelType = meta_14.tunnel_metadata.ingress_tunnel_type; hdr_14.fabric_header_unicast.nexthopIndex = meta_14.l3_metadata.nexthop_index; - hdr_14.fabric_payload_header.setValid(true); + hdr_14.fabric_payload_header.setValid(); hdr_14.fabric_payload_header.etherType = hdr_14.ethernet.etherType; hdr_14.ethernet.etherType = 16w0x9000; } @name("process_tunnel_encap.fabric_multicast_rewrite") action process_tunnel_encap_fabric_multicast_rewrite(bit<16> fabric_mgid) { - hdr_14.fabric_header.setValid(true); + hdr_14.fabric_header.setValid(); hdr_14.fabric_header.headerVersion = 2w0; hdr_14.fabric_header.packetVersion = 2w0; hdr_14.fabric_header.pad1 = 1w0; @@ -2712,13 +2712,13 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t hdr_14.fabric_header.dstPortOrGroup = fabric_mgid; hdr_14.fabric_header_multicast.ingressIfindex = meta_14.ingress_metadata.ifindex; hdr_14.fabric_header_multicast.ingressBd = meta_14.ingress_metadata.bd; - hdr_14.fabric_header_multicast.setValid(true); + hdr_14.fabric_header_multicast.setValid(); hdr_14.fabric_header_multicast.tunnelTerminate = meta_14.tunnel_metadata.tunnel_terminate; hdr_14.fabric_header_multicast.routed = meta_14.l3_metadata.routed; hdr_14.fabric_header_multicast.outerRouted = meta_14.l3_metadata.outer_routed; hdr_14.fabric_header_multicast.ingressTunnelType = meta_14.tunnel_metadata.ingress_tunnel_type; hdr_14.fabric_header_multicast.mcastGrp = meta_14.multicast_metadata.mcast_grp; - hdr_14.fabric_payload_header.setValid(true); + hdr_14.fabric_payload_header.setValid(); hdr_14.fabric_payload_header.etherType = hdr_14.ethernet.etherType; hdr_14.ethernet.etherType = 16w0x9000; } @@ -2894,14 +2894,14 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t @name("process_vlan_xlate.set_egress_packet_vlan_untagged") action process_vlan_xlate_set_egress_packet_vlan_untagged() { } @name("process_vlan_xlate.set_egress_packet_vlan_tagged") action process_vlan_xlate_set_egress_packet_vlan_tagged(bit<12> vlan_id) { - hdr_16.vlan_tag_[0].setValid(true); + hdr_16.vlan_tag_[0].setValid(); hdr_16.vlan_tag_[0].etherType = hdr_16.ethernet.etherType; hdr_16.vlan_tag_[0].vid = vlan_id; hdr_16.ethernet.etherType = 16w0x8100; } @name("process_vlan_xlate.set_egress_packet_vlan_double_tagged") action process_vlan_xlate_set_egress_packet_vlan_double_tagged(bit<12> s_tag, bit<12> c_tag) { - hdr_16.vlan_tag_[1].setValid(true); - hdr_16.vlan_tag_[0].setValid(true); + hdr_16.vlan_tag_[1].setValid(); + hdr_16.vlan_tag_[0].setValid(); hdr_16.vlan_tag_[1].etherType = hdr_16.ethernet.etherType; hdr_16.vlan_tag_[1].vid = c_tag; hdr_16.vlan_tag_[0].etherType = 16w0x8100; @@ -4749,9 +4749,9 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ standard_metadata_38.egress_spec = (bit<9>)hdr_38.fabric_header.dstPortOrGroup; meta_38.egress_metadata.bypass = hdr_38.fabric_header_cpu.txBypass; hdr_38.ethernet.etherType = hdr_38.fabric_payload_header.etherType; - hdr_38.fabric_header.setValid(false); - hdr_38.fabric_header_cpu.setValid(false); - hdr_38.fabric_payload_header.setValid(false); + hdr_38.fabric_header.setInvalid(); + hdr_38.fabric_header_cpu.setInvalid(); + hdr_38.fabric_payload_header.setInvalid(); } @name("process_ingress_fabric.switch_fabric_unicast_packet") action process_ingress_fabric_switch_fabric_unicast_packet() { meta_38.fabric_metadata.fabric_header_present = 1w1; @@ -4766,9 +4766,9 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ meta_38.l3_metadata.routed = hdr_38.fabric_header_unicast.routed; meta_38.l3_metadata.outer_routed = hdr_38.fabric_header_unicast.outerRouted; hdr_38.ethernet.etherType = hdr_38.fabric_payload_header.etherType; - hdr_38.fabric_header.setValid(false); - hdr_38.fabric_header_unicast.setValid(false); - hdr_38.fabric_payload_header.setValid(false); + hdr_38.fabric_header.setInvalid(); + hdr_38.fabric_header_unicast.setInvalid(); + hdr_38.fabric_payload_header.setInvalid(); } @name("process_ingress_fabric.switch_fabric_multicast_packet") action process_ingress_fabric_switch_fabric_multicast_packet() { meta_38.fabric_metadata.fabric_header_present = 1w1; @@ -4782,9 +4782,9 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ meta_38.l3_metadata.outer_routed = hdr_38.fabric_header_multicast.outerRouted; meta_38.intrinsic_metadata.mcast_grp = hdr_38.fabric_header_multicast.mcastGrp; hdr_38.ethernet.etherType = hdr_38.fabric_payload_header.etherType; - hdr_38.fabric_header.setValid(false); - hdr_38.fabric_header_multicast.setValid(false); - hdr_38.fabric_payload_header.setValid(false); + hdr_38.fabric_header.setInvalid(); + hdr_38.fabric_header_multicast.setInvalid(); + hdr_38.fabric_payload_header.setInvalid(); } @name("process_ingress_fabric.set_ingress_ifindex_properties") action process_ingress_fabric_set_ingress_ifindex_properties() { } diff --git a/testdata/v1_samples_outputs/switch.p4 b/testdata/v1_samples_outputs/switch.p4 index 132b2234cdb..5ab004aa003 100644 --- a/testdata/v1_samples_outputs/switch.p4 +++ b/testdata/v1_samples_outputs/switch.p4 @@ -1314,12 +1314,12 @@ control process_vlan_decap(inout headers hdr, inout metadata meta, inout standar } @name("remove_vlan_single_tagged") action remove_vlan_single_tagged() { hdr.ethernet.etherType = hdr.vlan_tag_[0].etherType; - hdr.vlan_tag_[0].setValid(false); + hdr.vlan_tag_[0].setInvalid(); } @name("remove_vlan_double_tagged") action remove_vlan_double_tagged() { hdr.ethernet.etherType = hdr.vlan_tag_[1].etherType; - hdr.vlan_tag_[0].setValid(false); - hdr.vlan_tag_[1].setValid(false); + hdr.vlan_tag_[0].setInvalid(); + hdr.vlan_tag_[1].setInvalid(); } @name("vlan_decap") table vlan_decap() { actions = { @@ -1343,211 +1343,211 @@ control process_vlan_decap(inout headers hdr, inout metadata meta, inout standar control process_tunnel_decap(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("decap_inner_udp") action decap_inner_udp() { hdr.udp = hdr.inner_udp; - hdr.inner_udp.setValid(false); + hdr.inner_udp.setInvalid(); } @name("decap_inner_tcp") action decap_inner_tcp() { hdr.tcp = hdr.inner_tcp; - hdr.inner_tcp.setValid(false); - hdr.udp.setValid(false); + hdr.inner_tcp.setInvalid(); + hdr.udp.setInvalid(); } @name("decap_inner_icmp") action decap_inner_icmp() { hdr.icmp = hdr.inner_icmp; - hdr.inner_icmp.setValid(false); - hdr.udp.setValid(false); + hdr.inner_icmp.setInvalid(); + hdr.udp.setInvalid(); } @name("decap_inner_unknown") action decap_inner_unknown() { - hdr.udp.setValid(false); + hdr.udp.setInvalid(); } @name("decap_vxlan_inner_ipv4") action decap_vxlan_inner_ipv4() { hdr.ethernet = hdr.inner_ethernet; hdr.ipv4 = hdr.inner_ipv4; - hdr.vxlan.setValid(false); - hdr.ipv6.setValid(false); - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv4.setValid(false); + hdr.vxlan.setInvalid(); + hdr.ipv6.setInvalid(); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv4.setInvalid(); } @name("decap_vxlan_inner_ipv6") action decap_vxlan_inner_ipv6() { hdr.ethernet = hdr.inner_ethernet; hdr.ipv6 = hdr.inner_ipv6; - hdr.vxlan.setValid(false); - hdr.ipv4.setValid(false); - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv6.setValid(false); + hdr.vxlan.setInvalid(); + hdr.ipv4.setInvalid(); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv6.setInvalid(); } @name("decap_vxlan_inner_non_ip") action decap_vxlan_inner_non_ip() { hdr.ethernet = hdr.inner_ethernet; - hdr.vxlan.setValid(false); - hdr.ipv4.setValid(false); - hdr.ipv6.setValid(false); + hdr.vxlan.setInvalid(); + hdr.ipv4.setInvalid(); + hdr.ipv6.setInvalid(); } @name("decap_genv_inner_ipv4") action decap_genv_inner_ipv4() { hdr.ethernet = hdr.inner_ethernet; hdr.ipv4 = hdr.inner_ipv4; - hdr.genv.setValid(false); - hdr.ipv6.setValid(false); - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv4.setValid(false); + hdr.genv.setInvalid(); + hdr.ipv6.setInvalid(); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv4.setInvalid(); } @name("decap_genv_inner_ipv6") action decap_genv_inner_ipv6() { hdr.ethernet = hdr.inner_ethernet; hdr.ipv6 = hdr.inner_ipv6; - hdr.genv.setValid(false); - hdr.ipv4.setValid(false); - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv6.setValid(false); + hdr.genv.setInvalid(); + hdr.ipv4.setInvalid(); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv6.setInvalid(); } @name("decap_genv_inner_non_ip") action decap_genv_inner_non_ip() { hdr.ethernet = hdr.inner_ethernet; - hdr.genv.setValid(false); - hdr.ipv4.setValid(false); - hdr.ipv6.setValid(false); + hdr.genv.setInvalid(); + hdr.ipv4.setInvalid(); + hdr.ipv6.setInvalid(); } @name("decap_nvgre_inner_ipv4") action decap_nvgre_inner_ipv4() { hdr.ethernet = hdr.inner_ethernet; hdr.ipv4 = hdr.inner_ipv4; - hdr.nvgre.setValid(false); - hdr.gre.setValid(false); - hdr.ipv6.setValid(false); - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv4.setValid(false); + hdr.nvgre.setInvalid(); + hdr.gre.setInvalid(); + hdr.ipv6.setInvalid(); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv4.setInvalid(); } @name("decap_nvgre_inner_ipv6") action decap_nvgre_inner_ipv6() { hdr.ethernet = hdr.inner_ethernet; hdr.ipv6 = hdr.inner_ipv6; - hdr.nvgre.setValid(false); - hdr.gre.setValid(false); - hdr.ipv4.setValid(false); - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv6.setValid(false); + hdr.nvgre.setInvalid(); + hdr.gre.setInvalid(); + hdr.ipv4.setInvalid(); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv6.setInvalid(); } @name("decap_nvgre_inner_non_ip") action decap_nvgre_inner_non_ip() { hdr.ethernet = hdr.inner_ethernet; - hdr.nvgre.setValid(false); - hdr.gre.setValid(false); - hdr.ipv4.setValid(false); - hdr.ipv6.setValid(false); + hdr.nvgre.setInvalid(); + hdr.gre.setInvalid(); + hdr.ipv4.setInvalid(); + hdr.ipv6.setInvalid(); } @name("decap_ip_inner_ipv4") action decap_ip_inner_ipv4() { hdr.ipv4 = hdr.inner_ipv4; - hdr.gre.setValid(false); - hdr.ipv6.setValid(false); - hdr.inner_ipv4.setValid(false); + hdr.gre.setInvalid(); + hdr.ipv6.setInvalid(); + hdr.inner_ipv4.setInvalid(); hdr.ethernet.etherType = 16w0x800; } @name("decap_ip_inner_ipv6") action decap_ip_inner_ipv6() { hdr.ipv6 = hdr.inner_ipv6; - hdr.gre.setValid(false); - hdr.ipv4.setValid(false); - hdr.inner_ipv6.setValid(false); + hdr.gre.setInvalid(); + hdr.ipv4.setInvalid(); + hdr.inner_ipv6.setInvalid(); hdr.ethernet.etherType = 16w0x86dd; } @name("decap_mpls_inner_ipv4_pop1") action decap_mpls_inner_ipv4_pop1() { - hdr.mpls[0].setValid(false); + hdr.mpls[0].setInvalid(); hdr.ipv4 = hdr.inner_ipv4; - hdr.inner_ipv4.setValid(false); + hdr.inner_ipv4.setInvalid(); hdr.ethernet.etherType = 16w0x800; } @name("decap_mpls_inner_ipv6_pop1") action decap_mpls_inner_ipv6_pop1() { - hdr.mpls[0].setValid(false); + hdr.mpls[0].setInvalid(); hdr.ipv6 = hdr.inner_ipv6; - hdr.inner_ipv6.setValid(false); + hdr.inner_ipv6.setInvalid(); hdr.ethernet.etherType = 16w0x86dd; } @name("decap_mpls_inner_ethernet_ipv4_pop1") action decap_mpls_inner_ethernet_ipv4_pop1() { - hdr.mpls[0].setValid(false); + hdr.mpls[0].setInvalid(); hdr.ethernet = hdr.inner_ethernet; hdr.ipv4 = hdr.inner_ipv4; - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv4.setValid(false); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv4.setInvalid(); } @name("decap_mpls_inner_ethernet_ipv6_pop1") action decap_mpls_inner_ethernet_ipv6_pop1() { - hdr.mpls[0].setValid(false); + hdr.mpls[0].setInvalid(); hdr.ethernet = hdr.inner_ethernet; hdr.ipv6 = hdr.inner_ipv6; - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv6.setValid(false); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv6.setInvalid(); } @name("decap_mpls_inner_ethernet_non_ip_pop1") action decap_mpls_inner_ethernet_non_ip_pop1() { - hdr.mpls[0].setValid(false); + hdr.mpls[0].setInvalid(); hdr.ethernet = hdr.inner_ethernet; - hdr.inner_ethernet.setValid(false); + hdr.inner_ethernet.setInvalid(); } @name("decap_mpls_inner_ipv4_pop2") action decap_mpls_inner_ipv4_pop2() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); hdr.ipv4 = hdr.inner_ipv4; - hdr.inner_ipv4.setValid(false); + hdr.inner_ipv4.setInvalid(); hdr.ethernet.etherType = 16w0x800; } @name("decap_mpls_inner_ipv6_pop2") action decap_mpls_inner_ipv6_pop2() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); hdr.ipv6 = hdr.inner_ipv6; - hdr.inner_ipv6.setValid(false); + hdr.inner_ipv6.setInvalid(); hdr.ethernet.etherType = 16w0x86dd; } @name("decap_mpls_inner_ethernet_ipv4_pop2") action decap_mpls_inner_ethernet_ipv4_pop2() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); hdr.ethernet = hdr.inner_ethernet; hdr.ipv4 = hdr.inner_ipv4; - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv4.setValid(false); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv4.setInvalid(); } @name("decap_mpls_inner_ethernet_ipv6_pop2") action decap_mpls_inner_ethernet_ipv6_pop2() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); hdr.ethernet = hdr.inner_ethernet; hdr.ipv6 = hdr.inner_ipv6; - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv6.setValid(false); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv6.setInvalid(); } @name("decap_mpls_inner_ethernet_non_ip_pop2") action decap_mpls_inner_ethernet_non_ip_pop2() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); hdr.ethernet = hdr.inner_ethernet; - hdr.inner_ethernet.setValid(false); + hdr.inner_ethernet.setInvalid(); } @name("decap_mpls_inner_ipv4_pop3") action decap_mpls_inner_ipv4_pop3() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); - hdr.mpls[2].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); + hdr.mpls[2].setInvalid(); hdr.ipv4 = hdr.inner_ipv4; - hdr.inner_ipv4.setValid(false); + hdr.inner_ipv4.setInvalid(); hdr.ethernet.etherType = 16w0x800; } @name("decap_mpls_inner_ipv6_pop3") action decap_mpls_inner_ipv6_pop3() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); - hdr.mpls[2].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); + hdr.mpls[2].setInvalid(); hdr.ipv6 = hdr.inner_ipv6; - hdr.inner_ipv6.setValid(false); + hdr.inner_ipv6.setInvalid(); hdr.ethernet.etherType = 16w0x86dd; } @name("decap_mpls_inner_ethernet_ipv4_pop3") action decap_mpls_inner_ethernet_ipv4_pop3() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); - hdr.mpls[2].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); + hdr.mpls[2].setInvalid(); hdr.ethernet = hdr.inner_ethernet; hdr.ipv4 = hdr.inner_ipv4; - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv4.setValid(false); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv4.setInvalid(); } @name("decap_mpls_inner_ethernet_ipv6_pop3") action decap_mpls_inner_ethernet_ipv6_pop3() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); - hdr.mpls[2].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); + hdr.mpls[2].setInvalid(); hdr.ethernet = hdr.inner_ethernet; hdr.ipv6 = hdr.inner_ipv6; - hdr.inner_ethernet.setValid(false); - hdr.inner_ipv6.setValid(false); + hdr.inner_ethernet.setInvalid(); + hdr.inner_ipv6.setInvalid(); } @name("decap_mpls_inner_ethernet_non_ip_pop3") action decap_mpls_inner_ethernet_non_ip_pop3() { - hdr.mpls[0].setValid(false); - hdr.mpls[1].setValid(false); - hdr.mpls[2].setValid(false); + hdr.mpls[0].setInvalid(); + hdr.mpls[1].setInvalid(); + hdr.mpls[2].setInvalid(); hdr.ethernet = hdr.inner_ethernet; - hdr.inner_ethernet.setValid(false); + hdr.inner_ethernet.setInvalid(); } @name("tunnel_decap_process_inner") table tunnel_decap_process_inner() { actions = { @@ -1769,14 +1769,14 @@ control process_int_insertion(inout headers hdr, inout metadata meta, inout stan @name("int_set_header_0003_i0") action int_set_header_0003_i0() { } @name("int_set_header_3") action int_set_header_3() { - hdr.int_q_occupancy_header.setValid(true); + hdr.int_q_occupancy_header.setValid(); hdr.int_q_occupancy_header.q_occupancy = meta.intrinsic_metadata.enq_qdepth; } @name("int_set_header_0003_i1") action int_set_header_0003_i1() { int_set_header_3(); } @name("int_set_header_2") action int_set_header_2() { - hdr.int_hop_latency_header.setValid(true); + hdr.int_hop_latency_header.setValid(); hdr.int_hop_latency_header.hop_latency = meta.intrinsic_metadata.deq_timedelta; } @name("int_set_header_0003_i2") action int_set_header_0003_i2() { @@ -1787,7 +1787,7 @@ control process_int_insertion(inout headers hdr, inout metadata meta, inout stan int_set_header_2(); } @name("int_set_header_1") action int_set_header_1() { - hdr.int_ingress_port_id_header.setValid(true); + hdr.int_ingress_port_id_header.setValid(); hdr.int_ingress_port_id_header.ingress_port_id = meta.ingress_metadata.ifindex; } @name("int_set_header_0003_i4") action int_set_header_0003_i4() { @@ -1807,7 +1807,7 @@ control process_int_insertion(inout headers hdr, inout metadata meta, inout stan int_set_header_1(); } @name("int_set_header_0") action int_set_header_0() { - hdr.int_switch_id_header.setValid(true); + hdr.int_switch_id_header.setValid(); hdr.int_switch_id_header.switch_id = meta.int_metadata.switch_id; } @name("int_set_header_0003_i8") action int_set_header_0003_i8() { @@ -1849,14 +1849,14 @@ control process_int_insertion(inout headers hdr, inout metadata meta, inout stan @name("int_set_header_0407_i0") action int_set_header_0407_i0() { } @name("int_set_header_7") action int_set_header_7() { - hdr.int_egress_port_tx_utilization_header.setValid(true); + hdr.int_egress_port_tx_utilization_header.setValid(); hdr.int_egress_port_tx_utilization_header.egress_port_tx_utilization = 31w0x7fffffff; } @name("int_set_header_0407_i1") action int_set_header_0407_i1() { int_set_header_7(); } @name("int_set_header_6") action int_set_header_6() { - hdr.int_q_congestion_header.setValid(true); + hdr.int_q_congestion_header.setValid(); hdr.int_q_congestion_header.q_congestion = 31w0x7fffffff; } @name("int_set_header_0407_i2") action int_set_header_0407_i2() { @@ -1867,7 +1867,7 @@ control process_int_insertion(inout headers hdr, inout metadata meta, inout stan int_set_header_6(); } @name("int_set_header_5") action int_set_header_5() { - hdr.int_egress_port_id_header.setValid(true); + hdr.int_egress_port_id_header.setValid(); hdr.int_egress_port_id_header.egress_port_id = standard_metadata.egress_port; } @name("int_set_header_0407_i4") action int_set_header_0407_i4() { @@ -1887,7 +1887,7 @@ control process_int_insertion(inout headers hdr, inout metadata meta, inout stan int_set_header_5(); } @name("int_set_header_4") action int_set_header_4() { - hdr.int_ingress_tstamp_header.setValid(true); + hdr.int_ingress_tstamp_header.setValid(); hdr.int_ingress_tstamp_header.ingress_tstamp = meta.i2e_metadata.ingress_tstamp; } @name("int_set_header_0407_i8") action int_set_header_0407_i8() { @@ -2145,60 +2145,60 @@ control process_tunnel_encap(inout headers hdr, inout metadata meta, inout stand hdr.inner_ipv4 = hdr.ipv4; hdr.inner_udp = hdr.udp; meta.egress_metadata.payload_length = hdr.ipv4.totalLen; - hdr.udp.setValid(false); - hdr.ipv4.setValid(false); + hdr.udp.setInvalid(); + hdr.ipv4.setInvalid(); } @name("inner_ipv4_tcp_rewrite") action inner_ipv4_tcp_rewrite() { hdr.inner_ipv4 = hdr.ipv4; hdr.inner_tcp = hdr.tcp; meta.egress_metadata.payload_length = hdr.ipv4.totalLen; - hdr.tcp.setValid(false); - hdr.ipv4.setValid(false); + hdr.tcp.setInvalid(); + hdr.ipv4.setInvalid(); } @name("inner_ipv4_icmp_rewrite") action inner_ipv4_icmp_rewrite() { hdr.inner_ipv4 = hdr.ipv4; hdr.inner_icmp = hdr.icmp; meta.egress_metadata.payload_length = hdr.ipv4.totalLen; - hdr.icmp.setValid(false); - hdr.ipv4.setValid(false); + hdr.icmp.setInvalid(); + hdr.ipv4.setInvalid(); } @name("inner_ipv4_unknown_rewrite") action inner_ipv4_unknown_rewrite() { hdr.inner_ipv4 = hdr.ipv4; meta.egress_metadata.payload_length = hdr.ipv4.totalLen; - hdr.ipv4.setValid(false); + hdr.ipv4.setInvalid(); } @name("inner_ipv6_udp_rewrite") action inner_ipv6_udp_rewrite() { hdr.inner_ipv6 = hdr.ipv6; hdr.inner_udp = hdr.udp; meta.egress_metadata.payload_length = hdr.ipv6.payloadLen + 16w40; - hdr.ipv6.setValid(false); + hdr.ipv6.setInvalid(); } @name("inner_ipv6_tcp_rewrite") action inner_ipv6_tcp_rewrite() { hdr.inner_ipv6 = hdr.ipv6; hdr.inner_tcp = hdr.tcp; meta.egress_metadata.payload_length = hdr.ipv6.payloadLen + 16w40; - hdr.tcp.setValid(false); - hdr.ipv6.setValid(false); + hdr.tcp.setInvalid(); + hdr.ipv6.setInvalid(); } @name("inner_ipv6_icmp_rewrite") action inner_ipv6_icmp_rewrite() { hdr.inner_ipv6 = hdr.ipv6; hdr.inner_icmp = hdr.icmp; meta.egress_metadata.payload_length = hdr.ipv6.payloadLen + 16w40; - hdr.icmp.setValid(false); - hdr.ipv6.setValid(false); + hdr.icmp.setInvalid(); + hdr.ipv6.setInvalid(); } @name("inner_ipv6_unknown_rewrite") action inner_ipv6_unknown_rewrite() { hdr.inner_ipv6 = hdr.ipv6; meta.egress_metadata.payload_length = hdr.ipv6.payloadLen + 16w40; - hdr.ipv6.setValid(false); + hdr.ipv6.setInvalid(); } @name("inner_non_ip_rewrite") action inner_non_ip_rewrite() { meta.egress_metadata.payload_length = standard_metadata.packet_length + (bit<32>)16w65522; } @name("f_insert_vxlan_header") action f_insert_vxlan_header() { hdr.inner_ethernet = hdr.ethernet; - hdr.udp.setValid(true); - hdr.vxlan.setValid(true); + hdr.udp.setValid(); + hdr.vxlan.setValid(); hdr.udp.srcPort = meta.hash_metadata.entropy_hash; hdr.udp.dstPort = 16w4789; hdr.udp.checksum = 16w0; @@ -2209,7 +2209,7 @@ control process_tunnel_encap(inout headers hdr, inout metadata meta, inout stand hdr.vxlan.reserved2 = 8w0; } @name("f_insert_ipv4_header") action f_insert_ipv4_header(in bit<8> proto) { - hdr.ipv4.setValid(true); + hdr.ipv4.setValid(); hdr.ipv4.protocol = proto; hdr.ipv4.ttl = 8w64; hdr.ipv4.version = 4w0x4; @@ -2223,7 +2223,7 @@ control process_tunnel_encap(inout headers hdr, inout metadata meta, inout stand hdr.ethernet.etherType = 16w0x800; } @name("f_insert_ipv6_header") action f_insert_ipv6_header(in bit<8> proto) { - hdr.ipv6.setValid(true); + hdr.ipv6.setValid(); hdr.ipv6.version = 4w0x6; hdr.ipv6.nextHdr = proto; hdr.ipv6.hopLimit = 8w64; @@ -2238,8 +2238,8 @@ control process_tunnel_encap(inout headers hdr, inout metadata meta, inout stand } @name("f_insert_genv_header") action f_insert_genv_header() { hdr.inner_ethernet = hdr.ethernet; - hdr.udp.setValid(true); - hdr.genv.setValid(true); + hdr.udp.setValid(); + hdr.genv.setValid(); hdr.udp.srcPort = meta.hash_metadata.entropy_hash; hdr.udp.dstPort = 16w6081; hdr.udp.checksum = 16w0; @@ -2267,8 +2267,8 @@ control process_tunnel_encap(inout headers hdr, inout metadata meta, inout stand } @name("f_insert_nvgre_header") action f_insert_nvgre_header() { hdr.inner_ethernet = hdr.ethernet; - hdr.gre.setValid(true); - hdr.nvgre.setValid(true); + hdr.gre.setValid(); + hdr.nvgre.setValid(); hdr.gre.proto = 16w0x6558; hdr.gre.recurse = 3w0; hdr.gre.flags = 5w0; @@ -2294,7 +2294,7 @@ control process_tunnel_encap(inout headers hdr, inout metadata meta, inout stand hdr.ethernet.etherType = 16w0x86dd; } @name("f_insert_gre_header") action f_insert_gre_header() { - hdr.gre.setValid(true); + hdr.gre.setValid(); } @name("ipv4_gre_rewrite") action ipv4_gre_rewrite() { f_insert_gre_header(); @@ -2332,8 +2332,8 @@ control process_tunnel_encap(inout headers hdr, inout metadata meta, inout stand } @name("f_insert_erspan_t3_header") action f_insert_erspan_t3_header() { hdr.inner_ethernet = hdr.ethernet; - hdr.gre.setValid(true); - hdr.erspan_t3_header.setValid(true); + hdr.gre.setValid(); + hdr.erspan_t3_header.setValid(); hdr.gre.C = 1w0; hdr.gre.R = 1w0; hdr.gre.K = 1w0; @@ -2433,40 +2433,40 @@ control process_tunnel_encap(inout headers hdr, inout metadata meta, inout stand meta.tunnel_metadata.tunnel_dmac_index = dmac_idx; } @name("cpu_rx_rewrite") action cpu_rx_rewrite() { - hdr.fabric_header.setValid(true); + hdr.fabric_header.setValid(); hdr.fabric_header.headerVersion = 2w0; hdr.fabric_header.packetVersion = 2w0; hdr.fabric_header.pad1 = 1w0; hdr.fabric_header.packetType = 3w5; - hdr.fabric_header_cpu.setValid(true); + hdr.fabric_header_cpu.setValid(); hdr.fabric_header_cpu.ingressPort = meta.ingress_metadata.ingress_port; hdr.fabric_header_cpu.ingressIfindex = meta.ingress_metadata.ifindex; hdr.fabric_header_cpu.ingressBd = meta.ingress_metadata.bd; hdr.fabric_header_cpu.reasonCode = meta.fabric_metadata.reason_code; - hdr.fabric_payload_header.setValid(true); + hdr.fabric_payload_header.setValid(); hdr.fabric_payload_header.etherType = hdr.ethernet.etherType; hdr.ethernet.etherType = 16w0x9000; } @name("fabric_unicast_rewrite") action fabric_unicast_rewrite() { - hdr.fabric_header.setValid(true); + hdr.fabric_header.setValid(); hdr.fabric_header.headerVersion = 2w0; hdr.fabric_header.packetVersion = 2w0; hdr.fabric_header.pad1 = 1w0; hdr.fabric_header.packetType = 3w1; hdr.fabric_header.dstDevice = meta.fabric_metadata.dst_device; hdr.fabric_header.dstPortOrGroup = meta.fabric_metadata.dst_port; - hdr.fabric_header_unicast.setValid(true); + hdr.fabric_header_unicast.setValid(); hdr.fabric_header_unicast.tunnelTerminate = meta.tunnel_metadata.tunnel_terminate; hdr.fabric_header_unicast.routed = meta.l3_metadata.routed; hdr.fabric_header_unicast.outerRouted = meta.l3_metadata.outer_routed; hdr.fabric_header_unicast.ingressTunnelType = meta.tunnel_metadata.ingress_tunnel_type; hdr.fabric_header_unicast.nexthopIndex = meta.l3_metadata.nexthop_index; - hdr.fabric_payload_header.setValid(true); + hdr.fabric_payload_header.setValid(); hdr.fabric_payload_header.etherType = hdr.ethernet.etherType; hdr.ethernet.etherType = 16w0x9000; } @name("fabric_multicast_rewrite") action fabric_multicast_rewrite(bit<16> fabric_mgid) { - hdr.fabric_header.setValid(true); + hdr.fabric_header.setValid(); hdr.fabric_header.headerVersion = 2w0; hdr.fabric_header.packetVersion = 2w0; hdr.fabric_header.pad1 = 1w0; @@ -2475,13 +2475,13 @@ control process_tunnel_encap(inout headers hdr, inout metadata meta, inout stand hdr.fabric_header.dstPortOrGroup = fabric_mgid; hdr.fabric_header_multicast.ingressIfindex = meta.ingress_metadata.ifindex; hdr.fabric_header_multicast.ingressBd = meta.ingress_metadata.bd; - hdr.fabric_header_multicast.setValid(true); + hdr.fabric_header_multicast.setValid(); hdr.fabric_header_multicast.tunnelTerminate = meta.tunnel_metadata.tunnel_terminate; hdr.fabric_header_multicast.routed = meta.l3_metadata.routed; hdr.fabric_header_multicast.outerRouted = meta.l3_metadata.outer_routed; hdr.fabric_header_multicast.ingressTunnelType = meta.tunnel_metadata.ingress_tunnel_type; hdr.fabric_header_multicast.mcastGrp = meta.multicast_metadata.mcast_grp; - hdr.fabric_payload_header.setValid(true); + hdr.fabric_payload_header.setValid(); hdr.fabric_payload_header.etherType = hdr.ethernet.etherType; hdr.ethernet.etherType = 16w0x9000; } @@ -2682,14 +2682,14 @@ control process_vlan_xlate(inout headers hdr, inout metadata meta, inout standar @name("set_egress_packet_vlan_untagged") action set_egress_packet_vlan_untagged() { } @name("set_egress_packet_vlan_tagged") action set_egress_packet_vlan_tagged(bit<12> vlan_id) { - hdr.vlan_tag_[0].setValid(true); + hdr.vlan_tag_[0].setValid(); hdr.vlan_tag_[0].etherType = hdr.ethernet.etherType; hdr.vlan_tag_[0].vid = vlan_id; hdr.ethernet.etherType = 16w0x8100; } @name("set_egress_packet_vlan_double_tagged") action set_egress_packet_vlan_double_tagged(bit<12> s_tag, bit<12> c_tag) { - hdr.vlan_tag_[1].setValid(true); - hdr.vlan_tag_[0].setValid(true); + hdr.vlan_tag_[1].setValid(); + hdr.vlan_tag_[0].setValid(); hdr.vlan_tag_[1].etherType = hdr.ethernet.etherType; hdr.vlan_tag_[1].vid = c_tag; hdr.vlan_tag_[0].etherType = 16w0x8100; @@ -4280,9 +4280,9 @@ control process_ingress_fabric(inout headers hdr, inout metadata meta, inout sta standard_metadata.egress_spec = hdr.fabric_header.dstPortOrGroup; meta.egress_metadata.bypass = hdr.fabric_header_cpu.txBypass; hdr.ethernet.etherType = hdr.fabric_payload_header.etherType; - hdr.fabric_header.setValid(false); - hdr.fabric_header_cpu.setValid(false); - hdr.fabric_payload_header.setValid(false); + hdr.fabric_header.setInvalid(); + hdr.fabric_header_cpu.setInvalid(); + hdr.fabric_payload_header.setInvalid(); } @name("switch_fabric_unicast_packet") action switch_fabric_unicast_packet() { meta.fabric_metadata.fabric_header_present = 1w1; @@ -4297,9 +4297,9 @@ control process_ingress_fabric(inout headers hdr, inout metadata meta, inout sta meta.l3_metadata.routed = hdr.fabric_header_unicast.routed; meta.l3_metadata.outer_routed = hdr.fabric_header_unicast.outerRouted; hdr.ethernet.etherType = hdr.fabric_payload_header.etherType; - hdr.fabric_header.setValid(false); - hdr.fabric_header_unicast.setValid(false); - hdr.fabric_payload_header.setValid(false); + hdr.fabric_header.setInvalid(); + hdr.fabric_header_unicast.setInvalid(); + hdr.fabric_payload_header.setInvalid(); } @name("switch_fabric_multicast_packet") action switch_fabric_multicast_packet() { meta.fabric_metadata.fabric_header_present = 1w1; @@ -4313,9 +4313,9 @@ control process_ingress_fabric(inout headers hdr, inout metadata meta, inout sta meta.l3_metadata.outer_routed = hdr.fabric_header_multicast.outerRouted; meta.intrinsic_metadata.mcast_grp = hdr.fabric_header_multicast.mcastGrp; hdr.ethernet.etherType = hdr.fabric_payload_header.etherType; - hdr.fabric_header.setValid(false); - hdr.fabric_header_multicast.setValid(false); - hdr.fabric_payload_header.setValid(false); + hdr.fabric_header.setInvalid(); + hdr.fabric_header_multicast.setInvalid(); + hdr.fabric_payload_header.setInvalid(); } @name("set_ingress_ifindex_properties") action set_ingress_ifindex_properties() { }