JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY GURJADA VIZIANAGARAM
VIZIANAGARAM – 535 003, Andhra Pradesh, India
B.Tech CSE (R23-COURSE STRUCTURE & SYLLABUS)
L T P C
III Year I Semester COMPILER DESIGN LAB
0 0 3 1.5
Course Objectives:
The objectives of this course is to acquire knowledge on the
1. Implementation of a compiler for a basic language
2. Lex/Yacc specifications for designing frontend of a compiler
3. Generate MIPS instruction set
Course Outcomes:
The students should be able to:
1. Understand the different phases of compilation and the working of compilers like gcc, clang etc
2. Implement lexical analyzer for any language
3. Implement parser for any language
4. Implement 3-address code generator for simple programming constructs
5. Implement MIPS code generator by considering simple programming constructs
List of experiments
1. Check the ouput of different compilers gcc, g++, clang, clang++, javac, python etc by
running respective language programs with different flags. (purpose to understand
preprocessor, optimizations, linker)
2. The Language called TinyCStr is described as follows
a) Every TinyCStr program has one or more functions and syntax of function declaration
and function definition is similar to C, one function function must be main.
b) Every TinyCStr function has zero or statements
c) The possible statements are declaration, assignment, conditional
statements (if,else, for, while) except switch.
d) TinyCStr supports primitive data types of C and a string datatype
i. Implement a lexical analyser for TinyCStr usingflex/lex
ii. Implement a parser for TinyCStr using bison/yacc and generate AST(Abstract Syntax Tree)
iii. Generate a 3-address code from theAST
iv. Generate MIPS instructions from 3-address code and run it on SPIM simulator
3. Write a program illustrating code optimization techniques:
i) Constant folding ii) Copy propagation iii) Common sub expression elimination
iv)Loop unrolling v) Dead code elimination
Text Books:
i. flex & bison by John Levine Released August 2009 Publisher(s): O'Reilly Media,Inc.
ii. Compilers: Principles, Techniques and Tools, Second Edition, Alfred V. Aho,
Monica S. Lam, Ravi Sethi, Jeffry D. Ullman,Pearson.
Reference Books:
i. LLVM Cookbook, Mayur pandey
E-resources:
30
B.
Te
JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY GURJADA VIZIANAGARAM
VIZIANAGARAM – 535 003, Andhra Pradesh, India
B.Tech CSE (R23-COURSE STRUCTURE & SYLLABUS)
i. https://llvm.org/
ii. https://gcc.gnu.org/
iii. https://www.dsi.unive.it/~gasparetto/materials/MIPS_Instruction_Set.pdf
31
B.
Te