The Design and Implementation of Gnu Compiler Collection

Similar documents
An Overview of Compilation

Introduction and Opening Remarks

The Design and Implementation of Gnu Compiler Collection

GCC Internals: A Conceptual View Part II

What 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

Introduction to Machine Descriptions

What is a compiler? Xiaokang Qiu Purdue University. August 21, 2017 ECE 573

The Compiler So Far. CSC 4181 Compiler Construction. Semantic Analysis. Beyond Syntax. Goals of a Semantic Analyzer.

The GNU Compiler Collection

An Overview to Compiler Design. 2008/2/14 \course\cpeg421-08s\topic-1a.ppt 1

Compiler Theory. (Semantic Analysis and Run-Time Environments)

COLLEGE OF ENGINEERING, NASHIK. LANGUAGE TRANSLATOR

Semantic Analysis. Compiler Architecture

Incremental Machine Descriptions for GCC

Compiler Design (40-414)

CS5363 Final Review. cs5363 1


Prof. Mohamed Hamada Software Engineering Lab. The University of Aizu Japan

Intermediate Code & Local Optimizations

Compiler Design. Computer Science & Information Technology (CS) Rank under AIR 100

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler Front-End

First Level Gray Box Probing

Alternatives for semantic processing

Syntax-Directed Translation. Lecture 14

CS 4201 Compilers 2014/2015 Handout: Lab 1

An Architectural Overview of GCC

Intermediate Representations

Principles of Compiler Design

Welcome to CSE131b: Compiler Construction

Lecture Outline. Code Generation. Lecture 30. Example of a Stack Machine Program. Stack Machines

Intermediate Code Generation

Code Generation. Lecture 30

CSc 453. Code Generation I Christian Collberg. Compiler Phases. Code Generation Issues. Slide Compilers and Systems Software.

Introduction. CSc 453. Compilers and Systems Software. 19 : Code Generation I. Department of Computer Science University of Arizona.

Formats of Translated Programs

Undergraduate Compilers in a Day

The Structure of a Syntax-Directed Compiler

9/5/17. The Design and Implementation of Programming Languages. Compilation. Interpretation. Compilation vs. Interpretation. Hybrid Implementation

Plugin Mechanisms in GCC

Retargeting GCC to Spim: A Recap

CS 415 Midterm Exam Spring 2002

Acknowledgement. CS Compiler Design. Semantic Processing. Alternatives for semantic processing. Intro to Semantic Analysis. V.

Appendix A The DL Language

Implementing Subprograms

GCC Configuration and Building

