From patchwork Thu Sep 26 18:57:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 1168106 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-509662-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sandoe.co.uk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="CcgLPyV7"; 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 46fPM76Pkcz9sP3 for ; Fri, 27 Sep 2019 04:57:53 +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 :content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; q=dns; s= default; b=k7ZXzpanNa+2132CB9PHo2707ved8tpTCrhQSQbLtMMcgwZImbam+ 6nO0tMYao90HSjUJ1yghPcj0lWbHHKy+Oif6+MLtLnAFKErHGXP7zBsrSnlUuhFI aZw14L8MTT4OfpBiPSOjkQ6+ZnCDCyo+o5+eluKm9pQSIS/QghCzRQ= 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 :content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; s=default; bh=9XRk8ZMLMl4lZ+KsTH7BchTKshA=; b=CcgLPyV7wE9lb7MZeFrd4yJgTq4Y XM/eB3HOFCVG/VJ++VJirkL8wB7BcFsqCctSUJADxTqapdDQDihC7pcKuMvZwyxk vGtg8Ei6Bmf4rfOcFM+Und8dxPdm208QdqJx8ix5pax8WOPnkiCmvmFaDUjjDCQQ jdqx/Bqp/tGZRTM= Received: (qmail 15350 invoked by alias); 26 Sep 2019 18:57:45 -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 15337 invoked by uid 89); 26 Sep 2019 18:57:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_COUK, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=rs6000md, UD:rs6000.md, rs6000.md, voidmode X-HELO: smtp1.wavenetuk.net Received: from smtp.wavenetuk.net (HELO smtp1.wavenetuk.net) (195.26.36.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 26 Sep 2019 18:57:43 +0000 Received: from [192.168.1.212] (host81-138-1-83.in-addr.btopenworld.com [81.138.1.83]) by smtp1.wavenetuk.net (Postfix) with ESMTPA id 818991200323; Thu, 26 Sep 2019 19:57:40 +0100 (BST) Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [Darwin, PPC, Mode Iterators 2/n] Eliminate picbase expanders. From: Iain Sandoe In-Reply-To: <20190924232333.GP9749@gate.crashing.org> Date: Thu, 26 Sep 2019 19:57:38 +0100 Cc: GCC Patches Message-Id: References: <20190924232333.GP9749@gate.crashing.org> To: Segher Boessenkool Hi Segher, thanks for the pointers to how to simplify this! > On 25 Sep 2019, at 00:23, Segher Boessenkool wrote: > On Tue, Sep 24, 2019 at 08:31:16PM +0100, Iain Sandoe wrote: >> This switches the picbase load and reload patterns to use the 'P' mode >> iterator instead of writing an SI and DI pattern for each (and deletes the >> old patterns). No functional change intended. > >> (define_expand "load_macho_picbase" >> - [(set (reg:SI LR_REGNO) >> + [(set (reg LR_REGNO) > > This changes it to VOIDmode instead? It should have been reg:P LR_REGNO? > >> (define_expand "reload_macho_picbase" >> - [(set (reg:SI LR_REGNO) >> + [(set (reg LR_REGNO) > > Same here. As we discussed this is symptomatic of the fact that the expanders only exist in this to pass the mode through. We can eliminate them completely by using an “@pattern” in the actual patterns (and updating callers to pass the mode as the first argument). tested on powerpc-darwin9, powerpc64-linux-gnu (m32, m64) applied to mainline, thanks Iain gcc/ChangeLog: 2019-09-26 Iain Sandoe * config/rs6000/darwin.md: Replace the expanders for load_macho_picbase and reload_macho_picbase with use of '@' in their respective define_insns. (nonlocal_goto_receiver): Pass Pmode to gen_reload_macho_picbase. * config/rs6000/rs6000-logue.c (rs6000_emit_prologue): Pass Pmode to gen_load_macho_picbase. * config/rs6000/rs6000.md: Likewise. diff --git a/gcc/config/rs6000/darwin.md b/gcc/config/rs6000/darwin.md index 4a284211af..a5c5a3af39 100644 --- a/gcc/config/rs6000/darwin.md +++ b/gcc/config/rs6000/darwin.md @@ -216,21 +216,7 @@ You should have received a copy of the GNU General Public License (match_dup 2))] "") -(define_expand "load_macho_picbase" - [(set (reg LR_REGNO) - (unspec [(match_operand 0 "")] - UNSPEC_LD_MPIC))] - "(DEFAULT_ABI == ABI_DARWIN) && flag_pic" -{ - if (TARGET_32BIT) - emit_insn (gen_load_macho_picbase_si (operands[0])); - else - emit_insn (gen_load_macho_picbase_di (operands[0])); - - DONE; -}) - -(define_insn "load_macho_picbase_" +(define_insn "@load_macho_picbase_" [(set (reg:P LR_REGNO) (unspec:P [(match_operand:P 0 "immediate_operand" "s") (pc)] UNSPEC_LD_MPIC))] @@ -284,21 +270,7 @@ You should have received a copy of the GNU General Public License "addis %0,%1,ha16(%2-%3)\n\taddi %0,%0,lo16(%2-%3)" [(set_attr "length" "8")]) -(define_expand "reload_macho_picbase" - [(set (reg LR_REGNO) - (unspec [(match_operand 0 "")] - UNSPEC_RELD_MPIC))] - "(DEFAULT_ABI == ABI_DARWIN) && flag_pic" -{ - if (TARGET_32BIT) - emit_insn (gen_reload_macho_picbase_si (operands[0])); - else - emit_insn (gen_reload_macho_picbase_di (operands[0])); - - DONE; -}) - -(define_insn "reload_macho_picbase_" +(define_insn "@reload_macho_picbase_" [(set (reg:P LR_REGNO) (unspec:P [(match_operand:P 0 "immediate_operand" "s") (pc)] UNSPEC_RELD_MPIC))] @@ -342,7 +314,7 @@ You should have received a copy of the GNU General Public License ASM_GENERATE_INTERNAL_LABEL(tmplab, "Lnlgr", ++n); tmplrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (tmplab)); - emit_insn (gen_reload_macho_picbase (tmplrtx)); + emit_insn (gen_reload_macho_picbase (Pmode, tmplrtx)); emit_move_insn (picreg, gen_rtx_REG (Pmode, LR_REGNO)); emit_insn (gen_macho_correct_pic (picreg, picreg, picrtx, tmplrtx)); } diff --git a/gcc/config/rs6000/rs6000-logue.c b/gcc/config/rs6000/rs6000-logue.c index 633a253e43..e98893a440 100644 --- a/gcc/config/rs6000/rs6000-logue.c +++ b/gcc/config/rs6000/rs6000-logue.c @@ -3809,7 +3809,7 @@ rs6000_emit_prologue (void) if (!info->lr_save_p) emit_move_insn (gen_rtx_REG (Pmode, 0), lr); - emit_insn (gen_load_macho_picbase (src)); + emit_insn (gen_load_macho_picbase (Pmode, src)); emit_move_insn (gen_rtx_REG (Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM), diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index 4dbf85bbc9..c5443bab9e 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -10053,7 +10053,7 @@ CODE_LABEL_NUMBER (operands[0])); tmplabrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (tmplab)); - emit_insn (gen_load_macho_picbase (tmplabrtx)); + emit_insn (gen_load_macho_picbase (Pmode, tmplabrtx)); emit_move_insn (picreg, gen_rtx_REG (Pmode, LR_REGNO)); emit_insn (gen_macho_correct_pic (picreg, picreg, picrtx, tmplabrtx)); }