Game with gcc intermediate format

According to this article, gcc uses several intermediate formats before generating the code. I read that the GIMPLE format uses three address codes, which seems to be the easiest intermediate language to use. But I need more detail, since I need to create a tool that can take intermediate code and insert some code into it before creating the final code.

To do this, I first need to know how I can even generate GIMPLE format code and save it in a file. Therefore, I am looking for some documents and examples. Also, if someone has worked with such things, can I know the complexity of this task, which is to insert some code into the intermediate code?

+7
source share
3 answers

It might be easier for you to write a plugin for GCC, which allows you to enable GIMPLE generation and change it inside GCC, which should eliminate downtime when saving, editing, and then trying to compile from the GIMPLE form. MELT is one such plugin (although it offers more than just changing lower-level representations). There is also a good PDF here on plugins that modify GIMPLE.

Otherwise, you can look here for information on how GCC GIMPLE works. In terms of resetting GIMPLE:

You can request a reset of the C-shaped representation of the GIMPLE form using the -fdump-tree-gimple flag.

+13
source

You can easily generate a GIMPLE representation of any file using the -fdump-tree-gimple .

If you want to write a plugin, you might be wondering how gaps work in GCC. You can see the output of each pass with the flags of the form:

 -fdump-<ir>-<passname> 

where ir may be:

  • tree : GIMPLE in-processor skips
  • ipa : GIMPLE Intermediate Passes
  • rtl : internal rtl transfers over RTL

Use <passname> = all to see all dumps, for example. -fdump-ipa-all .

+5
source

I tried the -fdump-tree-gimple . It works only for C / C ++, and not for other languages ​​such as Java, Ada, Fortran, and Objective-C)

-one
source

All Articles