]>
Commit | Line | Data |
---|---|---|
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 | ||
8 | Support for testing GIMPLE passes | |
9 | ********************************* | |
10 | ||
11 | As of gcc 7, C functions can be tagged with ``__GIMPLE`` to indicate | |
12 | that the function body will be GIMPLE, rather than C. The compiler requires | |
13 | the 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 | ||
44 | The ``startwith`` argument indicates at which pass to begin. | |
45 | ||
46 | Use the dump modifier ``-gimple`` (e.g. :option:`-fdump-tree-all-gimple`) | |
47 | to make tree dumps more closely follow the format accepted by the GIMPLE | |
48 | parser. | |
49 | ||
50 | Example DejaGnu tests of GIMPLE can be seen in the source tree at | |
51 | :samp:`gcc/testsuite/gcc.dg/gimplefe-*.c`. | |
52 | ||
53 | The ``__GIMPLE`` parser is integrated with the C tokenizer and | |
54 | preprocessor, so it should be possible to use macros to build out | |
55 | test coverage. |