]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/doc/gccint/testsuites/support-for-testing-gimple-passes.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / doc / gccint / testsuites / support-for-testing-gimple-passes.rst
CommitLineData
c63539ff
ML
1..
2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
5
6.. _gimple-tests:
7
8Support for testing GIMPLE passes
9*********************************
10
11As of gcc 7, C functions can be tagged with ``__GIMPLE`` to indicate
12that the function body will be GIMPLE, rather than C. The compiler requires
13the option :option:`-fgimple` to enable this functionality. For example:
14
15.. code-block:: c++
16
17 /* { dg-do compile } */
18 /* { dg-options "-O -fgimple" } */
19
20 void __GIMPLE (startwith ("dse2")) foo ()
21 {
22 int a;
23
24 bb_2:
25 if (a > 4)
26 goto bb_3;
27 else
28 goto bb_4;
29
30 bb_3:
31 a_2 = 10;
32 goto bb_5;
33
34 bb_4:
35 a_3 = 20;
36
37 bb_5:
38 a_1 = __PHI (bb_3: a_2, bb_4: a_3);
39 a_4 = a_1 + 4;
40
41 return;
42 }
43
44The ``startwith`` argument indicates at which pass to begin.
45
46Use the dump modifier ``-gimple`` (e.g. :option:`-fdump-tree-all-gimple`)
47to make tree dumps more closely follow the format accepted by the GIMPLE
48parser.
49
50Example DejaGnu tests of GIMPLE can be seen in the source tree at
51:samp:`gcc/testsuite/gcc.dg/gimplefe-*.c`.
52
53The ``__GIMPLE`` parser is integrated with the C tokenizer and
54preprocessor, so it should be possible to use macros to build out
3ed1b4ce 55test coverage.