Add a new parameter to the function output_return_instruction to handle simple...
authorIan Bolton <ian.bolton@arm.com>
Mon, 18 Jun 2012 17:57:06 +0000 (17:57 +0000)
committerGreta Yorsh <gretay@gcc.gnu.org>
Mon, 18 Jun 2012 17:57:06 +0000 (18:57 +0100)
Add a new parameter to the function output_return_instruction to handle
simple cases of return when no epilogue needs to be printed out.

gcc/

2012-06-18  Ian Bolton  <ian.bolton@arm.com>
            Sameera Deshpande  <sameera.deshpande@arm.com>
            Greta Yorsh  <greta.yorsh@arm.com>

        * config/arm/arm-protos.h (output_return_instruction): New parameter and
int to bool change of parameter types.
        * config/arm/arm.c (output_return_instruction): Likewise.
        * config/arm/arm.md (arm_simple_return): New pattern.
        (arm_return, cond_return, cond_return_inverted): Add new arguments.
        * config/arm/thumb2.md (thumb2_return): Update condition and code.

Co-Authored-By: Greta Yorsh <greta.yorsh@arm.com>
Co-Authored-By: Sameera Deshpande <sameera.deshpande@arm.com>
From-SVN: r188743

gcc/ChangeLog
gcc/config/arm/arm-protos.h
gcc/config/arm/arm.c
gcc/config/arm/arm.md
gcc/config/arm/thumb2.md

index ec83ad6a95daa03715a30c9c7d1aa1292af4a758..45497a73b70f30ebc381d642597da481a9418364 100644 (file)
@@ -1,3 +1,14 @@
+2012-06-18  Ian Bolton  <ian.bolton@arm.com>
+            Sameera Deshpande  <sameera.deshpande@arm.com>
+            Greta Yorsh  <greta.yorsh@arm.com>
+
+        * config/arm/arm-protos.h (output_return_instruction): New parameter and
+       int to bool change of parameter types.
+        * config/arm/arm.c (output_return_instruction): Likewise.
+        * config/arm/arm.md (arm_simple_return): New pattern.
+        (arm_return, cond_return, cond_return_inverted): Add new arguments.
+        * config/arm/thumb2.md (thumb2_return): Update condition and code.
+
 2012-06-18  Ian Bolton  <ian.bolton@arm.com>
             Sameera Deshpande  <sameera.deshpande@arm.com>
             Greta Yorsh  <greta.yorsh@arm.com>
index 5c25e997c7fb5f81787b0b4d2bb00a648a55cf31..e19c6356731faab70a7e564c5373a5da4db68e3d 100644 (file)
@@ -148,7 +148,7 @@ extern int arm_address_offset_is_imm (rtx);
 extern const char *output_add_immediate (rtx *);
 extern const char *arithmetic_instr (rtx, int);
 extern void output_ascii_pseudo_op (FILE *, const unsigned char *, int);
-extern const char *output_return_instruction (rtx, int, int);
+extern const char *output_return_instruction (rtx, bool, bool, bool);
 extern void arm_poke_function_name (FILE *, const char *);
 extern void arm_final_prescan_insn (rtx);
 extern int arm_debugger_arg_offset (int, rtx);
index 8bc8fd0b357ba46643bfca3f722ab02991736705..b9e0f7bbf1a5e48f86aee833a6214cf6947f643d 100644 (file)
@@ -15516,9 +15516,11 @@ arm_get_vfp_saved_size (void)
 
 
 /* Generate a function exit sequence.  If REALLY_RETURN is false, then do
-   everything bar the final return instruction.  */
+   everything bar the final return instruction.  If simple_return is true,
+   then do not output epilogue, because it has already been emitted in RTL.  */
 const char *
-output_return_instruction (rtx operand, int really_return, int reverse)
+output_return_instruction (rtx operand, bool really_return, bool reverse,
+                           bool simple_return)
 {
   char conditional[10];
   char instr[100];
@@ -15561,7 +15563,7 @@ output_return_instruction (rtx operand, int really_return, int reverse)
   offsets = arm_get_frame_offsets ();
   live_regs_mask = offsets->saved_regs_mask;
 
-  if (live_regs_mask)
+  if (!simple_return && live_regs_mask)
     {
       const char * return_reg;
 
@@ -15689,7 +15691,7 @@ output_return_instruction (rtx operand, int really_return, int reverse)
        {
          /* The return has already been handled
             by loading the LR into the PC.  */
-         really_return = 0;
+          return "";
        }
     }
 
index c2793f1bf174f28d2fc39e874e584fff8602c8e0..5954323e1a4ce6dcbb5d2d96e4e492b0f728ba7a 100644 (file)
         arm_ccfsm_state += 2;
         return \"\";
       }
-    return output_return_instruction (const_true_rtx, TRUE, FALSE);
+    return output_return_instruction (const_true_rtx, true, false, false);
   }"
   [(set_attr "type" "load1")
    (set_attr "length" "12")
         arm_ccfsm_state += 2;
         return \"\";
       }
-    return output_return_instruction (operands[0], TRUE, FALSE);
+    return output_return_instruction (operands[0], true, false, false);
   }"
   [(set_attr "conds" "use")
    (set_attr "length" "12")
         arm_ccfsm_state += 2;
         return \"\";
       }
-    return output_return_instruction (operands[0], TRUE, TRUE);
+    return output_return_instruction (operands[0], true, true, false);
   }"
   [(set_attr "conds" "use")
    (set_attr "length" "12")
    (set_attr "type" "load1")]
 )
 
+(define_insn "*arm_simple_return"
+  [(simple_return)]
+  "TARGET_ARM"
+  "*
+  {
+    if (arm_ccfsm_state == 2)
+      {
+        arm_ccfsm_state += 2;
+        return \"\";
+      }
+    return output_return_instruction (const_true_rtx, true, false, true);
+  }"
+  [(set_attr "type" "branch")
+   (set_attr "length" "4")
+   (set_attr "predicable" "yes")]
+)
+
 ;; Generate a sequence of instructions to determine if the processor is
 ;; in 26-bit or 32-bit mode, and return the appropriate return address
 ;; mask.
index 337717efcf7d5b41d972f9719fd0e94bf86e1828..fd0bea63f417cc88c60fdb8f4e2048db7080aeda 100644 (file)
    (set_attr "length" "20")]
 )
 
-;; Note: this is not predicable, to avoid issues with linker-generated
-;; interworking stubs.
 (define_insn "*thumb2_return"
-  [(return)]
-  "TARGET_THUMB2 && USE_RETURN_INSN (FALSE)"
-  "*
-  {
-    return output_return_instruction (const_true_rtx, TRUE, FALSE);
-  }"
-  [(set_attr "type" "load1")
-   (set_attr "length" "12")]
+  [(simple_return)]
+  "TARGET_THUMB2"
+  "* return output_return_instruction (const_true_rtx, true, false, true);"
+  [(set_attr "type" "branch")
+   (set_attr "length" "4")]
 )
 
 (define_insn_and_split "thumb2_eh_return"