setting registers in the allocator

unfortunately the reg instances are spread across instructions
this causes problems when setting them
This commit is contained in:
2020-03-20 16:15:11 +02:00
parent c890e8402b
commit d2e7c647d0
3 changed files with 44 additions and 7 deletions

View File

@ -21,4 +21,26 @@ module Risc
assert_equal "Integer_Type" , risc(1).register.type.name
end
end
# following tests are really Instruction tests, but would require mocking there
class TestInstructionProtocol < MiniTest::Test
def setup
Parfait.boot!({})
@load = Risc.load_data("source" , 1)
end
def test_reg_names
assert_equal 1 , @load.register_names.length
end
def test_reg_get
reg = @load.register_names.first
assert_equal :fix_1 , reg
end
def test_reg_set
@load.set_registers(:fix_1 , :r10)
assert_equal :r10 , @load.get_register(:register)
end
def test_reg_ssa
value = @load.set_registers(:register , :r10)
assert_equal :fix_1 , @load.get_register(:register)
end
end
end