Skip to content

Commit

Permalink
frontend policy fix: missed ConstantFolding
Browse files Browse the repository at this point in the history
Pass the ConstantFoldingPolicy instance to the ConstantFolding instance
in SpecializeAll. This was missed in #4406.
  • Loading branch information
grg authored and vlstill committed Feb 14, 2024
1 parent 4b3d4bc commit bd5d9a9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion frontends/p4/frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ const IR::P4Program *FrontEnd::run(const CompilerOptions &options, const IR::P4P
new SimplifyDefUse(&refMap, &typeMap),
new UniqueParameters(&refMap, &typeMap),
new SimplifyControlFlow(&refMap, &typeMap),
new SpecializeAll(&refMap, &typeMap),
new SpecializeAll(&refMap, &typeMap, constantFoldingPolicy),
new RemoveParserControlFlow(&refMap, &typeMap),
new RemoveReturns(&refMap),
new RemoveDontcareArgs(&refMap, &typeMap),
Expand Down
6 changes: 4 additions & 2 deletions frontends/p4/specialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,10 @@ const IR::Node *Specialize::postorder(IR::Declaration_Instance *decl) {
return instantiate(replacement);
}

SpecializeAll::SpecializeAll(ReferenceMap *refMap, TypeMap *typeMap) : PassRepeated({}) {
passes.emplace_back(new ConstantFolding(refMap, typeMap));
SpecializeAll::SpecializeAll(ReferenceMap *refMap, TypeMap *typeMap,
ConstantFoldingPolicy *constantFoldingPolicy)
: PassRepeated({}) {
passes.emplace_back(new ConstantFolding(refMap, typeMap, constantFoldingPolicy));
passes.emplace_back(new TypeChecking(refMap, typeMap));
passes.emplace_back(new FindSpecializations(&specMap));
passes.emplace_back(new Specialize(&specMap));
Expand Down
3 changes: 2 additions & 1 deletion frontends/p4/specialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ class SpecializeAll : public PassRepeated {
SpecializationMap specMap;

public:
SpecializeAll(ReferenceMap *refMap, TypeMap *typeMap);
SpecializeAll(ReferenceMap *refMap, TypeMap *typeMap,
ConstantFoldingPolicy *constantFoldingPolicy);
};

} // namespace P4
Expand Down

0 comments on commit bd5d9a9

Please sign in to comment.