Commit 95770ca3 by David Malcolm Committed by David Malcolm

Use rtx_insn internally within generated functions

2014-08-21  David Malcolm  <dmalcolm@redhat.com>

	* recog.h (insn_output_fn): Update this function typedef to match
	the changes below to the generated output functions, strengthening
	the 2nd param from rtx to rtx_insn *.

	* final.c (get_insn_template): Add a checked cast to rtx_insn * on
	insn when invoking an output function, to match the new signature
	of insn_output_fn with a stronger second param.

	* genconditions.c (write_header): In the generated code for
	gencondmd.c, strengthen the global "insn" from rtx to rtx_insn *
	to match the other changes in this patch.

	* genemit.c (gen_split): Strengthen the 1st param "curr_insn" of
	the generated "gen_" functions from rtx to rtx_insn * within their
	implementations.

	* genrecog.c (write_subroutine): Strengthen the 2nd param "insn" of
	the subfunctions within the generated "recog_", "split", "peephole2"
	function trees from rtx to rtx_insn *.  For now, the top-level
	generated functions ("recog", "split", "peephole2") continue to
	take a plain rtx for "insn", to avoid introducing dependencies on
	other patches.  Rename this 2nd param from "insn" to
	"uncast_insn", and reintroduce "insn" as a local variable of type
	rtx_insn *, initialized at the top of the generated function with
	a checked cast on "uncast_insn".
	(make_insn_sequence): Strengthen the 1st param "curr_insn" of
	the generated "gen_" functions from rtx to rtx_insn * within their
	prototypes.

	* genoutput.c (process_template): Strengthen the 2nd param within
	the generated "output_" functions "insn" from rtx to rtx_insn *.