Compilers. Intermediate representations and code generation. Yannis Smaragdakis, U. Athens (original slides by Sam

Where We Are. Lexical Analysis. Syntax Analysis. IR Generation. IR Optimization. Code Generation. Machine Code. Optimization.

Project Compiler. CS031 TA Help Session November 28, 2011

GCC Control Flow and Plugins

Anatomy of a Compiler. Overview of Semantic Analysis. The Compiler So Far. Why a Separate Semantic Analysis?

CSE P 501 Compilers. Intermediate Representations Hal Perkins Spring UW CSE P 501 Spring 2018 G-1

Using GCC as a Research Compiler

What do Compilers Produce?

5. Semantic Analysis!

CS 415 Midterm Exam Spring SOLUTION

5. Semantic Analysis. Mircea Lungu Oscar Nierstrasz

Administration CS 412/413. Why build a compiler? Compilers. Architectural independence. Source-to-source translator

COMP 303 Computer Architecture Lecture 3. Comp 303 Computer Architecture

Agenda. CSE P 501 Compilers. Big Picture. Compiler Organization. Intermediate Representations. IR for Code Generation. CSE P 501 Au05 N-1

The Phasewise File Groups of GCC

COP4020 Programming Languages. Compilers and Interpreters Robert van Engelen & Chris Lacher

Introduction to Compiler Construction

Semantic Analysis and Type Checking

Time : 1 Hour Max Marks : 30

The role of semantic analysis in a compiler

CS152 Programming Language Paradigms Prof. Tom Austin, Fall Syntax & Semantics, and Language Design Criteria

Syntax-directed translation. Context-sensitive analysis. What context-sensitive questions might the compiler ask?

Crafting a Compiler with C (II) Compiler V. S. Interpreter

PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILING

Semantic actions for expressions

CSE 401/M501 Compilers

Compilers and Code Optimization EDOARDO FUSELLA

5. Semantic Analysis. Mircea Lungu Oscar Nierstrasz

CSE 582 Autumn 2002 Exam 11/26/02

Prof. Mohamed Hamada Software Engineering Lab. The University of Aizu Japan

Extension of GCC with a fully manageable reverse engineering front end

CSE450. Translation of Programming Languages. Lecture 11: Semantic Analysis: Types & Type Checking

LECTURE 3. Compiler Phases

LECTURE NOTES ON COMPILER DESIGN P a g e 2

Introduction to Compiler Construction

IR Optimization. May 15th, Tuesday, May 14, 13

GENERIC and GIMPLE: A New Tree Representation for Entire Functions

Chapter 2. Instructions:

GUJARAT TECHNOLOGICAL UNIVERSITY

CSE 401 Midterm Exam Sample Solution 11/4/11

Code Genera*on for Control Flow Constructs

CST-402(T): Language Processors

Announcements. My office hours are today in Gates 160 from 1PM-3PM. Programming Project 3 checkpoint due tomorrow night at 11:59PM.

The Structure of a Compiler

Compiling Regular Expressions COMP360

CSC488S/CSC2107S - Compilers and Interpreters. CSC 488S/CSC 2107S Lecture Notes

Review. Pat Morin COMP 3002

Usually, target code is semantically equivalent to source code, but not always!

Outline. Lecture 17: Putting it all together. Example (input program) How to make the computer understand? Example (Output assembly code) Fall 2002

Advances in Compilers

CS415 Compilers. Intermediate Represeation & Code Generation

Intermediate Code Generation

Politecnico di Milano

Recursive Descent Parsers

CS453 Compiler Construction

Transcription:

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 Outline

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

Part 2 Open Source Vs. Free Software

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

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)

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

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)

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

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 OR 12 persons working for 1 month?

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 OR 12 persons working for 1 month? Bazaar approach believes that the two somewhat equivalent in internet-based distributed development.

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 OR 12 persons working for 1 month? Bazaar approach believes that the two somewhat equivalent in internet-based distributed development. Given enough eyeballs, all bugs are shallow. Code errors, logical errors, and architectural errors.

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 OR 12 persons working for 1 month? Bazaar approach believes that the two somewhat equivalent in internet-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

Part 3 Introduction to Compilation

cs 715 GCC: Introduction to Compilation 5/22 Implementation Mechanisms Source Program Translator Target Program Machine

cs 715 GCC: Introduction to Compilation 5/22 Implementation Mechanisms Source Program Translator Input Data Target Program Machine

cs 715 GCC: Introduction to Compilation 5/22 Implementation Mechanisms Source Program Input Data Source Program Translator Target Program Machine Interpreter Machine

cs 715 GCC: Introduction to Compilation 6/22 Implementation Mechanisms as Bridges Gap between the levels of program specification and execution Program Specification Machine

cs 715 GCC: Introduction to Compilation 6/22 Implementation Mechanisms as Bridges Gap between the levels of program specification and execution Program Specification Translation Machine

cs 715 GCC: Introduction to Compilation 6/22 Implementation Mechanisms as Bridges Gap between the levels of program specification and execution Program Specification Translation Interpretation Machine

cs 715 GCC: Introduction to Compilation 6/22 Implementation Mechanisms as Bridges Gap between the levels of program specification and execution Program Specification State : Variables Operations: Expressions, Control Flow Translation Interpretation Machine State : Memory, Registers Operations: Machine Instructions

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

cs 715 GCC: Introduction to Compilation 8/22 Binding Overall Strategy, algorithm, data structure etc No.of unbound objects Conceptualisation Coding Compiling Linking Loading Execution Time

