Skip to content

Commit 3e61cc3

Browse files
Add simpler alternative to generate gimple
1 parent b391653 commit 3e61cc3

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

doc/gimple.md

+24-10
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ int main() {
3636
// To set `-O3`, update it depending on your needs.
3737
gcc_jit_context_set_int_option(ctxt, GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL, 3);
3838
// Very important option to generate the gimple format.
39-
gcc_jit_context_add_command_line_option(ctxt, "-fdump-tree-gimple");
39+
gcc_jit_context_set_bool_option(ctxt, GCC_JIT_BOOL_OPTION_DUMP_INITIAL_GIMPLE, 1);
4040
create_code(ctxt, NULL);
4141

4242
gcc_jit_context_compile(ctxt);
@@ -54,21 +54,13 @@ Then we can compile it by using:
5454
gcc local.c -I `pwd`/gcc/gcc/jit/ -L `pwd`/gcc-build/gcc -lgccjit -o out
5555
```
5656

57-
Before running it, I recommend running:
58-
59-
```console
60-
rm -rf /tmp/libgccjit-*
61-
```
62-
63-
to make it easier for you to know which folder to look into.
64-
6557
And finally when you run it:
6658

6759
```console
6860
LD_LIBRARY_PATH=`pwd`/gcc-build/gcc LIBRARY_PATH=`pwd`/gcc-build/gcc ./out
6961
```
7062

71-
You should now have a file named with path looking like `/tmp/libgccjit-9OFqkD/fake.c.006t.gimple` which contains:
63+
It should display:
7264

7365
```c
7466
__attribute__((const))
@@ -95,3 +87,25 @@ int xxx ()
9587
return D.3394;
9688
}
9789
```
90+
91+
An alternative way to generate the GIMPLE is to replace:
92+
93+
```c
94+
gcc_jit_context_set_bool_option(ctxt, GCC_JIT_BOOL_OPTION_DUMP_INITIAL_GIMPLE, 1);
95+
```
96+
97+
with:
98+
99+
```c
100+
gcc_jit_context_add_command_line_option(ctxt, "-fdump-tree-gimple");
101+
```
102+
103+
(although you can have both at the same time too). Then you can compile it like previously. Only one difference: before executing it, I recommend to run:
104+
105+
```console
106+
rm -rf /tmp/libgccjit-*
107+
```
108+
109+
to make it easier for you to know which folder to look into.
110+
111+
Once the execution is done, you should now have a file with path looking like `/tmp/libgccjit-9OFqkD/fake.c.006t.gimple` which contains the GIMPLE format.

0 commit comments

Comments
 (0)