Intermediate-Code Generation Jin Tianxing 5110309085.
-
Upload
karen-jefferson -
Category
Documents
-
view
252 -
download
0
description
Transcript of Intermediate-Code Generation Jin Tianxing 5110309085.
Purpose Theoretically, we can directly generate the
MIPS assemble code after semantic analysis.
Intermediate-code give us opportunities to register allocation, code optimization and easiness when debugging.
After this, the input code and AST can be thrown away.
Where is the data? There are only two possible place containing
data: and .
That means the intermediate-code get data only with and
For simplicity, we assume the number of is unlimited.
Quadruple A quadruple consists of an , which can possibly be null. You should design your own IR package. Here is a viable example.
Example for jump stmt Maintain stacks of and of loops.
break Jump to the peek of
continue Jump to the peek of
What to do when calling a function? Save in memory. Change , (jump and link) to the of the function. When from a function:
address(value) stores in a . (jump register)
Restore from memory.
Single Static Assignment It is a intuitive approach in intermediate-code
generation.
One can be only assigned once.