diff mbox

[045/236] define_bypass guard functions take a pair of rtx_insn

Message ID 1407345815-14551-46-git-send-email-dmalcolm@redhat.com
State New
Headers show

Commit Message

David Malcolm Aug. 6, 2014, 5:20 p.m. UTC
(define_bypass) clauses in .md files can specify the name of a guard
function as their final operand.  Currently these functions are called
with a pair of rtx.  This patch strengthens insn-automata.c so that such
guard functions are passed a pair of rtx_insn *, allowing these guard
functions to be similarly strengthened in the per-target phase of this
patch kit.

gcc/
	* genautomata.c (output_internal_insn_latency_func): When writing
	the function "internal_insn_latency" to insn-automata.c,
	strengthen params "insn" and "insn2" from rtx to rtx_insn *, thus
	allowing the optional guard function of (define_bypass) clauses to
	expect a pair of rtx_insn *, rather than a pair of rtx.
	(output_insn_latency_func): When writing the function
	"insn_latency", add an "uncast_" prefix to params "insn" and
	"insn2", reintroducing "insn" and "insn2" as rtx_insn * locals
	using checked casts from the params, thus enabling the above
	change to the generated "internal_insn_latency" function.
---
 gcc/genautomata.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Jeff Law Aug. 13, 2014, 6:07 p.m. UTC | #1
On 08/06/14 11:20, David Malcolm wrote:
> (define_bypass) clauses in .md files can specify the name of a guard
> function as their final operand.  Currently these functions are called
> with a pair of rtx.  This patch strengthens insn-automata.c so that such
> guard functions are passed a pair of rtx_insn *, allowing these guard
> functions to be similarly strengthened in the per-target phase of this
> patch kit.
>
> gcc/
> 	* genautomata.c (output_internal_insn_latency_func): When writing
> 	the function "internal_insn_latency" to insn-automata.c,
> 	strengthen params "insn" and "insn2" from rtx to rtx_insn *, thus
> 	allowing the optional guard function of (define_bypass) clauses to
> 	expect a pair of rtx_insn *, rather than a pair of rtx.
> 	(output_insn_latency_func): When writing the function
> 	"insn_latency", add an "uncast_" prefix to params "insn" and
> 	"insn2", reintroducing "insn" and "insn2" as rtx_insn * locals
> 	using checked casts from the params, thus enabling the above
> 	change to the generated "internal_insn_latency" function.
OK.
Jeff
David Malcolm Aug. 21, 2014, 1:59 p.m. UTC | #2
On Wed, 2014-08-13 at 12:07 -0600, Jeff Law wrote:
> On 08/06/14 11:20, David Malcolm wrote:
> > (define_bypass) clauses in .md files can specify the name of a guard
> > function as their final operand.  Currently these functions are called
> > with a pair of rtx.  This patch strengthens insn-automata.c so that such
> > guard functions are passed a pair of rtx_insn *, allowing these guard
> > functions to be similarly strengthened in the per-target phase of this
> > patch kit.
> >
> > gcc/
> > 	* genautomata.c (output_internal_insn_latency_func): When writing
> > 	the function "internal_insn_latency" to insn-automata.c,
> > 	strengthen params "insn" and "insn2" from rtx to rtx_insn *, thus
> > 	allowing the optional guard function of (define_bypass) clauses to
> > 	expect a pair of rtx_insn *, rather than a pair of rtx.
> > 	(output_insn_latency_func): When writing the function
> > 	"insn_latency", add an "uncast_" prefix to params "insn" and
> > 	"insn2", reintroducing "insn" and "insn2" as rtx_insn * locals
> > 	using checked casts from the params, thus enabling the above
> > 	change to the generated "internal_insn_latency" function.
> OK.
Thanks; committed to trunk as r214273, with the trivial fixup of
as_a_nullable to safe_as_a.
diff mbox

Patch

diff --git a/gcc/genautomata.c b/gcc/genautomata.c
index 0c61278..3017e20 100644
--- a/gcc/genautomata.c
+++ b/gcc/genautomata.c
@@ -8360,7 +8360,7 @@  output_internal_insn_latency_func (void)
   decl_t decl;
   struct bypass_decl *bypass;
 
-  fprintf (output_file, "static int\n%s (int %s ATTRIBUTE_UNUSED,\n\tint %s ATTRIBUTE_UNUSED,\n\trtx %s ATTRIBUTE_UNUSED,\n\trtx %s ATTRIBUTE_UNUSED)\n",
+  fprintf (output_file, "static int\n%s (int %s ATTRIBUTE_UNUSED,\n\tint %s ATTRIBUTE_UNUSED,\n\trtx_insn *%s ATTRIBUTE_UNUSED,\n\trtx_insn *%s ATTRIBUTE_UNUSED)\n",
 	   INTERNAL_INSN_LATENCY_FUNC_NAME, INTERNAL_INSN_CODE_NAME,
 	   INTERNAL_INSN2_CODE_NAME, INSN_PARAMETER_NAME,
 	   INSN2_PARAMETER_NAME);
@@ -8477,10 +8477,16 @@  output_internal_maximal_insn_latency_func (void)
 static void
 output_insn_latency_func (void)
 {
-  fprintf (output_file, "int\n%s (rtx %s, rtx %s)\n",
+  fprintf (output_file, "int\n%s (rtx uncast_%s, rtx uncast_%s)\n",
 	   INSN_LATENCY_FUNC_NAME, INSN_PARAMETER_NAME, INSN2_PARAMETER_NAME);
   fprintf (output_file, "{\n  int %s, %s;\n",
 	   INTERNAL_INSN_CODE_NAME, INTERNAL_INSN2_CODE_NAME);
+  fprintf (output_file,
+	   "  rtx_insn *%s = as_a_nullable <rtx_insn *> (uncast_%s);\n",
+	   INSN_PARAMETER_NAME, INSN_PARAMETER_NAME);
+  fprintf (output_file,
+	   "  rtx_insn *%s = as_a_nullable <rtx_insn *> (uncast_%s);\n",
+	   INSN2_PARAMETER_NAME, INSN2_PARAMETER_NAME);
   output_internal_insn_code_evaluation (INSN_PARAMETER_NAME,
 					INTERNAL_INSN_CODE_NAME, 0);
   output_internal_insn_code_evaluation (INSN2_PARAMETER_NAME,