@@ -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
@@ -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
@@ -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';
}
@@ -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 */