SH patch applied
Joern Rennecke
joern.rennecke@superh.com
Tue Jul 30 10:54:00 GMT 2002
This patch prevents medium-range branches from the fixup_pcloads
stage to be enlarged to eight bytes by reorg scavanging for a
superflous delay-slot insn.
--
--------------------------
SuperH
2430 Aztec West / Almondsbury / BRISTOL / BS32 4AQ
T:+44 1454 462330
-------------- next part --------------
Tue Jul 30 18:31:31 2002 J"orn Rennecke <joern.rennecke@superh.com>
* sh.md (cond_delay_slot): New attribute.
(cbranch delay): Use it for anulled-true case.
(stuff_delay_slot): New pattern.
* sh.c (print_operand, case '.'): Don't print .s / /s fore zero-length
delay slot insn.
(gen_far_branch): Emit stuff_delay_slot pattern.
Index: config/sh/sh.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sh/sh.c,v
retrieving revision 1.165
diff -p -r1.165 sh.c
*** config/sh/sh.c 18 Jul 2002 19:26:07 -0000 1.165
--- config/sh/sh.c 30 Jul 2002 17:30:40 -0000
*************** print_operand (stream, x, code)
*** 346,352 ****
{
case '.':
if (final_sequence
! && ! INSN_ANNULLED_BRANCH_P (XVECEXP (final_sequence, 0, 0)))
fprintf (stream, ASSEMBLER_DIALECT ? "/s" : ".s");
break;
case ',':
--- 346,353 ----
{
case '.':
if (final_sequence
! && ! INSN_ANNULLED_BRANCH_P (XVECEXP (final_sequence, 0, 0))
! && get_attr_length (XVECEXP (final_sequence, 0, 1)))
fprintf (stream, ASSEMBLER_DIALECT ? "/s" : ".s");
break;
case ',':
*************** gen_far_branch (bp)
*** 3212,3217 ****
--- 3213,3223 ----
JUMP_LABEL (jump) = bp->far_label;
if (! invert_jump (insn, label, 1))
abort ();
+ (emit_insn_after
+ (gen_stuff_delay_slot
+ (GEN_INT (INSN_UID (XEXP (SET_SRC (PATTERN (jump)), 0))),
+ GEN_INT (recog_memoized (insn) == CODE_FOR_branch_false)),
+ insn));
/* Prevent reorg from undoing our splits. */
gen_block_redirect (jump, bp->address += 2, 2);
}
Index: config/sh/sh.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sh/sh.md,v
retrieving revision 1.117
diff -p -r1.117 sh.md
*** config/sh/sh.md 25 Jul 2002 19:38:54 -0000 1.117
--- config/sh/sh.md 30 Jul 2002 17:30:40 -0000
***************
*** 696,701 ****
--- 696,705 ----
(eq_attr "length" "2") (const_string "yes")
] (const_string "no")))
+ (define_attr "cond_delay_slot" "yes,no"
+ (cond [(eq_attr "in_delay_slot" "yes") (const_string "yes")
+ ] (const_string "no")))
+
(define_attr "is_sfunc" ""
(if_then_else (eq_attr "type" "sfunc") (const_int 1) (const_int 0)))
***************
*** 738,744 ****
(define_delay
(and (eq_attr "type" "cbranch")
(ne (symbol_ref "TARGET_SH2") (const_int 0)))
! [(eq_attr "in_delay_slot" "yes") (eq_attr "in_delay_slot" "yes") (nil)])
;; -------------------------------------------------------------------------
;; SImode signed integer comparisons
--- 742,748 ----
(define_delay
(and (eq_attr "type" "cbranch")
(ne (symbol_ref "TARGET_SH2") (const_int 0)))
! [(eq_attr "in_delay_slot" "yes") (eq_attr "cond_delay_slot" "yes") (nil)])
;; -------------------------------------------------------------------------
;; SImode signed integer comparisons
***************
*** 5141,5146 ****
--- 5145,5162 ----
"TARGET_SH1"
""
[(set_attr "length" "0")])
+
+ ;; This one is used to preemt an insn from beyond the bra / braf / jmp
+ ;; being pulled into the delay slot of a condbranch that has been made to
+ ;; jump around the unconditional jump because it was out of range.
+ (define_insn "stuff_delay_slot"
+ [(set (pc)
+ (unspec [(match_operand 0 "const_int_operand" "") (pc)] UNSPEC_BBR))
+ (set (reg:SI T_REG) (match_operand 1 "const_int_operand" ""))]
+ "TARGET_SH1"
+ ""
+ [(set_attr "length" "0")
+ (set_attr "cond_delay_slot" "yes")])
;; Conditional branch insns
More information about the Gcc-patches
mailing list