How to get Register-Transfer-Language (RTL) Code from C and JAVA Code?

余生颓废 提交于 2020-04-10 04:46:14

问题


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.

  1. Abstract Syntax Tree (AST). The -fdump-tree-original-raw switch dumps the textual representation of the AST for given input source.
  2. Gnu SIMPLE representation (GIMPLE) The -fdump-tree-gimple-raw switch dumps the GIMPLE representation of the input source.
  3. Control Flow Graph (CFG). The -fdump-tree-cfg-raw switch dumps the CFG form of the GIMPLE code.
  4. 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.
  5. Assembly Language (ASM). The -S switch dumps the target assembly code for the input. In our case, this is the Pentium assembly language.


来源:https://stackoverflow.com/questions/33624392/how-to-get-register-transfer-language-rtl-code-from-c-and-java-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!