This is the mail archive of the gcc-bugs@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 candidate for PR target/16665 (Was: Re: Quo vadis, thunk?)


Here is the SH specific patch to go with the cp/method.c patch.
So far I have only checked that the assembly looks right.
(for sh5-compact and sh5 at -O0 and -O2, with and without -fpic).

2004-08-03  J"orn Rennecke <joern.rennecke@superh.com>

	* sh.md (UNSPEC_THUNK): New constant.
	(gen_sibcalli_thunk): New pattern.
	* sh.c (sh_output_mi_thunk): Use limited range pc-relative addressing.

Index: sh.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sh/sh.c,v
retrieving revision 1.288
diff -p -r1.288 sh.c
*** sh.c	29 Jul 2004 07:37:16 -0000	1.288
--- sh.c	3 Aug 2004 15:43:23 -0000
*************** sh_adjust_cost (rtx insn, rtx link ATTRI
*** 8514,8520 ****
  	  if (GET_CODE (call) == SET)
  	    call = SET_SRC (call);
  	  if (GET_CODE (call) == CALL && GET_CODE (XEXP (call, 0)) == MEM
! 	      && ! reg_set_p (XEXP (XEXP (call, 0), 0), dep_insn))
  	    cost = 0;
  	}
        /* Likewise, the most timing critical input for an sfuncs call
--- 8514,8522 ----
  	  if (GET_CODE (call) == SET)
  	    call = SET_SRC (call);
  	  if (GET_CODE (call) == CALL && GET_CODE (XEXP (call, 0)) == MEM
! 		  /* sibcalli_thunk uses a symbol_ref in an unspec.  */
! 	      && (GET_CODE (XEXP (XEXP (call, 0), 0)) == UNSPEC
! 		  || ! reg_set_p (XEXP (XEXP (call, 0), 0), dep_insn)))
  	    cost = 0;
  	}
        /* Likewise, the most timing critical input for an sfuncs call
*************** sh_output_mi_thunk (FILE *file, tree thu
*** 9711,9719 ****
        TREE_USED (function) = 1;
      }
    funexp = XEXP (DECL_RTL (function), 0);
!   emit_move_insn (scratch2, funexp);
!   funexp = gen_rtx_MEM (FUNCTION_MODE, scratch2);
!   sibcall = emit_call_insn (gen_sibcall (funexp, const0_rtx, NULL_RTX));
    SIBLING_CALL_P (sibcall) = 1;
    use_reg (&CALL_INSN_FUNCTION_USAGE (sibcall), this);
    emit_barrier ();
--- 9713,9728 ----
        TREE_USED (function) = 1;
      }
    funexp = XEXP (DECL_RTL (function), 0);
!   if (TARGET_SH1)
!     sibcall = gen_sibcalli_thunk (funexp, const0_rtx);
!   else
!     {
!       funexp = gen_sym2PIC (funexp);
!       emit_move_insn (scratch2, funexp);
!       funexp = gen_rtx_MEM (FUNCTION_MODE, scratch2);
!       sibcall = gen_sibcall (funexp, const0_rtx, NULL_RTX);
!     }
!   sibcall = emit_call_insn (sibcall);
    SIBLING_CALL_P (sibcall) = 1;
    use_reg (&CALL_INSN_FUNCTION_USAGE (sibcall), this);
    emit_barrier ();
Index: sh.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sh/sh.md,v
retrieving revision 1.180
diff -p -r1.180 sh.md
*** sh.md	29 Jul 2004 07:37:16 -0000	1.180
--- sh.md	3 Aug 2004 15:43:23 -0000
***************
*** 143,148 ****
--- 143,149 ----
    (UNSPEC_GOTTPOFF	24)
    (UNSPEC_TPOFF		25)
    (UNSPEC_RA		26)
+   (UNSPEC_THUNK		36)
  
    ;; These are used with unspec_volatile.
    (UNSPECV_BLOCKAGE	0)
***************
*** 6133,6138 ****
--- 6134,6157 ----
  		      (const_string "single") (const_string "double")))
     (set_attr "type" "jump_ind")])
  
+ ;; This uses an unspec to describe that the symbol_ref is very close.
+ ;; N.B. UNSPEC_PIC only means defined in the same module, which might be still
+ ;; to far for bra.
+ (define_insn "sibcalli_thunk"
+   [(call (mem:SI (unspec:SI [(match_operand:SI 0 "symbol_ref_operand" "")]
+ 			     UNSPEC_THUNK))
+ 	 (match_operand 1 "" ""))
+    (use (reg:PSI FPSCR_REG))
+    (return)]
+   "TARGET_SH1"
+   "bra\t%O0%#"
+   [(set_attr "needs_delay_slot" "yes")
+    (set (attr "fp_mode")
+ 	(if_then_else (eq_attr "fpu_single" "yes")
+ 		      (const_string "single") (const_string "double")))
+    (set_attr "type" "jump")
+    (set_attr "length" "2")])
+ 
  (define_insn_and_split "sibcall_pcrel"
    [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" ""))
  	 (match_operand 1 "" ""))


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