aboutsummaryrefslogtreecommitdiff
path: root/gcc/genopinit.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2019-07-12 07:54:23 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2019-07-12 07:54:23 +0000
commitd281492de84960b5885f88fffeeb226650f5141d (patch)
tree28304a490e6a430efab5d43f9479dbef727543b4 /gcc/genopinit.c
parent1fdd6f0412922eb7438cbbadbb805fce8cc77485 (diff)
downloadgcc-d281492de84960b5885f88fffeeb226650f5141d.zip
gcc-d281492de84960b5885f88fffeeb226650f5141d.tar.gz
gcc-d281492de84960b5885f88fffeeb226650f5141d.tar.bz2
Support multiple operand counts for .md @ patterns
This patch extends the support for "@..." pattern names so that the patterns can have different numbers of operands. This allows things like binary and ternary operations to be handled in a consistent way, a bit like optabs. The generators assert that the number of operands passed is correct for the underlying instruction. Also, replace_operands_with_dups iterated over the old rtx format even after having decided to do a replacement, which broke with match_operator. 2019-07-12 Richard Sandiford <richard.sandiford@arm.com> gcc/ * doc/md.texi: Document that @ patterns can have different numbers of operands. * genemit.c (handle_overloaded_gen): Handle this case. * genopinit.c (handle_overloaded_gen): Likewise. * gensupport.c (replace_operands_with_dups): Iterate over the new rtx's format rather than the old one's. From-SVN: r273432
Diffstat (limited to 'gcc/genopinit.c')
-rw-r--r--gcc/genopinit.c62
1 files changed, 37 insertions, 25 deletions
diff --git a/gcc/genopinit.c b/gcc/genopinit.c
index ea4c3ce..1dd1d82 100644
--- a/gcc/genopinit.c
+++ b/gcc/genopinit.c
@@ -134,31 +134,43 @@ handle_overloaded_code_for (FILE *file, overloaded_name *oname)
static void
handle_overloaded_gen (FILE *file, overloaded_name *oname)
{
- pattern_stats stats;
- get_pattern_stats (&stats, XVEC (oname->first_instance->insn, 1));
-
- fprintf (file, "\nextern rtx maybe_gen_%s (", oname->name);
- for (unsigned int i = 0; i < oname->arg_types.length (); ++i)
- fprintf (file, "%s%s", i == 0 ? "" : ", ", oname->arg_types[i]);
- for (int i = 0; i < stats.num_generator_args; ++i)
- fprintf (file, ", rtx");
- fprintf (file, ");\n");
-
- fprintf (file, "inline rtx\ngen_%s (", oname->name);
- for (unsigned int i = 0; i < oname->arg_types.length (); ++i)
- fprintf (file, "%s%s arg%d", i == 0 ? "" : ", ", oname->arg_types[i], i);
- for (int i = 0; i < stats.num_generator_args; ++i)
- fprintf (file, ", rtx x%d", i);
- fprintf (file, ")\n{\n rtx res = maybe_gen_%s (", oname->name);
- for (unsigned int i = 0; i < oname->arg_types.length (); ++i)
- fprintf (file, "%sarg%d", i == 0 ? "" : ", ", i);
- for (int i = 0; i < stats.num_generator_args; ++i)
- fprintf (file, ", x%d", i);
- fprintf (file,
- ");\n"
- " gcc_assert (res);\n"
- " return res;\n"
- "}\n");
+ unsigned HOST_WIDE_INT seen = 0;
+ for (overloaded_instance *instance = oname->first_instance->next;
+ instance; instance = instance->next)
+ {
+ pattern_stats stats;
+ get_pattern_stats (&stats, XVEC (instance->insn, 1));
+ unsigned HOST_WIDE_INT mask
+ = HOST_WIDE_INT_1U << stats.num_generator_args;
+ if (seen & mask)
+ continue;
+
+ seen |= mask;
+
+ fprintf (file, "\nextern rtx maybe_gen_%s (", oname->name);
+ for (unsigned int i = 0; i < oname->arg_types.length (); ++i)
+ fprintf (file, "%s%s", i == 0 ? "" : ", ", oname->arg_types[i]);
+ for (int i = 0; i < stats.num_generator_args; ++i)
+ fprintf (file, ", rtx");
+ fprintf (file, ");\n");
+
+ fprintf (file, "inline rtx\ngen_%s (", oname->name);
+ for (unsigned int i = 0; i < oname->arg_types.length (); ++i)
+ fprintf (file, "%s%s arg%d", i == 0 ? "" : ", ",
+ oname->arg_types[i], i);
+ for (int i = 0; i < stats.num_generator_args; ++i)
+ fprintf (file, ", rtx x%d", i);
+ fprintf (file, ")\n{\n rtx res = maybe_gen_%s (", oname->name);
+ for (unsigned int i = 0; i < oname->arg_types.length (); ++i)
+ fprintf (file, "%sarg%d", i == 0 ? "" : ", ", i);
+ for (int i = 0; i < stats.num_generator_args; ++i)
+ fprintf (file, ", x%d", i);
+ fprintf (file,
+ ");\n"
+ " gcc_assert (res);\n"
+ " return res;\n"
+ "}\n");
+ }
}
int