Studying note of GCC-3.4.6 source
wuhui_gdnt
这个作者很懒,什么都没留下…
展开
-
Studying note of GCC-3.4.6 source (2)
1.1.1. Identifier of tree node - tree_code Within the definition of tree_node, items like tree_type, tree_decl etc, are used for the semantics ingrediences, for example, tree_type is used for type d原创 2010-02-21 15:10:00 · 1524 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (1)
About 4 years ago, I joined GDNT – the coventure of Nortel in China and worked in project of Radio access network of 3G UMTS; where I used GCC first time. At that time Nortel widely used GCC as the of原创 2010-02-21 15:06:00 · 1963 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (3)
1.1.3. Tree node allocation1.1.3.1. Decision of node sizeThe allocaiton function of tree node is done by make_node below. The detail of parameter code is shown in above tables, note that it is原创 2010-02-22 11:46:00 · 1094 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (4)
1.2. Building tree nodesAbove make_node gives the tool to create nodes for certain tree code. However, this facility is quite primitive. GCC also defines a series functions to create nodes group for原创 2010-02-23 11:44:00 · 914 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (5)
1.2.2. Create node for internal types For internal types of the language, for example, int, unsigned short in C/C++, the compiler will create nodes for these types first when it starts up.1.2.2.1.原创 2010-02-24 12:11:00 · 1010 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (7)
1.2.4. Create node for address conceptIn C++, concept of pointer, reference, and address are exchangable at certain level. The langauage allows to manipulate the content of the address directly via原创 2010-02-26 11:52:00 · 775 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (6)
1.2.3. Create node for real constantNode in GCC to represent real constant is tree_real_cst as below.1.2.3.1. Node of tree_real_cst 702 struct tree_real_cst GTY(())原创 2010-02-25 11:58:00 · 1067 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (8)
1.3. Create nodes for non-unary expressionbuild can be used to create tree node for expression. But it can only accept nodes of expression, and composes them into a more complex one. It can’t be use原创 2010-03-01 11:56:00 · 1024 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (9)
1.4. Create node for uniary expression - build1build1 is same as build, but only builds for unary operators. Saves lion share of calls to build; cuts down use of varargs, which is expensive for RISC原创 2010-03-02 12:10:00 · 675 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (10)
1.6. Create node for types – part 11.6.1. Create node for function typesFirst, we see what FUNCTION_TYPE is:FUNCTION_TYPE[2]² Used to represent the type of non-member functions and of s原创 2010-03-04 11:50:00 · 741 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (10 cont2)
1.6.3.1.1.1.2. Right shiftFor the right shift, it is similar handling. Again, paramter ll is the lower part of the number being shifted, and hl is the high part, while count is the bits原创 2010-03-05 13:01:00 · 698 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (10 cont3)
1.6.1.1.1.1.4. Addition and minusThen for other operation, back in int_const_binop. int_const_binop (continue) 1239 case PLUS_EXPR:1240 overflow = add_double (int1l,原创 2010-03-05 13:03:00 · 1614 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (10 cont4)
1.6.3.1.1.2. Get the resultIn the rest of int_const_binop, the operation result which now are saved in low and hi, will be combined into a tree object with corresponding fields set. Below notru原创 2010-03-05 13:12:00 · 752 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (11)
2. Compiler initializationThis core begins in the main function in file main.c at YOUR-GCC-SOURCE-DIR/gcc directory. This function does nothing but calls toplev_main. 4684 int4685 tople原创 2010-03-08 13:00:00 · 885 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (10 cont1)
1.6.3. Create node for array typeWhen invoking build_array_type, the second parameter index_type should be node of index created in previous sector. 3790 tree3791 build_array_type (tree elt_ty原创 2010-03-05 12:55:00 · 753 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (12)
2.2. Initialize hashtable for typeAfter initializing hashtable for identifier, general_init invokes init_ttree to initialize the hashtable for type. 116 void117 init_ttree (void)原创 2010-03-09 11:58:00 · 617 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (13)
2.2.3.1.5. Information of aggregate type 2.2.3.1.5.1. Overview[2]A class type is represented by either a RECORD_TYPE or a UNION_TYPE. A class declared with the union tag is represe原创 2010-03-10 12:14:00 · 832 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (14)
2.2.3.1.5.2.2.5. Layout of UNIONAbove line 854, rli->t is tree node of the type to be laid out., amd comes at here, field must be a FIELD_DECL. If rli->t is not a RECORD_TYPE, in C++, it must原创 2010-03-16 12:02:00 · 857 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (15)
2.2.3.1.5.2.2.6. FIELD_DECL of RECORD_TYPEWe have known that FIELD_DECL is used to represent a non-static data member, and the detail is given in following FIELD_DECL[2]² These nod原创 2010-03-17 11:50:00 · 1055 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (17)
2.4. Initialize Optimization ParametersBack to general_init, at line 4264 add_params saves elements of lang_independent_params into compiler_params which contains the compiler parameters and their c原创 2010-03-19 11:48:00 · 673 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (18)
3. Preparation According to Parsing Options3.1. Hooks for LangaugesBack to toplev_main, as we mentioned before, it’s appreciate that front-end can make new language introducation easy. In G原创 2010-03-22 12:00:00 · 799 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (19)
3.2.1. Create cpp_readerAt line 205 above, cpp_create_reader tries to create a cpp_reader object. For language requires preprocessor like C and C++, usually compiler should provide a pass to preproc原创 2010-03-23 12:04:00 · 1035 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (19 cont)
Field op_stack in cpp_reader aims to handle multiple-include optimization (using #if !defined and #endif to enclose #include directive), it will holds the tokens of the #if or #elseif expression.原创 2010-03-23 12:07:00 · 858 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (20)
3.2.2. Prepare for switches handling After creating cpp_reader, c_common_init_options confirms the language finally; and initializes related data structure. The function will return information abou原创 2010-03-24 11:40:00 · 635 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (21)
3.3. Handling switches3.3.1. Options related to optimizationBack to decode_options, at line 480, for C++, initialize_diagnostics in lang_hooks points to cxx_initialize_diagnostics. It setups diagn原创 2010-03-25 11:42:00 · 775 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (22)
3.3.2. Initializing options related to targetAt line 605 above, set_target_switch handles options related to compile target. All these options begins with “-m”. 3829 void3830 set_target_switch原创 2010-03-30 11:51:00 · 810 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (26)
3.3.3.1.2. Handling common options For common switches or switches can’t be finished by c_common_handle_option, common_handle_option is invoked. 655 static int656 common_handle_op原创 2010-04-08 12:05:00 · 834 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (26 cont1)
common_handle_option (continue) 909 case OPT_fcall_used_:910 fix_register (arg, 0, 1);911 break;912 913 case OPT_fcall_saved_:914 fix_register (arg, 0, 0)原创 2010-04-13 12:23:00 · 1457 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (26 cont2)
common_handle_option (continue) 1179 case OPT_fprofile:1180 profile_flag = value;1181 break;11821183 case OPT_fprofile_arcs:1184 profile_arc_flag_set = true;1原创 2010-04-13 12:40:00 · 860 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (23)
3.3.3. Handling other optionsNow everything is ready, it’s time to handle options other than –O, the optimization option. decode_options (continue) 618 handle_options (argc, argv, lang_ma原创 2010-03-31 11:56:00 · 628 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (27)
3.3.4. Finish the handlingWhen return from handle_options, decode_options updates other flags accordingly. Orinigal value of flag_no_inline and flag_really_no_inline are 2. If appropriate, flag_no_i原创 2010-04-14 09:25:00 · 695 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (24 cont)
-foptimize-sibling-callsRefer to flag_optimize_sibling_callsCL_COMMON-foptional-diagsEnable optional diagnosticsCL_CXX | CL_ObjCXX-fpack-struct原创 2010-04-01 12:26:00 · 1054 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (24)
3.3.3.1. Usable optionsThis array is initialized in options.c and the initializing value is displayed in following table. It is a long list. For more details, refers to [6], [8]. Note that the en原创 2010-04-01 12:22:00 · 1254 阅读 · 1 评论 -
Studying note of GCC-3.4.6 source (28)
4.1.1. Finish the setup of search pathGCC looks in several different places for headers. On a normal Unix system, if you do not instruct it otherwise, it will look for headers requested with `#inclu原创 2010-04-15 09:46:00 · 671 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (29)
4.1.2. Set up flags controlling lexerBelow, flag_inline_trees, it is 0 if we should not perform inlining, 1 if we should expand functions calls inline at the tree level, and 2 if we should consider原创 2010-04-16 09:50:00 · 710 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (30)
4.1.3. Read in source fileAs now cpp_reader is ready, it is time to read in source files. Below, macro input_line accesses line field of global variable input_location which records the current file原创 2010-04-19 10:13:00 · 819 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (31)
4.1.3.1.1.1. Validate PCH FileIf PCH file is found, it needs ensure this file is valid. 1257 static bool1258 validate_pch (cpp_reader *pfile, _cpp_file *file, const char *pchname)原创 2010-04-20 09:35:00 · 713 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (25)
3.3.3.1.1. Options for C++For C/C++ or obj-C, handle_options of lang_hooks is the same as c_common_handle_option. In below, OPT_* is used as index into cl_options. 251 int252 c_co原创 2010-04-07 11:29:00 · 1061 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (25 cont1)
c_common_handle_option (continue) 401 case OPT_Wbad_function_cast:402 warn_bad_function_cast = value;403 break;404 405 case OPT_Wcast_qual:406 warn_cast_qu原创 2010-04-07 11:33:00 · 1035 阅读 · 0 评论 -
Studying note of GCC-3.4.6 source (25 cont2)
c_common_handle_option (continue) 657 case OPT_Wwrite_strings:658 if (!c_dialect_cxx ())659 flag_const_strings = value;660 else661 warn_write_strings =原创 2010-04-07 11:36:00 · 1018 阅读 · 0 评论