From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by sourceware.org (Postfix) with ESMTP id B306A3858D37 for ; Wed, 28 Sep 2022 22:05:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B306A3858D37 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kernel.crashing.org Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 28SM4jxi024780; Wed, 28 Sep 2022 17:04:45 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 28SM4h36024779; Wed, 28 Sep 2022 17:04:43 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Wed, 28 Sep 2022 17:04:43 -0500 From: Segher Boessenkool To: "Kewen.Lin" Cc: GCC Patches , David Edelsohn , Peter Bergner , iain@sandoe.co.uk, idsandoe@googlemail.com Subject: Re: [PATCH] rs6000: Rework option -mpowerpc64 handling [PR106680] Message-ID: <20220928220443.GV25951@gate.crashing.org> References: <9d9f1f43-b528-387d-45a7-1d89400de0fc@linux.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9d9f1f43-b528-387d-45a7-1d89400de0fc@linux.ibm.com> User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,KAM_SHORT,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, Sep 28, 2022 at 01:30:46PM +0800, Kewen.Lin wrote: > PR106680 shows that -m32 -mpowerpc64 is different from > -mpowerpc64 -m32, this is determined by the way how we > handle option powerpc64 in rs6000_handle_option. > > Segher pointed out this difference should be taken as > a bug and we should ensure that option powerpc64 is > independent of -m32/-m64. So this patch removes the > handlings in rs6000_handle_option and add some necessary > supports in rs6000_option_override_internal instead. Thanks! > With this patch, if users specify -m{no-,}powerpc64, the > specified value is honoured, otherwise, for 64bit it > always enables OPTION_MASK_POWERPC64 while for 32bit > it disables OPTION_MASK_POWERPC64 if OS_MISSING_POWERPC64. If the user says -m64 -mno-powerpc64 it should error, and perhaps -m32 -mpowerpc64 should warn if OS_MISSING_POWERPC64? > - /* Some OSs don't support saving the high part of 64-bit registers on context > - switch. Other OSs don't support saving Altivec registers. On those OSs, > - we don't touch the OPTION_MASK_POWERPC64 or OPTION_MASK_ALTIVEC settings; > - if the user wants either, the user must explicitly specify them and we > - won't interfere with the user's specification. */ > + /* Some OSs don't support saving Altivec registers. On those OSs, we don't > + touch the OPTION_MASK_POWERPC64 or OPTION_MASK_ALTIVEC settings; if the > + user wants either, the user must explicitly specify them and we won't > + interfere with the user's specification. */ > > set_masks = POWERPC_MASKS; > -#ifdef OS_MISSING_POWERPC64 > - if (OS_MISSING_POWERPC64) > - set_masks &= ~OPTION_MASK_POWERPC64; > -#endif As I said elsewhere, it probably is helpful if we still warn here for -m32 -mpowerpc64 with OS_MISSING_POWERPC64 (or without the -m32 even, same thing). > + /* With option powerpc64 specified explicitly (either on or off), even if > + being compiled for 64 bit we don't need to check if it's disabled here, > + since subtargets will check and raise an error message if necessary > + later. But without option powerpc64 specified explicitly, we need to > + ensure powerpc64 enabled for 64 bit and disabled on those OSes with > + OS_MISSING_POWERPC64, since they don't support saving the high part of > + 64-bit registers on context switch. */ > + if (!(rs6000_isa_flags_explicit & OPTION_MASK_POWERPC64)) > + { > + if (TARGET_64BIT) > + /* Make sure we always enable it by default for 64 bit. */ > + rs6000_isa_flags |= OPTION_MASK_POWERPC64; > +#ifdef OS_MISSING_POWERPC64 > + else if (OS_MISSING_POWERPC64) > + /* It's unexpected to have OPTION_MASK_POWERPC64 on for OSes which > + miss powerpc64 support, so disable it. */ > + rs6000_isa_flags &= ~OPTION_MASK_POWERPC64; > +#endif > + } Aha. Please don't, just warn instead? Silently disabling such stuff is the worst option :-( > +/* { dg-error "'-m64' requires a PowerPC64 cpu" "PR106680" { target powerpc*-*-linux* powerpc-*-rtems* } 0 } */ Everything except AIX even? So it will include Darwin as well (and the BSDs, and powerpc*-elf, etc.) > --- /dev/null > +++ b/gcc/testsuite/gcc.target/powerpc/pr106680-4.c > @@ -0,0 +1,16 @@ > +/* Skip this on aix, otherwise it emits the error message like "64-bit > + computation with 32-bit addressing not yet supported" on aix. */ > +/* { dg-skip-if "" { powerpc*-*-aix* } } */ > +/* { dg-require-effective-target ilp32 } */ > +/* { dg-options "-mpowerpc64 -m32 -O2" } */ If you have -m32 you don't need ilp32, and the other way around. > +/* Verify option -m32 doesn't override option -mpowerpc64. > + If option -mpowerpc64 gets overridden, the assembly would > + end up with addc and adde. */ > +/* { dg-final { scan-assembler-not "addc" } } */ > +/* { dg-final { scan-assembler-not "adde" } } */ Lol, nice :-) "adde" is a frequent substring, use \m \M please? You will always get these exact insns anyway. And you could add a -times {\madd\M} 1 ? - - - The Darwin problem might be something in darwin*.h, but I don't see it. Maybe it is a more generic problem? Segher