[Advanced Compiler Lecture Notes] Week 06 (2003/10/20) 1. c_expand_body Phase 1: tree optimization (only tree inline so far) Phase 2: RTL generation (7 steps) Step 1: init_function_start() /* Initialize the RTL code for the function. */ Step 2: expand_function_start() /* Set up parameters and prepare for return, for the function. */ Step 3: walk_tree() /* If the function has a variably modified type, there may be SAVE_EXPRs in the parameter types. Their context must be set to refer to this function; they cannot be expanded in the containing function. */ Step 4: expand_main_function() /* If this function is `main', emit a call to `__main' to run global initializers, etc. */ Step 5: expand_stmt /* Generate the RTL for this function. */ (input: a tree of compund-statement, if-statement, for-statement, etc.) Step 6: lang_expand_function_end() /* Allow language dialects to perform special processing. */ Step 7: expand_function_end() /* Generate rtl for function exit. */ Phase 3: rest of compilation (apply optimizations to RTL) 2. rtx format: (rtx_type, rtx_id, previous_id, next_id, ...) 3. define_attr_queue, define_insns_queue, other_queue 4. I think both tree strucutre and RTL format are similar to the language grammar rules.