the design and implementation of gnu compiler collectionuday/courses/cs715-08/gcc-intro-1.pdf ·...
TRANSCRIPT
![Page 1: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/1.jpg)
The Design and Implementation of GnuCompiler Collection
Uday Khedker
(www.cse.iitb.ac.in/̃ uday)
Department of Computer Science and Engineering,
Indian Institute of Technology, Bombay
July 2008
![Page 2: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/2.jpg)
Part 1
Outline
![Page 3: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/3.jpg)
cs 715 GCC: Outline 1/22
Outline
• Open Source Vs. Free Software
• An Introduction to Compilation
• An overview of Gnu Compiler Collection
• Our work in GCC
• Conclusions
UPK IIT Bombay
![Page 4: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/4.jpg)
Part 2
Open Source Vs. Free Software
![Page 5: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/5.jpg)
cs 715 GCC: Open Source Vs. Free Software 2/22
Open Source Vs. Free Software
• The open source initiative: (http://www.opensource.org/)
Emphasis on development methodology
• The Free Software Foundation: (http://www.fsf.org/)
Emphasis on freedom of the user
• In some cases, open source software has restricted user freedom
UPK IIT Bombay
![Page 6: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/6.jpg)
cs 715 GCC: Open Source Vs. Free Software 2/22
Open Source Vs. Free Software
• The open source initiative: (http://www.opensource.org/)
Emphasis on development methodology
• The Free Software Foundation: (http://www.fsf.org/)
Emphasis on freedom of the user
• In some cases, open source software has restricted user freedom
◮ May cooperate with restrictive systems◮ eg. DRM (Digital Rights Management)
UPK IIT Bombay
![Page 7: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/7.jpg)
cs 715 GCC: Open Source Vs. Free Software 3/22
Open Source and Free Software Development Model
• The Cathedral and the Bazaar
Eric S Raymond, 1997.
• Cathedral: Total Centralized Control
Design, implement, test, release
• Bazaar: Total Decentralization
Release early, release often, let users fix bugs
UPK IIT Bombay
![Page 8: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/8.jpg)
cs 715 GCC: Open Source Vs. Free Software 4/22
The Bazaar Approach
Release early, release often, let users fix bugs
• Brooks’ law (The Mythical Man Month, 1975)
UPK IIT Bombay
![Page 9: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/9.jpg)
cs 715 GCC: Open Source Vs. Free Software 4/22
The Bazaar Approach
Release early, release often, let users fix bugs
• Brooks’ law (The Mythical Man Month, 1975)
◮ 12 man month effort
UPK IIT Bombay
![Page 10: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/10.jpg)
cs 715 GCC: Open Source Vs. Free Software 4/22
The Bazaar Approach
Release early, release often, let users fix bugs
• Brooks’ law (The Mythical Man Month, 1975)
◮ 12 man month effort◮ 1 person working for 12 months
OR12 persons working for 1 month?
UPK IIT Bombay
![Page 11: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/11.jpg)
cs 715 GCC: Open Source Vs. Free Software 4/22
The Bazaar Approach
Release early, release often, let users fix bugs
• Brooks’ law (The Mythical Man Month, 1975)
◮ 12 man month effort◮ 1 person working for 12 months
OR12 persons working for 1 month?
• Bazaar approach believes that the two somewhat equivalent ininternet-based distributed development.
UPK IIT Bombay
![Page 12: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/12.jpg)
cs 715 GCC: Open Source Vs. Free Software 4/22
The Bazaar Approach
Release early, release often, let users fix bugs
• Brooks’ law (The Mythical Man Month, 1975)
◮ 12 man month effort◮ 1 person working for 12 months
OR12 persons working for 1 month?
• Bazaar approach believes that the two somewhat equivalent ininternet-based distributed development.
• “Given enough eyeballs, all bugs are shallow”.
Code errors, logical errors, and architectural errors.
UPK IIT Bombay
![Page 13: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/13.jpg)
cs 715 GCC: Open Source Vs. Free Software 4/22
The Bazaar Approach
Release early, release often, let users fix bugs
• Brooks’ law (The Mythical Man Month, 1975)
◮ 12 man month effort◮ 1 person working for 12 months
OR12 persons working for 1 month?
• Bazaar approach believes that the two somewhat equivalent ininternet-based distributed development.
• “Given enough eyeballs, all bugs are shallow”.
Code errors, logical errors, and architectural errors.
A combination of the two seems more sensible
UPK IIT Bombay
![Page 14: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/14.jpg)
Part 3
Introduction to Compilation
![Page 15: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/15.jpg)
cs 715 GCC: Introduction to Compilation 5/22
Implementation Mechanisms
Source Program
Translator
Target Program
Machine
UPK IIT Bombay
![Page 16: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/16.jpg)
cs 715 GCC: Introduction to Compilation 5/22
Implementation Mechanisms
Source Program
Translator
Target Program
Machine
Input Data
UPK IIT Bombay
![Page 17: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/17.jpg)
cs 715 GCC: Introduction to Compilation 5/22
Implementation Mechanisms
Source Program
Translator
Target Program
Machine
Input Data
Source Program
Interpreter
Machine
UPK IIT Bombay
![Page 18: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/18.jpg)
cs 715 GCC: Introduction to Compilation 6/22
Implementation Mechanisms as “Bridges”
• “Gap” between the “levels” of program specification and execution
Program Specification
Machine
UPK IIT Bombay
![Page 19: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/19.jpg)
cs 715 GCC: Introduction to Compilation 6/22
Implementation Mechanisms as “Bridges”
• “Gap” between the “levels” of program specification and execution
Program Specification
Machine
Translation
UPK IIT Bombay
![Page 20: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/20.jpg)
cs 715 GCC: Introduction to Compilation 6/22
Implementation Mechanisms as “Bridges”
• “Gap” between the “levels” of program specification and execution
Program Specification
Machine
Translation Interpretation
UPK IIT Bombay
![Page 21: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/21.jpg)
cs 715 GCC: Introduction to Compilation 6/22
Implementation Mechanisms as “Bridges”
• “Gap” between the “levels” of program specification and execution
Program Specification
Machine
Translation Interpretation
State : VariablesOperations: Expressions,
Control Flow
State : Memory,Registers
Operations: MachineInstructions
UPK IIT Bombay
![Page 22: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/22.jpg)
cs 715 GCC: Introduction to Compilation 7/22
High and Low Level Abstractions
• A source statement
a = b < 10 ? b : c;
• Spim assembly equivalent
lw $t0, 4($fp) # $t0 <- b
slti $t0, $t0, 10 # $t0 <- $t0 < b
not $t0, $t0 # $t0 <- ! $t0
bgtz $t0, L0: # if $t0 >= 0 goto L0:
lw $t0, 4($fp) # $t0 <- b
b L1: # goto L1:
L0: lw $t0, 8($fp) # L0: $t0 <- c
L1: sw 0($fp), $t0 # L1: a <- $t0
UPK IIT Bombay
![Page 23: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/23.jpg)
cs 715 GCC: Introduction to Compilation 8/22
Binding
Conceptualisation Coding Compiling Linking Loading Execution
Time
No.ofunboundobjects
Overall Strategy, algorithm, data structure etc
UPK IIT Bombay
![Page 24: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/24.jpg)
cs 715 GCC: Introduction to Compilation 8/22
Binding
Conceptualisation Coding Compiling Linking Loading Execution
Time
No.ofunboundobjects
Functions, variables, their types etc
UPK IIT Bombay
![Page 25: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/25.jpg)
cs 715 GCC: Introduction to Compilation 8/22
Binding
Conceptualisation Coding Compiling Linking Loading Execution
Time
No.ofunboundobjects
Machine instructions registers etc
UPK IIT Bombay
![Page 26: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/26.jpg)
cs 715 GCC: Introduction to Compilation 8/22
Binding
Conceptualisation Coding Compiling Linking Loading Execution
Time
No.ofunboundobjects
Virtual addresses of global variables, functions etc.
UPK IIT Bombay
![Page 27: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/27.jpg)
cs 715 GCC: Introduction to Compilation 8/22
Binding
Conceptualisation Coding Compiling Linking Loading Execution
Time
No.ofunboundobjects
Actual addresses of code and data
UPK IIT Bombay
![Page 28: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/28.jpg)
cs 715 GCC: Introduction to Compilation 8/22
Binding
Conceptualisation Coding Compiling Linking Loading Execution
Time
No.ofunboundobjects
Values of variables
UPK IIT Bombay
![Page 29: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/29.jpg)
cs 715 GCC: Introduction to Compilation 9/22
Implementation Mechanisms
• Translation = Analysis + Synthesis
Interpretation = Analysis + Execution
UPK IIT Bombay
![Page 30: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/30.jpg)
cs 715 GCC: Introduction to Compilation 9/22
Implementation Mechanisms
• Translation = Analysis + Synthesis
Interpretation = Analysis + Execution
• Translation InstructionsEquivalent
Instructions
UPK IIT Bombay
![Page 31: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/31.jpg)
cs 715 GCC: Introduction to Compilation 9/22
Implementation Mechanisms
• Translation = Analysis + Synthesis
Interpretation = Analysis + Execution
• Translation InstructionsEquivalent
Instructions
Interpretation InstructionsActions Implied
by Instructions
UPK IIT Bombay
![Page 32: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/32.jpg)
cs 715 GCC: Introduction to Compilation 10/22
Language Implementation Models
Analysis
Synthesis
Execution
Compilation
Interpretation
UPK IIT Bombay
![Page 33: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/33.jpg)
cs 715 GCC: Introduction to Compilation 11/22
Language Processor Models
C,C++
Java,C#
FrontEnd
Optimizer
BackEnd
VirtualMachine
UPK IIT Bombay
![Page 34: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/34.jpg)
cs 715 GCC: Introduction to Compilation 12/22
Translation Sequence in Our Example: Parsing
a=b<10?b:c;
Input
UPK IIT Bombay
![Page 35: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/35.jpg)
cs 715 GCC: Introduction to Compilation 12/22
Translation Sequence in Our Example: Parsing
a=b<10?b:c;
Input
AsgnStmnt
Lhs = E ;
E ? E : E
E < E
name
name name
name numParse Tree
Issues:
UPK IIT Bombay
![Page 36: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/36.jpg)
cs 715 GCC: Introduction to Compilation 12/22
Translation Sequence in Our Example: Parsing
a=b<10?b:c;
Input
AsgnStmnt
Lhs = E ;
E ? E : E
E < E
name
name name
name numParse Tree
Issues:
• Grammar rules, terminals, non-terminals
UPK IIT Bombay
![Page 37: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/37.jpg)
cs 715 GCC: Introduction to Compilation 12/22
Translation Sequence in Our Example: Parsing
a=b<10?b:c;
Input
AsgnStmnt
Lhs = E ;
E ? E : E
E < E
name
name name
name numParse Tree
Issues:
• Grammar rules, terminals, non-terminals
• Order of application of grammar rules
eg. is it (a = b<10?) followed by (b:c)?
UPK IIT Bombay
![Page 38: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/38.jpg)
cs 715 GCC: Introduction to Compilation 12/22
Translation Sequence in Our Example: Parsing
a=b<10?b:c;
Input
AsgnStmnt
Lhs = E ;
E ? E : E
E < E
name
name name
name numParse Tree
Issues:
• Grammar rules, terminals, non-terminals
• Order of application of grammar rules
eg. is it (a = b<10?) followed by (b:c)?
• Values of terminal symbols
eg. string “10” vs. integer number 10.
UPK IIT Bombay
![Page 39: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/39.jpg)
cs 715 GCC: Introduction to Compilation 13/22
Translation Sequence in Our Example: Semantic Analysis
a=b<10?b:c;
Input
AsgnStmnt
Lhs = E ;
E ? E : E
E < E
name
name name
name numParse Tree
UPK IIT Bombay
![Page 40: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/40.jpg)
cs 715 GCC: Introduction to Compilation 13/22
Translation Sequence in Our Example: Semantic Analysis
a=b<10?b:c;
Input
AsgnStmnt
Lhs = E ;
E ? E : E
E < E
name
name name
name numParse Tree
=name(a,int) ?: (int)
<
(bool)name(b,int)
name(c,int)
name(b,int)
num(10,int)
Abstract Syntax Tree(with attributes)
Issues:
UPK IIT Bombay
![Page 41: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/41.jpg)
cs 715 GCC: Introduction to Compilation 13/22
Translation Sequence in Our Example: Semantic Analysis
a=b<10?b:c;
Input
AsgnStmnt
Lhs = E ;
E ? E : E
E < E
name
name name
name numParse Tree
=name(a,int) ?: (int)
<
(bool)name(b,int)
name(c,int)
name(b,int)
num(10,int)
Abstract Syntax Tree(with attributes)
Issues:
• Symbol tables
Have variables been declared? What are their types?What is their scope?
UPK IIT Bombay
![Page 42: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/42.jpg)
cs 715 GCC: Introduction to Compilation 13/22
Translation Sequence in Our Example: Semantic Analysis
a=b<10?b:c;
Input
AsgnStmnt
Lhs = E ;
E ? E : E
E < E
name
name name
name numParse Tree
=name(a,int) ?: (int)
<
(bool)name(b,int)
name(c,int)
name(b,int)
num(10,int)
Abstract Syntax Tree(with attributes)
Issues:
• Symbol tables
Have variables been declared? What are their types?What is their scope?
• Type consistency of operators and operands
The result of computing b<10? is bool and not int
UPK IIT Bombay
![Page 43: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/43.jpg)
cs 715 GCC: Introduction to Compilation 14/22
Translation Sequence in Our Example: IR Generation
a=b<10?b:c;
Input
AsgnStmnt
Lhs = E ;
E ? E : E
E < E
name
name name
name numParse Tree
=name(a,int) ?: (int)
<
(bool)name(b,int)
name(c,int)
name(b,int)
num(10,int)
Abstract Syntax Tree(with attributes)
UPK IIT Bombay
![Page 44: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/44.jpg)
cs 715 GCC: Introduction to Compilation 14/22
Translation Sequence in Our Example: IR Generation
a=b<10?b:c;
Input
AsgnStmnt
Lhs = E ;
E ? E : E
E < E
name
name name
name numParse Tree
=name(a,int) ?: (int)
<
(bool)name(b,int)
name(c,int)
name(b,int)
num(10,int)
Abstract Syntax Tree(with attributes)
=
T0<
b 10IfGoto
Not L0:
T0
=
T1 bGoto
L1:=
T1 c
L0:
=
T1a
L1:
Tree List
Issues:
UPK IIT Bombay
![Page 45: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/45.jpg)
cs 715 GCC: Introduction to Compilation 14/22
Translation Sequence in Our Example: IR Generation
a=b<10?b:c;
Input
AsgnStmnt
Lhs = E ;
E ? E : E
E < E
name
name name
name numParse Tree
=name(a,int) ?: (int)
<
(bool)name(b,int)
name(c,int)
name(b,int)
num(10,int)
Abstract Syntax Tree(with attributes)
=
T0<
b 10IfGoto
Not L0:
T0
=
T1 bGoto
L1:=
T1 c
L0:
=
T1a
L1:
Tree List
Issues:
• Convert to maximal trees which can beimplemented without altering control flow
Simplifies instruction selection and scheduling,register allocation etc.
UPK IIT Bombay
![Page 46: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/46.jpg)
cs 715 GCC: Introduction to Compilation 14/22
Translation Sequence in Our Example: IR Generation
a=b<10?b:c;
Input
AsgnStmnt
Lhs = E ;
E ? E : E
E < E
name
name name
name numParse Tree
=name(a,int) ?: (int)
<
(bool)name(b,int)
name(c,int)
name(b,int)
num(10,int)
Abstract Syntax Tree(with attributes)
=
T0<
b 10IfGoto
Not L0:
T0
=
T1 bGoto
L1:=
T1 c
L0:
=
T1a
L1:
Tree List
Issues:
• Convert to maximal trees which can beimplemented without altering control flow
Simplifies instruction selection and scheduling,register allocation etc.
• Linearise control flow by flattening nestedcontrol constructs
UPK IIT Bombay
![Page 47: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/47.jpg)
cs 715 GCC: Introduction to Compilation 15/22
Translation Sequence in Our Example: Instruction Selection
a=b<10?b:c;
Input
AsgnStmnt
Lhs = E ;
E ? E : E
E < E
name
name name
name numParse Tree
=name(a,int) ?: (int)
<
(bool)name(b,int)
name(c,int)
name(b,int)
num(10,int)
Abstract Syntax Tree(with attributes)
=
T0<
b 10IfGoto
Not L0:
T0
=
T1 bGoto
L1:=
T1 c
L0:
=
T1a
L1:
Tree List
UPK IIT Bombay
![Page 48: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/48.jpg)
cs 715 GCC: Introduction to Compilation 15/22
Translation Sequence in Our Example: Instruction Selection
a=b<10?b:c;
Input
AsgnStmnt
Lhs = E ;
E ? E : E
E < E
name
name name
name numParse Tree
=name(a,int) ?: (int)
<
(bool)name(b,int)
name(c,int)
name(b,int)
num(10,int)
Abstract Syntax Tree(with attributes)
=
T0<
b 10IfGoto
Not L0:
T0
=
T1 bGoto
L1:=
T1 c
L0:
=
T1a
L1:
Tree List
T0 ← bT0 ← T0 < bT0 ← ! T0
if T0 ≥ 0 goto L0:T1 ← bgoto L1:
L0: T1 ← cL1: a ← T1
Instruction List Issues:
UPK IIT Bombay
![Page 49: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/49.jpg)
cs 715 GCC: Introduction to Compilation 15/22
Translation Sequence in Our Example: Instruction Selection
a=b<10?b:c;
Input
AsgnStmnt
Lhs = E ;
E ? E : E
E < E
name
name name
name numParse Tree
=name(a,int) ?: (int)
<
(bool)name(b,int)
name(c,int)
name(b,int)
num(10,int)
Abstract Syntax Tree(with attributes)
=
T0<
b 10IfGoto
Not L0:
T0
=
T1 bGoto
L1:=
T1 c
L0:
=
T1a
L1:
Tree List
T0 ← bT0 ← T0 < bT0 ← ! T0
if T0 ≥ 0 goto L0:T1 ← bgoto L1:
L0: T1 ← cL1: a ← T1
Instruction List Issues:
• Cover trees with as fewmachine instructions aspossible
UPK IIT Bombay
![Page 50: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/50.jpg)
cs 715 GCC: Introduction to Compilation 15/22
Translation Sequence in Our Example: Instruction Selection
a=b<10?b:c;
Input
AsgnStmnt
Lhs = E ;
E ? E : E
E < E
name
name name
name numParse Tree
=name(a,int) ?: (int)
<
(bool)name(b,int)
name(c,int)
name(b,int)
num(10,int)
Abstract Syntax Tree(with attributes)
=
T0<
b 10IfGoto
Not L0:
T0
=
T1 bGoto
L1:=
T1 c
L0:
=
T1a
L1:
Tree List
T0 ← bT0 ← T0 < bT0 ← ! T0
if T0 ≥ 0 goto L0:T1 ← bgoto L1:
L0: T1 ← cL1: a ← T1
Instruction List Issues:
• Cover trees with as fewmachine instructions aspossible
• Use temporaries and localregisters
UPK IIT Bombay
![Page 51: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/51.jpg)
cs 715 GCC: Introduction to Compilation 16/22
Translation Sequence in Our Example: Emitting Instructions
a=b<10?b:c;
Input
AsgnStmnt
Lhs = E ;
E ? E : E
E < E
name
name name
name numParse Tree
=name(a,int) ?: (int)
<
(bool)name(b,int)
name(c,int)
name(b,int)
num(10,int)
Abstract Syntax Tree(with attributes)
=
T0<
b 10IfGoto
Not L0:
T0
=
T1 bGoto
L1:=
T1 c
L0:
=
T1a
L1:
Tree List
T0 ← bT0 ← T0 < bT0 ← ! T0
if T0 ≥ 0 goto L0:T1 ← bgoto L1:
L0: T1 ← cL1: a ← T1
Instruction List
UPK IIT Bombay
![Page 52: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/52.jpg)
cs 715 GCC: Introduction to Compilation 16/22
Translation Sequence in Our Example: Emitting Instructions
a=b<10?b:c;
Input
AsgnStmnt
Lhs = E ;
E ? E : E
E < E
name
name name
name numParse Tree
=name(a,int) ?: (int)
<
(bool)name(b,int)
name(c,int)
name(b,int)
num(10,int)
Abstract Syntax Tree(with attributes)
=
T0<
b 10IfGoto
Not L0:
T0
=
T1 bGoto
L1:=
T1 c
L0:
=
T1a
L1:
Tree List
T0 ← bT0 ← T0 < bT0 ← ! T0
if T0 ≥ 0 goto L0:T1 ← bgoto L1:
L0: T1 ← cL1: a ← T1
Instruction List
lw $t0, 4($fp)slti $t0, $t0, 10not $t0, $t0bgtz $t0, L0:lw $t0, 4($fp)b L1:
L0: lw $t0, 8($fp)L1: sw 0($fp), $t0
Assembly Code
Issues:
UPK IIT Bombay
![Page 53: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/53.jpg)
cs 715 GCC: Introduction to Compilation 16/22
Translation Sequence in Our Example: Emitting Instructions
a=b<10?b:c;
Input
AsgnStmnt
Lhs = E ;
E ? E : E
E < E
name
name name
name numParse Tree
=name(a,int) ?: (int)
<
(bool)name(b,int)
name(c,int)
name(b,int)
num(10,int)
Abstract Syntax Tree(with attributes)
=
T0<
b 10IfGoto
Not L0:
T0
=
T1 bGoto
L1:=
T1 c
L0:
=
T1a
L1:
Tree List
T0 ← bT0 ← T0 < bT0 ← ! T0
if T0 ≥ 0 goto L0:T1 ← bgoto L1:
L0: T1 ← cL1: a ← T1
Instruction List
lw $t0, 4($fp)slti $t0, $t0, 10not $t0, $t0bgtz $t0, L0:lw $t0, 4($fp)b L1:
L0: lw $t0, 8($fp)L1: sw 0($fp), $t0
Assembly Code
Issues:
• Offsets of variables in thestack frame
UPK IIT Bombay
![Page 54: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/54.jpg)
cs 715 GCC: Introduction to Compilation 16/22
Translation Sequence in Our Example: Emitting Instructions
a=b<10?b:c;
Input
AsgnStmnt
Lhs = E ;
E ? E : E
E < E
name
name name
name numParse Tree
=name(a,int) ?: (int)
<
(bool)name(b,int)
name(c,int)
name(b,int)
num(10,int)
Abstract Syntax Tree(with attributes)
=
T0<
b 10IfGoto
Not L0:
T0
=
T1 bGoto
L1:=
T1 c
L0:
=
T1a
L1:
Tree List
T0 ← bT0 ← T0 < bT0 ← ! T0
if T0 ≥ 0 goto L0:T1 ← bgoto L1:
L0: T1 ← cL1: a ← T1
Instruction List
lw $t0, 4($fp)slti $t0, $t0, 10not $t0, $t0bgtz $t0, L0:lw $t0, 4($fp)b L1:
L0: lw $t0, 8($fp)L1: sw 0($fp), $t0
Assembly Code
Issues:
• Offsets of variables in thestack frame
• Actual register numbersand assembly mnemonics
UPK IIT Bombay
![Page 55: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/55.jpg)
cs 715 GCC: Introduction to Compilation 16/22
Translation Sequence in Our Example: Emitting Instructions
a=b<10?b:c;
Input
AsgnStmnt
Lhs = E ;
E ? E : E
E < E
name
name name
name numParse Tree
=name(a,int) ?: (int)
<
(bool)name(b,int)
name(c,int)
name(b,int)
num(10,int)
Abstract Syntax Tree(with attributes)
=
T0<
b 10IfGoto
Not L0:
T0
=
T1 bGoto
L1:=
T1 c
L0:
=
T1a
L1:
Tree List
T0 ← bT0 ← T0 < bT0 ← ! T0
if T0 ≥ 0 goto L0:T1 ← bgoto L1:
L0: T1 ← cL1: a ← T1
Instruction List
lw $t0, 4($fp)slti $t0, $t0, 10not $t0, $t0bgtz $t0, L0:lw $t0, 4($fp)b L1:
L0: lw $t0, 8($fp)L1: sw 0($fp), $t0
Assembly Code
Issues:
• Offsets of variables in thestack frame
• Actual register numbersand assembly mnemonics
• Code to construct anddiscard activation records
UPK IIT Bombay
![Page 56: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/56.jpg)
cs 715 GCC: Introduction to Compilation 16/22
Translation Sequence in Our Example: Emitting Instructions
a=b<10?b:c;
Input
AsgnStmnt
Lhs = E ;
E ? E : E
E < E
name
name name
name numParse Tree
=name(a,int) ?: (int)
<
(bool)name(b,int)
name(c,int)
name(b,int)
num(10,int)
Abstract Syntax Tree(with attributes)
=
T0<
b 10IfGoto
Not L0:
T0
=
T1 bGoto
L1:=
T1 c
L0:
=
T1a
L1:
Tree List
T0 ← bT0 ← T0 < bT0 ← ! T0
if T0 ≥ 0 goto L0:T1 ← bgoto L1:
L0: T1 ← cL1: a ← T1
Instruction List
lw $t0, 4($fp)slti $t0, $t0, 10not $t0, $t0bgtz $t0, L0:lw $t0, 4($fp)b L1:
L0: lw $t0, 8($fp)L1: sw 0($fp), $t0
Assembly Code
UPK IIT Bombay
![Page 57: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/57.jpg)
cs 715 GCC: Introduction to Compilation 17/22
Typical Front Ends
Parser
UPK IIT Bombay
![Page 58: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/58.jpg)
cs 715 GCC: Introduction to Compilation 17/22
Typical Front Ends
ParserSourceProgram
Scanner
Tokens
UPK IIT Bombay
![Page 59: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/59.jpg)
cs 715 GCC: Introduction to Compilation 17/22
Typical Front Ends
ParserSourceProgram
Scanner
Tokens
SemanticAnalyzer
AST
ParseTree
AST or Linear IR+
Symbol Table
UPK IIT Bombay
![Page 60: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/60.jpg)
cs 715 GCC: Introduction to Compilation 17/22
Typical Front Ends
ParserSourceProgram
Scanner
Tokens
SemanticAnalyzer
AST
ParseTree
AST or Linear IR+
Symbol Table
ErrorHandler
SymtabHandler
UPK IIT Bombay
![Page 61: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/61.jpg)
cs 715 GCC: Introduction to Compilation 18/22
Typical Back Ends
M/c Ind.IR
M/c Ind.Optimizer
− Compile timeevaluations
− Eliminatingredundantcomputations
M/cInd.IR
UPK IIT Bombay
![Page 62: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/62.jpg)
cs 715 GCC: Introduction to Compilation 18/22
Typical Back Ends
M/c Ind.IR
M/c Ind.Optimizer
− Compile timeevaluations
− Eliminatingredundantcomputations
M/cInd.IR
CodeGenerator
M/cDep.IR
− Instruction Selection− Local Reg Allocation− Choice of Order of
Evaluation
UPK IIT Bombay
![Page 63: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/63.jpg)
cs 715 GCC: Introduction to Compilation 18/22
Typical Back Ends
M/c Ind.IR
M/c Ind.Optimizer
− Compile timeevaluations
− Eliminatingredundantcomputations
M/cInd.IR
CodeGenerator
M/cDep.IR
− Instruction Selection− Local Reg Allocation− Choice of Order of
Evaluation
M/c Dep.Optimizer
Assembly Code
UPK IIT Bombay
![Page 64: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/64.jpg)
cs 715 GCC: Introduction to Compilation 18/22
Typical Back Ends
M/c Ind.IR
M/c Ind.Optimizer
− Compile timeevaluations
− Eliminatingredundantcomputations
M/cInd.IR
CodeGenerator
M/cDep.IR
− Instruction Selection− Local Reg Allocation− Choice of Order of
Evaluation
Assembly Code
RegisterAllocator
InstructionScheduler
PeepholeOptimizer
UPK IIT Bombay
![Page 65: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/65.jpg)
Part 4
Introduction to GCC
![Page 66: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/66.jpg)
cs 715 GCC: Introduction to GCC 19/22
The GNU Tool Chain
gcc
Source Program
Target Program
UPK IIT Bombay
![Page 67: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/67.jpg)
cs 715 GCC: Introduction to GCC 19/22
The GNU Tool Chain
gcc
Source Program
Target Program
cc1
UPK IIT Bombay
![Page 68: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/68.jpg)
cs 715 GCC: Introduction to GCC 19/22
The GNU Tool Chain
gcc
Source Program
Target Program
cc1 cpp
UPK IIT Bombay
![Page 69: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/69.jpg)
cs 715 GCC: Introduction to GCC 19/22
The GNU Tool Chain
gcc
Source Program
Target Program
cc1 cpp
as
UPK IIT Bombay
![Page 70: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/70.jpg)
cs 715 GCC: Introduction to GCC 19/22
The GNU Tool Chain
gcc
Source Program
Target Program
cc1 cpp
as
ld
UPK IIT Bombay
![Page 71: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/71.jpg)
cs 715 GCC: Introduction to GCC 19/22
The GNU Tool Chain
gcc
Source Program
Target Program
cc1 cpp
as
ld
glibc/newlib
UPK IIT Bombay
![Page 72: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/72.jpg)
cs 715 GCC: Introduction to GCC 20/22
The GCC Framework
LanguageSpecific Code
Language andMachine
IndependentGeneric Code
MachinedependentGenerator
Code
MachineDescrip-
tionsGCC
Input Language Machine Description
Parser Genericizer GimplifierTree SSAOptimizer
RTLGenerator
OptimizerCode
Generator
cc1/gcc
UPK IIT Bombay
![Page 73: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/73.jpg)
cs 715 GCC: Introduction to GCC 20/22
The GCC Framework
LanguageSpecific Code
Language andMachine
IndependentGeneric Code
MachinedependentGenerator
Code
MachineDescrip-
tionsGCC
Input Language Machine Description
Parser Genericizer GimplifierTree SSAOptimizer
RTLGenerator
OptimizerCode
Generator
cc1/gcc
Source Program
Assembly Program
UPK IIT Bombay
![Page 74: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/74.jpg)
cs 715 GCC: Introduction to GCC 20/22
The GCC Framework
LanguageSpecific Code
Language andMachine
IndependentGeneric Code
MachinedependentGenerator
Code
MachineDescrip-
tionsGCC
Input Language Machine Description
Parser Genericizer GimplifierTree SSAOptimizer
RTLGenerator
OptimizerCode
Generator
Selected
cc1/gcc
UPK IIT Bombay
![Page 75: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/75.jpg)
cs 715 GCC: Introduction to GCC 20/22
The GCC Framework
LanguageSpecific Code
Language andMachine
IndependentGeneric Code
MachinedependentGenerator
Code
MachineDescrip-
tionsGCC
Input Language Machine Description
Parser Genericizer GimplifierTree SSAOptimizer
RTLGenerator
OptimizerCode
Generator
Selected Copied
Copied
cc1/gcc
UPK IIT Bombay
![Page 76: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/76.jpg)
cs 715 GCC: Introduction to GCC 20/22
The GCC Framework
LanguageSpecific Code
Language andMachine
IndependentGeneric Code
MachinedependentGenerator
Code
MachineDescrip-
tionsGCC
Input Language Machine Description
Parser Genericizer GimplifierTree SSAOptimizer
RTLGenerator
OptimizerCode
Generator
Selected Copied
CopiedGenerated
Generated
cc1/gcc
UPK IIT Bombay
![Page 77: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/77.jpg)
cs 715 GCC: Introduction to GCC 21/22
The cc1 Phase Sequence as IR Chain
The GCC Phase Sequence
Generic GIMPLE RTL ASM
UPK IIT Bombay
![Page 78: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/78.jpg)
cs 715 GCC: Introduction to GCC 21/22
The cc1 Phase Sequence as IR Chain
The GCC Phase Sequence
Generic GIMPLE RTL ASM
HLL
Scope ExplicationLower controlflow
Lower procedures& data
Target
UPK IIT Bombay
![Page 79: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/79.jpg)
cs 715 GCC: Introduction to GCC 21/22
The cc1 Phase Sequence as IR Chain
The GCC Phase Sequence
Generic GIMPLE RTL ASM
HLL
Scope ExplicationLower controlflow
Lower procedures& data
TargetOptimization Opportunities
Rescoping SSA Scheduling
UPK IIT Bombay
![Page 80: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/80.jpg)
Part 5
Configuration and Building
![Page 81: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/81.jpg)
cs 715 GCC: Configuration and Building 22/22
Configuring GCC
configure
UPK IIT Bombay
![Page 82: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/82.jpg)
cs 715 GCC: Configuration and Building 22/22
Configuring GCC
configure
config.guess
UPK IIT Bombay
![Page 83: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/83.jpg)
cs 715 GCC: Configuration and Building 22/22
Configuring GCC
configure
config.guess
configure.in
UPK IIT Bombay
![Page 84: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/84.jpg)
cs 715 GCC: Configuration and Building 22/22
Configuring GCC
configure
config.guess
configure.in config/*
UPK IIT Bombay
![Page 85: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/85.jpg)
cs 715 GCC: Configuration and Building 22/22
Configuring GCC
configure
config.guess
configure.in config/*
config.sub
UPK IIT Bombay
![Page 86: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/86.jpg)
cs 715 GCC: Configuration and Building 22/22
Configuring GCC
configure
config.guess
configure.in config/*
config.sub
config.log config.cache config.status
UPK IIT Bombay
![Page 87: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/87.jpg)
cs 715 GCC: Configuration and Building 22/22
Configuring GCC
configure
config.guess
configure.in config/*
config.sub
config.log config.cache config.status
config.h.in makefile.in
UPK IIT Bombay
![Page 88: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/88.jpg)
cs 715 GCC: Configuration and Building 22/22
Configuring GCC
configure
config.guess
configure.in config/*
config.sub
config.log config.cache config.status
config.h.in makefile.in
Makefile config.h
UPK IIT Bombay
![Page 89: The Design and Implementation of Gnu Compiler Collectionuday/courses/cs715-08/gcc-intro-1.pdf · •The Cathedral and the Bazaar Eric S Raymond, 1997. •Cathedral: Total Centralized](https://reader035.vdocuments.net/reader035/viewer/2022071218/60536d1149ddbe762253ad7d/html5/thumbnails/89.jpg)
Part 6
About The Course