Skip to content

Commit

Permalink
Remove ReferenceMap recalculation (almost) everywhere and switch to m…
Browse files Browse the repository at this point in the history
…ore fine-grained solutions (#4757)

* Get rid of unused RefMap in ConstantTypeSubstitution

Signed-off-by: Anton Korobeynikov <[email protected]>

* Convert ConstantFolding to DeclarationLookup

Signed-off-by: Anton Korobeynikov <[email protected]>

* Convert SyntacticEquivalence to DeclarationLookup

Signed-off-by: Anton Korobeynikov <[email protected]>

* Switch SubstituteParameters to DeclarationLookup. It stops populating
refmap with cloned paths, but it seems it does not matter according to
tests. In any way, the refmap was not fully correct after it.

Signed-off-by: Anton Korobeynikov <[email protected]>

* Switch TypeInference to ResolutionContext

Signed-off-by: Anton Korobeynikov <[email protected]>

* Remove refMap dependency from TypeChecking entirely. Clean up corresponding API around

Signed-off-by: Anton Korobeynikov <[email protected]>

* Make DiscoverActionsInlining a ResolutionContext: no ReferenceMap is required

Signed-off-by: Anton Korobeynikov <[email protected]>

* Switch action inliner not to use ReferenceMap

Signed-off-by: Anton Korobeynikov <[email protected]>

* Update tests

Signed-off-by: Anton Korobeynikov <[email protected]>

* Finally remove ReferenceMap recalculation from ActionsInliner

Signed-off-by: Anton Korobeynikov <[email protected]>

* Switch to abseil time routines in time tracker

Signed-off-by: Anton Korobeynikov <[email protected]>

* Ensure name generator is inherited for nested TypeInference calls

Signed-off-by: Anton Korobeynikov <[email protected]>

* Ensure we always resolve to original declaration, not to the cloned one.
This is particular important when mixing ResolveReferences with a Transform:
various maps (e.g. TypeMap) are formulated in terms of original IR, not cloned.

Signed-off-by: Anton Korobeynikov <[email protected]>

* Make DefaultArguments not to require ReferenceMap

Signed-off-by: Anton Korobeynikov <[email protected]>

* Remove ReferenceMap from CheckCoreMethods

Signed-off-by: Anton Korobeynikov <[email protected]>

* Move EntryPriorities to ResolutionContext

Signed-off-by: Anton Korobeynikov <[email protected]>

* Remove RefMap from SpecializeGenericTypes

Signed-off-by: Anton Korobeynikov <[email protected]>

* Remove RefMap from SpecializeGenericFunctions

Signed-off-by: Anton Korobeynikov <[email protected]>

* Make StrengthReduce refmap-independent

Signed-off-by: Anton Korobeynikov <[email protected]>

* Make DoConstantFolding a ResolutionContext, so it could resolve if necessary

Signed-off-by: Anton Korobeynikov <[email protected]>

* Remove refmap from frontent ConstantFolding invocation

Signed-off-by: Anton Korobeynikov <[email protected]>

* Make UniqueNames refmap-less

Signed-off-by: Anton Korobeynikov <[email protected]>

* Remove RefMap from RemoveParserControlFlow

Signed-off-by: Anton Korobeynikov <[email protected]>

* Switch TableApply to DeclarationLookup

Signed-off-by: Anton Korobeynikov <[email protected]>

* Get rid of RefMap from DirectCalls

Signed-off-by: Anton Korobeynikov <[email protected]>

* Switch Deprecated to ResolutionContext

Signed-off-by: Anton Korobeynikov <[email protected]>

* DefaultValues does not use RefMap at all

Signed-off-by: Anton Korobeynikov <[email protected]>

* No need for RefMap in BindVariables

Signed-off-by: Anton Korobeynikov <[email protected]>

* Move StaticAsserts to ResolutionContext

Signed-off-by: Anton Korobeynikov <[email protected]>

* Move StructInitializers to ResolutionContext

Signed-off-by: Anton Korobeynikov <[email protected]>

* TableKeyNames does not need refMap

Signed-off-by: Anton Korobeynikov <[email protected]>

* ResetHeaders do not need RefMap

Signed-off-by: Anton Korobeynikov <[email protected]>

* Remove MoveDeclarations out of RefMap

Signed-off-by: Anton Korobeynikov <[email protected]>

* No need for refMap in SimplifySwitch

Signed-off-by: Anton Korobeynikov <[email protected]>

* Make UniqueParameters RefMap-less

Signed-off-by: Anton Korobeynikov <[email protected]>

* Remove refMap from RemoveReturns / RemoveExits

Signed-off-by: Anton Korobeynikov <[email protected]>

* Remove RefMap from DontcareArgs

Signed-off-by: Anton Korobeynikov <[email protected]>

* Remove refmap from MoveConstructors

Signed-off-by: Anton Korobeynikov <[email protected]>

* Move RemoveActionParameters out of RefMap

Signed-off-by: Anton Korobeynikov <[email protected]>

* SetHeaders do not use RefMap

Signed-off-by: Anton Korobeynikov <[email protected]>

* Remove RefMap from CheckConstants

Signed-off-by: Anton Korobeynikov <[email protected]>

* Reduce RefMap proliferation in LocalizeActions

Signed-off-by: Anton Korobeynikov <[email protected]>

* Remove much of refMap usage from functions inlining

Signed-off-by: Anton Korobeynikov <[email protected]>

* Remove refMap from SimplifyControlFlow and around

Signed-off-by: Anton Korobeynikov <[email protected]>

* Reduce refMap dependency inside Specialize

Signed-off-by: Anton Korobeynikov <[email protected]>

* Reduce refMap usage around SimplifyExpressions

Signed-off-by: Anton Korobeynikov <[email protected]>

* Silence a warning

Signed-off-by: Anton Korobeynikov <[email protected]>

* Remove RefMap from DoSimplifyExpressions

Signed-off-by: Anton Korobeynikov <[email protected]>

* Recognize nested TypeInference learners

Signed-off-by: Anton Korobeynikov <[email protected]>

* Restore type checking instead of inference to emphasize read-only mode here

Signed-off-by: Anton Korobeynikov <[email protected]>

* Restore old renaming scheme

Signed-off-by: Anton Korobeynikov <[email protected]>

* Do not recalculate name generator contents on each inliner iteration

Signed-off-by: Anton Korobeynikov <[email protected]>

* Reformat

Signed-off-by: Anton Korobeynikov <[email protected]>

* Add fixme about declaration lookup caching

Signed-off-by: Anton Korobeynikov <[email protected]>

* Make visitor context required for alias analysis routines

Signed-off-by: Anton Korobeynikov <[email protected]>

* Get rid of PassManager for MoveConstructors

Signed-off-by: Anton Korobeynikov <[email protected]>

* Get rid of EntryPriorities PassManager wrapper

Signed-off-by: Anton Korobeynikov <[email protected]>

* Remove PassManager wrapper over InstantiateDirectCalls

Signed-off-by: Anton Korobeynikov <[email protected]>

* Remove PassManager from Deprecated

Signed-off-by: Anton Korobeynikov <[email protected]>

---------

Signed-off-by: Anton Korobeynikov <[email protected]>
  • Loading branch information
asl authored Jun 28, 2024
1 parent 36fa73d commit 274c508
Show file tree
Hide file tree
Showing 100 changed files with 1,129 additions and 978 deletions.
22 changes: 14 additions & 8 deletions backends/bmv2/psa_switch/midend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ PsaSwitchMidEnd::PsaSwitchMidEnd(CompilerOptions &options, std::ostream *outStre
&refMap, &typeMap,
new P4::OrPolicy(new P4::IsValid(&refMap, &typeMap), new P4::IsMask())),
new P4::ConstantFolding(&refMap, &typeMap),
new P4::StrengthReduction(&refMap, &typeMap),
new P4::StrengthReduction(&typeMap),
new P4::SimplifySelectCases(&refMap, &typeMap, true), // require constant keysets
new P4::ExpandLookahead(&refMap, &typeMap),
new P4::ExpandEmit(&refMap, &typeMap),
new P4::SimplifyParsers(&refMap),
new P4::StrengthReduction(&refMap, &typeMap),
new P4::StrengthReduction(&typeMap),
new P4::EliminateTuples(&refMap, &typeMap),
new P4::SimplifyComparisons(&refMap, &typeMap),
new P4::CopyStructures(&refMap, &typeMap),
Expand All @@ -142,13 +142,19 @@ PsaSwitchMidEnd::PsaSwitchMidEnd(CompilerOptions &options, std::ostream *outStre
new P4::MoveDeclarations(), // more may have been introduced
new P4::ConstantFolding(&refMap, &typeMap),
new P4::LocalCopyPropagation(&refMap, &typeMap, nullptr, policy),
new PassRepeated({new P4::ConstantFolding(&refMap, &typeMap),
new P4::StrengthReduction(&refMap, &typeMap)}),
new PassRepeated({
new P4::ConstantFolding(&refMap, &typeMap),
new P4::StrengthReduction(&typeMap),
}),
new P4::MoveDeclarations(),
new P4::ValidateTableProperties({"psa_implementation"_cs, "psa_direct_counter"_cs,
"psa_direct_meter"_cs, "psa_idle_timeout"_cs,
"size"_cs}),
new P4::SimplifyControlFlow(&refMap, &typeMap),
new P4::ValidateTableProperties({
"psa_implementation"_cs,
"psa_direct_counter"_cs,
"psa_direct_meter"_cs,
"psa_idle_timeout"_cs,
"size"_cs,
}),
new P4::SimplifyControlFlow(&typeMap),
new P4::CompileTimeOperations(),
new P4::TableHit(&refMap, &typeMap),
new P4::EliminateSwitch(&refMap, &typeMap),
Expand Down
10 changes: 6 additions & 4 deletions backends/bmv2/psa_switch/psaSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,16 @@ void PsaSwitchBackend::convert(const IR::ToplevelBlock *tlb) {
new SkipControls(&structure.non_pipeline_controls)),
new P4::MoveActionsToTables(refMap, typeMap),
new P4::TypeChecking(refMap, typeMap),
new P4::SimplifyControlFlow(refMap, typeMap),
new P4::SimplifyControlFlow(typeMap),
new LowerExpressions(typeMap),
new PassRepeated(
{new P4::ConstantFolding(refMap, typeMap), new P4::StrengthReduction(refMap, typeMap)}),
new PassRepeated({
new P4::ConstantFolding(refMap, typeMap),
new P4::StrengthReduction(typeMap),
}),
new P4::TypeChecking(refMap, typeMap),
new P4::RemoveComplexExpressions(refMap, typeMap,
new ProcessControls(&structure.pipeline_controls)),
new P4::SimplifyControlFlow(refMap, typeMap),
new P4::SimplifyControlFlow(typeMap),
new P4::RemoveAllUnusedDeclarations(refMap, P4::RemoveUnusedPolicy()),
// Converts the DAG into a TREE (at least for expressions)
// This is important later for conversion to JSON.
Expand Down
21 changes: 14 additions & 7 deletions backends/bmv2/simple_switch/midend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ SimpleSwitchMidEnd::SimpleSwitchMidEnd(CompilerOptions &options, std::ostream *o
&refMap, &typeMap,
new P4::OrPolicy(new P4::IsValid(&refMap, &typeMap), new P4::IsMask())),
new P4::ConstantFolding(&refMap, &typeMap),
new P4::StrengthReduction(&refMap, &typeMap),
new P4::StrengthReduction(&typeMap),
new P4::SimplifySelectCases(&refMap, &typeMap, true), // require constant keysets
new P4::ExpandLookahead(&refMap, &typeMap),
new P4::ExpandEmit(&refMap, &typeMap),
new P4::SimplifyParsers(&refMap),
new P4::StrengthReduction(&refMap, &typeMap),
new P4::StrengthReduction(&typeMap),
new P4::EliminateTuples(&refMap, &typeMap),
new P4::SimplifyComparisons(&refMap, &typeMap),
new P4::CopyStructures(&refMap, &typeMap),
Expand All @@ -111,15 +111,22 @@ SimpleSwitchMidEnd::SimpleSwitchMidEnd(CompilerOptions &options, std::ostream *o
new P4::MoveDeclarations(), // more may have been introduced
new P4::ConstantFolding(&refMap, &typeMap),
new P4::LocalCopyPropagation(&refMap, &typeMap),
new PassRepeated({new P4::ConstantFolding(&refMap, &typeMap),
new P4::StrengthReduction(&refMap, &typeMap)}),
new PassRepeated({
new P4::ConstantFolding(&refMap, &typeMap),
new P4::StrengthReduction(&typeMap),
}),
new P4::SimplifyKey(
&refMap, &typeMap,
new P4::OrPolicy(new P4::IsValid(&refMap, &typeMap), new P4::IsMask())),
new P4::MoveDeclarations(),
new P4::ValidateTableProperties({"implementation"_cs, "size"_cs, "counters"_cs,
"meters"_cs, "support_timeout"_cs}),
new P4::SimplifyControlFlow(&refMap, &typeMap),
new P4::ValidateTableProperties({
"implementation"_cs,
"size"_cs,
"counters"_cs,
"meters"_cs,
"support_timeout"_cs,
}),
new P4::SimplifyControlFlow(&typeMap),
new P4::EliminateTypedef(&refMap, &typeMap),
new P4::CompileTimeOperations(),
new P4::TableHit(&refMap, &typeMap),
Expand Down
4 changes: 2 additions & 2 deletions backends/bmv2/simple_switch/simpleSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1175,13 +1175,13 @@ void SimpleSwitchBackend::convert(const IR::ToplevelBlock *tlb) {
new SkipControls(&structure->non_pipeline_controls)),
new P4::MoveActionsToTables(refMap, typeMap),
new P4::TypeChecking(refMap, typeMap),
new P4::SimplifyControlFlow(refMap, typeMap),
new P4::SimplifyControlFlow(typeMap),
new LowerExpressions(typeMap),
new P4::ConstantFolding(refMap, typeMap, false),
new P4::TypeChecking(refMap, typeMap),
new RemoveComplexExpressions(refMap, typeMap,
new ProcessControls(&structure->pipeline_controls)),
new P4::SimplifyControlFlow(refMap, typeMap),
new P4::SimplifyControlFlow(typeMap),
new P4::RemoveAllUnusedDeclarations(refMap, P4::RemoveUnusedPolicy()),
new P4::FlattenLogMsg(refMap, typeMap),
// Converts the DAG into a TREE (at least for expressions)
Expand Down
2 changes: 1 addition & 1 deletion backends/dpdk/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void DpdkBackend::convert(const IR::ToplevelBlock *tlb) {
new P4::TypeChecking(refMap, typeMap, true),
new ConvertBinaryOperationTo2Params(refMap),
new CollectProgramStructure(refMap, typeMap, &structure),
new CopyMatchKeysToSingleStruct(refMap, typeMap, &invokedInKey, &structure),
new CopyMatchKeysToSingleStruct(typeMap, &invokedInKey, &structure),
new P4::ResolveReferences(refMap),
new CollectLocalVariables(refMap, typeMap, &structure),
new P4::ClearTypeMap(typeMap),
Expand Down
9 changes: 5 additions & 4 deletions backends/dpdk/dpdkArch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1709,7 +1709,7 @@ const IR::Node *CopyMatchKeysToSingleStruct::postorder(IR::KeyElement *element)
}

if (isHeader || metaCopyNeeded) {
IR::ID keyNameId(refMap->newName(keyName.string_view()));
IR::ID keyNameId(nameGen.newName(keyName.string_view()));
auto decl = new IR::Declaration_Variable(keyNameId, element->expression->type, nullptr);
// Store the compiler generated table keys in Program structure. These will be
// inserted to Metadata by CollectLocalVariables pass.
Expand All @@ -1724,11 +1724,12 @@ const IR::Node *CopyMatchKeysToSingleStruct::postorder(IR::KeyElement *element)
}

const IR::Node *CopyMatchKeysToSingleStruct::doStatement(const IR::Statement *statement,
const IR::Expression *expression) {
const IR::Expression *expression,
const Visitor::Context *ctxt) {
LOG3("Visiting " << getOriginal());
P4::HasTableApply hta(refMap, typeMap);
P4::HasTableApply hta(this, typeMap);
hta.setCalledBy(this);
(void)expression->apply(hta);
(void)expression->apply(hta, ctxt);
if (hta.table == nullptr) return statement;
auto insertions = get(toInsert, hta.table);
if (insertions == nullptr) return statement;
Expand Down
19 changes: 9 additions & 10 deletions backends/dpdk/dpdkArch.h
Original file line number Diff line number Diff line change
Expand Up @@ -831,17 +831,16 @@ class CopyMatchKeysToSingleStruct : public P4::KeySideEffect {
bool metaCopyNeeded = false;

public:
CopyMatchKeysToSingleStruct(P4::ReferenceMap *refMap, P4::TypeMap *typeMap,
std::set<const IR::P4Table *> *invokedInKey,
CopyMatchKeysToSingleStruct(P4::TypeMap *typeMap, std::set<const IR::P4Table *> *invokedInKey,
DpdkProgramStructure *structure)
: P4::KeySideEffect(refMap, typeMap, invokedInKey), structure(structure) {
: P4::KeySideEffect(typeMap, invokedInKey), structure(structure) {
setName("CopyMatchKeysToSingleStruct");
}

const IR::Node *preorder(IR::Key *key) override;
const IR::Node *postorder(IR::KeyElement *element) override;
const IR::Node *doStatement(const IR::Statement *statement,
const IR::Expression *expression) override;
const IR::Node *doStatement(const IR::Statement *statement, const IR::Expression *expression,
const Visitor::Context *ctxt) override;
struct keyInfo *getKeyInfo(IR::Key *keys);
cstring getTableKeyName(const IR::Expression *e);
int getFieldSizeBits(const IR::Type *field_type);
Expand Down Expand Up @@ -1184,7 +1183,7 @@ class EliminateHeaderCopy : public PassManager {
EliminateHeaderCopy(P4::ReferenceMap *refMap, P4::TypeMap *typeMap) {
passes.push_back(new P4::ClearTypeMap(typeMap));
passes.push_back(new P4::ResolveReferences(refMap));
passes.push_back(new P4::TypeInference(refMap, typeMap, false));
passes.push_back(new P4::TypeInference(typeMap, false));
passes.push_back(new P4::TypeChecking(refMap, typeMap, true));
passes.push_back(new ElimHeaderCopy(typeMap));
}
Expand Down Expand Up @@ -1435,13 +1434,13 @@ class CollectLocalStructAndFlatten : public PassManager {
CollectLocalStructAndFlatten(P4::ReferenceMap *refMap, P4::TypeMap *typeMap) {
passes.push_back(new P4::ClearTypeMap(typeMap));
passes.push_back(new P4::ResolveReferences(refMap));
passes.push_back(new P4::TypeInference(refMap, typeMap, false));
passes.push_back(new P4::TypeInference(typeMap, false));
passes.push_back(new P4::TypeChecking(refMap, typeMap, true));
passes.push_back(new CollectStructLocalVariables(refMap, typeMap));
passes.push_back(new MoveCollectedStructLocalVariableToMetadata(typeMap));
passes.push_back(new P4::ClearTypeMap(typeMap));
passes.push_back(new P4::ResolveReferences(refMap));
passes.push_back(new P4::TypeInference(refMap, typeMap, false));
passes.push_back(new P4::TypeInference(typeMap, false));
passes.push_back(new P4::TypeChecking(refMap, typeMap, true));
passes.push_back(new P4::FlattenInterfaceStructs(refMap, typeMap));
}
Expand All @@ -1464,7 +1463,7 @@ class CollectIPSecInfo : public Inspector {
typeMap(typeMap),
structure(structure) {}
bool preorder(const IR::MethodCallStatement *mcs) override {
auto mi = P4::MethodInstance::resolve(mcs->methodCall, refMap, typeMap);
auto mi = P4::MethodInstance::resolve(mcs, refMap, typeMap);
if (auto a = mi->to<P4::ExternMethod>()) {
if (a->originalExternType->getName().name == "ipsec_accelerator") {
if (structure->isPSA()) {
Expand Down Expand Up @@ -1542,7 +1541,7 @@ struct DpdkHandleIPSec : public PassManager {
passes.push_back(new InsertReqDeclForIPSec(refMap, structure, is_ipsec_used, sa_id_width));
passes.push_back(new P4::ClearTypeMap(typeMap));
passes.push_back(new P4::ResolveReferences(refMap));
passes.push_back(new P4::TypeInference(refMap, typeMap, false));
passes.push_back(new P4::TypeInference(typeMap, false));
}
};

Expand Down
18 changes: 10 additions & 8 deletions backends/dpdk/midend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ DpdkMidEnd::DpdkMidEnd(CompilerOptions &options, std::ostream *outStream) {
new P4::SimplifyKey(
&refMap, &typeMap,
new P4::OrPolicy(new P4::IsValid(&refMap, &typeMap), new P4::IsLikeLeftValue())),
new P4::RemoveExits(&refMap, &typeMap),
new P4::RemoveExits(&typeMap),
new P4::ConstantFolding(&refMap, &typeMap),
new P4::StrengthReduction(&refMap, &typeMap),
new P4::StrengthReduction(&typeMap),
new P4::SimplifySelectCases(&refMap, &typeMap, true),
// The lookahead implementation in DPDK target supports only a header instance as
// an operand, we do not expand headers.
Expand All @@ -192,7 +192,7 @@ DpdkMidEnd::DpdkMidEnd(CompilerOptions &options, std::ostream *outStream) {
new P4::ExpandEmit(&refMap, &typeMap),
new P4::HandleNoMatch(&refMap),
new P4::SimplifyParsers(&refMap),
new P4::StrengthReduction(&refMap, &typeMap),
new P4::StrengthReduction(&typeMap),
new P4::EliminateTuples(&refMap, &typeMap),
new P4::SimplifyComparisons(&refMap, &typeMap),
new P4::CopyStructures(&refMap, &typeMap, false /* errorOnMethodCall */),
Expand All @@ -205,17 +205,19 @@ DpdkMidEnd::DpdkMidEnd(CompilerOptions &options, std::ostream *outStream) {
new P4::HSIndexSimplifier(&refMap, &typeMap),
new P4::ParsersUnroll(true, &refMap, &typeMap),
new P4::FlattenHeaderUnion(&refMap, &typeMap),
new P4::SimplifyControlFlow(&refMap, &typeMap),
new P4::SimplifyControlFlow(&typeMap),
new P4::ReplaceSelectRange(&refMap, &typeMap),
new P4::MoveDeclarations(), // more may have been introduced
new P4::ConstantFolding(&refMap, &typeMap),
new P4::LocalCopyPropagation(&refMap, &typeMap, nullptr, policy),
new PassRepeated({new P4::ConstantFolding(&refMap, &typeMap),
new P4::StrengthReduction(&refMap, &typeMap)}),
new PassRepeated({
new P4::ConstantFolding(&refMap, &typeMap),
new P4::StrengthReduction(&typeMap),
}),
new P4::MoveDeclarations(),
validateTableProperties(options.arch),
new P4::SimplifyControlFlow(&refMap, &typeMap),
new P4::SimplifySwitch(&refMap, &typeMap),
new P4::SimplifyControlFlow(&typeMap),
new P4::SimplifySwitch(&typeMap),
new P4::CompileTimeOperations(),
new P4::TableHit(&refMap, &typeMap),
new P4::RemoveLeftSlices(&refMap, &typeMap),
Expand Down
12 changes: 7 additions & 5 deletions backends/ebpf/midend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,26 +84,28 @@ const IR::ToplevelBlock *MidEnd::run(EbpfOptions &options, const IR::P4Program *
new P4::RemoveMiss(&refMap, &typeMap),
new P4::EliminateInvalidHeaders(&refMap, &typeMap),
new P4::EliminateNewtype(&refMap, &typeMap),
new P4::SimplifyControlFlow(&refMap, &typeMap),
new P4::SimplifyControlFlow(&typeMap),
new P4::SimplifyKey(
&refMap, &typeMap,
new P4::OrPolicy(new P4::IsValid(&refMap, &typeMap), new P4::IsLikeLeftValue())),
new P4::RemoveExits(&refMap, &typeMap),
new P4::RemoveExits(&typeMap),
new P4::ConstantFolding(&refMap, &typeMap),
new P4::SimplifySelectCases(&refMap, &typeMap, false), // accept non-constant keysets
new P4::ExpandEmit(&refMap, &typeMap),
new P4::HandleNoMatch(&refMap),
new P4::SimplifyParsers(&refMap),
new PassRepeated({new P4::ConstantFolding(&refMap, &typeMap),
new P4::StrengthReduction(&refMap, &typeMap)}),
new PassRepeated({
new P4::ConstantFolding(&refMap, &typeMap),
new P4::StrengthReduction(&typeMap),
}),
new P4::SimplifyComparisons(&refMap, &typeMap),
new P4::EliminateTuples(&refMap, &typeMap),
new P4::SimplifySelectList(&refMap, &typeMap),
new P4::MoveDeclarations(), // more may have been introduced
new P4::RemoveSelectBooleans(&refMap, &typeMap),
new P4::SingleArgumentSelect(&refMap, &typeMap),
new P4::ConstantFolding(&refMap, &typeMap),
new P4::SimplifyControlFlow(&refMap, &typeMap),
new P4::SimplifyControlFlow(&typeMap),
new P4::TableHit(&refMap, &typeMap),
new P4::RemoveLeftSlices(&refMap, &typeMap),
new EBPF::Lower(&refMap, &typeMap),
Expand Down
14 changes: 7 additions & 7 deletions backends/p4test/midend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,19 @@ MidEnd::MidEnd(CompilerOptions &options, std::ostream *outStream) {
new P4::SimplifyKey(
&refMap, &typeMap,
new P4::OrPolicy(new P4::IsValid(&refMap, &typeMap), new P4::IsLikeLeftValue())),
new P4::RemoveExits(&refMap, &typeMap),
new P4::RemoveExits(&typeMap),
new P4::ConstantFolding(&refMap, &typeMap),
new P4::SimplifySelectCases(&refMap, &typeMap, false), // non-constant keysets
new P4::ExpandLookahead(&refMap, &typeMap),
new P4::ExpandEmit(&refMap, &typeMap),
new P4::HandleNoMatch(&refMap),
new P4::SimplifyParsers(&refMap),
new P4::StrengthReduction(&refMap, &typeMap),
new P4::StrengthReduction(&typeMap),
new P4::EliminateTuples(&refMap, &typeMap),
new P4::SimplifyComparisons(&refMap, &typeMap),
new P4::CopyStructures(&refMap, &typeMap, false),
new P4::NestedStructs(&refMap, &typeMap),
new P4::StrengthReduction(&refMap, &typeMap),
new P4::StrengthReduction(&typeMap),
new P4::SimplifySelectList(&refMap, &typeMap),
new P4::RemoveSelectBooleans(&refMap, &typeMap),
new P4::FlattenHeaders(&refMap, &typeMap),
Expand All @@ -119,9 +119,9 @@ MidEnd::MidEnd(CompilerOptions &options, std::ostream *outStream) {
new P4::LocalCopyPropagation(&refMap, &typeMap),
new P4::ConstantFolding(&refMap, &typeMap),
}),
new P4::StrengthReduction(&refMap, &typeMap),
new P4::StrengthReduction(&typeMap),
new P4::MoveDeclarations(), // more may have been introduced
new P4::SimplifyControlFlow(&refMap, &typeMap),
new P4::SimplifyControlFlow(&typeMap),
new P4::CompileTimeOperations(),
new P4::TableHit(&refMap, &typeMap),
new P4::EliminateSwitch(&refMap, &typeMap),
Expand All @@ -132,7 +132,7 @@ MidEnd::MidEnd(CompilerOptions &options, std::ostream *outStream) {
new P4::UnrollLoops(refMap, defUse),
new P4::LocalCopyPropagation(&refMap, &typeMap),
new P4::ConstantFolding(&refMap, &typeMap),
new P4::StrengthReduction(&refMap, &typeMap),
new P4::StrengthReduction(&typeMap),
}),
new P4::MoveDeclarations(), // more may have been introduced
evaluator,
Expand Down Expand Up @@ -166,7 +166,7 @@ MidEnd::MidEnd(CompilerOptions &options, std::ostream *outStream) {
evaluator,
[this, evaluator]() { toplevel = evaluator->getToplevelBlock(); },
new P4::FlattenHeaderUnion(&refMap, &typeMap, options.loopsUnrolling),
new P4::SimplifyControlFlow(&refMap, &typeMap),
new P4::SimplifyControlFlow(&typeMap),
new P4::MidEndLast()});
if (options.listMidendPasses) {
listPasses(*outStream, cstring::newline);
Expand Down
Loading

0 comments on commit 274c508

Please sign in to comment.