Cia 2

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

8115 - K.

RAMAKRISHNAN COLLEGE OF ENGINEERING


(AUTONOMOUS)
Department of Computer Science and Engineering
UCS1602 - COMPILER DESIGN
CONTINUOUS INTERNAL ASSESSMENT- II

DATE: 25.04.24 MAX MARKS: 100


DEPT/YEAR / SEM :CSE/ III / VI TIME:9.45 am–12.45 pm
Knowledge K1 - Remember K3 - Apply K5 - Evaluate
Levels (KL) K2 - Understand K4 - Analyze K6 - Create
Answer ALL questions
PART A – (10 x 2 = 20 Marks)
Q.No Questions KL CO
1 Why are quadruples preferred over triples in an optimizing compiler? K1 CO3
2 Translate the expression a*-(b+c) into syntax tree and postfix notation? K1 CO3
3 Write three-address code sequence for the assignment statement. K1 CO3
d:=(a-b)+(a-c)+(a-c)
4 Write the syntax directed definition for if – else statement. K1 CO3

5 Why do we need of back patching? K1 CO3

6 Define peephole optimization technique. K1 CO4


List out the transformation techniques that can be used applied code K1 CO4
7
optimization.
8 Represent the following in flow graph K2 CO4
i=1,sum =0 ;
while(i<=0)
{
Sum+=i;
i++
}
9 What are the properties of optimizing compilers? K1 CO4
10 How would you represent the dummy blocks with no statements indicated in K1 CO4
global data flow analysis?
PART B – (5 x 16 = 80 Marks)

Q.No Questions Marks KL CO

11.(a) (i) Describe the various methods of implementing the three 8 K2 CO3
address statements with an example?
(ii) Write down the translation scheme to generate code for 8 K1 CO3
assignment statements. Use the scheme for generating three
address code for the assignment statements
x:=(a+b)*(c*d).Also draw its annotated parse tree for the
assignment statements.
(OR)
11.(b) (i) Generate intermediate code for the following code segment 16 K3 CO3
along with the required syntax directed translation scheme.
int main()
{
int a, b, c;
printf("Enter the numbers A, B and C: ");
scanf("%d %d %d", &a &b, &c);
// finding max using compound expressions
if (a >= b && a >= c)
printf("%d is the largest number.", a);
else if (b >= a && b >= c)
printf("%d is the largest number.", b);
else
printf("%d is the largest number.", c);
return 0;
}

12.(a) (i) Explain in detail about concepts of back patching using flow 16 K2 CO3
control statements. Also generate three address code and
syntax tree for the given expression a < b or c < d and e < f.
(OR)
12.(b) (i) Discuss the various methods for translating Boolean 16 K2 CO3
expression
13.(a) (i) Describe the principle sources of optimization with relevant 16 K2 CO4
examples.
(OR)
13.(b) (i) Explain peephole optimization and various code improving 16 K2 CO4
transformations.
14.(a) (i) Construct DAG representation of the following code and list 8 K3 CO4
out the applications of DAG representation:
I=1,s=0
While(i<10)
S=s+a[i][i]
i=i+1
(ii) Elaborate loops in flow graph with example. 8 K2 CO4
(OR)
14.(b) (i) Explain in detail about data flow analysis of flow graphs 16 K2 CO4
with relevant example.

15.(a) (i) Construct the flow graph and apply the possible 16 K3 CO4
optimizations for the following program segment.
sum := 0
i := 1
do
sum := prod + a[i] * b[i]
i := i+1
while i <= 20
(OR)
15.(b) (i) Explain in detail about how loops are represented in flow 16 K3 CO2
graph with relevant example.

You might also like