From patchwork Wed Aug 8 20:10:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 955224 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-483425-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="vMVc6skI"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41m2Ys0fVRz9s3Z for ; Thu, 9 Aug 2018 06:10:22 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=pg0M20Xz/WELkvoOzHCogqL+ScSzlKtBsRpsbCJYxseIP0hkt08Qs /C0ZNqxlrH7yUB1BmGlplSJGtHhpRsuT9GQ+vXwbXksOTtTnWahPXp19hxbO/9Tn uHq9a1TWj3R+zrA3VAShsrdFKZ14WY7yWUQF2AOf6rnAoeHq0Ei/wY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=yPehK9RQoSgEo3LKdom0xmIyqvA=; b=vMVc6skIxWwF733IID+7 0dJLZqnxcPRGuQmySjjHpiEW98et719XKG6K9Ng1Wd1aP9qfwSzSiP8bFwaHJz0Y vt8LZqBRsjoqL/AAOYsY4gO+zCL36dur9bCgFKJmMtJub0kMLv8fnmlPaSWgKUE/ aN/Pmzc+tzmzAPAZs1Nv5y0= Received: (qmail 110367 invoked by alias); 8 Aug 2018 20:10:14 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 110345 invoked by uid 89); 8 Aug 2018 20:10:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=CODE, sk:schwab@, A9DA, 4d69 X-HELO: mail-out.m-online.net Received: from mail-out.m-online.net (HELO mail-out.m-online.net) (212.18.0.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 08 Aug 2018 20:10:11 +0000 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 41m2YY2dt8z1qtXt for ; Wed, 8 Aug 2018 22:10:09 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 41m2YY1WHBz1qrVn for ; Wed, 8 Aug 2018 22:10:09 +0200 (CEST) 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 dQnI3AC9QIUO for ; Wed, 8 Aug 2018 22:10:08 +0200 (CEST) Received: from igel.home (ppp-188-174-158-129.dynamic.mnet-online.de [188.174.158.129]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA for ; Wed, 8 Aug 2018 22:10:08 +0200 (CEST) Received: by igel.home (Postfix, from userid 1000) id 7CDF42C1219; Wed, 8 Aug 2018 22:10:07 +0200 (CEST) From: Andreas Schwab To: gcc-patches@gcc.gnu.org Subject: m68k: handle more cases of TLS symbols with offset X-Yow: Mmmmmm-MMMMMM!! A plate of STEAMING PIECES of a PIG mixed with the shreds of SEVERAL CHICKENS!!... Oh BOY!! I'm about to swallow a TORN-OFF section of a COW'S LEFT LEG soaked in COTTONSEED OIL and SUGAR!! .. Let's see.. Next, I'll have the GROUND-UP flesh of CUTE, BABY LAMBS fried in the MELTED, FATTY TISSUES from a warm-blooded animal someone once PETTED!! ... YUM!! That was GOOD!! For DESSERT, I'll have a TOFU BURGER with BEAN SPROUTS on a stone-ground, WHOLE WHEAT BUN!! Date: Wed, 08 Aug 2018 22:10:07 +0200 Message-ID: <87a7pwfwm8.fsf@igel.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 This is a better fix for PR target/46179. There are more DImode insns that call adjust_operand during output processing. Instead of scanning the insns in the FINAL_PRESCAN_INSN hook, adjust them directly before they are output by print_operand or print_operand_address. Andreas. PR target/46179 * config/m68k/m68k.h (FINAL_PRESCAN_INSN): Don't define. * config/m68k/m68k.c (handle_move_double): Don't call m68k_final_prescan_insn. (m68k_adjust_decorated_operand): Renamed from m68k_final_prescan_insn, remove first and third operand and simplify. (print_operand): Call it. (print_operand_address): Call it. PR target/46179 * gcc.target/m68k/tls-dimode.c: New file. --- gcc/ChangeLog | 12 ++++ gcc/config/m68k/m68k.c | 66 ++++++++++------------ gcc/config/m68k/m68k.h | 3 - gcc/testsuite/ChangeLog | 5 ++ gcc/testsuite/gcc.target/m68k/tls-dimode.c | 15 +++++ 5 files changed, 62 insertions(+), 39 deletions(-) create mode 100644 gcc/testsuite/gcc.target/m68k/tls-dimode.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 64704bcd6d..e8f65c9791 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2018-08-08 Andreas Schwab + + PR target/46179 + * config/m68k/m68k.h (FINAL_PRESCAN_INSN): Don't define. + * config/m68k/m68k.c (handle_move_double): Don't call + m68k_final_prescan_insn. + (m68k_adjust_decorated_operand): Renamed from + m68k_final_prescan_insn, remove first and third operand and + simplify. + (print_operand): Call it. + (print_operand_address): Call it. + 2018-08-08 Nathan Sidwell * diagnostic.c (diagnostic_report_current_module): Use diff --git a/gcc/config/m68k/m68k.c b/gcc/config/m68k/m68k.c index 75a5a5b69b..303dfc1c0c 100644 --- a/gcc/config/m68k/m68k.c +++ b/gcc/config/m68k/m68k.c @@ -2329,11 +2329,10 @@ m68k_unwrap_symbol (rtx orig, bool unwrap_reloc32_p) return m68k_unwrap_symbol_1 (orig, unwrap_reloc32_p, NULL); } -/* Prescan insn before outputing assembler for it. */ +/* Adjust decorated address operand before outputing assembler for it. */ -void -m68k_final_prescan_insn (rtx_insn *insn ATTRIBUTE_UNUSED, - rtx *operands, int n_operands) +static void +m68k_adjust_decorated_operand (rtx op) { int i; @@ -2355,45 +2354,38 @@ m68k_final_prescan_insn (rtx_insn *insn ATTRIBUTE_UNUSED, to patch up anything outside of the operand. */ subrtx_var_iterator::array_type array; - for (i = 0; i < n_operands; ++i) + FOR_EACH_SUBRTX_VAR (iter, array, op, ALL) { - rtx op; - - op = operands[i]; - - FOR_EACH_SUBRTX_VAR (iter, array, op, ALL) + rtx x = *iter; + if (m68k_unwrap_symbol (x, true) != x) { - rtx x = *iter; - if (m68k_unwrap_symbol (x, true) != x) - { - rtx plus; + rtx plus; - gcc_assert (GET_CODE (x) == CONST); - plus = XEXP (x, 0); + gcc_assert (GET_CODE (x) == CONST); + plus = XEXP (x, 0); - if (GET_CODE (plus) == PLUS || GET_CODE (plus) == MINUS) - { - rtx unspec; - rtx addend; + if (GET_CODE (plus) == PLUS || GET_CODE (plus) == MINUS) + { + rtx unspec; + rtx addend; - unspec = XEXP (plus, 0); - gcc_assert (GET_CODE (unspec) == UNSPEC); - addend = XEXP (plus, 1); - gcc_assert (CONST_INT_P (addend)); + unspec = XEXP (plus, 0); + gcc_assert (GET_CODE (unspec) == UNSPEC); + addend = XEXP (plus, 1); + gcc_assert (CONST_INT_P (addend)); - /* We now have all the pieces, rearrange them. */ + /* We now have all the pieces, rearrange them. */ - /* Move symbol to plus. */ - XEXP (plus, 0) = XVECEXP (unspec, 0, 0); + /* Move symbol to plus. */ + XEXP (plus, 0) = XVECEXP (unspec, 0, 0); - /* Move plus inside unspec. */ - XVECEXP (unspec, 0, 0) = plus; + /* Move plus inside unspec. */ + XVECEXP (unspec, 0, 0) = plus; - /* Move unspec to top level of const. */ - XEXP (x, 0) = unspec; - } - iter.skip_subrtxes (); + /* Move unspec to top level of const. */ + XEXP (x, 0) = unspec; } + iter.skip_subrtxes (); } } } @@ -3496,7 +3488,6 @@ 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 */ @@ -3507,7 +3498,6 @@ handle_move_double (rtx operands[2], if (addreg1) handle_reg_adjust (addreg1, 4); - m68k_final_prescan_insn (NULL, middlehalf, 2); handle_movsi (middlehalf); } @@ -3518,7 +3508,6 @@ 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. */ @@ -4464,6 +4453,9 @@ floating_exact_log2 (rtx x) void print_operand (FILE *file, rtx op, int letter) { + if (op != NULL_RTX) + m68k_adjust_decorated_operand (op); + if (letter == '.') { if (MOTOROLA) @@ -4712,6 +4704,8 @@ print_operand_address (FILE *file, rtx addr) { struct m68k_address address; + m68k_adjust_decorated_operand (addr); + if (!m68k_decompose_address (QImode, addr, true, &address)) gcc_unreachable (); diff --git a/gcc/config/m68k/m68k.h b/gcc/config/m68k/m68k.h index 506fa4e50e..29e9be2b9d 100644 --- a/gcc/config/m68k/m68k.h +++ b/gcc/config/m68k/m68k.h @@ -867,9 +867,6 @@ do { if (cc_prev_status.flags & CC_IN_68881) \ 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/ChangeLog b/gcc/testsuite/ChangeLog index 12f842592d..779b50f98e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-08-08 Andreas Schwab + + PR target/46179 + * gcc.target/m68k/tls-dimode.c: New file. + 2018-08-08 Nathan Sidwell * c-c++-common/inc-from-1a.h, c-c++-common/inc-from-1b.h, diff --git a/gcc/testsuite/gcc.target/m68k/tls-dimode.c b/gcc/testsuite/gcc.target/m68k/tls-dimode.c new file mode 100644 index 0000000000..0bc59cd1d9 --- /dev/null +++ b/gcc/testsuite/gcc.target/m68k/tls-dimode.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { ! *-linux-* } } */ +/* { dg-options "-w -O2" } */ + +__thread long long ti; + +void f (void) +{ + ti++; +} + +void g (long long x) +{ + ti = x; +}