diff options
author | Andrew Trick <atrick@apple.com> | 2012-04-10 02:25:21 +0000 |
---|---|---|
committer | Andrew Trick <atrick@apple.com> | 2012-04-10 02:25:21 +0000 |
commit | d35ac3c8bc37ab383b10a04b9c8b1087d6b2bc45 (patch) | |
tree | c4fce3fe570921ac6cdb05b6e123b9bb9fe313bc /utils/TableGen/CodeGenRegisters.h | |
parent | aec111a06b595742683b529a7f4391becd7e24ec (diff) | |
download | llvm-d35ac3c8bc37ab383b10a04b9c8b1087d6b2bc45.tar.gz llvm-d35ac3c8bc37ab383b10a04b9c8b1087d6b2bc45.tar.bz2 llvm-d35ac3c8bc37ab383b10a04b9c8b1087d6b2bc45.tar.xz |
Added register unit weights to the target description.
This is a new algorithm that associates registers with weighted
register units to accuretely model their effect on register
pressure. This handles registers with multiple overlapping
subregisters. It is possible, but almost inconceivable that the
algorithm fails to find an exact solution for a target description. If
an exact solution cannot be found, an inexact, but reasonable solution
will be chosen.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154373 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/CodeGenRegisters.h')
-rw-r--r-- | utils/TableGen/CodeGenRegisters.h | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/utils/TableGen/CodeGenRegisters.h b/utils/TableGen/CodeGenRegisters.h index 0d26bc493e..d22dced9d3 100644 --- a/utils/TableGen/CodeGenRegisters.h +++ b/utils/TableGen/CodeGenRegisters.h @@ -130,6 +130,17 @@ namespace llvm { // This is only valid after getSubRegs() completes. const RegUnitList &getRegUnits() const { return RegUnits; } + // Inherit register units from subregisters. + // Return true if the RegUnits changed. + bool inheritRegUnits(CodeGenRegBank &RegBank); + + // Adopt a register unit for pressure tracking. + // A unit is adopted iff its unit number is >= NumNativeRegUnits. + void adoptRegUnit(unsigned RUID) { RegUnits.push_back(RUID); } + + // Get the sum of this register's register unit weights. + unsigned getWeight(const CodeGenRegBank &RegBank) const; + // Order CodeGenRegister pointers by EnumValue. struct Less { bool operator()(const CodeGenRegister *A, @@ -315,7 +326,12 @@ namespace llvm { // Registers. std::vector<CodeGenRegister*> Registers; DenseMap<Record*, CodeGenRegister*> Def2Reg; - unsigned NumRegUnits; + unsigned NumNativeRegUnits; + unsigned NumRegUnits; // # native + adopted register units. + + // Map each register unit to a weight (for register pressure). + // Includes native and adopted register units. + std::vector<unsigned> RegUnitWeights; // Register classes. std::vector<CodeGenRegisterClass*> RegClasses; @@ -338,6 +354,9 @@ namespace llvm { void inferMatchingSuperRegClass(CodeGenRegisterClass *RC, unsigned FirstSubRegRC = 0); + // Compute a weight for each register unit created during getSubRegs. + void computeRegUnitWeights(); + // Populate the Composite map from sub-register relationships. void computeComposites(); @@ -364,7 +383,24 @@ namespace llvm { // Find a register from its Record def. CodeGenRegister *getReg(Record*); - unsigned newRegUnit() { return NumRegUnits++; } + // Get a Register's index into the Registers array. + unsigned getRegIndex(const CodeGenRegister *Reg) const { + return Reg->EnumValue - 1; + } + + // Create a new non-native register unit that can be adopted by a register + // to increase its pressure. Note that NumNativeRegUnits is not increased. + unsigned newRegUnit(unsigned Weight) { + if (!RegUnitWeights.empty()) { + RegUnitWeights.resize(NumRegUnits+1); + RegUnitWeights[NumRegUnits] = Weight; + } + return NumRegUnits++; + } + + bool isNativeUnit(unsigned RUID) { + return RUID < NumNativeRegUnits; + } ArrayRef<CodeGenRegisterClass*> getRegClasses() const { return RegClasses; @@ -380,6 +416,14 @@ namespace llvm { /// return the superclass. Otherwise return null. const CodeGenRegisterClass* getRegClassForRegister(Record *R); + unsigned getRegUnitWeight(unsigned RUID) const { + return RegUnitWeights[RUID]; + } + + void increaseRegUnitWeight(unsigned RUID, unsigned Inc) { + RegUnitWeights[RUID] += Inc; + } + // Computed derived records such as missing sub-register indices. void computeDerivedInfo(); |