From patchwork Wed Aug 5 15:48:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 504077 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 9EF0E1402E2 for ; Thu, 6 Aug 2015 01:48:32 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=xGc0gSUn; 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=HB5Mi//hz7UjWKPq a7ojeOaNGe5fdtkkeYgN8YLcqlRKSmpPLdCXJ5blN/WN7O4yu5upuwdDWagJLXLD mhAQH7/6EtdCIUcaCBsTDZhsZq2UlV2MgZ4yaxxH0UQjPO9R9wa3RVY9xERDHfJj JPRXj2ffTyZEzkSooADiTYiqg3A= 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=f/8z0RLApJnBAV2OlKuYdg SalKw=; b=xGc0gSUnjitDLVwjPH+ABt8j/vNNc3506plIt7k/LQYWab7ZArPKne PBGzL3V4mlGyGUCS27b8ZBcfgssv/WDonbzHVoq1M35MW2ltnq4dgo9eH1goabVl vbuak7xtFjke8Ys43GTXY1hUbfHdJGk1K54KKDVCEq279GCgV26h0= Received: (qmail 13059 invoked by alias); 5 Aug 2015 15:48:24 -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 13047 invoked by uid 89); 5 Aug 2015 15:48:23 -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:48:22 +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-37-QleGlUQ8QMq-sXij1WRcLg-1; Wed, 05 Aug 2015 16:48:15 +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:48:14 +0100 From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [committed] Reduce size of insn_data Date: Wed, 05 Aug 2015 16:48:14 +0100 Message-ID: <87twsdivnl.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: QleGlUQ8QMq-sXij1WRcLg-1 At the moment insn_data contains entries for define_splits and define_peephole2s "only for reasons of consistency and to simplify genrecog". We don't need that any more and it just adds bloat. This patch instead uses separate counters for define_split and define_peephole2. It also removes a redundant DEFINE_SUBST case in read_md_rtx. define_subst is a preprocessing directive and doesn't get passed back to generators. Bootstrapped and regression-tested on x86_64-linux-gnu. Thanks, Richard gcc/ * gensupport.c (sequence_num): Replace with... (insn_sequence_num, split_sequence_num, peephole2_sequence_num): ...these new variables. (init_rtx_reader_args_cb): Update accordingly. (get_num_code_insns): Likewise. (read_md_rtx): Rework to use a while loop and get_c_test. Use the new counters. Remove redundant DEFINE_SUBST case. * genoutput.c (gen_split): Delete. (main): Don't call it. diff --git a/gcc/genoutput.c b/gcc/genoutput.c index cd7f129..ed9540d 100644 --- a/gcc/genoutput.c +++ b/gcc/genoutput.c @@ -973,46 +973,6 @@ gen_expand (md_rtx_info *info) place_operands (d); } -/* Process a define_split just read. Assign its code number, - only for reasons of consistency and to simplify genrecog. */ - -static void -gen_split (md_rtx_info *info) -{ - struct pattern_stats stats; - data *d = new data; - int i; - - d->code_number = info->index; - d->loc = info->loc; - d->name = 0; - - /* Build up the list in the same order as the insns are seen - in the machine description. */ - d->next = 0; - *idata_end = d; - idata_end = &d->next; - - memset (d->operand, 0, sizeof (d->operand)); - - /* Get the number of operands by scanning all the patterns of the - split patterns. But ignore all the rest of the information thus - obtained. */ - rtx split = info->def; - for (i = 0; i < XVECLEN (split, 0); i++) - scan_operands (d, XVECEXP (split, 0, i), 0, 0); - - get_pattern_stats (&stats, XVEC (split, 0)); - d->n_generator_args = 0; - d->n_operands = stats.num_insn_operands; - d->n_dups = 0; - d->n_alternatives = 0; - d->template_code = 0; - d->output_format = INSN_OUTPUT_FORMAT_NONE; - - place_operands (d); -} - static void init_insn_for_nothing (void) { @@ -1055,11 +1015,6 @@ main (int argc, char **argv) gen_expand (&info); break; - case DEFINE_SPLIT: - case DEFINE_PEEPHOLE2: - gen_split (&info); - break; - case DEFINE_CONSTRAINT: case DEFINE_REGISTER_CONSTRAINT: case DEFINE_ADDRESS_CONSTRAINT: diff --git a/gcc/gensupport.c b/gcc/gensupport.c index 6870058..9e00f13 100644 --- a/gcc/gensupport.c +++ b/gcc/gensupport.c @@ -43,11 +43,14 @@ int insn_elision = 1; static struct obstack obstack; struct obstack *rtl_obstack = &obstack; -/* Counter for patterns that generate code: define_insn, define_expand, - define_split, define_peephole, and define_peephole2. See read_md_rtx(). - Any define_insn_and_splits are already in separate queues so that the - insn and the splitter get a unique number also. */ -static int sequence_num; +/* Counter for named patterns and INSN_CODEs. */ +static int insn_sequence_num; + +/* Counter for define_splits. */ +static int split_sequence_num; + +/* Counter for define_peephole2s. */ +static int peephole2_sequence_num; static int predicable_default; static const char *predicable_true; @@ -2504,7 +2507,11 @@ init_rtx_reader_args_cb (int argc, char **argv, obstack_init (rtl_obstack); /* Start at 1, to make 0 available for CODE_FOR_nothing. */ - sequence_num = 1; + insn_sequence_num = 1; + + /* These sequences are not used as indices, so can start at 1 also. */ + split_sequence_num = 1; + peephole2_sequence_num = 1; read_md_files (argc, argv, parse_opt, rtx_handle_directive); @@ -2539,30 +2546,8 @@ init_rtx_reader_args (int argc, char **argv) bool read_md_rtx (md_rtx_info *info) { - struct queue_elem **queue, *elem; - rtx desc; - - discard: - - /* Read all patterns from a given queue before moving on to the next. */ - if (define_attr_queue != NULL) - queue = &define_attr_queue; - else if (define_pred_queue != NULL) - queue = &define_pred_queue; - else if (define_insn_queue != NULL) - queue = &define_insn_queue; - else if (other_queue != NULL) - queue = &other_queue; - else - return false; - - elem = *queue; - *queue = elem->next; - info->def = elem->data; - info->loc = elem->loc; - info->index = sequence_num; - - free (elem); + int truth, *counter; + rtx def; /* Discard insn patterns which we know can never match (because their C test is provably always false). If insn_elision is @@ -2570,35 +2555,70 @@ read_md_rtx (md_rtx_info *info) elided patterns are never counted by the sequence numbering; it is the caller's responsibility, when insn_elision is false, not to use elided pattern numbers for anything. */ - desc = info->def; - switch (GET_CODE (desc)) + do + { + struct queue_elem **queue, *elem; + + /* Read all patterns from a given queue before moving on to the next. */ + if (define_attr_queue != NULL) + queue = &define_attr_queue; + else if (define_pred_queue != NULL) + queue = &define_pred_queue; + else if (define_insn_queue != NULL) + queue = &define_insn_queue; + else if (other_queue != NULL) + queue = &other_queue; + else + return false; + + elem = *queue; + *queue = elem->next; + def = elem->data; + info->def = def; + info->loc = elem->loc; + free (elem); + + truth = maybe_eval_c_test (get_c_test (def)); + } + while (truth == 0 && insn_elision); + + /* Perform code-specific processing and pick the appropriate sequence + number counter. */ + switch (GET_CODE (def)) { case DEFINE_INSN: case DEFINE_EXPAND: - case DEFINE_SUBST: - if (maybe_eval_c_test (XSTR (desc, 2)) != 0) - sequence_num++; - else if (insn_elision) - goto discard; - - /* info->index is used here so the name table will match caller's + /* insn_sequence_num is used here so the name table will match caller's idea of insn numbering, whether or not elision is active. */ - record_insn_name (info->index, XSTR (desc, 0)); + record_insn_name (insn_sequence_num, XSTR (def, 0)); + + /* Fall through. */ + case DEFINE_PEEPHOLE: + counter = &insn_sequence_num; break; case DEFINE_SPLIT: - case DEFINE_PEEPHOLE: + counter = &split_sequence_num; + break; + case DEFINE_PEEPHOLE2: - if (maybe_eval_c_test (XSTR (desc, 1)) != 0) - sequence_num++; - else if (insn_elision) - goto discard; + counter = &peephole2_sequence_num; break; default: + counter = NULL; break; } + if (counter) + { + info->index = *counter; + if (truth != 0) + *counter += 1; + } + else + info->index = -1; + return true; } @@ -2607,7 +2627,7 @@ read_md_rtx (md_rtx_info *info) unsigned int get_num_insn_codes () { - return sequence_num; + return insn_sequence_num; } /* Return the C test that says whether definition rtx DEF can be used,