TAC
This handout summarizes a simple TAC intermediate language. There are many choices as to the exact instructions to include in such a language, and you will probably want to modify and extend this variant when we translate IC programs into TAC.
One representation note: TAC operands that name program variables should refer to the symbol-table entries you built in PA 2, not to raw identifier strings, so that distinct variables with the same name stay distinct.
Instruction Forms
Arithmetic and Logic Instructions.
The basic instruction forms are:a = b OP c a = OP bwhere
OPcan be
an arithmetic operator: ADD,SUB,DIV,MULa logic operator: AND,OR,XORa comparison operator: EQ,NEQ,LE,LEQ,GE,GEQa unary operator: MINUS,NEGData Movement Instructions.
Copy: a = bLoad/store: a = *b*a = bArray load/store: a = b[i]a[i] = bField load/store: a = b.fa.f = bBranch Instructions.
Label: label LUnconditional jump: jump LConditional jump: cjump a L(jump to Lifais true)Function Call Instructions.
Call with no result: call f(a_1, ..., a_n)Call with result: a = call f(a_1, ..., a_n)(Note: there is no explicit TAC representation for parameter passing, stack frame setup, etc.)