cs 715 GCC: Introduction to Compilation 8/22 Binding Functions, variables, their types etc No.of unbound objects Conceptualisation Coding Compiling Linking Loading Execution Time

cs 715 GCC: Introduction to Compilation 8/22 Binding Machine instructions registers etc No.of unbound objects Conceptualisation Coding Compiling Linking Loading Execution Time

cs 715 GCC: Introduction to Compilation 8/22 Binding Virtual addresses of global variables, functions etc. No.of unbound objects Conceptualisation Coding Compiling Linking Loading Execution Time

cs 715 GCC: Introduction to Compilation 8/22 Binding Actual addresses of code and data No.of unbound objects Conceptualisation Coding Compiling Linking Loading Execution Time

cs 715 GCC: Introduction to Compilation 8/22 Binding Values of variables No.of unbound objects Conceptualisation Coding Compiling Linking Loading Execution Time

cs 715 GCC: Introduction to Compilation 9/22 Implementation Mechanisms Translation Analysis + Synthesis Interpretation Analysis + Execution

cs 715 GCC: Introduction to Compilation 9/22 Implementation Mechanisms Translation Analysis + Synthesis Interpretation Analysis + Execution Translation Instructions Equivalent Instructions

cs 715 GCC: Introduction to Compilation 9/22 Implementation Mechanisms Translation Analysis + Synthesis Interpretation Analysis + Execution Translation Instructions Equivalent Instructions Interpretation Instructions Actions Implied by Instructions

cs 715 GCC: Introduction to Compilation 10/22 Language Implementation Models Synthesis Compilation Analysis Execution Interpretation

cs 715 GCC: Introduction to Compilation 11/22 Language Processor Models Front End Optimizer Back End Virtual Machine C,C++ Java, C#

cs 715 GCC: Introduction to Compilation 12/22 Translation Sequence in Our Example: Parsing ab<10?b:c; Input

cs 715 GCC: Introduction to Compilation 12/22 Translation Sequence in Our Example: Parsing ab<10?b:c; Input AsgnStmnt Lhs E ; E? E : E E < E Issues: num Parse Tree

cs 715 GCC: Introduction to Compilation 12/22 Translation Sequence in Our Example: Parsing ab<10?b:c; Input AsgnStmnt Lhs E ; E? E : E E < E Issues: num Parse Tree Grammar rules, terminals, non-terminals

cs 715 GCC: Introduction to Compilation 12/22 Translation Sequence in Our Example: Parsing ab<10?b:c; Input AsgnStmnt Lhs E ; E? E : E E < E Issues: num Parse Tree Grammar rules, terminals, non-terminals Order of application of grammar rules eg. is it (a b<10?) followed by (b:c)?

cs 715 GCC: Introduction to Compilation 12/22 Translation Sequence in Our Example: Parsing ab<10?b:c; Input AsgnStmnt Lhs E ; E? E : E E < E Issues: num Parse Tree 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.

cs 715 GCC: Introduction to Compilation 13/22 Translation Sequence in Our Example: Semantic Analysis ab<10?b:c; Input AsgnStmnt Lhs E ; E? E : E E < E num Parse Tree

cs 715 GCC: Introduction to Compilation 13/22 Translation Sequence in Our Example: Semantic Analysis ab<10?b:c; Input Issues: AsgnStmnt Lhs E E < E E? E : E num Parse Tree ; (a,int) < (bool)?: (int) (b,int) (c,int) num (b,int) (10,int) Abstract Syntax Tree (with attributes)

cs 715 GCC: Introduction to Compilation 13/22 Translation Sequence in Our Example: Semantic Analysis ab<10?b:c; Input AsgnStmnt Lhs E ; (a,int)?: (int) E < E E? E : E num Parse Tree < (bool) (b,int) (c,int) num (b,int) (10,int) Abstract Syntax Tree (with attributes) Issues: Symbol tables Have variables been declared? What are their types? What is their scope?

