Tutorial on Essential Abstractions in GCC
Introduction to Machine Descriptions
Uday Khedker
(www.cse.iitb.ac.in/grc) GCC Resource Center, Department of Computer Science and Engineering, Indian Institute of Technology, Bombay
April 2011
Introduction to Machine Descriptions Uday Khedker - - PowerPoint PPT Presentation
Tutorial on Essential Abstractions in GCC Introduction to Machine Descriptions Uday Khedker (www.cse.iitb.ac.in/grc) GCC Resource Center, Department of Computer Science and Engineering, Indian Institute of Technology, Bombay April 2011
(www.cse.iitb.ac.in/grc) GCC Resource Center, Department of Computer Science and Engineering, Indian Institute of Technology, Bombay
April 2011
EA-GCC, Chamonix MD Intro: Outline 1/21
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: Outline 2/21
Machine Description Source Language
<target>.h GCC Architecture
instruction selection
<target>.h Build System Host System hwint.h Target System
Architecture
executable formats
<target>.h <target>.h
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: Organization of GCC MD 3/21
◮ Peephole optimizations ◮ Transformations for enabling scheduling
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: Organization of GCC MD 4/21
◮ Processor instructions useful to GCC ◮ One GIMPLE → One IR-RTL
define insn
◮ One GIMPLE → More than one IR-RTL
define expand
◮ Processor characteristics useful to GCC
define cpu unit
◮ Target ASM syntax
part of define insn
◮ IR-RTL → IR-RTL transformations
define split
◮ Target Specific Optimizations
define peephole2
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: Organization of GCC MD 5/21
◮ HLL properties: e.g. INT TYPE SIZE to h/w bits ◮ Activation record structure ◮ Target Register (sub)sets, and characteristics
(lists of read-only regs, dedicated regs, etc.)
◮ System Software details: formats of assembler, executable etc.
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: Organization of GCC MD 5/21
◮ HLL properties: e.g. INT TYPE SIZE to h/w bits ◮ Activation record structure ◮ Target Register (sub)sets, and characteristics
(lists of read-only regs, dedicated regs, etc.)
◮ System Software details: formats of assembler, executable etc.
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: Essential Constructs in Machine Descriptions 6/21
Target Independent Target Dependent Parse Gimplify Tree SSA Optimize Generate RTL Optimize RTL Generate ASM GIMPLE → RTL RTL → ASM
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: Essential Constructs in Machine Descriptions 6/21
Target Independent Target Dependent Parse Gimplify Tree SSA Optimize Generate RTL Optimize RTL Generate ASM GIMPLE → RTL RTL → ASM
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: Essential Constructs in Machine Descriptions 7/21
◮ operator match + coarse operand match, and ◮ refine the operand match
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: Essential Constructs in Machine Descriptions 8/21
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: Essential Constructs in Machine Descriptions 9/21
[(set (match_operand:SI 0 "register_operand" "r") (match_operand:SI 1 "const_int_operand" "k") )]
C boolean expression, if required */
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: Essential Constructs in Machine Descriptions 9/21
[(set (match_operand:SI 0 "register_operand" "r") (match_operand:SI 1 "const_int_operand" "k") )]
C boolean expression, if required */
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: Essential Constructs in Machine Descriptions 9/21
[(set (match_operand:SI 0 "register_operand" "r") (match_operand:SI 1 "const_int_operand" "k") )]
C boolean expression, if required */
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: Essential Constructs in Machine Descriptions 10/21
Target Independent Target Dependent Parse Gimplify Tree SSA Optimize Generate RTL Optimize RTL Generate ASM GIMPLE → RTL RTL → ASM
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: Essential Constructs in Machine Descriptions 10/21
Target Independent Target Dependent Parse Gimplify Tree SSA Optimize Generate RTL Optimize RTL Generate ASM GIMPLE → RTL RTL → ASM
⇒GCC Solution: Standard Pattern Names
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: Essential Constructs in Machine Descriptions 10/21
Target Independent Target Dependent Parse Gimplify Tree SSA Optimize Generate RTL Optimize RTL Generate ASM GIMPLE → RTL RTL → ASM
⇒GCC Solution: Standard Pattern Names GIMPLE ASSIGN
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: Essential Constructs in Machine Descriptions 11/21
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: Essential Constructs in Machine Descriptions 12/21
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: Essential Constructs in Machine Descriptions 13/21
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: Essential Constructs in Machine Descriptions 14/21
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: Essential Constructs in Machine Descriptions 15/21
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: Essential Constructs in Machine Descriptions 16/21
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: The Essence of Retargetability 17/21
Target Independent Target Dependent Parse Gimplify Tree SSA Optimize Generate RTL Optimize RTL Generate ASM GIMPLE → RTL RTL → ASM
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: The Essence of Retargetability 17/21
Target Independent Target Dependent Parse Gimplify Tree SSA Optimize Generate RTL Optimize RTL Generate ASM GIMPLE → RTL RTL → ASM
⇒GCC Solution: Standard Pattern Names
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: The Essence of Retargetability 17/21
Target Independent Target Dependent Parse Gimplify Tree SSA Optimize Generate RTL Optimize RTL Generate ASM GIMPLE → RTL RTL → ASM
⇒GCC Solution: Standard Pattern Names GIMPLE ASSIGN
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: The Essence of Retargetability 18/21
[(set (match_operand:SI 0 "register_operand" "r") (match_operand:SI 1 "const_int_operand" "k") )]
C boolean expression, if required */
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: The Essence of Retargetability 18/21
[(set (match_operand:SI 0 "register_operand" "r") (match_operand:SI 1 "const_int_operand" "k") )]
C boolean expression, if required */
(set (reg:SI 58 [D.1283]) (const int 10 [0xa]) )
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: The Essence of Retargetability 19/21
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: The Essence of Retargetability 19/21
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: The Essence of Retargetability 19/21
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: The Essence of Retargetability 20/21
Language Specific Code Language and Machine Independent Generic Code Machine Dependent Generator Code Machine Descriptions Compiler Generation Framework Input Language Target Name Parser Gimplifier Tree SSA Optimizer Expander Optimizer Code Generator Selected Copied Copied Generated Generated Generated Compiler Development Time Build Time Use Time Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: The Essence of Retargetability 20/21
Language Specific Code Language and Machine Independent Generic Code Machine Dependent Generator Code Machine Descriptions Compiler Generation Framework Input Language Target Name Parser Gimplifier Tree SSA Optimizer Expander Optimizer Code Generator Selected Copied Copied Generated Generated Generated Compiler Development Time Build Time Use Time
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: The Essence of Retargetability 20/21
Language Specific Code Language and Machine Independent Generic Code Machine Dependent Generator Code Machine Descriptions Compiler Generation Framework Input Language Target Name Parser Gimplifier Tree SSA Optimizer Expander Optimizer Code Generator Selected Copied Copied Generated Generated Generated Compiler Development Time Build Time Use Time
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: The Essence of Retargetability 20/21
Language Specific Code Language and Machine Independent Generic Code Machine Dependent Generator Code Machine Descriptions Compiler Generation Framework Input Language Target Name Parser Gimplifier Tree SSA Optimizer Expander Optimizer Code Generator Selected Copied Copied Generated Generated Generated Compiler Development Time Build Time Use Time
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: The Essence of Retargetability 20/21
Language Specific Code Language and Machine Independent Generic Code Machine Dependent Generator Code Machine Descriptions Compiler Generation Framework Input Language Target Name Parser Gimplifier Tree SSA Optimizer Expander Optimizer Code Generator Selected Copied Copied Generated Generated Generated Compiler Development Time Build Time Use Time
Uday Khedker GRC, IIT Bombay
EA-GCC, Chamonix MD Intro: Summary 21/21
Uday Khedker GRC, IIT Bombay