From patchwork Thu Sep 19 00:17:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Meissner X-Patchwork-Id: 1164253 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-509243-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="SXvZKrIl"; 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 46Ycr821G0z9sCJ for ; Thu, 19 Sep 2019 10:17:58 +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:date :from:to:subject:message-id:references:mime-version:content-type :in-reply-to; q=dns; s=default; b=GwNZ6dyPSDjfK47xFyxAT7IBH9siMU TWhxhvrjkdZNOVM75po5WkrM/PumKcgf7iFKpF6mZQPY8TyLEijeY3nLPr00FvHZ nINiBuGYvQvMTez6iOctMIKAI8XpiaQ+tKI6wSyO8dQq/iO15PqAZY1HVJuPDziU 6OLSJA01c864s= 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:date :from:to:subject:message-id:references:mime-version:content-type :in-reply-to; s=default; bh=dylbMzkNyBVzHlMJ1oSHKfGIRdc=; b=SXvZ KrIldz/dSqnWAWYmcPO1pSRAYEiJFYKVg6JwDqY2gzsDEt8skI/alV9+Sib58bbD VbQJEP0GjvV7bc9/jYKr9WKv+CRuuTqtlGEpwF6yy0+syTXB/WShS5KKX3trfrhw 6PdpNSC0qp9LD+E3YABjcmfrjSKc/pdJDcuv9R4= Received: (qmail 79012 invoked by alias); 19 Sep 2019 00:17:51 -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 78994 invoked by uid 89); 19 Sep 2019 00:17:51 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=UD:rs6000-cpus.def, mpcrel, linux64.h, tmh X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 19 Sep 2019 00:17:49 +0000 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x8J0CXUx011241; Wed, 18 Sep 2019 20:17:48 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 2v3vdnv0cb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Sep 2019 20:17:47 -0400 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.27/8.16.0.27) with SMTP id x8J0D025012415; Wed, 18 Sep 2019 20:17:47 -0400 Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com with ESMTP id 2v3vdnv0c0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Sep 2019 20:17:47 -0400 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x8J0C4l2009278; Thu, 19 Sep 2019 00:17:46 GMT Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by ppma01dal.us.ibm.com with ESMTP id 2v3vbts7t0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Sep 2019 00:17:46 +0000 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x8J0HjtM53608864 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 19 Sep 2019 00:17:45 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CFED3124055; Thu, 19 Sep 2019 00:17:45 +0000 (GMT) Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 95426124052; Thu, 19 Sep 2019 00:17:45 +0000 (GMT) Received: from ibm-toto.the-meissners.org (unknown [9.32.77.177]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTPS; Thu, 19 Sep 2019 00:17:45 +0000 (GMT) Date: Wed, 18 Sep 2019 20:17:44 -0400 From: Michael Meissner To: Michael Meissner , gcc-patches@gcc.gnu.org, segher@kernel.crashing.org, dje.gcc@gmail.com Subject: [PATCH] V4, patch #8: Enable -mpcrel on Linux 64-bit, but not on other targets Message-ID: <20190919001744.GH28484@ibm-toto.the-meissners.org> Mail-Followup-To: Michael Meissner , gcc-patches@gcc.gnu.org, segher@kernel.crashing.org, dje.gcc@gmail.com References: <20190918234214.GA27521@ibm-toto.the-meissners.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190918234214.GA27521@ibm-toto.the-meissners.org> User-Agent: Mutt/1.5.21 (2010-09-15) This is the last patch in the compiler series for now. On Linux 64-bit systems it will enable -mpcrel (and -mprefixed-addr) by default. On other systems, it will not enable these switches until the tm.h for the OS enables it. I have the 3 patches for the test suite that will be following this if things are settling down. At the moment, the tests have not been modified, but I will look at your comments to see if I need to modify anything. In addition, I will be re-vamping PCREL_OPT to take into account your comments. That will come at a later date. I have done a bootstrap build with all of the patches applied, and there were no regressions in the test suite (this includes running all of the tests not yet submitted). After posting these patches, I will start a job to build each set of patches in turn just to make sure there are no extra warnings. Can I commit this patch to the trunk? 2019-09-18 Michael Meissner * config/rs6000/linux64.h (TARGET_PREFIXED_ADDR_DEFAULT): Enable prefixed addressing by default. (TARGET_PCREL_DEFAULT): Enable pc-relative addressing by default. * config/rs6000/rs6000-cpus.def (ISA_FUTURE_MASKS_SERVER): Only enable -mprefixed-addr and -mpcrel if the OS tm.h says to enable it. (ADDRESSING_FUTURE_MASKS): New mask macro. (OTHER_FUTURE_MASKS): Use ADDRESSING_FUTURE_MASKS. * config/rs6000/rs6000.c (TARGET_PREFIXED_ADDR_DEFAULT): Do not enable -mprefixed-addr unless the OS tm.h says to. (TARGET_PCREL_DEFAULT): Do not enable -mpcrel unless the OS tm.h says to. (rs6000_option_override_internal): Do not enable -mprefixed-addr or -mpcrel unless the OS tm.h says to enable it. Add more checks for -mcpu=future. Index: gcc/config/rs6000/linux64.h =================================================================== --- gcc/config/rs6000/linux64.h (revision 275894) +++ gcc/config/rs6000/linux64.h (working copy) @@ -640,3 +640,11 @@ extern int dot_symbols; enabling the __float128 keyword. */ #undef TARGET_FLOAT128_ENABLE_TYPE #define TARGET_FLOAT128_ENABLE_TYPE 1 + +/* Enable support for pc-relative and numeric prefixed addressing on the + 'future' system. */ +#undef TARGET_PREFIXED_ADDR_DEFAULT +#define TARGET_PREFIXED_ADDR_DEFAULT 1 + +#undef TARGET_PCREL_DEFAULT +#define TARGET_PCREL_DEFAULT 1 Index: gcc/config/rs6000/rs6000-cpus.def =================================================================== --- gcc/config/rs6000/rs6000-cpus.def (revision 275894) +++ gcc/config/rs6000/rs6000-cpus.def (working copy) @@ -75,15 +75,21 @@ | OPTION_MASK_P8_VECTOR \ | OPTION_MASK_P9_VECTOR) -/* Support for a future processor's features. Do not enable -mpcrel until it - is fully functional. */ +/* Support for a future processor's features. The prefixed and pc-relative + addressing bits are not added here. Instead, rs6000.c adds them if the OS + tm.h says that it supports the addressing modes. */ #define ISA_FUTURE_MASKS_SERVER (ISA_3_0_MASKS_SERVER \ - | OPTION_MASK_FUTURE \ + | OPTION_MASK_FUTURE) + +/* Addressing related flags on a future processor. These flags are broken out + because not all targets will support either pc-relative addressing, or even + prefixed addressing, and we want to clear all of the addressing bits + on targets that cannot support prefixed/pcrel addressing. */ +#define ADDRESSING_FUTURE_MASKS (OPTION_MASK_PCREL \ | OPTION_MASK_PREFIXED_ADDR) /* Flags that need to be turned off if -mno-future. */ -#define OTHER_FUTURE_MASKS (OPTION_MASK_PCREL \ - | OPTION_MASK_PREFIXED_ADDR) +#define OTHER_FUTURE_MASKS ADDRESSING_FUTURE_MASKS /* Flags that need to be turned off if -mno-power9-vector. */ #define OTHER_P9_VECTOR_MASKS (OPTION_MASK_FLOAT128_HW \ Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 275912) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -98,6 +98,16 @@ #endif #endif +/* Set up the defaults for whether prefixed addressing is used, and if it is + used, whether we want to turn on pc-relative support by default. */ +#ifndef TARGET_PREFIXED_ADDR_DEFAULT +#define TARGET_PREFIXED_ADDR_DEFAULT 0 +#endif + +#ifndef TARGET_PCREL_DEFAULT +#define TARGET_PCREL_DEFAULT 0 +#endif + /* Support targetm.vectorize.builtin_mask_for_load. */ GTY(()) tree altivec_builtin_mask_for_load; @@ -2532,6 +2542,14 @@ rs6000_debug_reg_global (void) if (TARGET_DIRECT_MOVE_128) fprintf (stderr, DEBUG_FMT_D, "VSX easy 64-bit mfvsrld element", (int)VECTOR_ELEMENT_MFVSRLD_64BIT); + + if (TARGET_FUTURE) + { + fprintf (stderr, DEBUG_FMT_D, "TARGET_PREFIXED_ADDR_DEFAULT", + TARGET_PREFIXED_ADDR_DEFAULT); + fprintf (stderr, DEBUG_FMT_D, "TARGET_PCREL_DEFAULT", + TARGET_PCREL_DEFAULT); + } } @@ -4012,26 +4030,6 @@ rs6000_option_override_internal (bool gl rs6000_isa_flags &= ~OPTION_MASK_FLOAT128_HW; } - /* -mprefixed-addr (and hence -mpcrel) requires -mcpu=future. */ - if (TARGET_PREFIXED_ADDR && !TARGET_FUTURE) - { - if ((rs6000_isa_flags_explicit & OPTION_MASK_PCREL) != 0) - error ("%qs requires %qs", "-mpcrel", "-mcpu=future"); - else if ((rs6000_isa_flags_explicit & OPTION_MASK_PREFIXED_ADDR) != 0) - error ("%qs requires %qs", "-mprefixed-addr", "-mcpu=future"); - - rs6000_isa_flags &= ~(OPTION_MASK_PCREL | OPTION_MASK_PREFIXED_ADDR); - } - - /* -mpcrel requires prefixed load/store addressing. */ - if (TARGET_PCREL && !TARGET_PREFIXED_ADDR) - { - if ((rs6000_isa_flags_explicit & OPTION_MASK_PCREL) != 0) - error ("%qs requires %qs", "-mpcrel", "-mprefixed-addr"); - - rs6000_isa_flags &= ~OPTION_MASK_PCREL; - } - /* Print the options after updating the defaults. */ if (TARGET_DEBUG_REG || TARGET_DEBUG_TARGET) rs6000_print_isa_options (stderr, 0, "after defaults", rs6000_isa_flags); @@ -4163,12 +4161,89 @@ rs6000_option_override_internal (bool gl SUB3TARGET_OVERRIDE_OPTIONS; #endif - /* -mpcrel requires -mcmodel=medium, but we can't check TARGET_CMODEL until - after the subtarget override options are done. */ - if (TARGET_PCREL && TARGET_CMODEL != CMODEL_MEDIUM) + /* Enable prefixed addressing and pc-relative addressing on 64-bit ELF v2 + systems if the OS tm.h file says that it is supported and the user did not + explicitly use -mprefixed-addr or -mpcrel. At the present time, only + 64-bit Linux enables this. + + Pc-relative support also requires the medium code model. + + However, we can't check for ELFv2 or -mcmodel=medium until after the + subtarget macros are run. + + If prefixed addressing is disabled by default, and the user does -mpcrel, + don't force them to also specify -mprefixed-addr. */ + if (TARGET_FUTURE) + { + bool explicit_prefixed = ((rs6000_isa_flags_explicit + & OPTION_MASK_PREFIXED_ADDR) != 0); + bool explicit_pcrel = ((rs6000_isa_flags_explicit + & OPTION_MASK_PCREL) != 0); + + /* Prefixed addressing requires 64-bit registers. */ + if (!TARGET_POWERPC64) + { + if (TARGET_PCREL && explicit_pcrel) + error ("%qs requires %qs", "-mpcrel", "-m64"); + + else if (TARGET_PREFIXED_ADDR && explicit_prefixed) + error ("%qs requires %qs", "-mprefixed-addr", "-m64"); + + rs6000_isa_flags &= ~ADDRESSING_FUTURE_MASKS; + } + + /* Only ELFv2 currently supports prefixed/pcrel addressing. */ + else if (rs6000_current_abi != ABI_ELFv2) + { + if (TARGET_PCREL && explicit_pcrel) + error ("%qs requires %qs", "-mpcrel", "-mabi=elfv2"); + + else if (TARGET_PREFIXED_ADDR && explicit_prefixed) + error ("%qs requires %qs", "-mprefixed-addr", "-mabi=elfv2"); + + rs6000_isa_flags &= ~ADDRESSING_FUTURE_MASKS; + } + + /* Pc-relative requires the medium code model. */ + else if (TARGET_PCREL && TARGET_CMODEL != CMODEL_MEDIUM) + { + if ((rs6000_isa_flags_explicit & OPTION_MASK_PCREL) != 0) + error ("%qs requires %qs", "-mpcrel", "-mcmodel=medium"); + + rs6000_isa_flags &= ~OPTION_MASK_PCREL; + } + + /* Enable defaults if desired. */ + else + { + if (!explicit_prefixed + && (TARGET_PREFIXED_ADDR_DEFAULT + || TARGET_PCREL + || TARGET_PCREL_DEFAULT)) + rs6000_isa_flags |= OPTION_MASK_PREFIXED_ADDR; + + if (!explicit_pcrel && TARGET_PCREL_DEFAULT + && TARGET_CMODEL == CMODEL_MEDIUM) + rs6000_isa_flags |= OPTION_MASK_PCREL; + } + } + + /* -mprefixed-addr (and hence -mpcrel) requires -mcpu=future. */ + if (TARGET_PREFIXED_ADDR && !TARGET_FUTURE) { if ((rs6000_isa_flags_explicit & OPTION_MASK_PCREL) != 0) - error ("%qs requires %qs", "-mpcrel", "-mcmodel=medium"); + error ("%qs requires %qs", "-mpcrel", "-mcpu=future"); + else if ((rs6000_isa_flags_explicit & OPTION_MASK_PREFIXED_ADDR) != 0) + error ("%qs requires %qs", "-mprefixed-addr", "-mcpu=future"); + + rs6000_isa_flags &= ~(OPTION_MASK_PCREL | OPTION_MASK_PREFIXED_ADDR); + } + + /* -mpcrel requires prefixed load/store addressing. */ + if (TARGET_PCREL && !TARGET_PREFIXED_ADDR) + { + if ((rs6000_isa_flags_explicit & OPTION_MASK_PCREL) != 0) + error ("%qs requires %qs", "-mpcrel", "-mprefixed-addr"); rs6000_isa_flags &= ~OPTION_MASK_PCREL; }