[3.4-BIB] x86-64 sibcall fixes

Jan Hubicka jh@suse.cz
Sun Oct 27 11:32:00 GMT 2002


> On Tue, Oct 15, 2002 at 07:58:07PM +0200, Jan Hubicka wrote:
> > 	(override_options): Disable MASK_FLOAT_RETURNS for 64bit ABI.
> 
> This breaks returning long double values.
Hi,
here is updated patch, this time for BIB branch, as I don't think this
needs fixing for 3.3.

Sun Oct 27 20:30:29 CET 2002  Jan Hubicka  <jh@suse.cz>
	* i386.c (ix86_function_ok_for_sibcall): handle 64bit case.
	* i386.md (call_1_rex64): Do not handle sibcall
	(sibcall_1_rex64): Handle sibcall.

Index: i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.446.2.2
diff -c -3 -p -r1.446.2.2 i386.c
*** i386.c	23 Oct 2002 15:48:29 -0000	1.446.2.2
--- i386.c	27 Oct 2002 19:28:51 -0000
*************** ix86_function_ok_for_sibcall (decl, exp)
*** 1382,1404 ****
       tree decl;
       tree exp;
  {
!   /* We don't have 64-bit patterns in place.  */
!   if (TARGET_64BIT)
!     return false;
! 
    /* If we are generating position-independent code, we cannot sibcall
       optimize any indirect call, or a direct call to a global function,
       as the PLT requires %ebx be live.  */
    if (flag_pic && (!decl || TREE_PUBLIC (decl)))
      return false;
  
    /* If we are returning floats on the 80387 register stack, we cannot
       make a sibcall from a function that doesn't return a float to a
       function that does; the necessary stack adjustment will not be
       executed.  */
!   if (TARGET_FLOAT_RETURNS_IN_80387
!       && FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (exp)))
!       && !FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (TREE_TYPE (cfun->decl)))))
      return false;
  
    /* If this call is indirect, we'll need to be able to use a call-clobbered
--- 1382,1402 ----
       tree decl;
       tree exp;
  {
!   rtx result;
!   rtx cfunresult;
    /* If we are generating position-independent code, we cannot sibcall
       optimize any indirect call, or a direct call to a global function,
       as the PLT requires %ebx be live.  */
    if (flag_pic && (!decl || TREE_PUBLIC (decl)))
      return false;
  
+   result = ix86_function_value (TREE_TYPE (exp));
+   cfunresult = ix86_function_value (TREE_TYPE (DECL_RESULT (cfun->decl)));
    /* If we are returning floats on the 80387 register stack, we cannot
       make a sibcall from a function that doesn't return a float to a
       function that does; the necessary stack adjustment will not be
       executed.  */
!   if (STACK_REG_P (result) && !STACK_REG_P (cfunresult))
      return false;
  
    /* If this call is indirect, we'll need to be able to use a call-clobbered
Index: i386.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.md,v
retrieving revision 1.380.2.3
diff -c -3 -p -r1.380.2.3 i386.md
*** i386.md	23 Oct 2002 20:57:40 -0000	1.380.2.3
--- i386.md	27 Oct 2002 19:28:58 -0000
***************
*** 13777,13783 ****
  (define_insn "*call_1_rex64"
    [(call (mem:QI (match_operand:DI 0 "call_insn_operand" "rsm"))
  	 (match_operand 1 "" ""))]
!   "TARGET_64BIT"
  {
    if (constant_call_address_operand (operands[0], QImode))
      {
--- 13777,13783 ----
  (define_insn "*call_1_rex64"
    [(call (mem:QI (match_operand:DI 0 "call_insn_operand" "rsm"))
  	 (match_operand 1 "" ""))]
!   "!SIBLING_CALL_P (insn) && TARGET_64BIT"
  {
    if (constant_call_address_operand (operands[0], QImode))
      {
***************
*** 13792,13797 ****
--- 13792,13809 ----
      return "call\t%A0";
  }
    [(set_attr "type" "call")])
+ 
+ (define_insn "*sibcall_1_rtx64"
+   [(call (mem:QI (match_operand:DI 0 "sibcall_insn_operand" "s,c,d,a"))
+ 	 (match_operand 1 "" ""))]
+   "SIBLING_CALL_P (insn) && TARGET_64BIT"
+ {
+   if (constant_call_address_operand (operands[0], QImode))
+     return "jmp\t%P0";
+   return "jmp\t%A0";
+ }
+   [(set_attr "type" "call")])
+ 
  
  ;; Call subroutine, returning value in operand 0
  



More information about the Gcc-patches mailing list