2020-03-18 16:50:22 +01:00
|
|
|
require_relative "../helper"
|
|
|
|
|
|
|
|
module Risc
|
|
|
|
class TestStandardAllocator1 < MiniTest::Test
|
|
|
|
include SlotMachineCompile
|
|
|
|
def setup
|
|
|
|
coll = compile_slot( "class Space ; def main(); main{return 'Ho'};return 'Hi'; end; end;")
|
|
|
|
@compiler = coll.to_risc.method_compilers
|
|
|
|
@allocator = Platform.for(:arm).allocator(@compiler)
|
|
|
|
end
|
|
|
|
def test_main
|
|
|
|
assert_equal :main , @compiler.callable.name
|
|
|
|
end
|
|
|
|
def test_allocate_runs
|
2020-03-19 11:30:44 +01:00
|
|
|
assert_nil @allocator.allocate_regs
|
2020-03-19 13:10:39 +01:00
|
|
|
assert_equal 0 , @allocator.used_regs.length
|
2020-03-18 16:50:22 +01:00
|
|
|
end
|
|
|
|
def test_live_length
|
2020-03-19 11:30:44 +01:00
|
|
|
live = @allocator.walk_and_mark(@compiler.risc_instructions)
|
2020-03-18 16:50:22 +01:00
|
|
|
assert_equal 10 , live.length
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|