aboutsummaryrefslogtreecommitdiffstats
path: root/libyul/optimiser/SimplificationRules.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-12-21 01:55:32 +0800
committerchriseth <chris@ethereum.org>2019-01-07 23:41:03 +0800
commit9222eff08fad8e6a0ea7df8b299880f90c68c8b3 (patch)
tree20b9a2e40164fb693ab52e75ad1cd2388d142473 /libyul/optimiser/SimplificationRules.cpp
parentd9910f2a1258e8d16d7a57905dabcd09db4e6a8d (diff)
downloaddexon-solidity-9222eff08fad8e6a0ea7df8b299880f90c68c8b3.tar.gz
dexon-solidity-9222eff08fad8e6a0ea7df8b299880f90c68c8b3.tar.zst
dexon-solidity-9222eff08fad8e6a0ea7df8b299880f90c68c8b3.zip
Make the dialect available everywhere.
Diffstat (limited to 'libyul/optimiser/SimplificationRules.cpp')
-rw-r--r--libyul/optimiser/SimplificationRules.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/libyul/optimiser/SimplificationRules.cpp b/libyul/optimiser/SimplificationRules.cpp
index 45b0ca2c..da9c7d9d 100644
--- a/libyul/optimiser/SimplificationRules.cpp
+++ b/libyul/optimiser/SimplificationRules.cpp
@@ -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
@@ -167,7 +172,7 @@ bool Pattern::matches(Expression const& _expr, map<YulString, Expression const*>
assertThrow(firstMatch, OptimizerException, "Match set but to null.");
return
SyntacticalEqualityChecker::equal(*firstMatch, _expr) &&
- MovableChecker(_expr).movable();
+ MovableChecker(_dialect, _expr).movable();
}
else if (m_kind == PatternKind::Any)
(*m_matchGroups)[m_matchGroup] = &_expr;