April / May 2013
PRINCIPLES OF COMPILER DESIGN
Anna University
1 question papers available. Select an examination session to view its question paper.
PRINCIPLES OF COMPILER DESIGN
Based on available extracted papers. Question groups and frequency are provisional, not official syllabus weightage or examination predictions.
What type of optimization computes the available expressions? 7
0 eligible source papersa. i. With reference to the phases of the compiler, identify the sequence of steps that: would take place for the input ans := (a +- b * 6.3) 525 (1-k) [8] il. Write the algorithm and construct the predictive. parsing table for the grammar S>L=R({R . L~> *R|id ROL Find whether this grammar is LL(1) or not and give reason for your answer. [8] _ . | (OR) b. Write the algorithm and construct SLR parsing table for the following context free . grammar. Check whether the string id + id id * is a valid string. [1 6] EDE+T|T | | | TOTF(F FD F*{id
0 eligible source papers1. Write the translation scheme for translating assignment statements having scalar variables and array references to three-address statements. . 8) ii. Using the above translation: scheme construct an annotated parse tree for the . following assignment statement and generate the intermediate language representation. A[I, J + B[K]*L] - C[ I*J, K+L] * D தி {8] where A and C are integer arrays of sizes 20 x 50, B is an integer array of size 10, _ integer size 4 bytes, and first index position for all the arrays and all dimensions is 1. [OR] b. Consider the following program segment. for (i= 0; 1< 10; i++) begin if ( ti< tj) then begin tk=ti; i=i+1; end else begin tk = tj; j=j+1; end end | i. Write the production rules needed for recognizing the above program block along with the translations using back patching for each rule. - {8} ii. Construct annotated parse tree and generate three-address code as intermediate language for the grammar given. 18]
0 eligible source papersஉர். Discuss any four important issues in the code generation phase. [6] ரர். Apply the code generation algorithm for the following basic block and find the. _ object code produced for a machine with exactly two registers namely Ri and R2. The next use information, address descriptors, register descriptors should be taken : into account while looking for registers to carry out the computation. Initially the | ' register descriptors for all registers are empty and it is not required to keep any variable live on exit from the basic block. [10] d=b*c;e=at+b; b=b*c; f=a[if; | (OR) b. i. Construct a DAG for the following basic block and find the optimal ordering of instructions for code generation which requires minimal number of registers. [10 ] a [i] =b; *p=c¢; d=alj}; e=* p; * p=a [i] 15. 10 ii. Consider the following expression a: = b+c*d-e/f * g-, and generate three address code for the same. Construct a register interference graph and determine the minimum number of registers required to evaluate this expression. [6] a. i. Define peephole and explain all the transformations carried out in peephole - optimization. . ன ரர . [$] constructs - [8] ii. Optimize the following code using all known optimization techniques by explaining in a few words what each optimization refers to. [8] -dp =0;1=0; L: tl =i* 8; t2=A[tl],t3=i* 8; 4 =B {03 ]; 5 = 12 * 4; dp=dp + tS;i=i+1; if(i<n) gotoL | (OR) ae OB b. i. Write the data flow equations for basic blocks ‘and derive the data flow equations for \ -c:=atbh | l:=¢-a . the most familiar three program control ii. Compute the definitions in and out of each fo basic block for the flowgraph given here. [ 8 ] d:=1 B3 , c:=6 | yy b:=atb Ba e:= b-a d:= -b-e B ணம். . | b:=a-d d:=a-b
0 eligible source papersHistorical analysis based on extracted question papers. Topic classifications, marks and planning estimates are provisional.