Intermediate Code Here's a summary of the informal 3-address intermediate code used in lecture, including a precise description of the gen() function, which generates intermediate code instructions. In general, gen calls have the form gen(target,operator,source1,source2) but the precise meaning of these fields depends on the particular operator. Each call to gen() produces a single instruction. Code attributes are normally lists of such instructions. The following notation is used for lists: [x] is the singleton list containing x. [x1,...,xn] is the n-element list containing x1,...,xn. l1 @ l2 is the concatenation of list l1 with list l2. I use the following convention to indicate the types of source and target operands: t = temporary v = variable name n = numeric constant l = label _ = missing operand Gen call Corresponding instruction in Meaning informal notation gen(t1,const,n,_) t1 = const n Set t1 to the numeric constant n. gen(t1,*,t2,_) t1 = *t2 Load t1 from address t2. gen(t1,addr,v,_) t1 = addr v Set t1 to the address of v. gen(*t1,:=,t2,_) *t1 = t2 Store t2 into address t1. gen(t1,+,t2,t3) t1 = t2 + t3 Set t1 to the sum of t2 and t3. Note: Other binary arithmetic operators (-,*,/,|,etc.) are similar. gen(t1,uminus,t2,_) t1 = - t2 Set t1 to the negation of t2. gen(t1,<,t2,t3) t1 = t2 < t3 Set t1 to 1 if t2 < t3, else to 0. Note: Other binary relational operators (>,=,<=,>=,<>) are similar. gen(l,:,_,_) l: Declare label l. gen(l,goto,_,_) goto l Unconditional jump to l. gen(l,if0,t,_) if t = 0 goto l Conditional jump to l if t = 0. gen(l,if<,t1,t2) if t1 < t2 goto l Conditional jump to l if t1 < t2. Note: Other conditional jump operators (if>,if=,if<=,if>=,if<>) are similar. General Note: A real IR would probably have the binary relational operators (like "<") and the "if0" operator, OR the conditional jump operators (like "if<"), but not both.