[PATCH] RegAllocGreedy: Allow target to specify register class ordering.

Matthias Braun matze at braunis.de
Wed Mar 25 20:13:25 PDT 2015


Hi qcolombet, atrick,

Allow the target to define an ordering for its register classes. This is
used in the greedy register allocator heuristic, it is often beneficial
to color "big" (each register aliases 2 or more registers of a smaller
register class) or very constrained classes first.

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D8626

Files:
  include/llvm/Target/TargetRegisterInfo.h
  lib/CodeGen/RegAllocGreedy.cpp

Index: include/llvm/Target/TargetRegisterInfo.h
===================================================================
--- include/llvm/Target/TargetRegisterInfo.h
+++ include/llvm/Target/TargetRegisterInfo.h
@@ -713,6 +713,14 @@
   /// (3) Bottom-up allocation is no longer guaranteed to optimally color.
   virtual bool reverseLocalAssignment() const { return false; }
 
+  /// Allow the target to define an ordering for its register classes. This is
+  /// used in the greedy register allocator heuristic, it is often beneficial to
+  /// color "big" (each register aliases 2 or more registers of a smaller
+  /// register class) or very constrained classes first.
+  virtual uint8_t getClassPriority(const TargetRegisterClass *cls) const {
+    return 0;
+  }
+
   /// Allow the target to override the cost of using a callee-saved register for
   /// the first time. Default value of 0 means we will use a callee-saved
   /// register if it is available.
Index: lib/CodeGen/RegAllocGreedy.cpp
===================================================================
--- lib/CodeGen/RegAllocGreedy.cpp
+++ lib/CodeGen/RegAllocGreedy.cpp
@@ -554,6 +554,7 @@
         // large blocks on targets with many physical registers.
         Prio = Indexes->getZeroIndex().getInstrDistance(LI->endIndex());
       }
+      Prio |= TRI->getClassPriority(MRI->getRegClass(Reg)) << 24;
     }
     else {
       // Allocate global and split ranges in long->short order. Long ranges that

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8626.22697.patch
Type: text/x-patch
Size: 1469 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150326/bccb900e/attachment.bin>


More information about the llvm-commits mailing list