Content deleted Content added
Adding short description: "Algorithm for minimising register usage" |
|||
(6 intermediate revisions by 4 users not shown) | |||
Line 1:
{{Short description|Algorithm for minimising register usage}}
In [[computer science]], the '''Sethi–Ullman algorithm''' is an [[algorithm]] named after [[Ravi Sethi]] and [[Jeffrey D. Ullman]], its inventors, for translating [[abstract syntax tree]]s into [[machine code]] that uses as few [[Processor register|registers]] as possible.
Line 8 ⟶ 9:
# Traverse the [[abstract syntax tree]] in pre- or postorder
## For every leaf node, if it is a non-constant
## For every non-leaf node
# To emit code, if the subtrees need different numbers of registers, evaluate the subtree needing the most registers first (since the register needed to save the result of one subtree may make the other one [[Register spilling|spill]]), otherwise the order is irrelevant.
===Example===
For an arithmetic expression <math>a = (b + c + f * g)
=
Line 62:
==External links==
*[
{{DEFAULTSORT:Sethi-Ullman algorithm}}
|