From patchwork Sun Mar 26 20:37:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 75151 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1114989vqo; Sun, 26 Mar 2023 13:37:53 -0700 (PDT) X-Google-Smtp-Source: AKy350aaqvCOLEGHqxJN8+4LX1AxspFUsSWVEY8k8uRNLB9fpeOTPBdYU3rkwTLRunHdLCxI+d9x X-Received: by 2002:a17:906:3118:b0:930:d319:d947 with SMTP id 24-20020a170906311800b00930d319d947mr10696572ejx.74.1679863073327; Sun, 26 Mar 2023 13:37:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679863073; cv=none; d=google.com; s=arc-20160816; b=r7R6V8F0f+JHWVgRzGmTuJ2i6Z2x5iG4KPfc44VVlI1IMBckYQr2ddVLrpgguMiB0E Jr8/UOpMHOXicKcxv0m8ExAgD81PNoCmxrspKrmRBZOW/2qaW6pHVEVBZ6iqW38V4h/J WO6cB6+1rxwOlOWjvxfzkp/OqLtoVMv9q2vdWVjVTCFvfBz/Sz9IGe1QpRcV2NrDv7IG oBvPMfcsYywyi7e1bHALdrC6J2yZbXouE+BwMrnxkxFlHxNIVh39SrsTNVcK93S+QB9l RqrMop7nXqhTf9kQbVgdEJj+V+h/bElSzr7VjPI9HGGZPCcttR16IyLvne8zvSawTChA QoEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:user-agent :message-id:date:subject:to:from:dmarc-filter:delivered-to; bh=xXdqCLD85Xzum37vpOdwqIYM0w1BRx9PUAwR4UlHRgw=; b=ahYden/b+LfpBQew2nKA2XCLfT28LGZIYEYVuXk7OlZX+M0uHOk8YGnOWU2jaMD7LX dh7m+RDUKK8+B5sZQEocxq0LpjMe98PbgH7fH13OHf7pUQiO/BCMB2O0K0CydQF1cbxj +JGyFM+bggV4hFCCEnbE0TM55oh8Km4bsLuBptd+JdlOn3P0Cv5fjoRcS6uURTe8BKki LOorH6EozBfsmXkJYtFxg3J96Eyv6UyQdFVTu1JcazgcjeZHlrmYwvu5rupNtwX4RiD4 +cT0zvMm9l04z++xRYmqK4PQB0gMNP77VMAs4eST59U9nEIl6+a466D+2icGvWGr5107 x1Rw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id xd12-20020a170907078c00b0093239cf2704si29258328ejb.213.2023.03.26.13.37.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Mar 2023 13:37:53 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9F16B385842A for ; Sun, 26 Mar 2023 20:37:45 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-out.m-online.net (mail-out.m-online.net [IPv6:2001:a60:0:28:0:1:25:1]) by sourceware.org (Postfix) with ESMTPS id 3F9CF385842D for ; Sun, 26 Mar 2023 20:37:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3F9CF385842D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nefkom.net Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4Pl76P2Y4Vz1s88m for ; Sun, 26 Mar 2023 22:37:17 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4Pl76P2S6fz1qqlS for ; Sun, 26 Mar 2023 22:37:17 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id dUlpHeku6jlw for ; Sun, 26 Mar 2023 22:37:16 +0200 (CEST) X-Auth-Info: 0IP69n9Ita0xRTdylol1azMMhfJODz6bJZavA6303qyW+WwJzcugYV9pgEeNLrh2 Received: from igel.home (aftr-82-135-86-30.dynamic.mnet-online.de [82.135.86.30]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA for ; Sun, 26 Mar 2023 22:37:16 +0200 (CEST) Received: by igel.home (Postfix, from userid 1000) id B97252C1C35; Sun, 26 Mar 2023 22:37:15 +0200 (CEST) From: Andreas Schwab To: gcc-patches@gcc.gnu.org Subject: m68k: handle TLS access with offset X-Yow: ..Wait 'til those ITALIAN TEENAGERS get back to their HONDAS & discover them to be FILLED to the BRIM with MAZOLA!! Date: Sun, 26 Mar 2023 22:37:15 +0200 Message-ID: <87fs9rs0zo.fsf@igel.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TO_NO_BRKTS_PCNT, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761464102464468657?= X-GMAIL-MSGID: =?utf-8?q?1761464102464468657?= 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;