GCC Control Flow and Plugins
|
|
- Elaine Owen
- 6 years ago
- Views:
Transcription
1 Workshop on GCC Control Flow and Plugins GCC Resource Center ( Department of Computer Science and Engineering, Indian Institute of Technology, Bombay July 2010
2 July 2010 Plugins: Outline 1/22 Outline Motivation Plugins in GCC GCC Control Flow Conclusions
3 Part 1 Motivation
4 July 2010 Plugins: Motivation 2/22 Walking the Maze of a Large Code Base Use cscope cd $SOURCE cscope -R Use ctags cd $SOURCE ctags -R Make sure you use exeburant-ctags
5 July 2010 Plugins: Motivation 3/22 The Role of Plugins in Large Software A plugin is neither a stub nor a driver A plugin allows plugging in new modules without making changes at many places Most often a plugin in a C based software is a data structure containing function pointers and other related information The terms plugin and hook are used interchangeably
6 July 2010 Plugins: Motivation 4/22 Plugins in the GCC Driver Source Program cc1 cpp gcc as glibc/newlib ld Target Program
7 July 2010 Plugins: Motivation 4/22 Plugins in the GCC Driver Source Program cc1 cpp gcc as Plugin for a translator in the driver gcc glibc/newlib ld Target Program
8 July 2010 Plugins: Motivation 5/22 Plugins in the Generated Compiler Input Language Compiler Generation Framework Target Name Language Specific Code Language and Machine Independent Generic Code Machine Dependent Generator Code Machine Descriptions Selected Copied Copied Generated Generated Parser Gimplifier Source Program Tree SSA Optimizer RTL Generator Generated Compiler (cc1) Optimizer Code Generator Assembly Program
9 July 2010 Plugins: Motivation 5/22 Plugins in the Generated Compiler Input Language Compiler Generation Framework Target Name Language Specific Code Language and Machine Independent Generic Code Machine Dependent Generator Code Machine Descriptions Selected Plugin for Copied a language front end in cc1 Copied Generated Generated Parser Gimplifier Source Program Tree SSA Optimizer RTL Generator Generated Compiler (cc1) Optimizer Code Generator Assembly Program
10 July 2010 Plugins: Motivation 5/22 Plugins in the Generated Compiler Input Language Compiler Generation Framework Target Name Language Specific Code Language and Machine Independent Generic Code Machine Dependent Generator Code Machine Descriptions Selected Plugin for Copied a Plugin for language front adding passes end in cc1 Copied in cc1 Generated Generated Parser Gimplifier Source Program Tree SSA Optimizer RTL Generator Generated Compiler (cc1) Optimizer Code Generator Assembly Program
11 July 2010 Plugins: Motivation 5/22 Plugins in the Generated Compiler Input Language Compiler Generation Framework Target Name Language Specific Code Language and Machine Independent Generic Code Machine Dependent Generator Code Machine Descriptions Selected Plugin for Copied a Plugin for language front adding passes end in cc1 Copied in cc1 Generated Generated Plugin for code generator in cc1 Parser Gimplifier Source Program Tree SSA Optimizer RTL Generator Generated Compiler (cc1) Optimizer Code Generator Assembly Program
12 Part 2 GCC Plugins
13 July 2010 Plugins: GCC Plugins 6/22 GCC s Solution Plugin Implementation Data Structure Initialization Translator in gcc Array of C structures Development time Front end in cc1 C structure Build time Passes in cc1 Linked list of C structures Development time Back end in cc1 Arrays of structures Build time
14 July 2010 Plugins: GCC Plugins 7/22 Plugin Data Structure in the GCC Driver struct compiler { const char *suffix; /* Use this compiler for input files whose names end in this suffix. */ const char *spec; /* To use this compiler, run this spec. * const char *cpp_spec; /* If non-null, substitute this spec for %C, rather than the usual cpp_spec. */ const int combinable; /* If nonzero, compiler can deal with multiple source files at once (IMA). const int needs_preprocessing; /* If nonzero, source files need to be run through a preprocessor. */ };
15 July 2010 Plugins: GCC Plugins 8/22 Populated Plugin Data Structure in the GCC Driver All entries of Objective C/C++ and some entries of Fortran removed. static const struct compiler default_compilers[] = { {".cc", "#C++", 0, 0, 0}, {".cxx", "#C++", 0, 0, 0}, {".cpp", "#C++", 0, 0, 0}, {".cp", "#C++", 0, 0, 0}, {".c++", "#C++", 0, 0, 0}, {".C", "#C++", 0, 0, 0}, {".CPP", "#C++", 0, 0, 0}, {".ii", "#C++", 0, 0, 0}, {".ads", "#Ada", 0, 0, 0}, {".adb", "#Ada", 0, 0, 0}, {".f", "#Fortran", 0, 0, 0}, {".F", "#Fortran", 0, 0, 0}, {".for", "#Fortran", 0, 0, 0}, {".FOR", "#Fortran", 0, 0, 0}, {".f90", "#Fortran", 0, 0, 0}, {".F90", "#Fortran", 0, 0, 0}, {".p", "#Pascal", 0, 0, 0}, {".pas", "#Pascal", 0, 0, 0}, {".java", "#Java", 0, 0, 0}, {".class", "#Java", 0, 0, 0}, {".c", "@c", 0, 1, 1}, {".h", "@c-header", 0, 0, 0}, {".i", "@cpp-output", 0, 1, 0}, {".s", "@assembler", 0, 1, 0} }
16 July 2010 Plugins: GCC Plugins 8/22 Populated Plugin Data Structure in the GCC Driver All entries of Objective C/C++ and some entries of Fortran removed. static const struct compiler default_compilers[] = { {".cc", "#C++", 0, 0, 0}, {".cxx", "#C++", 0, 0, 0}, {".cpp", "#C++", 0, 0, 0}, {".cp", "#C++", 0, 0, 0}, {".c++", "#C++", 0, 0, 0}, {".C", "#C++", 0, 0, 0}, What about linker files? {".CPP", "#C++", 0, 0, 0}, {".ii", "#C++", 0, 0, 0}, {".ads", "#Ada", 0, 0, 0}, {".adb", "#Ada", 0, 0, 0}, {".f", "#Fortran", 0, 0, 0}, {".F", "#Fortran", 0, 0, 0}, {".for", "#Fortran", 0, 0, 0}, {".FOR", "#Fortran", 0, 0, 0}, {".f90", "#Fortran", 0, 0, 0}, {".F90", "#Fortran", 0, 0, 0}, {".p", "#Pascal", 0, 0, 0}, {".pas", "#Pascal", 0, 0, 0}, {".java", "#Java", 0, 0, 0}, {".class", "#Java", 0, 0, 0}, {".c", "@c", 0, 1, 1}, {".h", "@c-header", 0, 0, 0}, {".i", "@cpp-output", 0, 1, 0}, {".s", "@assembler", 0, 1, 0} }
17 July 2010 Plugins: GCC Plugins 8/22 Populated Plugin Data Structure in the GCC Driver All entries of Objective C/C++ and some entries of Fortran removed. static const struct compiler default_compilers[] = { {".cc", "#C++", 0, 0, 0}, {".cxx", "#C++", 0, 0, 0}, {".cpp", "#C++", 0, 0, 0}, {".cp", "#C++", 0, 0, 0}, {".c++", "#C++", 0, 0, 0}, {".C", "#C++", 0, 0, 0}, What about linker files? {".CPP", "#C++", 0, 0, 0}, {".ii", "#C++", 0, 0, 0}, {".ads", "#Ada", 0, 0, 0}, Linking is {".adb", the last step "#Ada", 0, 0, 0}, {".f", "#Fortran", 0, 0, 0}, {".F", "#Fortran", 0, 0, 0}, {".for", "#Fortran", 0, 0, 0}, {".FOR", "#Fortran", 0, 0, 0}, {".f90", "#Fortran", 0, 0, 0}, {".F90", "#Fortran", 0, 0, 0}, {".p", "#Pascal", 0, 0, 0}, {".pas", "#Pascal", 0, 0, 0}, {".java", "#Java", 0, 0, 0}, {".class", "#Java", 0, 0, 0}, {".c", "@c", 0, 1, 1}, {".h", "@c-header", 0, 0, 0}, {".i", "@cpp-output", 0, 1, 0}, {".s", "@assembler", 0, 1, 0} }
18 July 2010 Plugins: GCC Plugins 8/22 Populated Plugin Data Structure in the GCC Driver All entries of Objective C/C++ and some entries of Fortran removed. static const struct compiler default_compilers[] = { {".cc", "#C++", 0, 0, 0}, {".cxx", "#C++", 0, 0, 0}, {".cpp", "#C++", 0, 0, 0}, {".cp", "#C++", 0, 0, 0}, {".c++", "#C++", 0, 0, 0}, {".C", "#C++", 0, 0, 0}, What about linker files? {".CPP", "#C++", 0, 0, 0}, {".ii", "#C++", 0, 0, 0}, {".ads", "#Ada", 0, 0, 0}, Linking is {".adb", the last step "#Ada", 0, 0, 0}, {".f", "#Fortran", 0, 0, 0}, {".F", "#Fortran", 0, 0, 0}, Every file is passed on to {".for", "#Fortran", 0, 0, 0}, {".FOR", "#Fortran", 0, 0, 0}, linker unless it is suppressed {".f90", "#Fortran", 0, 0, 0}, {".F90", "#Fortran", 0, 0, 0}, {".p", "#Pascal", 0, 0, 0}, {".pas", "#Pascal", 0, 0, 0}, {".java", "#Java", 0, 0, 0}, {".class", "#Java", 0, 0, 0}, {".c", "@c", 0, 1, 1}, {".h", "@c-header", 0, 0, 0}, {".i", "@cpp-output", 0, 1, 0}, {".s", "@assembler", 0, 1, 0} }
19 July 2010 Plugins: GCC Plugins 8/22 Populated Plugin Data Structure in the GCC Driver All entries of Objective C/C++ and some entries of Fortran removed. static const struct compiler default_compilers[] = { {".cc", "#C++", 0, 0, 0}, {".cxx", "#C++", 0, 0, 0}, {".cpp", "#C++", 0, 0, 0}, {".cp", "#C++", 0, 0, 0}, {".c++", "#C++", 0, 0, 0}, {".C", "#C++", 0, 0, 0}, What about linker files? {".CPP", "#C++", 0, 0, 0}, {".ii", "#C++", 0, 0, 0}, {".ads", "#Ada", 0, 0, 0}, Linking is {".adb", the last step "#Ada", 0, 0, 0}, {".f", "#Fortran", 0, 0, 0}, {".F", "#Fortran", 0, 0, 0}, Every file is passed on to {".for", "#Fortran", 0, 0, 0}, {".FOR", "#Fortran", 0, 0, 0}, linker unless it is suppressed {".f90", "#Fortran", 0, 0, 0}, {".F90", "#Fortran", 0, 0, 0}, {".p", "#Pascal", 0, 0, 0}, If a translator {".pas", is not"#pascal", found, 0, 0, 0}, {".java", "#Java", 0, 0, 0}, input file{".class", is assumed to"#java", be a 0, 0, 0}, {".c", "@c", 0, 1, 1}, file for linker {".h", "@c-header", 0, 0, 0}, {".i", "@cpp-output", 0, 1, 0}, {".s", "@assembler", 0, 1, 0} }
20 July 2010 Plugins: GCC Plugins 9/22 Plugin Structure in cc1 toplev main front end pass manager
21 July 2010 Plugins: GCC Plugins 9/22 Plugin Structure in cc1 toplev main front end pass manager double arrow represents control flow whereas single arrow represents pointer or index pass 1 pass 2 pass expand pass n
22 July 2010 Plugins: GCC Plugins 9/22 Plugin Structure in cc1 toplev main front end pass manager pass 1 pass 2 pass expand pass n code for pass 1 code for pass 2 expander code optab table code for pass n
23 July 2010 Plugins: GCC Plugins 9/22 Plugin Structure in cc1 toplev main front end pass manager langhook... pass 1 code for pass 1 code for language 1 code for language 2 code for language n pass 2 pass expand pass n code for pass 2 expander code optab table code for pass n
24 July 2010 Plugins: GCC Plugins 9/22 Plugin Structure in cc1 toplev main front end pass manager langhook... pass 1 code for pass 1 code for language 1 code for language 2 code for language n pass 2 pass expand pass n code for pass 2 expander code optab table code for pass n
25 July 2010 Plugins: GCC Plugins 9/22 Plugin Structure in cc1 toplev main front end pass manager langhook... pass 1 code for pass 1 code for language 1 code for language 2 code for language n pass 2 pass expand pass n code for pass 2 expander code optab table code for pass n
26 July 2010 Plugins: GCC Plugins 9/22 Plugin Structure in cc1 toplev main langhook... code for language 1 code for language 2 code for language n front end pass 1 pass 2 pass expand pass n pass manager code for pass 1 code for pass 2 expander code optab table code for pass n insn data generated code for machine 1 MD n MD 2 MD 1
27 July 2010 Plugins: GCC Plugins 9/22 Plugin Structure in cc1 toplev main langhook... code for language 1 code for language 2 code for language n front end pass 1 pass 2 pass expand pass n pass manager code for pass 1 code for pass 2 expander code optab table code for pass n insn data generated code for machine 2 MD n MD 2 MD 1
28 July 2010 Plugins: GCC Plugins 9/22 Plugin Structure in cc1 toplev main langhook... code for language 1 code for language 2 code for language n front end pass 1 pass 2 pass expand pass n pass manager code for pass 1 code for pass 2 expander code optab table code for pass n insn data generated code for machine n MD n MD 2 MD 1
29 July 2010 Plugins: GCC Plugins 10/22 Front End Plugin Important fields of struct lang hooks instantiated for C #define LANG_HOOKS_FINISH c_common_finish #define LANG_HOOKS_EXPAND_EXPR c_expand_expr #define LANG_HOOKS_PARSE_FILE c_common_parse_file #define LANG_HOOKS_WRITE_GLOBALS c_write_global_declarations
30 July 2010 Plugins: GCC Plugins 11/22 Plugins for Intraprocedural Passes struct opt_pass { enum opt_pass_type type; const char *name; bool (*gate) (void); unsigned int (*execute) (void); struct opt_pass *sub; struct opt_pass *next; int static_pass_number; timevar_id_t tv_id; unsigned int properties_required; unsigned int properties_provided; unsigned int properties_destroyed; unsigned int todo_flags_start; unsigned int todo_flags_finish; }; struct gimple_opt_pass { struct opt_pass pass; }; struct rtl_opt_pass { struct opt_pass pass; };
31 July 2010 Plugins: GCC Plugins 12/22 Plugins for Interprocedural Passes struct ipa_opt_pass_d { struct opt_pass pass; void (*generate_summary) (void); void (*write_summary) (struct cgraph_node_set_def *); void (*read_summary) (void); void (*function_read_summary) (struct cgraph_node *); void (*stmt_fixup) (struct cgraph_node *, gimple *); unsigned int function_transform_todo_flags_start; unsigned int (*function_transform) (struct cgraph_node *); void (*variable_transform) (struct varpool_node *); }; struct simple_ipa_opt_pass { struct opt_pass pass; };
32 Part 3 GCC Control Flow
33 July 2010 Plugins: GCC Control Flow 13/22 gcc Driver Control Flow main /* In file gcc.c */ validate_all_switches lookup_compiler do_spec do_spec_2 do_spec_1 /* Get the name of the compiler */ execute pex_init pex_run pex_run_in_environment obj->funcs->exec_child
34 July 2010 Plugins: GCC Control Flow 13/22 gcc Driver Control Flow main /* In file gcc.c */ validate_all_switches lookup_compiler do_spec Observations do_spec_2 do_spec_1 /* Get the All compilers name of the are invoked compiler by */ this driver execute pex_init pex_run Assembler is also invoked by this driver pex_run_in_environment obj->funcs->exec_child Linker is invoked in the end by default
35 July 2010 Plugins: GCC Control Flow 14/22 cc1 Top Level Control Flow main /* In file toplev.c */ toplev_main decode_options do_compile compile_file lang_hooks.parse_file => c_common_parse_file lang_hooks.decls.final_write_globals => c_write_global_declarations targetm.asm_out.file_end finalize
36 July 2010 Plugins: GCC Control Flow 14/22 cc1 Top Level Control Flow main /* In file toplev.c */ toplev_main decode_options do_compile compile_file Observations lang_hooks.parse_file => c_common_parse_file The entire compilation is lang_hooks.decls.final_write_globals => driven by functions specified c_write_global_declarations in language hooks targetm.asm_out.file_end finalize Bad design!
37 July 2010 Plugins: GCC Control Flow 15/22 cc1 Control Flow: Parsing for C lang_hooks.parse_file => c_common_parse_file c_parse_file c_parser_translation_unit c_parser_external_declaration c_parser_declaration_or_fndef c_parser_declspecs /* parse declarations */ c_parser_compound_statement finish_function /* finish parsing */ c_genericize cgraph_finalize_function /* finalize AST of a function */
38 July 2010 Plugins: GCC Control Flow 15/22 cc1 Control Flow: Parsing for C lang_hooks.parse_file => c_common_parse_file c_parse_file c_parser_translation_unit c_parser_external_declaration Observations c_parser_declaration_or_fndef c_parser_declspecs GCC has moved /* parse to a declarations */ c_parser_compound_statement recursive descent parser from finish_function version /* finish parsing */ c_genericize Earlier parser was generated cgraph_finalize_function using Bison specification /* finalize AST of a function */
39 July 2010 Plugins: GCC Control Flow 16/22 cc1 Control Flow: Lowering Passes for C lang_hooks.decls.final_write_globals => c_write_global_declarations cgraph_finalize_compilation_unit cgraph_analyze_functions /* Create GIMPLE */ cgraph_analyze_function gimplify_function_tree gimplify_body gimplify_stmt gimplify_expr cgraph_lower_function /* Intraprocedural */ tree_lowering_passes execute_pass_list (all_lowering_passes)
40 July 2010 Plugins: GCC Control Flow 16/22 cc1 Control Flow: Lowering Passes for C lang_hooks.decls.final_write_globals => c_write_global_declarations cgraph_finalize_compilation_unit cgraph_analyze_functions /* Create GIMPLE */ Observations cgraph_analyze_function gimplify_function_tree Lowering passes are language gimplify_body independent gimplify_stmt Yet they are being called gimplify_expr from a function in language cgraph_lower_function /* Intraprocedural */ hooks tree_lowering_passes execute_pass_list Bad design! (all_lowering_passes)
41 July 2010 Plugins: GCC Control Flow 17/22 cc1 Control Flow: Optimization and Code Generation Passes lang_hooks.decls.final_write_globals => c_write_global_declarations cgraph_finalize_compilation_unit cgraph_analyze_function /* Create GIMPLE */ cgraph_optimize ipa_passes cgraph_expand_all_functions cgraph_expand_function /* Intraprocedural passes on GIMPLE, */ /* expansion pass, and passes on RTL. */ tree_rest_of_compilation execute_pass_list (&all_passes)
42 July 2010 Plugins: GCC Control Flow 17/22 cc1 Control Flow: Optimization and Code Generation Passes lang_hooks.decls.final_write_globals => c_write_global_declarations cgraph_finalize_compilation_unit cgraph_analyze_function Observations /* Create GIMPLE */ cgraph_optimize Optimization and code ipa_passes generation passes are cgraph_expand_all_functions language independent cgraph_expand_function /* Intraprocedural Yet theypasses are beingon called GIMPLE, */ /* expansionfrom pass, a function and passes in language on RTL. */ tree_rest_of_compilation hooks execute_pass_list (&all_passes) Bad design!
43 July 2010 Plugins: GCC Control Flow 18/22 Organization of Passes Order Task IR Level Pass data structure 1 Lowering GIMPLE Intraproc. struct gimple opt pass 2 Optimizations GIMPLE Interproc. struct ipa opt pass 3 Optimizations GIMPLE Intraproc. struct gimple opt pass 4 RTL Generation GIMPLE Intraproc. struct rtl opt pass 5 Optimization RTL Intraproc. struct rtl opt pass
44 July 2010 Plugins: GCC Control Flow 19/22 Execution Order in Intraprocedural Passes Function 1 Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 2 Function 3 Function 4 Function 5
45 July 2010 Plugins: GCC Control Flow 19/22 Execution Order in Intraprocedural Passes Function 1 Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 2 Function 3 Function 4 Function 5
46 July 2010 Plugins: GCC Control Flow 19/22 Execution Order in Intraprocedural Passes Function 1 Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 2 Function 3 Function 4 Function 5
47 July 2010 Plugins: GCC Control Flow 19/22 Execution Order in Intraprocedural Passes Function 1 Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 2 Function 3 Function 4 Function 5
48 July 2010 Plugins: GCC Control Flow 19/22 Execution Order in Intraprocedural Passes Function 1 Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 2 Function 3 Function 4 Function 5
49 July 2010 Plugins: GCC Control Flow 19/22 Execution Order in Intraprocedural Passes Function 1 Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 2 Function 3 Function 4 Function 5
50 July 2010 Plugins: GCC Control Flow 19/22 Execution Order in Intraprocedural Passes Function 1 Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 2 Function 3 Function 4 Function 5
51 July 2010 Plugins: GCC Control Flow 19/22 Execution Order in Intraprocedural Passes Function 1 Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 2 Function 3 Function 4 Function 5
52 July 2010 Plugins: GCC Control Flow 19/22 Execution Order in Intraprocedural Passes Function 1 Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 2 Function 3 Function 4 Function 5
53 July 2010 Plugins: GCC Control Flow 19/22 Execution Order in Intraprocedural Passes Function 1 Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 2 Function 3 Function 4 Function 5
54 July 2010 Plugins: GCC Control Flow 19/22 Execution Order in Intraprocedural Passes Function 1 Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 2 Function 3 Function 4 Function 5
55 July 2010 Plugins: GCC Control Flow 19/22 Execution Order in Intraprocedural Passes Function 1 Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 2 Function 3 Function 4 Function 5
56 July 2010 Plugins: GCC Control Flow 19/22 Execution Order in Intraprocedural Passes Function 1 Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 2 Function 3 Function 4 Function 5
57 July 2010 Plugins: GCC Control Flow 19/22 Execution Order in Intraprocedural Passes Function 1 Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 2 Function 3 Function 4 Function 5
58 July 2010 Plugins: GCC Control Flow 19/22 Execution Order in Intraprocedural Passes Function 1 Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 2 Function 3 Function 4 Function 5
59 July 2010 Plugins: GCC Control Flow 19/22 Execution Order in Intraprocedural Passes Function 1 Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 2 Function 3 Function 4 Function 5
60 July 2010 Plugins: GCC Control Flow 19/22 Execution Order in Intraprocedural Passes Function 1 Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 2 Function 3 Function 4 Function 5
61 July 2010 Plugins: GCC Control Flow 19/22 Execution Order in Intraprocedural Passes Function 1 Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 2 Function 3 Function 4 Function 5
62 July 2010 Plugins: GCC Control Flow 19/22 Execution Order in Intraprocedural Passes Function 1 Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 2 Function 3 Function 4 Function 5
63 July 2010 Plugins: GCC Control Flow 19/22 Execution Order in Intraprocedural Passes Function 1 Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 2 Function 3 Function 4 Function 5
64 July 2010 Plugins: GCC Control Flow 19/22 Execution Order in Intraprocedural Passes Function 1 Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 2 Function 3 Function 4 Function 5
65 July 2010 Plugins: GCC Control Flow 20/22 Execution Order in Interprocedural Passes Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 1 Function 2 Function 3 Function 4 Function 5
66 July 2010 Plugins: GCC Control Flow 20/22 Execution Order in Interprocedural Passes Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 1 Function 2 Function 3 Function 4 Function 5
67 July 2010 Plugins: GCC Control Flow 20/22 Execution Order in Interprocedural Passes Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 1 Function 2 Function 3 Function 4 Function 5
68 July 2010 Plugins: GCC Control Flow 20/22 Execution Order in Interprocedural Passes Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 1 Function 2 Function 3 Function 4 Function 5
69 July 2010 Plugins: GCC Control Flow 20/22 Execution Order in Interprocedural Passes Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 1 Function 2 Function 3 Function 4 Function 5
70 July 2010 Plugins: GCC Control Flow 20/22 Execution Order in Interprocedural Passes Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 1 Function 2 Function 3 Function 4 Function 5
71 July 2010 Plugins: GCC Control Flow 20/22 Execution Order in Interprocedural Passes Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 1 Function 2 Function 3 Function 4 Function 5
72 July 2010 Plugins: GCC Control Flow 20/22 Execution Order in Interprocedural Passes Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 1 Function 2 Function 3 Function 4 Function 5
73 July 2010 Plugins: GCC Control Flow 20/22 Execution Order in Interprocedural Passes Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 1 Function 2 Function 3 Function 4 Function 5
74 July 2010 Plugins: GCC Control Flow 20/22 Execution Order in Interprocedural Passes Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 1 Function 2 Function 3 Function 4 Function 5
75 July 2010 Plugins: GCC Control Flow 20/22 Execution Order in Interprocedural Passes Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 1 Function 2 Function 3 Function 4 Function 5
76 July 2010 Plugins: GCC Control Flow 20/22 Execution Order in Interprocedural Passes Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 1 Function 2 Function 3 Function 4 Function 5
77 July 2010 Plugins: GCC Control Flow 20/22 Execution Order in Interprocedural Passes Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 1 Function 2 Function 3 Function 4 Function 5
78 July 2010 Plugins: GCC Control Flow 20/22 Execution Order in Interprocedural Passes Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 1 Function 2 Function 3 Function 4 Function 5
79 July 2010 Plugins: GCC Control Flow 20/22 Execution Order in Interprocedural Passes Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 1 Function 2 Function 3 Function 4 Function 5
80 July 2010 Plugins: GCC Control Flow 20/22 Execution Order in Interprocedural Passes Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 1 Function 2 Function 3 Function 4 Function 5
81 July 2010 Plugins: GCC Control Flow 20/22 Execution Order in Interprocedural Passes Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 1 Function 2 Function 3 Function 4 Function 5
82 July 2010 Plugins: GCC Control Flow 20/22 Execution Order in Interprocedural Passes Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 1 Function 2 Function 3 Function 4 Function 5
83 July 2010 Plugins: GCC Control Flow 20/22 Execution Order in Interprocedural Passes Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 1 Function 2 Function 3 Function 4 Function 5
84 July 2010 Plugins: GCC Control Flow 20/22 Execution Order in Interprocedural Passes Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 1 Function 2 Function 3 Function 4 Function 5
85 July 2010 Plugins: GCC Control Flow 20/22 Execution Order in Interprocedural Passes Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Function 1 Function 2 Function 3 Function 4 Function 5
86 July 2010 Plugins: GCC Control Flow 21/22 cc1 Control Flow: GIMPLE to RTL Expansion (pass expand) gimple_expand_cfg expand_gimple_basic_block(bb) expand_gimple_cond(stmt) expand_gimple_stmt(stmt) expand_gimple_stmt_1 (stmt) expand_expr_real_2 expand_expr /* Operands */ expand_expr_real optab_for_tree_code expand_binop /* Now we have rtx for operands */ expand_binop_directly /* The plugin for a machine */ code=optab_handler(binoptab,mode)->insn_code; GEN_FCN emit_insn
87 Part 4 Conclusions
88 July 2010 Plugins: Conclusions 22/22 Conclusions Excellent mechanism of plugging in different translators in the main driver front ends, passes, and back ends in the main compiler However, the plugins have been used in an adhoc manner
Motivation. GCC Control Flow and Plugins. Outline. Essential Abstractions in GCC. Module Binding Mechanisms. Part 1. GCC Resource Center.
Workshop on 1 July 2012 Plugins: Outline 1/61 Outline GCC Control Flow and Plugins GCC Resource Center (www.cse.iitb.ac.in/grc) Department of Computer Science and Engineering, Indian Institute of Technology,
More informationPlugin Mechanisms in GCC
Plugin Mechanisms in GCC (www.cse.iitb.ac.in/ uday) GCC Resource Center, Department of Computer Science and Engineering, Indian Institute of Technology, Bombay 13 June 2014 EAGCC-PLDI-14 Plugins: Outline
More informationThe Design and Implementation of Gnu Compiler Collection
The Design and Implementation of Gnu Compiler Collection Uday Khedker (www.cse.iitb.ac.in/ uday) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay Aug 2008 Part 1 Compilation
More informationGCC Internals: A Conceptual View Part II
: A Conceptual View Part II Abhijat Vichare CFDVS, Indian Institute of Technology, Bombay January 2008 Plan Part I GCC: Conceptual Structure C Program through GCC Building GCC Part II Gimple The MD-RTL
More informationThe Design and Implementation of Gnu Compiler Collection
The Design and Implementation of Gnu Compiler Collection Uday Khedker (www.cse.iitb.ac.in/ uday) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay July 2008 Part 1
More informationGCC The Implementation
GCC 4.0.2 The Implementation GCC Version 4.0.2 Abhijat Vichare (amvichare@iitb.ac.in) Sameera Deshpande (sameera@cse.iitb.ac.in) Indian Institute of Technology, Bombay (http://www.iitb.ac.in) This is edition
More informationIntroduction to Machine Descriptions
Tutorial on Essential Abstractions in GCC Introduction to Machine Descriptions (www.cse.iitb.ac.in/grc) GCC Resource Center, Department of Computer Science and Engineering, Indian Institute of Technology,
More informationCompiler Theory. (GCC the GNU Compiler Collection) Sandro Spina 2009
Compiler Theory (GCC the GNU Compiler Collection) Sandro Spina 2009 GCC Probably the most used compiler. Not only a native compiler but it can also cross-compile any program, producing executables for
More informationspecrtl: A Language for GCC Machine Descriptions
specrtl: A Language for GCC Machine Descriptions GCC Resource Center, Department of Computer Science and Engineering, Indian Institute of Technology, Bombay April 2011 GROW 2011, Chamonix specrtl: Outline
More informationGCC Internals. Diego Novillo Red Hat Canada. CGO 2007 San Jose, California March 2007
GCC Internals Diego Novillo dnovillo@redhat.com Red Hat Canada CGO 2007 San Jose, California March 2007 Outline 1. Overview 2. Source code organization 3. Internal architecture 4. Passes NOTE: Internal
More informationAdvanced Programming & C++ Language
Advanced Programming & C++ Language ~1~ Introduction. Compilation Process Ariel University 2018 Dr. Miri (Kopel) Ben-Nissan 2 Administration Stuff Final Exam: 70% Exercises: 30% Both lectures and exercises
More informationAbout These Slides. GDFA: Generic Data Flow Analyser for GCC. Part 1. Copyright. Outline. Uday Khedker
GDFA: Generic Data Flow Analyser for GCC Uday Khedker (www.cse.iitb.ac.in/ uday) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay Part 1 About These Slides August
More informationShort Notes of CS201
#includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system
More informationCS201 - Introduction to Programming Glossary By
CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with
More informationFirst Level Gray Box Probing
First Level Gray Box Probing (www.cse.iitb.ac.in/ uday) GCC Resource Center, Department of Computer Science and Engineering, Indian Institute of Technology, Bombay January 2012 CS 715 Graybox Probing-I:
More informationIntroduction and Opening Remarks
Workshop on Essential Abstractions in GCC Introduction and Opening Remarks GCC Resource Center (www.cse.iitb.ac.in/grc) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay
More informationCOP4020 Programming Languages. Compilers and Interpreters Robert van Engelen & Chris Lacher
COP4020 ming Languages Compilers and Interpreters Robert van Engelen & Chris Lacher Overview Common compiler and interpreter configurations Virtual machines Integrated development environments Compiler
More informationCS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco
CS 326 Operating Systems C Programming Greg Benson Department of Computer Science University of San Francisco Why C? Fast (good optimizing compilers) Not too high-level (Java, Python, Lisp) Not too low-level
More informationThe Phasewise File Groups of GCC
The Phasewise File Groups of GCC GCC Version 4.0.2 Abhijat Vichare (amvichare@iitb.ac.in) Indian Institute of Technology, Bombay (http://www.iitb.ac.in) This is edition 1.0 of The Phasewise File Groups
More informationRetargeting GCC to Spim: A Recap
Workshop on Essential Abstractions in GCC July 09 Spim MD Levels 0 & 1: Outline 1/32 Outline Incremental Machine Descriptions for Spim: Levels 0 and 1 GCC Resource Center (www.cse.iitb.ac.in/grc Department
More informationLECTURE 3. Compiler Phases
LECTURE 3 Compiler Phases COMPILER PHASES Compilation of a program proceeds through a fixed series of phases. Each phase uses an (intermediate) form of the program produced by an earlier phase. Subsequent
More informationCompiling and Interpreting Programming. Overview of Compilers and Interpreters
Copyright R.A. van Engelen, FSU Department of Computer Science, 2000 Overview of Compilers and Interpreters Common compiler and interpreter configurations Virtual machines Integrated programming environments
More informationComputers Programming Course 5. Iulian Năstac
Computers Programming Course 5 Iulian Năstac Recap from previous course Classification of the programming languages High level (Ada, Pascal, Fortran, etc.) programming languages with strong abstraction
More informationUNIT II Structuring the Data, Computations and Program. Kainjan Sanghavi
UNIT II Structuring the Data, Computations and Program B y Kainjan Sanghavi Contents Monomorphic versus polymorphic type systems Case Study- The type structure of C++ and Java Structuring the computation
More informationWhere We Are. Lexical Analysis. Syntax Analysis. IR Generation. IR Optimization. Code Generation. Machine Code. Optimization.
Where We Are Source Code Lexical Analysis Syntax Analysis Semantic Analysis IR Generation IR Optimization Code Generation Optimization Machine Code Where We Are Source Code Lexical Analysis Syntax Analysis
More informationSEMANTIC ANALYSIS TYPES AND DECLARATIONS
SEMANTIC ANALYSIS CS 403: Type Checking Stefan D. Bruda Winter 2015 Parsing only verifies that the program consists of tokens arranged in a syntactically valid combination now we move to check whether
More informationP.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above
P.G.TRB - COMPUTER SCIENCE Total Marks : 50 Time : 30 Minutes 1. C was primarily developed as a a)systems programming language b) general purpose language c) data processing language d) none of the above
More informationFinal CSE 131B Spring 2004
Login name Signature Name Student ID Final CSE 131B Spring 2004 Page 1 Page 2 Page 3 Page 4 Page 5 Page 6 Page 7 Page 8 (25 points) (24 points) (32 points) (24 points) (28 points) (26 points) (22 points)
More informationProgramming Fundamentals (CS 302 ) Dr. Ihsan Ullah. Lecturer Department of Computer Science & IT University of Balochistan
Programming Fundamentals (CS 302 ) Dr. Ihsan Ullah Lecturer Department of Computer Science & IT University of Balochistan 1 Outline p Introduction p Program development p C language and beginning with
More informationPass-by-Pointer. Advanced Pointer Ideas. Pointers are also used in C to enable a function to modify a variable held by the caller:
Pass-by-Pointer 1 Pointers are also used in C to enable a function to modify a variable held by the caller: void findextrema(const int *pa, int Sz, int *pmin, int *pmax) { *Min = *Max = A[0]; // prime
More informationA simple tutorial on generating PTX assembler out of Ada source code using LLVM NVPTX backend
Institute of Computational Science A simple tutorial on generating PTX assembler out of Ada source code using LLVM NVPTX backend Dmitry Mikushin dmitrymikushin@usich September 14, 2012 Dmitry Mikushin
More informationChapter 11 Introduction to Programming in C
C: A High-Level Language Chapter 11 Introduction to Programming in C Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University! Gives
More informationAn Overview of Compilation
An Overview of Compilation (www.cse.iitb.ac.in/ uday) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay January 2014 cs306 Compilation Overview: Outline 1/18 Outline
More informationChapter 11 Introduction to Programming in C
Chapter 11 Introduction to Programming in C Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University C: A High-Level Language! Gives
More informationType Checking. Outline. General properties of type systems. Types in programming languages. Notation for type rules.
Outline Type Checking General properties of type systems Types in programming languages Notation for type rules Logical rules of inference Common type rules 2 Static Checking Refers to the compile-time
More informationLecture 2. Xiaoguang Wang. January 16th, 2014 STAT 598W. (STAT 598W) Lecture 2 1 / 41
Lecture 2 Xiaoguang Wang STAT 598W January 16th, 2014 (STAT 598W) Lecture 2 1 / 41 Outline 1 GNU compiler and debugger 2 Pointers and Arrays 3 Structures 4 Compilation Process 5 Exercises (STAT 598W) Lecture
More informationLectures 5-6: Introduction to C
Lectures 5-6: Introduction to C Motivation: C is both a high and a low-level language Very useful for systems programming Faster than Java This intro assumes knowledge of Java Focus is on differences Most
More informationExtension of GCC with a fully manageable reverse engineering front end
Proceedings of the 7 th International Conference on Applied Informatics Eger, Hungary, January 28 31, 2007. Vol. 1. pp. 147 154. Extension of GCC with a fully manageable reverse engineering front end Csaba
More informationChapter 7:: Data Types. Mid-Term Test. Mid-Term Test (cont.) Administrative Notes
Chapter 7:: Data Types Programming Language Pragmatics Michael L. Scott Administrative Notes Mid-Term Test Thursday, July 27 2006 at 11:30am No lecture before or after the mid-term test You are responsible
More informationOutline. General properties of type systems. Types in programming languages. Notation for type rules. Common type rules. Logical rules of inference
Type Checking Outline General properties of type systems Types in programming languages Notation for type rules Logical rules of inference Common type rules 2 Static Checking Refers to the compile-time
More informationCompilers Project 3: Semantic Analyzer
Compilers Project 3: Semantic Analyzer CSE 40243 Due April 11, 2006 Updated March 14, 2006 Overview Your compiler is halfway done. It now can both recognize individual elements of the language (scan) and
More informationM2 Instruction Set Architecture
M2 Instruction Set Architecture Module Outline Addressing modes. Instruction classes. MIPS-I ISA. Translating and starting a program. High level languages, Assembly languages and object code. Subroutine
More informationProgram Translation. text. text. binary. binary. C program (p1.c) Compiler (gcc -S) Asm code (p1.s) Assembler (gcc or as) Object code (p1.
Program Translation Compilation & Linking 1 text C program (p1.c) Compiler (gcc -S) text Asm code (p1.s) binary binary Assembler (gcc or as) Object code (p1.o) Linker (gcc or ld) Executable program (p1)
More information9/5/17. The Design and Implementation of Programming Languages. Compilation. Interpretation. Compilation vs. Interpretation. Hybrid Implementation
Language Implementation Methods The Design and Implementation of Programming Languages Compilation Interpretation Hybrid In Text: Chapter 1 2 Compilation Interpretation Translate high-level programs to
More informationMidterm CSE 131 Winter 2014
Student ID Login Name _ Name Signature Midterm CSE 131 Winter 2014 Page 1 Page 2 Page 3 Page 4 Page 5 Page 6 (21 points) (36 points) (28 points) (16 points) (18 points) (20 points) Subtotal (139 points
More informationMidterm CSE 131 Winter 2012
Login Name Signature _ Name Student ID Midterm CSE 131 Winter 2012 Page 1 Page 2 Page 3 Page 4 Page 5 Page 6 (22 points) (29 points) (25 points) (34 points) (20 points) (18 points) Subtotal (148 points
More informationSE352b: Roadmap. SE352b Software Engineering Design Tools. W3: Programming Paradigms
SE352b Software Engineering Design Tools W3: Programming Paradigms Feb. 3, 2005 SE352b, ECE,UWO, Hamada Ghenniwa SE352b: Roadmap CASE Tools: Introduction System Programming Tools Programming Paradigms
More informationChapter 11 Introduction to Programming in C
Chapter 11 Introduction to Programming in C Original slides from Gregory Byrd, North Carolina State University Modified by Chris Wilcox, Yashwant Malaiya Colorado State University C: A High-Level Language
More informationPage 1. Agenda. Programming Languages. C Compilation Process
EE 472 Embedded Systems Dr. Shwetak Patel Assistant Professor Computer Science & Engineering Electrical Engineering Agenda Announcements C programming intro + pointers Shwetak N. Patel - EE 472 2 Programming
More informationUsing GCC as a Research Compiler
Using GCC as a Research Compiler Diego Novillo dnovillo@redhat.com Computer Engineering Seminar Series North Carolina State University October 25, 2004 Introduction GCC is a popular compiler, freely available
More informationC - Basics, Bitwise Operator. Zhaoguo Wang
C - Basics, Bitwise Operator Zhaoguo Wang Java is the best language!!! NO! C is the best!!!! Languages C Java Python 1972 1995 2000 (2.0) Procedure Object oriented Procedure & object oriented Compiled
More informationThe C Preprocessor (and more)!
The C Preprocessor (and more)! Peter Kristensen 2012-11-19 Peter Kristensen The C Preprocessor (and more)! Outline 1 C Pre Processor Compiler Assembler Linker Frontend 2 Simple directives Headers Macros
More informationIntroduction to the C Programming Language
Introduction to the C Programming Language Michael Griffiths Corporate Information and Computing Services The University of Sheffield Email m.griffiths@sheffield.ac.uk Course Outline Part 1 Introduction
More informationGENERIC and GIMPLE: A New Tree Representation for Entire Functions
GENERIC and GIMPLE: A New Tree Representation for Entire Functions Jason Merrill Red Hat, Inc. jason@redhat.com 1 Abstract The tree SSA project requires a tree representation of functions for the optimizers
More informationC Programming Review CSC 4320/6320
C Programming Review CSC 4320/6320 Overview Introduction C program Structure Keywords & C Types Input & Output Arrays Functions Pointers Structures LinkedList Dynamic Memory Allocation Macro Compile &
More informationLectures 5-6: Introduction to C
Lectures 5-6: Introduction to C Motivation: C is both a high and a low-level language Very useful for systems programming Faster than Java This intro assumes knowledge of Java Focus is on differences Most
More informationAnnouncements. My office hours are today in Gates 160 from 1PM-3PM. Programming Project 3 checkpoint due tomorrow night at 11:59PM.
IR Generation Announcements My office hours are today in Gates 160 from 1PM-3PM. Programming Project 3 checkpoint due tomorrow night at 11:59PM. This is a hard deadline and no late submissions will be
More informationQUIZ. What are 3 differences between C and C++ const variables?
QUIZ What are 3 differences between C and C++ const variables? Solution QUIZ Source: http://stackoverflow.com/questions/17349387/scope-of-macros-in-c Solution The C/C++ preprocessor substitutes mechanically,
More information2 Compiling a C program
2 Compiling a C program This chapter describes how to compile C programs using gcc. Programs can be compiled from a single source file or from multiple source files, and may use system libraries and header
More informationModule 2: GNU Tools and Compilation Process Introduction to GCC and History The original GNU C Compiler is developed by Richard Stallman in 1984 to create a complete UNIX like operating systems as free
More informationProgramming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur
Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture - 08 Constants and Inline Functions Welcome to module 6 of Programming
More informationCode Structure Visualization
TECHNISCHE UNIVERSITEIT EINDHOVEN Department of Mathematics and Computer Science MASTER S THESIS Code Structure Visualization by G.L.P.M. Lommerse Supervisor: Dr. Ir. A.C. Telea (TUE) Eindhoven, August
More informationCS5363 Final Review. cs5363 1
CS5363 Final Review cs5363 1 Programming language implementation Programming languages Tools for describing data and algorithms Instructing machines what to do Communicate between computers and programmers
More informationFORM 2 (Please put your name and form # on the scantron!!!!) CS 161 Exam II:
FORM 2 (Please put your name and form # on the scantron!!!!) CS 161 Exam II: True (A)/False(B) (2 pts each): 1. The declaration below declares three pointer variables of type pointer to double that is
More informationAn Architectural Overview of GCC
An Architectural Overview of GCC Diego Novillo dnovillo@redhat.com Red Hat Canada Linux Symposium Ottawa, Canada, July 2006 Topics 1. Overview 2. Development model 3. Compiler infrastructure 4. Intermediate
More informationException Namespaces C Interoperability Templates. More C++ David Chisnall. March 17, 2011
More C++ David Chisnall March 17, 2011 Exceptions A more fashionable goto Provides a second way of sending an error condition up the stack until it can be handled Lets intervening stack frames ignore errors
More informationnftables switchdev support
nftables switchdev support Pablo Neira Ayuso Netdev 1.1 February 2016 Sevilla, Spain nftables switchdev support Steps: Check if switchdev is available If so, transparently insertion
More informationIncremental Machine Descriptions for GCC
Incremental Machine Descriptions for GCC Sameera Deshpande Uday Khedker. (www.cse.iitb.ac.in/ {sameera,uday}) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay September
More informationCS2141 Software Development using C/C++ C++ Basics
CS2141 Software Development using C/C++ C++ Basics Integers Basic Types Can be short, long, or just plain int C++ does not define the size of them other than short
More informationStream Computing using Brook+
Stream Computing using Brook+ School of Electrical Engineering and Computer Science University of Central Florida Slides courtesy of P. Bhaniramka Outline Overview of Brook+ Brook+ Software Architecture
More informationProgram Translation. text. text. binary. binary. C program (p1.c) Compiler (gcc -S) Asm code (p1.s) Assembler (gcc or as) Object code (p1.
Program Translation Compilation & Linking 1 text C program (p1.c) Compiler (gcc -S) text Asm code (p1.s) binary binary Assembler (gcc or as) Object code (p1.o) Linker (gccor ld) Executable program (p)
More informationThe GNU Compiler Collection
The GNU Compiler Collection Diego Novillo dnovillo@redhat.com Gelato Federation Meeting Porto Alegre, Rio Grande do Sul, Brazil October 3, 2005 Introduction GCC is a popular compiler, freely available
More informationWhat is a compiler? var a var b mov 3 a mov 4 r1 cmpi a r1 jge l_e mov 2 b jmp l_d l_e: mov 3 b l_d: ;done
What is a compiler? What is a compiler? Traditionally: Program that analyzes and translates from a high level language (e.g., C++) to low-level assembly language that can be executed by hardware int a,
More informationThe SGI Pro64 Compiler Infrastructure - A Tutorial
The SGI Pro64 Compiler Infrastructure - A Tutorial Guang R. Gao (U of Delaware) J. Dehnert (SGI) J. N. Amaral (U of Alberta) R. Towle (SGI) Acknowledgement The SGI Compiler Development Teams The MIPSpro/Pro64
More informationType Checking. Chapter 6, Section 6.3, 6.5
Type Checking Chapter 6, Section 6.3, 6.5 Inside the Compiler: Front End Lexical analyzer (aka scanner) Converts ASCII or Unicode to a stream of tokens Syntax analyzer (aka parser) Creates a parse tree
More information6.096 Introduction to C++ January (IAP) 2009
MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Welcome to 6.096 Lecture
More informationReview of the C Programming Language
Review of the C Programming Language Prof. James L. Frankel Harvard University Version of 11:55 AM 22-Apr-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights reserved. Reference Manual for the
More informationThe structure of a compiler
The structure of a compiler O(n) A compiler is a lot of fast stuff followed by hard problems scanning parsing intermediate code generation Polynomial time Code optimization: local dataflow, global dataflow,
More informationChapter 1 INTRODUCTION
Chapter 1 INTRODUCTION A digital computer system consists of hardware and software: The hardware consists of the physical components of the system. The software is the collection of programs that a computer
More informationGCC Plugins Die by the Sword
GCC Plugins Die by the Sword Matt Davis (enferex) Ruxcon 2011 mattdavis9@gmail.com November 20 2011 mattdavis9@gmail.com (Ruxcon 2011) Getting Dirty with GCC November 20 2011 1 / 666 Overview 1 Overview
More informationType checking. Jianguo Lu. November 27, slides adapted from Sean Treichler and Alex Aiken s. Jianguo Lu November 27, / 39
Type checking Jianguo Lu November 27, 2014 slides adapted from Sean Treichler and Alex Aiken s Jianguo Lu November 27, 2014 1 / 39 Outline 1 Language translation 2 Type checking 3 optimization Jianguo
More informationHigh Performance Computing Lecture 1. Matthew Jacob Indian Institute of Science
High Performance Computing Lecture 1 Matthew Jacob Indian Institute of Science Agenda 1. Program execution: Compilation, Object files, Function call and return, Address space, Data & its representation
More informationAssembler Programming. Lecture 10
Assembler Programming Lecture 10 Lecture 10 Mixed language programming. C and Basic to MASM Interface. Mixed language programming Combine Basic, C, Pascal with assembler. Call MASM routines from HLL program.
More informationChapter 11 Introduction to Programming in C
C: A High-Level Language Chapter 11 Introduction to Programming in C Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University Gives
More informationUndergraduate Compilers in a Day
Question of the Day Backpatching o.foo(); In Java, the address of foo() is often not known until runtime (due to dynamic class loading), so the method call requires a table lookup. After the first execution
More informationChapter 11 Introduction to Programming in C
Chapter 11 Introduction to Programming in C C: A High-Level Language Gives symbolic names to values don t need to know which register or memory location Provides abstraction of underlying hardware operations
More information6. Pointers, Structs, and Arrays. 1. Juli 2011
1. Juli 2011 Einführung in die Programmierung Introduction to C/C++, Tobias Weinzierl page 1 of 50 Outline Recapitulation Pointers Dynamic Memory Allocation Structs Arrays Bubble Sort Strings Einführung
More informationInstantiation of Template class
Class Templates Templates are like advanced macros. They are useful for building new classes that depend on already existing user defined classes or built-in types. Example: stack of int or stack of double
More informationWelcome to CSE131b: Compiler Construction
Welcome to CSE131b: Compiler Construction Lingjia Tang pic from: http://xkcd.com/303/ Course Information What are compilers? Why do we learn about them? History of compilers Structure of compilers A bit
More informationGeneric Programming in C
Generic Programming in C Void * This is where the real fun starts There is too much coding everywhere else! 1 Using void * and function pointers to write generic code Using libraries to reuse code without
More informationCOMP 181. Agenda. Midterm topics. Today: type checking. Purpose of types. Type errors. Type checking
Agenda COMP 181 Type checking October 21, 2009 Next week OOPSLA: Object-oriented Programming Systems Languages and Applications One of the top PL conferences Monday (Oct 26 th ) In-class midterm Review
More informationComputational Physics Operating systems
Computational Physics numerical methods with C++ (and UNIX) 2018-19 Fernando Barao Instituto Superior Tecnico, Dep. Fisica email: fernando.barao@tecnico.ulisboa.pt Computational Physics 2018-19 (Phys Dep
More informationPioneering Compiler Design
Pioneering Compiler Design NikhitaUpreti;Divya Bali&Aabha Sharma CSE,Dronacharya College of Engineering, Gurgaon, Haryana, India nikhita.upreti@gmail.comdivyabali16@gmail.com aabha6@gmail.com Abstract
More informationCOSC 2P91. Introduction Part Deux. Week 1b. Brock University. Brock University (Week 1b) Introduction Part Deux 1 / 14
COSC 2P91 Introduction Part Deux Week 1b Brock University Brock University (Week 1b) Introduction Part Deux 1 / 14 Source Files Like most other compiled languages, we ll be dealing with a few different
More informationPrograms. Function main. C Refresher. CSCI 4061 Introduction to Operating Systems
Programs CSCI 4061 Introduction to Operating Systems C Program Structure Libraries and header files Compiling and building programs Executing and debugging Instructor: Abhishek Chandra Assume familiarity
More informationENERGY 211 / CME 211. Evolution
ENERGY 211 / CME 211 Lecture 2 September 24, 2008 1 Evolution In the beginning, we all used assembly That was too tedious, so a very crude compiler for FORTRAN was built FORTRAN was still too painful to
More informationData Types. Every program uses data, either explicitly or implicitly to arrive at a result.
Every program uses data, either explicitly or implicitly to arrive at a result. Data in a program is collected into data structures, and is manipulated by algorithms. Algorithms + Data Structures = Programs
More informationSyntax-Directed Translation. Lecture 14
Syntax-Directed Translation Lecture 14 (adapted from slides by R. Bodik) 9/27/2006 Prof. Hilfinger, Lecture 14 1 Motivation: parser as a translator syntax-directed translation stream of tokens parser ASTs,
More informationData and File Structures Laboratory
Tools: Gcov, Cscope, Ctags, and Makefiles Assistant Professor Machine Intelligence Unit Indian Statistical Institute, Kolkata August, 2018 1 Gcov 2 Cscope 3 Ctags 4 Makefiles Gcov Gcov stands for GNU Coverage
More informationCSE 307: Principles of Programming Languages
1 / 26 CSE 307: Principles of Programming Languages Names, Scopes, and Bindings R. Sekar 2 / 26 Topics Bindings 1. Bindings Bindings: Names and Attributes Names are a fundamental abstraction in languages
More information