]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[NDS32] Implment ADJUST_REG_ALLOC_ORDER for performance requirement.
authorChung-Ju Wu <jasonwucj@gmail.com>
Sat, 17 Mar 2018 13:06:12 +0000 (13:06 +0000)
committerChung-Ju Wu <jasonwucj@gcc.gnu.org>
Sat, 17 Mar 2018 13:06:12 +0000 (13:06 +0000)
gcc/
* config/nds32/nds32-protos.h (nds32_adjust_reg_alloc_order): Declare.
* config/nds32/nds32.c (nds32_reg_alloc_order_for_speed): New array.
(nds32_adjust_reg_alloc_order): New function.
* config/nds32/nds32.h (ADJUST_REG_ALLOC_ORDER): Define.

Co-Authored-By: Kito Cheng <kito.cheng@gmail.com>
From-SVN: r258621

gcc/ChangeLog
gcc/config/nds32/nds32-protos.h
gcc/config/nds32/nds32.c
gcc/config/nds32/nds32.h

index a0e056b89cbdbee912639b19bcbd1e0aafe0dc8d..a1186fc2dfb5e13e9f03d214ca4e1ae44f15d652 100644 (file)
@@ -1,3 +1,11 @@
+2018-03-17  Chung-Ju Wu  <jasonwucj@gmail.com>
+           Kito Cheng  <kito.cheng@gmail.com>
+
+       * config/nds32/nds32-protos.h (nds32_adjust_reg_alloc_order): Declare.
+       * config/nds32/nds32.c (nds32_reg_alloc_order_for_speed): New array.
+       (nds32_adjust_reg_alloc_order): New function.
+       * config/nds32/nds32.h (ADJUST_REG_ALLOC_ORDER): Define.
+
 2018-03-17  Kito Cheng  <kito.cheng@gmail.com>
 
        * config/nds32/nds32.c (nds32_asm_output_mi_thunk,
index fe2509bbae3996bb0e6602bcc3855af65bb51972..61105001c72061d2d7224c026438c908d6c57fa8 100644 (file)
 extern void nds32_init_expanders (void);
 
 \f
+/* Register Usage.  */
+
+/* -- Order of Allocation of Registers.  */
+extern void nds32_adjust_reg_alloc_order (void);
+
 /* Register Classes.  */
 
 extern enum reg_class nds32_regno_reg_class (int);
index e0836d8a89509c043043f091e02fea88a1c8f853..f405ea13e9ea8921d5c46bd800028af51f29ce68 100644 (file)
@@ -82,6 +82,18 @@ static const char * const nds32_intrinsic_register_names[] =
   "$PSW", "$IPSW", "$ITYPE", "$IPC"
 };
 
+
+/* Defining register allocation order for performance.
+   We want to allocate callee-saved registers after others.
+   It may be used by nds32_adjust_reg_alloc_order().  */
+static const int nds32_reg_alloc_order_for_speed[] =
+{
+   0,   1,   2,   3,   4,   5,  16,  17,
+  18,  19,  20,  21,  22,  23,  24,  25,
+  26,  27,   6,   7,   8,   9,  10,  11,
+  12,  13,  14,  15
+};
+
 /* Defining target-specific uses of __attribute__.  */
 static const struct attribute_spec nds32_attribute_table[] =
 {
@@ -2870,6 +2882,25 @@ nds32_init_expanders (void)
 \f
 /* Register Usage.  */
 
+/* -- Order of Allocation of Registers.  */
+
+void
+nds32_adjust_reg_alloc_order (void)
+{
+  const int nds32_reg_alloc_order[] = REG_ALLOC_ORDER;
+
+  /* Copy the default register allocation order, which is designed
+     to optimize for code size.  */
+  memcpy(reg_alloc_order, nds32_reg_alloc_order, sizeof (reg_alloc_order));
+
+  /* Adjust few register allocation order when optimizing for speed.  */
+  if (!optimize_size)
+    {
+      memcpy (reg_alloc_order, nds32_reg_alloc_order_for_speed,
+             sizeof (nds32_reg_alloc_order_for_speed));
+    }
+}
+
 /* -- How Values Fit in Registers.  */
 
 /* Implement TARGET_HARD_REGNO_MODE_OK.  */
index dc40735700a69549b954d503398fbf1c9627c75f..749a55208d40c55dcb1268a8744d71afa428ee5f 100644 (file)
@@ -627,6 +627,10 @@ enum nds32_builtins
    96,  97,  98,  99, 100,                \
 }
 
+/* ADJUST_REG_ALLOC_ORDER is a macro which permits reg_alloc_order
+   to be rearranged based on optimizing for speed or size.  */
+#define ADJUST_REG_ALLOC_ORDER nds32_adjust_reg_alloc_order ()
+
 /* Tell IRA to use the order we define rather than messing it up with its
    own cost calculations.  */
 #define HONOR_REG_ALLOC_ORDER optimize_size