When any compiler like GCC compiles a C Program it generates intermediate code. Just like we can get Assembly code by applying -s option to any .c file, similarly I want to get Register-Transfer-Language (RTL) for C and JAVA file . How to get it ?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
The three adress code is called gimple, see e.g. https://gcc.gnu.org/onlinedocs/gccint/GIMPLE.html but this seems more frontend-backend communication, it can be dumped using
gcc -fdump-tree-gimple <file>
See http://www.cse.iitb.ac.in/~uday/courses/cs324-05/gccProjects/node4.html
from some more IR related dumping options from HLL to deep. Probably you want option 4.
- Abstract Syntax Tree (AST). The -fdump-tree-original-raw switch dumps the textual representation of the AST for given input source.
- Gnu SIMPLE representation (GIMPLE) The -fdump-tree-gimple-raw switch dumps the GIMPLE representation of the input source.
- Control Flow Graph (CFG). The -fdump-tree-cfg-raw switch dumps the CFG form of the GIMPLE code.
- Register Transfer Language (RTL IR) The -da switch dumps the RTL IR of the input source program with the pass number as a part of the dump file name.
- Assembly Language (ASM). The -S switch dumps the target assembly code for the input. In our case, this is the Pentium assembly language.