Drawtomata / Three-address code and code generation

Three-address code and code generation

Type an expression such as a = b * -c + b * -c or a short program above. Drawtomata produces three-address code with quadruples, triples and indirect triples, and goes on to DAGs, SSA, basic blocks, liveness, target code and peephole optimization.

Three-address code

Every instruction has at most one operator and three addresses, such as t2 = b * t1. Temporaries hold intermediate results, in the order the expression is evaluated. For a = b * -c + b * -c:

#oparg1arg2result
0minusct1
1*bt1t2
2minusct3
3*bt3t4
4+t2t4t5
5=t5a

Triples drop the result column and refer to earlier results by their number; indirect triples add a list of pointers so an optimizer can reorder instructions.

What else is on the tab

Every optimized program is run against the original on random inputs before it is shown.