cs 715 GCC: Introduction to Compilation 13/22 Translation Sequence in Our Example: Semantic Analysis ab<10?b:c; Input AsgnStmnt Lhs E ; (a,int)?: (int) E < E E? E : E num Parse Tree < (bool) (b,int) (c,int) num (b,int) (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

cs 715 GCC: Introduction to Compilation 14/22 Translation Sequence in Our Example: IR Generation ab<10?b:c; Input AsgnStmnt Lhs E E < E E? E : E num Parse Tree ; (a,int) < (bool)?: (int) (b,int) (c,int) num (b,int) (10,int) Abstract Syntax Tree (with attributes)

cs 715 GCC: Introduction to Compilation 14/22 Translation Sequence in Our Example: IR Generation ab<10?b:c; Input Tree List T 0 < b 10 IfGoto Not L0: AsgnStmnt Lhs E E < E E? E : E num Parse Tree ; (a,int) < (bool)?: (int) (b,int) (c,int) num (b,int) (10,int) Abstract Syntax Tree (with attributes) T 0 T 1 L0: T 1 L1: a Goto L1: b c T 1 Issues:

cs 715 GCC: Introduction to Compilation 14/22 Translation Sequence in Our Example: IR Generation ab<10?b:c; Input Tree List T 0 < b 10 IfGoto Not L0: AsgnStmnt Lhs E E < E E? E : E num Parse Tree ; (a,int) < (bool)?: (int) (b,int) (c,int) num (b,int) (10,int) Abstract Syntax Tree (with attributes) T 0 T 1 L0: T 1 L1: a Goto L1: b c T 1 Issues: Convert to maximal trees which can be implemented without altering control flow Simplifies instruction selection and scheduling, register allocation etc.

cs 715 GCC: Introduction to Compilation 14/22 Translation Sequence in Our Example: IR Generation ab<10?b:c; Input Tree List T 0 < b 10 IfGoto Not L0: AsgnStmnt Lhs E E < E E? E : E num Parse Tree ; (a,int) < (bool)?: (int) (b,int) (c,int) num (b,int) (10,int) Abstract Syntax Tree (with attributes) T 0 T 1 L0: T 1 L1: a Goto L1: b c T 1 Issues: Convert to maximal trees which can be implemented without altering control flow Simplifies instruction selection and scheduling, register allocation etc. Linearise control flow by flattening nested control constructs

cs 715 GCC: Introduction to Compilation 15/22 Translation Sequence in Our Example: Instruction Selection ab<10?b:c; Input Tree List T 0 < b 10 IfGoto Not L0: T 0 AsgnStmnt Lhs E E < E E? E : E num Parse Tree ; (a,int) < (bool)?: (int) (b,int) (c,int) num (b,int) (10,int) Abstract Syntax Tree (with attributes) T 1 L0: T 1 L1: a Goto L1: b c T 1

cs 715 GCC: Introduction to Compilation 15/22 Translation Sequence in Our Example: Instruction Selection ab<10?b:c; Input Tree List T 0 < b 10 IfGoto Not L0: AsgnStmnt Lhs E E < E E? E : E num Parse Tree ; (a,int) < (bool)?: (int) (b,int) (c,int) num (b,int) (10,int) Abstract Syntax Tree (with attributes) T 0 T 1 L0: T 1 L1: a Goto L1: b c T 1 Instruction List T 0 b T 0 T 0 < b T 0! T 0 if T 0 0 goto L0: T 1 b goto L1: L0: T 1 c L1: a T 1 Issues:

cs 715 GCC: Introduction to Compilation 15/22 Translation Sequence in Our Example: Instruction Selection ab<10?b:c; Input Tree List T 0 < b 10 IfGoto Not L0: AsgnStmnt Lhs E E < E E? E : E num Parse Tree ; (a,int) < (bool)?: (int) (b,int) (c,int) num (b,int) (10,int) Abstract Syntax Tree (with attributes) T 0 T 1 L0: T 1 L1: a Goto L1: b c T 1 Instruction List T 0 b T 0 T 0 < b T 0! T 0 if T 0 0 goto L0: T 1 b goto L1: L0: T 1 c L1: a T 1 Issues: Cover trees with as few machine instructions as possible

cs 715 GCC: Introduction to Compilation 15/22 Translation Sequence in Our Example: Instruction Selection ab<10?b:c; Input Tree List T 0 < b 10 IfGoto Not L0: AsgnStmnt Lhs E E < E E? E : E num Parse Tree ; (a,int) < (bool)?: (int) (b,int) (c,int) num (b,int) (10,int) Abstract Syntax Tree (with attributes) T 0 T 1 L0: T 1 L1: a Goto L1: b c T 1 Instruction List T 0 b T 0 T 0 < b T 0! T 0 if T 0 0 goto L0: T 1 b goto L1: L0: T 1 c L1: a T 1 Issues: Cover trees with as few machine instructions as possible Use temporaries and local registers

cs 715 GCC: Introduction to Compilation 16/22 Translation Sequence in Our Example: Emitting Instructions ab<10?b:c; Input Tree List T 0 < b 10 IfGoto Not L0: AsgnStmnt Lhs E E < E E? E : E num Parse Tree ; (a,int) < (bool)?: (int) (b,int) (c,int) num (b,int) (10,int) Abstract Syntax Tree (with attributes) T 0 T 1 L0: T 1 L1: a Goto L1: b c T 1 Instruction List T 0 b T 0 T 0 < b T 0! T 0 if T 0 0 goto L0: T 1 b goto L1: L0: T 1 c L1: a T 1

cs 715 GCC: Introduction to Compilation 16/22 Translation Sequence in Our Example: Emitting Instructions ab<10?b:c; Input Tree List T 0 < b 10 IfGoto Not L0: AsgnStmnt Lhs Issues: E E < E E? E : E num Parse Tree ; (a,int) < (bool)?: (int) (b,int) (c,int) num (b,int) (10,int) Abstract Syntax Tree (with attributes) T 0 T 1 L0: T 1 L1: a Goto L1: b c T 1 Instruction List T 0 b T 0 T 0 < b T 0! T 0 if T 0 0 goto L0: T 1 b goto L1: L0: T 1 c L1: a T 1 Assembly Code lw $t0, 4($fp) slti $t0, $t0, 10 not $t0, $t0 bgtz $t0, L0: lw $t0, 4($fp) b L1: L0: lw $t0, 8($fp) L1: sw 0($fp), $t0

cs 715 GCC: Introduction to Compilation 16/22 Translation Sequence in Our Example: Emitting Instructions ab<10?b:c; Input Tree List T 0 < b 10 IfGoto Not L0: AsgnStmnt Lhs Issues: E Offsets E of? E variables : E in the stack frame E < E num Parse Tree ; (a,int) < (bool)?: (int) (b,int) (c,int) num (b,int) (10,int) Abstract Syntax Tree (with attributes) T 0 T 1 L0: T 1 L1: a Goto L1: b c T 1 Instruction List T 0 b T 0 T 0 < b T 0! T 0 if T 0 0 goto L0: T 1 b goto L1: L0: T 1 c L1: a T 1 Assembly Code lw $t0, 4($fp) slti $t0, $t0, 10 not $t0, $t0 bgtz $t0, L0: lw $t0, 4($fp) b L1: L0: lw $t0, 8($fp) L1: sw 0($fp), $t0

cs 715 GCC: Introduction to Compilation 16/22 Translation Sequence in Our Example: Emitting Instructions ab<10?b:c; Input Tree List T 0 < b 10 IfGoto Not L0: AsgnStmnt Lhs Issues: E Offsets E of? E variables : E in the stack frame E < E Actual register numbers andnum assembly mnemonics Parse Tree ; (a,int) < (bool)?: (int) (b,int) (c,int) num (b,int) (10,int) Abstract Syntax Tree (with attributes) T 0 T 1 L0: T 1 L1: a Goto L1: b c T 1 Instruction List T 0 b T 0 T 0 < b T 0! T 0 if T 0 0 goto L0: T 1 b goto L1: L0: T 1 c L1: a T 1 Assembly Code lw $t0, 4($fp) slti $t0, $t0, 10 not $t0, $t0 bgtz $t0, L0: lw $t0, 4($fp) b L1: L0: lw $t0, 8($fp) L1: sw 0($fp), $t0

cs 715 GCC: Introduction to Compilation 16/22 Translation Sequence in Our Example: Emitting Instructions ab<10?b:c; Input Tree List T 0 < b 10 IfGoto Not L0: T 0 T 1 L0: T 1 L1: a Goto L1: b c T 1 AsgnStmnt Lhs Issues: E Offsets E of? E variables : E in the stack frame E < E Actual register numbers andnum assembly mnemonics Code Parseto Tree construct and discard activation records Instruction List T 0 b T 0 T 0 < b T 0! T 0 if T 0 0 goto L0: T 1 b goto L1: L0: T 1 c L1: a T 1 ; (a,int) < (bool)?: (int) (b,int) (c,int) num (b,int) (10,int) Abstract Syntax Tree (with attributes) Assembly Code lw $t0, 4($fp) slti $t0, $t0, 10 not $t0, $t0 bgtz $t0, L0: lw $t0, 4($fp) b L1: L0: lw $t0, 8($fp) L1: sw 0($fp), $t0

cs 715 GCC: Introduction to Compilation 16/22 Translation Sequence in Our Example: Emitting Instructions ab<10?b:c; Input Tree List T 0 < b 10 IfGoto Not L0: AsgnStmnt Lhs E E < E E? E : E num Parse Tree ; (a,int) < (bool)?: (int) (b,int) (c,int) num (b,int) (10,int) Abstract Syntax Tree (with attributes) T 0 T 1 L0: T 1 L1: a Goto L1: b c T 1 Instruction List T 0 b T 0 T 0 < b T 0! T 0 if T 0 0 goto L0: T 1 b goto L1: L0: T 1 c L1: a T 1 Assembly Code lw $t0, 4($fp) slti $t0, $t0, 10 not $t0, $t0 bgtz $t0, L0: lw $t0, 4($fp) b L1: L0: lw $t0, 8($fp) L1: sw 0($fp), $t0

cs 715 GCC: Introduction to Compilation 17/22 Typical Front Ends Parser

cs 715 GCC: Introduction to Compilation 17/22 Typical Front Ends Source Program Parser Tokens Scanner

cs 715 GCC: Introduction to Compilation 17/22 Typical Front Ends Source Program Scanner Tokens Parser Parse Tree AST AST or Linear IR + Symbol Table Semantic Analyzer

cs 715 GCC: Introduction to Compilation 17/22 Typical Front Ends Source Program Scanner Tokens Parser Parse Tree AST AST or Linear IR + Symbol Table Semantic Analyzer Symtab Handler Error Handler

cs 715 GCC: Introduction to Compilation 18/22 Typical Back Ends M/c Ind. IR M/c Ind. Optimizer M/c Ind. IR Compile time evaluations Eliminating redundant computations

cs 715 GCC: Introduction to Compilation 18/22 Typical Back Ends M/c Ind. IR M/c Ind. Optimizer M/c Ind. IR Code Generator M/c Dep. IR Compile time evaluations Eliminating redundant computations Instruction Selection Local Reg Allocation Choice of Order of Evaluation

cs 715 GCC: Introduction to Compilation 18/22 Typical Back Ends M/c Ind. IR M/c Ind. Optimizer M/c Ind. IR Code Generator M/c Dep. IR M/c Dep. Optimizer Compile time evaluations Eliminating redundant computations Instruction Selection Local Reg Allocation Choice of Order of Evaluation Assembly Code

cs 715 GCC: Introduction to Compilation 18/22 Typical Back Ends M/c Ind. IR Register Allocator M/c Ind. Optimizer M/c Ind. IR Code Generator M/c Dep. IR Instruction Scheduler Compile time evaluations Eliminating redundant computations Instruction Selection Local Reg Allocation Choice of Order of Evaluation Peephole Optimizer Assembly Code

Part 4 Introduction to GCC

cs 715 GCC: Introduction to GCC 19/22 The GNU Tool Chain Source Program gcc Target Program

cs 715 GCC: Introduction to GCC 19/22 The GNU Tool Chain Source Program cc1 gcc Target Program

cs 715 GCC: Introduction to GCC 19/22 The GNU Tool Chain Source Program cc1 cpp gcc Target Program

cs 715 GCC: Introduction to GCC 19/22 The GNU Tool Chain Source Program cc1 cpp gcc as Target Program

cs 715 GCC: Introduction to GCC 19/22 The GNU Tool Chain Source Program cc1 cpp gcc as ld Target Program

cs 715 GCC: Introduction to GCC 19/22 The GNU Tool Chain Source Program cc1 cpp gcc as glibc/newlib ld Target Program

cs 715 GCC: Introduction to GCC 20/22 The GCC Framework Input Language Machine Description GCC Language Specific Code Language and Machine Independent Generic Code Machine dependent Generator Code Machine Descriptions Parser Genericizer Gimplifier Tree SSA Optimizer RTL Generator Optimizer Code Generator cc1/gcc

cs 715 GCC: Introduction to GCC 20/22 The GCC Framework Input Language Machine Description GCC Language Specific Code Language and Machine Independent Generic Code Machine dependent Generator Code Machine Descriptions Source Program Parser Genericizer Gimplifier Tree SSA Optimizer RTL Generator Optimizer Code Generator cc1/gcc Assembly Program

cs 715 GCC: Introduction to GCC 20/22 The GCC Framework Input Language Machine Description GCC Language Specific Code Language and Machine Independent Generic Code Machine dependent Generator Code Machine Descriptions Selected Parser Genericizer Gimplifier Tree SSA Optimizer RTL Generator Optimizer Code Generator cc1/gcc

cs 715 GCC: Introduction to GCC 20/22 The GCC Framework Input Language Machine Description GCC Language Specific Code Language and Machine Independent Generic Code Machine dependent Generator Code Machine Descriptions Selected Copied Copied Parser Genericizer Gimplifier Tree SSA Optimizer RTL Generator Optimizer Code Generator cc1/gcc

cs 715 GCC: Introduction to GCC 20/22 The GCC Framework Input Language Machine Description GCC Language Specific Code Language and Machine Independent Generic Code Machine dependent Generator Code Machine Descriptions Selected Copied Copied Generated Generated Parser Genericizer Gimplifier Tree SSA Optimizer RTL Generator Optimizer Code Generator cc1/gcc

cs 715 GCC: Introduction to GCC 21/22 The cc1 Phase Sequence as IR Chain The GCC Phase Sequence Generic GIMPLE RTL ASM

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 Explication Lower flow control Lower & data procedures Target

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 Explication Lower flow control Lower & data procedures Optimization Opportunities Target Rescoping SSA Scheduling

Part 5 Configuration and Building

cs 715 GCC: Configuration and Building 22/22 Configuring GCC configure

cs 715 GCC: Configuration and Building 22/22 Configuring GCC config.guess configure

cs 715 GCC: Configuration and Building 22/22 Configuring GCC configure.in config.guess configure

cs 715 GCC: Configuration and Building 22/22 Configuring GCC configure.in config/* config.guess configure

cs 715 GCC: Configuration and Building 22/22 Configuring GCC configure.in config/* config.guess config.sub configure

cs 715 GCC: Configuration and Building 22/22 Configuring GCC configure.in config/* config.guess config.sub configure config.log config.cache config.status

cs 715 GCC: Configuration and Building 22/22 Configuring GCC configure.in config/* config.guess config.sub configure config.h.in makefile.in config.log config.cache config.status

cs 715 GCC: Configuration and Building 22/22 Configuring GCC configure.in config/* config.guess config.sub configure config.h.in makefile.in config.log config.cache config.status Makefile config.h

Part 6 About The Course