diff mbox

[044/236] Pass "insn" as an rtx_insn within generated get_attr_ fns in insn-attrtab.c

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

Commit Message

David Malcolm Aug. 6, 2014, 5:20 p.m. UTC
Strengthen "insn" from rtx to rtx_insn * within the generated get_attr_
functions in insn-attrtab.c, without imposing a strengthening from rtx
to rtx_insn * on the param itself and thus the callers.

gcc/
	* genattrtab.c (write_attr_get): Within the generated get_attr_
	functions, rename param "insn" to "uncast_insn" and reintroduce
	"insn" as an local rtx_insn * using a checked cast, so that "insn"
	is an rtx_insn * within insn-attrtab.c
---
 gcc/genattrtab.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Jeff Law Aug. 13, 2014, 6:07 p.m. UTC | #1
On 08/06/14 11:20, David Malcolm wrote:
> Strengthen "insn" from rtx to rtx_insn * within the generated get_attr_
> functions in insn-attrtab.c, without imposing a strengthening from rtx
> to rtx_insn * on the param itself and thus the callers.
>
> gcc/
> 	* genattrtab.c (write_attr_get): Within the generated get_attr_
> 	functions, rename param "insn" to "uncast_insn" and reintroduce
> 	"insn" as an local rtx_insn * using a checked cast, so that "insn"
> 	is an rtx_insn * within insn-attrtab.c
OK.
Jeff
David Malcolm Aug. 21, 2014, 10:10 a.m. UTC | #2
On Wed, 2014-08-13 at 12:07 -0600, Jeff Law wrote:
> On 08/06/14 11:20, David Malcolm wrote:
> > Strengthen "insn" from rtx to rtx_insn * within the generated get_attr_
> > functions in insn-attrtab.c, without imposing a strengthening from rtx
> > to rtx_insn * on the param itself and thus the callers.
> >
> > gcc/
> > 	* genattrtab.c (write_attr_get): Within the generated get_attr_
> > 	functions, rename param "insn" to "uncast_insn" and reintroduce
> > 	"insn" as an local rtx_insn * using a checked cast, so that "insn"
> > 	is an rtx_insn * within insn-attrtab.c
> OK.
Thanks; committed to trunk as r214265.
diff mbox

Patch

diff --git a/gcc/genattrtab.c b/gcc/genattrtab.c
index c5ce51c..68d05d07 100644
--- a/gcc/genattrtab.c
+++ b/gcc/genattrtab.c
@@ -4027,9 +4027,9 @@  write_attr_get (FILE *outf, struct attr_desc *attr)
   /* If the attribute name starts with a star, the remainder is the name of
      the subroutine to use, instead of `get_attr_...'.  */
   if (attr->name[0] == '*')
-    fprintf (outf, "%s (rtx insn ATTRIBUTE_UNUSED)\n", &attr->name[1]);
+    fprintf (outf, "%s (rtx uncast_insn ATTRIBUTE_UNUSED)\n", &attr->name[1]);
   else if (attr->is_const == 0)
-    fprintf (outf, "get_attr_%s (rtx insn ATTRIBUTE_UNUSED)\n", attr->name);
+    fprintf (outf, "get_attr_%s (rtx uncast_insn ATTRIBUTE_UNUSED)\n", attr->name);
   else
     {
       fprintf (outf, "get_attr_%s (void)\n", attr->name);
@@ -4050,6 +4050,9 @@  write_attr_get (FILE *outf, struct attr_desc *attr)
 
   fprintf (outf, "{\n");
 
+  if (attr->name[0] == '*' || attr->is_const == 0)
+    fprintf (outf, "  rtx_insn *insn = as_a <rtx_insn *> (uncast_insn);\n");
+
   /* Find attributes that are worth caching in the conditions.  */
   cached_attr_count = 0;
   attrs_seen_more_than_once = 0;