chapter4 compilers and interpreters

11
System Programming Mrs. Sunita M Dol, CSE Dept 1 Chapter 4. Compilers & Interpreters Multiple Choice Questions 1) An ideal compiler should a. Detect error b. Detect and repair error c. Detect, repair and correct error d. None of these 2) Compiler bridges semantic gap between which domains a. Application and execution b. Application and PL c. PL and execution d. None of these 3) An optimizing compiler a. Is optimized to occupy less space b. Is optimized to reduce execution time c. Optimizes the code d. None of these 4) A basic block can be analyzed by a. a DAG b. a graph which may involve cycles c. flow graph d. none of these 5) The register descriptor has the fields a. Name b. Addressability c. Address of CPU register of memory word d. None of the above

Upload: sunita-aher

Post on 16-Apr-2017

132 views

Category:

Engineering


11 download

TRANSCRIPT

Page 1: Chapter4 compilers and interpreters

System Programming Mrs. Sunita M Dol, CSE Dept

1

Chapter 4. Compilers & Interpreters

Multiple Choice Questions

1) An ideal compiler should

a. Detect error

b. Detect and repair error

c. Detect, repair and correct error

d. None of these

2) Compiler bridges semantic gap between which domains

a. Application and execution

b. Application and PL

c. PL and execution

d. None of these

3) An optimizing compiler

a. Is optimized to occupy less space

b. Is optimized to reduce execution time

c. Optimizes the code

d. None of these

4) A basic block can be analyzed by

a. a DAG

b. a graph which may involve cycles

c. flow graph

d. none of these

5) The register descriptor has the fields

a. Name

b. Addressability

c. Address of CPU register of memory word

d. None of the above

Page 2: Chapter4 compilers and interpreters

System Programming Mrs. Sunita M Dol, CSE Dept

2

6) The _______of a language is the collection of language features for altering the

flow of control during the execution of the program

a. Control structure

b. Control block

c. Control sequence

d. Control table

7) Code optimization aims at improving

a. Execution efficiency of a program

b. Storage capacity of a program

c. (a) and (b)

d. None of these

8) The optimization techniques are independent of

a. Target machine

b. PL

c. Both a and b

d. None of these

9) The transformed IR (intermediate representation) is input to _____ of optimizing

compiler

a. Front end

b. Back end

c. Both (a) and (b)

d. None of the above

10) Optimizing transformations are classified into

a. Local transformation

b. Global transformation

c. Both a and b

d. None of these

Page 3: Chapter4 compilers and interpreters

System Programming Mrs. Sunita M Dol, CSE Dept

3

11) Which of the following is/are optimizing transformation(s) commonly used in

compilers?

a. Compile time evaluation and Elimination of common sub expressions

b. Frequency reduction and Strength reduction

c. Dead code elimination

d. All of the above

12) A data type is the specification of

a. Legal values for variables of the type

b. Legal operations on the legal values of the type

c. Both (a) and (b)

d. None of the above

13) Semantics of a data type require a/an _______ to ensure that variables of a type

are assigned or manipulated only through legal operations

a. Compiler

b. Interpreter

c. Assembler

d. Linker

14) Generation of type specific code achieves:

a. Implementation of second half of a type’s definition

b. Execution efficiency

c. Both (a) and (b)

d. None of the above

15) When an operator is reduced by parse, which function is called?

a. gencode

b. codegen

c. both (a) and (b)

d. none of the above

Page 4: Chapter4 compilers and interpreters

System Programming Mrs. Sunita M Dol, CSE Dept

4

16) In most languages, scope of a data item is restricted to the ______in which the

data item is declared

a. Program block

b. Control structure

c. Memory

d. None of the above

17) PL feature(s) which contribute(s) to semantic gap between PL and execution

domain is/are:

a. Data types and Data Structures

b. Scope Rules

c. Control Structure

d. All of the above

18) The major issue(s) in code generation for expressions is/are:

a. Determination of evaluation order for operators in an expression

b. Selection of instructions to be used in the target code

c. Use of registers and handling of partial results

d. All of the above

19) The choice of an instruction to be used in the target code depends on

a. Type of each operand

b. Length of each operand

c. Addressability of each operand

d. All of the above

20) ____ is used to maintain the type, length and addressability information for each

operand

a. Operand descriptor

b. Operand table

c. Symbol table

d. None of the above

Page 5: Chapter4 compilers and interpreters

System Programming Mrs. Sunita M Dol, CSE Dept

5

21) A part of a program where the entity is accessible is_____ of the program

a. Limit

b. Scope

c. Age

d. Period

22) An operand descriptor has following field(s):

a. Attributes

b. Addressability

c. Both (a) and (b)

d. None of the above

23) Representation of an elementary operation in the form of a pseudo-machine

