Commit 47a90a9d authored by Aleksandar Radojicic's avatar Aleksandar Radojicic
Browse files

tc_9: Add explanations about rewrite_program

* source/compiler_stages/tc_9/faq.rst,
* source/compiler_stages/tc_9/simple_add.tig: Here
parent 15eb9d55
......@@ -2,3 +2,22 @@
TC-9 FAQ
--------
Why does :code:`Codegen::rewrite_program` need the :code:`created_temps` argument ?
:code:`created_temps` is a set storing all the new temporaries generated
during the program's rewrite. This set is then used by
:code:`Color::select_spill` to avoid spilling these temporaries.
Spilling the generated temporaries could potentially lead to an infinite
loop because it does not reduce the number of conflicts.
For instance the following example produces an infinite loop if no check
is done:
.. literalinclude:: simple_add.tig
:language: tiger
:caption:
.. code-block:: none
$ tc --callee-save=0 --caller-save=2 -eS simple_add.tig
let
var a0 := 0
var a1 := 1
var a2 := 2
var a3 := 3
in
print_int(0
+ a0 + a0
+ a1 + a1
+ a2 + a2
+ a3 + a3
)
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment