This reinstates FINAL_PRESCAN_INSN, and the calls in handle_move_double, so that access to TLS variables with offset are properly handled.
gcc: PR target/106282 * config/m68k/m68k.h (FINAL_PRESCAN_INSN): Define. * config/m68k/m68k.cc (m68k_final_prescan_insn): Define. (handle_move_double): Call it before handle_movsi. * config/m68k/m68k-protos.h: Declare it. gcc/testsuite: PR target/106282 * gcc.target/m68k/tls-gd-off.c: New. * gcc.target/m68k/tls-ie-off.c: New. * gcc.target/m68k/tls-ld-off.c: New. * gcc.target/m68k/tls-ld-xtls-off.c: New. * gcc.target/m68k/tls-le-off.c: New. * gcc.target/m68k/tls-le-xtls-off.c: New. * gcc.target/m68k/tls-ld.c: Make pattern less strict. * gcc.target/m68k/tls-le.c: Likewise. --- gcc/config/m68k/m68k-protos.h | 1 + gcc/config/m68k/m68k.cc | 15 +++++++++++++++ gcc/config/m68k/m68k.h | 3 +++ .../gcc.target/m68k/{tls-ld.c => tls-gd-off.c} | 7 +++---- .../gcc.target/m68k/{tls-le.c => tls-ie-off.c} | 6 +++--- .../gcc.target/m68k/{tls-ld.c => tls-ld-off.c} | 8 ++++---- .../m68k/{tls-ld.c => tls-ld-xtls-off.c} | 8 ++++---- gcc/testsuite/gcc.target/m68k/tls-ld.c | 4 ++-- .../gcc.target/m68k/{tls-le.c => tls-le-off.c} | 6 +++--- gcc/testsuite/gcc.target/m68k/tls-le-xtls-off.c | 13 +++++++++++++ gcc/testsuite/gcc.target/m68k/tls-le.c | 2 +- 11 files changed, 52 insertions(+), 21 deletions(-) copy gcc/testsuite/gcc.target/m68k/{tls-ld.c => tls-gd-off.c} (52%) copy gcc/testsuite/gcc.target/m68k/{tls-le.c => tls-ie-off.c} (62%) copy gcc/testsuite/gcc.target/m68k/{tls-ld.c => tls-ld-off.c} (52%) copy gcc/testsuite/gcc.target/m68k/{tls-ld.c => tls-ld-xtls-off.c} (57%) copy gcc/testsuite/gcc.target/m68k/{tls-le.c => tls-le-off.c} (62%) create mode 100644 gcc/testsuite/gcc.target/m68k/tls-le-xtls-off.c diff --git a/gcc/config/m68k/m68k-protos.h b/gcc/config/m68k/m68k-protos.h index 60bff796534..724d446af93 100644 --- a/gcc/config/m68k/m68k-protos.h +++ b/gcc/config/m68k/m68k-protos.h @@ -84,6 +84,7 @@ extern int emit_move_sequence (rtx *, machine_mode, rtx); extern bool m68k_movem_pattern_p (rtx, rtx, HOST_WIDE_INT, bool); extern const char *m68k_output_movem (rtx *, rtx, HOST_WIDE_INT, bool); extern bool m68k_epilogue_uses (int); +extern void m68k_final_prescan_insn (rtx_insn *, rtx *, int); /* Functions from m68k.cc used in constraints.md. */ extern rtx m68k_unwrap_symbol (rtx, bool); diff --git a/gcc/config/m68k/m68k.cc b/gcc/config/m68k/m68k.cc index 0bff89bc39d..03db2b6a936 100644 --- a/gcc/config/m68k/m68k.cc +++ b/gcc/config/m68k/m68k.cc @@ -2550,6 +2550,18 @@ m68k_adjust_decorated_operand (rtx op) } } +/* Prescan insn before outputing assembler for it. */ + +void +m68k_final_prescan_insn (rtx_insn *insn ATTRIBUTE_UNUSED, + rtx *operands, int n_operands) +{ + int i; + + for (i = 0; i < n_operands; ++i) + m68k_adjust_decorated_operand (operands[i]); +} + /* Move X to a register and add REG_EQUAL note pointing to ORIG. If REG is non-null, use it; generate new pseudo otherwise. */ @@ -3658,6 +3670,7 @@ handle_move_double (rtx operands[2], /* Normal case: do the two words, low-numbered first. */ + m68k_final_prescan_insn (NULL, operands, 2); handle_movsi (operands); /* Do the middle one of the three words for long double */ @@ -3668,6 +3681,7 @@ handle_move_double (rtx operands[2], if (addreg1) handle_reg_adjust (addreg1, 4); + m68k_final_prescan_insn (NULL, middlehalf, 2); handle_movsi (middlehalf); } @@ -3678,6 +3692,7 @@ handle_move_double (rtx operands[2], handle_reg_adjust (addreg1, 4); /* Do that word. */ + m68k_final_prescan_insn (NULL, latehalf, 2); handle_movsi (latehalf); /* Undo the adds we just did. */ diff --git a/gcc/config/m68k/m68k.h b/gcc/config/m68k/m68k.h index 6f0bdd8dffa..450c380359c 100644 --- a/gcc/config/m68k/m68k.h +++ b/gcc/config/m68k/m68k.h @@ -837,6 +837,9 @@ __transfer_from_trampoline () \ assemble_name ((FILE), (NAME)), \ fprintf ((FILE), ",%u\n", (int)(ROUNDED))) +#define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \ + m68k_final_prescan_insn (INSN, OPVEC, NOPERANDS) + /* On the 68000, we use several CODE characters: '.' for dot needed in Motorola-style opcode names. '-' for an operand pushing on the stack: diff --git a/gcc/testsuite/gcc.target/m68k/tls-ld.c b/gcc/testsuite/gcc.target/m68k/tls-gd-off.c similarity index 52% copy from gcc/testsuite/gcc.target/m68k/tls-ld.c copy to gcc/testsuite/gcc.target/m68k/tls-gd-off.c index af470c9613a..4af6128ae27 100644 --- a/gcc/testsuite/gcc.target/m68k/tls-ld.c +++ b/gcc/testsuite/gcc.target/m68k/tls-gd-off.c @@ -1,14 +1,13 @@ /* { dg-do compile } */ /* { dg-skip-if "" { ! *-linux-* } } */ /* { dg-options "-O2 -fpic" } */ -/* { dg-final { scan-assembler "foo@TLSLDM\\(\%a5\\)" } } */ +/* { dg-final { scan-assembler "foo@TLSGD\\(\%a5\\)" } } */ /* { dg-final { scan-assembler "bsr.l __tls_get_addr@PLTPC" } } */ -/* { dg-final { scan-assembler "lea \\(foo@TLSLDO,\%a0\\)" } } */ -static int __thread foo; +extern int __thread foo[2]; int * bar (void) { - return &foo; + return foo + 1; } diff --git a/gcc/testsuite/gcc.target/m68k/tls-le.c b/gcc/testsuite/gcc.target/m68k/tls-ie-off.c similarity index 62% copy from gcc/testsuite/gcc.target/m68k/tls-le.c copy to gcc/testsuite/gcc.target/m68k/tls-ie-off.c index 74234e9e5a4..024cefe2ac5 100644 --- a/gcc/testsuite/gcc.target/m68k/tls-le.c +++ b/gcc/testsuite/gcc.target/m68k/tls-ie-off.c @@ -2,12 +2,12 @@ /* { dg-skip-if "" { ! *-linux-* } } */ /* { dg-options "-O2" } */ /* { dg-final { scan-assembler "jsr __m68k_read_tp" } } */ -/* { dg-final { scan-assembler "lea \\(foo@TLSLE,\%a0\\)" } } */ +/* { dg-final { scan-assembler "foo@TLSIE\\(\%a5\\)" } } */ -static int __thread foo; +extern int __thread foo[2]; int * bar (void) { - return &foo; + return foo + 1; } diff --git a/gcc/testsuite/gcc.target/m68k/tls-ld.c b/gcc/testsuite/gcc.target/m68k/tls-ld-off.c similarity index 52% copy from gcc/testsuite/gcc.target/m68k/tls-ld.c copy to gcc/testsuite/gcc.target/m68k/tls-ld-off.c index af470c9613a..bd0ee8d2c03 100644 --- a/gcc/testsuite/gcc.target/m68k/tls-ld.c +++ b/gcc/testsuite/gcc.target/m68k/tls-ld-off.c @@ -1,14 +1,14 @@ /* { dg-do compile } */ /* { dg-skip-if "" { ! *-linux-* } } */ /* { dg-options "-O2 -fpic" } */ -/* { dg-final { scan-assembler "foo@TLSLDM\\(\%a5\\)" } } */ +/* { dg-final { scan-assembler "foo@TLSLDM\\(%a5\\)" } } */ /* { dg-final { scan-assembler "bsr.l __tls_get_addr@PLTPC" } } */ -/* { dg-final { scan-assembler "lea \\(foo@TLSLDO,\%a0\\)" } } */ +/* { dg-final { scan-assembler "foo\\+4@TLSLDO,%a0" } } */ -static int __thread foo; +static int __thread foo[2]; int * bar (void) { - return &foo; + return foo + 1; } diff --git a/gcc/testsuite/gcc.target/m68k/tls-ld.c b/gcc/testsuite/gcc.target/m68k/tls-ld-xtls-off.c similarity index 57% copy from gcc/testsuite/gcc.target/m68k/tls-ld.c copy to gcc/testsuite/gcc.target/m68k/tls-ld-xtls-off.c index af470c9613a..195682b2291 100644 --- a/gcc/testsuite/gcc.target/m68k/tls-ld.c +++ b/gcc/testsuite/gcc.target/m68k/tls-ld-xtls-off.c @@ -1,14 +1,14 @@ /* { dg-do compile } */ /* { dg-skip-if "" { ! *-linux-* } } */ -/* { dg-options "-O2 -fpic" } */ +/* { dg-options "-O2 -fpic -mxtls" } */ /* { dg-final { scan-assembler "foo@TLSLDM\\(\%a5\\)" } } */ /* { dg-final { scan-assembler "bsr.l __tls_get_addr@PLTPC" } } */ -/* { dg-final { scan-assembler "lea \\(foo@TLSLDO,\%a0\\)" } } */ +/* { dg-final { scan-assembler "#foo\\+4@TLSLDO,\%\[ad\]\[0-7\]" } } */ -static int __thread foo; +static int __thread foo[2]; int * bar (void) { - return &foo; + return foo + 1; } diff --git a/gcc/testsuite/gcc.target/m68k/tls-ld.c b/gcc/testsuite/gcc.target/m68k/tls-ld.c index af470c9613a..091a72a03b2 100644 --- a/gcc/testsuite/gcc.target/m68k/tls-ld.c +++ b/gcc/testsuite/gcc.target/m68k/tls-ld.c @@ -1,9 +1,9 @@ /* { dg-do compile } */ /* { dg-skip-if "" { ! *-linux-* } } */ /* { dg-options "-O2 -fpic" } */ -/* { dg-final { scan-assembler "foo@TLSLDM\\(\%a5\\)" } } */ +/* { dg-final { scan-assembler "foo@TLSLDM\\(%a5\\)" } } */ /* { dg-final { scan-assembler "bsr.l __tls_get_addr@PLTPC" } } */ -/* { dg-final { scan-assembler "lea \\(foo@TLSLDO,\%a0\\)" } } */ +/* { dg-final { scan-assembler "foo@TLSLDO,%a0" } } */ static int __thread foo; diff --git a/gcc/testsuite/gcc.target/m68k/tls-le.c b/gcc/testsuite/gcc.target/m68k/tls-le-off.c similarity index 62% copy from gcc/testsuite/gcc.target/m68k/tls-le.c copy to gcc/testsuite/gcc.target/m68k/tls-le-off.c index 74234e9e5a4..c61ae08f074 100644 --- a/gcc/testsuite/gcc.target/m68k/tls-le.c +++ b/gcc/testsuite/gcc.target/m68k/tls-le-off.c @@ -2,12 +2,12 @@ /* { dg-skip-if "" { ! *-linux-* } } */ /* { dg-options "-O2" } */ /* { dg-final { scan-assembler "jsr __m68k_read_tp" } } */ -/* { dg-final { scan-assembler "lea \\(foo@TLSLE,\%a0\\)" } } */ +/* { dg-final { scan-assembler "foo\\+4@TLSLE,%a0" } } */ -static int __thread foo; +static int __thread foo[2]; int * bar (void) { - return &foo; + return foo + 1; } diff --git a/gcc/testsuite/gcc.target/m68k/tls-le-xtls-off.c b/gcc/testsuite/gcc.target/m68k/tls-le-xtls-off.c new file mode 100644 index 00000000000..0a9f47d8d0e --- /dev/null +++ b/gcc/testsuite/gcc.target/m68k/tls-le-xtls-off.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { ! *-linux-* } } */ +/* { dg-options "-O2 -mxtls" } */ +/* { dg-final { scan-assembler "jsr __m68k_read_tp" } } */ +/* { dg-final { scan-assembler "#foo\\+4@TLSLE,\%\[ad\]\[0-7\]" } } */ + +static int __thread foo[2]; + +int * +bar (void) +{ + return foo + 1; +} diff --git a/gcc/testsuite/gcc.target/m68k/tls-le.c b/gcc/testsuite/gcc.target/m68k/tls-le.c index 74234e9e5a4..7a9f215f44b 100644 --- a/gcc/testsuite/gcc.target/m68k/tls-le.c +++ b/gcc/testsuite/gcc.target/m68k/tls-le.c @@ -2,7 +2,7 @@ /* { dg-skip-if "" { ! *-linux-* } } */ /* { dg-options "-O2" } */ /* { dg-final { scan-assembler "jsr __m68k_read_tp" } } */ -/* { dg-final { scan-assembler "lea \\(foo@TLSLE,\%a0\\)" } } */ +/* { dg-final { scan-assembler "foo@TLSLE,%a0" } } */ static int __thread foo; -- 2.40.0 -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."