From patchwork Tue Jul 16 06:19:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Meissner X-Patchwork-Id: 1132451 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-505113-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="FUnGc9In"; 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 45nqxP2Qm5z9sDB for ; Tue, 16 Jul 2019 16:19:32 +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=XZv028Ty0lc8G9MFks7D5L+hpttLrH Kb1/jYJJ6GmxTOlyEpfuYFgympI2P1Pr55sctlYu8WZBLphdyuuMeKMJsEuI4m4L IxLAvV1PRpYUdrDL/w18pu/N68J/r8Ln3f/8SkSGEK7vvSNOHFoeiGLW3lOnwnx4 UWn94jRgjHf28= 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=Qjg6WVC9lGJLO7Twwc5VVTYFBro=; b=FUnG c9In4H5NlNfdOFBorsYuHC1IO7a90NftknOD44RJHxQbrAXfittDgSmZ8teNcSDq BrN6xBj1kww9eJCSvSBGcV3FeuWeWUmexssTphsfmN07e4rmboLD8B/lZwzvS/IF MhzfoT61VnyJpJ3460Q2yajIg2OjBKfWiR0XXek= Received: (qmail 85072 invoked by alias); 16 Jul 2019 06:19:24 -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 85064 invoked by uid 89); 16 Jul 2019 06:19:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=sk:meissne 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; Tue, 16 Jul 2019 06:19:22 +0000 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6G6Gop0121020; Tue, 16 Jul 2019 02:19:20 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ts706dd6b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 16 Jul 2019 02:19:19 -0400 Received: from m0098393.ppops.net (m0098393.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.27/8.16.0.27) with SMTP id x6G6ITWu126897; Tue, 16 Jul 2019 02:19:19 -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 2ts706dd5q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 16 Jul 2019 02:19:19 -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 x6G6EgPS015581; Tue, 16 Jul 2019 06:19:18 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma01dal.us.ibm.com with ESMTP id 2tq6x6mude-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 16 Jul 2019 06:19:18 +0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6G6JGHX60424588 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Jul 2019 06:19:16 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6B4EDBE054; Tue, 16 Jul 2019 06:19:16 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DE039BE051; Tue, 16 Jul 2019 06:19:15 +0000 (GMT) Received: from ibm-toto.the-meissners.org (unknown [9.32.77.177]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTPS; Tue, 16 Jul 2019 06:19:15 +0000 (GMT) Date: Tue, 16 Jul 2019 02:19:14 -0400 From: Michael Meissner To: Michael Meissner , gcc-patches@gcc.gnu.org, segher@kernel.crashing.org, dje.gcc@gmail.com Subject: [PATCH], Patch #6, revision 3, Create pc-relative addressing insns Message-ID: <20190716061913.GA20513@ibm-toto.the-meissners.org> Mail-Followup-To: Michael Meissner , gcc-patches@gcc.gnu.org, segher@kernel.crashing.org, dje.gcc@gmail.com References: <20190628000602.GA24286@ibm-toto.the-meissners.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190628000602.GA24286@ibm-toto.the-meissners.org> User-Agent: Mutt/1.5.21 (2010-09-15) This is a re-think of patch #6. I have changed the TARGET_TOC to be TARGET_HAS_TOC in the aix, darwin, system V, and Linux 64-bit headers. Then in rs6000.h, TARGET_TOC is defined in terms of TARGET_HAS_TOC and not pc-relative referencing. I discovered that TARGET_NO_TOC must not be set to be just !TARGET_TOC, since TARGET_NO_TOC is used to create the elf_high, elf_low insns in 32-bit. I added a gcc_assert in create_TOC_reference. For pc-relative, I dropped setting an alias set, since it uses the constant pool SYMBOL_REF created by force_const_mem (the TOC code needs to create the alias set because it rewrites the memory address, and the constant pool stuff is missing). Note, there is some more code that will need to be done when pc-relative support is completely supported, and that will be in a later patch. I did rename the static variable 'set' that contained the alias set to TOC_alias_set. I did not move the initialization of the TOC_alias_set elsewhere, because in order to call TOC_alias_set, the code has already called force_const_mem, create_TOC_reference, and gen_const_mem, so I didn't see the point of adding a micro-optimization for this. For that future pc-relative change, I did add code to only allow pc-relative if the memory model is medium. This eliminates some of the checks you objected to in the previous patch. I did build the compiler on both big endian and little endian power8 system, and ran the regression tests (both 64/32-bit on the big endian system, and just 64-bit on the little endian system) and there were no regressions. In addition, I built spec 2017 and spec 2006 for both little endian power9 and the future system using the branch that contains the full future pc-relative changes that I'm submitting bits and pieces from. I reworked that branch to use the same patches that are being submitted. Can I check this into the trunk? 2019-07-15 Michael Meissner * config/rs6000/aix.h (TARGET_HAS_TOC): Rename TARGET_TOC to TARGET_HAS_TOC. (TARGET_TOC): Likewise. (TARGET_NO_TOC): Delete here, define in rs6000.h. * config/rs6000/darwin.h (TARGET_HAS_TOC): Rename TARGET_TOC to TARGET_HAS_TOC. (TARGET_TOC): Likewise. (TARGET_NO_TOC): Delete here, define in rs6000.h. * config/rs6000/linux64.h (TARGET_HAS_TOC): Rename TARGET_TOC to TARGET_HAS_TOC. (TARGET_TOC): Likewise. * config/rs6000/rs6000.c (rs6000_option_override_internal): Add check to require -mcmodel=medium for pc-relative addressing. (create_TOC_reference): Add assertion for TARGET_TOC. (TOC_alias_set): Rename TOC alias set static variable from 'set' to 'TOC_alias_set'. (get_TOC_alias_set): Likewise. * config/rs6000/rs6000.h (TARGET_TOC): Define in terms of TARGET_HAS_TOC and not pc-relative. (TARGET_NO_TOC): Likewise. * config/rs6000/sysv4.h (TARGET_HAS_TOC): Rename TARGET_TOC to TARGET_HAS_TOC. (TARGET_TOC): Likewise. (TARGET_NO_TOC): Delete here, define in rs6000.h. Index: gcc/config/rs6000/aix.h =================================================================== --- gcc/config/rs6000/aix.h (revision 273457) +++ gcc/config/rs6000/aix.h (working copy) @@ -32,8 +32,7 @@ #define TARGET_AIX_OS 1 /* AIX always has a TOC. */ -#define TARGET_NO_TOC 0 -#define TARGET_TOC 1 +#define TARGET_HAS_TOC 1 #define FIXED_R2 1 /* AIX allows r13 to be used in 32-bit mode. */ Index: gcc/config/rs6000/darwin.h =================================================================== --- gcc/config/rs6000/darwin.h (revision 273457) +++ gcc/config/rs6000/darwin.h (working copy) @@ -43,8 +43,7 @@ /* We're not ever going to do TOCs. */ -#define TARGET_TOC 0 -#define TARGET_NO_TOC 1 +#define TARGET_HAS_TOC 0 /* Override the default rs6000 definition. */ #undef PTRDIFF_TYPE Index: gcc/config/rs6000/linux64.h =================================================================== --- gcc/config/rs6000/linux64.h (revision 273457) +++ gcc/config/rs6000/linux64.h (working copy) @@ -277,8 +277,8 @@ extern int dot_symbols; #ifndef RS6000_BI_ARCH /* 64-bit PowerPC Linux always has a TOC. */ -#undef TARGET_TOC -#define TARGET_TOC 1 +#undef TARGET_HAS_TOC +#define TARGET_HAS_TOC 1 /* Some things from sysv4.h we don't do when 64 bit. */ #undef OPTION_RELOCATABLE Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 273457) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -4333,6 +4333,16 @@ 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) + { + if ((rs6000_isa_flags_explicit & OPTION_MASK_PCREL) != 0) + error ("%qs requires %qs", "-mpcrel", "-mcmodel=medium"); + + rs6000_isa_flags &= ~OPTION_MASK_PCREL; + } + if (TARGET_DEBUG_REG || TARGET_DEBUG_TARGET) rs6000_print_isa_options (stderr, 0, "after subtarget", rs6000_isa_flags); @@ -7744,6 +7754,8 @@ create_TOC_reference (rtx symbol, rtx la { rtx tocrel, tocreg, hi; + gcc_assert (TARGET_TOC); + if (TARGET_DEBUG_ADDR) { if (SYMBOL_REF_P (symbol)) @@ -23736,14 +23748,14 @@ rs6000_split_multireg_move (rtx dst, rtx } } -static GTY(()) alias_set_type set = -1; +static GTY(()) alias_set_type TOC_alias_set = -1; alias_set_type get_TOC_alias_set (void) { - if (set == -1) - set = new_alias_set (); - return set; + if (TOC_alias_set == -1) + TOC_alias_set = new_alias_set (); + return TOC_alias_set; } /* Return the internal arg pointer used for function incoming Index: gcc/config/rs6000/rs6000.h =================================================================== --- gcc/config/rs6000/rs6000.h (revision 273457) +++ gcc/config/rs6000/rs6000.h (working copy) @@ -54,6 +54,14 @@ #define TARGET_AIX_OS 0 #endif +/* Turn off TOC support if pc-relative addressing is used. However, do not + turn on TARGET_NO_TOC if we have pc-relative addressing. The places that + check TARGET_NO_TOC are mostly for 32-bit ELF systems using elf_high and + elf_low, and we do not want to generate those instructions if we have + pc-relative support. */ +#define TARGET_TOC (TARGET_HAS_TOC && !TARGET_PCREL) +#define TARGET_NO_TOC (!TARGET_HAS_TOC && !TARGET_PCREL) + /* Control whether function entry points use a "dot" symbol when ABI_AIX. */ #define DOT_SYMBOLS 1 Index: gcc/config/rs6000/sysv4.h =================================================================== --- gcc/config/rs6000/sysv4.h (revision 273457) +++ gcc/config/rs6000/sysv4.h (working copy) @@ -41,7 +41,7 @@ #undef ASM_DEFAULT_SPEC #define ASM_DEFAULT_SPEC "-mppc" -#define TARGET_TOC (TARGET_64BIT \ +#define TARGET_HAS_TOC (TARGET_64BIT \ || (TARGET_MINIMAL_TOC \ && flag_pic > 1) \ || DEFAULT_ABI != ABI_V4) @@ -50,7 +50,6 @@ #define TARGET_BIG_ENDIAN (! TARGET_LITTLE_ENDIAN) #define TARGET_PROTOTYPE target_prototype #define TARGET_NO_PROTOTYPE (! TARGET_PROTOTYPE) -#define TARGET_NO_TOC (! TARGET_TOC) #define TARGET_NO_EABI (! TARGET_EABI) #define TARGET_REGNAMES rs6000_regnames