aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVikram S. Adve <vadve@cs.uiuc.edu>2002-03-24 03:25:17 +0000
committerVikram S. Adve <vadve@cs.uiuc.edu>2002-03-24 03:25:17 +0000
commit6be4ebe1eb682eb6a9f5ef9fb8b52edd7cfb32bc (patch)
treebdd5c694761912a7106dfa98319be866c4ce6986
parentd95919cbd09007f3e363180c3059a63287f4edd1 (diff)
Change treeRoots data structure to make enumeration deterministic.
Also, add a flag to marked nodes that do not need code because they have been folded into the user (parent in the BURG tree). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1963 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/CodeGen/InstrForest.h27
1 files changed, 22 insertions, 5 deletions
diff --git a/include/llvm/CodeGen/InstrForest.h b/include/llvm/CodeGen/InstrForest.h
index 834899d22c..ef5e2f9a06 100644
--- a/include/llvm/CodeGen/InstrForest.h
+++ b/include/llvm/CodeGen/InstrForest.h
@@ -27,7 +27,6 @@
#include "llvm/Instruction.h"
#include "Support/NonCopyable.h"
#include "Support/HashExtras.h"
-#include <ext/hash_set>
class Constant;
class BasicBlock;
@@ -170,6 +169,9 @@ protected:
class InstructionNode : public InstrTreeNode {
+private:
+ bool codeIsFoldedIntoParent;
+
public:
InstructionNode(Instruction *_instr);
@@ -177,6 +179,10 @@ public:
assert(treeNodeType == NTInstructionNode);
return cast<Instruction>(val);
}
+
+ void markFoldedIntoParent() { codeIsFoldedIntoParent = true; }
+ bool isFoldedIntoParent() { return codeIsFoldedIntoParent; }
+
protected:
virtual void dumpNode(int indent) const;
};
@@ -239,8 +245,17 @@ protected:
//------------------------------------------------------------------------
class InstrForest : private std::hash_map<const Instruction *, InstructionNode*> {
+public:
+ // Use a vector for the root set to get a deterministic iterator
+ // for stable code generation. Even though we need to erase nodes
+ // during forest construction, a vector should still be efficient
+ // because the elements to erase are nearly always near the end.
+ typedef std::vector<InstructionNode*> RootSet;
+ typedef RootSet:: iterator root_iterator;
+ typedef RootSet::const_iterator const_root_iterator;
+
private:
- std::hash_set<InstructionNode*> treeRoots;
+ RootSet treeRoots;
public:
/*ctor*/ InstrForest (Function *F);
@@ -250,9 +265,10 @@ public:
return (*this)[instr];
}
- inline const std::hash_set<InstructionNode*> &getRootSet() const {
- return treeRoots;
- }
+ const_root_iterator roots_begin() const { return treeRoots.begin(); }
+ root_iterator roots_begin() { return treeRoots.begin(); }
+ const_root_iterator roots_end () const { return treeRoots.end(); }
+ root_iterator roots_end () { return treeRoots.end(); }
void dump() const;
@@ -260,6 +276,7 @@ private:
//
// Private methods for buidling the instruction forest
//
+ void eraseRoot (InstructionNode* node);
void setLeftChild (InstrTreeNode* parent, InstrTreeNode* child);
void setRightChild(InstrTreeNode* parent, InstrTreeNode* child);
void setParent (InstrTreeNode* child, InstrTreeNode* parent);