Add simpler alternative to generate gimple
This commit is contained in:
parent
b3916539dd
commit
3e61cc3de2
@ -36,7 +36,7 @@ int main() {
|
|||||||
// To set `-O3`, update it depending on your needs.
|
// To set `-O3`, update it depending on your needs.
|
||||||
gcc_jit_context_set_int_option(ctxt, GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL, 3);
|
gcc_jit_context_set_int_option(ctxt, GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL, 3);
|
||||||
// Very important option to generate the gimple format.
|
// Very important option to generate the gimple format.
|
||||||
gcc_jit_context_add_command_line_option(ctxt, "-fdump-tree-gimple");
|
gcc_jit_context_set_bool_option(ctxt, GCC_JIT_BOOL_OPTION_DUMP_INITIAL_GIMPLE, 1);
|
||||||
create_code(ctxt, NULL);
|
create_code(ctxt, NULL);
|
||||||
|
|
||||||
gcc_jit_context_compile(ctxt);
|
gcc_jit_context_compile(ctxt);
|
||||||
@ -54,21 +54,13 @@ Then we can compile it by using:
|
|||||||
gcc local.c -I `pwd`/gcc/gcc/jit/ -L `pwd`/gcc-build/gcc -lgccjit -o out
|
gcc local.c -I `pwd`/gcc/gcc/jit/ -L `pwd`/gcc-build/gcc -lgccjit -o out
|
||||||
```
|
```
|
||||||
|
|
||||||
Before running it, I recommend running:
|
|
||||||
|
|
||||||
```console
|
|
||||||
rm -rf /tmp/libgccjit-*
|
|
||||||
```
|
|
||||||
|
|
||||||
to make it easier for you to know which folder to look into.
|
|
||||||
|
|
||||||
And finally when you run it:
|
And finally when you run it:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
LD_LIBRARY_PATH=`pwd`/gcc-build/gcc LIBRARY_PATH=`pwd`/gcc-build/gcc ./out
|
LD_LIBRARY_PATH=`pwd`/gcc-build/gcc LIBRARY_PATH=`pwd`/gcc-build/gcc ./out
|
||||||
```
|
```
|
||||||
|
|
||||||
You should now have a file named with path looking like `/tmp/libgccjit-9OFqkD/fake.c.006t.gimple` which contains:
|
It should display:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
__attribute__((const))
|
__attribute__((const))
|
||||||
@ -95,3 +87,25 @@ int xxx ()
|
|||||||
return D.3394;
|
return D.3394;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
An alternative way to generate the GIMPLE is to replace:
|
||||||
|
|
||||||
|
```c
|
||||||
|
gcc_jit_context_set_bool_option(ctxt, GCC_JIT_BOOL_OPTION_DUMP_INITIAL_GIMPLE, 1);
|
||||||
|
```
|
||||||
|
|
||||||
|
with:
|
||||||
|
|
||||||
|
```c
|
||||||
|
gcc_jit_context_add_command_line_option(ctxt, "-fdump-tree-gimple");
|
||||||
|
```
|
||||||
|
|
||||||
|
(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:
|
||||||
|
|
||||||
|
```console
|
||||||
|
rm -rf /tmp/libgccjit-*
|
||||||
|
```
|
||||||
|
|
||||||
|
to make it easier for you to know which folder to look into.
|
||||||
|
|
||||||
|
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.
|
||||||
|
Loading…
Reference in New Issue
Block a user