the retargetability model of gcc
play

The Retargetability Model of GCC Uday Khedker - PowerPoint PPT Presentation

Tutorial on Essential Abstractions in GCC The Retargetability Model of GCC Uday Khedker (www.cse.iitb.ac.in/grc) GCC Resource Center, Department of Computer Science and Engineering, Indian Institute of Technology, Bombay April 2011 EA-GCC,


  1. Tutorial on Essential Abstractions in GCC The Retargetability Model of GCC Uday Khedker (www.cse.iitb.ac.in/grc) GCC Resource Center, Department of Computer Science and Engineering, Indian Institute of Technology, Bombay April 2011

  2. EA-GCC, Chamonix Retargetability Model: Outline 1/16 Outline • A Recap • Generating the code generators • Using the generator code generators Uday Khedker GRC, IIT Bombay

  3. Part 1 A Recap

  4. EA-GCC, Chamonix Retargetability Model: A Recap 2/16 Retargetability Mechanism of GCC Input Language Target Name Compiler Generation Framework Language and Machine Language Machine Machine Dependent Development Specific Time Descriptions Independent Generator Code Generic Code Code Build Selected Generated Copied Time Copied Generated Tree SSA Code Use Parser Gimplifier Expander Optimizer Time Optimizer Generator Generated Compiler Uday Khedker GRC, IIT Bombay

  5. EA-GCC, Chamonix Retargetability Model: A Recap 2/16 Retargetability Mechanism of GCC Input Language Target Name Compiler Generation Framework Language and Machine Language Machine Machine Dependent Development Specific Time Descriptions Independent Generator Code Generic Code Code Build Selected Generated Copied Time Copied Generated GIMPLE → IR-RTL Tree SSA Code Use + Parser Gimplifier Expander Optimizer Time Optimizer Generator IR-RTL → ASM Generated Compiler Uday Khedker GRC, IIT Bombay

  6. EA-GCC, Chamonix Retargetability Model: A Recap 2/16 Retargetability Mechanism of GCC Input Language Target Name Compiler Generation Framework GIMPLE → PN + Language and Machine Language Machine Machine Dependent Development PN → IR-RTL Specific Time Descriptions Independent Generator + Code Generic Code Code IR-RTL → ASM Build Selected Generated Copied Time Copied Generated GIMPLE → IR-RTL Tree SSA Code Use + Parser Gimplifier Expander Optimizer Time Optimizer Generator IR-RTL → ASM Generated Compiler Uday Khedker GRC, IIT Bombay

  7. EA-GCC, Chamonix Retargetability Model: A Recap 2/16 Retargetability Mechanism of GCC Input Language Target Name Compiler Generation Framework GIMPLE → PN + Language and Machine Language Machine Machine Dependent Development PN → IR-RTL Specific Time Descriptions Independent Generator + Code Generic Code Code IR-RTL → ASM Build Selected Generated Copied Time Copied Generated GIMPLE → IR-RTL Tree SSA Code Use + Parser Gimplifier Expander Optimizer Time Optimizer Generator IR-RTL → ASM Generated Compiler Uday Khedker GRC, IIT Bombay

  8. EA-GCC, Chamonix Retargetability Model: A Recap 2/16 Retargetability Mechanism of GCC Input Language Target Name Compiler Generation Framework GIMPLE → PN + Language and Machine Language Machine Machine Dependent Development PN → IR-RTL Specific Time Descriptions Independent Generator + Code Generic Code Code IR-RTL → ASM Build Selected Generated Copied Time Copied Generated GIMPLE → IR-RTL Tree SSA Code Use + Parser Gimplifier Expander Optimizer Time Optimizer Generator IR-RTL → ASM Generated Compiler Uday Khedker GRC, IIT Bombay

  9. EA-GCC, Chamonix Retargetability Model: A Recap 3/16 Plugin Structure in cc1 double arrow represents control toplev front pass flow whereas single arrow main end manager represents pointer or index code for pass 1 pass 1 langhook langhook . . . . . . code for pass 2 pass 2 code for code for . . . language 1 language 1 expander code pass code for code for expand optab table language 2 language 2 . . . code for code for code for language n language n pass n pass n Uday Khedker GRC, IIT Bombay

  10. EA-GCC, Chamonix Retargetability Model: A Recap 3/16 Plugin Structure in cc1 MD n toplev front pass main end manager MD 2 code for pass 1 pass 1 langhook langhook MD 1 . . . . . . code for pass 2 pass 2 code for code for . . . language 1 language 1 expander insn data code pass generated code for code for expand optab table code for language 2 language 2 machine 1 . . . code for code for code for language n language n pass n pass n Uday Khedker GRC, IIT Bombay

  11. EA-GCC, Chamonix Retargetability Model: A Recap 3/16 Plugin Structure in cc1 MD n toplev front pass main end manager MD 2 code for pass 1 pass 1 langhook langhook MD 1 . . . . . . code for pass 2 pass 2 code for code for . . . language 1 language 1 expander insn data code pass generated code for code for expand optab table code for language 2 language 2 machine 2 . . . code for code for code for language n language n pass n pass n Uday Khedker GRC, IIT Bombay

  12. EA-GCC, Chamonix Retargetability Model: A Recap 3/16 Plugin Structure in cc1 MD n toplev front pass main end manager MD 2 code for pass 1 pass 1 langhook langhook MD 1 . . . . . . code for pass 2 pass 2 code for code for . . . language 1 language 1 expander insn data code pass generated code for code for expand optab table code for language 2 language 2 machine n . . . code for code for code for language n language n pass n pass n Uday Khedker GRC, IIT Bombay

  13. EA-GCC, Chamonix Retargetability Model: A Recap 4/16 What is “Generated”? • Info about instructions supported by chosen target, e.g. ◮ Listing data structures (e.g. instruction pattern lists) ◮ Indexing data structures, since diff. targets give diff. lists. • C functions that generate RTL internal representation • Any useful “attributes”, e.g. ◮ Semantic groupings: arithmetic, logical, I/O etc. ◮ Processor unit usage groups for pipeline utilisation Uday Khedker GRC, IIT Bombay

  14. EA-GCC, Chamonix Retargetability Model: A Recap 5/16 Information supplied by the MD • The target instructions – as ASM strings • A description of the semantics of each • A description of the features of each like ◮ Data size limits ◮ One of the operands must be a register ◮ Implicit operands ◮ Register restrictions Information supplied in define insn as The target instruction ASM string A description of it’s semantics RTL Template Operand data size limits predicates Register restrictions constraints Uday Khedker GRC, IIT Bombay

  15. Part 2 Generating the Code Generators

  16. EA-GCC, Chamonix Retargetability Model: Generating the Code Generators 6/16 How GCC uses target specific RTL as IR GIMPLE ASSIGN (set (<dest>) (<src>)) Uday Khedker GRC, IIT Bombay

  17. EA-GCC, Chamonix Retargetability Model: Generating the Code Generators 6/16 How GCC uses target specific RTL as IR GIMPLE ASSIGN "movsi" (set (<dest>) (<src>)) Standard Pattern Name Uday Khedker GRC, IIT Bombay

  18. EA-GCC, Chamonix Retargetability Model: Generating the Code Generators 6/16 How GCC uses target specific RTL as IR GIMPLE ASSIGN "movsi" (set (<dest>) (<src>)) Standard Pattern Name Separate CGF code and MD GIMPLE ASSIGN "movsi" "movsi" (set (<dest>) (<src>)) Uday Khedker GRC, IIT Bombay

  19. EA-GCC, Chamonix Retargetability Model: Generating the Code Generators 6/16 How GCC uses target specific RTL as IR GIMPLE ASSIGN "movsi" (set (<dest>) (<src>)) Standard Pattern Name Separate CGF code and MD GIMPLE ASSIGN "movsi" "movsi" (set (<dest>) (<src>)) Implement GIMPLE ASSIGN "movsi" "movsi" (set (<dest>) (<src>)) Unnecessary in CGF; Implement in MD hard code Uday Khedker GRC, IIT Bombay

  20. EA-GCC, Chamonix Retargetability Model: Generating the Code Generators 7/16 Retargetability ⇒ Multiple MD vs. One CGF! MD 1 CGF "movsi" , (set (<dest>) (<src>)) GIMPLE ASSIGN "movsi" MD n "movsi" , (set (<dest>) (<src>)) CGF needs: An interface immune to MD authoring variations Uday Khedker GRC, IIT Bombay

  21. EA-GCC, Chamonix Retargetability Model: Generating the Code Generators 7/16 Retargetability ⇒ Multiple MD vs. One CGF! MD 1 CGF "movsi" , (set (<dest>) (<src>)) GIMPLE ASSIGN "movsi" How ? MD n "movsi" , (set (<dest>) (<src>)) CGF needs: An interface immune to MD authoring variations Uday Khedker GRC, IIT Bombay

  22. EA-GCC, Chamonix Retargetability Model: Generating the Code Generators 7/16 Retargetability ⇒ Multiple MD vs. One CGF! MD 1 CGF "movsi" , (set (<dest>) (<src>)) GIMPLE ASSIGN "movsi" How ? MD n "movsi" , (set (<dest>) (<src>)) Basic Approach: Tabulate GIMPLE – RTL struct optab [] struct insn data [] CGF needs: An interface immune to MD authoring variations Uday Khedker GRC, IIT Bombay

  23. EA-GCC, Chamonix Retargetability Model: Generating the Code Generators 8/16 MD Information Data Structures Two principal data structures • struct optab – Interface to CGF • struct insn data – All information about a pattern ◮ Array of each pattern read ◮ Some patterns are SPNs ◮ Each pattern is accessed using the generated index Supporting data structures • enum insn code : Index of patterns available in the given MD Note Data structures are named in the CGF, but populated at build time. Generating target specific code = populating these data structures. Uday Khedker GRC, IIT Bombay

Recommend


More recommend