diff options
author | chriseth <c@ethdev.com> | 2015-04-30 20:41:55 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-05-06 17:10:42 +0800 |
commit | 867101e40981db56d8b72fd363e4f9e376991284 (patch) | |
tree | ba4dc55d57bf0c90960fb0755e273ca86a42c0b1 /CommonSubexpressionEliminator.cpp | |
parent | 3ebb7d99c4e24d7bc963c419790c9f0081cc47a1 (diff) | |
download | dexon-solidity-867101e40981db56d8b72fd363e4f9e376991284.tar.gz dexon-solidity-867101e40981db56d8b72fd363e4f9e376991284.tar.zst dexon-solidity-867101e40981db56d8b72fd363e4f9e376991284.zip |
Common subexpression elimination ready for using pre-known state.
Diffstat (limited to 'CommonSubexpressionEliminator.cpp')
-rw-r--r-- | CommonSubexpressionEliminator.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/CommonSubexpressionEliminator.cpp b/CommonSubexpressionEliminator.cpp index 645a426d..4b85eba4 100644 --- a/CommonSubexpressionEliminator.cpp +++ b/CommonSubexpressionEliminator.cpp @@ -40,9 +40,8 @@ vector<AssemblyItem> CommonSubexpressionEliminator::getOptimizedItems() int minHeight = m_state.stackHeight() + 1; if (!m_state.stackElements().empty()) minHeight = min(minHeight, m_state.stackElements().begin()->first); - for (int height = minHeight; height <= 0; ++height) - //@todo this is not nice as it is here - should be "unknownStackElement" - but is it really unknown? - initialStackContents[height] = m_state.initialStackElement(height, SourceLocation()); + for (int height = minHeight; height <= m_initialState.stackHeight(); ++height) + initialStackContents[height] = m_initialState.stackElement(height, SourceLocation()); for (int height = minHeight; height <= m_state.stackHeight(); ++height) targetStackContents[height] = m_state.stackElement(height, SourceLocation()); @@ -50,6 +49,7 @@ vector<AssemblyItem> CommonSubexpressionEliminator::getOptimizedItems() //stream(cout, initialStackContents, targetStackContents); AssemblyItems items = CSECodeGenerator(m_state.expressionClasses(), m_storeOperations).generateCode( + m_initialState.stackHeight(), initialStackContents, targetStackContents ); @@ -106,10 +106,12 @@ CSECodeGenerator::CSECodeGenerator( } AssemblyItems CSECodeGenerator::generateCode( + int _initialStackHeight, map<int, Id> const& _initialStack, map<int, Id> const& _targetStackContents ) { + m_stackHeight = _initialStackHeight; m_stack = _initialStack; for (auto const& item: m_stack) if (!m_classPositions.count(item.second)) |