starting on risc allocation

inserting allocator stage in method translation
This commit is contained in:
2020-03-17 21:46:57 +02:00
parent d5411c7727
commit 2e109a16dc
11 changed files with 55 additions and 13 deletions

View File

@ -1,4 +1,4 @@
require_relative "helper"
require_relative "../helper"
module Risc
class TestLinkerObjects < MiniTest::Test

View File

@ -1,4 +1,4 @@
require_relative "helper"
require_relative "../helper"
module Risc
class TestMachinePos < MiniTest::Test

View File

@ -5,7 +5,7 @@ module Risc
def setup
Parfait.boot!(Parfait.default_test_options)
@allocator = Allocator.new
@allocator = Allocator.new(Risc.test_compiler , Platform.for(:arm))
end
def tmp_reg
Risc.tmp_reg(:Type)
@ -16,6 +16,13 @@ module Risc
def test_empty
assert @allocator.regs_empty?
end
def test_compiler
assert_equal CallableCompiler , @allocator.compiler.class
assert_equal :fake_name , @allocator.compiler.callable.name
end
def test_platform
assert_equal Arm::ArmPlatform , @allocator.platform.class
end
def test_add_ok
assert_equal Array, @allocator.add_reg(tmp_reg).class
end

View File

@ -0,0 +1,21 @@
require_relative "../helper"
module Risc
class TestCallableCompiler1 < MiniTest::Test
include SolCompile
def setup
@compiler = compile_main("return 5").to_risc
@platform = Platform.for(:arm)
end
def test_init
@compiler.risc_instructions.each do |ins|
puts ins.to_s
end
end
def test_1
@compiler.translate_method( @platform , [])
end
end
end

View File

@ -4,7 +4,7 @@ module ScopeHelper
def compiler_with_main(options = {})
compiler = RubyX::RubyXCompiler.new(RubyX.default_test_options.merge(options))
compiler.ruby_to_sol( "class Space;def main(arg);return;end;end" )
compiler.ruby_to_sol( in_Space( as_main("return")) )
compiler
end
def in_Test(statements)