From patchwork Wed Aug 5 15:46:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 504070 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 187B61402E2 for ; Thu, 6 Aug 2015 01:46:25 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=YNl4T/P0; 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=tBt+NukpTfjBkFD8 QxwAE6QWy9N1C3v5J5kCkEkIXFH4LekqqK3kpzGa3SYNPROUBOYgBRAiwwL3ziT9 zFe+zOCNXVEUJ9Pn41+iimW1I5vKSY9LqSPau3HNl0nPcyW1bd51A+CglC1tiEz/ 0lMppzIJ0nin1FlmU4EVnCQ1Uw4= 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=q42C+4aOH1sc2x7PAJVfMx /lUqg=; b=YNl4T/P0hiiXxo74d0JpK0CpzE0l5+SH0ui8OeiMX4l7oQ/6FrRM5h SNlXqFkA/iZFCDF2xeZ7tcNQmKkcH0hyZdgtksEZnYtdiJaWuhmiczl/M/YXJ17c rVax1hjbi6DUGjB+iM43pqdGJDqAiQZRd+2QLHzunktv6KNlyfBWc= Received: (qmail 113201 invoked by alias); 5 Aug 2015 15:46:17 -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 113185 invoked by uid 89); 5 Aug 2015 15:46:16 -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) (207.82.80.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Aug 2015 15:46:15 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-12-BN0x0rS3RAeEjCXAeSMfIA-1; Wed, 05 Aug 2015 16:46:10 +0100 Received: from localhost ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 5 Aug 2015 16:46:10 +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 a get_c_test helper function to gensupport Date: Wed, 05 Aug 2015 16:46:10 +0100 Message-ID: <87y4hpivr1.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: BN0x0rS3RAeEjCXAeSMfIA-1 Add a new function to return the C condition that must hold for an .md rtx to be valid. This is needed by the next patch but is a minor clean-up anyway. Bootstrapped and regression-tested on x86_64-linux-gnu. Thanks, Richard gcc/ * gensupport.h (get_c_test): Declare. * gensupport.c (get_c_test): New function. * genconditions.c (main): Use it. * genrecog.c (validate_pattern): Likewise. (match_pattern_1): Likewise. Remove c_test argument. (match_pattern): Update accordingly and remove c_test argument. (main): Update accordingly. diff --git a/gcc/genconditions.c b/gcc/genconditions.c index 23109ee..001e58e 100644 --- a/gcc/genconditions.c +++ b/gcc/genconditions.c @@ -222,25 +222,17 @@ main (int argc, char **argv) while (read_md_rtx (&info)) { rtx def = info.def; - /* N.B. define_insn_and_split, define_cond_exec are handled - entirely within read_md_rtx; we never see them. */ + add_c_test (get_c_test (def), -1); switch (GET_CODE (def)) { case DEFINE_INSN: case DEFINE_EXPAND: - add_c_test (XSTR (def, 2), -1); /* except.h needs to know whether there is an eh_return pattern in the machine description. */ if (!strcmp (XSTR (def, 0), "eh_return")) saw_eh_return = 1; break; - case DEFINE_SPLIT: - case DEFINE_PEEPHOLE: - case DEFINE_PEEPHOLE2: - add_c_test (XSTR (def, 1), -1); - break; - default: break; } diff --git a/gcc/genrecog.c b/gcc/genrecog.c index 4275bd2..599121f 100644 --- a/gcc/genrecog.c +++ b/gcc/genrecog.c @@ -519,10 +519,7 @@ validate_pattern (rtx pattern, md_rtx_info *info, rtx set, int set_code) const struct pred_data *pred; const char *c_test; - if (GET_CODE (info->def) == DEFINE_INSN) - c_test = XSTR (info->def, 2); - else - c_test = XSTR (info->def, 1); + c_test = get_c_test (info->def); if (pred_name[0] != 0) { @@ -4080,13 +4077,13 @@ match_pattern_2 (state *s, md_rtx_info *info, position *pos, rtx pattern) (1) the rtx doesn't match anything already matched by S (2) the rtx matches TOP_PATTERN and - (3) C_TEST is true. + (3) the C test required by INFO->def is true For peephole2, TOP_PATTERN is a SEQUENCE of the instruction patterns to match, otherwise it is a single instruction pattern. */ static void -match_pattern_1 (state *s, md_rtx_info *info, rtx pattern, const char *c_test, +match_pattern_1 (state *s, md_rtx_info *info, rtx pattern, acceptance_type acceptance) { if (acceptance.type == PEEPHOLE2) @@ -4120,6 +4117,7 @@ match_pattern_1 (state *s, md_rtx_info *info, rtx pattern, const char *c_test, } /* Make sure that the C test is true. */ + const char *c_test = get_c_test (info->def); if (maybe_eval_c_test (c_test) != 1) s = add_decision (s, rtx_test::c_test (c_test), true, false); @@ -4132,7 +4130,7 @@ match_pattern_1 (state *s, md_rtx_info *info, rtx pattern, const char *c_test, backtracking. */ static void -match_pattern (state *s, md_rtx_info *info, rtx pattern, const char *c_test, +match_pattern (state *s, md_rtx_info *info, rtx pattern, acceptance_type acceptance) { if (merge_states_p) @@ -4140,11 +4138,11 @@ match_pattern (state *s, md_rtx_info *info, rtx pattern, const char *c_test, state root; /* Add the decisions to a fresh state and then merge the full tree into the existing one. */ - match_pattern_1 (&root, info, pattern, c_test, acceptance); + match_pattern_1 (&root, info, pattern, acceptance); merge_into_state (s, &root); } else - match_pattern_1 (s, info, pattern, c_test, acceptance); + match_pattern_1 (s, info, pattern, acceptance); } /* Begin the output file. */ @@ -5256,15 +5254,13 @@ main (int argc, char **argv) acceptance.u.full.u.num_clobbers = 0; pattern = add_implicit_parallel (XVEC (def, 1)); validate_pattern (pattern, &info, NULL_RTX, 0); - match_pattern (&insn_root, &info, pattern, - XSTR (def, 2), acceptance); + match_pattern (&insn_root, &info, pattern, acceptance); /* If the pattern is a PARALLEL with trailing CLOBBERs, allow recog_for_combine to match without the clobbers. */ if (GET_CODE (pattern) == PARALLEL && remove_clobbers (&acceptance, &pattern)) - match_pattern (&insn_root, &info, pattern, - XSTR (def, 2), acceptance); + match_pattern (&insn_root, &info, pattern, acceptance); break; } @@ -5272,8 +5268,7 @@ main (int argc, char **argv) acceptance.type = SPLIT; pattern = add_implicit_parallel (XVEC (def, 0)); validate_pattern (pattern, &info, NULL_RTX, 0); - match_pattern (&split_root, &info, pattern, - XSTR (def, 1), acceptance); + match_pattern (&split_root, &info, pattern, acceptance); /* Declare the gen_split routine that we'll call if the pattern matches. The definition comes from insn-emit.c. */ @@ -5285,8 +5280,7 @@ main (int argc, char **argv) acceptance.type = PEEPHOLE2; pattern = get_peephole2_pattern (&info); validate_pattern (pattern, &info, NULL_RTX, 0); - match_pattern (&peephole2_root, &info, pattern, - XSTR (def, 1), acceptance); + match_pattern (&peephole2_root, &info, pattern, acceptance); /* Declare the gen_peephole2 routine that we'll call if the pattern matches. The definition comes from insn-emit.c. */ diff --git a/gcc/gensupport.c b/gcc/gensupport.c index 714af03..6870058 100644 --- a/gcc/gensupport.c +++ b/gcc/gensupport.c @@ -2610,6 +2610,29 @@ get_num_insn_codes () return sequence_num; } +/* Return the C test that says whether definition rtx DEF can be used, + or "" if it can be used unconditionally. */ + +const char * +get_c_test (rtx x) +{ + switch (GET_CODE (x)) + { + case DEFINE_INSN: + case DEFINE_EXPAND: + case DEFINE_SUBST: + return XSTR (x, 2); + + case DEFINE_SPLIT: + case DEFINE_PEEPHOLE: + case DEFINE_PEEPHOLE2: + return XSTR (x, 1); + + default: + return ""; + } +} + /* 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 c37ec36..a15c36a 100644 --- a/gcc/gensupport.h +++ b/gcc/gensupport.h @@ -50,6 +50,10 @@ extern unsigned int get_num_insn_codes (); Must be set before calling init_md_reader. */ extern int insn_elision; +/* Return the C test that says whether a definition rtx can be used, + or "" if it can be used unconditionally. */ +extern const char *get_c_test (rtx); + /* If the C test passed as the argument can be evaluated at compile time, return its truth value; else return -1. The test must have appeared somewhere in the machine description when genconditions