From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 43445 invoked by alias); 26 Jun 2015 08:49:47 -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 43427 invoked by uid 89); 26 Jun 2015 08:49:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (146.101.78.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 26 Jun 2015 08:49:45 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-3-OWdLcYHFQV-f9889OGmFog-1 Received: from localhost ([10.1.2.79]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 26 Jun 2015 09:49:42 +0100 From: Richard Sandiford To: "H.J. Lu" Mail-Followup-To: "H.J. Lu" ,Andrew Pinski , GCC Patches , Mikhail Maltsev , richard.sandiford@arm.com Cc: Andrew Pinski , GCC Patches , Mikhail Maltsev Subject: Re: Add .def file for public target instructions References: <87ioaegtcp.fsf@googlemail.com> Date: Fri, 26 Jun 2015 08:50:00 -0000 In-Reply-To: (H. J. Lu's message of "Thu, 25 Jun 2015 19:36:10 -0700") Message-ID: <874mlurh0a.fsf@e105548-lin.cambridge.arm.com> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-MC-Unique: OWdLcYHFQV-f9889OGmFog-1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2015-06/txt/msg01905.txt.bz2 "H.J. Lu" writes: > On Thu, Jun 25, 2015 at 4:37 PM, H.J. Lu wrote: >> On Thu, Jun 25, 2015 at 4:00 PM, Andrew Pinski wrote: >>> On Thu, Jun 25, 2015 at 3:57 PM, H.J. Lu wrote: >>>> On Thu, Jun 25, 2015 at 1:09 PM, H.J. Lu wrote: >>>>> On Tue, Jun 23, 2015 at 11:41 AM, Richard Sandiford >>>>> wrote: >>>>>> [A fair bit later than promised, sorry...] >>>>>> >>>>>> Mikhail posted a patch to make genflags generate the default HAVE_foo >>>>>> and gen_foo definitions that have recently been added to defaults.h: >>>>>> >>>>>> https://gcc.gnu.org/ml/gcc-patches/2015-06/msg00723.html >>>>>> >>>>>> I agree it'd be a good idea to generate this kind of thing automatic= ally, >>>>>> but I think we should take the opportunity to move the interface to = the >>>>>> target structure. I.e.: >>>>>> >>>>>> HAVE_foo -> targetm.have_foo () >>>>>> gen_foo -> targetm.gen_foo () >>>>>> >>>>>> This should move us closer to the pipedream goal of supporting multi= ple >>>>>> targets at once. It should also mean that only the target code depe= nds >>>>>> on insn-flags.h. >>>>>> >>>>>> The patch just moves return and simple_return as an example. I have= more >>>>>> locally (in order to test other code paths), but they're just an obv= ious >>>>>> extension of this one. >>>>>> >>>>>> The patch relies on the hashing changes in: >>>>>> >>>>>> https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01066.html >>>>>> https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01564.html >>>>>> >>>>>> and on this trivial patch: >>>>>> >>>>>> https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01604.html >>>>>> >>>>>> It seems a bit heavyweight when you just look at these two instructi= ons, >>>>>> but I think it'll be a saving in the end. >>>>>> >>>>>> Bootstrapped & regression-tested on x86_64-linux-gnu. Also tested >>>>>> via config-list.mk. OK to install? >>>>>> >>>>>> Thanks, >>>>>> Richard >>>>>> >>>>>> >>>>>> gcc/ >>>>>> * Makefile.in (TARGET_DEF): Add target-insns.def. >>>>>> (.PRECIOUS, simple_rtl_generated_h): Add insn-target-def.h. >>>>>> (build/gentarget-def.o): New rule. >>>>>> (genprogrtl): Add target-def. >>>>>> * target-insns.def, gentarget-def.c: New files. >>>>>> * target.def: Add targetm.have_* and targetm.gen_* hooks, >>>>>> based on the contents of target-insns.def. >>>>>> * defaults.h (HAVE_simple_return, gen_simple_return): Delete. >>>>>> (HAVE_return, gen_return): Delete. >>>>>> * target-def.h: Include insn-target-def.h. >>>>>> * cfgrtl.c (force_nonfallthru_and_redirect): Use targetm int= erface >>>>>> instead of direct calls. Rely on them to do the appropriate= assertions. >>>>>> * function.c (gen_return_pattern): Likewise. Return an rtx_= insn *. >>>>>> (convert_jumps_to_returns): Use targetm interface instead of >>>>>> direct calls. >>>>>> (thread_prologue_and_epilogue_insns): Likewise. >>>>>> * reorg.c (find_end_label, dbr_schedule): Likewise. >>>>>> * shrink-wrap.h (SHRINK_WRAPPING_ENABLED): Likewise. >>>>>> * shrink-wrap.c (convert_to_simple_return): Likewise. >>>>>> (try_shrink_wrapping): Use SHRINK_WRAPPING_ENABLED. >>>>>> >>>>> >>>>> This breaks bootstrap on Linux/ia32: >>>>> >>>>> https://gcc.gnu.org/ml/gcc-regression/2015-06/msg00649.html >>>>> >>>>> ../../src-trunk/gcc/gentarget-def.c: In function =C3=A2void >>>>> def_target_insn(const char*, const char*)=C3=A2: >>>>> ../../src-trunk/gcc/gentarget-def.c:88:34: error: comparison between >>>>> signed and unsigned integer expressions [-Werror=3Dsign-compare] >>>>> if (strtol (p + 1, &endptr, 10) !=3D opno >>>>> >>>> >>>> There are >>>> >>>> unsigned int opno =3D 0; >>>> for (const char *p =3D prototype; *p; ++p) >>>> if (*p =3D=3D 'x' && ISDIGIT (p[1])) >>>> { >>>> /* This should be a parameter name of the form "x". >>>> That doesn't contribute to the suffix, so skip ahead and >>>> process the following character. */ >>>> char *endptr; >>>> if (strtol (p + 1, &endptr, 10) !=3D opno >>>> || (*endptr !=3D ',' && *endptr !=3D ')')) >>>> >>>> strtol returns long int. Somehow, there is no warning on x86-64. >>> >>> Because on x86_64 (and all LP64 targets), the comparison gets promoted >>> to long (which is 64bit) so the conversion from unsigned int to long >>> does not lose precision. >>> >> >> I am testing this. >> >> >> -- >> H.J. >> --- >> diff --git a/gcc/gentarget-def.c b/gcc/gentarget-def.c >> index d4839e8..3ca9cfd 100644 >> --- a/gcc/gentarget-def.c >> +++ b/gcc/gentarget-def.c >> @@ -77,7 +77,7 @@ def_target_insn (const char *name, const char *prototy= pe) >> together to get a suffix. */ >> char *suffix =3D XALLOCAVEC (char, strlen (prototype) + 1); >> i =3D 0; >> - unsigned int opno =3D 0; >> + long opno =3D 0; >> for (const char *p =3D prototype; *p; ++p) >> if (*p =3D=3D 'x' && ISDIGIT (p[1])) >> { > > It doesn't work. I checked in this patch instead. Thanks H.J., and sorry for the breakage. Richard