summaryrefslogtreecommitdiffstats
path: root/llvm/utils/TableGen/CodeGenRegisters.h
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2012-01-31 21:44:11 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2012-01-31 21:44:11 +0000
commit9a44ad70294b148eb031e492eb842751d03667c4 (patch)
tree98ccfd6262663aef3f206c60feaf2d5bb089c6c4 /llvm/utils/TableGen/CodeGenRegisters.h
parent9d3f7af8c3387de94b93e60e8e44ce8b91f81e31 (diff)
downloadbcm5719-llvm-9a44ad70294b148eb031e492eb842751d03667c4.tar.gz
bcm5719-llvm-9a44ad70294b148eb031e492eb842751d03667c4.zip
Move the composite map into CodeGenSubRegIndex.
Each SubRegIndex keeps track of how it composes. llvm-svn: 149423
Diffstat (limited to 'llvm/utils/TableGen/CodeGenRegisters.h')
-rw-r--r--llvm/utils/TableGen/CodeGenRegisters.h37
1 files changed, 29 insertions, 8 deletions
diff --git a/llvm/utils/TableGen/CodeGenRegisters.h b/llvm/utils/TableGen/CodeGenRegisters.h
index 7b96bd599e8..b83ad6e7850 100644
--- a/llvm/utils/TableGen/CodeGenRegisters.h
+++ b/llvm/utils/TableGen/CodeGenRegisters.h
@@ -51,6 +51,34 @@ namespace llvm {
return A->EnumValue < B->EnumValue;
}
};
+
+ // Map of composite subreg indices.
+ typedef std::map<CodeGenSubRegIndex*, CodeGenSubRegIndex*, Less> CompMap;
+
+ // Returns the subreg index that results from composing this with Idx.
+ // Returns NULL if this and Idx don't compose.
+ CodeGenSubRegIndex *compose(CodeGenSubRegIndex *Idx) const {
+ CompMap::const_iterator I = Composed.find(Idx);
+ return I == Composed.end() ? 0 : I->second;
+ }
+
+ // Add a composite subreg index: this+A = B.
+ // Return a conflicting composite, or NULL
+ CodeGenSubRegIndex *addComposite(CodeGenSubRegIndex *A,
+ CodeGenSubRegIndex *B) {
+ std::pair<CompMap::iterator, bool> Ins =
+ Composed.insert(std::make_pair(A, B));
+ return (Ins.second || Ins.first->second == B) ? 0 : Ins.first->second;
+ }
+
+ // Clean out redundant composite mappings.
+ void cleanComposites();
+
+ // Return the map of composites.
+ const CompMap &getComposites() const { return Composed; }
+
+ private:
+ CompMap Composed;
};
/// CodeGenRegister - Represents a register definition.
@@ -298,12 +326,6 @@ namespace llvm {
void inferMatchingSuperRegClass(CodeGenRegisterClass *RC,
unsigned FirstSubRegRC = 0);
- // Composite SubRegIndex instances.
- // Map (SubRegIndex, SubRegIndex) -> SubRegIndex.
- typedef DenseMap<std::pair<CodeGenSubRegIndex*, CodeGenSubRegIndex*>,
- CodeGenSubRegIndex*> CompositeMap;
- CompositeMap Composite;
-
// Populate the Composite map from sub-register relationships.
void computeComposites();
@@ -323,8 +345,7 @@ namespace llvm {
// Find or create a sub-register index representing the A+B composition.
CodeGenSubRegIndex *getCompositeSubRegIndex(CodeGenSubRegIndex *A,
- CodeGenSubRegIndex *B,
- bool create = false);
+ CodeGenSubRegIndex *B);
const std::vector<CodeGenRegister*> &getRegisters() { return Registers; }
OpenPOWER on IntegriCloud