This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH SH]: Added pop insn to avoid delay slot scheduling


Hi,
Please find below patch for SH which will prevent the generation of 
the pop instruction in the delay slot after 'rte'. For the 'sh' and
'sh2', the rte instruction reads the return pc from the stack and any
pop in the delay slot crashes the hardware. A new predicate has been 
defined to implement this.
Regression done for sh-elf-* and no new regressions found.
Please comment.

Regards,
Kaushik Phatak
www.kpitgnutools.com

=======================Start of Patch================================
ChangeLog
2010-02-26  Kaushik Phatak  <kaushik.phatak@kpitcummins.com>

        * config/sh/sh.md (movqi_pop): New insn pattern.
        * config/sh/predicates.md (sh_no_delay_pop_operand): New predicate.

diff -upr trunk.orig/gcc/config/sh/predicates.md trunk/gcc/config/sh/predicates.md
--- trunk.orig/gcc/config/sh/predicates.md	2009-04-17 04:39:53.000000000 +0530
+++ trunk/gcc/config/sh/predicates.md	2010-02-25 12:08:27.000000000 +0530
@@ -421,6 +421,25 @@
   return general_operand (op, mode);
 })
 
+
+;; Returns 1 if OP is a POST_INC on stack pointer register.
+
+(define_predicate "sh_no_delay_pop_operand"
+  (match_code "mem")
+{
+  rtx inside;
+  inside = XEXP (op, 0);
+
+  if (GET_CODE (op) == MEM && GET_MODE (op) == SImode 
+      && GET_CODE (inside) == POST_INC 
+      && GET_CODE (XEXP (inside, 0)) == REG
+      && REGNO (XEXP (inside, 0)) == SP_REG)
+    return 1;
+
+  return 0;
+})
+
+
 ;; Returns 1 if OP is a MEM that can be source of a simple move operation.
 
 (define_predicate "unaligned_load_operand"
diff -upr trunk.orig/gcc/config/sh/sh.md trunk/gcc/config/sh/sh.md
--- trunk.orig/gcc/config/sh/sh.md	2009-08-07 19:42:00.000000000 +0530
+++ trunk/gcc/config/sh/sh.md	2010-02-26 11:45:43.000000000 +0530
@@ -4992,6 +4992,21 @@ label:
   "TARGET_SH1"
   "sett")
 
+;; define additional pop for SH1 and SH2 so it does not get 
+;; placed in the delay slot
+(define_insn "movsi_pop"
+  [(set (match_operand:SI 0 "register_operand" "=r,x,l")
+        (match_operand:SI 1 "sh_no_delay_pop_operand" ">,>,>"))]
+  "(TARGET_SH1 || TARGET_SH2E || TARGET_SH2A)
+   && ! TARGET_SH3"
+  "@
+   mov.l   %1,%0
+   lds.l   %1,%0
+   lds.l   %1,%0"
+  [(set_attr "type" "load_si,mem_mac,pload")
+   (set_attr "length" "2,2,2")
+   (set_attr "in_delay_slot" "no,no,no")])
+
 ;; t/r must come after r/r, lest reload will try to reload stuff like
 ;; (set (subreg:SI (mem:QI (plus:SI (reg:SI SP_REG) (const_int 12)) 0) 0)
 ;; (made from (set (subreg:SI (reg:QI ###) 0) ) into T.
 
=========================End Of Patch================================


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]