Compiler Design - CS25C18

[ 4th Semester - CSE(CY) - Computer Science and Engineering (Cyber Security) Department ]

Under Class: | 4th Semester [CSE(CY) Dept Anna University 2025 Regulation] |

Compiler Design - CS25C18 - Study Materials, Notes, Important Questions, Anna University Semester Question Paper PDF Download

Engineering - Compiler Design - CS25C18 Subject (under Anna University 4th Semester - CSE(CY) - Computer Science and Engineering (Cyber Security) Department Regulation 2025) - Study Materials, Written and lecture Notes, Important Questions, Semester Question Paper PDF Download


Compiler Design


LEXICAL ANALYSIS:


• Algorithms for Solving Nonlinear Equations
• Introduction to Compiling Compilers
• Analysis of the source program
• The Phases of a Compiler
• Cousins of Compiler
• Grouping of the Phases
• Compiler Construction Tools
• Lexical Analysis
• Input Buffering
• Specification of Tokens
• Recognition of Tokens
• A Language For Specifying Lexical Analyzer
• Important Short Questions and Answers : Principles of Compiler Design - Lexical Analysis

SYNTAX ANALYSIS and RUN TIME ENVIRONMENTS:


• Syntax Analysis
• The Role of Parser
• Context-Free Grammars
• Writing a Grammar
• Top down parsing and Bottom up Parsing
• Constructing SLR(1) Parsing Table
• Type Checking
• Specification of a Simple Type Checker
• Run-Time Environments - Source Language Issues
• Storage Organization
• Storage Allocation Strategies
• Important Short Questions and Answers: Syntax Analysis and Run-Time Environments

INTERMEDIATE CODE GENERATION:


• Intermediate Languages
• Declarations
• Assignment Statements
• Boolean Expressions
• Case Statements
• Backpatching
• Procedure Calls
• Important Short Questions and Answers: Principles of Compiler Design - Intermediate Code Generation

CODE GENERATION:


• Issues in the design of a code generator
• Target Machine
• Run-Time Storage Management
• Basic Blocks and Flow Graphs of Code Generation
• A Simple Code Generator
• Register Allocation and Assignment
• The Dag Representation For Basic Blocks
• Generating Code From DAGs
• Important Short Questions and Answers: Compiler Design - Code Generation

CODE OPTIMIZATION:


• Code Optimization
• Principal Sources of Optimisation
• Peephole Optimization
• Optimization of Basic Blocks
• Loops in Flow Graph
• Introduction to Global Dataflow Analysis
• Code Improvig Transformations
• Glossary - Principles of Compiler Design
• Tutorial problems and worked out examples - Principles of Compiler Design
• Important Short Questions and Answers: Code optimization


Compiler Design



Chapter 1 : Introduction:


• Compilers - Principles, Techniques, & Tools
• Language Processors
• The Structure of a Compiler
• The Evolution of Programming Languages
• The Science of Building a Compiler
• Applications of Compiler Technology
• Programming Language Basics

Chapter 2 : Simple Syntax Directed Translator:


• A Simple Syntax-Directed Translator
• Syntax Definition
• Syntax-Directed Translation
• Parsing
• A Translator for Simple Expressions
• Lexical Analysis
• Symbol Table Per Scope and Use of Symbol Tables
• Intermediate Code Generation

Chapter 3 : Lexical Analysis:


• Lexical Analysis
• The Role of the Lexical Analyzer
• Input Buffering: Buffer Pairs, Sentinels
• Specification of Tokens
• Recognition of Tokens
• The Lexical-Analyzer Generator Lex
• Finite Automata
• From Regular Expressions to Automata
• Design of a Lexical-Analyzer Generator
• Optimization of DFA-Based Pattern Matchers

Chapter 4 : Syntax Analysis:


• Syntax Analysis
• Context-Free Grammars
• Writing a Grammar
• Top-Down Parsing
• Bottom-Up Parsing
• Introduction to LR Parsing: Simple LR
• More Powerful LR Parsers
• Using Ambiguous Grammars
• Parser Generators

Chapter 5 : Syntax Directed Translation:


• Syntax-Directed Translation
• Syntax-Directed Definitions
• Evaluation Orders for SDD's
• Applications of Syntax-Directed Translation
• Syntax-Directed Translation Schemes
• Implementing L-Attributed SDD's

Chapter 6 : Intermediate Code Generation:


• Intermediate-Code Generation
• Variants of Syntax Trees
• Three-Address Code
• Types and Declarations
• Translation of Expressions
• Type Checking
• Control Flow
• Backpatching
• Switch-Statements
• Intermediate Code for Procedures

Chapter 7 : Run Time Environments:


• Run-Time Environments
• Storage Organization
• Stack Allocation of Space
• Access to Nonlocal Data on the Stack
• Heap Management
• Introduction to Garbage Collection
• Introduction to Trace-Based Collection
• Short-Pause Garbage Collection
• Advanced Topics in Garbage Collection

Chapter 8 : Code Generation:


• Code Generation
• Issues in the Design of a Code Generator
• The Target Language
• Addresses in the Target Code
• Basic Blocks and Flow Graphs
• Optimization of Basic Blocks
• A Simple Code Generator
• Peephole Optimization
• Register Allocation and Assignment
• Instruction Selection by Tree Rewriting
• Optimal Code Generation for Expressions
• Dynamic Programming Code-Generation

