diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2011-06-12 03:05:52 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2011-06-12 03:05:52 +0000 |
commit | d2b4713e53a7667fa51b5aad17337bc6142d157d (patch) | |
tree | e58795813841cb8dbb1aeae63fdbb2153118e2b6 /llvm/utils/TableGen/CodeGenRegisters.h | |
parent | 7ed40cbded2fb1d0d4a1aa4521c79d95888b815d (diff) | |
download | bcm5719-llvm-d2b4713e53a7667fa51b5aad17337bc6142d157d.tar.gz bcm5719-llvm-d2b4713e53a7667fa51b5aad17337bc6142d157d.zip |
Compute lists of sub-regs, super-regs, and overlapping regs.
Besides moving structural computations to CodeGenRegisters.cpp, this
also well-defines the order of these lists:
- Sub-register lists come from a pre-order traversal of the graph
defined by the SubRegs lists in the .td files.
- Super-register lists are topologically ordered so no register comes
before any of its sub-registers. When the sub-register graph is not a
tree, independent super-registers appear in numerical order.
- Lists of overlapping registers are ordered according to register
number.
This reverses the order of the super-regs lists, but nobody was
depending on that. The previous order of the overlaps lists was odd, and
it may have depended on the precise behavior of std::stable_sort.
The old computations are still there, but will be removed shortly.
llvm-svn: 132881
Diffstat (limited to 'llvm/utils/TableGen/CodeGenRegisters.h')
-rw-r--r-- | llvm/utils/TableGen/CodeGenRegisters.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/llvm/utils/TableGen/CodeGenRegisters.h b/llvm/utils/TableGen/CodeGenRegisters.h index 09341f00d00..233ceb2769a 100644 --- a/llvm/utils/TableGen/CodeGenRegisters.h +++ b/llvm/utils/TableGen/CodeGenRegisters.h @@ -18,6 +18,7 @@ #include "Record.h" #include "llvm/CodeGen/ValueTypes.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/SetVector.h" #include <cstdlib> #include <map> #include <string> @@ -49,9 +50,33 @@ namespace llvm { return SubRegs; } + // Add sub-registers to OSet following a pre-order defined by the .td file. + void addSubRegsPreOrder(SetVector<CodeGenRegister*> &OSet) const; + + // List of super-registers in topological order, small to large. + typedef std::vector<CodeGenRegister*> SuperRegList; + + // Get the list of super-registers. + // This is only valid after computeDerivedInfo has visited all registers. + const SuperRegList &getSuperRegs() const { + assert(SubRegsComplete && "Must precompute sub-registers"); + return SuperRegs; + } + + // Order CodeGenRegister pointers by EnumValue. + struct Less { + bool operator()(const CodeGenRegister *A, const CodeGenRegister *B) { + return A->EnumValue < B->EnumValue; + } + }; + + // Canonically ordered set. + typedef std::set<CodeGenRegister*, Less> Set; + private: bool SubRegsComplete; SubRegMap SubRegs; + SuperRegList SuperRegs; }; @@ -158,6 +183,15 @@ namespace llvm { // Computed derived records such as missing sub-register indices. void computeDerivedInfo(); + + // Compute full overlap sets for every register. These sets include the + // rarely used aliases that are neither sub nor super-registers. + // + // Map[R1].count(R2) is reflexive and symmetric, but not transitive. + // + // If R1 is a sub-register of R2, Map[R1] is a subset of Map[R2]. + void computeOverlaps(std::map<const CodeGenRegister*, + CodeGenRegister::Set> &Map); }; } |