Patchwork Commit: RX: Add return pattern

login
register
mail settings
Submitter Nick Clifton
Date Jan. 12, 2012, 5:31 p.m.
Message ID <4F0F18D8.2060403@redhat.com>
Download mbox | patch
Permalink /patch/135653/
State New
Headers show

Comments

Nick Clifton - Jan. 12, 2012, 5:31 p.m.
Hi Richard,

> Not an ideal solution, since the availability of this pattern implies
> it's extremely cheap, and we'll replace jumps to the epilogue with
> this pattern.
> Or to define an availability predicate similar to i386, testing if
> the epilogue is trivial, and only a return insn is needed.

Something like the attached ?

I am running some local checks now and if there are no regressions then 
I will check the patch in tomorrow.

Cheers
   Nick
Richard Henderson - Jan. 22, 2012, 11:09 p.m.
On 01/13/2012 04:31 AM, nick clifton wrote:
> Hi Richard,
> 
>> Not an ideal solution, since the availability of this pattern implies
>> it's extremely cheap, and we'll replace jumps to the epilogue with
>> this pattern.
>> Or to define an availability predicate similar to i386, testing if
>> the epilogue is trivial, and only a return insn is needed.
> 
> Something like the attached ?
> 
> I am running some local checks now and if there are no regressions then I will check the patch in tomorrow.

Looks good, thanks.


r~

Patch

Index: gcc/config/rx/rx-protos.h
===================================================================
--- gcc/config/rx/rx-protos.h	(revision 183121)
+++ gcc/config/rx/rx-protos.h	(working copy)
@@ -21,6 +22,8 @@ 
 #ifndef GCC_RX_PROTOS_H
 #define GCC_RX_PROTOS_H
 
+extern bool             rx_can_use_simple_return (void);
+extern void		rx_expand_epilogue (bool);
 extern void		rx_expand_prologue (void);
 extern int		rx_initial_elimination_offset (int, int);
 
@@ -29,7 +32,6 @@ 
 extern int 		rx_align_for_label (rtx, int);
 extern void             rx_emit_stack_popm (rtx *, bool);
 extern void             rx_emit_stack_pushm (rtx *);
-extern void		rx_expand_epilogue (bool);
 extern char *		rx_gen_move_template (rtx *, bool);
 extern bool		rx_is_legitimate_constant (enum machine_mode, rtx);
 extern bool		rx_is_restricted_memory_address (rtx,
Index: gcc/config/rx/rx.md
===================================================================
--- gcc/config/rx/rx.md	(revision 183121)
+++ gcc/config/rx/rx.md	(working copy)
@@ -342,7 +343,7 @@ 
 
 (define_expand "return"
   [(return)]
-  ""
+  "rx_can_use_simple_return ()"
   "rx_expand_epilogue (false); DONE;"
 )
 
Index: gcc/config/rx/rx.c
===================================================================
--- gcc/config/rx/rx.c	(revision 183121)
+++ gcc/config/rx/rx.c	(working copy)
@@ -1818,7 +1819,31 @@ 
 
   return vector;
 }
-  
+
+/* Returns true if a simple return insn can be used.  */
+
+bool
+rx_can_use_simple_return (void)
+{
+  unsigned int low;
+  unsigned int high;
+  unsigned int frame_size;
+  unsigned int stack_size;
+  unsigned int register_mask;
+
+  if (is_naked_func (NULL_TREE)
+      || is_fast_interrupt_func (NULL_TREE)
+      || is_interrupt_func (NULL_TREE))
+    return false;
+
+  rx_get_stack_layout (& low, & high, & register_mask,
+		       & frame_size, & stack_size);
+
+  return (register_mask == 0
+	  && (frame_size + stack_size) == 0
+	  && low == 0);
+}
+
 void
 rx_expand_epilogue (bool is_sibcall)
 {