From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 56249 invoked by alias); 10 Jul 2019 21:18:00 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 56240 invoked by uid 89); 10 Jul 2019 21:17:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.1 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= 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; Wed, 10 Jul 2019 21:17:58 +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 x6ALDA8p066171 for ; Wed, 10 Jul 2019 17:17:55 -0400 Received: from e11.ny.us.ibm.com (e11.ny.us.ibm.com [129.33.205.201]) by mx0a-001b2d01.pphosted.com with ESMTP id 2tnmrcq1bn-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 10 Jul 2019 17:17:54 -0400 Received: from localhost by e11.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 10 Jul 2019 22:17:53 +0100 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e11.ny.us.ibm.com (146.89.104.198) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 10 Jul 2019 22:17:51 +0100 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6ALHoJc42271220 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Jul 2019 21:17:50 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 407F5AE05F; Wed, 10 Jul 2019 21:17:50 +0000 (GMT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0663AAE060; Wed, 10 Jul 2019 21:17:50 +0000 (GMT) Received: from ibm-toto.the-meissners.org (unknown [9.32.77.177]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTPS; Wed, 10 Jul 2019 21:17:49 +0000 (GMT) Date: Wed, 10 Jul 2019 21:51:00 -0000 From: Michael Meissner To: Michael Meissner Cc: gcc-patches@gcc.gnu.org, segher@kernel.crashing.org, dje.gcc@gmail.com Subject: [PATCH], PowerPC, Patch #6, revision 2, Create pc-relative addressing insns 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> <20190709223000.GA18842@ibm-toto.the-meissners.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190709223000.GA18842@ibm-toto.the-meissners.org> User-Agent: Mutt/1.5.21 (2010-09-15) x-cbid: 19071021-2213-0000-0000-000003AC28A1 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011405; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000286; SDB=6.01230325; UDB=6.00648026; IPR=6.01011594; MB=3.00027671; MTD=3.00000008; XFM=3.00000015; UTC=2019-07-10 21:17:52 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19071021-2214-0000-0000-00005F2E3A23 Message-Id: <20190710211748.GA18544@ibm-toto.the-meissners.org> X-SW-Source: 2019-07/txt/msg00839.txt.bz2 Here is the revision of patch #6. Changes from the previous version of the patch: 1) I provided separate get_TOC_alias_set and get_pc_relative_alias_set functions, and changed all of the places that had been changed to call get_data_alias_set to revert to calling get_TOC_alias_set. 2) I added an assert in create_TOC_reference to guard against being called with pc-relative addressing. 3) In the other places that check for TOC handling, I added tests to skip the TOC handling if we are generating pc-relative code. 4) I added code in rs6000_emit_move to handle the local SYMBOL_REFs when pc-relative moves are handled, as well as the constants that were created. 5) I simplified some of the code that set up prefixed addressing since we already created a valid address when the constant was forced to memory. I realized that I didn't have to check whether the SYMBOL_REF was within the constant pool with pc-relative addressing, I just had to check if it was a local label and medium code model. I have bootstrapped this on a little endian power8 system and there were no regressions in the test suite. Can I check this into the trunk? 2019-07-10 Michael Meissner * config/rs6000/rs6000-protos.h (get_pc_relative_alias_set): New declaration. * config/rs6000/rs6000.c (create_TOC_reference): Add gcc_assert. (toc_relative_expr_p): Add pc-relative check. (rs6000_legitimize_address): Add pc-relative check in TOC code. (rs6000_emit_move): Add support for loading up the addresses and constants with pc-relative addressing. (TOC_alias_set): Rename static variable from 'set'. (get_TOC_alias_set): Use TOC_alias_set. (pc_relative_alias_set): New static variable. (get_pc_relative_alias_set): New function. * config/rs6000/rs6000.md (cmp_internal2): Add support for pc-relative addressing. Index: gcc/config/rs6000/rs6000-protos.h =================================================================== --- gcc/config/rs6000/rs6000-protos.h (revision 273361) +++ gcc/config/rs6000/rs6000-protos.h (working copy) @@ -190,6 +190,7 @@ extern void output_function_profiler (FI extern void output_profile_hook (int); extern int rs6000_trampoline_size (void); extern alias_set_type get_TOC_alias_set (void); +extern alias_set_type get_pc_relative_alias_set (void); extern void rs6000_emit_prologue (void); extern void rs6000_emit_load_toc_table (int); extern unsigned int rs6000_dbx_register_number (unsigned int, unsigned int); Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 273363) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -7740,6 +7740,8 @@ create_TOC_reference (rtx symbol, rtx la { rtx tocrel, tocreg, hi; + gcc_assert (TARGET_TOC && !TARGET_PCREL); + if (TARGET_DEBUG_ADDR) { if (SYMBOL_REF_P (symbol)) @@ -7785,7 +7787,7 @@ bool toc_relative_expr_p (const_rtx op, bool strict, const_rtx *tocrel_base_ret, const_rtx *tocrel_offset_ret) { - if (!TARGET_TOC) + if (!TARGET_TOC || TARGET_PCREL) return false; if (TARGET_CMODEL != CMODEL_SMALL) @@ -8137,7 +8139,7 @@ rs6000_legitimize_address (rtx x, rtx ol emit_insn (gen_macho_high (reg, x)); return gen_rtx_LO_SUM (Pmode, reg, x); } - else if (TARGET_TOC + else if (TARGET_TOC && !TARGET_PCREL && SYMBOL_REF_P (x) && constant_pool_expr_p (x) && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (x), Pmode)) @@ -9865,10 +9867,18 @@ rs6000_emit_move (rtx dest, rtx source, /* If this is a SYMBOL_REF that refers to a constant pool entry, and we have put it in the TOC, we just need to make a TOC-relative reference to it. */ - if (TARGET_TOC + if (TARGET_TOC && !TARGET_PCREL && SYMBOL_REF_P (operands[1]) && use_toc_relative_ref (operands[1], mode)) operands[1] = create_TOC_reference (operands[1], operands[0]); + + /* If this is a SYMBOL_REF that we refer to via pc-relative addressing, + we don't have to do any special for it. */ + else if (TARGET_PCREL && SYMBOL_REF_P (operands[1]) + && TARGET_CMODEL == CMODEL_MEDIUM + && SYMBOL_REF_LOCAL_P (operands[1])) + ; + else if (mode == Pmode && CONSTANT_P (operands[1]) && GET_CODE (operands[1]) != HIGH @@ -9919,7 +9929,7 @@ rs6000_emit_move (rtx dest, rtx source, operands[1] = force_const_mem (mode, operands[1]); - if (TARGET_TOC + if (TARGET_TOC && !TARGET_PCREL && SYMBOL_REF_P (XEXP (operands[1], 0)) && use_toc_relative_ref (XEXP (operands[1], 0), mode)) { @@ -9928,6 +9938,11 @@ rs6000_emit_move (rtx dest, rtx source, operands[1] = gen_const_mem (mode, tocref); set_mem_alias_set (operands[1], get_TOC_alias_set ()); } + + else if (TARGET_PCREL && SYMBOL_REF_P (XEXP (operands[1], 0)) + && TARGET_CMODEL == CMODEL_MEDIUM + && SYMBOL_REF_LOCAL_P (XEXP (operands[1], 0))) + set_mem_alias_set (operands[1], get_pc_relative_alias_set ()); } break; @@ -23732,14 +23747,26 @@ rs6000_split_multireg_move (rtx dst, rtx } } -static GTY(()) alias_set_type set = -1; +/* Alias set for constants accessed via the TOC. */ +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; +} + +/* Alias set for constants accessed via the pc-relative addressing. */ +static GTY(()) alias_set_type pc_relative_alias_set = -1; + +alias_set_type +get_pc_relative_alias_set (void) +{ + if (pc_relative_alias_set == -1) + pc_relative_alias_set = new_alias_set (); + return pc_relative_alias_set; } /* Return the internal arg pointer used for function incoming Index: gcc/config/rs6000/rs6000.md =================================================================== --- gcc/config/rs6000/rs6000.md (revision 273361) +++ gcc/config/rs6000/rs6000.md (working copy) @@ -11606,7 +11606,7 @@ (define_insn_and_split "*cmp_inter operands[15] = force_const_mem (DFmode, const_double_from_real_value (dconst0, DFmode)); - if (TARGET_TOC) + if (TARGET_TOC && !TARGET_PCREL) { rtx tocref; tocref = create_TOC_reference (XEXP (operands[14], 0), operands[11]); @@ -11616,6 +11616,12 @@ (define_insn_and_split "*cmp_inter set_mem_alias_set (operands[14], get_TOC_alias_set ()); set_mem_alias_set (operands[15], get_TOC_alias_set ()); } + + else if (TARGET_PCREL) + { + set_mem_alias_set (operands[14], get_pc_relative_alias_set ()); + set_mem_alias_set (operands[15], get_pc_relative_alias_set ()); + } }) ;; Now we have the scc insns. We can do some combinations because of the -- Michael Meissner, IBM IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA email: meissner@linux.ibm.com, phone: +1 (978) 899-4797