DOC PREVIEW
CSU CS 453 - Study Guide

This preview shows page 1 out of 2 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CS453 Intro and PA1 1CS453 Lecture More tranlation to Tree IR 2Plan for todayTranslating program features to the Tree IR Last time– arithmetic and some binary operations– assignments– accesses to array variables– array assignment This time:– functions in the MiniJava run-time library– allocating class instances– allocating arrays– length expression– this expression– call expressions– less than operator– if and while statementsCS453 Lecture More tranlation to Tree IR 3Functions in MiniJava runtime library Assume the following will be available– void printint( int x )– Prints given integer followed by a newline– void * halloc( int n )– Allocates n consecutive bytes in the heap and returns the address ofthe first byte allocated.– void initArray(int [] a, int n)– Assumes that a points at an array allocation of size (n+1)*wordsize– Puts the length n into a[0]– Initializes a[1] through a[n] to zero Calling the functions within Tree IR– Exp initExp = frame.externalCall("initArray",arglist);– Frame.externalCall places an “_” in front of all function namesCS453 Lecture More tranlation to Tree IR 4Allocating class instancesclass Foo { ... }... new Foo ...CS453 Lecture More tranlation to Tree IR 5Allocating an arrayint [] y;y = new int [20];CS453 Intro and PA1 2CS453 Lecture More tranlation to Tree IR 6Length expressionint [] y; ... y.length ... ... new int [13] . length ...CS453 Lecture More tranlation to Tree IR 7Call expression... this . otherFunc(y,f)...CS453 Lecture More tranlation to Tree IR 8StmCJUMP public class StmCJUMP extends Stm { public int relop; public Exp left, right; public Label iftrue, iffalse; public StmCJUMP(int rel, Exp l, Exp r, Label t,Label f) { ... } public final static int EQ=0, NE=1, LT=2, GT=3, ...CS453 Lecture More tranlation to Tree IR 9Tree intermediate representation ExpCONST(int i) - The integer constant i ExpNAME(Label n) - Constant address. Corresponds to label in assembly. ExpTEMP(Temp t) - Temporary t. “Infinite” Temps in Tree IR. ExpBINOP(int binop, Exp left, Exp right) - left binop right ExpMEM(Exp exp) - If left child of move, then store into address calculated by exp.Otherwise, fetch value at address calculated by exp. ExpCALL(Exp func, List<Exp> args) - evaluate func to find func address, thenevaluate args left to right. StmMOVE(Temp t, e) - Eval e and put result in t. StmMOVE(ExpMEM(e1), e2) - Eval e2 and store into address e1. StmEXP(Exp e) - Eval e and ignore result StmJUMP(Label targ) - Transfer control to given label. StmCJUMP(int rel, Exp l, Exp r, Label t, Label f) - if l rel r then goto t else goto f StmLABEL(Label l) - Label in


View Full Document

CSU CS 453 - Study Guide

Download Study Guide
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Study Guide and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Study Guide 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?