Implement HARD_REGNO_CALLER_SAVE_MODE for AArch64
authorIan Bolton <ian.bolton@arm.com>
Tue, 13 May 2014 09:28:35 +0000 (09:28 +0000)
committerIan Bolton <ibolton@gcc.gnu.org>
Tue, 13 May 2014 09:28:35 +0000 (09:28 +0000)
* config/aarch64/aarch64-protos.h
(aarch64_hard_regno_caller_save_mode): New prototype.
* config/aarch64/aarch64.c (aarch64_hard_regno_caller_save_mode):
New function.
* config/aarch64/aarch64.h (HARD_REGNO_CALLER_SAVE_MODE): New macro.

From-SVN: r210355

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

index 456f740..8352d09 100644 (file)
@@ -1,3 +1,11 @@
+2014-05-13  Ian Bolton  <ian.bolton@arm.com>
+
+       * config/aarch64/aarch64-protos.h
+       (aarch64_hard_regno_caller_save_mode): New prototype.
+       * config/aarch64/aarch64.c (aarch64_hard_regno_caller_save_mode):
+       New function.
+       * config/aarch64/aarch64.h (HARD_REGNO_CALLER_SAVE_MODE): New macro.
+
 2014-05-13  Christian Bruel  <christian.bruel@st.com>
 
        * target.def (mode_switching): New hook vector.
index 04cbc78..7cf7d9f 100644 (file)
@@ -202,6 +202,8 @@ enum aarch64_symbol_type aarch64_classify_symbol (rtx,
 enum aarch64_symbol_type aarch64_classify_tls_symbol (rtx);
 enum reg_class aarch64_regno_regclass (unsigned);
 int aarch64_asm_preferred_eh_data_format (int, int);
+enum machine_mode aarch64_hard_regno_caller_save_mode (unsigned, unsigned,
+                                                      enum machine_mode);
 int aarch64_hard_regno_mode_ok (unsigned, enum machine_mode);
 int aarch64_hard_regno_nregs (unsigned, enum machine_mode);
 int aarch64_simd_attr_length_move (rtx);
index 6a6fb03..fabd6a9 100644 (file)
@@ -424,6 +424,24 @@ aarch64_hard_regno_mode_ok (unsigned regno, enum machine_mode mode)
   return 0;
 }
 
+/* Implement HARD_REGNO_CALLER_SAVE_MODE.  */
+enum machine_mode
+aarch64_hard_regno_caller_save_mode (unsigned regno, unsigned nregs,
+                                    enum machine_mode mode)
+{
+  /* Handle modes that fit within single registers.  */
+  if (nregs == 1 && GET_MODE_SIZE (mode) <= 16)
+    {
+      if (GET_MODE_SIZE (mode) >= 4)
+        return mode;
+      else
+        return SImode;
+    }
+  /* Fall back to generic for multi-reg and very large modes.  */
+  else
+    return choose_hard_reg_mode (regno, nregs, false);
+}
+
 /* Return true if calls to DECL should be treated as
    long-calls (ie called via a register).  */
 static bool
index c9b30d0..0574593 100644 (file)
@@ -824,6 +824,11 @@ do {                                                                            \
 
 #define SHIFT_COUNT_TRUNCATED !TARGET_SIMD
 
+/* Choose appropriate mode for caller saves, so we do the minimum
+   required size of load/store.  */
+#define HARD_REGNO_CALLER_SAVE_MODE(REGNO, NREGS, MODE) \
+  aarch64_hard_regno_caller_save_mode ((REGNO), (NREGS), (MODE))
+
 /* Callee only saves lower 64-bits of a 128-bit register.  Tell the
    compiler the callee clobbers the top 64-bits when restoring the
    bottom 64-bits.  */