This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] genemit.c: Generate gen_rtx_fmt_e* instead of gen_rtx.


Hi,

Attached is a patch to have genemit.c generate gen_rtx_fmt_e* instead
of gen_rtx.

GCC with this patch would fail if somebody exploited variable length
arguments' nature of gen_rtx.  For example, if we had

  (match_op_dup 0 [(match_dup 1) (match_dup 2)])

and the arity of GET_CODE (operands[0]) could change at run time, then
we would be in trouble, but that IMHO people really shouldn't be using
.md this way.

Tested on i686-pc-linux-gnu.  OK to apply?

Kazu Hirata

2004-02-01  Kazu Hirata  <kazu@cs.umass.edu>

	* genemit.c (gen_exp): Generate gen_rtx_fmt_e* instead of
	gen_rtx.

Index: genemit.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/genemit.c,v
retrieving revision 1.88
diff -u -r1.88 genemit.c
--- genemit.c	21 Jan 2004 20:40:00 -0000	1.88
+++ genemit.c	1 Feb 2004 22:40:06 -0000
@@ -178,7 +178,10 @@
       return;
 
     case MATCH_OP_DUP:
-      printf ("gen_rtx (GET_CODE (operand%d), ", XINT (x, 0));
+      printf ("gen_rtx_fmt_");
+      for (i = 0; i < XVECLEN (x, 1); i++)
+	printf ("e");
+      printf (" (GET_CODE (operand%d), ", XINT (x, 0));
       if (GET_MODE (x) == VOIDmode)
 	printf ("GET_MODE (operand%d)", XINT (x, 0));
       else
@@ -192,7 +195,10 @@
       return;
 
     case MATCH_OPERATOR:
-      printf ("gen_rtx (GET_CODE (operand%d)", XINT (x, 0));
+      printf ("gen_rtx_fmt_");
+      for (i = 0; i < XVECLEN (x, 2); i++)
+	printf ("e");
+      printf (" (GET_CODE (operand%d)", XINT (x, 0));
       printf (", %smode", GET_MODE_NAME (GET_MODE (x)));
       for (i = 0; i < XVECLEN (x, 2); i++)
 	{


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]