From-SVN: r214257
parent 07db0f9b
2014-08-21 David Malcolm <dmalcolm@redhat.com>
* recog.h (insn_output_fn): Update this function typedef to match
the changes below to the generated output functions, strengthening
the 2nd param from rtx to rtx_insn *.
* final.c (get_insn_template): Add a checked cast to rtx_insn * on
insn when invoking an output function, to match the new signature
of insn_output_fn with a stronger second param.
* genconditions.c (write_header): In the generated code for
gencondmd.c, strengthen the global "insn" from rtx to rtx_insn *
to match the other changes in this patch.
* genemit.c (gen_split): Strengthen the 1st param "curr_insn" of
the generated "gen_" functions from rtx to rtx_insn * within their
implementations.
* genrecog.c (write_subroutine): Strengthen the 2nd param "insn" of
the subfunctions within the generated "recog_", "split", "peephole2"
function trees from rtx to rtx_insn *. For now, the top-level
generated functions ("recog", "split", "peephole2") continue to
take a plain rtx for "insn", to avoid introducing dependencies on
other patches. Rename this 2nd param from "insn" to
"uncast_insn", and reintroduce "insn" as a local variable of type
rtx_insn *, initialized at the top of the generated function with
a checked cast on "uncast_insn".
(make_insn_sequence): Strengthen the 1st param "curr_insn" of
the generated "gen_" functions from rtx to rtx_insn * within their
prototypes.
* genoutput.c (process_template): Strengthen the 2nd param within
the generated "output_" functions "insn" from rtx to rtx_insn *.
2014-08-20 Jan Hubicka <hubicka@ucw.cz> 2014-08-20 Jan Hubicka <hubicka@ucw.cz>
* tree-profile.c (tree_profiling): Skip external functions * tree-profile.c (tree_profiling): Skip external functions
......
...@@ -2055,7 +2055,8 @@ get_insn_template (int code, rtx insn) ...@@ -2055,7 +2055,8 @@ get_insn_template (int code, rtx insn)
return insn_data[code].output.multi[which_alternative]; return insn_data[code].output.multi[which_alternative];
case INSN_OUTPUT_FORMAT_FUNCTION: case INSN_OUTPUT_FORMAT_FUNCTION:
gcc_assert (insn); gcc_assert (insn);
return (*insn_data[code].output.function) (recog_data.operand, insn); return (*insn_data[code].output.function) (recog_data.operand,
as_a <rtx_insn *> (insn));
default: default:
gcc_unreachable (); gcc_unreachable ();
......
...@@ -95,7 +95,7 @@ write_header (void) ...@@ -95,7 +95,7 @@ write_header (void)
puts ("\ puts ("\
/* Dummy external declarations. */\n\ /* Dummy external declarations. */\n\
extern rtx insn;\n\ extern rtx_insn *insn;\n\
extern rtx ins1;\n\ extern rtx ins1;\n\
extern rtx operands[];\n\ extern rtx operands[];\n\
\n\ \n\
......
...@@ -557,15 +557,15 @@ gen_split (rtx split) ...@@ -557,15 +557,15 @@ gen_split (rtx split)
/* 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)
{ {
printf ("extern rtx gen_%s_%d (rtx, rtx *);\n", printf ("extern rtx gen_%s_%d (rtx_insn *, rtx *);\n",
name, insn_code_number); name, insn_code_number);
printf ("rtx\ngen_%s_%d (rtx curr_insn ATTRIBUTE_UNUSED, rtx *operands%s)\n", printf ("rtx\ngen_%s_%d (rtx_insn *curr_insn ATTRIBUTE_UNUSED, rtx *operands%s)\n",
name, insn_code_number, unused); name, insn_code_number, unused);
} }
else else
{ {
printf ("extern rtx gen_split_%d (rtx, rtx *);\n", insn_code_number); printf ("extern rtx gen_split_%d (rtx_insn *, rtx *);\n", insn_code_number);
printf ("rtx\ngen_split_%d (rtx curr_insn ATTRIBUTE_UNUSED, rtx *operands%s)\n", printf ("rtx\ngen_split_%d (rtx_insn *curr_insn ATTRIBUTE_UNUSED, rtx *operands%s)\n",
insn_code_number, unused); insn_code_number, unused);
} }
printf ("{\n"); printf ("{\n");
......
...@@ -643,7 +643,7 @@ process_template (struct data *d, const char *template_code) ...@@ -643,7 +643,7 @@ process_template (struct data *d, const char *template_code)
d->output_format = INSN_OUTPUT_FORMAT_FUNCTION; d->output_format = INSN_OUTPUT_FORMAT_FUNCTION;
puts ("\nstatic const char *"); puts ("\nstatic const char *");
printf ("output_%d (rtx *operands ATTRIBUTE_UNUSED, rtx insn ATTRIBUTE_UNUSED)\n", printf ("output_%d (rtx *operands ATTRIBUTE_UNUSED, rtx_insn *insn ATTRIBUTE_UNUSED)\n",
d->code_number); d->code_number);
puts ("{"); puts ("{");
print_md_ptr_loc (template_code); print_md_ptr_loc (template_code);
...@@ -672,7 +672,7 @@ process_template (struct data *d, const char *template_code) ...@@ -672,7 +672,7 @@ process_template (struct data *d, const char *template_code)
d->output_format = INSN_OUTPUT_FORMAT_FUNCTION; d->output_format = INSN_OUTPUT_FORMAT_FUNCTION;
puts ("\nstatic const char *"); puts ("\nstatic const char *");
printf ("output_%d (rtx *operands ATTRIBUTE_UNUSED, " printf ("output_%d (rtx *operands ATTRIBUTE_UNUSED, "
"rtx insn ATTRIBUTE_UNUSED)\n", d->code_number); "rtx_insn *insn ATTRIBUTE_UNUSED)\n", d->code_number);
puts ("{"); puts ("{");
puts (" switch (which_alternative)\n {"); puts (" switch (which_alternative)\n {");
} }
......
...@@ -2180,6 +2180,7 @@ write_subroutine (struct decision_head *head, enum routine_type type) ...@@ -2180,6 +2180,7 @@ write_subroutine (struct decision_head *head, enum routine_type type)
const char *s_or_e; const char *s_or_e;
char extension[32]; char extension[32];
int i; int i;
const char *insn_param;
s_or_e = subfunction ? "static " : ""; s_or_e = subfunction ? "static " : "";
...@@ -2190,21 +2191,27 @@ write_subroutine (struct decision_head *head, enum routine_type type) ...@@ -2190,21 +2191,27 @@ write_subroutine (struct decision_head *head, enum routine_type type)
else else
strcpy (extension, "_insns"); strcpy (extension, "_insns");
/* For now, the top-level functions take a plain "rtx", and perform a
checked cast to "rtx_insn *" for use throughout the rest of the
function and the code it calls. */
insn_param = subfunction ? "rtx_insn *insn" : "rtx uncast_insn";
switch (type) switch (type)
{ {
case RECOG: case RECOG:
printf ("%sint\n\ printf ("%sint\n\
recog%s (rtx x0 ATTRIBUTE_UNUSED,\n\trtx insn ATTRIBUTE_UNUSED,\n\tint *pnum_clobbers ATTRIBUTE_UNUSED)\n", s_or_e, extension); recog%s (rtx x0 ATTRIBUTE_UNUSED,\n\t%s ATTRIBUTE_UNUSED,\n\tint *pnum_clobbers ATTRIBUTE_UNUSED)\n",
s_or_e, extension, insn_param);
break; break;
case SPLIT: case SPLIT:
printf ("%srtx\n\ printf ("%srtx\n\
split%s (rtx x0 ATTRIBUTE_UNUSED, rtx insn ATTRIBUTE_UNUSED)\n", split%s (rtx x0 ATTRIBUTE_UNUSED, %s ATTRIBUTE_UNUSED)\n",
s_or_e, extension); s_or_e, extension, insn_param);
break; break;
case PEEPHOLE2: case PEEPHOLE2:
printf ("%srtx\n\ printf ("%srtx\n\
peephole2%s (rtx x0 ATTRIBUTE_UNUSED,\n\trtx insn ATTRIBUTE_UNUSED,\n\tint *_pmatch_len ATTRIBUTE_UNUSED)\n", peephole2%s (rtx x0 ATTRIBUTE_UNUSED,\n\t%s ATTRIBUTE_UNUSED,\n\tint *_pmatch_len ATTRIBUTE_UNUSED)\n",
s_or_e, extension); s_or_e, extension, insn_param);
break; break;
} }
...@@ -2217,6 +2224,14 @@ peephole2%s (rtx x0 ATTRIBUTE_UNUSED,\n\trtx insn ATTRIBUTE_UNUSED,\n\tint *_pma ...@@ -2217,6 +2224,14 @@ peephole2%s (rtx x0 ATTRIBUTE_UNUSED,\n\trtx insn ATTRIBUTE_UNUSED,\n\tint *_pma
if (!subfunction) if (!subfunction)
printf (" recog_data.insn = NULL_RTX;\n"); printf (" recog_data.insn = NULL_RTX;\n");
/* For now add the downcast to rtx_insn *, at the top of each top-level
function. */
if (!subfunction)
{
printf (" rtx_insn *insn ATTRIBUTE_UNUSED;\n");
printf (" insn = safe_as_a <rtx_insn *> (uncast_insn);\n");
}
if (head->first) if (head->first)
write_tree (head, &root_pos, type, 1); write_tree (head, &root_pos, type, 1);
else else
...@@ -2461,12 +2476,12 @@ make_insn_sequence (rtx insn, enum routine_type type) ...@@ -2461,12 +2476,12 @@ make_insn_sequence (rtx insn, enum routine_type type)
case SPLIT: case SPLIT:
/* Define the subroutine we will call below and emit in genemit. */ /* Define the subroutine we will call below and emit in genemit. */
printf ("extern rtx gen_split_%d (rtx, rtx *);\n", next_insn_code); printf ("extern rtx gen_split_%d (rtx_insn *, rtx *);\n", next_insn_code);
break; break;
case PEEPHOLE2: case PEEPHOLE2:
/* Define the subroutine we will call below and emit in genemit. */ /* Define the subroutine we will call below and emit in genemit. */
printf ("extern rtx gen_peephole2_%d (rtx, rtx *);\n", printf ("extern rtx gen_peephole2_%d (rtx_insn *, rtx *);\n",
next_insn_code); next_insn_code);
break; break;
} }
......
...@@ -279,7 +279,7 @@ which_op_alt () ...@@ -279,7 +279,7 @@ which_op_alt ()
each insn-code value. */ each insn-code value. */
typedef int (*insn_operand_predicate_fn) (rtx, enum machine_mode); typedef int (*insn_operand_predicate_fn) (rtx, enum machine_mode);
typedef const char * (*insn_output_fn) (rtx *, rtx); typedef const char * (*insn_output_fn) (rtx *, rtx_insn *);
struct insn_gen_fn struct insn_gen_fn
{ {
......
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