Mostly to reduce cut-&-paste.
gcc/
* genemit.cc (start_gen_insn): New function, split out from...
(gen_insn, gen_expand): ...here.
---
gcc/genemit.cc | 45 ++++++++++++++++++++++-----------------------
1 file changed, 22 insertions(+), 23 deletions(-)
diff --git a/gcc/genemit.cc b/gcc/genemit.cc
index b73a45a0412..90f36e293b4 100644
--- a/gcc/genemit.cc
+++ b/gcc/genemit.cc
@@ -427,13 +427,32 @@ maybe_queue_insn (const md_rtx_info &info)
queue.safe_push (info);
}
+/* Output the function name, argument declarations, and initial function
+ body for a pattern called NAME, given that it has the properties
+ in STATS. */
+
+static void
+start_gen_insn (FILE *file, const char *name, const pattern_stats &stats)
+{
+ fprintf (file, "rtx\ngen_%s (", name);
+ if (stats.num_generator_args)
+ for (int i = 0; i < stats.num_generator_args; i++)
+ if (i)
+ fprintf (file, ",\n\trtx operand%d ATTRIBUTE_UNUSED", i);
+ else
+ fprintf (file, "rtx operand%d ATTRIBUTE_UNUSED", i);
+ else
+ fprintf (file, "void");
+ fprintf (file, ")\n");
+ fprintf (file, "{\n");
+}
+
/* Generate the `gen_...' function for a DEFINE_INSN. */
static void
gen_insn (const md_rtx_info &info, FILE *file)
{
struct pattern_stats stats;
- int i;
/* Find out how many operands this function has. */
rtx insn = info.def;
@@ -442,17 +461,7 @@ gen_insn (const md_rtx_info &info, FILE *file)
fatal_at (info.loc, "match_dup operand number has no match_operand");
/* Output the function name and argument declarations. */
- fprintf (file, "rtx\ngen_%s (", XSTR (insn, 0));
- if (stats.num_generator_args)
- for (i = 0; i < stats.num_generator_args; i++)
- if (i)
- fprintf (file, ",\n\trtx operand%d ATTRIBUTE_UNUSED", i);
- else
- fprintf (file, "rtx operand%d ATTRIBUTE_UNUSED", i);
- else
- fprintf (file, "void");
- fprintf (file, ")\n");
- fprintf (file, "{\n");
+ start_gen_insn (file, XSTR (insn, 0), stats);
/* Output code to construct and return the rtl for the instruction body. */
@@ -499,17 +508,7 @@ gen_expand (const md_rtx_info &info, FILE *file)
"numbers above all other operands", XSTR (expand, 0));
/* Output the function name and argument declarations. */
- fprintf (file, "rtx\ngen_%s (", XSTR (expand, 0));
- if (stats.num_generator_args)
- for (i = 0; i < stats.num_generator_args; i++)
- if (i)
- fprintf (file, ",\n\trtx operand%d", i);
- else
- fprintf (file, "rtx operand%d", i);
- else
- fprintf (file, "void");
- fprintf (file, ")\n");
- fprintf (file, "{\n");
+ start_gen_insn (file, XSTR (expand, 0), stats);
/* If we don't have any C code to write, only one insn is being written,
and no MATCH_DUPs are present, we can just return the desired insn
--
2.43.0