Commit ab55f58c by Richard Henderson Committed by Richard Henderson

genemit.c (gen_exp): New argument used.

        * genemit.c (gen_exp): New argument used.  Invoke copy_rtx
        if used indicates we've already emitted one copy of an operand.
        (gen_insn, gen_expand, output_add_clobbers): Supply a null used.
        (gen_split): Supply a non-null used.

From-SVN: r50386
parent 957978a4
2002-03-06 Richard Henderson <rth@redhat.com>
* genemit.c (gen_exp): New argument used. Invoke copy_rtx
if used indicates we've already emitted one copy of an operand.
(gen_insn, gen_expand, output_add_clobbers): Supply a null used.
(gen_split): Supply a non-null used.
2002-03-06 Ulrich Weigand <uweigand@de.ibm.com> 2002-03-06 Ulrich Weigand <uweigand@de.ibm.com>
* reload1.c (reload): Unshare all rtl after reload is done. * reload1.c (reload): Unshare all rtl after reload is done.
......
...@@ -58,7 +58,7 @@ struct clobber_ent ...@@ -58,7 +58,7 @@ struct clobber_ent
static void max_operand_1 PARAMS ((rtx)); static void max_operand_1 PARAMS ((rtx));
static int max_operand_vec PARAMS ((rtx, int)); static int max_operand_vec PARAMS ((rtx, int));
static void print_code PARAMS ((RTX_CODE)); static void print_code PARAMS ((RTX_CODE));
static void gen_exp PARAMS ((rtx, enum rtx_code)); static void gen_exp PARAMS ((rtx, enum rtx_code, char *));
static void gen_insn PARAMS ((rtx)); static void gen_insn PARAMS ((rtx));
static void gen_expand PARAMS ((rtx)); static void gen_expand PARAMS ((rtx));
static void gen_split PARAMS ((rtx)); static void gen_split PARAMS ((rtx));
...@@ -155,9 +155,10 @@ gen_rtx_scratch (x, subroutine_type) ...@@ -155,9 +155,10 @@ gen_rtx_scratch (x, subroutine_type)
substituting any operand references appearing within. */ substituting any operand references appearing within. */
static void static void
gen_exp (x, subroutine_type) gen_exp (x, subroutine_type, used)
rtx x; rtx x;
enum rtx_code subroutine_type; enum rtx_code subroutine_type;
char *used;
{ {
RTX_CODE code; RTX_CODE code;
int i; int i;
...@@ -176,6 +177,15 @@ gen_exp (x, subroutine_type) ...@@ -176,6 +177,15 @@ gen_exp (x, subroutine_type)
{ {
case MATCH_OPERAND: case MATCH_OPERAND:
case MATCH_DUP: case MATCH_DUP:
if (used)
{
if (used[XINT (x, 0)])
{
printf ("copy_rtx (operand%d)", XINT (x, 0));
return;
}
used[XINT (x, 0)] = 1;
}
printf ("operand%d", XINT (x, 0)); printf ("operand%d", XINT (x, 0));
return; return;
...@@ -188,7 +198,7 @@ gen_exp (x, subroutine_type) ...@@ -188,7 +198,7 @@ gen_exp (x, subroutine_type)
for (i = 0; i < XVECLEN (x, 1); i++) for (i = 0; i < XVECLEN (x, 1); i++)
{ {
printf (",\n\t\t"); printf (",\n\t\t");
gen_exp (XVECEXP (x, 1, i), subroutine_type); gen_exp (XVECEXP (x, 1, i), subroutine_type, used);
} }
printf (")"); printf (")");
return; return;
...@@ -199,7 +209,7 @@ gen_exp (x, subroutine_type) ...@@ -199,7 +209,7 @@ gen_exp (x, subroutine_type)
for (i = 0; i < XVECLEN (x, 2); i++) for (i = 0; i < XVECLEN (x, 2); i++)
{ {
printf (",\n\t\t"); printf (",\n\t\t");
gen_exp (XVECEXP (x, 2, i), subroutine_type); gen_exp (XVECEXP (x, 2, i), subroutine_type, used);
} }
printf (")"); printf (")");
return; return;
...@@ -262,7 +272,7 @@ gen_exp (x, subroutine_type) ...@@ -262,7 +272,7 @@ gen_exp (x, subroutine_type)
break; break;
printf (",\n\t"); printf (",\n\t");
if (fmt[i] == 'e' || fmt[i] == 'u') if (fmt[i] == 'e' || fmt[i] == 'u')
gen_exp (XEXP (x, i), subroutine_type); gen_exp (XEXP (x, i), subroutine_type, used);
else if (fmt[i] == 'i') else if (fmt[i] == 'i')
printf ("%u", XINT (x, i)); printf ("%u", XINT (x, i));
else if (fmt[i] == 's') else if (fmt[i] == 's')
...@@ -274,7 +284,7 @@ gen_exp (x, subroutine_type) ...@@ -274,7 +284,7 @@ gen_exp (x, subroutine_type)
for (j = 0; j < XVECLEN (x, i); j++) for (j = 0; j < XVECLEN (x, i); j++)
{ {
printf (",\n\t\t"); printf (",\n\t\t");
gen_exp (XVECEXP (x, i, j), subroutine_type); gen_exp (XVECEXP (x, i, j), subroutine_type, used);
} }
printf (")"); printf (")");
} }
...@@ -397,7 +407,7 @@ gen_insn (insn) ...@@ -397,7 +407,7 @@ gen_insn (insn)
if (XVECLEN (insn, 1) == 1) if (XVECLEN (insn, 1) == 1)
{ {
printf (" return "); printf (" return ");
gen_exp (XVECEXP (insn, 1, 0), DEFINE_INSN); gen_exp (XVECEXP (insn, 1, 0), DEFINE_INSN, NULL);
printf (";\n}\n\n"); printf (";\n}\n\n");
} }
else else
...@@ -408,7 +418,7 @@ gen_insn (insn) ...@@ -408,7 +418,7 @@ gen_insn (insn)
for (i = 0; i < XVECLEN (insn, 1); i++) for (i = 0; i < XVECLEN (insn, 1); i++)
{ {
printf (",\n\t\t"); printf (",\n\t\t");
gen_exp (XVECEXP (insn, 1, i), DEFINE_INSN); gen_exp (XVECEXP (insn, 1, i), DEFINE_INSN, NULL);
} }
printf ("));\n}\n\n"); printf ("));\n}\n\n");
} }
...@@ -454,7 +464,7 @@ gen_expand (expand) ...@@ -454,7 +464,7 @@ gen_expand (expand)
&& XVECLEN (expand, 1) == 1) && XVECLEN (expand, 1) == 1)
{ {
printf (" return "); printf (" return ");
gen_exp (XVECEXP (expand, 1, 0), DEFINE_EXPAND); gen_exp (XVECEXP (expand, 1, 0), DEFINE_EXPAND, NULL);
printf (";\n}\n\n"); printf (";\n}\n\n");
return; return;
} }
...@@ -535,7 +545,7 @@ gen_expand (expand) ...@@ -535,7 +545,7 @@ gen_expand (expand)
printf (" emit ("); printf (" emit (");
else else
printf (" emit_insn ("); printf (" emit_insn (");
gen_exp (next, DEFINE_EXPAND); gen_exp (next, DEFINE_EXPAND, NULL);
printf (");\n"); printf (");\n");
if (GET_CODE (next) == SET && GET_CODE (SET_DEST (next)) == PC if (GET_CODE (next) == SET && GET_CODE (SET_DEST (next)) == PC
&& GET_CODE (SET_SRC (next)) == LABEL_REF) && GET_CODE (SET_SRC (next)) == LABEL_REF)
...@@ -561,6 +571,7 @@ gen_split (split) ...@@ -561,6 +571,7 @@ gen_split (split)
const char *const name = const char *const name =
((GET_CODE (split) == DEFINE_PEEPHOLE2) ? "peephole2" : "split"); ((GET_CODE (split) == DEFINE_PEEPHOLE2) ? "peephole2" : "split");
const char *unused; const char *unused;
char *used;
if (XVEC (split, 0) == 0) if (XVEC (split, 0) == 0)
fatal ("define_%s (definition %d) lacks a pattern", name, fatal ("define_%s (definition %d) lacks a pattern", name,
...@@ -574,6 +585,7 @@ gen_split (split) ...@@ -574,6 +585,7 @@ gen_split (split)
max_operand_vec (split, 2); max_operand_vec (split, 2);
operands = MAX (max_opno, MAX (max_dup_opno, max_scratch_opno)) + 1; operands = MAX (max_opno, MAX (max_dup_opno, max_scratch_opno)) + 1;
unused = (operands == 0 ? " ATTRIBUTE_UNUSED" : ""); unused = (operands == 0 ? " ATTRIBUTE_UNUSED" : "");
used = xcalloc (1, operands);
/* Output the prototype, function name and argument declarations. */ /* Output the prototype, function name and argument declarations. */
if (GET_CODE (split) == DEFINE_PEEPHOLE2) if (GET_CODE (split) == DEFINE_PEEPHOLE2)
...@@ -645,7 +657,7 @@ gen_split (split) ...@@ -645,7 +657,7 @@ gen_split (split)
printf (" emit ("); printf (" emit (");
else else
printf (" emit_insn ("); printf (" emit_insn (");
gen_exp (next, GET_CODE (split)); gen_exp (next, GET_CODE (split), used);
printf (");\n"); printf (");\n");
if (GET_CODE (next) == SET && GET_CODE (SET_DEST (next)) == PC if (GET_CODE (next) == SET && GET_CODE (SET_DEST (next)) == PC
&& GET_CODE (SET_SRC (next)) == LABEL_REF) && GET_CODE (SET_SRC (next)) == LABEL_REF)
...@@ -658,6 +670,8 @@ gen_split (split) ...@@ -658,6 +670,8 @@ gen_split (split)
printf (" _val = gen_sequence ();\n"); printf (" _val = gen_sequence ();\n");
printf (" end_sequence ();\n"); printf (" end_sequence ();\n");
printf (" return _val;\n}\n\n"); printf (" return _val;\n}\n\n");
free (used);
} }
/* Write a function, `add_clobbers', that is given a PARALLEL of sufficient /* Write a function, `add_clobbers', that is given a PARALLEL of sufficient
...@@ -686,7 +700,7 @@ output_add_clobbers () ...@@ -686,7 +700,7 @@ output_add_clobbers ()
{ {
printf (" XVECEXP (pattern, 0, %d) = ", i); printf (" XVECEXP (pattern, 0, %d) = ", i);
gen_exp (XVECEXP (clobber->pattern, 1, i), gen_exp (XVECEXP (clobber->pattern, 1, i),
GET_CODE (clobber->pattern)); GET_CODE (clobber->pattern), NULL);
printf (";\n"); printf (";\n");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment