Advance Compiler 2004 Fall
# TO tag FROM line in file/text 1 1 toplev_main 35 main.c 2 1 do_compile 5414 toplev.c 3 1 compile_file 5384 toplev.c 4 1 lang_hooks 2130 toplev.c 5 1 c_common_parse_file 57 c-lang.c 6 1 yyparse 159 c-lex.c 7 1 fndef 357 c-parse.y 8 1 finish_function 403 c-parse.y
It's very fast (about 10mins) on my X31 (1.4G). To define a compile-time variable, I modified the CFLAGS, {BOOT,STAGE1}_CFLAGS. (The 3-stage bootstrap is very complicated, normal make -DBLAH doesn't work.)
# TO tag FROM line in file/text 1 1 toplev_main 43 gcc/main.c 2 1 do_compile 5414 gcc/toplev.c 3 1 compile_file 5384 gcc/toplev.c 4 1 yyparse 162 yyparse (); 5 1 yyparse 162 yyparse (); 6 1 YYLEX 4658 gcc/c-parse.c 7 1 yylex 2102 gcc/c-parse.c 8 1 _yylex 5918 gcc/c-parse.c 9 1 c_lex 5810 gcc/c-parse.c 9 1 last_token 5810 gcc/c-parse.c 10 1 cpp_ttype 5425 gcc/c-parse.c 11 1 TTYPE_TABLE 148 TTYPE_TABLE 12 1 TTYPE_TABLE 148 TTYPE_TABLE 10 1 cpp_get_token 680 tok = cpp_get_token (parse_in);
#define DEFTREECODE(SYM, STRING, TYPE, NARGS) SYM, enum tree_code { #include "tree.def" LAST_AND_UNUSED_TREE_CODE /* A convenient way to get a value for NUM_TREE_CODE. */ }; #undef DEFTREECODE
#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE, const char tree_code_type[] = { #include "tree.def" 'x', #include "c-common.def" }; #undef DEFTREECODE
enum c_tree_code { C_DUMMY_TREE_CODE = LAST_AND_UNUSED_TREE_CODE, // "link" to tree_node !! #include "c-common.def" LAST_C_TREE_CODE };
struct tree_exp GTY(()) { struct tree_common common; int complexity; tree GTY ((special ("tree_exp"), desc ("TREE_CODE ((tree) &%0)"))) operands[1]; };
#define RTX_CODE enum rtx_code enum rtx_code { #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) ENUM , #include "rtl.def" /* rtl expressions are documented here */ #undef DEF_RTL_EXPR LAST_AND_UNUSED_RTX_CODE}; /* A convenient way to get a value for NUM_RTX_CODE. Assumes default enum value assignment. */
Each state contains a action *
which is a linked list. In remove_conflict()
called by make_parser()
utilizes the precdence and association information which comes from symbol to determime whethere this action is applied first (SHIFT action)
In details, it uses a (action *
) pref to record preferred action and (action *
) p for current action. The loop is 2 level, first level is for each states, second is for each actions in that state. When it found an action with higher precedence, it modifies oldaction→suppressed
to 2, i.e., the new action is dominated. (suppressed is used to indicated if this action is suppressed.)
yydefred, defreds()→ sole_reduction()
, in this function, this handles '.' reduction, as the name ``sole'' implies.
Oh, bison's source is more clear than yacc.
In main(), it calls conflicts_solve() → set_conflicts(state), it calls resolve_sr_conflict(state) (only if the action has prec) to solve shift/reduce conflicts by precedence and associcatively. Inside it, it first finds the current reduction action for this state then if a shift has higher prec. Once the solution is out, it calls log_resolution(cur_reduction, which action, shift/reduce/right/left/…) to record the solution and records curresponding things.
this_optab = ! unsignedp && flag_trapv && (GET_MODE_CLASS(mode) == MODE_INT) ? subv_optab : sub_optab; goto binop2; expand_binop()
(define_expand "addsi3" [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "") (plus:SI (match_operand:SI 1 "nonimmediate_operand" "") (match_operand:SI 2 "general_operand" ""))) (clobber (reg:CC 17))])]