Define live range splitting instructions.

The copy/spill/fill instructions will be used by the register allocator
for splitting live ranges. The copy instruction is also useful when
rewriting values:

If a primary value is rewritten as a secondary result, a copy
instruction can be used instead:

  a = foo x
=>
  t, vx1 = call ...
  a = copy vx1

Since a primary value must be the first value of an instruction, this
doesn't work:

  a = foo x
=>
  t, a = call ...
This commit is contained in:
Jakob Stoklund Olesen
2016-10-20 15:34:16 -07:00
parent 8422976d78
commit 0acabc80d0
2 changed files with 59 additions and 1 deletions

View File

@@ -204,6 +204,40 @@ select = Instruction(
""",
ins=(c, x, y), outs=a)
x = Operand('x', Any)
copy = Instruction(
'copy', r"""
Register-register copy.
This instruction copies its input, preserving the value type.
A pure SSA-form program does not need to copy values, but this
instruction is useful for representing intermediate stages during
instruction transformations, and the register allocator needs a way of
representing register copies.
""",
ins=x, outs=a)
spill = Instruction(
'spill', r"""
Spill a register value to a stack slot.
This instruction behaves exactly like :inst:`copy`, but the result
value is assigned to a spill slot.
""",
ins=x, outs=a)
fill = Instruction(
'fill', r"""
Load a register value from a stack slot.
This instruction behaves exactly like :inst:`copy`, but the input
value is assigned to a spill slot.
""",
ins=x, outs=a)
#
# Vector operations
#