moving to SA register names (wip)

starting to implement register allocation by first creating SA
Single Assignment means a register is only every assigned a value once. Hence for any operation involving another register, a new register is created.
We do this with a naming scheme for the registers in dot notation (as it would be in c) which means 2 registers with the same name, should have the same contents. This does not apply to temporaries, but that is another day.
Starting WIP now, and will create many red commits before merging when green.
This commit is contained in:
2020-02-29 17:16:52 +02:00
parent f2c853821c
commit 0ce14bdfd1
4 changed files with 36 additions and 29 deletions

View File

@ -5,8 +5,8 @@ module Risc
def setup
Parfait.boot!(Parfait.default_test_options)
@r0 = RegisterValue.new(:r0 , :Message)
@r1 = RegisterValue.new(:r1 , :Space)
@r0 = RegisterValue.new(:message , :Message)
@r1 = RegisterValue.new(:id_1234 , :Space)
@compiler = Risc.test_compiler
end
@ -28,16 +28,16 @@ module Risc
assert @r0.get_new_left(:caller , @compiler).extra.empty?
end
def test_get_new_left_0_reg
assert_equal :r1 , @r0.get_new_left(:caller , @compiler).symbol
assert_equal :"message.caller" , @r0.get_new_left(:caller , @compiler).symbol
end
def test_get_new_left_1
assert_equal RegisterValue , @r0.get_new_left(:caller , @compiler).class
end
def test_get_new_left_1_reg
assert_equal :r1 , @r0.get_new_left(:caller , @compiler).symbol
assert_equal :"id_1234.classes" , @r1.get_new_left(:classes , @compiler).symbol
end
def test_get_left_uses_extra
@r1 = RegisterValue.new(:r1 , :Space , type_arguments: @r0.type)
@r1 = RegisterValue.new(:message , :Space , type_arguments: @r0.type)
# works with nil as compiler, because extra is used
assert_equal :Message , @r1.get_new_left(:arguments , nil).type.class_name
end