]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
-fuse-caller-save - Enable for AArch64
authorTom de Vries <tom@codesourcery.com>
Wed, 18 Jun 2014 16:09:01 +0000 (16:09 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Wed, 18 Jun 2014 16:09:01 +0000 (16:09 +0000)
2014-05-30  Tom de Vries  <tom@codesourcery.com>

* config/aarch64/aarch64-protos.h (aarch64_emit_call_insn): Declare.
* config/aarch64/aarch64.c
(TARGET_CALL_FUSAGE_CONTAINS_NON_CALLEE_CLOBBERS): Redefine as true.
(aarch64_emit_call_insn): New function.
(aarch64_load_symref_appropriately): Use aarch64_emit_call_insn instead
of emit_call_insn.
* config/aarch64/aarch64.md (define_expand "call_internal")
(define_expand "call_value_internal", define_expand "sibcall_internal")
(define_expand "sibcall_value_internal"): New.
(define_expand "call", define_expand "call_value")
(define_expand "sibcall", define_expand "sibcall_value"): Use internal
expand variant and aarch64_emit_call_insn.

* gcc.target/aarch64/fuse-caller-save.c: New test.

From-SVN: r211799

gcc/ChangeLog
gcc/config/aarch64/aarch64-protos.h
gcc/config/aarch64/aarch64.c
gcc/config/aarch64/aarch64.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/aarch64/fuse-caller-save.c [new file with mode: 0644]

index b0c9ed83ba0e67fb522817e4d5709568ccacd7ec..564c503e3dd8daf67ba4521eabfd2df3f33ec8a4 100644 (file)
@@ -1,3 +1,18 @@
+2014-06-18  Tom de Vries  <tom@codesourcery.com>
+
+       * config/aarch64/aarch64-protos.h (aarch64_emit_call_insn): Declare.
+       * config/aarch64/aarch64.c
+       (TARGET_CALL_FUSAGE_CONTAINS_NON_CALLEE_CLOBBERS): Redefine as true.
+       (aarch64_emit_call_insn): New function.
+       (aarch64_load_symref_appropriately): Use aarch64_emit_call_insn instead
+       of emit_call_insn.
+       * config/aarch64/aarch64.md (define_expand "call_internal")
+       (define_expand "call_value_internal", define_expand "sibcall_internal")
+       (define_expand "sibcall_value_internal"): New.
+       (define_expand "call", define_expand "call_value")
+       (define_expand "sibcall", define_expand "sibcall_value"): Use internal
+       expand variant and aarch64_emit_call_insn.
+
 2014-06-18  Radovan Obradovic  <robradovic@mips.com>
             Tom de Vries  <tom@codesourcery.com>
 
index c4f75b36a173a11b09120b8943da40c7e1eee9f5..213c8dce12660c3347105a2cea62ea1fcde2efdf 100644 (file)
@@ -245,6 +245,7 @@ void aarch64_init_cumulative_args (CUMULATIVE_ARGS *, const_tree, rtx,
 void aarch64_init_expanders (void);
 void aarch64_print_operand (FILE *, rtx, char);
 void aarch64_print_operand_address (FILE *, rtx);
+bool aarch64_emit_call_insn (rtx);
 
 /* Initialize builtins for SIMD intrinsics.  */
 void init_aarch64_simd_builtins (void);
index e0c25e7afef0a5d66d7a0111df44423cfe387b00..b2d005b98b0085ad6e48eba8beed596ea72a3921 100644 (file)
@@ -696,7 +696,7 @@ aarch64_load_symref_appropriately (rtx dest, rtx imm,
        rtx result = gen_rtx_REG (Pmode, R0_REGNUM);
 
        start_sequence ();
-       emit_call_insn (gen_tlsgd_small (result, imm));
+       aarch64_emit_call_insn (gen_tlsgd_small (result, imm));
        insns = get_insns ();
        end_sequence ();
 
@@ -3393,6 +3393,18 @@ aarch64_fixed_condition_code_regs (unsigned int *p1, unsigned int *p2)
   return true;
 }
 
+/* Emit call insn with PAT and do aarch64-specific handling.  */
+
+bool
+aarch64_emit_call_insn (rtx pat)
+{
+  rtx insn = emit_call_insn (pat);
+
+  rtx *fusage = &CALL_INSN_FUNCTION_USAGE (insn);
+  clobber_reg (fusage, gen_rtx_REG (word_mode, IP0_REGNUM));
+  clobber_reg (fusage, gen_rtx_REG (word_mode, IP1_REGNUM));
+}
+
 enum machine_mode
 aarch64_select_cc_mode (RTX_CODE code, rtx x, rtx y)
 {
@@ -9813,6 +9825,9 @@ aarch64_expand_movmem (rtx *operands)
 #undef TARGET_FLAGS_REGNUM
 #define TARGET_FLAGS_REGNUM CC_REGNUM
 
+#undef TARGET_CALL_FUSAGE_CONTAINS_NON_CALLEE_CLOBBERS
+#define TARGET_CALL_FUSAGE_CONTAINS_NON_CALLEE_CLOBBERS true
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-aarch64.h"
index 1ee2cae998b6f87723d0c973145cbda2819a13bb..7f8bb82867da942b30e0e0e9fb57350a69b98dec 100644 (file)
 ;; Subroutine calls and sibcalls
 ;; -------------------------------------------------------------------
 
+(define_expand "call_internal"
+  [(parallel [(call (match_operand 0 "memory_operand" "")
+                   (match_operand 1 "general_operand" ""))
+             (use (match_operand 2 "" ""))
+             (clobber (reg:DI LR_REGNUM))])])
+
 (define_expand "call"
   [(parallel [(call (match_operand 0 "memory_operand" "")
                    (match_operand 1 "general_operand" ""))
   ""
   "
   {
-    rtx callee;
+    rtx callee, pat;
 
     /* In an untyped call, we can get NULL for operand 2.  */
     if (operands[2] == NULL)
        ? aarch64_is_long_call_p (callee)
        : !REG_P (callee))
       XEXP (operands[0], 0) = force_reg (Pmode, callee);
+
+    pat = gen_call_internal (operands[0], operands[1], operands[2]);
+    aarch64_emit_call_insn (pat);
+    DONE;
   }"
 )
 
   [(set_attr "type" "call")]
 )
 
+(define_expand "call_value_internal"
+  [(parallel [(set (match_operand 0 "" "")
+                  (call (match_operand 1 "memory_operand" "")
+                        (match_operand 2 "general_operand" "")))
+             (use (match_operand 3 "" ""))
+             (clobber (reg:DI LR_REGNUM))])])
+
 (define_expand "call_value"
   [(parallel [(set (match_operand 0 "" "")
                   (call (match_operand 1 "memory_operand" "")
   ""
   "
   {
-    rtx callee;
+    rtx callee, pat;
 
     /* In an untyped call, we can get NULL for operand 3.  */
     if (operands[3] == NULL)
        ? aarch64_is_long_call_p (callee)
        : !REG_P (callee))
       XEXP (operands[1], 0) = force_reg (Pmode, callee);
+
+    pat = gen_call_value_internal (operands[0], operands[1], operands[2],
+                                   operands[3]);
+    aarch64_emit_call_insn (pat);
+    DONE;
   }"
 )
 
   [(set_attr "type" "call")]
 )
 
+(define_expand "sibcall_internal"
+  [(parallel [(call (match_operand 0 "memory_operand" "")
+                   (match_operand 1 "general_operand" ""))
+             (return)
+             (use (match_operand 2 "" ""))])])
+
 (define_expand "sibcall"
   [(parallel [(call (match_operand 0 "memory_operand" "")
                    (match_operand 1 "general_operand" ""))
              (use (match_operand 2 "" ""))])]
   ""
   {
+    rtx pat;
+
     if (!REG_P (XEXP (operands[0], 0))
        && (GET_CODE (XEXP (operands[0], 0)) != SYMBOL_REF))
      XEXP (operands[0], 0) = force_reg (Pmode, XEXP (operands[0], 0));
 
     if (operands[2] == NULL_RTX)
       operands[2] = const0_rtx;
+
+    pat = gen_sibcall_internal (operands[0], operands[1], operands[2]);
+    aarch64_emit_call_insn (pat);
+    DONE;
   }
 )
 
+(define_expand "sibcall_value_internal"
+  [(parallel [(set (match_operand 0 "" "")
+                  (call (match_operand 1 "memory_operand" "")
+                        (match_operand 2 "general_operand" "")))
+             (return)
+             (use (match_operand 3 "" ""))])])
+
 (define_expand "sibcall_value"
   [(parallel [(set (match_operand 0 "" "")
                   (call (match_operand 1 "memory_operand" "")
              (use (match_operand 3 "" ""))])]
   ""
   {
+    rtx pat;
+
     if (!REG_P (XEXP (operands[1], 0))
        && (GET_CODE (XEXP (operands[1], 0)) != SYMBOL_REF))
      XEXP (operands[1], 0) = force_reg (Pmode, XEXP (operands[1], 0));
 
     if (operands[3] == NULL_RTX)
       operands[3] = const0_rtx;
+
+    pat = gen_sibcall_value_internal (operands[0], operands[1], operands[2],
+                                      operands[3]);
+    aarch64_emit_call_insn (pat);
+    DONE;
   }
 )
 
index f41f3dfe06911446ed72e46bcb337eff5c929f49..6f77a38e23f6ba5d59e36e70a24df9c39b8bff98 100644 (file)
@@ -1,3 +1,7 @@
+2014-06-18  Tom de Vries  <tom@codesourcery.com>
+
+       * gcc.target/aarch64/fuse-caller-save.c: New test.
+
 2014-06-18  Radovan Obradovic  <robradovic@mips.com>
             Tom de Vries  <tom@codesourcery.com>
 
diff --git a/gcc/testsuite/gcc.target/aarch64/fuse-caller-save.c b/gcc/testsuite/gcc.target/aarch64/fuse-caller-save.c
new file mode 100644 (file)
index 0000000..45e535c
--- /dev/null
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fuse-caller-save" } */
+/* Testing -fuse-caller-save optimization option.  */
+
+static int __attribute__((noinline))
+bar (int x)
+{
+  return x + 3;
+}
+
+int __attribute__((noinline))
+foo (int y)
+{
+  return y + bar (y);
+}
+
+int
+main (void)
+{
+  return !(foo (5) == 13);
+}
+
+/* { dg-final { scan-assembler-times "\\\[sp, -16\\\]!" 2 } } */
+/* { dg-final { scan-assembler-not "\\\[sp, -32\\\]!" } } */