Question 1 |
In the context of compilers, which of the following is/are NOT an intermediate representation of the source program?
Three address code | |
Abstract Syntax Tree (AST) | |
Control Flow Graph (CFG) | |
Symbol table |
Question 1 Explanation:
Question 2 |
Which of the following is a type of a out-of-order execution, with the reordering done by a compiler
loop unrolling | |
dead code elimination | |
strength reduction | |
software pipelining |
Question 2 Explanation:
Question 3 |
Consider the productions A\rightarrow PQ and A\rightarrow XY. Each of the five non-terminals A,P,Q,X, and Y has two attributes: s is a synthesized attribute, and i is an inherited attribute. Consider the following rules.
Rule 1: P.i=A.i+2, Q.i=P.i+A.i, and A.s=P.s+Q.s
Rule 2: X.i=A.i+Y.s and Y.i=X.s+A.i
Which one of the following is TRUE?
Rule 1: P.i=A.i+2, Q.i=P.i+A.i, and A.s=P.s+Q.s
Rule 2: X.i=A.i+Y.s and Y.i=X.s+A.i
Which one of the following is TRUE?
Both Rule 1 and Rule 2 are L-attributed. | |
Only Rule 1 is L-attributed. | |
Only Rule 2 is L-attributed. | |
Neither Rule 1 nor Rule 2 is L-attributed. |
Question 3 Explanation:
Question 4 |
Which of the following comment about peep-hole optimization is true?
It is applied to small part of the code and applied repeatedly | |
It can be used to optimize intermediate code | |
It can be applied to a portion of the code that is not contiguous | |
It is applied in symbol table to optimize the memory requirements. |
Question 4 Explanation:
Question 5 |
Consider the expression ( a-1)* (((b + c) / 3) + d)) . Let X be the minimum number of
registers required by an optimal code generation (without any register spill) algorithm for a
load/store architecture in which (i) only loads and store instructions can have memory
operands and (ii) arithmetic instructions can have only register or immediate operands. The
value of X is _________.
2 | |
3 | |
4 | |
5 |
Question 5 Explanation:
Question 6 |
Consider the following intermediate program in three address code
p= a -b
q= p *c
p= u * v
q= p + q
Which one of the following corresponds to a static single assignment form of the above code?
p= a -b
q= p *c
p= u * v
q= p + q
Which one of the following corresponds to a static single assignment form of the above code?
p_{1}=a-b q_{1}=p_{1}*c p_{1}=u*v q_{1}=p_{1}+q_{1} | |
p_{3}=a-b q_{4}=p_{3}*c p_{4}=u*v q_{3}=p_{4}+q_{4} | |
p_{1}=a-b q_{1}=p_{2}*c p_{3}=u*v q_{2}=p_{4}+q_{3} | |
p_{1}=a-b q_{1}=p_{1}*c p_{2}=u*v q_{2}=p+q |
Question 6 Explanation:
Question 7 |
Peephole optimization is form of
Loop optimization | |
Local optimization | |
Constant folding | |
Data flow analysis |
Question 7 Explanation:
Question 8 |
Consider the following code segment.
x =u-t;
y =x*v;
x =y+w;
y =t-z;
y =x*y;
The minimum number of total variables required to convert the above code segment to static single assignment form is__________ .
x =u-t;
y =x*v;
x =y+w;
y =t-z;
y =x*y;
The minimum number of total variables required to convert the above code segment to static single assignment form is__________ .
8 | |
9 | |
10 | |
11 |
Question 8 Explanation:
Question 9 |
Consider the intermediate code given below.
(1) i = 1
(2) j = 1
(3) t1 = 5 * i
(4) t2 = t1 + j
(5) t3 = 4 * t2
(6) t4 = t3
(7) a[t4] = -1
(8) j = j + 1
(9) if j\leq 5 goto (3)
(10) i=i+1
(11) if i\lt 5 goto (2)
The number of nodes and edges in the control-flow-graph constructed for the above code, respectively, are
(1) i = 1
(2) j = 1
(3) t1 = 5 * i
(4) t2 = t1 + j
(5) t3 = 4 * t2
(6) t4 = t3
(7) a[t4] = -1
(8) j = j + 1
(9) if j\leq 5 goto (3)
(10) i=i+1
(11) if i\lt 5 goto (2)
The number of nodes and edges in the control-flow-graph constructed for the above code, respectively, are
5 and 7 | |
6 and 7 | |
5 and 5 | |
7 and 8 |
Question 9 Explanation:
Question 10 |
In the context of abstract-syntax-tree (AST) and control-flow-graph (CFG), which one of the following is TRUE?
In both AST and CFG, let node N2 be the successor of node N1. In the input program, the code corresponding to N2 is present after the code corresponding to N1 | |
For any input program, neither AST nor CFG will contain a cycle | |
The maximum number of successors of a node in an AST and a CFG depends on the input program | |
Each node in AST and CFG corresponds to at most one statement in the input program |
Question 10 Explanation:
There are 10 questions to complete.
In Q.6 “q” should be “q=p+q” instead of “q=p-q”.
Please correct it.
BTW great work.