diff options
| author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-05-10 23:27:10 +0000 |
|---|---|---|
| committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-05-10 23:27:10 +0000 |
| commit | c08df9e5fdce2856697fbbe52102b4fcb23c4304 (patch) | |
| tree | b1447d90b8e47ae4ace3c965362e2afcdf55855b /llvm/utils/TableGen/CodeGenRegisters.h | |
| parent | 370f5fd20ada3bed37cc1c97fe5487cdcd8d420c (diff) | |
| download | bcm5719-llvm-c08df9e5fdce2856697fbbe52102b4fcb23c4304.tar.gz bcm5719-llvm-c08df9e5fdce2856697fbbe52102b4fcb23c4304.zip | |
Compute secondary sub-registers.
The sub-registers explicitly listed in SubRegs in the .td files form a
tree. In a complicated register bank, it is possible to have
sub-register relationships across sub-trees. For example, the ARM NEON
double vector Q0_Q1 is a tree:
Q0_Q1 = [Q0, Q1], Q0 = [D0, D1], Q1 = [D2, D3]
But we also define the DPair register D1_D2 = [D1, D2] which is fully
contained in Q0_Q1.
This patch teaches TableGen to find such sub-register relationships, and
assign sub-register indices to them. In the example, TableGen will
create a dsub_1_dsub_2 sub-register index, and add D1_D2 as a
sub-register of Q0_Q1.
This will eventually enable the coalescer to handle copies of skewed
sub-registers.
llvm-svn: 156587
Diffstat (limited to 'llvm/utils/TableGen/CodeGenRegisters.h')
| -rw-r--r-- | llvm/utils/TableGen/CodeGenRegisters.h | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/llvm/utils/TableGen/CodeGenRegisters.h b/llvm/utils/TableGen/CodeGenRegisters.h index 1d0e30f9fbf..23cc53932d9 100644 --- a/llvm/utils/TableGen/CodeGenRegisters.h +++ b/llvm/utils/TableGen/CodeGenRegisters.h @@ -67,6 +67,7 @@ namespace llvm { // Return a conflicting composite, or NULL CodeGenSubRegIndex *addComposite(CodeGenSubRegIndex *A, CodeGenSubRegIndex *B) { + assert(A && 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; @@ -108,6 +109,9 @@ namespace llvm { // This includes unique entries for all sub-sub-registers. const SubRegMap &computeSubRegs(CodeGenRegBank&); + // Compute extra sub-registers by combining the existing sub-registers. + void computeSecondarySubRegs(CodeGenRegBank&); + const SubRegMap &getSubRegs() const { assert(SubRegsComplete && "Must precompute sub-registers"); return SubRegs; @@ -123,11 +127,11 @@ namespace llvm { return SubReg2Idx.lookup(Reg); } - // List of super-registers in topological order, small to large. typedef std::vector<const CodeGenRegister*> SuperRegList; - // Get the list of super-registers. This is valid after getSubReg - // visits all registers during RegBank construction. + // Get the list of super-registers in topological order, small to large. + // This is valid after computeSubRegs visits all registers during RegBank + // construction. const SuperRegList &getSuperRegs() const { assert(SubRegsComplete && "Must precompute sub-registers"); return SuperRegs; @@ -170,6 +174,9 @@ namespace llvm { SmallVector<CodeGenSubRegIndex*, 8> ExplicitSubRegIndices; SmallVector<CodeGenRegister*, 8> ExplicitSubRegs; + // Super-registers where this is the first explicit sub-register. + SuperRegList LeadingSuperRegs; + SubRegMap SubRegs; SuperRegList SuperRegs; DenseMap<const CodeGenRegister*, CodeGenSubRegIndex*> SubReg2Idx; @@ -349,6 +356,10 @@ namespace llvm { DenseMap<Record*, CodeGenSubRegIndex*> Def2SubRegIdx; unsigned NumNamedIndices; + typedef std::map<SmallVector<CodeGenSubRegIndex*, 8>, + CodeGenSubRegIndex*> ConcatIdxMap; + ConcatIdxMap ConcatIdx; + // Registers. std::vector<CodeGenRegister*> Registers; DenseMap<Record*, CodeGenRegister*> Def2Reg; @@ -419,6 +430,17 @@ namespace llvm { CodeGenSubRegIndex *getCompositeSubRegIndex(CodeGenSubRegIndex *A, CodeGenSubRegIndex *B); + // Find or create a sub-register index representing the concatenation of + // non-overlapping sibling indices. + CodeGenSubRegIndex * + getConcatSubRegIndex(const SmallVector<CodeGenSubRegIndex*, 8>&); + + void + addConcatSubRegIndex(const SmallVector<CodeGenSubRegIndex*, 8> &Parts, + CodeGenSubRegIndex *Idx) { + ConcatIdx.insert(std::make_pair(Parts, Idx)); + } + const std::vector<CodeGenRegister*> &getRegisters() { return Registers; } // Find a register from its Record def. |