instruction is

a. A triple

b. A quadruple

c. An expression tree

d. All of the above

24) When optimization is applied over small segment of program consisting of a few

source statements, it is called

a. Local transformation

b. Global transformation

c. Body transformation

d. None of the above

25) If (bi, bj) Є E(set of directed edges), bi is ___________________ of bj and bj is

_____________ of bi

a. Predecessor, successor

b. Ancestor, descendant

c. Dominator, post-dominator

d. None of the above

Page 6: Chapter4 compilers and interpreters

System Programming Mrs. Sunita M Dol, CSE Dept

6

26) Use of algebraic equivalence

a. Improves effectiveness of optimization

b. Increases cost of optimization

c. Both (a) and (b)

d. None of the above

27) The code which can be eliminated from the program without affecting results is

called

a. Common sub expression

b. Dead code

c. Both (a) and (b)

d. None of the above

28) The data flow concept ‘live variable’ corresponds to which optimization?

a. Common sub expression elimination

b. Dead code elimination

c. Constant and variable propagation

d. None of the above

29) Which optimization requires more analysis effort to establish feasibility of

optimization

a. Local

b. Global

c. Both (a) and (b)

d. None

30) A program flow graph for a program P is ______ graph

a. Directed

b. Undirected

c. Bidirectional

d. None of the above

Page 7: Chapter4 compilers and interpreters

System Programming Mrs. Sunita M Dol, CSE Dept

7

31) A sequence of edges such that the destination node of one edge is the source

node of the following node is called

a. Path

b. Scope

c. Range

d. None of the above

32) If a path exists from bi to bj, bi is ____________________of bj and bj is

____________________of bi.

a. Predecessor, successor

b. Ancestor, descendant

c. Dominator, Post-dominator

d. None of the above

33) If every path from n0 (Start node) to bj passes through block bi, block bi

is______________ of block bj.

a. Predecessor

b. Ancestor

c. Dominator

d. Post dominator

34) If every path from bj to an exit node passes through bi, bi is __________of bj.

a. Ancestor

b. Successor

c. Post Dominator

d. Dominator

Page 8: Chapter4 compilers and interpreters

System Programming Mrs. Sunita M Dol, CSE Dept

8

35) When optimization is applied over larger segments consisting of loops or fun

bodies, it is called

a. Local transformation

b. Global transformation

c. Body transformation

d. None of the above

36) The data flow concept ‘Reaching definition’ corresponds to which optimization?

a. Common sub expression elimination

b. Dead code elimination

c. Constant and variable propagation

d. None of the above

37) Which information is used to decide whether an optimizing transformation can be

applied to a segment of code in the program?

a. Data flow information

b. Control flow information

c. Concept information

d. None of the above

38) Complier can diagnose

a. Grammatical errors only

b. Logical errors only

c. Grammatical and logical errors

d. Neither grammatical nor logical

Page 9: Chapter4 compilers and interpreters

System Programming Mrs. Sunita M Dol, CSE Dept

9

39) For a*b, Avail_in = true for blocks:

a) 2,5,8,9

b) 5,6,8,9

c) 1,7,8,9

d) 2,5,6,7,8,9

40) In figure A, for x+y, Avail_in=true for blocks:

a. 6,8

b. 6,7,8,9

c. 6,7,8,9

d. 5,6,7,8,9

41) In figure A, for a*b, Avail_in=true for blocks:

a. 2, 3, 5, 6, 7, 8, 9

b. 2, 3, 5, 6, 7, 8, 9, 10

Page 10: Chapter4 compilers and interpreters

System Programming Mrs. Sunita M Dol, CSE Dept

10

c. 2, 5, 6, 7, 8, 9, 10

d. None of above

42) In figure A, variable a is live at the entry of all blocks except for block(s):

a. 4

b. 5

c. 6,7

d. 3

43) In figure A, variable b is live at the entry of which block?

a. 1

b. 9

c. 10

d. All the blocks

44) The data flow concept ‘Available Expression’ corresponds to which optimization?

a. Common sub expression elimination

b. Dead Code Elimination

c. Constant and variable propagation

d. None of the above

Page 11: Chapter4 compilers and interpreters

System Programming Mrs. Sunita M Dol, CSE Dept

11

45) Perform Frequency Reduction for the following

a.

b.

c.

d. None of above

for i: =1 to 100 do

begin

z:=i;

x:=25*a;

y:=x+z;

end;

for i: =1 to

100 do

z:=i;

begin

x:=25*a;

y:=x+z;

end;

for i: =1 to

100 do

y:=x+z;

begin

x:=25*a;

z:=i;

end;

x:=25*a;

for i: =1 to 100 do

begin

z:=i;

y:=x+z;

end;