* [3.4-BIB] x86-64 sibcall fixes
@ 2002-10-15 10:58 Jan Hubicka
2002-10-15 12:41 ` Michael Matz
` (2 more replies)
0 siblings, 3 replies; 24+ messages in thread
From: Jan Hubicka @ 2002-10-15 10:58 UTC (permalink / raw)
To: gcc-patches, rth
Hi,
this patch fix two problems I found while looking into the sibcall
code on x86-64. Otherwise it seems to do the sibcalls
What else is missing?
Honza
Tue Oct 15 19:55:00 CEST 2002 Jan Hubicka <jh@suse.cz>
* i386.h (FUNCTION_OK_FOR_SIBCALL): Allow sibcalls in 64bit PIC.
(override_options): Disable MASK_FLOAT_RETURNS for 64bit ABI.
*** i386.h Mon Oct 14 12:07:58 2002
--- /abuild/jh/egcs1/gcc/config/i386/i386.h Tue Oct 15 18:25:28 2002
*************** typedef struct ix86_args {
*** 1686,1692 ****
instruction will wind up after the sibcall jump, and not be executed.) */
#define FUNCTION_OK_FOR_SIBCALL(DECL) \
((DECL) \
! && (! flag_pic || ! TREE_PUBLIC (DECL)) \
&& (! TARGET_FLOAT_RETURNS_IN_80387 \
|| ! FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (TREE_TYPE (DECL)))) \
|| FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (TREE_TYPE (cfun->decl))))))
--- 1686,1692 ----
instruction will wind up after the sibcall jump, and not be executed.) */
#define FUNCTION_OK_FOR_SIBCALL(DECL) \
((DECL) \
! && (TARGET_64BIT || ! flag_pic || ! TREE_PUBLIC (DECL)) \
&& (! TARGET_FLOAT_RETURNS_IN_80387 \
|| ! FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (TREE_TYPE (DECL)))) \
|| FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (TREE_TYPE (cfun->decl))))))
*** i386.c Tue Oct 15 10:24:34 2002
--- /abuild/jh/egcs1/gcc/config/i386/i386.c Tue Oct 15 18:26:31 2002
*************** override_options ()
*** 1226,1231 ****
--- 1226,1233 ----
error ("-mrtd calling convention not supported in the 64bit mode");
/* Enable by default the SSE and MMX builtins. */
target_flags |= (MASK_SSE2 | MASK_SSE | MASK_MMX | MASK_128BIT_LONG_DOUBLE);
+ /* We always return floats in SSE, not 80387. */
+ target_flags &= MASK_FLOAT_RETURNS;
ix86_fpmath = FPMATH_SSE;
}
else
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [3.4-BIB] x86-64 sibcall fixes
2002-10-15 10:58 [3.4-BIB] x86-64 sibcall fixes Jan Hubicka
@ 2002-10-15 12:41 ` Michael Matz
2002-10-15 12:44 ` Jan Hubicka
2002-10-15 13:45 ` Richard Henderson
2002-10-20 19:54 ` Andreas Bauer
2 siblings, 1 reply; 24+ messages in thread
From: Michael Matz @ 2002-10-15 12:41 UTC (permalink / raw)
To: Jan Hubicka; +Cc: gcc-patches, rth
Hi,
On Tue, 15 Oct 2002, Jan Hubicka wrote:
> *** i386.c Tue Oct 15 10:24:34 2002
> --- /abuild/jh/egcs1/gcc/config/i386/i386.c Tue Oct 15 18:26:31 2002
> *************** override_options ()
> *** 1226,1231 ****
> --- 1226,1233 ----
> error ("-mrtd calling convention not supported in the 64bit mode");
> /* Enable by default the SSE and MMX builtins. */
> target_flags |= (MASK_SSE2 | MASK_SSE | MASK_MMX | MASK_128BIT_LONG_DOUBLE);
> + /* We always return floats in SSE, not 80387. */
> + target_flags &= MASK_FLOAT_RETURNS;
I think you meant "target_flags &= ~MASK_FLOAT_RETURNS;" Note the
complement.
Ciao,
Michael.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [3.4-BIB] x86-64 sibcall fixes
2002-10-15 12:41 ` Michael Matz
@ 2002-10-15 12:44 ` Jan Hubicka
0 siblings, 0 replies; 24+ messages in thread
From: Jan Hubicka @ 2002-10-15 12:44 UTC (permalink / raw)
To: Michael Matz; +Cc: Jan Hubicka, gcc-patches, rth
> Hi,
>
> On Tue, 15 Oct 2002, Jan Hubicka wrote:
>
> > *** i386.c Tue Oct 15 10:24:34 2002
> > --- /abuild/jh/egcs1/gcc/config/i386/i386.c Tue Oct 15 18:26:31 2002
> > *************** override_options ()
> > *** 1226,1231 ****
> > --- 1226,1233 ----
> > error ("-mrtd calling convention not supported in the 64bit mode");
> > /* Enable by default the SSE and MMX builtins. */
> > target_flags |= (MASK_SSE2 | MASK_SSE | MASK_MMX | MASK_128BIT_LONG_DOUBLE);
> > + /* We always return floats in SSE, not 80387. */
> > + target_flags &= MASK_FLOAT_RETURNS;
>
> I think you meant "target_flags &= ~MASK_FLOAT_RETURNS;" Note the
> complement.
Uugh, yes. Must get lost when creating the patch, as compiler won't
work otherwise ;(
Honza
>
>
> Ciao,
> Michael.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [3.4-BIB] x86-64 sibcall fixes
2002-10-15 10:58 [3.4-BIB] x86-64 sibcall fixes Jan Hubicka
2002-10-15 12:41 ` Michael Matz
@ 2002-10-15 13:45 ` Richard Henderson
2002-10-27 11:32 ` Jan Hubicka
2002-10-20 19:54 ` Andreas Bauer
2 siblings, 1 reply; 24+ messages in thread
From: Richard Henderson @ 2002-10-15 13:45 UTC (permalink / raw)
To: Jan Hubicka; +Cc: gcc-patches
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.
r~
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [3.4-BIB] x86-64 sibcall fixes
2002-10-15 10:58 [3.4-BIB] x86-64 sibcall fixes Jan Hubicka
2002-10-15 12:41 ` Michael Matz
2002-10-15 13:45 ` Richard Henderson
@ 2002-10-20 19:54 ` Andreas Bauer
2 siblings, 0 replies; 24+ messages in thread
From: Andreas Bauer @ 2002-10-20 19:54 UTC (permalink / raw)
To: Jan Hubicka; +Cc: gcc-patches, rth
On Tue, Oct 15, 2002 at 07:58:07PM +0200, Jan Hubicka wrote:
> this patch fix two problems I found while looking into the sibcall
> code on x86-64. Otherwise it seems to do the sibcalls
> What else is missing?
Note, on 3.4 BIB, the macro FUNCTION_OK_FOR_SIBCALL is no longer in
effect. We now have
#define TARGET_FUNCTION_OK_FOR_SIBCALL ARCH_function_ok_for_sibcall
Where ARCH is the target platform.
Cheers,
Andi.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [3.4-BIB] x86-64 sibcall fixes
2002-10-15 13:45 ` Richard Henderson
@ 2002-10-27 11:32 ` Jan Hubicka
2002-10-27 12:59 ` Jan Hubicka
2002-10-29 5:43 ` [3.4-BIB] x86-64 sibcall fixes Richard Henderson
0 siblings, 2 replies; 24+ messages in thread
From: Jan Hubicka @ 2002-10-27 11:32 UTC (permalink / raw)
To: Richard Henderson, Jan Hubicka, gcc-patches
> 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
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [3.4-BIB] x86-64 sibcall fixes
2002-10-27 11:32 ` Jan Hubicka
@ 2002-10-27 12:59 ` Jan Hubicka
2002-10-27 13:16 ` [3.4-BIB] x86-64 sibcall fixes try III Jan Hubicka
2002-10-29 5:43 ` [3.4-BIB] x86-64 sibcall fixes Richard Henderson
1 sibling, 1 reply; 24+ messages in thread
From: Jan Hubicka @ 2002-10-27 12:59 UTC (permalink / raw)
To: Jan Hubicka; +Cc: Richard Henderson, gcc-patches
> > 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
Uhh,
please ignore this patch, it fails for indirect call with 6 registers.
I am testing another version with class for volatile registers added so
we can use r10.
^ permalink raw reply [flat|nested] 24+ messages in thread
* [3.4-BIB] x86-64 sibcall fixes try III
2002-10-27 12:59 ` Jan Hubicka
@ 2002-10-27 13:16 ` Jan Hubicka
2002-10-27 13:44 ` Jakub Jelinek
` (2 more replies)
0 siblings, 3 replies; 24+ messages in thread
From: Jan Hubicka @ 2002-10-27 13:16 UTC (permalink / raw)
To: Jan Hubicka; +Cc: Richard Henderson, gcc-patches
Hi,
this version should work in the corner cases too.
Bootstrapped/regtested x86-64, i386 bootstrap just started. OK if it
passes? (for BIB)
Honza
Sun Oct 27 22:09:55 CET 2002 Jan Hubicka <jh@suse.cz>
* i386.c (ix86_function_ok_for_sibcall): Handle 64bit
* i386.h (enum reg_class, REG_CLASS_NAMES, REG_CLASS_CONTENTS,
REG_CLASS_FROM_LETTER): Add VOLATILE_REGS and VOLATILE64_REGS.
* i386.md (sibcall_1): Simplify constraints.
(call_1_rex64): Do not handle sibcalls.
(sibcall_1_rex64, sibcall_value_1, sibcall_value_1_rex64): New.
* md.texi (i386 constraints): Document 'v'.
Index: config/i386/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
*** config/i386/i386.c 23 Oct 2002 15:48:29 -0000 1.446.2.2
--- config/i386/i386.c 27 Oct 2002 21:08:34 -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,1399 ----
tree decl;
tree exp;
{
/* 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 (!TARGET_64BIT && 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 (STACK_REG_P (ix86_function_value (TREE_TYPE (exp)))
! && ! STACK_REG_P (ix86_function_value (TREE_TYPE (DECL_RESULT (cfun->decl)))))
return false;
/* If this call is indirect, we'll need to be able to use a call-clobbered
Index: config/i386/i386.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.h,v
retrieving revision 1.280.2.2
diff -c -3 -p -r1.280.2.2 i386.h
*** config/i386/i386.h 23 Oct 2002 15:48:30 -0000 1.280.2.2
--- config/i386/i386.h 27 Oct 2002 21:08:36 -0000
*************** enum reg_class
*** 1203,1208 ****
--- 1203,1210 ----
AD_REGS, /* %eax/%edx for DImode */
Q_REGS, /* %eax %ebx %ecx %edx */
NON_Q_REGS, /* %esi %edi %ebp %esp */
+ VOLATILE_REGS, /* Call used registers in 32bit mode. */
+ VOLATILE64_REGS, /* Call used registers in 64bit mode. */
INDEX_REGS, /* %eax %ebx %ecx %edx %esi %edi %ebp */
LEGACY_REGS, /* %eax %ebx %ecx %edx %esi %edi %ebp %esp */
GENERAL_REGS, /* %eax %ebx %ecx %edx %esi %edi %ebp %esp %r8 - %r15*/
*************** enum reg_class
*** 1249,1254 ****
--- 1251,1258 ----
"SIREG", "DIREG", \
"AD_REGS", \
"Q_REGS", "NON_Q_REGS", \
+ "VOLATILE_REGS", \
+ "VOLATILE64_REGS", \
"INDEX_REGS", \
"LEGACY_REGS", \
"GENERAL_REGS", \
*************** enum reg_class
*** 1276,1281 ****
--- 1280,1287 ----
{ 0x03, 0x0 }, /* AD_REGS */ \
{ 0x0f, 0x0 }, /* Q_REGS */ \
{ 0x1100f0, 0x1fe0 }, /* NON_Q_REGS */ \
+ { 0x07, 0x0 }, /* VOLATILE_REGS */ \
+ { 0x37, 0x360 }, /* VOLATILE64_REGS */ \
{ 0x7f, 0x1fe0 }, /* INDEX_REGS */ \
{ 0x1100ff, 0x0 }, /* LEGACY_REGS */ \
{ 0x1100ff, 0x1fe0 }, /* GENERAL_REGS */ \
*************** enum reg_class
*** 1386,1391 ****
--- 1392,1398 ----
(C) == 'x' ? TARGET_SSE ? SSE_REGS : NO_REGS : \
(C) == 'Y' ? TARGET_SSE2? SSE_REGS : NO_REGS : \
(C) == 'y' ? TARGET_MMX ? MMX_REGS : NO_REGS : \
+ (C) == 'v' ? TARGET_64BIT ? VOLATILE64_REGS : VOLATILE_REGS :\
(C) == 'A' ? AD_REGS : \
(C) == 'D' ? DIREG : \
(C) == 'S' ? SIREG : NO_REGS)
Index: config/i386/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
*** config/i386/i386.md 23 Oct 2002 20:57:40 -0000 1.380.2.3
--- config/i386/i386.md 27 Oct 2002 21:08:42 -0000
***************
*** 13764,13770 ****
[(set_attr "type" "call")])
(define_insn "*sibcall_1"
! [(call (mem:QI (match_operand:SI 0 "sibcall_insn_operand" "s,c,d,a"))
(match_operand 1 "" ""))]
"SIBLING_CALL_P (insn) && !TARGET_64BIT"
{
--- 13764,13770 ----
[(set_attr "type" "call")])
(define_insn "*sibcall_1"
! [(call (mem:QI (match_operand:SI 0 "sibcall_insn_operand" "sv"))
(match_operand 1 "" ""))]
"SIBLING_CALL_P (insn) && !TARGET_64BIT"
{
***************
*** 13777,13798 ****
(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))
! {
! if (SIBLING_CALL_P (insn))
! return "jmp\t%P0";
! else
! return "call\t%P0";
! }
! if (SIBLING_CALL_P (insn))
! return "jmp\t%A0";
! else
! return "call\t%A0";
}
[(set_attr "type" "call")])
;; Call subroutine, returning value in operand 0
(define_expand "call_value_pop"
--- 13777,13801 ----
(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))
! return "call\t%P0";
! return "call\t%A0";
! }
! [(set_attr "type" "call")])
!
! (define_insn "*sibcall_1_rex64"
! [(call (mem:QI (match_operand:DI 0 "sibcall_insn_operand" "sv"))
! (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
(define_expand "call_value_pop"
***************
*** 18078,18084 ****
(define_insn "*sibcall_value_1"
[(set (match_operand 0 "" "")
! (call (mem:QI (match_operand:SI 1 "sibcall_insn_operand" "s,c,d,a"))
(match_operand:SI 2 "" "")))]
"SIBLING_CALL_P (insn) && !TARGET_64BIT"
{
--- 18082,18088 ----
(define_insn "*sibcall_value_1"
[(set (match_operand 0 "" "")
! (call (mem:QI (match_operand:SI 1 "sibcall_insn_operand" "sv"))
(match_operand:SI 2 "" "")))]
"SIBLING_CALL_P (insn) && !TARGET_64BIT"
{
***************
*** 18092,18110 ****
[(set (match_operand 0 "" "")
(call (mem:QI (match_operand:DI 1 "call_insn_operand" "rsm"))
(match_operand:DI 2 "" "")))]
! "TARGET_64BIT"
{
if (constant_call_address_operand (operands[1], QImode))
! {
! if (SIBLING_CALL_P (insn))
! return "jmp\t%P1";
! else
! return "call\t%P1";
! }
! if (SIBLING_CALL_P (insn))
! return "jmp\t%A1";
! else
! return "call\t%A1";
}
[(set_attr "type" "callv")])
\f
--- 18096,18118 ----
[(set (match_operand 0 "" "")
(call (mem:QI (match_operand:DI 1 "call_insn_operand" "rsm"))
(match_operand:DI 2 "" "")))]
! "!SIBLING_CALL_P (insn) && TARGET_64BIT"
{
if (constant_call_address_operand (operands[1], QImode))
! return "call\t%P1";
! return "call\t%A1";
! }
! [(set_attr "type" "callv")])
!
! (define_insn "*sibcall_value_1_rex64"
! [(set (match_operand 0 "" "")
! (call (mem:QI (match_operand:DI 1 "call_insn_operand" "sv"))
! (match_operand:DI 2 "" "")))]
! "SIBLING_CALL_P (insn) && TARGET_64BIT"
! {
! if (constant_call_address_operand (operands[1], QImode))
! return "jmp\t%P1";
! return "jmp\t%A1";
}
[(set_attr "type" "callv")])
\f
Index: doc/md.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/md.texi,v
retrieving revision 1.46.2.1
diff -c -3 -p -r1.46.2.1 md.texi
*** doc/md.texi 16 Oct 2002 16:08:36 -0000 1.46.2.1
--- doc/md.texi 27 Oct 2002 21:08:44 -0000
*************** Integer constant in the range 1 to 4 for
*** 1742,1747 ****
--- 1742,1751 ----
@item S
Memory operand except postincrement and postdecrement
+
+ @item v
+ Call used (volatile) register
+
@end table
@item IP2K---@file{ip2k.h}
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [3.4-BIB] x86-64 sibcall fixes try III
2002-10-27 13:16 ` [3.4-BIB] x86-64 sibcall fixes try III Jan Hubicka
@ 2002-10-27 13:44 ` Jakub Jelinek
2002-10-27 13:57 ` Jan Hubicka
2002-10-27 14:46 ` Andreas Bauer
2002-10-27 17:41 ` Fergus Henderson
2 siblings, 1 reply; 24+ messages in thread
From: Jakub Jelinek @ 2002-10-27 13:44 UTC (permalink / raw)
To: Jan Hubicka; +Cc: Richard Henderson, gcc-patches
On Sun, Oct 27, 2002 at 10:16:24PM +0100, Jan Hubicka wrote:
> Hi,
> this version should work in the corner cases too.
> Bootstrapped/regtested x86-64, i386 bootstrap just started. OK if it
> passes? (for BIB)
Is indirect sibcall with 6+ regs common enough to justify adding two
more register classes on IA-32?
Last time I checked already the current huge number of IA-32 reg classes
is a compile performance problem which would go even worse by this patch.
Jakub
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [3.4-BIB] x86-64 sibcall fixes try III
2002-10-27 13:44 ` Jakub Jelinek
@ 2002-10-27 13:57 ` Jan Hubicka
2002-10-29 5:43 ` Richard Henderson
0 siblings, 1 reply; 24+ messages in thread
From: Jan Hubicka @ 2002-10-27 13:57 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Jan Hubicka, Richard Henderson, gcc-patches
> On Sun, Oct 27, 2002 at 10:16:24PM +0100, Jan Hubicka wrote:
> > Hi,
> > this version should work in the corner cases too.
> > Bootstrapped/regtested x86-64, i386 bootstrap just started. OK if it
> > passes? (for BIB)
>
> Is indirect sibcall with 6+ regs common enough to justify adding two
> more register classes on IA-32?
Well, I was thinking about the same (compile time performance).
I believe we need it to compile well any indirect sibcall (as otherwise
register allocator just won't be able to make union for register class).
I checked that with current code it always choose class 'A' that don't
work for regparm i386 operands and always results in reload. For X86-64
same problem has been happening, just the reload happent more commonly.
I also believe that this class can be usefull in other cases too (i've
run into need for such class in asm statements)
Also if we don't do this path, we need to disable sibcalls for functions
with 6+ integer operands that is bit dificult to check.
We can eigther work around the class as i've mentioned, or use just one
class (and make 'v' NO_REGS for i386) if this is not acceptable.
Honza
> Last time I checked already the current huge number of IA-32 reg classes
> is a compile performance problem which would go even worse by this patch.
>
> Jakub
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [3.4-BIB] x86-64 sibcall fixes try III
2002-10-27 13:16 ` [3.4-BIB] x86-64 sibcall fixes try III Jan Hubicka
2002-10-27 13:44 ` Jakub Jelinek
@ 2002-10-27 14:46 ` Andreas Bauer
2002-10-27 17:41 ` Fergus Henderson
2 siblings, 0 replies; 24+ messages in thread
From: Andreas Bauer @ 2002-10-27 14:46 UTC (permalink / raw)
To: Jan Hubicka; +Cc: Richard Henderson, gcc-patches
> * i386.md (sibcall_1): Simplify constraints.
> (call_1_rex64): Do not handle sibcalls.
> (sibcall_1_rex64, sibcall_value_1, sibcall_value_1_rex64): New.
I think the above should be:
* i386.md (sibcall_1): Simplify constraints.
(sibcall_value_1): Simply constraints.
(call_1_rex64): Do not handle sibcalls.
(sibcall_1_rex64, sibcall_value_1_rex64): New.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [3.4-BIB] x86-64 sibcall fixes try III
2002-10-27 13:16 ` [3.4-BIB] x86-64 sibcall fixes try III Jan Hubicka
2002-10-27 13:44 ` Jakub Jelinek
2002-10-27 14:46 ` Andreas Bauer
@ 2002-10-27 17:41 ` Fergus Henderson
2002-10-28 2:51 ` Jan Hubicka
2002-10-28 2:53 ` Michael Matz
2 siblings, 2 replies; 24+ messages in thread
From: Fergus Henderson @ 2002-10-27 17:41 UTC (permalink / raw)
To: Jan Hubicka; +Cc: gcc-patches
On 27-Oct-2002, Jan Hubicka <jh@suse.cz> wrote:
> + VOLATILE_REGS, /* Call used registers in 32bit mode. */
> + VOLATILE64_REGS, /* Call used registers in 64bit mode. */
IMHO it would be much nicer to name those CALL_USED_REGS and CALL_USED_64_REGS.
This meaning of "volatile" is quite different from the other meaning for
volatile used in the C/C++ front-ends and through-out the compiler,
and if the same term is used to mean different things in different places
then it gets very confusing.
> *** doc/md.texi 16 Oct 2002 16:08:36 -0000 1.46.2.1
> --- doc/md.texi 27 Oct 2002 21:08:44 -0000
> *************** Integer constant in the range 1 to 4 for
> *** 1742,1747 ****
> --- 1742,1751 ----
>
> @item S
> Memory operand except postincrement and postdecrement
> +
> + @item v
> + Call used (volatile) register
I suggest
Call used (i.e. caller-save) register
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [3.4-BIB] x86-64 sibcall fixes try III
2002-10-27 17:41 ` Fergus Henderson
@ 2002-10-28 2:51 ` Jan Hubicka
2002-10-28 2:53 ` Michael Matz
1 sibling, 0 replies; 24+ messages in thread
From: Jan Hubicka @ 2002-10-28 2:51 UTC (permalink / raw)
To: Fergus Henderson; +Cc: Jan Hubicka, gcc-patches
> On 27-Oct-2002, Jan Hubicka <jh@suse.cz> wrote:
> > + VOLATILE_REGS, /* Call used registers in 32bit mode. */
> > + VOLATILE64_REGS, /* Call used registers in 64bit mode. */
>
> IMHO it would be much nicer to name those CALL_USED_REGS and CALL_USED_64_REGS.
> This meaning of "volatile" is quite different from the other meaning for
> volatile used in the C/C++ front-ends and through-out the compiler,
> and if the same term is used to mean different things in different places
> then it gets very confusing.
OK, I can rename these if the patch in concept is OK.
Honza
>
> > *** doc/md.texi 16 Oct 2002 16:08:36 -0000 1.46.2.1
> > --- doc/md.texi 27 Oct 2002 21:08:44 -0000
> > *************** Integer constant in the range 1 to 4 for
> > *** 1742,1747 ****
> > --- 1742,1751 ----
> >
> > @item S
> > Memory operand except postincrement and postdecrement
> > +
> > + @item v
> > + Call used (volatile) register
>
> I suggest
>
> Call used (i.e. caller-save) register
>
> --
> Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
> The University of Melbourne | of excellence is a lethal habit"
> WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [3.4-BIB] x86-64 sibcall fixes try III
2002-10-27 17:41 ` Fergus Henderson
2002-10-28 2:51 ` Jan Hubicka
@ 2002-10-28 2:53 ` Michael Matz
2002-10-28 2:57 ` Jan Hubicka
1 sibling, 1 reply; 24+ messages in thread
From: Michael Matz @ 2002-10-28 2:53 UTC (permalink / raw)
To: Fergus Henderson; +Cc: Jan Hubicka, gcc-patches
Hi,
On Mon, 28 Oct 2002, Fergus Henderson wrote:
> On 27-Oct-2002, Jan Hubicka <jh@suse.cz> wrote:
> > + VOLATILE_REGS, /* Call used registers in 32bit mode. */
> > + VOLATILE64_REGS, /* Call used registers in 64bit mode. */
>
> IMHO it would be much nicer to name those CALL_USED_REGS and
> CALL_USED_64_REGS.
I would even suggest CALL_CLOBBERED... The term call-used is misleading,
it only can be justified with gcc's history of having it named such since
ages (and wrongly so IMO). The term "use" doesn't indicate at all that
all those registers can be changed after a call.
Besides from that, I also don't exactly like the addition of more register
classes.
> This meaning of "volatile" is quite different from
> the other meaning for volatile used in the C/C++ front-ends and
> through-out the compiler, and if the same term is used to mean
> different things in different places then it gets very confusing.
Ciao,
Michael.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [3.4-BIB] x86-64 sibcall fixes try III
2002-10-28 2:53 ` Michael Matz
@ 2002-10-28 2:57 ` Jan Hubicka
2002-10-28 3:13 ` Michael Matz
0 siblings, 1 reply; 24+ messages in thread
From: Jan Hubicka @ 2002-10-28 2:57 UTC (permalink / raw)
To: Michael Matz; +Cc: Fergus Henderson, Jan Hubicka, gcc-patches
> Hi,
>
> On Mon, 28 Oct 2002, Fergus Henderson wrote:
>
> > On 27-Oct-2002, Jan Hubicka <jh@suse.cz> wrote:
> > > + VOLATILE_REGS, /* Call used registers in 32bit mode. */
> > > + VOLATILE64_REGS, /* Call used registers in 64bit mode. */
> >
> > IMHO it would be much nicer to name those CALL_USED_REGS and
> > CALL_USED_64_REGS.
>
> I would even suggest CALL_CLOBBERED... The term call-used is misleading,
> it only can be justified with gcc's history of having it named such since
> ages (and wrongly so IMO). The term "use" doesn't indicate at all that
> all those registers can be changed after a call.
>
> Besides from that, I also don't exactly like the addition of more register
> classes.
Any idea for good sollution without them?
One I got today is to simply encode hard register for this (ie always
use r11). Also not perfect.
Honza
>
> > This meaning of "volatile" is quite different from
> > the other meaning for volatile used in the C/C++ front-ends and
> > through-out the compiler, and if the same term is used to mean
> > different things in different places then it gets very confusing.
>
>
> Ciao,
> Michael.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [3.4-BIB] x86-64 sibcall fixes try III
2002-10-28 2:57 ` Jan Hubicka
@ 2002-10-28 3:13 ` Michael Matz
2002-10-28 4:25 ` Jan Hubicka
0 siblings, 1 reply; 24+ messages in thread
From: Michael Matz @ 2002-10-28 3:13 UTC (permalink / raw)
To: Jan Hubicka; +Cc: Fergus Henderson, gcc-patches
Hi,
On Mon, 28 Oct 2002, Jan Hubicka wrote:
> > >
> > > IMHO it would be much nicer to name those CALL_USED_REGS and
> > > CALL_USED_64_REGS.
> >
> > I would even suggest CALL_CLOBBERED... The term call-used is misleading,
> > it only can be justified with gcc's history of having it named such since
> > ages (and wrongly so IMO). The term "use" doesn't indicate at all that
> > all those registers can be changed after a call.
> >
> > Besides from that, I also don't exactly like the addition of more register
> > classes.
>
> Any idea for good sollution without them?
Unfortunately no ;-( You could prohibit sibcalls with too many arguments,
but that's not necessarily a good solution ;)
> One I got today is to simply encode hard register for this (ie always
> use r11). Also not perfect.
What would this affect? Only sibcall with many arguments? If yes, then
this would be a better solution IMHO.
Ciao,
Michael.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [3.4-BIB] x86-64 sibcall fixes try III
2002-10-28 3:13 ` Michael Matz
@ 2002-10-28 4:25 ` Jan Hubicka
2002-10-28 6:26 ` [3.4-BIB] x86-64 sibcall fixes try IV Jan Hubicka
0 siblings, 1 reply; 24+ messages in thread
From: Jan Hubicka @ 2002-10-28 4:25 UTC (permalink / raw)
To: Michael Matz; +Cc: Jan Hubicka, Fergus Henderson, gcc-patches
> Hi,
>
> On Mon, 28 Oct 2002, Jan Hubicka wrote:
>
> > > >
> > > > IMHO it would be much nicer to name those CALL_USED_REGS and
> > > > CALL_USED_64_REGS.
> > >
> > > I would even suggest CALL_CLOBBERED... The term call-used is misleading,
> > > it only can be justified with gcc's history of having it named such since
> > > ages (and wrongly so IMO). The term "use" doesn't indicate at all that
> > > all those registers can be changed after a call.
> > >
> > > Besides from that, I also don't exactly like the addition of more register
> > > classes.
> >
> > Any idea for good sollution without them?
>
> Unfortunately no ;-( You could prohibit sibcalls with too many arguments,
> but that's not necessarily a good solution ;)
We produce poor code for any sibcall to function with arguments passed
in registers.
>
> > One I got today is to simply encode hard register for this (ie always
> > use r11). Also not perfect.
>
> What would this affect? Only sibcall with many arguments? If yes, then
> this would be a better solution IMHO.
With current classes we don't generate good code for sibcalls with any
number of arguments, just because we get extra move.
I guess this should avoid all moves and regallocate the value into r11
should not be big deal given the fact that just before sibcall there is
not much to keep in registers.
I will benchmark the cost of extra class first.
Honza
>
>
> Ciao,
> Michael.
^ permalink raw reply [flat|nested] 24+ messages in thread
* [3.4-BIB] x86-64 sibcall fixes try IV
2002-10-28 4:25 ` Jan Hubicka
@ 2002-10-28 6:26 ` Jan Hubicka
2002-10-28 19:32 ` Fergus Henderson
2002-10-29 7:51 ` Richard Henderson
0 siblings, 2 replies; 24+ messages in thread
From: Jan Hubicka @ 2002-10-28 6:26 UTC (permalink / raw)
To: Jan Hubicka; +Cc: Michael Matz, Fergus Henderson, gcc-patches
Hi,
this version works around the regalloc defect by using hard register. It seems
to result in similar code except the fact that sometimes r11 is used for no
reason (rax would fit the role saving 2 bytes), but it is quite corner case.
Honza
Mon Oct 28 15:11:30 CET 2002 Jan Hubicka <jh@suse.cz>
* i386-protos.h (ix86_expand_call): Update prototype.
* i386.c (ix86_function_ok_for_sibcall): Handle 64bit
(ix86_expand_call): Use r11 for indirect sibcalls.
* i386.md (call, call_value, untyped_call, call_value_pop):
update x86_expand_call call.
(sibcall, sibcall_value): new patterns
(call_rex64, call_value_rex64): Do not accept sibcalls.
(sibcall_rex64, sibcall_value_rex64,
sibcall_rex64_v, sibcall_value_rex64_v): New.
Index: i386-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386-protos.h,v
retrieving revision 1.77.2.2
diff -c -3 -p -r1.77.2.2 i386-protos.h
*** i386-protos.h 23 Oct 2002 15:48:29 -0000 1.77.2.2
--- i386-protos.h 28 Oct 2002 14:10:42 -0000
*************** extern void ix86_expand_branch PARAMS ((
*** 138,144 ****
extern int ix86_expand_setcc PARAMS ((enum rtx_code, rtx));
extern int ix86_expand_int_movcc PARAMS ((rtx[]));
extern int ix86_expand_fp_movcc PARAMS ((rtx[]));
! extern void ix86_expand_call PARAMS ((rtx, rtx, rtx, rtx, rtx));
extern void x86_initialize_trampoline PARAMS ((rtx, rtx, rtx));
extern rtx ix86_zero_extend_to_Pmode PARAMS ((rtx));
extern void ix86_split_long_move PARAMS ((rtx[]));
--- 138,144 ----
extern int ix86_expand_setcc PARAMS ((enum rtx_code, rtx));
extern int ix86_expand_int_movcc PARAMS ((rtx[]));
extern int ix86_expand_fp_movcc PARAMS ((rtx[]));
! extern void ix86_expand_call PARAMS ((rtx, rtx, rtx, rtx, rtx, int));
extern void x86_initialize_trampoline PARAMS ((rtx, rtx, rtx));
extern rtx ix86_zero_extend_to_Pmode PARAMS ((rtx));
extern void ix86_split_long_move PARAMS ((rtx[]));
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 28 Oct 2002 14:10:44 -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,1399 ----
tree decl;
tree exp;
{
/* 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 (!TARGET_64BIT && 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 (STACK_REG_P (ix86_function_value (TREE_TYPE (exp)))
! && ! STACK_REG_P (ix86_function_value (TREE_TYPE (DECL_RESULT (cfun->decl)))))
return false;
/* If this call is indirect, we'll need to be able to use a call-clobbered
*************** ix86_expand_vector_move (mode, operands)
*** 7799,7812 ****
if ((reload_in_progress | reload_completed) == 0
&& register_operand (operands[0], mode)
&& CONSTANT_P (operands[1]))
! {
! rtx addr = gen_reg_rtx (Pmode);
! emit_move_insn (addr, XEXP (force_const_mem (mode, operands[1]), 0));
! operands[1] = gen_rtx_MEM (mode, addr);
! }
/* Make operand1 a register if it isn't already. */
! if ((reload_in_progress | reload_completed) == 0
&& !register_operand (operands[0], mode)
&& !register_operand (operands[1], mode))
{
--- 7794,7803 ----
if ((reload_in_progress | reload_completed) == 0
&& register_operand (operands[0], mode)
&& CONSTANT_P (operands[1]))
! operands[1] = force_const_mem (mode, operands[1]);
/* Make operand1 a register if it isn't already. */
! if (!no_new_pseudos
&& !register_operand (operands[0], mode)
&& !register_operand (operands[1], mode))
{
*************** ix86_expand_strlensi_unroll_1 (out, alig
*** 10837,10844 ****
}
void
! ix86_expand_call (retval, fnaddr, callarg1, callarg2, pop)
rtx retval, fnaddr, callarg1, callarg2, pop;
{
rtx use = NULL, call;
--- 10828,10836 ----
}
void
! ix86_expand_call (retval, fnaddr, callarg1, callarg2, pop, sibcall)
rtx retval, fnaddr, callarg1, callarg2, pop;
+ int sibcall;
{
rtx use = NULL, call;
*************** ix86_expand_call (retval, fnaddr, callar
*** 10868,10873 ****
--- 10860,10874 ----
if (! call_insn_operand (XEXP (fnaddr, 0), Pmode))
{
fnaddr = copy_to_mode_reg (Pmode, XEXP (fnaddr, 0));
+ fnaddr = gen_rtx_MEM (QImode, fnaddr);
+ }
+ if (sibcall && TARGET_64BIT
+ && !constant_call_address_operand (XEXP (fnaddr, 0), Pmode))
+ {
+ rtx addr;
+ addr = copy_to_mode_reg (Pmode, XEXP (fnaddr, 0));
+ fnaddr = gen_rtx_REG (Pmode, 40);
+ emit_move_insn (fnaddr, addr);
fnaddr = gen_rtx_MEM (QImode, fnaddr);
}
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 28 Oct 2002 14:10:49 -0000
***************
*** 13691,13697 ****
(match_operand:SI 3 "" "")))])]
"!TARGET_64BIT"
{
! ix86_expand_call (NULL, operands[0], operands[1], operands[2], operands[3]);
DONE;
})
--- 13691,13697 ----
(match_operand:SI 3 "" "")))])]
"!TARGET_64BIT"
{
! ix86_expand_call (NULL, operands[0], operands[1], operands[2], operands[3], 0);
DONE;
})
***************
*** 13736,13742 ****
(use (match_operand 2 "" ""))]
""
{
! ix86_expand_call (NULL, operands[0], operands[1], operands[2], NULL);
DONE;
})
--- 13736,13752 ----
(use (match_operand 2 "" ""))]
""
{
! ix86_expand_call (NULL, operands[0], operands[1], operands[2], NULL, 0);
! DONE;
! })
!
! (define_expand "sibcall"
! [(call (match_operand:QI 0 "" "")
! (match_operand 1 "" ""))
! (use (match_operand 2 "" ""))]
! ""
! {
! ix86_expand_call (NULL, operands[0], operands[1], operands[2], NULL, 1);
DONE;
})
***************
*** 13777,13798 ****
(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))
! {
! if (SIBLING_CALL_P (insn))
! return "jmp\t%P0";
! else
! return "call\t%P0";
! }
! if (SIBLING_CALL_P (insn))
! return "jmp\t%A0";
! else
! return "call\t%A0";
}
[(set_attr "type" "call")])
;; Call subroutine, returning value in operand 0
(define_expand "call_value_pop"
--- 13787,13815 ----
(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))
! return "call\t%P0";
! return "call\t%A0";
}
[(set_attr "type" "call")])
+ (define_insn "*sibcall_1_rex64"
+ [(call (mem:QI (match_operand:DI 0 "constant_call_address_operand" ""))
+ (match_operand 1 "" ""))]
+ "SIBLING_CALL_P (insn) && TARGET_64BIT"
+ "jmp\t%P0"
+ [(set_attr "type" "call")])
+
+ (define_insn "*sibcall_1_rex64_v"
+ [(call (mem:QI (reg:DI 40))
+ (match_operand 0 "" ""))]
+ "SIBLING_CALL_P (insn) && TARGET_64BIT"
+ "jmp\t*%%r11"
+ [(set_attr "type" "call")])
+
+
;; Call subroutine, returning value in operand 0
(define_expand "call_value_pop"
***************
*** 13805,13811 ****
"!TARGET_64BIT"
{
ix86_expand_call (operands[0], operands[1], operands[2],
! operands[3], operands[4]);
DONE;
})
--- 13822,13828 ----
"!TARGET_64BIT"
{
ix86_expand_call (operands[0], operands[1], operands[2],
! operands[3], operands[4], 0);
DONE;
})
***************
*** 13817,13823 ****
;; Operand 2 not used on the i386.
""
{
! ix86_expand_call (operands[0], operands[1], operands[2], operands[3], NULL);
DONE;
})
--- 13834,13852 ----
;; Operand 2 not used on the i386.
""
{
! ix86_expand_call (operands[0], operands[1], operands[2], operands[3], NULL, 0);
! DONE;
! })
!
! (define_expand "sibcall_value"
! [(set (match_operand 0 "" "")
! (call (match_operand:QI 1 "" "")
! (match_operand:SI 2 "" "")))
! (use (match_operand:SI 3 "" ""))]
! ;; Operand 2 not used on the i386.
! ""
! {
! ix86_expand_call (operands[0], operands[1], operands[2], operands[3], NULL, 1);
DONE;
})
***************
*** 13840,13846 ****
ix86_expand_call ((TARGET_FLOAT_RETURNS_IN_80387
? gen_rtx_REG (XCmode, FIRST_FLOAT_REG) : NULL),
operands[0], const0_rtx, GEN_INT (SSE_REGPARM_MAX - 1),
! NULL);
for (i = 0; i < XVECLEN (operands[2], 0); i++)
{
--- 13869,13875 ----
ix86_expand_call ((TARGET_FLOAT_RETURNS_IN_80387
? gen_rtx_REG (XCmode, FIRST_FLOAT_REG) : NULL),
operands[0], const0_rtx, GEN_INT (SSE_REGPARM_MAX - 1),
! NULL, 0);
for (i = 0; i < XVECLEN (operands[2], 0); i++)
{
***************
*** 18092,18111 ****
[(set (match_operand 0 "" "")
(call (mem:QI (match_operand:DI 1 "call_insn_operand" "rsm"))
(match_operand:DI 2 "" "")))]
! "TARGET_64BIT"
{
if (constant_call_address_operand (operands[1], QImode))
! {
! if (SIBLING_CALL_P (insn))
! return "jmp\t%P1";
! else
! return "call\t%P1";
! }
! if (SIBLING_CALL_P (insn))
! return "jmp\t%A1";
! else
! return "call\t%A1";
}
[(set_attr "type" "callv")])
\f
(define_insn "trap"
--- 18121,18148 ----
[(set (match_operand 0 "" "")
(call (mem:QI (match_operand:DI 1 "call_insn_operand" "rsm"))
(match_operand:DI 2 "" "")))]
! "!SIBLING_CALL_P (insn) && TARGET_64BIT"
{
if (constant_call_address_operand (operands[1], QImode))
! return "call\t%P1";
! return "call\t%A1";
}
+ [(set_attr "type" "callv")])
+
+ (define_insn "*sibcall_value_1_rex64"
+ [(set (match_operand 0 "" "")
+ (call (mem:QI (match_operand:DI 1 "constant_call_address_operand" ""))
+ (match_operand:DI 2 "" "")))]
+ "SIBLING_CALL_P (insn) && TARGET_64BIT"
+ "jmp\t%P1"
+ [(set_attr "type" "callv")])
+
+ (define_insn "*sibcall_value_1_rex64_v"
+ [(set (match_operand 0 "" "")
+ (call (mem:QI (reg:DI 40))
+ (match_operand:DI 1 "" "")))]
+ "SIBLING_CALL_P (insn) && TARGET_64BIT"
+ "jmp\t*%%r11"
[(set_attr "type" "callv")])
\f
(define_insn "trap"
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [3.4-BIB] x86-64 sibcall fixes try IV
2002-10-28 6:26 ` [3.4-BIB] x86-64 sibcall fixes try IV Jan Hubicka
@ 2002-10-28 19:32 ` Fergus Henderson
2002-10-29 7:51 ` Richard Henderson
1 sibling, 0 replies; 24+ messages in thread
From: Fergus Henderson @ 2002-10-28 19:32 UTC (permalink / raw)
To: Jan Hubicka; +Cc: Michael Matz, gcc-patches
On 28-Oct-2002, Jan Hubicka <jh@suse.cz> wrote:
> this version works around the regalloc defect by using hard register. It seems
> to result in similar code except the fact that sometimes r11 is used for no
> reason (rax would fit the role saving 2 bytes), but it is quite corner case.
Personally I care a lot more about compilation speed on i386 than about
efficiency of sibcalls on x86-64. So I think this is a better
solution.
> Mon Oct 28 15:11:30 CET 2002 Jan Hubicka <jh@suse.cz>
> (ix86_expand_call): Use r11 for indirect sibcalls.
..
> *************** ix86_expand_call (retval, fnaddr, callar
> *** 10868,10873 ****
> --- 10860,10874 ----
> if (! call_insn_operand (XEXP (fnaddr, 0), Pmode))
> {
> fnaddr = copy_to_mode_reg (Pmode, XEXP (fnaddr, 0));
> + fnaddr = gen_rtx_MEM (QImode, fnaddr);
> + }
> + if (sibcall && TARGET_64BIT
> + && !constant_call_address_operand (XEXP (fnaddr, 0), Pmode))
> + {
> + rtx addr;
> + addr = copy_to_mode_reg (Pmode, XEXP (fnaddr, 0));
> + fnaddr = gen_rtx_REG (Pmode, 40);
> + emit_move_insn (fnaddr, addr);
> fnaddr = gen_rtx_MEM (QImode, fnaddr);
> }
>
> Index: i386.md
Please include a comment in the source code explaining what is happening
(i.e. what the hard-coded constant "40" is for) and why.
With regard to Michael Matz's comment, I agree that CALL_CLOBBERED
is a better term than CALL_USED.
(P.S. Don't mistake this post for a proper review -- I don't know RTL or
x86-64 well enough to properly review this patch.)
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [3.4-BIB] x86-64 sibcall fixes
2002-10-27 11:32 ` Jan Hubicka
2002-10-27 12:59 ` Jan Hubicka
@ 2002-10-29 5:43 ` Richard Henderson
2002-10-29 5:45 ` Jan Hubicka
1 sibling, 1 reply; 24+ messages in thread
From: Richard Henderson @ 2002-10-29 5:43 UTC (permalink / raw)
To: Jan Hubicka; +Cc: gcc-patches
On Sun, Oct 27, 2002 at 08:32:05PM +0100, Jan Hubicka wrote:
> * i386.c (ix86_function_ok_for_sibcall): handle 64bit case.
> * i386.md (call_1_rex64): Do not handle sibcall
> (sibcall_1_rex64): Handle sibcall.
Ok.
r~
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [3.4-BIB] x86-64 sibcall fixes try III
2002-10-27 13:57 ` Jan Hubicka
@ 2002-10-29 5:43 ` Richard Henderson
2002-10-29 5:48 ` Jan Hubicka
0 siblings, 1 reply; 24+ messages in thread
From: Richard Henderson @ 2002-10-29 5:43 UTC (permalink / raw)
To: Jan Hubicka; +Cc: Jakub Jelinek, gcc-patches
On Sun, Oct 27, 2002 at 10:57:01PM +0100, Jan Hubicka wrote:
> We can eigther work around the class as i've mentioned, or use just one
> class (and make 'v' NO_REGS for i386) if this is not acceptable.
First, I don't think a class is needed for x86 at all.
There's pretty much no reason _not_ to use ecx all the
time as the current class preferencing will choose.
Second, even if we did add a new register class, we don't
need two classes for 32 and 64 bit. We just need to change
the contents of the class based on the switch.
r~
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [3.4-BIB] x86-64 sibcall fixes
2002-10-29 5:43 ` [3.4-BIB] x86-64 sibcall fixes Richard Henderson
@ 2002-10-29 5:45 ` Jan Hubicka
0 siblings, 0 replies; 24+ messages in thread
From: Jan Hubicka @ 2002-10-29 5:45 UTC (permalink / raw)
To: Richard Henderson, Jan Hubicka, gcc-patches
> On Sun, Oct 27, 2002 at 08:32:05PM +0100, Jan Hubicka wrote:
> > * i386.c (ix86_function_ok_for_sibcall): handle 64bit case.
> > * i386.md (call_1_rex64): Do not handle sibcall
> > (sibcall_1_rex64): Handle sibcall.
>
> Ok.
This is the version that does not work with sibcalls having 6 arguments.
Can you please leek for "try IV" one?
That one gets around creating new class and should work in all cases.
Honza
>
>
> r~
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [3.4-BIB] x86-64 sibcall fixes try III
2002-10-29 5:43 ` Richard Henderson
@ 2002-10-29 5:48 ` Jan Hubicka
0 siblings, 0 replies; 24+ messages in thread
From: Jan Hubicka @ 2002-10-29 5:48 UTC (permalink / raw)
To: Richard Henderson, Jan Hubicka, Jakub Jelinek, gcc-patches
> On Sun, Oct 27, 2002 at 10:57:01PM +0100, Jan Hubicka wrote:
> > We can eigther work around the class as i've mentioned, or use just one
> > class (and make 'v' NO_REGS for i386) if this is not acceptable.
>
> First, I don't think a class is needed for x86 at all.
> There's pretty much no reason _not_ to use ecx all the
> time as the current class preferencing will choose.
>
> Second, even if we did add a new register class, we don't
> need two classes for 32 and 64 bit. We just need to change
> the contents of the class based on the switch.
The reg_class_content is const array. We can get around that of course.
Honza
>
>
> r~
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [3.4-BIB] x86-64 sibcall fixes try IV
2002-10-28 6:26 ` [3.4-BIB] x86-64 sibcall fixes try IV Jan Hubicka
2002-10-28 19:32 ` Fergus Henderson
@ 2002-10-29 7:51 ` Richard Henderson
1 sibling, 0 replies; 24+ messages in thread
From: Richard Henderson @ 2002-10-29 7:51 UTC (permalink / raw)
To: Jan Hubicka; +Cc: Michael Matz, Fergus Henderson, gcc-patches
On Mon, Oct 28, 2002 at 03:26:29PM +0100, Jan Hubicka wrote:
> * i386-protos.h (ix86_expand_call): Update prototype.
> * i386.c (ix86_function_ok_for_sibcall): Handle 64bit
> (ix86_expand_call): Use r11 for indirect sibcalls.
> * i386.md (call, call_value, untyped_call, call_value_pop):
> update x86_expand_call call.
> (sibcall, sibcall_value): new patterns
> (call_rex64, call_value_rex64): Do not accept sibcalls.
> (sibcall_rex64, sibcall_value_rex64,
> sibcall_rex64_v, sibcall_value_rex64_v): New.
Ok.
> *************** ix86_expand_vector_move (mode, operands)
> *** 7799,7812 ****
> if ((reload_in_progress | reload_completed) == 0
> && register_operand (operands[0], mode)
> && CONSTANT_P (operands[1]))
> ! {
> ! rtx addr = gen_reg_rtx (Pmode);
> ! emit_move_insn (addr, XEXP (force_const_mem (mode, operands[1]), 0));
> ! operands[1] = gen_rtx_MEM (mode, addr);
You've got some unrelated changes in this patch.
r~
^ permalink raw reply [flat|nested] 24+ messages in thread
end of thread, other threads:[~2002-10-29 15:51 UTC | newest]
Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-15 10:58 [3.4-BIB] x86-64 sibcall fixes Jan Hubicka
2002-10-15 12:41 ` Michael Matz
2002-10-15 12:44 ` Jan Hubicka
2002-10-15 13:45 ` Richard Henderson
2002-10-27 11:32 ` Jan Hubicka
2002-10-27 12:59 ` Jan Hubicka
2002-10-27 13:16 ` [3.4-BIB] x86-64 sibcall fixes try III Jan Hubicka
2002-10-27 13:44 ` Jakub Jelinek
2002-10-27 13:57 ` Jan Hubicka
2002-10-29 5:43 ` Richard Henderson
2002-10-29 5:48 ` Jan Hubicka
2002-10-27 14:46 ` Andreas Bauer
2002-10-27 17:41 ` Fergus Henderson
2002-10-28 2:51 ` Jan Hubicka
2002-10-28 2:53 ` Michael Matz
2002-10-28 2:57 ` Jan Hubicka
2002-10-28 3:13 ` Michael Matz
2002-10-28 4:25 ` Jan Hubicka
2002-10-28 6:26 ` [3.4-BIB] x86-64 sibcall fixes try IV Jan Hubicka
2002-10-28 19:32 ` Fergus Henderson
2002-10-29 7:51 ` Richard Henderson
2002-10-29 5:43 ` [3.4-BIB] x86-64 sibcall fixes Richard Henderson
2002-10-29 5:45 ` Jan Hubicka
2002-10-20 19:54 ` Andreas Bauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).