The Design and Implementation of Gnu Compiler Collection

Size: px
Start display at page:

Download "The Design and Implementation of Gnu Compiler Collection"

Transcription

1 The Design and Implementation of Gnu Compiler Collection Uday Khedker ( uday) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay July 2008

2 Part 1 Outline

3 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

4 Part 2 Open Source Vs. Free Software

5 cs 715 GCC: Open Source Vs. Free Software 2/22 Open Source Vs. Free Software The open source initiative: ( Emphasis on development methodology The Free Software Foundation: ( Emphasis on freedom of the user In some cases, open source software has restricted user freedom

6 cs 715 GCC: Open Source Vs. Free Software 2/22 Open Source Vs. Free Software The open source initiative: ( Emphasis on development methodology The Free Software Foundation: ( 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)

7 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, Cathedral: Total Centralized Control Design, implement, test, release Bazaar: Total Decentralization Release early, release often, let users fix bugs

8 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)

9 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

10 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?

11 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.

12 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.

13 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

14 Part 3 Introduction to Compilation

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

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

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

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

19 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

20 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

21 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

22 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

23 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

24 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

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

26 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

27 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

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

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

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

31 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

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

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

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

35 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

36 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

37 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)?

38 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.

39 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

40 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)

41 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?

42 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

43 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)

44 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:

45 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.

46 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

47 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

48 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:

49 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

50 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

51 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

52 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

53 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

54 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

55 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

56 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

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

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

59 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

60 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

61 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

62 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

63 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

64 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

65 Part 4 Introduction to GCC

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

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

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

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

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

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

72 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

73 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

74 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

75 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

76 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

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

78 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

79 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

80 Part 5 Configuration and Building

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

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

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

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

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

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

87 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

88 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

89 Part 6 About The Course

An Overview of Compilation

An Overview of Compilation An Overview of Compilation (www.cse.iitb.ac.in/ uday) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay January 2014 cs306 Compilation Overview: Outline 1/18 Outline

More information

Introduction and Opening Remarks

Introduction and Opening Remarks Workshop on Essential Abstractions in GCC Introduction and Opening Remarks GCC Resource Center (www.cse.iitb.ac.in/grc) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay

More information

The Design and Implementation of Gnu Compiler Collection

The Design and Implementation of Gnu Compiler Collection The Design and Implementation of Gnu Compiler Collection Uday Khedker (www.cse.iitb.ac.in/ uday) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay Aug 2008 Part 1 Compilation

More information

GCC Internals: A Conceptual View Part II

GCC Internals: A Conceptual View Part II : A Conceptual View Part II Abhijat Vichare CFDVS, Indian Institute of Technology, Bombay January 2008 Plan Part I GCC: Conceptual Structure C Program through GCC Building GCC Part II Gimple The MD-RTL

More information

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

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 What is a compiler? What is a compiler? Traditionally: Program that analyzes and translates from a high level language (e.g., C++) to low-level assembly language that can be executed by hardware int a,

More information

Introduction to Machine Descriptions

Introduction to Machine Descriptions Tutorial on Essential Abstractions in GCC Introduction to Machine Descriptions (www.cse.iitb.ac.in/grc) GCC Resource Center, Department of Computer Science and Engineering, Indian Institute of Technology,

More information

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

