diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-12-04 22:25:16 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-12-04 22:25:16 +0000 |
commit | 3cb2cb800ff6bc19ed4e066af47b0b9994cf13c4 (patch) | |
tree | fc12200e74d149b63f9891a913a7d37373cb87a2 /llvm/lib/CodeGen/AllocationOrder.h | |
parent | e71ce976894e809029ba3cb24eb1a60939fdfba6 (diff) | |
download | bcm5719-llvm-3cb2cb800ff6bc19ed4e066af47b0b9994cf13c4.tar.gz bcm5719-llvm-3cb2cb800ff6bc19ed4e066af47b0b9994cf13c4.zip |
Speed up the AllocationOrder class a bit.
Allow the central functions to be inlined, and use the argumentless
isHint() function when possible.
llvm-svn: 169319
Diffstat (limited to 'llvm/lib/CodeGen/AllocationOrder.h')
-rw-r--r-- | llvm/lib/CodeGen/AllocationOrder.h | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/AllocationOrder.h b/llvm/lib/CodeGen/AllocationOrder.h index 9bcbc732ed3..a5293f60a07 100644 --- a/llvm/lib/CodeGen/AllocationOrder.h +++ b/llvm/lib/CodeGen/AllocationOrder.h @@ -28,7 +28,7 @@ class VirtRegMap; class AllocationOrder { SmallVector<MCPhysReg, 16> Hints; ArrayRef<MCPhysReg> Order; - unsigned Pos; + int Pos; public: /// Create a new AllocationOrder for VirtReg. @@ -42,16 +42,27 @@ public: /// Return the next physical register in the allocation order, or 0. /// It is safe to call next() again after it returned 0, it will keep /// returning 0 until rewind() is called. - unsigned next(); + unsigned next() { + if (Pos < 0) + return Hints.end()[Pos++]; + while (Pos < int(Order.size())) { + unsigned Reg = Order[Pos++]; + if (!isHint(Reg)) + return Reg; + } + return 0; + } /// Start over from the beginning. - void rewind() { Pos = 0; } + void rewind() { Pos = -int(Hints.size()); } /// Return true if the last register returned from next() was a preferred register. - bool isHint() const { return Pos <= Hints.size(); } + bool isHint() const { return Pos <= 0; } /// Return true if PhysReg is a preferred register. - bool isHint(unsigned PhysReg) const; + bool isHint(unsigned PhysReg) const { + return std::find(Hints.begin(), Hints.end(), PhysReg) != Hints.end(); + } }; } // end namespace llvm |