diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-01-31 21:44:11 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-01-31 21:44:11 +0000 |
commit | 90498b195ba759cf4f2a98da4e46fb9a2b580396 (patch) | |
tree | edc3e2762485d692ba0b28956c9901c8731a5fce /utils/TableGen/CodeGenRegisters.h | |
parent | 5fcc156344e0d38fa5f5eab3d9193b859b27b45e (diff) | |
download | llvm-90498b195ba759cf4f2a98da4e46fb9a2b580396.tar.gz llvm-90498b195ba759cf4f2a98da4e46fb9a2b580396.tar.bz2 llvm-90498b195ba759cf4f2a98da4e46fb9a2b580396.tar.xz |
Move the composite map into CodeGenSubRegIndex.
Each SubRegIndex keeps track of how it composes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149423 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/CodeGenRegisters.h')
-rw-r--r-- | utils/TableGen/CodeGenRegisters.h | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/utils/TableGen/CodeGenRegisters.h b/utils/TableGen/CodeGenRegisters.h index 7b96bd599e..b83ad6e785 100644 --- a/utils/TableGen/CodeGenRegisters.h +++ b/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; } |