Commit 75d38379 by Jakub Jelinek Committed by Jakub Jelinek

i386.c (x86_64_sign_extended_value): Add allow_rip argument.

	* config/i386/i386.c (x86_64_sign_extended_value): Add allow_rip
	argument.  In CM_SMALL_PIC model consider SYMBOL_REFs binding locally or
	from constant pool or LABEL_REFs as sign extended if allow_rip.
	Change all +-1GB limits to +-16MB.
	(x86_64_general_operand, x86_64_szext_general_operand,
	x86_64_nonmemory_operand, x86_64_movabs_operand,
	x86_64_szext_nonmemory_operand, x86_64_immediate_operand,
	legitimate_address_p, ix86_expand_int_movcc): Update callers.
	(local_symbolic_operand): Don't allow offsets bigger than +-16MB
	in CM_SMALL_PIC model.
	(legitimate_pic_address_disp_p): Don't check offsets before
	calling local_symbolic_operand.
	(legitimize_pic_address): Force offsets bigger than +-16MB into
	register.
	* config/i386/i386.h (EXTRA_CONSTRAINT, CONST_COSTS): Likewise.
	* config/i386/i386-protos.h (x86_64_sign_extended_value): Update
	prototype.

	* configure.in: Test for @GOTNTPOFF and @INDNTPOFF on IA-32 too.
	Add x86-64 test.  Set tls_first_minor to 14 on IA-32 and x86-64.
	* configure: Rebuilt.
	* config/i386/i386.c (x86_64_sign_extended_value): Don't allow TLS
	SYMBOL_REFs unless enclosed in UNSPEC.  Handle UNSPEC_DTPOFF,
	UNSPEC_GOTNTPOFF and UNSPEC_NTPOFF.
	(legitimate_address_p): Allow foo@dtpoff(base) even on TARGET_64BIT
	-fpic.
	(ix86_encode_section_info): Don't ever generate TLSGD or TLSLD for
	non-pic code if TARGET_64BIT.
	(legitimize_address): Generate 64-bit TLS sequences.
	(output_pic_addr_const): Support x86-64 TLS operators.
	(i386_output_dwarf_dtprel): Output 64-bit DTPOFF as .long f@DTPOFF, 0.
	(print_operand_address): Use %fs instead of %gs on TARGET_64BIT.
	Don't append (%rip) in 64-bit TLSGD and TLSLD sequences.
	(output_addr_const_extra): Support x86-64 TLS operators.
	(maybe_get_pool_constant): Handle TARGET_64BIT -fpic.
	(ix86_tls_get_addr): Use __tls_get_addr on TARGET_64BIT
	unconditionally.
	* config/i386/i386.md (*tls_global_dynamic_gnu): Renamed to...
	(*tls_global_dynamic_32_gnu): ..., add !TARGET_64BIT.
	(*tls_global_dynamic_sun): Renamed to...
	(*tls_global_dynamic_32_sun): ..., add !TARGET_64BIT.
	(tls_global_dynamic): Renamed to...
	(tls_global_dynamic_32): ... this.
	(tls_global_dynamic_64, *tls_global_dynamic_64): New.
	(*tls_local_dynamic_base_dynamic_gnu): Renamed to...
	(*tls_local_dynamic_base_dynamic_32_gnu): ..., add !TARGET_64BIT.
	(*tls_local_dynamic_base_dynamic_sun): Renamed to...
	(*tls_local_dynamic_base_dynamic_32_sun): ..., add !TARGET_64BIT.
	(tls_local_dynamic_base_dynamic): Renamed to...
	(tls_local_dynamic_base_dynamic_32): ... this.
	(tls_local_dynamic_base_dynamic_64,
	*tls_local_dynamic_base_dynamic_64): New.
	(*tls_local_dynamic_once): Renamed to...
	(*tls_local_dynamic_32_once): ... this.

	* gcc.dg/tls/pic-1.c: New test.
	* gcc.dg/tls/nonpic-1.c: New test.
	* gcc.dg/20021018-1.c: New test.

