RTL Tests (GNU Compiler Collection (GCC) Internals)

### 6.11 Support for testing RTL passes ¶

As of gcc 7, C functions can be tagged with `__RTL` to indicate that the function body will be RTL, rather than C. For example:

    double __RTL (startwith ("ira")) test (struct foo *f, const struct bar *b)
    {
      (function "test"
         [...snip; various directives go in here...]
      ) ;; function "test"
    }

The `startwith` argument indicates at which pass to begin.

The parser expects the RTL body to be in the format emitted by this dumping function:

    DEBUG_FUNCTION void
    print_rtx_function (FILE *outfile, function *fn, bool compact);

when "compact" is true. So you can capture RTL in the correct format from the debugger using:

    (gdb) print_rtx_function (stderr, cfun, true);

and copy and paste the output into the body of the C function.

Example DejaGnu tests of RTL can be seen in the source tree under `gcc/testsuite/gcc.dg/rtl`.

The `__RTL` parser is not integrated with the C tokenizer or preprocessor, and works simply by reading the relevant lines within the braces. In particular, the RTL body must be on separate lines from the enclosing braces, and the preprocessor is not usable within it.