Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a frontend policy as a customization point for frontend #4406

Merged
merged 8 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add missing const on the policy interface return type
  • Loading branch information
vlstill committed Feb 13, 2024
commit 0902ee25853d963877bc36ce1c131662bc1c9a9e
2 changes: 1 addition & 1 deletion frontends/common/constantFolding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const IR::Expression *DoConstantFolding::getConstant(const IR::Expression *expr)
}

const IR::Node *DoConstantFolding::postorder(IR::PathExpression *e) {
if (auto *r = policy->hook(*this, e)) return r;
if (const auto *r = policy->hook(*this, e)) return r;
if (refMap == nullptr || assignmentTarget) return e;
auto decl = refMap->getDeclaration(e->path);
if (decl == nullptr) return e;
Expand Down
2 changes: 1 addition & 1 deletion frontends/common/constantFolding.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace P4 {
class ConstantFoldingPolicy {
public:
/// The default hook does not modify anything.
virtual IR::Node *hook(Visitor &, IR::PathExpression *) { return nullptr; }
virtual const IR::Node *hook(Visitor &, IR::PathExpression *) { return nullptr; }
};

/** @brief statically evaluates many constant expressions.
Expand Down
Loading