Compiler Design
106501Module 4 : Intermediate Code Generation & Code Improvement
Q1b. Choose the correct answer of the following: Quadruple is a record structure of (i) three fields (ii) four fields (iii) one field (iv) none of these20232m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Choose the correct answer of the following:
Quadruple is a record structure of
(i) three fields
(ii) four fields
(iii) one field
(iv) none of theseQ1f. Choose the correct answer of the following: Right side of three-address code has how many numbers of operator at most? (i) 1 (ii) 2 (iii) 4 (iv) 320222m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Choose the correct answer of the following:
Right side of three-address code has how many numbers of operator at most?
(i) 1
(ii) 2
(iii) 4
(iv) 3Q1g. Choose the correct option / answer the following: Which of the following phase of the compiler is optional? (i) Syntax Analysis (ii) Intermediate Code Generation (iii) Semantic Analysis (iv) Code Optimization20242m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Choose the correct option / answer the following:
Which of the following phase of the compiler is optional?
(i) Syntax Analysis
(ii) Intermediate Code Generation
(iii) Semantic Analysis
(iv) Code OptimizationQ1h. Choose the correct answer of the following: In compilers, generation of intermediate code based on an abstract machine model is useful because (i) syntax-directed translations can be written for intermediate code generation (ii) to generate code for real machines directly from high-level language program is not possible (iii) portability of the front end of the compiler is enhanced (iv) implementation of lexical and syntax analyses is easier20192m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Choose the correct answer of the following:
In compilers, generation of intermediate code based on an abstract machine model is useful because
(i) syntax-directed translations can be written for intermediate code generation
(ii) to generate code for real machines directly from high-level language program is not possible
(iii) portability of the front end of the compiler is enhanced
(iv) implementation of lexical and syntax analyses is easierQ1i. Choose the correct option / answer the following: Which optimization technique focuses on reducing code in small sequences? (i) Peephole optimization (ii) Strength reduction (iii) Loop optimization (iv) Code hoisting20242m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Choose the correct option / answer the following:
Which optimization technique focuses on reducing code in small sequences?
(i) Peephole optimization
(ii) Strength reduction
(iii) Loop optimization
(iv) Code hoistingQ1i. Which optimization removes repeated computations? (i) Dead code elimination (ii) Common sub-expression elimination (iii) Loop optimization (iv) Register allocation20252m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Which optimization removes repeated computations?
(i) Dead code elimination
(ii) Common sub-expression elimination
(iii) Loop optimization
(iv) Register allocationQ1j. Choose the correct answer of the following: The method which merges the bodies of two loops is (i) loop rolling (ii) loop jamming (iii) constant folding (iv) None of the above20192m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Choose the correct answer of the following:
The method which merges the bodies of two loops is
(i) loop rolling
(ii) loop jamming
(iii) constant folding
(iv) None of the aboveQ1j. Choose the correct answer of the following: By which of the following, bodies of two loops merges to form a single loop? (i) Loop Unrolling (ii) Strength Reduction (iii) Loop Concatenation (iv) Loop Fusion20232m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Choose the correct answer of the following:
By which of the following, bodies of two loops merges to form a single loop?
(i) Loop Unrolling
(ii) Strength Reduction
(iii) Loop Concatenation
(iv) Loop FusionQ1j. A three-address code uses (i) One operand (ii) Two operands (iii) Three operands (iv) No operands20252m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →A three-address code uses
(i) One operand
(ii) Two operands
(iii) Three operands
(iv) No operandsQ3b. Construct the DAG for the following basic block: d = b * c e = a + b b = b * c a = e - d20233m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Construct the DAG for the following basic block:
Q3c. Discuss peephole optimization with suitable example.20234m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Discuss peephole optimization with suitable example.
Q4c. Translate the following expression into quadruples and triples representation. A = -b * (c + d)/e20234m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Translate the following expression into quadruples and triples representation.
Q5a. Find the three-address codes of the following program. There are four bytes per word: ``c Sum = 0; for (i = 1; i<=20; i++) Sum = Sum + a[i] + b[i]; ``20227m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Find the three-address codes of the following program. There are four bytes per word:
Sum = 0; for (i = 1; i<=20; i++) Sum = Sum + a[i] + b[i];Q5a. Write down Three Address Code for the following expression: (a \times b) + (c + d) - (a + b + c + d)20257m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Write down Three Address Code for the following expression:
Q5b. Explain peephole optimization with examples and its benefits.20257m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Explain peephole optimization with examples and its benefits.
Q6b. Explain how type checking and error reporting are performed in compiler. Draw syntax tree and DAG for the statement: a = (a * b + c) \wedge (b + c) * b + c20197m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Explain how type checking and error reporting are performed in compiler. Draw syntax tree and DAG for the statement:
Q7a. Explain various targets for code optimization with examples.20197m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Explain various targets for code optimization with examples.
Q7a. Translate the arithmetic expression a + - (b + c) into: (a) Syntax tree (b) Quadruples (c) Triples (d) Indirect Triples20227m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Translate the arithmetic expression into:
(a) Syntax tree
(b) Quadruples
(c) Triples
(d) Indirect TriplesQ7a. Write down the process for identifying basic blocks.20233m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Write down the process for identifying basic blocks.
Q7b. How are CPU registers allocated while creating machine code?20197m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →How are CPU registers allocated while creating machine code?
Q7b. Consider the following code: (i) i = 12 (ii) j = 1 (iii) t1 = 10 * i (iv) t2 = t1 + j (v) t3 = 8 * t2 (vi) t4 = t3 - 88 (vii) a [ t4 ] = 0.0 (viii) j = j + 1 (ix) if j <= 10 goto (iii) (x) i = i + 1 (xi) if i <= 10 goto (ii) (xii) i = 1 (xiii) t5 = i - 1 (xiv) t6 = 88 * t5 (xv) a [ t6 ] = 1.0 (xvi) i = i + 1 (xvii) if i <= 10 goto (xiii) find out the basic block and draw the flow graph for the above code.20238m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Consider the following code:
(i)i = 12
(ii)j = 1
(iii)t1 = 10 * i
(iv)t2 = t1 + j
(v)t3 = 8 * t2
(vi)t4 = t3 - 88
(vii)a [ t4 ] = 0.0
(viii)j = j + 1
(ix)if j <= 10 goto (iii)
(x)i = i + 1
(xi)if i <= 10 goto (ii)
(xii)i = 1
(xiii)t5 = i - 1
(xiv)t6 = 88 * t5
(xv)a [ t6 ] = 1.0
(xvi)i = i + 1
(xvii)if i <= 10 goto (xiii)find out the basic block and draw the flow graph for the above code.
Q7b. Explain the process of translating an arithmetic expression into intermediate code using three-address code (TAC). Translate the expression a * -b + (c - d) * e into TAC and show the corresponding syntax tree and code.20247m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Explain the process of translating an arithmetic expression into intermediate code using three-address code (TAC). Translate the expression into TAC and show the corresponding syntax tree and code.
Q8a. Discuss *code motion* and *copy propagation* as machine - independent code optimization techniques.20227m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Discuss code motion and copy propagation as machine - independent code optimization techniques.
Q8a. Discuss the different types of code optimization techniques in compilers.20247m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Discuss the different types of code optimization techniques in compilers.
Q8a. Explain local and global optimization techniques.20257m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Explain local and global optimization techniques.
Q8b. What is basic block in the graph representation of intermediate codes. Construct DAG for the basic block given below. Also optimize the three address code, assuming only a is live on exit from the block. d = b * c e = a + b b = b * c a = e - d20227m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →What is basic block in the graph representation of intermediate codes. Construct DAG for the basic block given below. Also optimize the three address code, assuming only is live on exit from the block.
Q8b. Explain how instruction scheduling helps in pipeline optimization. Discuss how rearranging instructions improves performance and reduces stalls in pipelined architectures. Illustrate with an example.20247m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Explain how instruction scheduling helps in pipeline optimization. Discuss how rearranging instructions improves performance and reduces stalls in pipelined architectures. Illustrate with an example.
Q8c. Explain three of the targets for code optimization with examples.20234m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Explain three of the targets for code optimization with examples.
Q9a. What is register allocation in code generation? Explain the role of graph coloring in register allocation and describe how it improves the efficiency of target code.20247m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →What is register allocation in code generation? Explain the role of graph coloring in register allocation and describe how it improves the efficiency of target code.
Q9b. Explain any two of the following : (i) Lexical phase error (ii) Code generation using dynamic programming (iii) Syntax tree20197m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Explain any two of the following :
(i) Lexical phase error
(ii) Code generation using dynamic programming
(iii) Syntax treeQ9d. Write short notes on: Peephole optimization20227m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Write short notes on: Peephole optimization