Login | Contact Us | Essential Abstractions in GCC '10 A Workshop on GCC Internals by GCC Resource CenterJuly 5-8, 2010, IIT Bombay Department of Computer Science & EngineeringIndian Institute of Technology, Bombay Assignment on RTL IR Manipulation Problem Statement Traverse the RTL level CFG Print a more understandable RTL code by using "=" for set operations, converting prefix expressions into infix, and using familiar symbols for operations. Ignore non-instruction organisational rtx's like NOTE insns. Example: For the following two rtl instructions : (insn 5 4 6 3 1.c:15 (set (reg:SI 59) (mem/c/i:SI (plus:SI (reg/f:SI 54 virtual-stack-vars) (const_int -8 [0xfffffff8])) [0 b+0 S4 A32])) -1 (nil)) (insn 6 5 7 3 1.c:15 (set (reg:SI 61) (mem/c/i:SI (plus:SI (reg/f:SI 54 virtual-stack-vars) (const_int -4 [0xfffffffc])) [0 a+0 S4 A32])) -1 (nil)) (insn 7 6 8 3 1.c:15 (parallel [ (set (reg:SI 60) (plus:SI (reg:SI 61) (reg:SI 59))) (clobber (reg:CC 17 flags)) ]) -1 (nil)) Generate the following: r59 = *(r54 - 8) r61 = *(r54 - 4) r60 = r61 + r59 || clobber r17 Hints: A. Possible approach: Take a very simple program, eg. main() { int a,b,c; c = a + b; } Generate the rtl dump by executing gcc. Inspect the rtl dump of pass_expand. Extend the base code to handle rtl objects appearing in the rtl dump of the above program. Handle other rtl objects. B. Solution hint: Use recursion. Trying modifying the base code. Debugging AID: use GET_RTX_NAME(int rxt_code) to print the ascii string describing the rtl object you are currently processing. Anticipated Problems: The most important macros needed are: GET_CODE GET_RTX_NAME Accessor functions, XINT, XEXP,XSTR,XVEC What are The CODES of the RTL objects? Handle these cases first: PLUS, MINUS, MUL, DIV GE,LE,GT... NEG, NOT SET MEM, REG CONST_INT SYMBOL_REF, LABEL_REF, CODE_LABEL PC,COMPARE,IF_THEN_ELSE USE,CC0 All content copyright © 2010, GCC Resource Center