VALLIAMMAI ENGINEERING COLLEGE
SRM Nagar, Kattankulathur – 603 203
DEPARTMENT OF INFORMATION TECHNOLOGY
QUESTION BANK
VI SEMESTER
CS6660 COMPILER DESIGN
Regulation – 2013
Academic Year 2017 – 18
Prepared by
Ms. S. Jeyalakshmi, Assistant Professor / IT
Ms. R. Saranya, Assistant Professor / IT
VALLIAMMAI ENGINEERING COLLEGE SRM Nagar, Kattankulathur-603203.
Department of Information Technology Question Bank
SUBJECT : CS6660 COMPILER DESIGN
SEM / YEAR: VI Sem / III Year
UNIT I - INTRODUCTION TO COMPILERS
Translators-Compilation and Interpretation-Language processors -The Phases of Compiler-Errors Encountered
in Different Phases-The Grouping of Phases-Compiler Construction Tools - Programming Language basics
PART-A
Q.No Question BTL Competence
1 State any two reasons to why phases of compiler should be grouped. BTL-3 Applying
2 How will you group the phases of compiler? BTL-2 Understanding
3 Illustrate diagrammatically how a language is processed. BTL-6 Creating
4 Mention few cousins of compiler. BTL-3 Applying
5 What is a compiler? BTL-1 Remembering
6 Differentiate compiler and interpreter. BTL-2 Understanding
7 Explain the working of compiler. BTL-4 Analysing
8 Draw the block diagram of compiler. BTL-3 Applying
9 What are the aspects of high level languages which make them preferable
over machine language? BTL-4 Analysing
10 Discuss a compiler writing tools. BTL-2 Understanding
11 Compare single pass compiler and multi pass compiler BTL-4 Analysing
12 What do you mean by Cross-Compiler? BTL-1 Remembering
13 List the various compiler construction tools. BTL-6 Creating
14 Define compiler-compiler. BTL-1 Remembering
15 Mention the back-end phases of a compiler. BTL-2 Understanding
16 List the phases that constitute the front-end of a compiler. BTL-5 Evaluating
17 What are the classifications of compiler? BTL-5 Evaluating
18 What is an interpreter? BTL-1 Remembering
19 What are the two parts of a compilation? BTL-1 Remembering
20 What is a symbol table? BTL-1 Remembering
PART-B
1
(i)Mention any four compiler construction tools with their benefits and
drawbacks.(7)
(ii)Explain the need for grouping of phases of compiler. (6)
BTL-1 Remembering
2
(i)Define the following terms : Compiler, Interpreter, Translator and
difference between them. (8)
(ii)Describe in detail about Cousins of compiler. (5)
BTL-1 Remembering
3 Explain in detail the process of compilation. Illustrate the output of each
phase of compilation for the input : a = ( b + c ) * ( b + c ) * 2. BTL-5 Evaluating
4 (i)Explain the different phases of a compiler in detail. (10)
(ii)Discuss the cousins of compiler. (3) BTL-2 Understanding
5 What are the phases of compiler? Explain the phases in detail. Write down
the output of each phase for the expression a : = b + c * 50 BTL-6 Creating
6
For the given block structured code, indicate the values assigned to w, x, y
and z.
int i = 3 ; int j = 4 ;
{ int i = 5;
w = i + j ;
}
x = i + j ;
{ int j = 6 ;
{ i = 7 ;
y = i + j ;
}
z = i + j ;
}
BTL-2 Understanding
7 Explain in detail about the phases of compiler and translate the statement
pos := init + rate * 60 BTL-4 Analyzing
8
(i)Explain the various errors encountered in different phases of a compiler in
detail. (9)
(ii)Write notes on Symbol Table. (4)
BTL-1 Remembering
9 Briefly explain the compiler construction tools BTL-1 Remembering
10 Explain in detail the front end and back end of the compiler with the help of
examples BTL-3 Applying
11 Describe the basics of programming language in brief. BTL-4 Analyzing
12
For the given block structured code, indicate the values assigned to w, x, y
and z.
int w, x, y, z;
int i = 4 ; j = 5 ;
{ int j = 7;
i = 6 ;
w = i + j ;
}
x = i + j ;
{ int i = 8 ;
y = i + j ;
}
z = i + j ;
BTL-2 Understanding
13 Explain in detail the fundamental language processing activities. BTL-4 Analyzing
14 State the necessity for the compiler in conventional programming language BTL-3 Applying
PART - C
1
For the given block structured code, assuming the usual static scoping of
declarations, give the scope for each of the twelve declarations.
{ int w, x, y, z ; /* Block B1 */
{ int x, z ; /* Block B2 */
{ int w, x ; /* Block B3 */
} }
{ int w, x ; /* Block B4 */
{ int y, z ; /* Block B5 */
} } }
BTL-3 Applying
2
For the given block structured code, assuming the usual static scoping of
declarations, give the scope for each of the declarations.
main()
{ int a = 1; /* Block B1 */
int b = 1;
{ int b = 2; /* Block B2 */
{ int a = 3; /* Block B3 */
cout << a << b ; }
{ int b = 4; /* Block B4 */
cout << a << b ; }
cout << a << b ; }
cout << a << b; }
BTL-3 Applying
3
i.What advantages are there to a language-processing system in which the
compiler produces assembly language rather than machine language? ( 7 )
ii. Describe the types of errors occurring in different phases of compiler? ( 8 )
BTL-4 Analyzing
4 Explain in detail the issues in the design of compilers. BTL-4 Analyzing
UNIT II - LEXICAL ANALYSIS
Need and Role of Lexical Analyzer-Lexical Errors-Expressing Tokens by Regular Expressions-Converting Regular
Expression to DFA- Minimization of DFA-Language for Specifying Lexical Analyzers-LEX-Design of Lexical Analyzer
for a sample Language.
PART-A
Q.No Question BTL Competence
1 What is the role of lexical analyser? BTL-1 Remembering
2 Define Lexeme BTL-2 Remembering
3 Write a regular definition to represent date in the following format : JAN-5th
2014. BTL-3 Applying
4 Write regular expression to describe a language consists of strings made of
even numbers a and b. BTL-3 Applying
5 Why is buffering used in lexical analysis? What are the commonly used
buffering methods? BTL-1 Remembering
6 What are the various parts in LEX program? BTL-1 Understanding
7 Differentiate NFA and DFA. BTL-4 Analysing
8
Write regular expression for the following language
(i) set of statements over {a,b,c} that contain no two consecutive b's
(ii) set of statements over {a,b,c} that contain an even no. of a's
BTL-1 Remembering
9 Write a grammar for branching statements. BTL-1 Remembering
10 Write regular expression for number and identifier. BTL-3 Applying
11 Give the transition diagram for an identifier. BTL-1 Remembering
12 List the operations on languages. BTL-2 Understanding
13 Construct NFA for the regular expression ( a a * ) / ( b b * ). BTL-6 Creating
14 How can NFA be generated from regular expression. BTL-4 Analysing
15 Write short notes on LEX. BTL-5 Evaluating
16 List the various error recovery strategies for a lexical analysis. BTL-5 Evaluating
17 Mention the various notational shorthands for representing regular
expressions. BTL-6 Creating
18 Define kleene closure and positive closure. BTL-4 Analysing
19 Describe the language denoted by the regular expression:
(i) ( 0 / 1 ) * 0 ( 0 / 1 ) ( 0 / 1 ) (ii) 0 ( 0 / 1 ) * 0 BTL-2 Understanding
20 What are the models of LEX compiler? BTL-2 Understanding
PART-B
1 Prove that the following two regular expressions are equivalent by showing
that the minimum state DFA's are same : (i) ( a / b ) * (ii) ( a * / b * ) * BTL-5 Evaluating
2 Describe the error recovery schemes in the lexical phase of a compiler. BTL-2 Understanding
3 (i)Explain a language for specifying the lexical analyzer. (7)
(ii)Explain specification and recognition of tokens. (6) BTL-1 Remembering
4
(i)Draw the DFA for the augmented regular expression directly using syntax
tree ( a / b ) * a b b ( a / b ) * #. (9)
(ii)Discuss input buffering in detail. (4)
BTL-6 Creating
5
(i)Explain in detail about the Lexical analyzer with the possible error
recovery actions. (7)
(ii)Elaborate specification of tokens. (6)
BTL-1 Remembering
6 Compare NFA and DFA. Construct a DFA directly from an augmented
regular expression ( ( ε / a ) b * ) * BTL-4 Analyzing
7
(i)What are the issues in Lexical analysis. (3)
(ii)Differentiate between lexeme, token and pattern. (4)
(iii)Draw the transition diagram for relational operators and unsigned
numbers. (6)
BTL-3 Applying
8
(i)Explain briefly about input buffering in reading the source program for
finding the tokens. (6)
(ii)Construct the minimized DFA for the regular expression: (7)
( 0 + 1 ) * ( 0 + 1 ) 1 0
BTL-1 Remembering
9 Construct DFA from an augmented regular expression
( a / b ) * a ( a / b ) ( a / b ). Write down the algorithm wherever necessary. BTL-3 Applying
10
For the regular expression ( a / b ) * a b b ( a / b ) * draw the DFA from
NFA. Minimize DFA using Πnew construction. Write down the algorithm
wherever necessary
BTL-4 Analyzing
11 (i)Describe in detail the tool for generating lexical analyzer. (7)
(ii)Draw NFA for the regular expression a b * / a b. (6) BTL-2 Understanding
12 Convert the Regular Expression a b b ( a / b ) * to DFA using direct method
and minimize it. BTL-2 Understanding
13 (i)Conversion of regular expression ( a / b ) * a b b to NFA. (7)
(ii)Write an algorithm for minimizing the number of states of a DFA. ( 6 ) BTL-1 Remembering
14
(i)Write notes on regular expression to NFA. Construct Regular expression
to NFA for the sentence ( a | b ) * a b. (5)
(ii)Construct DFA to recognize the language ( a / b ) * a b. ( 8 )
BTL-4 Analyzing
PART - C
1
i.Discuss the role of lexical analyzer in detail with necessary examples. ( 8 )
ii.Discuss how finite automata is used to represent tokens and perform
lexical analysis with examples. (7)
BTL-2 Understanding
2 Explain in detail the Lexical-Analyzer Generator Lex with Lex program structure
and example Lex program BTL-4 Analyzing
3
Write the algorithm for converting a Regular Expression directly to a DFA and also
explain the computation of four functions involved and construction of syntax tree
and Dtrans BTL-1 Remembering
4 Write the algorithm for conversion of Regular Expression to NFA, NFA to DFA
and minimization of DFA BTL-1 Remembering
UNIT III - SYNTAX ANALYSIS
Need and Role of the Parser-Context Free Grammars -Top Down Parsing -General Strategies-Recursive Descent Parser
Predictive Parser-LL(1) Parser-Shift Reduce Parser-LR Parser-LR (0)Item-Construction of SLR Parsing Table -
Introduction to LALR Parser - Error Handling and Recovery in Syntax Analyzer-YACC-Design of a syntax Analyzer for a
Sample Language
PART-A
Q.No Question BTL Competence
1 What is the role of a parser? BTL-1 Remembering
2 Write a CF grammar to represent palindrome. BTL-2 Understanding
3
Eliminate the left recursion for the grammar
S → A a | b
A → A c | S d |ϵ
BTL-4 Analyzing
4 Eliminate the left recursion from the following grammar
A → A c | A a d | b d | ϵ BTL-4 Analyzing
5 What are the various conflicts that occur during Shift Reduce parsing. BTL-5 Evaluating
6 Write the rule to eliminate the left recursion in a grammar. BTL-2 Understanding
7 Define an ambiguous grammar. BTL-1 Remembering
8 Construct a parse tree for - ( id + id ). BTL-1 Remembering
9 Define handle pruning. BTL-1 Remembering
10 Construct a parse tree of ( a + b ) * c for the grammar
E→E + E | E * E | ( E ) | id. BTL-2 Understanding
11 Eliminate immediate left recursion from the following grammar
E → E + T | T , T→ T * F | F , F → ( E ) | id. BTL-5 Evaluating
12 What is LR parser? BTL-1 Remembering
13 How LR parser is different from SLR? BTL-3 Applying
14 How error recovery is done in LR parsing? BTL-4 Analysing
15 Write algorithm to compute FIRST of a non-terminal. BTL-6 Creating
16 Write algorithm to compute FOLLOW of a non-terminal. BTL-6 Creating
17 How parsing techniques are classified? BTL-3 Applying
18 Define regular grammar. BTL-1 Remembering
19 Define context free grammar. BTL-2 Understanding
20 How YACC handles different types of conflicts in parser? BTL-3 Applying
PART-B
1
Generate SLR parsing table for the following grammar
S → Aa | bAc | Bc | bBa
A → d
B → d
And parse the sentence "bdc" and "dd"
BTL-1 Remembering
2
(i)Write down the algorithm to eliminate left-recursion and left-factoring and
apply both to the following grammar. (6)
E → E + T | E - T | T
T → a | b | ( E )
(ii)Construct predictive parsing table for the above grammar and parse
(a+b)-a (7)
BTL-6 Creating
3
Find the LALR for the given grammar and parse the sentence ( a + b ) * c
E → E + T | T ,
T → T * F | F , F → ( E ) / id.
BTL-5 Evaluating
4
Consider the following grammar
S → AS | b
A → SA | a
Construct the SLR parse table for the grammar. Show the actions of the
parser for the input string "abab"
BTL-3 Applying
5 What is an ambiguous grammar? Is the following grammar ambiguous?
Prove. E → E + E | E * E | ( E ) | id BTL-3 Applying
6
Design an LALR parser for the following grammar and parse the input
id = id.
S → L = R | R
L → * R | id
R → L
BTL-2 Understanding
7
Construct a predictive parser for the following grammar
S → ( L ) | a
L → L,S | S
and show whether the following string will be accepted or not.
( a , ( a , ( a , a ) ) )
BTL-1 Remembering
8
(i)Construct a non recursive predictive parsing table for the following
grammar : E → E or E | E and E | not E | ( E ) | 0 | 1 (9)
(ii)Construct parse tree for the input string w = c a d using top down parser.
S -> c A d , A -> a b | a. (4)
BTL-1 Remembering
9
Construct SLR parsing table for the following grammar
E → E + T | T
T → T F | F
F → F * | a | b
BTL-4 Analyzing
10
Construct a canonical parsing table for the grammar given below. Also
explain the algorithm used.
E → E + T
E → T
T → T * F
T → F
F → ( E )
F → id.
BTL-4 Analyzing
11
(i)Construct Stack implementation of shift reduce parsing for the grammar
E → E + E | E * E | ( E ) | id and the input string is id1 + id2 * id3 (6)
(ii)Explain LL(1) grammar for the sentence : (7)
S -> iEts | iEtSeS | a, E -> b.
BTL-2 Understanding
12 Explain LR parsing algorithm with an example BTL-2 Understanding
13
Construct parsing table for the grammar and find moves made by predictive
parser on input id + id * id and find FIRST and FOLLOW.
E -> E + T
E -> T
T -> T * F
T -> F
F -> ( E ) / id
BTL-4 Analyzing
14
(i)Explain ambiguous grammar G : E -> E + E | E * E | ( E ) | - E | id for the
sentence : id + id * id (5)
(ii)Construct SLR parsing table for the following grammar G :
E -> E + T | T , T -> T * F | F , F -> ( E ) | id. (8)
BTL-1 Remembering
PART - C
1 i.Write an algorithm for Non recursive predictive parsing. ( 8 )
ii.Explain Context free grammar with examples. ( 7 ) BTL-2 Understanding
2 State how to resolve the parsing action conflicts in Shift Reduce parser with an
example BTL-1 Remembering
3
i.List all LR(0) items for the following grammar ( 8 )
S → AS | b
A → SA | a
ii.Write the algorithm for FIRST and FOLLOW computation. ( 7 )
BTL-3 Applying
4 Explain in detail the Parser Generator YACC and YACC specification of a simple
desk calculator BTL-1 Remembering
UNIT IV - SYNTAX DIRECTED TRANSLATION & RUN TIME ENVIRONMENT
Syntax directed Definitions-Construction of Syntax Tree-Bottom-up Evaluation of S-Attribute Definitions- Design of
predictive translator - Type Systems-Specification of a simple type checker-Equivalence of Type Expressions-Type
Conversions
PART-A
Q.No Question BTL Competence
1 Construct a parse tree according to the syntax directed definition, for the following
input statement : (4 + 7.5 * 3) / 2 BTL-6 Creating
2 Write the 3-address code for : x = *y; a = &x. BTL-1 Remembering
3 Place the above generated 3-address code for x = *y; a = &x , in Triplets and
indirect Triplets BTL-2 Understanding
4 List out the various storage allocation strategies BTL-1 Remembering
5 What are the types of intermediate languages? BTL-1 Remembering
6 Compare syntax tree and parse tree. BTL-3 Applying
7 What is the significance of intermediate code? BTL-1 Remembering
8 When does Dangling references occur ? BTL-4 Analysing
9 What is DAG? BTL-5 Evaluating
10 Translate the arithmetic expression a * - ( b + c ) into syntax tree and postfix
notation. BTL-2 Understanding
11 What do you mean by binding of names? BTL-6 Creating
12 Give examples for static check. BTL-1 Remembering
13 List Dynamic Storage allocation techniques. BTL-5 Evaluating
14 Mention the role of semantic analysis. BTL-1 Remembering
15 Draw syntax tree for the expression a = b * -c + b * -c BTL-3 Applying
16 Write down syntax directed definition of a simple desk calculator. BTL-2 Understanding
17 List out the motivations for backpatching. BTL-3 Applying
18 What are the types of three address statements? BTL-4 Analysing
19 Mention the two rules for type checking. BTL-4 Analysing
20 What are the limitations of static allocation? BTL-2 Understanding
PART-B
1
(i)Give a syntax-directed definition to differentiate expressions formed by
applying the arithmetic operators + and * to the variable x and constants ;
expression : x * ( 3 * x + x * x ). (7)
(ii)How names can be looked up in the symbol table? Discuss. (6)
BTL-1 Remembering
2
For the given program fragment A[i,j] = B[i,k] do the following :
(i)Draw the annotated parse tree with the translation scheme to convert to
three address code. (5)
(ii)Write the 3-address code. (5)
(iii) Determine the address of A[3,5] where all are integer arrays with size of
A as 10 x 10 and B as 10 x 10 with k=2 and the start index position of all
arrays is at 1. ( Assume the base addresses ) (3)
BTL-3 Applying
3
Generate intermediate code for the following code segment along with the
required syntax directed translation scheme.
while ( i < 10 )
if ( i % 2 == 0 )
evensum = evensum + i
else
oddsum = oddsum + i
BTL-6 Creating
4
Generate intermediate code for the following code segment along with the
required syntax directed translation scheme.
s = s + a[i][j];
BTL-1 Remembering
5
How would you convert the following into intermediate code? Give suitable
example
(i)Assignment statements and use the scheme for generating three address
code for g := a + b - c * d. (7)
(ii)Case statements. (6)
BTL-1 Remembering
6 (i)Explain the sequence of stack allocation processes for a function call. (7)
(ii)Explain about various parameter passing methods in procedure calls. (6) BTL-4 Analyzing
7
(i)Write the translation scheme for flow of control statement. (7)
(ii)Explain and compare in detail the various implementation forms of three
address code. (6)
BTL-5 Evaluating
8
(i)Write the grammar and translation scheme for procedure call
statements.(7)
(ii)Discuss runtime storage management in detail. (6)
BTL-1 Remembering
9
(i)Specify a type checker which can handle expressions, statements and
functions. (7)
(ii)Write down the translation scheme to generate three address for the
assignment statements. (6)
BTL-2 Understanding
10
(i)Translate the following switch statement into intermediate code. (7)
switch E
begin
case V1 : S1
case V2 : S2
case Vn-1 : Sn-1
default : Sn
end
(ii)Generate three address code for the boolean expression. (6)
a < b or c < d and e < f
BTL-3 Applying
11
(i)A Syntax-Directed Translation scheme that takes strings of a's, b's and c's
as input and produces as output the number of substrings in the input string
that correspond to the pattern a ( a | b ) * c + ( a | b ) * b. For example the
translation of the input string " a b b c a b c a b a b c " is " 3 ". (7)
(1) Write a context-free grammar that generates all strings of a's,
b's and c's
(2) Give the semantic attributes for the grammar symbols
(3) For each production of the grammar present a set of rules for
evaluation of the semantic attributes
(ii)Illustrate type checking with necessary diagram. (6)
BTL-4 Analyzing
12
Explain the following with respect to code generation phase.
(i) Input to code generator, (ii) Target program, (iii) Memory management,
(iv) Instruction Selection, (v) register allocation (vi) Evaluation Order
BTL-2 Understanding
13
(i)Construct a syntax directed definition for constructing a syntax tree for
assignment statements. (7)
S -> id := E , E -> E1 + E2 , E -> E1 * E2 , E -> -E1, E -> ( E1 ) , E -> id
(ii)Discuss specification of a simple type checker. (6)
BTL-4 Analyzing
14 Discuss different storage allocation strategies BTL-2 Understanding
PART - C
1
Translate the executable statements of the following C program into three address
code
main( )
{
BTL-6 Creating
int i, a[10];
i = 1;
while ( i <= 10 )
{
a[i] = 0;
i = i + 1;
}
}
2 Generate annotated parse tree for the expression c + a[i][j] and also generate three
address instruction BTL-2 Understanding
3 State the rules for type checking and explain type conversions BTL-5 Evaluating
4 Compare and contrast Quadruples, triples and indirect triples. Give examples BTL-4 Analyzing
UNIT V - CODE OPTIMIZATION AND CODE GENERATION
Principal Sources of Optimization-DAG- Optimization of Basic Blocks-Global Data Flow Analysis-Efficient Data Flow
Algorithms-Issues in Design of a Code Generator - A Simple Code Generator Algorithm.
PART-A
Q.No Question BTL Competence
1 How is Liveness of a variable calculated? BTL-1 Remembering
2 Generate code for the following C statement assuming three registers are
available : x = a / ( b + c ) - d * ( e + f ). BTL-6 Creating
3 Write the algorithm that orders the DAG nodes for generating optimal target
code. BTL-1 Remembering
4 Differentiate between basic block and flow graph. BTL-3 Remembering
5 Draw DAG to represent a[i] = b[i]; a[i] = & t BTL-3 Applying
6 Represent the following in flow graph: i = 1; sum = 0;
while ( i <= 10 ) { sum += i; i++; } BTL-6 Creating
7 What is global data flow analysis? BTL-1 Remembering
8 Name the techniques in loop optimization. BTL-3 Applying
9 Explain why code optimization is called optional phase. BTL-5 Evaluating
10 Draw DAG for the statement a= ( a * b + c ) – ( a * b + c ) BTL-1 Applying
11 Define basic blocks. BTL-1 Remembering
12 Give any four applications of DAG. BTL-2 Understanding
13 What are the properties of optimizing compilers? BTL-4 Analysing
14 What is constant folding? BTL-4 Analysing
15 List the advantages of DAG. BTL-2 Understanding
16 Identify the constructs for optimization in basic block. BTL-4 Analysing
17 What do you mean by copy propagation? BTL-1 Remembering
18 What are the characteristics of peephole optimization? BTL-2 Understanding
19 Write three address code sequence for the assignment statement :
d := ( a - b ) + ( a - c ) + ( a - c ) BTL-5 Evaluating
20 List out the criteria for code improving transformations. BTL-2 Understanding
PART-B
1
(i)Write the Code Generation Algorithm using Dynamic Programming and
generate code for the statement x = a / ( b - c ) - g * ( e + f ). [ Assume all
instructions to be unit cost ] (10)
(ii)What are the advantages of DAG representation ? Give example. (3)
BTL-1 Remembering
2
(i)Write the procedure to perform Register Allocation and Assignment with
Graph Coloring. (7)
(ii)Construct DAG and optimal target code for the expression (6)
x = ( ( a + b ) / ( b - c ) ) - ( a + b ) * ( b - c ) + / .
BTL-3 Applying
3
Perform analysis of available expressions on the following code by
converting into basic blocks and compute global common sub expression
elimination
(i) i : = 0 (ii) a : = n - 3 (iii) IF i < a THEN loop ELSE end
(iv) LABEL loop (v) b : = I - 4 (vi) c : = p + b (vii) d : - M[c]
(viii) e : = d - 2 (ix) f : = i – 4 (x) g : = p + f (xi) M[g] : = e
(xii) i : - i + 1 (xiii) a : = n – 3 (xiv) IF i < a THEN loop ELSE end
(xv) LABEL end
BTL-4 Analysing
4
(i)Explain in detail about optimization of Basic Blocks. (7)
(ii)What are the optimization techniques applied on procedure calls? Explain
with example. (6)
BTL-1 Remembering
5
(i)Generate DAG representation of the following code and list out the
applications of DAG representation. (7)
i = 1 :
while ( i <= 10 ) do
sum += a[i];
(ii)Explain - Generating code from DAG with suitable example. (6)
BTL-6 Creating
6 Explain peephole optimization and various code improving transformations. BTL-2 Understanding
7 Define a DAG. Construct a DAG and write the sequence of instructions for
the expression : a + a * ( b - c ) + ( b - c ) * d BTL-1 Remembering
8
(i)Draw the DAG for the following three address code. (7)
d = b * c
e = a + b
b = b * c
a = e - d
(ii)Write short notes on structure preserving transformation of basic
blocks.(6)
BTL-5 Evaluating
9
Construct DAG and three address code for the following C program
i = 1;
s = 0;
while ( i <= 10 )
{
s = s + a [i][i]
i = i + 1;
}
BTL-1 Remembering
10 Explain global data flow analysis with necessary equations BTL-2 Understanding
11
For the flow graph shown below, write the three address statements and
construct the DAG.
(1) t1 : = 4 * i (2) t2 : = a[ t1] (3) t3 := 4 * i (4) t4 := b[t3]
(5) t5 := t2 * t4 (6) t6 := prod + t5 (7) prod := t6 (8) t7 := i + 1
(9) i : = t7 (10) if i <= 20 goto (1)
BTL-6 Creating
12 Explain Principal Sources of Optimization with examples BTL-2 Understanding
13 Explain various issues in the design of code generator. BTL-4 Analyzing
14 (i)Write an algorithm for constructing natural loop of a back edge. (7)
(ii)Write note on simple code generator (6) BTL-1 Remembering
PART - C
1 Explain the data-flow analysis of structured programs. BTL-4 Analyzing
2 Explain any four issues that crop up when designing a code generator BTL-4 Analyzing
3 Generate code for the following assignment using the code generator:
( a – b ) + ( a – c ) + ( a – c ) BTL-2 Understanding
4 Write global common subexpression elimination algorithm with example BTL-1 Remembering
Verified by : 1. 2.
[ ] [ ]
3. 4.
[ ] [ ]
Forwarded by Year Coordinator :
Approved by HOD :