From patchwork Fri Jun 28 18:50:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Meissner X-Patchwork-Id: 1124463 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-503999-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="sY9TtfXd"; 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 45b5SX4Lk9z9s3Z for ; Sat, 29 Jun 2019 04:50:51 +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:references:mime-version:content-type :in-reply-to:message-id; q=dns; s=default; b=PMobipsBf74f9LKDbVk GrtXiBU+6qzLmOUoQ0LR6GhZdwBVqWEDWVUu8yAHcsOk3Q0Mp4lOx2QVlKsCi0OV 3qGhISgJfIx4qjmr32/6s3xCyDMucC4Ccx3cX9xNZmF/trBj0Wmar2X+46ZiAndT zuVConE6RwJ/13uMkgVI372s= 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:references:mime-version:content-type :in-reply-to:message-id; s=default; bh=VweVvq/mNKUkOHFHS9aJcYvgQ pE=; b=sY9TtfXdnPrzHW+rzhGmErR/VkmNiQ6IotvKSFt2TDA5/Tb4HOgyQSoIQ JzEtXlMlRK+610+0CBhX140DodF9NzGzxMqXakyRGWRCFRfs05ivBtfjozSGc7Rj SYVE1Hh3dbvyABlGrUt+u036FyQtP8d98uV+18qdHtb0afYimk= Received: (qmail 69209 invoked by alias); 28 Jun 2019 18:50:44 -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 69201 invoked by uid 89); 28 Jun 2019 18:50:44 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_STOCKGEN, KHOP_DYNAMIC, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=recognizes 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; Fri, 28 Jun 2019 18:50:42 +0000 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5SIkUph001331 for ; Fri, 28 Jun 2019 14:50:39 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0a-001b2d01.pphosted.com with ESMTP id 2tdrefr672-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 28 Jun 2019 14:50:39 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 28 Jun 2019 19:50:38 +0100 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 28 Jun 2019 19:50:36 +0100 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x5SIoZvF58851830 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Jun 2019 18:50:36 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E21A2C605A; Fri, 28 Jun 2019 18:50:35 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 63C2CC605D; Fri, 28 Jun 2019 18:50:35 +0000 (GMT) Received: from ibm-toto.the-meissners.org (unknown [9.32.77.177]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTPS; Fri, 28 Jun 2019 18:50:35 +0000 (GMT) Date: Fri, 28 Jun 2019 14:50:33 -0400 From: Michael Meissner To: Michael Meissner , gcc-patches@gcc.gnu.org, segher@kernel.crashing.org, dje.gcc@gmail.com Subject: [PATCH] PowerPC Prefixed Memory, Patch #4, Add pc-relative reference support 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) x-cbid: 19062818-0004-0000-0000-0000152217C0 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011348; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000286; SDB=6.01224597; UDB=6.00644546; IPR=6.01005790; MB=3.00027511; MTD=3.00000008; XFM=3.00000015; UTC=2019-06-28 18:50:38 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19062818-0005-0000-0000-00008C41EC95 Message-Id: <20190628185033.GA32553@ibm-toto.the-meissners.org> At the moment, we have two functions that create and look at TOC references: create_TOC_reference (global function) use_toc_relative_ref (static function in rs6000.c) Since I am adding pc-relative support that will be used instead of TOC support, this patch renames these two functions to be: create_data_reference use_toc_or_pc_relative_ref and it adds some of the foundation for adding pc-relative support. Note, it will need future patches to completely flesh out the pc-relative support. As per a previous private discussion, I kept the old create_TOC_reference and added a gcc assert if it is called when pc-relative addressing is used. There is currently one place that still calls create_TOC_reference (in a section using TLS addresses). I have done a bootstrap on a power8 little endian Linux system with no regressions. Can I check this into the trunk? 2019-06-28 Michael Meissner * config/rs6000/rs6000-logue.c (create_TOC_reference): Move debug statements to create_data_reference. Add gcc_assert to make sure we are using TOCs and not pc-relative addressing. (create_data_reference): New function, create either a TOC style reference or a pc-relative reference to local symbols. * config/rs6000/rs6000-protos.h (create_data_reference): Add declaration. * config/rs6000/rs6000.c (rs6000_legitimize_address): Call create_data_reference instead of create_TOC_reference. (use_toc_or_pc_relative_ref): Rename from use_toc_relative_ref and add support for pc-relative addressing. (rs6000_emit_move): Call use_toc_or_pc_relative_ref and create_data_reference instead of use_toc_relative_ref and create_TOC_reference. * config/rs6000/rs6000.md (cmp_internal2): Call create_data_reference instead of create_TOC_reference. Index: gcc/config/rs6000/rs6000-logue.c =================================================================== --- gcc/config/rs6000/rs6000-logue.c (revision 272714) +++ gcc/config/rs6000/rs6000-logue.c (working copy) @@ -1406,23 +1406,13 @@ uses_TOC (void) } #endif +/* Create a TOC style reference for a symbol. */ rtx create_TOC_reference (rtx symbol, rtx largetoc_reg) { rtx tocrel, tocreg, hi; - if (TARGET_DEBUG_ADDR) - { - if (SYMBOL_REF_P (symbol)) - fprintf (stderr, "\ncreate_TOC_reference, (symbol_ref %s)\n", - XSTR (symbol, 0)); - else - { - fprintf (stderr, "\ncreate_TOC_reference, code %s:\n", - GET_RTX_NAME (GET_CODE (symbol))); - debug_rtx (symbol); - } - } + gcc_assert (TARGET_TOC && !TARGET_PCREL); if (!can_create_pseudo_p ()) df_set_regs_ever_live (TOC_REGISTER, true); @@ -1441,6 +1431,39 @@ create_TOC_reference (rtx symbol, rtx la return gen_rtx_LO_SUM (Pmode, hi, tocrel); } +/* Create either a TOC reference to a locally defined item or a pc-relative + reference, depending on the ABI. */ +rtx +create_data_reference (rtx symbol, rtx largetoc_reg) +{ + if (TARGET_DEBUG_ADDR) + { + const char *toc_or_pcrel = (TARGET_PCREL) ? "pc-relative" : "TOC"; + + if (SYMBOL_REF_P (symbol)) + fprintf (stderr, "\ncreate_data_reference, abi %s, (symbol_ref %s)\n", + toc_or_pcrel, XSTR (symbol, 0)); + else + { + fprintf (stderr, "\ncreate_data_reference, abi %s, code %s:\n", + toc_or_pcrel, GET_RTX_NAME (GET_CODE (symbol))); + debug_rtx (symbol); + } + } + + /* We don't have to do anything special for pc-relative references. The + SYMBOL_REF bits sayss whether the label is local where we can use + pc-relative addressing, or if we have to load the address from the GOT + section to use it on external addresses. */ + if (TARGET_PCREL) + { + gcc_assert (TARGET_CMODEL == CMODEL_MEDIUM); + return symbol; + } + + return create_TOC_reference (symbol, largetoc_reg); +} + /* Issue assembly directives that create a reference to the given DWARF FRAME_TABLE_LABEL from the current function section. */ void Index: gcc/config/rs6000/rs6000-protos.h =================================================================== --- gcc/config/rs6000/rs6000-protos.h (revision 272714) +++ gcc/config/rs6000/rs6000-protos.h (working copy) @@ -131,6 +131,7 @@ extern void rs6000_emit_swdiv (rtx, rtx, extern void rs6000_emit_swsqrt (rtx, rtx, bool); extern void output_toc (FILE *, rtx, int, machine_mode); extern void rs6000_fatal_bad_address (rtx); +extern rtx create_data_reference (rtx, rtx); extern rtx create_TOC_reference (rtx, rtx); extern void rs6000_split_multireg_move (rtx, rtx); extern void rs6000_emit_le_vsx_permute (rtx, rtx, machine_mode); Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 272766) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -8084,7 +8084,7 @@ rs6000_legitimize_address (rtx x, rtx ol && SYMBOL_REF_P (x) && constant_pool_expr_p (x) && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (x), Pmode)) - return create_TOC_reference (x, NULL_RTX); + return create_data_reference (x, NULL_RTX); else return x; } @@ -8696,19 +8696,21 @@ rs6000_cannot_force_const_mem (machine_m return TARGET_ELF && tls_referenced_p (x); } -/* Return true iff the given SYMBOL_REF refers to a constant pool entry - that we have put in the TOC, or for cmodel=medium, if the SYMBOL_REF - can be addressed relative to the toc pointer. */ +/* Return true iff the given SYMBOL_REF refers to a constant pool entry that we + have put in the TOC or is referenced via a pc-relative reference. In + addition, for cmodel=medium, if the SYMBOL_REF can be addressed relative to + the either toc pointer or via a pc-relative reference. */ static bool -use_toc_relative_ref (rtx sym, machine_mode mode) +use_toc_or_pc_relative_ref (rtx sym, machine_mode mode) { return ((constant_pool_expr_p (sym) && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (sym), get_pool_mode (sym))) || (TARGET_CMODEL == CMODEL_MEDIUM && SYMBOL_REF_LOCAL_P (sym) - && GET_MODE_SIZE (mode) <= POWERPC64_TOC_POINTER_ALIGNMENT)); + && (TARGET_PCREL + || GET_MODE_SIZE (mode) <= POWERPC64_TOC_POINTER_ALIGNMENT))); } /* TARGET_LEGITIMATE_ADDRESS_P recognizes an RTL expression @@ -9810,8 +9812,8 @@ rs6000_emit_move (rtx dest, rtx source, reference to it. */ if (TARGET_TOC && SYMBOL_REF_P (operands[1]) - && use_toc_relative_ref (operands[1], mode)) - operands[1] = create_TOC_reference (operands[1], operands[0]); + && use_toc_or_pc_relative_ref (operands[1], mode)) + operands[1] = create_data_reference (operands[1], operands[0]); else if (mode == Pmode && CONSTANT_P (operands[1]) && GET_CODE (operands[1]) != HIGH @@ -9864,11 +9866,11 @@ rs6000_emit_move (rtx dest, rtx source, if (TARGET_TOC && SYMBOL_REF_P (XEXP (operands[1], 0)) - && use_toc_relative_ref (XEXP (operands[1], 0), mode)) + && use_toc_or_pc_relative_ref (XEXP (operands[1], 0), mode)) { - rtx tocref = create_TOC_reference (XEXP (operands[1], 0), - operands[0]); - operands[1] = gen_const_mem (mode, tocref); + rtx dataref = create_data_reference (XEXP (operands[1], 0), + operands[0]); + operands[1] = gen_const_mem (mode, dataref); set_mem_alias_set (operands[1], get_TOC_alias_set ()); } } Index: gcc/config/rs6000/rs6000.md =================================================================== --- gcc/config/rs6000/rs6000.md (revision 272757) +++ gcc/config/rs6000/rs6000.md (working copy) @@ -11666,9 +11666,9 @@ (define_insn_and_split "*cmp_inter if (TARGET_TOC) { rtx tocref; - tocref = create_TOC_reference (XEXP (operands[14], 0), operands[11]); + tocref = create_data_reference (XEXP (operands[14], 0), operands[11]); operands[14] = gen_const_mem (DFmode, tocref); - tocref = create_TOC_reference (XEXP (operands[15], 0), operands[11]); + tocref = create_data_reference (XEXP (operands[15], 0), operands[11]); operands[15] = gen_const_mem (DFmode, tocref); set_mem_alias_set (operands[14], get_TOC_alias_set ()); set_mem_alias_set (operands[15], get_TOC_alias_set ());