Compiler Design

106501
Back to Compiler Design

Module 4 : Intermediate Code Generation & Code Improvement

  1. 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

    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 these

    View this question on its own page →
  2. Q1f. 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

    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) 3

    View this question on its own page →
  3. Q1g. 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

    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 Optimization

    View this question on its own page →
  4. Q1h. 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

    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 easier

    View this question on its own page →
  5. Q1i. 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

    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 hoisting

    View this question on its own page →
  6. Q1i. 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

    Which optimization removes repeated computations?

    (i) Dead code elimination
    (ii) Common sub-expression elimination
    (iii) Loop optimization
    (iv) Register allocation

    View this question on its own page →
  7. Q1j. 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

    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 above

    View this question on its own page →
  8. Q1j. 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

    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 Fusion

    View this question on its own page →
  9. Q1j. A three-address code uses (i) One operand (ii) Two operands (iii) Three operands (iv) No operands20252m

    Module 4 : Intermediate Code Generation & Code Improvement

    A three-address code uses

    (i) One operand
    (ii) Two operands
    (iii) Three operands
    (iv) No operands

    View this question on its own page →
  10. Q3b. 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

    Construct the DAG for the following basic block:
    d=bcd = b * c
    e=a+be = a + b
    b=bcb = b * c
    a=eda = e - d

    View this question on its own page →
  11. Q3c. Discuss peephole optimization with suitable example.20234m

    Module 4 : Intermediate Code Generation & Code Improvement

    Discuss peephole optimization with suitable example.

    View this question on its own page →
  12. Q4c. Translate the following expression into quadruples and triples representation. A = -b * (c + d)/e20234m

    Module 4 : Intermediate Code Generation & Code Improvement

    Translate the following expression into quadruples and triples representation.
    A=b(c+d)/eA = -b * (c + d)/e

    View this question on its own page →
  13. 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

    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];
    
    View this question on its own page →
  14. 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

    Write down Three Address Code for the following expression:

    (a×b)+(c+d)(a+b+c+d)(a \times b) + (c + d) - (a + b + c + d)

    View this question on its own page →
  15. Q5b. Explain peephole optimization with examples and its benefits.20257m

    Module 4 : Intermediate Code Generation & Code Improvement

    Explain peephole optimization with examples and its benefits.

    View this question on its own page →
  16. 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

    Explain how type checking and error reporting are performed in compiler. Draw syntax tree and DAG for the statement:
    a=(ab+c)(b+c)b+ca = (a * b + c) \wedge (b + c) * b + c

    View this question on its own page →
  17. Q7a. Explain various targets for code optimization with examples.20197m

    Module 4 : Intermediate Code Generation & Code Improvement

    Explain various targets for code optimization with examples.

    View this question on its own page →
  18. 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

    Translate the arithmetic expression a+(b+c)a + - (b + c) into:
    (a) Syntax tree
    (b) Quadruples
    (c) Triples
    (d) Indirect Triples

    View this question on its own page →
  19. Q7a. Write down the process for identifying basic blocks.20233m

    Module 4 : Intermediate Code Generation & Code Improvement

    Write down the process for identifying basic blocks.

    View this question on its own page →
  20. Q7b. How are CPU registers allocated while creating machine code?20197m

    Module 4 : Intermediate Code Generation & Code Improvement

    How are CPU registers allocated while creating machine code?

    View this question on its own page →
  21. 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

    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.

    View this question on its own page →
  22. 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

    Explain the process of translating an arithmetic expression into intermediate code using three-address code (TAC). Translate the expression ab+(cd)ea * -b + (c - d) * e into TAC and show the corresponding syntax tree and code.

    View this question on its own page →
  23. Q8a. Discuss *code motion* and *copy propagation* as machine - independent code optimization techniques.20227m

    Module 4 : Intermediate Code Generation & Code Improvement

    Discuss code motion and copy propagation as machine - independent code optimization techniques.

    View this question on its own page →
  24. Q8a. Discuss the different types of code optimization techniques in compilers.20247m

    Module 4 : Intermediate Code Generation & Code Improvement

    Discuss the different types of code optimization techniques in compilers.

    View this question on its own page →
  25. Q8a. Explain local and global optimization techniques.20257m

    Module 4 : Intermediate Code Generation & Code Improvement

    Explain local and global optimization techniques.

    View this question on its own page →
  26. 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

    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 aa is live on exit from the block.
    d=bcd = b * c
    e=a+be = a + b
    b=bcb = b * c
    a=eda = e - d

    View this question on its own page →
  27. 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

    Explain how instruction scheduling helps in pipeline optimization. Discuss how rearranging instructions improves performance and reduces stalls in pipelined architectures. Illustrate with an example.

    View this question on its own page →
  28. Q8c. Explain three of the targets for code optimization with examples.20234m

    Module 4 : Intermediate Code Generation & Code Improvement

    Explain three of the targets for code optimization with examples.

    View this question on its own page →
  29. 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

    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.

    View this question on its own page →
  30. 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

    Explain any two of the following :
    (i) Lexical phase error
    (ii) Code generation using dynamic programming
    (iii) Syntax tree

    View this question on its own page →
  31. Q9d. Write short notes on: Peephole optimization20227m

    Module 4 : Intermediate Code Generation & Code Improvement

    Write short notes on: Peephole optimization

    View this question on its own page →