From patchwork Thu Jun 25 23:37:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 488583 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 2F60B1401E7 for ; Fri, 26 Jun 2015 09:37:20 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=J2zaP6Ms; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type:content-transfer-encoding; q=dns; s= default; b=IlTNAnTUG1vaCVkcP6Tl3z4BXxVnSsQoYTWoFDLyTMMcFXEB+HQB1 smQ9qYUAWAJmUoSAwnJSk20D9wk489bcF9o9KsBW6O1yLnn39E687nVpgTUG8XN7 I5afM4AMNn1HE/m2Vbs85kTDx1NC1j4FvVIDMbYwfIZSvCbgU0Pgno= 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 :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type:content-transfer-encoding; s=default; bh=uu1/5EIRIo0siRDMLBGPzahUgKY=; b=J2zaP6Ms4venSfpaFB+amXsfHr4W yrc0NBOq2/oaoC6BaUFHSA/eoxXaqTBFQs3zMA4Nmv6MRIlmfWXcjLkYrMp6Pc/6 DpNMbq2XSe07f4TWMxT2y8p8D9HeXbCpPKMwT2aFqSbs9wmFVXRD7A4Rh+Ih9wUG Fq2Gv7CTxR2rjj8= Received: (qmail 119606 invoked by alias); 25 Jun 2015 23:37:12 -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 119590 invoked by uid 89); 25 Jun 2015 23:37:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ob0-f177.google.com Received: from mail-ob0-f177.google.com (HELO mail-ob0-f177.google.com) (209.85.214.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 25 Jun 2015 23:37:10 +0000 Received: by obbkm3 with SMTP id km3so57123979obb.1 for ; Thu, 25 Jun 2015 16:37:08 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.60.178.33 with SMTP id cv1mr41253038oec.11.1435275428526; Thu, 25 Jun 2015 16:37:08 -0700 (PDT) Received: by 10.76.160.68 with HTTP; Thu, 25 Jun 2015 16:37:08 -0700 (PDT) In-Reply-To: References: <87ioaegtcp.fsf@googlemail.com> Date: Thu, 25 Jun 2015 16:37:08 -0700 Message-ID: Subject: Re: Add .def file for public target instructions From: "H.J. Lu" To: Andrew Pinski Cc: GCC Patches , Mikhail Maltsev , Richard Sandiford X-IsSubscribed: yes 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 automatically, >>>> 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 multiple >>>> targets at once. It should also mean that only the target code depends >>>> 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 obvious >>>> 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 instructions, >>>> 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 interface >>>> 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 âvoid >>> def_target_insn(const char*, const char*)â: >>> ../../src-trunk/gcc/gentarget-def.c:88:34: error: comparison between >>> signed and unsigned integer expressions [-Werror=sign-compare] >>> if (strtol (p + 1, &endptr, 10) != opno >>> >> >> There are >> >> unsigned int opno = 0; >> for (const char *p = prototype; *p; ++p) >> if (*p == '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) != opno >> || (*endptr != ',' && *endptr != ')')) >> >> 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. 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 *prototype) together to get a suffix. */ char *suffix = XALLOCAVEC (char, strlen (prototype) + 1); i = 0; - unsigned int opno = 0; + long opno = 0; for (const char *p = prototype; *p; ++p) if (*p == 'x' && ISDIGIT (p[1])) {