diff options
Diffstat (limited to 'CommonSubexpressionEliminator.h')
-rw-r--r-- | CommonSubexpressionEliminator.h | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/CommonSubexpressionEliminator.h b/CommonSubexpressionEliminator.h index 6e1ba40b..a35e31d9 100644 --- a/CommonSubexpressionEliminator.h +++ b/CommonSubexpressionEliminator.h @@ -71,13 +71,6 @@ public: /// @returns the resulting items after optimization. AssemblyItems getOptimizedItems(); - /// Streams debugging information to @a _out. - std::ostream& stream( - std::ostream& _out, - std::map<int, Id> _initialStack = std::map<int, Id>(), - std::map<int, Id> _targetStack = std::map<int, Id>() - ) const; - private: /// Feeds the item into the system for analysis. void feedItem(AssemblyItem const& _item, bool _copyItem = false); @@ -126,16 +119,15 @@ private: void addDependencies(Id _c); /// Produce code that generates the given element if it is not yet present. - /// @returns the stack position of the element or c_invalidPosition if it does not actually - /// generate a value on the stack. /// @param _allowSequenced indicates that sequence-constrained operations are allowed - int generateClassElement(Id _c, bool _allowSequenced = false); + void generateClassElement(Id _c, bool _allowSequenced = false); /// @returns the position of the representative of the given id on the stack. /// @note throws an exception if it is not on the stack. int classElementPosition(Id _id) const; - /// @returns true if @a _element can be removed - in general or, if given, while computing @a _result. - bool canBeRemoved(Id _element, Id _result = Id(-1)); + /// @returns true if the copy of @a _element can be removed from stack position _fromPosition + /// - in general or, if given, while computing @a _result. + bool canBeRemoved(Id _element, Id _result = Id(-1), int _fromPosition = c_invalidPosition); /// Appends code to remove the topmost stack element if it can be removed. bool removeStackTopIfPossible(); @@ -157,8 +149,8 @@ private: std::multimap<Id, Id> m_neededBy; /// Current content of the stack. std::map<int, Id> m_stack; - /// Current positions of equivalence classes, equal to c_invalidPosition if already deleted. - std::map<Id, int> m_classPositions; + /// Current positions of equivalence classes, equal to the empty set if already deleted. + std::map<Id, std::set<int>> m_classPositions; /// The actual eqivalence class items and how to compute them. ExpressionClasses& m_expressionClasses; @@ -167,6 +159,7 @@ private: std::map<std::pair<StoreOperation::Target, Id>, StoreOperations> m_storeOperations; /// The set of equivalence classes that should be present on the stack at the end. std::set<Id> m_finalClasses; + std::map<int, Id> m_targetStack; }; template <class _AssemblyItemIterator> @@ -175,6 +168,7 @@ _AssemblyItemIterator CommonSubexpressionEliminator::feedItems( _AssemblyItemIterator _end ) { + assertThrow(!m_breakingItem, OptimizerException, "Invalid use of CommonSubexpressionEliminator."); for (; _iterator != _end && !SemanticInformation::breaksCSEAnalysisBlock(*_iterator); ++_iterator) feedItem(*_iterator); if (_iterator != _end) |