From-SVN: r58383
parent 59798a0c
2002-10-21 Jakub Jelinek <jakub@redhat.com>
* config/i386/i386.c (x86_64_sign_extended_value): Add allow_rip
argument. In CM_SMALL_PIC model consider SYMBOL_REFs binding locally or
from constant pool or LABEL_REFs as sign extended if allow_rip.
Change all +-1GB limits to +-16MB.
(x86_64_general_operand, x86_64_szext_general_operand,
x86_64_nonmemory_operand, x86_64_movabs_operand,
x86_64_szext_nonmemory_operand, x86_64_immediate_operand,
legitimate_address_p, ix86_expand_int_movcc): Update callers.
(local_symbolic_operand): Don't allow offsets bigger than +-16MB
in CM_SMALL_PIC model.
(legitimate_pic_address_disp_p): Don't check offsets before
calling local_symbolic_operand.
(legitimize_pic_address): Force offsets bigger than +-16MB into
register.
* config/i386/i386.h (EXTRA_CONSTRAINT, CONST_COSTS): Likewise.
* config/i386/i386-protos.h (x86_64_sign_extended_value): Update
prototype.
* configure.in: Test for @GOTNTPOFF and @INDNTPOFF on IA-32 too.
Add x86-64 test. Set tls_first_minor to 14 on IA-32 and x86-64.
* configure: Rebuilt.
* config/i386/i386.c (x86_64_sign_extended_value): Don't allow TLS
SYMBOL_REFs unless enclosed in UNSPEC. Handle UNSPEC_DTPOFF,
UNSPEC_GOTNTPOFF and UNSPEC_NTPOFF.
(legitimate_address_p): Allow foo@dtpoff(base) even on TARGET_64BIT
-fpic.
(ix86_encode_section_info): Don't ever generate TLSGD or TLSLD for
non-pic code if TARGET_64BIT.
(legitimize_address): Generate 64-bit TLS sequences.
(output_pic_addr_const): Support x86-64 TLS operators.
(i386_output_dwarf_dtprel): Output 64-bit DTPOFF as .long f@DTPOFF, 0.
(print_operand_address): Use %fs instead of %gs on TARGET_64BIT.
Don't append (%rip) in 64-bit TLSGD and TLSLD sequences.
(output_addr_const_extra): Support x86-64 TLS operators.
(maybe_get_pool_constant): Handle TARGET_64BIT -fpic.
(ix86_tls_get_addr): Use __tls_get_addr on TARGET_64BIT
unconditionally.
* config/i386/i386.md (*tls_global_dynamic_gnu): Renamed to...
(*tls_global_dynamic_32_gnu): ..., add !TARGET_64BIT.
(*tls_global_dynamic_sun): Renamed to...
(*tls_global_dynamic_32_sun): ..., add !TARGET_64BIT.
(tls_global_dynamic): Renamed to...
(tls_global_dynamic_32): ... this.
(tls_global_dynamic_64, *tls_global_dynamic_64): New.
(*tls_local_dynamic_base_dynamic_gnu): Renamed to...
(*tls_local_dynamic_base_dynamic_32_gnu): ..., add !TARGET_64BIT.
(*tls_local_dynamic_base_dynamic_sun): Renamed to...
(*tls_local_dynamic_base_dynamic_32_sun): ..., add !TARGET_64BIT.
(tls_local_dynamic_base_dynamic): Renamed to...
(tls_local_dynamic_base_dynamic_32): ... this.
(tls_local_dynamic_base_dynamic_64,
*tls_local_dynamic_base_dynamic_64): New.
(*tls_local_dynamic_once): Renamed to...
(*tls_local_dynamic_32_once): ... this.
2002-10-21 Ulrich Weigand <uweigand@de.ibm.com>
* libgcc2.c: Inline __udiv_w_sdiv when compiling __udivdi3,
......
......@@ -153,7 +153,7 @@ extern int ix86_attr_length_address_default PARAMS ((rtx));
extern enum machine_mode ix86_fp_compare_mode PARAMS ((enum rtx_code));
extern int x86_64_sign_extended_value PARAMS ((rtx));
extern int x86_64_sign_extended_value PARAMS ((rtx, int));
extern int x86_64_zero_extended_value PARAMS ((rtx));
extern rtx ix86_libcall_value PARAMS ((enum machine_mode));
extern bool ix86_function_value_regno_p PARAMS ((int));
......
......@@ -1426,7 +1426,7 @@ enum reg_class
constraint, the value returned should be 0 regardless of VALUE. */
#define EXTRA_CONSTRAINT(VALUE, C) \
((C) == 'e' ? x86_64_sign_extended_value (VALUE) \
((C) == 'e' ? x86_64_sign_extended_value (VALUE, 0) \
: (C) == 'Z' ? x86_64_zero_extended_value (VALUE) \
: 0)
......@@ -2553,7 +2553,7 @@ do { \
case CONST: \
case LABEL_REF: \
case SYMBOL_REF: \
if (TARGET_64BIT && !x86_64_sign_extended_value (RTX)) \
if (TARGET_64BIT && !x86_64_sign_extended_value (RTX, 0)) \
return 3; \
if (TARGET_64BIT && !x86_64_zero_extended_value (RTX)) \
return 2; \
......
......@@ -13783,7 +13783,7 @@
;; Note that these code sequences must appear exactly as shown
;; in order to allow linker relaxation.
(define_insn "*tls_global_dynamic_gnu"
(define_insn "*tls_global_dynamic_32_gnu"
[(set (match_operand:SI 0 "register_operand" "=a")
(unspec:SI [(match_operand:SI 1 "register_operand" "b")
(match_operand:SI 2 "tls_symbolic_operand" "")
......@@ -13792,12 +13792,12 @@
(clobber (match_scratch:SI 4 "=d"))
(clobber (match_scratch:SI 5 "=c"))
(clobber (reg:CC 17))]
"TARGET_GNU_TLS"
"!TARGET_64BIT && TARGET_GNU_TLS"
"lea{l}\t{%a2@TLSGD(,%1,1), %0|%0, %a2@TLSGD[%1*1]}\;call\t%P3"
[(set_attr "type" "multi")
(set_attr "length" "12")])
(define_insn "*tls_global_dynamic_sun"
(define_insn "*tls_global_dynamic_32_sun"
[(set (match_operand:SI 0 "register_operand" "=a")
(unspec:SI [(match_operand:SI 1 "register_operand" "b")
(match_operand:SI 2 "tls_symbolic_operand" "")
......@@ -13806,13 +13806,13 @@
(clobber (match_scratch:SI 4 "=d"))
(clobber (match_scratch:SI 5 "=c"))
(clobber (reg:CC 17))]
"TARGET_SUN_TLS"
"!TARGET_64BIT && TARGET_SUN_TLS"
"lea{l}\t{%a2@DTLNDX(%1), %4|%4, %a2@DTLNDX[%1]}
push{l}\t%4\;call\t%a2@TLSPLT\;pop{l}\t%4\;nop"
[(set_attr "type" "multi")
(set_attr "length" "14")])
(define_expand "tls_global_dynamic"
(define_expand "tls_global_dynamic_32"
[(parallel [(set (match_operand:SI 0 "register_operand" "")
(unspec:SI
[(match_dup 2)
......@@ -13834,7 +13834,28 @@
operands[3] = ix86_tls_get_addr ();
})
(define_insn "*tls_local_dynamic_base_gnu"
(define_insn "*tls_global_dynamic_64"
[(set (match_operand:DI 0 "register_operand" "=a")
(call (mem:QI (match_operand:DI 2 "call_insn_operand" ""))
(match_operand:DI 3 "" "")))
(unspec:DI [(match_operand:DI 1 "tls_symbolic_operand" "")]
UNSPEC_TLS_GD)]
"TARGET_64BIT"
".byte\t0x66\;lea{q}\t{%a1@TLSGD(%%rip), %%rdi|%%rdi, %a1@TLSGD[%%rip]}\;.word\t0x6666\;rex64\;call\t%P2"
[(set_attr "type" "multi")
(set_attr "length" "16")])
(define_expand "tls_global_dynamic_64"
[(parallel [(set (match_operand:DI 0 "register_operand" "")
(call (mem:QI (match_dup 2)) (const_int 0)))
(unspec:DI [(match_operand:DI 1 "tls_symbolic_operand" "")]
UNSPEC_TLS_GD)])]
""
{
operands[2] = ix86_tls_get_addr ();
})
(define_insn "*tls_local_dynamic_base_32_gnu"
[(set (match_operand:SI 0 "register_operand" "=a")
(unspec:SI [(match_operand:SI 1 "register_operand" "b")
(match_operand:SI 2 "call_insn_operand" "")]
......@@ -13842,12 +13863,12 @@
(clobber (match_scratch:SI 3 "=d"))
(clobber (match_scratch:SI 4 "=c"))
(clobber (reg:CC 17))]
"TARGET_GNU_TLS"
"!TARGET_64BIT && TARGET_GNU_TLS"
"lea{l}\t{%&@TLSLDM(%1), %0|%0, %&@TLSLDM[%1]}\;call\t%P2"
[(set_attr "type" "multi")
(set_attr "length" "11")])
(define_insn "*tls_local_dynamic_base_sun"
(define_insn "*tls_local_dynamic_base_32_sun"
[(set (match_operand:SI 0 "register_operand" "=a")
(unspec:SI [(match_operand:SI 1 "register_operand" "b")
(match_operand:SI 2 "call_insn_operand" "")]
......@@ -13855,13 +13876,13 @@
(clobber (match_scratch:SI 3 "=d"))
(clobber (match_scratch:SI 4 "=c"))
(clobber (reg:CC 17))]
"TARGET_SUN_TLS"
"!TARGET_64BIT && TARGET_SUN_TLS"
"lea{l}\t{%&@TMDNX(%1), %3|%3, %&@TMDNX[%1]}
push{l}\t%3\;call\t%&@TLSPLT\;pop{l}\t%3"
[(set_attr "type" "multi")
(set_attr "length" "13")])
(define_expand "tls_local_dynamic_base"
(define_expand "tls_local_dynamic_base_32"
[(parallel [(set (match_operand:SI 0 "register_operand" "")
(unspec:SI [(match_dup 1) (match_dup 2)]
UNSPEC_TLS_LD_BASE))
......@@ -13880,10 +13901,29 @@
operands[2] = ix86_tls_get_addr ();
})
(define_insn "*tls_local_dynamic_base_64"
[(set (match_operand:DI 0 "register_operand" "=a")
(call (mem:QI (match_operand:DI 1 "call_insn_operand" ""))
(match_operand:DI 2 "" "")))
(unspec:DI [(const_int 0)] UNSPEC_TLS_LD_BASE)]
"TARGET_64BIT"
"lea{q}\t{%&@TLSLD(%%rip), %%rdi|%%rdi, %&@TLSLD[%%rip]}\;call\t%P1"
[(set_attr "type" "multi")
(set_attr "length" "12")])
(define_expand "tls_local_dynamic_base_64"
[(parallel [(set (match_operand:DI 0 "register_operand" "")
(call (mem:QI (match_dup 1)) (const_int 0)))
(unspec:DI [(const_int 0)] UNSPEC_TLS_LD_BASE)])]
""
{
operands[1] = ix86_tls_get_addr ();
})
;; Local dynamic of a single variable is a lose. Show combine how
;; to convert that back to global dynamic.
(define_insn_and_split "*tls_local_dynamic_once"
(define_insn_and_split "*tls_local_dynamic_32_once"
[(set (match_operand:SI 0 "register_operand" "=a")
(plus:SI (unspec:SI [(match_operand:SI 1 "register_operand" "b")
(match_operand:SI 2 "call_insn_operand" "")]
......
......@@ -7482,11 +7482,27 @@ foo: .long 25
leal foo@DTPOFF(%eax), %edx
movl foo@GOTTPOFF(%ebx), %eax
subl foo@GOTTPOFF(%ebx), %eax
addl foo@GOTNTPOFF(%ebx), %eax
movl foo@INDNTPOFF, %eax
movl $foo@TPOFF, %eax
subl $foo@TPOFF, %eax
leal foo@NTPOFF(%ecx), %eax'
tls_first_major=2
tls_first_minor=13
tls_first_minor=14
;;
x86_64-*-*)
conftest_s='
.section ".tdata","awT",@progbits
foo: .long 25
.text
movq %fs:0, %rax
leaq foo@TLSGD(%rip), %rdi
leaq foo@TLSLD(%rip), %rdi
leaq foo@DTPOFF(%rax), %rdx
movq foo@GOTTPOFF(%rip), %rax
movq $foo@TPOFF, %rax'
tls_first_major=2
tls_first_minor=14
;;
ia64-*-*)
conftest_s='
......
......@@ -1802,11 +1802,27 @@ foo: .long 25
leal foo@DTPOFF(%eax), %edx
movl foo@GOTTPOFF(%ebx), %eax
subl foo@GOTTPOFF(%ebx), %eax
addl foo@GOTNTPOFF(%ebx), %eax
movl foo@INDNTPOFF, %eax
movl $foo@TPOFF, %eax
subl $foo@TPOFF, %eax
leal foo@NTPOFF(%ecx), %eax'
tls_first_major=2
tls_first_minor=13
tls_first_minor=14
;;
x86_64-*-*)
conftest_s='
.section ".tdata","awT",@progbits
foo: .long 25
.text
movq %fs:0, %rax
leaq foo@TLSGD(%rip), %rdi
leaq foo@TLSLD(%rip), %rdi
leaq foo@DTPOFF(%rax), %rdx
movq foo@GOTTPOFF(%rip), %rax
movq $foo@TPOFF, %rax'
tls_first_major=2
tls_first_minor=14
;;
ia64-*-*)
conftest_s='
......
2002-10-21 Jakub Jelinek <jakub@redhat.com>
* gcc.dg/tls/pic-1.c: New test.
* gcc.dg/tls/nonpic-1.c: New test.
* gcc.dg/20021018-1.c: New test.
2002-10-21 Ulrich Weigand <uweigand@de.ibm.com>
* lib/profopt.exp (profopt-cleanup): New argument TESTCASE.
......
/* { dg-do run } */
/* { dg-options "-O2 -fpic" } */
extern void abort (void);
extern void exit (int);
static const long foo [10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
long __attribute__((noinline))
bar (int x)
{
return foo [x - 0x6ffffffa];
}
int
main (void)
{
if (bar (0x6ffffffc) != 2)
abort ();
exit (0);
}
/* { dg-do compile } */
/* { dg-options "-O2 -ftls-model=initial-exec" } */
extern __thread long e1;
extern __thread int e2;
static __thread long s1;
static __thread int s2;
long *ae1 (void)
{
return &e1;
}
int *ae2 (void)
{
return &e2;
}
long *as1 (void)
{
return &s1;
}
int *as2 (void)
{
return &s2;
}
long ge1 (void)
{
return e1;
}
int ge2 (void)
{
return e2;
}
long gs1 (void)
{
return s1;
}
int gs2 (void)
{
return s2;
}
long ge3 (void)
{
return e1 + e2;
}
long gs3 (void)
{
return s1 + s2;
}
long ge4 (void)
{
if (0)
return e1;
return e2;
}
long gs4 (void)
{
if (0)
return s1;
return s2;
}
/* { dg-do compile } */
/* { dg-options "-O2 -fpic -ftls-model=global-dynamic" } */
extern __thread long e1;
extern __thread int e2;
static __thread long s1;
static __thread int s2;
long *ae1 (void)
{
return &e1;
}
int *ae2 (void)
{
return &e2;
}
long *as1 (void)
{
return &s1;
}
int *as2 (void)
{
return &s2;
}
long ge1 (void)
{
return e1;
}
int ge2 (void)
{
return e2;
}
long gs1 (void)
{
return s1;
}
int gs2 (void)
{
return s2;
}
long ge3 (void)
{
return e1 + e2;
}
long gs3 (void)
{
return s1 + s2;
}
long ge4 (void)
{
if (0)
return e1;
return e2;
}
long gs4 (void)
{
if (0)
return s1;
return s2;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment