diff options
Diffstat (limited to 'libyul/optimiser/SimplificationRules.cpp')
-rw-r--r-- | libyul/optimiser/SimplificationRules.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/libyul/optimiser/SimplificationRules.cpp b/libyul/optimiser/SimplificationRules.cpp index 45b0ca2c..1b620b64 100644 --- a/libyul/optimiser/SimplificationRules.cpp +++ b/libyul/optimiser/SimplificationRules.cpp @@ -20,11 +20,11 @@ #include <libyul/optimiser/SimplificationRules.h> -#include <libyul/optimiser/Utilities.h> #include <libyul/optimiser/ASTCopier.h> #include <libyul/optimiser/Semantics.h> #include <libyul/optimiser/SyntacticalEquality.h> #include <libyul/AsmData.h> +#include <libyul/Utilities.h> #include <libevmasm/RuleList.h> @@ -36,6 +36,7 @@ using namespace yul; SimplificationRule<Pattern> const* SimplificationRules::findFirstMatch( Expression const& _expr, + Dialect const& _dialect, map<YulString, Expression const*> const& _ssaValues ) { @@ -49,7 +50,7 @@ SimplificationRule<Pattern> const* SimplificationRules::findFirstMatch( for (auto const& rule: rules.m_rules[uint8_t(instruction.instruction)]) { rules.resetMatchGroups(); - if (rule.pattern.matches(_expr, _ssaValues)) + if (rule.pattern.matches(_expr, _dialect, _ssaValues)) return &rule; } return nullptr; @@ -104,7 +105,11 @@ void Pattern::setMatchGroup(unsigned _group, map<unsigned, Expression const*>& _ m_matchGroups = &_matchGroups; } -bool Pattern::matches(Expression const& _expr, map<YulString, Expression const*> const& _ssaValues) const +bool Pattern::matches( + Expression const& _expr, + Dialect const& _dialect, + map<YulString, Expression const*> const& _ssaValues +) const { Expression const* expr = &_expr; @@ -139,7 +144,7 @@ bool Pattern::matches(Expression const& _expr, map<YulString, Expression const*> return false; assertThrow(m_arguments.size() == instr.arguments.size(), OptimizerException, ""); for (size_t i = 0; i < m_arguments.size(); ++i) - if (!m_arguments[i].matches(instr.arguments.at(i), _ssaValues)) + if (!m_arguments[i].matches(instr.arguments.at(i), _dialect, _ssaValues)) return false; } else @@ -166,8 +171,8 @@ bool Pattern::matches(Expression const& _expr, map<YulString, Expression const*> Expression const* firstMatch = (*m_matchGroups)[m_matchGroup]; assertThrow(firstMatch, OptimizerException, "Match set but to null."); return - SyntacticalEqualityChecker::equal(*firstMatch, _expr) && - MovableChecker(_expr).movable(); + SyntacticallyEqual{}(*firstMatch, _expr) && + MovableChecker(_dialect, _expr).movable(); } else if (m_kind == PatternKind::Any) (*m_matchGroups)[m_matchGroup] = &_expr; |