RFA: Fix rtl-checking with .md macros

Richard Sandiford rsandifo@redhat.com
Mon Aug 30 19:21:00 GMT 2004


Graham Stott <graham.stott@btinternet.com> writes:
> One thing to watch out for is CODES and MODES are limited to 16 and 8
> bits resp.  I doubt if were anywhere near these limits at present [...]

Agreed.  And I imagine we'd soon notice if the fields ever did overflow.
On the other hand...

> [...] but a check somehere
> in the new md macro handling code should be performing a sanity check against
> these limits.

...it's certainly easy enough to do that.

Patch bootstrapped & regression tested on i686-pc-linux-gnu.  I also
tested that it has no effect on the generated files for mipsisa64-elf.
I'll leave the maintainers to decide whether it's worthwhile or not.

I suppose another thing to worry about is how this will work with
C++ builds.  We'd probably need to extend the range of the enums
to the rtx bitfield widths (using dummy modes and codes).

Richard


	* read-rtl.c (read_rtx_1): Check that the mode and code fit into
	the rtx fields.

Index: read-rtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/read-rtl.c,v
retrieving revision 1.30
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.30 read-rtl.c
*** read-rtl.c	27 Aug 2004 10:12:51 -0000	1.30
--- read-rtl.c	30 Aug 2004 18:51:51 -0000
*************** read_rtx_1 (FILE *infile)
*** 1183,1188 ****
--- 1190,1196 ----
    return_rtx = rtx_alloc (bellwether_code);
    format_ptr = GET_RTX_FORMAT (bellwether_code);
    PUT_CODE (return_rtx, real_code);
+   gcc_assert (GET_CODE (return_rtx) == real_code);
  
    /* If what follows is `: mode ', read it and
       store the mode in the rtx.  */
*************** read_rtx_1 (FILE *infile)
*** 1190,1197 ****
    i = read_skip_spaces (infile);
    if (i == ':')
      {
        read_name (tmp_char, infile);
!       PUT_MODE (return_rtx, find_macro (&modes, tmp_char, infile));
      }
    else
      ungetc (i, infile);
--- 1198,1209 ----
    i = read_skip_spaces (infile);
    if (i == ':')
      {
+       enum machine_mode mode;
+ 
        read_name (tmp_char, infile);
!       mode = find_macro (&modes, tmp_char, infile);
!       PUT_MODE (return_rtx, mode);
!       gcc_assert (GET_MODE (return_rtx) == mode);
      }
    else
      ungetc (i, infile);



More information about the Gcc-patches mailing list