From patchwork Wed Aug 5 15:44:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 504066 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 48AB21402E2 for ; Thu, 6 Aug 2015 01:44:48 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=a/qC+egc; 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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=r0fjjfEogYmoUy8P rMfFGGfCUqx3fHPi2OAbXGYZ++HFQ+QoRvcbQlJVNCqfxL/wr8iHK7yAxvhdKNLz ErPQo9On+Yytp53CUGLcUxoD28SYg9Um6Xx0hFBcfvAkO9wQcnJr9td9P0w2paMN 74WIuNgr5fXyL5jsy5J0IVv6f7Q= 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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=i3gR4HJBMfx7mkhLtDCYX4 GlyAc=; b=a/qC+egch3RS1K2MO2Vdk63mSQj4J+vgSLvdfAj5SVlOlsbLpx1Hbc EBVM5E3u6yKlAu8QHwfhQIDqI3mGqt0SL7IdBLW08nJq1ALrHhG48SL/sLApCCFA Xiq2Q8AJieLd/RjDKZo+YNjNpHKn2wg37srxR1JnV0o86UEkRvKb0= Received: (qmail 109835 invoked by alias); 5 Aug 2015 15:44:40 -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 109825 invoked by uid 89); 5 Aug 2015 15:44:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 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; Wed, 05 Aug 2015 15:44:38 +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-9-1_TrO7BBQFu0HxVGjaF9xQ-1; Wed, 05 Aug 2015 16:44:33 +0100 Received: from localhost ([10.1.2.79]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 5 Aug 2015 16:44:33 +0100 From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [committed] Add get_num_insn_codes to gensupport Date: Wed, 05 Aug 2015 16:44:33 +0100 Message-ID: <8737zxkae6.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: 1_TrO7BBQFu0HxVGjaF9xQ-1 This patch adds a gensupport routine that generators can use to get the number of unique INSN_CODEs, rather than having to track it themselves. This is needed for a later patch that changes the way in which INSN_CODE is calculated. Bootstrapped and regression-tested on x86_64-linux-gnu. Thanks, Richard gcc/ * gensupport.h (get_num_insn_codes): Declare. * gensupport.c (get_num_insn_codes): New function. * genattrtab.c (optimize_attrs): Rename max_insn_code to num_insn_codes. (main): Likewise. Use get_num_insn_codes. * gencodes.c (main): Remove "last" and use get_num_insn_codes. diff --git a/gcc/genattrtab.c b/gcc/genattrtab.c index 1f57c36..932b18b 100644 --- a/gcc/genattrtab.c +++ b/gcc/genattrtab.c @@ -2952,11 +2952,11 @@ get_attr_order (struct attr_desc ***ret) /* Optimize the attribute lists by seeing if we can determine conditional values from the known values of other attributes. This will save subroutine - calls during the compilation. MAX_INSN_CODE is the number of unique + calls during the compilation. NUM_INSN_CODES is the number of unique instruction codes. */ static void -optimize_attrs (int max_insn_code) +optimize_attrs (int num_insn_codes) { struct attr_desc *attr; struct attr_value *av; @@ -2975,7 +2975,7 @@ optimize_attrs (int max_insn_code) return; /* Make 2 extra elements, for "code" values -2 and -1. */ - insn_code_values = XCNEWVEC (struct attr_value_list *, max_insn_code + 2); + insn_code_values = XCNEWVEC (struct attr_value_list *, num_insn_codes + 2); /* Offset the table address so we can index by -2 or -1. */ insn_code_values += 2; @@ -3003,7 +3003,7 @@ optimize_attrs (int max_insn_code) gcc_assert (iv == ivbuf + num_insn_ents); /* Process one insn code at a time. */ - for (i = -2; i < max_insn_code; i++) + for (i = -2; i < num_insn_codes; i++) { /* Clear the ATTR_CURR_SIMPLIFIED_P flag everywhere relevant. We use it to mean "already simplified for this insn". */ @@ -5161,7 +5161,6 @@ main (int argc, char **argv) struct attr_desc *attr; struct insn_def *id; int i; - int max_insn_code = 0; progname = "genattrtab"; @@ -5224,14 +5223,11 @@ main (int argc, char **argv) } if (GET_CODE (info.def) != DEFINE_ASM_ATTRIBUTES) insn_index_number++; - max_insn_code = info.index; } if (have_error) return FATAL_EXIT_CODE; - max_insn_code++; - /* If we didn't have a DEFINE_ASM_ATTRIBUTES, make a null one. */ if (! got_define_asm_attributes) { @@ -5248,14 +5244,15 @@ main (int argc, char **argv) expand_delays (); /* Make `insn_alternatives'. */ - insn_alternatives = oballocvec (uint64_t, max_insn_code); + int num_insn_codes = get_num_insn_codes (); + insn_alternatives = oballocvec (uint64_t, num_insn_codes); for (id = defs; id; id = id->next) if (id->insn_code >= 0) insn_alternatives[id->insn_code] = (((uint64_t) 1) << id->num_alternatives) - 1; /* Make `insn_n_alternatives'. */ - insn_n_alternatives = oballocvec (int, max_insn_code); + insn_n_alternatives = oballocvec (int, num_insn_codes); for (id = defs; id; id = id->next) if (id->insn_code >= 0) insn_n_alternatives[id->insn_code] = id->num_alternatives; @@ -5284,7 +5281,7 @@ main (int argc, char **argv) make_length_attrs (); /* Perform any possible optimizations to speed up compilation. */ - optimize_attrs (max_insn_code); + optimize_attrs (num_insn_codes); /* Now write out all the `gen_attr_...' routines. Do these before the special routines so that they get defined before they are used. */ diff --git a/gcc/gencodes.c b/gcc/gencodes.c index b9d65a2..c747891 100644 --- a/gcc/gencodes.c +++ b/gcc/gencodes.c @@ -49,8 +49,6 @@ gen_insn (md_rtx_info *info) int main (int argc, char **argv) { - int last = 1; - progname = "gencodes"; /* We need to see all the possibilities. Elided insns may have @@ -79,7 +77,6 @@ enum insn_code {\n\ case DEFINE_INSN: case DEFINE_EXPAND: gen_insn (&info); - last = info.index + 1; break; default: @@ -89,7 +86,7 @@ enum insn_code {\n\ printf (" LAST_INSN_CODE = %d\n\ };\n\ \n\ -#endif /* GCC_INSN_CODES_H */\n", last); +#endif /* GCC_INSN_CODES_H */\n", get_num_insn_codes () - 1); if (ferror (stdout) || fflush (stdout) || fclose (stdout)) return FATAL_EXIT_CODE; diff --git a/gcc/gensupport.c b/gcc/gensupport.c index b7681a2..714af03 100644 --- a/gcc/gensupport.c +++ b/gcc/gensupport.c @@ -2602,6 +2602,14 @@ read_md_rtx (md_rtx_info *info) return true; } +/* Return the number of possible INSN_CODEs. Only meaningful once the + whole file has been processed. */ +unsigned int +get_num_insn_codes () +{ + return sequence_num; +} + /* Helper functions for insn elision. */ /* Compute a hash function of a c_test structure, which is keyed diff --git a/gcc/gensupport.h b/gcc/gensupport.h index 8fbdb36..c37ec36 100644 --- a/gcc/gensupport.h +++ b/gcc/gensupport.h @@ -43,6 +43,7 @@ extern rtx add_implicit_parallel (rtvec); extern bool init_rtx_reader_args_cb (int, char **, bool (*)(const char *)); extern bool init_rtx_reader_args (int, char **); extern bool read_md_rtx (md_rtx_info *); +extern unsigned int get_num_insn_codes (); /* Set this to 0 to disable automatic elision of insn patterns which can never be used in this configuration. See genconditions.c.