hw3 - are nonescaping unless specified otherwise. e. a<b...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
HW 3: Intermediate Code CSC 4351, Spring 2011 Due: 11 April 2011 1. Suppose we change the Tiger language to use Ada’s copy-in-copy-out parameter passing mechanism. If a parameter is declared with the keywords in out , it uses copy-in-copy-out. Otherwise, we use call-by-value as before. With copy-in-copy-out, the argument is copied into the parameter variable on entering the function. On function exit, the parameter is copied back out into the argument vari- able. Describe in detail which changes (if any) are necessary to semantic analysis, escape analysis, activation records, and the intermediate representation. 2. Draw the intermediate code trees for questions 7.1(f), 7.1(h), 7.2(g), 7.2(j) on p. 160. 7.1 Suppose a certain compiler translates all expressions and subexpressions into Tree.Exp trees, and does not use the Nx and Cx constructors to represent expressions in different ways. Draw a picture of the IR tree that results from each of the following expressions. Assume all variables
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: are nonescaping unless specified otherwise. e. a<b , which should be implemented by making an ESEQ whose left-hand side moves a 1 or 0 into some newly defined temporary, and whose right-hand side is the temporary. f. if a then b else c , where a is an integer variable (true if n = 0 ); this should also be translated using an ESEQ . h. if a<b then c:=a else c:=b , translated using the a<b tree from part (e) above; the whole statement will therefore be rather clumsy and inefficient. 7.2 Translate each of these expressions into IR trees, but using the Ex , Nx , and Cx constructors as appropriate. In each case, just draw pictures of the trees; an Ex tree will be a Tree Exp , an Nx tree will be a Tree Stm , and a Cx tree will be a Stm with holes labeled true and false into which labels can later be placed. g. if a then b else c , where a is an integer variable (true if n = 0 ). j. if a<b then c:=a else c:=b 1...
View Full Document

This note was uploaded on 12/31/2011 for the course CSC 4351 taught by Professor Baumgartner,g during the Fall '08 term at LSU.

Ask a homework question - tutors are online