What is a compiler? Xiaokang Qiu Purdue University. August 21, 2017 ECE 573 What is a compiler? Xiaokang Qiu Purdue University ECE 573 August 21, 2017 What is a compiler? What is a compiler? Traditionally: Program that analyzes and translates from a high level language (e.g.,

More information

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

The Compiler So Far. CSC 4181 Compiler Construction. Semantic Analysis. Beyond Syntax. Goals of a Semantic Analyzer. The Compiler So Far CSC 4181 Compiler Construction Scanner - Lexical analysis Detects inputs with illegal tokens e.g.: main 5 (); Parser - Syntactic analysis Detects inputs with ill-formed parse trees

More information

The GNU Compiler Collection

The GNU Compiler Collection The GNU Compiler Collection Diego Novillo dnovillo@redhat.com Gelato Federation Meeting Porto Alegre, Rio Grande do Sul, Brazil October 3, 2005 Introduction GCC is a popular compiler, freely available

More information

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

An Overview to Compiler Design. 2008/2/14 \course\cpeg421-08s\topic-1a.ppt 1 An Overview to Compiler Design 2008/2/14 \course\cpeg421-08s\topic-1a.ppt 1 Outline An Overview of Compiler Structure Front End Middle End Back End 2008/2/14 \course\cpeg421-08s\topic-1a.ppt 2 Reading

More information

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

Compiler Theory. (Semantic Analysis and Run-Time Environments) Compiler Theory (Semantic Analysis and Run-Time Environments) 005 Semantic Actions A compiler must do more than recognise whether a sentence belongs to the language of a grammar it must do something useful

More information

COLLEGE OF ENGINEERING, NASHIK. LANGUAGE TRANSLATOR

COLLEGE OF ENGINEERING, NASHIK. LANGUAGE TRANSLATOR Pune Vidyarthi Griha s COLLEGE OF ENGINEERING, NASHIK. LANGUAGE TRANSLATOR By Prof. Anand N. Gharu (Assistant Professor) PVGCOE Computer Dept.. 22nd Jan 2018 CONTENTS :- 1. Role of lexical analysis 2.

More information

Semantic Analysis. Compiler Architecture

Semantic Analysis. Compiler Architecture Processing Systems Prof. Mohamed Hamada Software Engineering Lab. The University of Aizu Japan Source Compiler Architecture Front End Scanner (lexical tokens Parser (syntax Parse tree Semantic Analysis

More information

Incremental Machine Descriptions for GCC

Incremental Machine Descriptions for GCC Incremental Machine Descriptions for GCC Sameera Deshpande Uday Khedker. (www.cse.iitb.ac.in/ {sameera,uday}) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay September

More information

Compiler Design (40-414)

Compiler Design (40-414) Compiler Design (40-414) Main Text Book: Compilers: Principles, Techniques & Tools, 2 nd ed., Aho, Lam, Sethi, and Ullman, 2007 Evaluation: Midterm Exam 35% Final Exam 35% Assignments and Quizzes 10% Project

More information

CS5363 Final Review. cs5363 1

CS5363 Final Review. cs5363 1 CS5363 Final Review cs5363 1 Programming language implementation Programming languages Tools for describing data and algorithms Instructing machines what to do Communicate between computers and programmers

More information

UNIT -1 1.1 OVERVIEW OF LANGUAGE PROCESSING SYSTEM 1.2 Preprocessor A preprocessor produce input to compilers. They may perform the following functions. 1. Macro processing: A preprocessor may allow a

More information

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

Prof. Mohamed Hamada Software Engineering Lab. The University of Aizu Japan Language Processing Systems Prof. Mohamed Hamada Software Engineering Lab. The University of Aizu Japan Semantic Analysis Compiler Architecture Front End Back End Source language Scanner (lexical analysis)

More information

Intermediate Code & Local Optimizations

Intermediate Code & Local Optimizations Lecture Outline Intermediate Code & Local Optimizations Intermediate code Local optimizations Compiler Design I (2011) 2 Code Generation Summary We have so far discussed Runtime organization Simple stack

More information

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

Compiler Design. Computer Science & Information Technology (CS) Rank under AIR 100 GATE- 2016-17 Postal Correspondence 1 Compiler Design Computer Science & Information Technology (CS) 20 Rank under AIR 100 Postal Correspondence Examination Oriented Theory, Practice Set Key concepts,

More information

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

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler Front-End Outline Semantic Analysis The role of semantic analysis in a compiler A laundry list of tasks Scope Static vs. Dynamic scoping Implementation: symbol tables Types Static analyses that detect type errors

More information

First Level Gray Box Probing

First Level Gray Box Probing First Level Gray Box Probing (www.cse.iitb.ac.in/ uday) GCC Resource Center, Department of Computer Science and Engineering, Indian Institute of Technology, Bombay January 2012 CS 715 Graybox Probing-I:

More information

Alternatives for semantic processing

Alternatives for semantic processing Semantic Processing Copyright c 2000 by Antony L. Hosking. Permission to make digital or hard copies of part or all of this work for personal or classroom use is granted without fee provided that copies

More information

Syntax-Directed Translation. Lecture 14

Syntax-Directed Translation. Lecture 14 Syntax-Directed Translation Lecture 14 (adapted from slides by R. Bodik) 9/27/2006 Prof. Hilfinger, Lecture 14 1 Motivation: parser as a translator syntax-directed translation stream of tokens parser ASTs,

More information

CS 4201 Compilers 2014/2015 Handout: Lab 1

CS 4201 Compilers 2014/2015 Handout: Lab 1 CS 4201 Compilers 2014/2015 Handout: Lab 1 Lab Content: - What is compiler? - What is compilation? - Features of compiler - Compiler structure - Phases of compiler - Programs related to compilers - Some

More information

An Architectural Overview of GCC

An Architectural Overview of GCC An Architectural Overview of GCC Diego Novillo dnovillo@redhat.com Red Hat Canada Linux Symposium Ottawa, Canada, July 2006 Topics 1. Overview 2. Development model 3. Compiler infrastructure 4. Intermediate

More information

Intermediate Representations

Intermediate Representations COMP 506 Rice University Spring 2018 Intermediate Representations source code IR Front End Optimizer Back End IR target code Copyright 2018, Keith D. Cooper & Linda Torczon, all rights reserved. Students

More information

Principles of Compiler Design

Principles of Compiler Design Principles of Compiler Design Intermediate Representation Compiler Lexical Analysis Syntax Analysis Semantic Analysis Source Program Token stream Abstract Syntax tree Unambiguous Program representation

More information

Welcome to CSE131b: Compiler Construction

Welcome to CSE131b: Compiler Construction Welcome to CSE131b: Compiler Construction Lingjia Tang pic from: http://xkcd.com/303/ Course Information What are compilers? Why do we learn about them? History of compilers Structure of compilers A bit

More information

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

Lecture Outline. Code Generation. Lecture 30. Example of a Stack Machine Program. Stack Machines Lecture Outline Code Generation Lecture 30 (based on slides by R. Bodik) Stack machines The MIPS assembly language The x86 assembly language A simple source language Stack-machine implementation of the

More information

Intermediate Code Generation

Intermediate Code Generation Intermediate Code Generation In the analysis-synthesis model of a compiler, the front end analyzes a source program and creates an intermediate representation, from which the back end generates target

More information

Code Generation. Lecture 30

Code Generation. Lecture 30 Code Generation Lecture 30 (based on slides by R. Bodik) 11/14/06 Prof. Hilfinger CS164 Lecture 30 1 Lecture Outline Stack machines The MIPS assembly language The x86 assembly language A simple source

More information

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

CSc 453. Code Generation I Christian Collberg. Compiler Phases. Code Generation Issues. Slide Compilers and Systems Software. Slide 16 2 Lexing, Parsing Semantic Analysis, Intermediate Code Generation Peephole Optimization Assembly Code Assembler Machine Code Register Allocation Intermediate Code Selection Scheduling Register

More information

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

Introduction. CSc 453. Compilers and Systems Software. 19 : Code Generation I. Department of Computer Science University of Arizona. CSc 453 Compilers and Systems Software 19 : Code Generation I Introduction Department of Computer Science University of Arizona collberg@gmail.com Copyright c 2009 Christian Collberg Compiler Phases Optimize

More information

Formats of Translated Programs

Formats of Translated Programs Formats of Translated Programs Compilers differ in the format of the target code they generate. Target formats may be categorized as assembly language, relocatable binary, or memory-image. Assembly Language

More information

Undergraduate Compilers in a Day

Undergraduate Compilers in a Day Question of the Day Backpatching o.foo(); In Java, the address of foo() is often not known until runtime (due to dynamic class loading), so the method call requires a table lookup. After the first execution

More information

The Structure of a Syntax-Directed Compiler

The Structure of a Syntax-Directed Compiler Source Program (Character Stream) Scanner Tokens Parser Abstract Syntax Tree Type Checker (AST) Decorated AST Translator Intermediate Representation Symbol Tables Optimizer (IR) IR Code Generator Target

More information

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

9/5/17. The Design and Implementation of Programming Languages. Compilation. Interpretation. Compilation vs. Interpretation. Hybrid Implementation Language Implementation Methods The Design and Implementation of Programming Languages Compilation Interpretation Hybrid In Text: Chapter 1 2 Compilation Interpretation Translate high-level programs to

More information

Plugin Mechanisms in GCC

Plugin Mechanisms in GCC Plugin Mechanisms in GCC (www.cse.iitb.ac.in/ uday) GCC Resource Center, Department of Computer Science and Engineering, Indian Institute of Technology, Bombay 13 June 2014 EAGCC-PLDI-14 Plugins: Outline

More information

Retargeting GCC to Spim: A Recap

Retargeting GCC to Spim: A Recap Workshop on Essential Abstractions in GCC July 09 Spim MD Levels 0 & 1: Outline 1/32 Outline Incremental Machine Descriptions for Spim: Levels 0 and 1 GCC Resource Center (www.cse.iitb.ac.in/grc Department

More information

CS 415 Midterm Exam Spring 2002

CS 415 Midterm Exam Spring 2002 CS 415 Midterm Exam Spring 2002 Name KEY Email Address Student ID # Pledge: This exam is closed note, closed book. Good Luck! Score Fortran Algol 60 Compilation Names, Bindings, Scope Functional Programming

More information

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

Acknowledgement. CS Compiler Design. Semantic Processing. Alternatives for semantic processing. Intro to Semantic Analysis. V. Acknowledgement CS3300 - Compiler Design Intro to Semantic Analysis V. Krishna Nandivada IIT Madras Copyright c 2000 by Antony L. Hosking. Permission to make digital or hard copies of part or all of this

More information

Appendix A The DL Language

Appendix A The DL Language Appendix A The DL Language This appendix gives a description of the DL language used for many of the compiler examples in the book. DL is a simple high-level language, only operating on integer data, with

More information

Implementing Subprograms

Implementing Subprograms 1 Implementing Subprograms CS 315 Programming Languages Pinar Duygulu Bilkent University CS315 Programming Languages Pinar Duygulu The General Semantics of Calls and Returns 2 The subprogram call and return

More information

GCC Configuration and Building

GCC Configuration and Building Tutorial on Essential Abstractions in GCC GCC Configuration and Building (www.cse.iitb.ac.in/grc) GCC Resource Center, Department of Computer Science and Engineering, Indian Institute of Technology, Bombay

More information

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

Compilers. Intermediate representations and code generation. Yannis Smaragdakis, U. Athens (original slides by Sam Compilers Intermediate representations and code generation Yannis Smaragdakis, U. Athens (original slides by Sam Guyer@Tufts) Today Intermediate representations and code generation Scanner Parser Semantic

More information

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

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

More information

Project Compiler. CS031 TA Help Session November 28, 2011

Project Compiler. CS031 TA Help Session November 28, 2011 Project Compiler CS031 TA Help Session November 28, 2011 Motivation Generally, it s easier to program in higher-level languages than in assembly. Our goal is to automate the conversion from a higher-level

More information

GCC Control Flow and Plugins

GCC Control Flow and Plugins Workshop on GCC Control Flow and Plugins GCC Resource Center (www.cse.iitb.ac.in/grc) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay July 2010 July 2010 Plugins:

More information

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

Anatomy of a Compiler. Overview of Semantic Analysis. The Compiler So Far. Why a Separate Semantic Analysis? Anatomy of a Compiler Program (character stream) Lexical Analyzer (Scanner) Syntax Analyzer (Parser) Semantic Analysis Parse Tree Intermediate Code Generator Intermediate Code Optimizer Code Generator

More information

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

CSE P 501 Compilers. Intermediate Representations Hal Perkins Spring UW CSE P 501 Spring 2018 G-1 CSE P 501 Compilers Intermediate Representations Hal Perkins Spring 2018 UW CSE P 501 Spring 2018 G-1 Administrivia Semantics/types/symbol table project due ~2 weeks how goes it? Should be caught up on

More information

Using GCC as a Research Compiler

Using GCC as a Research Compiler Using GCC as a Research Compiler Diego Novillo dnovillo@redhat.com Computer Engineering Seminar Series North Carolina State University October 25, 2004 Introduction GCC is a popular compiler, freely available

More information

What do Compilers Produce?

What do Compilers Produce? What do Compilers Produce? Pure Machine Code Compilers may generate code for a particular machine, not assuming any operating system or library routines. This is pure code because it includes nothing beyond

More information

5. Semantic Analysis!

5. Semantic Analysis! 5. Semantic Analysis! Prof. O. Nierstrasz! Thanks to Jens Palsberg and Tony Hosking for their kind permission to reuse and adapt the CS132 and CS502 lecture notes.! http://www.cs.ucla.edu/~palsberg/! http://www.cs.purdue.edu/homes/hosking/!

More information

CS 415 Midterm Exam Spring SOLUTION

CS 415 Midterm Exam Spring SOLUTION CS 415 Midterm Exam Spring 2005 - SOLUTION Name Email Address Student ID # Pledge: This exam is closed note, closed book. Questions will be graded on quality of answer. Please supply the best answer you

More information

5. Semantic Analysis. Mircea Lungu Oscar Nierstrasz

5. Semantic Analysis. Mircea Lungu Oscar Nierstrasz 5. Semantic Analysis Mircea Lungu Oscar Nierstrasz Thanks to Jens Palsberg and Tony Hosking for their kind permission to reuse and adapt the CS132 and CS502 lecture notes. http://www.cs.ucla.edu/~palsberg/

More information

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

Administration CS 412/413. Why build a compiler? Compilers. Architectural independence. Source-to-source translator CS 412/413 Introduction to Compilers and Translators Andrew Myers Cornell University Administration Design reports due Friday Current demo schedule on web page send mail with preferred times if you haven

More information

COMP 303 Computer Architecture Lecture 3. Comp 303 Computer Architecture

COMP 303 Computer Architecture Lecture 3. Comp 303 Computer Architecture COMP 303 Computer Architecture Lecture 3 Comp 303 Computer Architecture 1 Supporting procedures in computer hardware The execution of a procedure Place parameters in a place where the procedure can access

More information

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

Agenda. CSE P 501 Compilers. Big Picture. Compiler Organization. Intermediate Representations. IR for Code Generation. CSE P 501 Au05 N-1 Agenda CSE P 501 Compilers Instruction Selection Hal Perkins Autumn 2005 Compiler back-end organization Low-level intermediate representations Trees Linear Instruction selection algorithms Tree pattern

More information

The Phasewise File Groups of GCC

The Phasewise File Groups of GCC The Phasewise File Groups of GCC GCC Version 4.0.2 Abhijat Vichare (amvichare@iitb.ac.in) Indian Institute of Technology, Bombay (http://www.iitb.ac.in) This is edition 1.0 of The Phasewise File Groups

More information

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

COP4020 Programming Languages. Compilers and Interpreters Robert van Engelen & Chris Lacher COP4020 ming Languages Compilers and Interpreters Robert van Engelen & Chris Lacher Overview Common compiler and interpreter configurations Virtual machines Integrated development environments Compiler

More information

Introduction to Compiler Construction

Introduction to Compiler Construction Introduction to Compiler Construction Robert van Engelen http://www.cs.fsu.edu/~engelen/courses/cop5621 COP5621 Compiler Construction Copyright Robert van Engelen, Florida State University, 2005 Syllabus

More information

Semantic Analysis and Type Checking

Semantic Analysis and Type Checking Semantic Analysis and Type Checking The compilation process is driven by the syntactic structure of the program as discovered by the parser Semantic routines: interpret meaning of the program based on

More information

Time : 1 Hour Max Marks : 30

Time : 1 Hour Max Marks : 30 Total No. of Questions : 6 P4890 B.E/ Insem.- 74 B.E ( Computer Engg) PRINCIPLES OF MODERN COMPILER DESIGN (2012 Pattern) (Semester I) Time : 1 Hour Max Marks : 30 Q.1 a) Explain need of symbol table with

More information

The role of semantic analysis in a compiler

The role of semantic analysis in a compiler Semantic Analysis Outline The role of semantic analysis in a compiler A laundry list of tasks Scope Static vs. Dynamic scoping Implementation: symbol tables Types Static analyses that detect type errors

More information

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

CS152 Programming Language Paradigms Prof. Tom Austin, Fall Syntax & Semantics, and Language Design Criteria CS152 Programming Language Paradigms Prof. Tom Austin, Fall 2014 Syntax & Semantics, and Language Design Criteria Lab 1 solution (in class) Formally defining a language When we define a language, we need

More information

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

Syntax-directed translation. Context-sensitive analysis. What context-sensitive questions might the compiler ask? Syntax-directed translation Context-sensitive analysis The compilation process is driven by the syntactic structure of the program as discovered by the parser Semantic routines: interpret meaning of the

More information

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

Crafting a Compiler with C (II) Compiler V. S. Interpreter Crafting a Compiler with C (II) 資科系 林偉川 Compiler V S Interpreter Compilation - Translate high-level program to machine code Lexical Analyzer, Syntax Analyzer, Intermediate code generator(semantics Analyzer),

More information

PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILING

PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILING PRINCIPLES OF COMPILER DESIGN 2 MARKS UNIT I INTRODUCTION TO COMPILING 1. Define compiler? A compiler is a program that reads a program written in one language (source language) and translates it into

More information

Semantic actions for expressions

Semantic actions for expressions Semantic actions for expressions Semantic actions Semantic actions are routines called as productions (or parts of productions) are recognized Actions work together to build up intermediate representations

More information

CSE 401/M501 Compilers

CSE 401/M501 Compilers CSE 401/M501 Compilers Intermediate Representations Hal Perkins Autumn 2018 UW CSE 401/M501 Autumn 2018 G-1 Agenda Survey of Intermediate Representations Graphical Concrete/Abstract Syntax Trees (ASTs)

More information

Compilers and Code Optimization EDOARDO FUSELLA

Compilers and Code Optimization EDOARDO FUSELLA Compilers and Code Optimization EDOARDO FUSELLA The course covers Compiler architecture Pre-requisite Front-end Strong programming background in C, C++ Back-end LLVM Code optimization A case study: nu+

More information

5. Semantic Analysis. Mircea Lungu Oscar Nierstrasz

5. Semantic Analysis. Mircea Lungu Oscar Nierstrasz 5. Semantic Analysis Mircea Lungu Oscar Nierstrasz Thanks to Jens Palsberg and Tony Hosking for their kind permission to reuse and adapt the CS132 and CS502 lecture notes. http://www.cs.ucla.edu/~palsberg/

More information

CSE 582 Autumn 2002 Exam 11/26/02

CSE 582 Autumn 2002 Exam 11/26/02 Name There are 8 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. You may refer to the following reference materials:

More information

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

Prof. Mohamed Hamada Software Engineering Lab. The University of Aizu Japan Language Processing Systems Prof. Mohamed Hamada Software ngineering Lab. The University of Aizu Japan Intermediate/Code Generation Source language Scanner (lexical analysis) tokens Parser (syntax analysis)

More information

Extension of GCC with a fully manageable reverse engineering front end

Extension of GCC with a fully manageable reverse engineering front end Proceedings of the 7 th International Conference on Applied Informatics Eger, Hungary, January 28 31, 2007. Vol. 1. pp. 147 154. Extension of GCC with a fully manageable reverse engineering front end Csaba

More information

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

CSE450. Translation of Programming Languages. Lecture 11: Semantic Analysis: Types & Type Checking CSE450 Translation of Programming Languages Lecture 11: Semantic Analysis: Types & Type Checking Structure Project 1 - of a Project 2 - Compiler Today! Project 3 - Source Language Lexical Analyzer Syntax

More information

LECTURE 3. Compiler Phases

LECTURE 3. Compiler Phases LECTURE 3 Compiler Phases COMPILER PHASES Compilation of a program proceeds through a fixed series of phases. Each phase uses an (intermediate) form of the program produced by an earlier phase. Subsequent

More information

LECTURE NOTES ON COMPILER DESIGN P a g e 2

LECTURE NOTES ON COMPILER DESIGN P a g e 2 LECTURE NOTES ON COMPILER DESIGN P a g e 1 (PCCS4305) COMPILER DESIGN KISHORE KUMAR SAHU SR. LECTURER, DEPARTMENT OF INFORMATION TECHNOLOGY ROLAND INSTITUTE OF TECHNOLOGY, BERHAMPUR LECTURE NOTES ON COMPILER

More information

Introduction to Compiler Construction

Introduction to Compiler Construction Introduction to Compiler Construction Robert van Engelen http://www.cs.fsu.edu/~engelen/courses/cop5621 COP5621 Compiler Construction Copyright Robert van Engelen, Florida State University, 2007-2011 Syllabus

More information

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

IR Optimization. May 15th, Tuesday, May 14, 13 IR Optimization May 15th, 2013 Tuesday, May 14, 13 But before we talk about IR optimization... Wrapping up IR generation Tuesday, May 14, 13 Three-Address Code Or TAC The IR that you will be using for

More information

GENERIC and GIMPLE: A New Tree Representation for Entire Functions

GENERIC and GIMPLE: A New Tree Representation for Entire Functions GENERIC and GIMPLE: A New Tree Representation for Entire Functions Jason Merrill Red Hat, Inc. jason@redhat.com 1 Abstract The tree SSA project requires a tree representation of functions for the optimizers

More information

Chapter 2. Instructions:

Chapter 2. Instructions: Chapter 2 1 Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive e.g., MIPS Arithmetic Instructions We ll be working with

More information

GUJARAT TECHNOLOGICAL UNIVERSITY

GUJARAT TECHNOLOGICAL UNIVERSITY Type of course: System Programming GUJARAT TECHNOLOGICAL UNIVERSITY SYSTEM PROGRAMMING SUBJECT CODE: 21508 B.E. 5 th SEMESTER Prerequisite: Data Structures and Operating Systems Rationale: NA Teaching

More information

CSE 401 Midterm Exam Sample Solution 11/4/11

CSE 401 Midterm Exam Sample Solution 11/4/11 Question 1. (12 points, 2 each) The front end of a compiler consists of three parts: scanner, parser, and (static) semantics. Collectively these need to analyze the input program and decide if it is correctly

More information

Code Genera*on for Control Flow Constructs

Code Genera*on for Control Flow Constructs Code Genera*on for Control Flow Constructs 1 Roadmap Last *me: Got the basics of MIPS CodeGen for some AST node types This *me: Do the rest of the AST nodes Introduce control flow graphs Scanner Parser

More information

CST-402(T): Language Processors

CST-402(T): Language Processors CST-402(T): Language Processors Course Outcomes: On successful completion of the course, students will be able to: 1. Exhibit role of various phases of compilation, with understanding of types of grammars

More information

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

Announcements. My office hours are today in Gates 160 from 1PM-3PM. Programming Project 3 checkpoint due tomorrow night at 11:59PM. IR Generation Announcements My office hours are today in Gates 160 from 1PM-3PM. Programming Project 3 checkpoint due tomorrow night at 11:59PM. This is a hard deadline and no late submissions will be

More information

The Structure of a Compiler

The Structure of a Compiler The Structure of a Compiler A compiler performs two major tasks: Analysis of the source program being compiled Synthesis of a target program Almost all modern compilers are syntax-directed: The compilation

More information

Compiling Regular Expressions COMP360

Compiling Regular Expressions COMP360 Compiling Regular Expressions COMP360 Logic is the beginning of wisdom, not the end. Leonard Nimoy Compiler s Purpose The compiler converts the program source code into a form that can be executed by the

More information

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

CSC488S/CSC2107S - Compilers and Interpreters. CSC 488S/CSC 2107S Lecture Notes CSC 488S/CSC 2107S Lecture Notes These lecture notes are provided for the personal use of students taking CSC488H1S or CSC2107HS in the Winter 2013/2014 term at the University of Toronto Copying for purposes

More information

Review. Pat Morin COMP 3002

Review. Pat Morin COMP 3002 Review Pat Morin COMP 3002 What is a Compiler A compiler translates from a source language S to a target language T while preserving the meaning of the input 2 Structure of a Compiler program text syntactic

More information

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

Usually, target code is semantically equivalent to source code, but not always! What is a Compiler? Compiler A program that translates code in one language (source code) to code in another language (target code). Usually, target code is semantically equivalent to source code, but

More information

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

Outline. Lecture 17: Putting it all together. Example (input program) How to make the computer understand? Example (Output assembly code) Fall 2002 Outline 5 Fall 2002 Lecture 17: Putting it all together From parsing to code generation Saman Amarasinghe 2 6.035 MIT Fall 1998 How to make the computer understand? Write a program using a programming

More information

Advances in Compilers

Advances in Compilers Advances in Compilers Prof. (Dr.) K.R. Chowdhary, Director COE Email: kr.chowdhary@jietjodhpur.ac.in webpage: http://www.krchowdhary.com JIET College of Engineering August 4, 2017 kr chowdhary Compilers

More information

CS415 Compilers. Intermediate Represeation & Code Generation

CS415 Compilers. Intermediate Represeation & Code Generation CS415 Compilers Intermediate Represeation & Code Generation These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University Review - Types of Intermediate Representations

More information

Intermediate Code Generation

Intermediate Code Generation Intermediate Code Generation Rupesh Nasre. CS3300 Compiler Design IIT Madras July 2018 Character stream Lexical Analyzer Machine-Independent Code Code Optimizer F r o n t e n d Token stream Syntax Analyzer

More information

Politecnico di Milano

Politecnico di Milano Politecnico di Milano Contents 1 2 3 4 Contents 1 2 3 4 Advanced Compiler System for Education It is our simple compiler front-end: accepts a C-like language generates a RISC-like intermediate code Usually,

More information

Recursive Descent Parsers

Recursive Descent Parsers Recursive Descent Parsers Lecture 7 Robb T. Koether Hampden-Sydney College Wed, Jan 28, 2015 Robb T. Koether (Hampden-Sydney College) Recursive Descent Parsers Wed, Jan 28, 2015 1 / 18 1 Parsing 2 LL Parsers

More information

CS453 Compiler Construction

CS453 Compiler Construction CS453 Compiler Construction Original Design: Michelle Strout Instructor: Wim Bohm wim.bohm@gmail.com, bohm@cs.colostate.edu Computer Science Building 344 Office hour: Monday 1-2pm TA: Andy Stone aistone@gmail.com,

More information