From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 57156 invoked by alias); 3 Dec 2018 19:14:48 -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 57138 invoked by uid 89); 3 Dec 2018 19:14:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.6 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_COUK,KAM_LAZY_DOMAIN_SECURITY,KAM_STOCKGEN autolearn=ham version=3.3.2 spammy=H*c:MHil, sk:amodra, sk:amodra@, amodra@gmail.com X-HELO: smtp2.wavenetuk.net Received: from smtp2.wavenetuk.net (HELO smtp2.wavenetuk.net) (195.26.37.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 03 Dec 2018 19:14:42 +0000 Received: from euterpe-sie.home (host81-138-1-83.in-addr.btopenworld.com [81.138.1.83]) by smtp2.wavenetuk.net (Postfix) with ESMTPA id 7BE9B6000FA; Mon, 3 Dec 2018 19:14:39 +0000 (GMT) From: Iain Sandoe Message-Id: <9A0F79A5-AA3F-468B-857E-42007BF6AB53@sandoe.co.uk> Content-Type: multipart/mixed; boundary="Apple-Mail=_F845A936-D7FD-4163-9957-6B26A8BAE729" Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: [Patch, ppc/darwin 1/2] Fix bootstrap. Date: Mon, 03 Dec 2018 19:14:00 -0000 In-Reply-To: <20181203061841.GA29034@bubble.grove.modra.org> Cc: GCC-patches , Segher Boessenkool To: Alan Modra References: <20181203061841.GA29034@bubble.grove.modra.org> X-SW-Source: 2018-12/txt/msg00114.txt.bz2 --Apple-Mail=_F845A936-D7FD-4163-9957-6B26A8BAE729 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Content-length: 2572 > On 3 Dec 2018, at 06:18, Alan Modra wrote: >=20 > On Mon, Dec 03, 2018 at 01:26:48AM +0000, Iain Sandoe wrote: >> The first patch makes Darwin share the sysv lowering, up until late in t= he process when we still use the macho_call_template. This means we need t= o preserve the CALL_LONG flag for Darwin. >>=20 >> In order to match this for Darwin64, the sysv patterns needed the clobbe= r mode to follow that of the pattern. It seems that this might be a typo -= since it=E2=80=99s not obvious how it would work for powerpc64 sysv as thi= ngs stand (AIX and ELFv2 already follow the mode). >=20 > Hmm, yes, and I think there may be some more modes to fix. > call_local64, call_value_local64, call_nonlocal_sysv splitter, > call_value_nonlocal_sysv splitter, call_value_nonlocal_sysv_secure. I=E2=80=99m slightly twitchy about patches I can=E2=80=99t fully test .. =E2=80=A6 but >=20 >> ;; Call and call_value insns >> +;; For the purposes of expanding calls, Darwin is very similar to SYSV. >> (define_expand "call" >> [(parallel [(call (mem:SI (match_operand 0 "address_operand")) >> (match_operand 1 "")) >> @@ -10288,7 +10289,7 @@ >> DONE; >> } >>=20 >> - if (DEFAULT_ABI =3D=3D ABI_V4) >> + if (DEFAULT_ABI =3D=3D ABI_V4 || DEFAULT_ABI =3D=3D ABI_DARWIN) >=20 > Better yet, replace this line with "else" and tidy a little. There's > some dead code and the "DONE" can move out of the conditional blocks. >=20 >> { >> rs6000_call_sysv (NULL_RTX, operands[0], operands[1], operands[2]); >> DONE; >=20 >=20 >> @@ -10321,7 +10322,7 @@ >> DONE; >> } >>=20 >> - if (DEFAULT_ABI =3D=3D ABI_V4) >> + if (DEFAULT_ABI =3D=3D ABI_V4 || DEFAULT_ABI =3D=3D ABI_DARWIN) >=20 > Similarly here, >=20 >> @@ -10765,7 +10766,7 @@ >> DONE; >> } >>=20 >> - if (DEFAULT_ABI =3D=3D ABI_V4) >> + if (DEFAULT_ABI =3D=3D ABI_V4 || DEFAULT_ABI =3D=3D ABI_DARWIN) >=20 > and here, >=20 >> { >> rs6000_sibcall_sysv (NULL_RTX, operands[0], operands[1], operands[= 2]); >> DONE; >> @@ -10796,7 +10797,7 @@ >> DONE; >> } >>=20 >> - if (DEFAULT_ABI =3D=3D ABI_V4) >> + if (DEFAULT_ABI =3D=3D ABI_V4 || DEFAULT_ABI =3D=3D ABI_DARWIN) >=20 > and here. >=20 >> { >> rs6000_sibcall_sysv (operands[0], operands[1], operands[2], operan= ds[3]); >> DONE; >> --=20 >> 2.17.1 those are nice tidyups - done. as attached.. bootstrapped w/out issues on gcc110 (Darwin will take a longer to regstrap)= .. Iain >>=20 >=20 > --=20 > Alan Modra > Australia Development Lab, IBM --Apple-Mail=_F845A936-D7FD-4163-9957-6B26A8BAE729 Content-Disposition: attachment; filename=darwin-ppc-calls-1-of-2-v2.txt Content-Type: text/plain; x-unix-mode=0644; name="darwin-ppc-calls-1-of-2-v2.txt" Content-Transfer-Encoding: quoted-printable Content-length: 10408 =46rom 3e9b487495807f1ba5c6709785536176b6540fd1 Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Fri, 30 Nov 2018 09:10:43 +0000 Subject: [PATCH] [PATCH,PPC] Fix up revised call handling for Darwin. --- gcc/config/rs6000/darwin.md | 60 ----------------------------- gcc/config/rs6000/rs6000.c | 13 +++++-- gcc/config/rs6000/rs6000.md | 75 +++++++++++++------------------------ 3 files changed, 35 insertions(+), 113 deletions(-) diff --git a/gcc/config/rs6000/darwin.md b/gcc/config/rs6000/darwin.md index a1c07702d6..ff8062c110 100644 --- a/gcc/config/rs6000/darwin.md +++ b/gcc/config/rs6000/darwin.md @@ -300,66 +300,6 @@ You should have received a copy of the GNU General Pub= lic License "addis %0,%1,ha16(%2-%3)\n\taddi %0,%0,lo16(%2-%3)" [(set_attr "length" "8")]) =20 -(define_insn "*call_indirect_nonlocal_darwin64" - [(call (mem:SI (match_operand:DI 0 "register_operand" "c,*l,c,*l")) - (match_operand 1)) - (use (match_operand:SI 2 "immediate_operand" "O,O,n,n")) - (clobber (reg:SI LR_REGNO))] - "DEFAULT_ABI =3D=3D ABI_DARWIN && TARGET_64BIT" -{ - return "b%T0l"; -} - [(set_attr "type" "jmpreg,jmpreg,jmpreg,jmpreg") - (set_attr "length" "4,4,8,8")]) - -(define_insn "*call_nonlocal_darwin64" - [(call (mem:SI (match_operand:DI 0 "symbol_ref_operand" "s,s")) - (match_operand 1)) - (use (match_operand:SI 2 "immediate_operand" "O,n")) - (clobber (reg:SI LR_REGNO))] - "(DEFAULT_ABI =3D=3D ABI_DARWIN) - && (INTVAL (operands[2]) & CALL_LONG) =3D=3D 0" -{ -#if TARGET_MACHO - return output_call(insn, operands, 0, 2); -#else - gcc_unreachable (); -#endif -} - [(set_attr "type" "branch,branch") - (set_attr "length" "4,8")]) - -(define_insn "*call_value_indirect_nonlocal_darwin64" - [(set (match_operand 0 "" "") - (call (mem:SI (match_operand:DI 1 "register_operand" "c,*l,c,*l")) - (match_operand 2))) - (use (match_operand:SI 3 "immediate_operand" "O,O,n,n")) - (clobber (reg:SI LR_REGNO))] - "DEFAULT_ABI =3D=3D ABI_DARWIN" -{ - return "b%T1l"; -} - [(set_attr "type" "jmpreg,jmpreg,jmpreg,jmpreg") - (set_attr "length" "4,4,8,8")]) - -(define_insn "*call_value_nonlocal_darwin64" - [(set (match_operand 0 "" "") - (call (mem:SI (match_operand:DI 1 "symbol_ref_operand" "s,s")) - (match_operand 2))) - (use (match_operand:SI 3 "immediate_operand" "O,n")) - (clobber (reg:SI LR_REGNO))] - "(DEFAULT_ABI =3D=3D ABI_DARWIN) - && (INTVAL (operands[3]) & CALL_LONG) =3D=3D 0" -{ -#if TARGET_MACHO - return output_call(insn, operands, 1, 3); -#else - gcc_unreachable (); -#endif -} - [(set_attr "type" "branch,branch") - (set_attr "length" "4,8")]) - (define_expand "reload_macho_picbase" [(set (reg:SI LR_REGNO) (unspec [(match_operand 0 "")] diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 03b983b6d6..bce968516c 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -21513,7 +21513,8 @@ rs6000_call_template_1 (rtx *operands, unsigned int= funop, bool sibcall) ? "+32768" : "")); =20 static char str[32]; /* 2 spare */ - if (DEFAULT_ABI =3D=3D ABI_AIX || DEFAULT_ABI =3D=3D ABI_ELFv2) + if (DEFAULT_ABI =3D=3D ABI_AIX || DEFAULT_ABI =3D=3D ABI_ELFv2 + || DEFAULT_ABI =3D=3D ABI_DARWIN) sprintf (str, "b%s %s%s%s", sibcall ? "" : "l", z, arg, sibcall ? "" : "\n\tnop"); else if (DEFAULT_ABI =3D=3D ABI_V4) @@ -37937,6 +37938,7 @@ rs6000_call_sysv (rtx value, rtx func_desc, rtx tls= arg, rtx cookie) =20 /* Handle longcall attributes. */ if ((INTVAL (cookie) & CALL_LONG) !=3D 0 + && DEFAULT_ABI !=3D ABI_DARWIN /* Darwin does it's own thing. */ && GET_CODE (func_desc) =3D=3D SYMBOL_REF) { func =3D rs6000_longcall_ref (func_desc, tlsarg); @@ -37977,8 +37979,13 @@ rs6000_call_sysv (rtx value, rtx func_desc, rtx tl= sarg, rtx cookie) if (value !=3D NULL_RTX) call[0] =3D gen_rtx_SET (value, call[0]); =20 - unsigned int mask =3D CALL_V4_SET_FP_ARGS | CALL_V4_CLEAR_FP_ARGS; - call[1] =3D gen_rtx_USE (VOIDmode, GEN_INT (INTVAL (cookie) & mask)); + if (DEFAULT_ABI =3D=3D ABI_DARWIN && TARGET_32BIT) + call[1] =3D gen_rtx_USE (VOIDmode, GEN_INT (INTVAL (cookie))); + else + { + unsigned int mask =3D CALL_V4_SET_FP_ARGS | CALL_V4_CLEAR_FP_ARGS; + call[1] =3D gen_rtx_USE (VOIDmode, GEN_INT (INTVAL (cookie) & mask)); + } =20 call[2] =3D gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (Pmode, LR_REGNO)); =20 diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index 797d5c32e6..f84b09b35a 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -10266,6 +10266,7 @@ }) =0C ;; Call and call_value insns +;; For the purposes of expanding calls, Darwin is very similar to SYSV. (define_expand "call" [(parallel [(call (mem:SI (match_operand 0 "address_operand")) (match_operand 1 "")) @@ -10283,19 +10284,11 @@ operands[0] =3D XEXP (operands[0], 0); =20 if (DEFAULT_ABI =3D=3D ABI_AIX || DEFAULT_ABI =3D=3D ABI_ELFv2) - { - rs6000_call_aix (NULL_RTX, operands[0], operands[1], operands[2]); - DONE; - } - - if (DEFAULT_ABI =3D=3D ABI_V4) - { - rs6000_call_sysv (NULL_RTX, operands[0], operands[1], operands[2]); - DONE; - } + rs6000_call_aix (NULL_RTX, operands[0], operands[1], operands[2]); + else + rs6000_call_sysv (NULL_RTX, operands[0], operands[1], operands[2]); =20 - if (GET_CODE (operands[0]) !=3D SYMBOL_REF) - operands[0] =3D force_reg (Pmode, operands[0]); + DONE; }) =20 (define_expand "call_value" @@ -10316,19 +10309,11 @@ operands[1] =3D XEXP (operands[1], 0); =20 if (DEFAULT_ABI =3D=3D ABI_AIX || DEFAULT_ABI =3D=3D ABI_ELFv2) - { - rs6000_call_aix (operands[0], operands[1], operands[2], operands[3]); - DONE; - } - - if (DEFAULT_ABI =3D=3D ABI_V4) - { - rs6000_call_sysv (operands[0], operands[1], operands[2], operands[3]= ); - DONE; - } + rs6000_call_aix (operands[0], operands[1], operands[2], operands[3]); + else + rs6000_call_sysv (operands[0], operands[1], operands[2], operands[3]); =20 - if (GET_CODE (operands[1]) !=3D SYMBOL_REF) - operands[1] =3D force_reg (Pmode, operands[1]); + DONE; }) =20 ;; Call to function in current module. No TOC pointer reload needed. @@ -10359,7 +10344,7 @@ [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"= )) (match_operand 1)) (use (match_operand:SI 2 "immediate_operand" "O,n")) - (clobber (reg:SI LR_REGNO))] + (clobber (reg:DI LR_REGNO))] "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) =3D=3D 0" { if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS) @@ -10398,7 +10383,7 @@ (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s")) (match_operand 2))) (use (match_operand:SI 3 "immediate_operand" "O,n")) - (clobber (reg:SI LR_REGNO))] + (clobber (reg:DI LR_REGNO))] "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) =3D=3D 0" { if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS) @@ -10423,7 +10408,7 @@ [(call (mem:SI (match_operand:P 0 "indirect_call_operand" "c,*l,X")) (match_operand 1)) (use (match_operand:SI 2 "immediate_operand" "n,n,n")) - (clobber (reg:SI LR_REGNO))] + (clobber (reg:P LR_REGNO))] "DEFAULT_ABI =3D=3D ABI_V4 || DEFAULT_ABI =3D=3D ABI_DARWIN" { @@ -10451,7 +10436,7 @@ [(call (mem:SI (match_operand:P 0 "symbol_ref_operand" "s,s")) (match_operand 1)) (use (match_operand:SI 2 "immediate_operand" "O,n")) - (clobber (reg:SI LR_REGNO))] + (clobber (reg:P LR_REGNO))] "(DEFAULT_ABI =3D=3D ABI_DARWIN || (DEFAULT_ABI =3D=3D ABI_V4 && (INTVAL (operands[2]) & CALL_LONG) =3D=3D 0))" @@ -10487,7 +10472,7 @@ (match_operand 1)) (use (match_operand:SI 2 "immediate_operand" "O,n")) (use (match_operand:SI 3 "register_operand" "r,r")) - (clobber (reg:SI LR_REGNO))] + (clobber (reg:P LR_REGNO))] "(DEFAULT_ABI =3D=3D ABI_V4 && TARGET_SECURE_PLT && flag_pic && !SYMBOL_REF_LOCAL_P (operands[0]) && (INTVAL (operands[2]) & CALL_LONG) =3D=3D 0)" @@ -10508,7 +10493,7 @@ (call (mem:SI (match_operand:P 1 "indirect_call_operand" "c,*l,X")) (match_operand 2))) (use (match_operand:SI 3 "immediate_operand" "n,n,n")) - (clobber (reg:SI LR_REGNO))] + (clobber (reg:P LR_REGNO))] "DEFAULT_ABI =3D=3D ABI_V4 || DEFAULT_ABI =3D=3D ABI_DARWIN" { @@ -10537,7 +10522,7 @@ (call (mem:SI (match_operand:P 1 "symbol_ref_operand" "s,s")) (match_operand 2))) (use (match_operand:SI 3 "immediate_operand" "O,n")) - (clobber (reg:SI LR_REGNO))] + (clobber (reg:P LR_REGNO))] "(DEFAULT_ABI =3D=3D ABI_DARWIN || (DEFAULT_ABI =3D=3D ABI_V4 && (INTVAL (operands[3]) & CALL_LONG) =3D=3D 0))" @@ -10575,7 +10560,7 @@ (match_operand 2))) (use (match_operand:SI 3 "immediate_operand" "O,n")) (use (match_operand:SI 4 "register_operand" "r,r")) - (clobber (reg:SI LR_REGNO))] + (clobber (reg:P LR_REGNO))] "(DEFAULT_ABI =3D=3D ABI_V4 && TARGET_SECURE_PLT && flag_pic && !SYMBOL_REF_LOCAL_P (operands[1]) && (INTVAL (operands[3]) & CALL_LONG) =3D=3D 0)" @@ -10760,16 +10745,11 @@ operands[0] =3D XEXP (operands[0], 0); =20 if (DEFAULT_ABI =3D=3D ABI_AIX || DEFAULT_ABI =3D=3D ABI_ELFv2) - { - rs6000_sibcall_aix (NULL_RTX, operands[0], operands[1], operands[2]); - DONE; - } + rs6000_sibcall_aix (NULL_RTX, operands[0], operands[1], operands[2]); + else + rs6000_sibcall_sysv (NULL_RTX, operands[0], operands[1], operands[2]); =20 - if (DEFAULT_ABI =3D=3D ABI_V4) - { - rs6000_sibcall_sysv (NULL_RTX, operands[0], operands[1], operands[2]= ); - DONE; - } + DONE; }) =20 (define_expand "sibcall_value" @@ -10791,16 +10771,11 @@ operands[1] =3D XEXP (operands[1], 0); =20 if (DEFAULT_ABI =3D=3D ABI_AIX || DEFAULT_ABI =3D=3D ABI_ELFv2) - { - rs6000_sibcall_aix (operands[0], operands[1], operands[2], operands[= 3]); - DONE; - } + rs6000_sibcall_aix (operands[0], operands[1], operands[2], operands[3]= ); + else + rs6000_sibcall_sysv (operands[0], operands[1], operands[2], operands[3= ]); =20 - if (DEFAULT_ABI =3D=3D ABI_V4) - { - rs6000_sibcall_sysv (operands[0], operands[1], operands[2], operands= [3]); - DONE; - } + DONE; }) =20 (define_insn "*sibcall_local32" --=20 2.17.1 --Apple-Mail=_F845A936-D7FD-4163-9957-6B26A8BAE729--