Chapter 9 : Machine Independent Optimizations:


• Machine-Independent Optimizations
• The Principal Sources of Optimization
• Introduction to Data-Flow Analysis
• Foundations of Data-Flow Analysis
• Constant Propagation
• Partial-Redundancy Elimination
• Loops in Flow Graphs
• Region-Based Analysis
• Symbolic Analysis

Chapter 10 : Instruction Level Parallelism:


• Instruction-Level Parallelism
• Processor Architectures
• Code-Scheduling Constraints
• Basic-Block Scheduling
• Global Code Scheduling
• Software Pipelining Algorithm
• Scheduling Acyclic Data-Dependence and Cyclic Dependence Graphs
• Improvements to the Pipelining Algorithms

Chapter 11 : Optimizing for Parallelism and Locality:


• Optimizing for Parallelism and Locality
• Basic Concepts of Optimizing for Parallelism and Locality
• Matrix Multiply: An In-Depth Example
• Iteration Spaces
• Affine Array Indexes
• Data Reuse
• Array Data-Dependence Analysis
• Finding Synchronization-Free Parallelism
• Synchronization Between Parallel Loops
• Pipelining
• Locality Optimizations
• Other Uses of Affine Transforms

Chapter 12 : Interprocedural Analysis:


• Interprocedural Analysis
• Basic Concepts of Interprocedural Analysis
• Why Interprocedural Analysis?
• A Logical Representation of Data Flow
• A Simple Pointer-Analysis Algorithm
• Context-Insensitive Interprocedural Analysis
• Context-Sensitive Pointer Analysis
• Datalog Implementation by BDD's






 

CS25C18:

Compiler Design

 

Course Objectives: This course focuses on analyze the intricate process by which high-level programming languages are transformed into low-level machine code and facilitates the synthesis of knowledge regarding diverse compiler construction phases.

 

Basics Of Compiler and Lexical Analysis: Language Processors – Structure of a Compiler – Grouping of phases, Compiler construction tools – Applications of Compiler Technology – Lexical Analysis – Role of Lexical Analyzer – Input Buffering – Specification of Tokens – Recognition of Tokens – Lexical-Analyzer Generator Lex

Suggested Activities:

Identify the errors: Present code snippets with lexical errors. Ask students how a lexical analyzer would typically handle these errors.

Debugging: Encourage them to experiment with different input strings and debug their Lex specifications.

 

Top- Down Parser: Parser – Role of parser - Context-Free Grammars – Writing a Grammar – Top-Down Parsing – Recursive-Descent Parsing – FIRST() and FOLLOW() – LL(1) Grammars – Non-recursive Predictive Parsing

Suggested Activities:

Solve the exercises: Encourage the student to find the FIRST() and FOLLOW().

Discussion: Students prepare and present short videos explaining about the top down parser

 

Bottom - Up Parser: Bottom-Up Parsing –Basics of LR Parsing: Simple LR – Canonical LR – Look –Ahead LR – Example Problems of all LR parser.

Suggested Activities:

Poster Presentation: Design posters illustrating the role of parsers using popular tools

Solving Exercises: Give some example problems to construct the parsing tables.

 

Syntax Directed Translation And Intermediate Code Generation: Syntax Directed Translation – Syntax-Directed Definitions – Evaluation Orders for SDD’s - – Intermediate Code Generation – Variants of syntax trees – Three Address Code – Types and Declarations – Translation of Expressions – Type Checking – Control Flow

Suggested Activities:

Solving exercises: Solve the example problems in implementation of three address code part.

Seminar : All intermediate codes during compilation

 

Code Generation and Storage Management: Issues in the design of a code generation – The target Language – Addresses in the Target code – A simple code Generator – Run-Time Environments: Storage organization – Stack allocation of space – Heap Management – Basics of garbage collection.

Suggested Activities:

Seminar: Advanced topics in Garbage Collection.

Quiz: Test understanding of storage allocation strategies.

 

Machine Independent Optimization: Basic Blocks and Flow Graphs –Optimization of Basic Blocks – Peephole Optimization – The Principal Sources of Optimization – DAG – loops in flow graphs.

Suggested Activities:

Diagram aid: Draw the flow graphs for the optimization of basic blocks concept using any recent tool.

Quiz: Test concepts of basic blocks, flow graphs, and code optimization

 

Assessment Weightage:

Weightage:Continuous Assessment: 40%

• Activities: 10%

• Internal Test – 1&2: 30%

End Semester Theory Examination: 60%

Mandated Activities with marks:

Assignments (30), Quiz (10), Project based learning (25), Flipped Classroom (10), Review of GATE questions (25).

Internal Examinations: TWO tests

 

References:

1. Alfred V. Aho, Monica S. Lam, Ravi Sethi, Jeffrey D. Ullman, Compilers: Principles, Techniques, and Tools, 2nd Edition, Pearson, 2023.

2. Keith D. Cooper, Linda Torczon, Engineering a Compiler, 3rd Edition, Morgan Kaufmann, 2022.

3. Chattopadhyay S. Compiler Design. 2nd ed. PHI Learning; 2022.