From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2920 invoked by alias); 30 Mar 2011 15:02:55 -0000 Received: (qmail 2909 invoked by uid 22791); 30 Mar 2011 15:02:52 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00,NO_DNS_FOR_FROM,TW_XV,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 30 Mar 2011 15:02:47 +0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 30 Mar 2011 08:02:39 -0700 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([10.3.194.135]) by orsmga002.jf.intel.com with ESMTP; 30 Mar 2011 08:02:39 -0700 Received: by gnu-6.sc.intel.com (Postfix, from userid 500) id 050E418099A; Wed, 30 Mar 2011 08:02:38 -0700 (PDT) Date: Wed, 30 Mar 2011 15:05:00 -0000 From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Subject: RFC: PATCH: Remove 26 element limit in XVECEXP Message-ID: <20110330150238.GA18279@intel.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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 X-SW-Source: 2011-03/txt/msg02084.txt.bz2 Hi, Currently, we limit XVECEXP to 26 elements in machine description since we use letters 'a' to 'z' to encode them. I don't see any reason why we can't go beyond 'z'. This patch removes this restriction. Any comments? Thanks. H.J. --- 2011-03-30 H.J. Lu * genextract.c (gen_insn): Use encode_xvecexp. (walk_rtx): Likewise. (print_path): Use is_xvecexp and decode_xvecexp. * genpreds.c (write_extract_subexp): Likewise. * genrecog.c (add_to_sequence): Add assert. Use encode_xvecexp. (change_state): Use is_xvecexp and decode_xvecexp. * gensupport.h (is_xvecexp): New. (encode_xvecexp): Likewise. (decode_xvecexp): Likewise. diff --git a/gcc/genextract.c b/gcc/genextract.c index 09e7cde..2afeec0 100644 --- a/gcc/genextract.c +++ b/gcc/genextract.c @@ -108,7 +108,7 @@ gen_insn (rtx insn, int insn_code_number) else for (i = XVECLEN (insn, 1) - 1; i >= 0; i--) { - VEC_safe_push (char,heap, acc.pathstr, 'a' + i); + VEC_safe_push (char,heap, acc.pathstr, encode_xvecexp (i)); walk_rtx (XVECEXP (insn, 1, i), &acc); VEC_pop (char, acc.pathstr); } @@ -222,7 +222,7 @@ static void walk_rtx (rtx x, struct accum_extract *acc) { RTX_CODE code; - int i, len, base; + int i, len, val; const char *fmt; if (x == 0) @@ -248,10 +248,13 @@ walk_rtx (rtx x, struct accum_extract *acc) VEC_safe_set_locstr (&acc->oplocs, XINT (x, 0), VEC_char_to_string (acc->pathstr)); - base = (code == MATCH_OPERATOR ? '0' : 'a'); for (i = XVECLEN (x, 2) - 1; i >= 0; i--) { - VEC_safe_push (char,heap, acc->pathstr, base + i); + if (code == MATCH_OPERATOR) + val = '0' + i; + else + val = encode_xvecexp (i); + VEC_safe_push (char,heap, acc->pathstr, val); walk_rtx (XVECEXP (x, 2, i), acc); VEC_pop (char, acc->pathstr); } @@ -267,10 +270,13 @@ walk_rtx (rtx x, struct accum_extract *acc) if (code == MATCH_DUP) break; - base = (code == MATCH_OP_DUP ? '0' : 'a'); for (i = XVECLEN (x, 1) - 1; i >= 0; i--) { - VEC_safe_push (char,heap, acc->pathstr, base + i); + if (code == MATCH_OP_DUP) + val = '0' + i; + else + val = encode_xvecexp (i); + VEC_safe_push (char,heap, acc->pathstr, val); walk_rtx (XVECEXP (x, 1, i), acc); VEC_pop (char, acc->pathstr); } @@ -295,7 +301,8 @@ walk_rtx (rtx x, struct accum_extract *acc) int j; for (j = XVECLEN (x, i) - 1; j >= 0; j--) { - VEC_safe_push (char,heap, acc->pathstr, 'a' + j); + VEC_safe_push (char,heap, acc->pathstr, + encode_xvecexp (j)); walk_rtx (XVECEXP (x, i, j), acc); VEC_pop (char, acc->pathstr); } @@ -326,7 +333,7 @@ print_path (const char *path) for (i = len - 1; i >= 0 ; i--) { - if (ISLOWER (path[i])) + if (is_xvecexp (path[i])) fputs ("XVECEXP (", stdout); else if (ISDIGIT (path[i])) fputs ("XEXP (", stdout); @@ -338,8 +345,8 @@ print_path (const char *path) for (i = 0; i < len; i++) { - if (ISLOWER (path[i])) - printf (", 0, %d)", path[i] - 'a'); + if (is_xvecexp (path[i])) + printf (", 0, %d)", decode_xvecexp (path[i])); else if (ISDIGIT(path[i])) printf (", %d)", path[i] - '0'); else diff --git a/gcc/genpreds.c b/gcc/genpreds.c index fba4372..d5e1ddc 100644 --- a/gcc/genpreds.c +++ b/gcc/genpreds.c @@ -433,7 +433,7 @@ write_extract_subexp (const char *path) order, then write "op", then the indices in forward order. */ for (i = len - 1; i >= 0; i--) { - if (ISLOWER (path[i])) + if (is_xvecexp (path[i])) fputs ("XVECEXP (", stdout); else if (ISDIGIT (path[i])) fputs ("XEXP (", stdout); @@ -445,8 +445,8 @@ write_extract_subexp (const char *path) for (i = 0; i < len; i++) { - if (ISLOWER (path[i])) - printf (", 0, %d)", path[i] - 'a'); + if (is_xvecexp (path[i])) + printf (", 0, %d)", decode_xvecexp (path[i])); else if (ISDIGIT (path[i])) printf (", %d)", path[i] - '0'); else diff --git a/gcc/genrecog.c b/gcc/genrecog.c index 74dd0a7..b65eb4f 100644 --- a/gcc/genrecog.c +++ b/gcc/genrecog.c @@ -912,6 +912,7 @@ add_to_sequence (rtx pattern, struct decision_head *last, const char *position, /* Which insn we're looking at is represented by A-Z. We don't ever use 'A', however; it is always implied. */ + gcc_assert (i < 26); subpos[depth] = (i > 0 ? 'A' + i : 0); sub = add_to_sequence (XVECEXP (pattern, 0, i), last, subpos, insn_type, 0); @@ -999,10 +1000,17 @@ add_to_sequence (rtx pattern, struct decision_head *last, const char *position, if (was_code == MATCH_OPERATOR || was_code == MATCH_PARALLEL) { - char base = (was_code == MATCH_OPERATOR ? '0' : 'a'); + int val; for (i = 0; i < (size_t) XVECLEN (pattern, 2); i++) { - subpos[depth] = i + base; + if (was_code == MATCH_OPERATOR) + { + val = '0' + i; + gcc_assert (ISDIGIT (val)); + } + else + val = encode_xvecexp (i); + subpos[depth] = val; sub = add_to_sequence (XVECEXP (pattern, 2, i), &sub->success, subpos, insn_type, 0); } @@ -1102,7 +1110,7 @@ add_to_sequence (rtx pattern, struct decision_head *last, const char *position, int j; for (j = 0; j < XVECLEN (pattern, i); j++) { - subpos[depth] = 'a' + j; + subpos[depth] = encode_xvecexp (j); sub = add_to_sequence (XVECEXP (pattern, i, j), &sub->success, subpos, insn_type, 0); } @@ -1776,9 +1784,10 @@ change_state (const char *oldpos, const char *newpos, const char *indent) indent, newpos[depth] - 'A'); printf ("%sx%d = PATTERN (tem);\n", indent, depth + 1); } - else if (ISLOWER (newpos[depth])) + else if (is_xvecexp (newpos[depth])) printf ("%sx%d = XVECEXP (x%d, 0, %d);\n", - indent, depth + 1, depth, newpos[depth] - 'a'); + indent, depth + 1, depth, + decode_xvecexp (newpos[depth])); else printf ("%sx%d = XEXP (x%d, %c);\n", indent, depth + 1, depth, newpos[depth]); @@ -2528,6 +2537,7 @@ make_insn_sequence (rtx insn, enum routine_type type) } XVECLEN (x, 0) = j; + gcc_assert ((j - 1) < 26); c_test_pos[0] = 'A' + j - 1; c_test_pos[1] = '\0'; } diff --git a/gcc/gensupport.h b/gcc/gensupport.h index 999c222..59eaec6 100644 --- a/gcc/gensupport.h +++ b/gcc/gensupport.h @@ -83,4 +83,25 @@ extern void add_predicate (struct pred_data *); #define FOR_ALL_PREDICATES(p) for (p = first_predicate; p; p = p->next) +static inline bool +is_xvecexp (unsigned char v) +{ + return v >= 'a'; +} + +static inline int +encode_xvecexp (int v) +{ + v += 'a'; + gcc_assert (v >= 'a' && v <= 255); + return v; +} + +static inline int +decode_xvecexp (int v) +{ + v -= 'a'; + return v; +} + #endif /* GCC_GENSUPPORT_H */