Chromium Code Reviews| Index: src/IceOperand.h |
| diff --git a/src/IceOperand.h b/src/IceOperand.h |
| index bcb38d03d395191d04ebc24a675e957d3df39bba..25d3542cc73f54f9840e263a9cf790277fc9d241 100644 |
| --- a/src/IceOperand.h |
| +++ b/src/IceOperand.h |
| @@ -343,6 +343,12 @@ bool operator<(const RegWeight &A, const RegWeight &B); |
| bool operator<=(const RegWeight &A, const RegWeight &B); |
| bool operator==(const RegWeight &A, const RegWeight &B); |
| +enum RegRequirement { |
|
jvoung (off chromium)
2015/08/26 21:45:47
Should this enum be scoped in RegWeight? (near the
ascull
2015/08/26 22:06:39
It is separate from RegWeight which is an 'infinit
|
| + ShouldHaveRegister, |
| + MustHaveRegister, |
| + MustNotHaveRegister, |
| +}; |
| + |
| /// LiveRange is a set of instruction number intervals representing |
| /// a variable's live range. Generally there is one interval per basic |
| /// block where the variable is live, but adjacent intervals get |
| @@ -364,7 +370,6 @@ public: |
| void reset() { |
| Range.clear(); |
| - Weight.setWeight(0); |
| untrim(); |
| } |
| void addSegment(InstNumberT Start, InstNumberT End); |
| @@ -384,9 +389,6 @@ public: |
| void untrim() { TrimmedBegin = Range.begin(); } |
| void trim(InstNumberT Lower); |
| - RegWeight getWeight() const { return Weight; } |
| - void setWeight(const RegWeight &NewWeight) { Weight = NewWeight; } |
| - void addWeight(uint32_t Delta) { Weight.addWeight(Delta); } |
| void dump(Ostream &Str) const; |
| private: |
| @@ -395,7 +397,6 @@ private: |
| typedef std::vector<RangeElementType, CfgLocalAllocator<RangeElementType>> |
| RangeType; |
| RangeType Range; |
| - RegWeight Weight = RegWeight(0); |
| /// TrimmedBegin is an optimization for the overlaps() computation. |
| /// Since the linear-scan algorithm always calls it as overlaps(Cur) |
| /// and Cur advances monotonically according to live range start, we |
| @@ -454,25 +455,30 @@ public: |
| int32_t getRegNumTmp() const { return RegNumTmp; } |
| void setRegNumTmp(int32_t NewRegNum) { RegNumTmp = NewRegNum; } |
| - RegWeight getWeight() const { return Weight; } |
| - void setWeight(uint32_t NewWeight) { Weight = RegWeight(NewWeight); } |
| - void setWeightInfinite() { setWeight(RegWeight::Inf); } |
| + RegWeight getWeight() const { |
| + return RegWeight(mustHaveReg() ? RegWeight::Inf : mustNotHaveReg() |
| + ? RegWeight::Zero |
| + : UseWeight); |
| + } |
| + void resetUses() { UseWeight = 0; } |
| + void addUse(uint32_t Weight) { UseWeight += Weight; } |
| + |
| + void setMustHaveReg() { RegRequirement = MustHaveRegister; } |
| + bool mustHaveReg() const { return RegRequirement == MustHaveRegister; } |
| + void setMustNotHaveReg() { RegRequirement = MustNotHaveRegister; } |
| + bool mustNotHaveReg() const { return RegRequirement == MustNotHaveRegister; } |
| LiveRange &getLiveRange() { return Live; } |
| const LiveRange &getLiveRange() const { return Live; } |
| void setLiveRange(const LiveRange &Range) { Live = Range; } |
| - void resetLiveRange() { Live.reset(); } |
| + void resetLiveRange() { |
| + Live.reset(); |
| + resetUses(); |
| + } |
| void addLiveRange(InstNumberT Start, InstNumberT End, uint32_t WeightDelta) { |
| assert(!getIgnoreLiveness()); |
| assert(WeightDelta != RegWeight::Inf); |
|
jvoung (off chromium)
2015/08/26 21:45:46
WeightDelta is only used in assert builds now and
ascull
2015/08/26 22:06:39
Done.
|
| Live.addSegment(Start, End); |
| - if (Weight.isInf()) |
| - Live.setWeight(RegWeight(RegWeight::Inf)); |
| - else |
| - Live.addWeight(WeightDelta * Weight.getWeight()); |
| - } |
| - void setLiveRangeInfiniteWeight() { |
| - Live.setWeight(RegWeight(RegWeight::Inf)); |
| } |
| void trimLiveRange(InstNumberT Start) { Live.trim(Start); } |
| void untrimLiveRange() { Live.untrim(); } |
| @@ -540,7 +546,11 @@ protected: |
| int32_t RegNum = NoRegister; |
| /// RegNumTmp is the tentative assignment during register allocation. |
| int32_t RegNumTmp = NoRegister; |
| - RegWeight Weight = RegWeight(1); // Register allocation priority |
| + /// \name Register allocation priority |
| + /// @{ |
| + uint32_t UseWeight = 0; /// Calculated by use count and loop nest depth. |
| + RegRequirement RegRequirement = ShouldHaveRegister; |
| + /// @} |
| LiveRange Live; |
| // LoVar and HiVar are needed for lowering from 64 to 32 bits. When |
| // lowering from I64 to I32 on a 32-bit architecture, we split the |