large test changes due to change in cc

calling convention does affect
less than before, but still a LOT
This commit is contained in:
Torsten Ruger
2018-08-12 15:02:23 +03:00
parent fee9e261a5
commit 86462e238a
27 changed files with 335 additions and 415 deletions

View File

@ -7,12 +7,10 @@ module Risc
def setup
super
@input = "r = 5.div4"
@expect = [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, RegToSlot, SlotToReg, RegToSlot, LoadConstant,
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
SlotToReg, FunctionCall, Label, SlotToReg, SlotToReg,
RegToSlot]
@expect = [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
FunctionCall, Label, SlotToReg, SlotToReg, RegToSlot]
end
def test_local_assign_instructions
assert_nil msg = check_nil , msg
@ -20,7 +18,7 @@ module Risc
def test_constant_load
produced = produce_body
load = produced.next(14)
load = produced.next(8)
assert_equal LoadConstant , load.class
assert_equal 5 , load.constant.value
end

View File

@ -10,8 +10,8 @@ module Risc
@expect = "something"
@produced = produce_instructions
end
def instruction(num) # 24 is the main, see test/mom/send/test_setup_simple.rb
@produced.next( 24 + num)
def instruction(num) # 18 is the main, see length in test/mom/send/test_setup_simple.rb
@produced.next( 18 + num)
end
def test_postamble_classes
postamble.each_with_index do |ins , index|

View File

@ -15,12 +15,11 @@ module Risc
Branch, Label, Transfer, Syscall, Transfer,
Transfer, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
RegToSlot, RegToSlot, Label, RegToSlot, Label,
LoadConstant, SlotToReg, LoadConstant, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, RegToSlot, RegToSlot, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
SlotToReg, RegToSlot, SlotToReg, LoadConstant, SlotToReg,
DynamicJump, Label]
LoadConstant, SlotToReg, LoadConstant, SlotToReg, SlotToReg,
RegToSlot, RegToSlot, RegToSlot, RegToSlot, SlotToReg,
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, SlotToReg, LoadConstant, SlotToReg, DynamicJump,
Label]
end
def test_send_instructions
@ -38,7 +37,7 @@ module Risc
end
def test_function_call
produced = produce_body
assert_equal DynamicJump , produced.next(65).class
assert_equal DynamicJump , produced.next(59).class
end
def test_cache_check
produced = produce_body

View File

@ -7,36 +7,33 @@ module Risc
def setup
super
@input = "5.div4"
@expect = [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, RegToSlot, SlotToReg, RegToSlot, LoadConstant,
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
SlotToReg, FunctionCall, Label]
@expect = [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
FunctionCall, Label]
end
def test_send_instructions
assert_nil msg = check_nil , msg
end
def test_load_5
produced = produce_body
assert_equal 5 , produced.next(14).constant.value
produced = produce_body.next(8)
assert_load( produced , Parfait::Integer)
assert_equal 5 , produced.constant.value
end
def test_load_label
produced = produce_body
assert_equal Label , produced.next(17).constant.class
end
def test_call_reg_setup
produced = produce_body
assert_equal :div4 , produced.next(21).method.name
produced = produce_body.next(11)
assert_load( produced , Label)
end
def test_function_call
produced = produce_body
assert_equal FunctionCall , produced.next(21).class
assert_equal :div4 , produced.next(21).method.name
produced = produce_body.next(15)
assert_equal FunctionCall , produced.class
assert_equal :div4 , produced.method.name
end
def test_check_continue
produced = produce_body
assert produced.next(22).name.start_with?("continue_")
produced = produce_body.next(16)
assert_equal Label , produced.class
assert produced.name.start_with?("continue_")
end
#TODO check the message setup, type and frame moves
end

View File

@ -7,12 +7,11 @@ module Risc
def setup
super
@input = "5.get_internal_word(1)"
@expect = [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, RegToSlot, SlotToReg, RegToSlot, LoadConstant,
SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
FunctionCall, Label]
@expect = [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
LoadConstant, SlotToReg, RegToSlot, SlotToReg, FunctionCall,
Label]
end
def test_send_instructions
@ -20,64 +19,45 @@ module Risc
end
def test_load_5
produced = produce_body
assert_equal 5 , produced.next(14).constant.value
assert_equal LoadConstant , produced.next(8).class
assert_equal 5 , produced.next(8).constant.value
end
def base
17
11
end
def test_load_arg_const
produced = produce_body
assert_equal LoadConstant , produced.next(base).class
assert_equal Parfait::Integer , produced.next(base).constant.class
assert_load( produced.next(base) , Parfait::Integer )
assert_equal 1 , produced.next(base).constant.value
end
def test_load_next_m
produced = produce_body
assert_equal SlotToReg , produced.next(base+1).class
assert_equal :r2 , produced.next(base+1).register.symbol
assert_equal :r0 , produced.next(base+1).array.symbol
assert_equal 1 , produced.next(base+1).index
produced = produce_body.next(base+1)
assert_slot_to_reg( produced ,:r0 ,1 , :r2 )
end
def test_load_args
produced = produce_body
assert_equal SlotToReg , produced.next(base+2).class
assert_equal :r2 , produced.next(base+2).register.symbol
assert_equal :r2 , produced.next(base+2).array.symbol
assert_equal 8 , produced.next(base+2).index
produced = produce_body.next(base+2)
assert_slot_to_reg( produced ,:r2 ,8 , :r2 )
end
def test_store_arg_at
produced = produce_body
assert_equal RegToSlot , produced.next(base+3).class
assert_equal :r1 , produced.next(base+3).register.symbol
assert_equal :r2 , produced.next(base+3).array.symbol
assert_equal 1 , produced.next(base+3).index , "first arg must have index 1"
produced = produce_body.next(base+3)
assert_reg_to_slot( produced ,:r1 ,:r2 , 1 )
end
def test_load_label
produced = produce_body
assert_equal LoadConstant , produced.next(base+4).class
assert_equal Label , produced.next(base+4).constant.class
produced = produce_body.next(base+4)
assert_load( produced , Label )
end
def test_load_some
produced = produce_body
assert_equal SlotToReg , produced.next(base+5).class
assert_equal :r0 , produced.next(base+5).array.symbol
assert_equal :r2 , produced.next(base+5).register.symbol
assert_equal 1 , produced.next(base+5).index
produced = produce_body.next(base+5)
assert_slot_to_reg( produced ,:r0 ,1 , :r2 )
end
def test_store_
produced = produce_body
assert_equal RegToSlot , produced.next(base+6).class
assert_equal :r2 , produced.next(base+6).array.symbol
assert_equal :r1 , produced.next(base+6).register.symbol
assert_equal 4 , produced.next(base+6).index
produced = produce_body.next(base+6)
assert_reg_to_slot( produced ,:r1 ,:r2 , 4 )
end
def test_swap_messages
produced = produce_body
assert_equal SlotToReg , produced.next(base+7).class
assert_equal :r0 , produced.next(base+7).array.symbol
assert_equal :r0 , produced.next(base+7).register.symbol
assert_equal 1 , produced.next(base+7).index
produced = produce_body.next(base+7)
assert_slot_to_reg( produced ,:r0 ,1 , :r0 )
end
def test_function_call
@ -89,6 +69,5 @@ module Risc
produced = produce_body
assert produced.next(base+9).name.start_with?("continue_")
end
#TODO check the message setup, type and frame moves
end
end

View File

@ -7,11 +7,10 @@ module Risc
def setup
super
@input = "5.div4"
@expect = [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, RegToSlot, SlotToReg, RegToSlot, LoadConstant,
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
SlotToReg, FunctionCall, Label]
@expect = [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
FunctionCall, Label]
@produced = produce_body
end
@ -31,51 +30,25 @@ module Risc
sl = @produced.next( 2 )
assert_slot_to_reg( sl , :r2 , 3 , :r3 )
end
def test_store_message_in_current
def test_get_next_next #reduce onto itself
sl = @produced.next( 3 )
assert_slot_to_reg( sl , :r3 , 1 , :r4 )
end
def test_store_next_next_in_space
sl = @produced.next( 4 )
assert_reg_to_slot( sl , :r4 , :r2 , 3 )
end
def test_store_message_in_current
sl = @produced.next( 5 )
assert_reg_to_slot( sl , :r3 , :r0 , 1 )
end
def test_store_caller_in_message
sl = @produced.next( 4 )
sl = @produced.next( 6 )
assert_reg_to_slot( sl , :r0 , :r3 , 6 )
end
def test_get_args_type #from method in r1
sl = @produced.next( 5 )
assert_slot_to_reg( sl , :r1 , 3 , :r4 )
end
def test_get_args #from message
sl = @produced.next( 6 )
assert_slot_to_reg( sl , :r3 , 8 , :r5 )
end
def test_store_type_in_args
sl = @produced.next( 7 )
assert_reg_to_slot( sl , :r4 , :r5 , 0 )
end
def test_get_frame_type #from method in r1
sl = @produced.next( 8 )
assert_slot_to_reg( sl , :r1 , 5 , :r4 )
end
def test_get_frame #from message
sl = @produced.next( 9 )
assert_slot_to_reg( sl , :r3 , 3 , :r5 )
end
def test_store_type_in_frame
sl = @produced.next( 10 )
assert_reg_to_slot( sl , :r4 , :r5 , 0 )
end
def test_store_method_in_message
sl = @produced.next( 11 )
sl = @produced.next( 7 )
assert_reg_to_slot( sl , :r1 , :r3 , 7 )
end
def test_get_next_next #reduce onto itself
sl = @produced.next( 12 )
assert_slot_to_reg( sl , :r3 , 1 , :r3 )
end
def test_store_next_next_in_space
sl = @produced.next( 13 )
assert_reg_to_slot( sl , :r3 , :r2 , 3 )
end
end
end

View File

@ -7,26 +7,25 @@ module Risc
def setup
super
@input = "return 5.div4"
@expect = [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, RegToSlot, SlotToReg, RegToSlot, LoadConstant,
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
SlotToReg, FunctionCall, Label, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, Branch]
@expect = [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
FunctionCall, Label, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, Branch]
end
def test_return_instructions
assert_nil msg = check_nil , msg
end
def test_function_return
produced = produce_body
assert_equal Branch , produced.next(29).class
assert_equal "return_label" , produced.next(29).label.name
produced = produce_body.next(23)
assert_equal Branch , produced.class
assert_equal "return_label" , produced.label.name
end
def test_load_5
produced = produce_body
assert_equal LoadConstant , produced.next(14).class
assert_equal 5 , produced.next(14).constant.value
produced = produce_body.next(8)
assert_equal LoadConstant , produced.class
assert_equal 5 , produced.constant.value
end
end
end

View File

@ -15,13 +15,12 @@ module Risc
Branch, Label, Transfer, Syscall, Transfer,
Transfer, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
RegToSlot, RegToSlot, Label, RegToSlot, Label,
LoadConstant, SlotToReg, LoadConstant, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, RegToSlot, RegToSlot, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
SlotToReg, RegToSlot, SlotToReg, LoadConstant, SlotToReg,
DynamicJump, Label, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, Branch]
LoadConstant, SlotToReg, LoadConstant, SlotToReg, SlotToReg,
RegToSlot, RegToSlot, RegToSlot, RegToSlot, SlotToReg,
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, SlotToReg, LoadConstant, SlotToReg, DynamicJump,
Label, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, RegToSlot, Branch]
end
def test_return_instructions
@ -29,9 +28,9 @@ module Risc
end
def test_function_return
produced = produce_body
assert_equal Branch , produced.next(73).class
assert_equal Branch , produced.next(67).class
end
def est_cache_check
def test_cache_check
produced = produce_body
assert_equal IsZero , produced.next(6).class
end

View File

@ -7,15 +7,14 @@ module Risc
def setup
super
@input = "while(5 > 0) ; @a = true; end"
@expect = [Label, LoadConstant, LoadConstant, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, RegToSlot, RegToSlot, SlotToReg, RegToSlot,
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
SlotToReg, FunctionCall, Label, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, LoadConstant, OperatorInstruction,
IsZero, LoadConstant, OperatorInstruction, IsZero, LoadConstant,
SlotToReg, RegToSlot, Branch, Label]
@expect = [Label, LoadConstant, LoadConstant, SlotToReg, SlotToReg,
RegToSlot, RegToSlot, RegToSlot, RegToSlot, LoadConstant,
SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
FunctionCall, Label, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, IsZero,
LoadConstant, OperatorInstruction, IsZero, LoadConstant, SlotToReg,
RegToSlot, Branch, Label]
end
def test_while_instructions
@ -26,33 +25,33 @@ module Risc
end
def test_int_load_5
produced = produce_body
load = produced.next(15)
load = produced.next(9)
assert_equal Risc::LoadConstant , load.class
assert_equal Parfait::Integer , load.constant.class
assert_equal 5 , load.constant.value
end
def test_int_load_0
produced = produce_body
load = produced.next(18)
load = produced.next(12)
assert_equal Risc::LoadConstant , load.class
assert_equal Parfait::Integer , load.constant.class
assert_equal 0 , load.constant.value
end
def test_false_check
produced = produce_body
assert_equal Risc::IsZero , produced.next(35).class
assert produced.next(35).label.name.start_with?("merge_label") , produced.next(35).label.name
assert_equal Risc::IsZero , produced.next(29).class
assert produced.next(29).label.name.start_with?("merge_label") , produced.next(29).label.name
end
def test_nil_load
produced = produce_body
assert_equal Risc::LoadConstant , produced.next(36).class
assert_equal Parfait::NilClass , produced.next(36).constant.class
assert_equal Risc::LoadConstant , produced.next(30).class
assert_equal Parfait::NilClass , produced.next(30).constant.class
end
def test_back_jump # should jump back to condition label
produced = produce_body
assert_equal Risc::Branch , produced.next(42).class
assert_equal produced , produced.next(42).label
assert_equal Risc::Branch , produced.next(36).class
assert_equal produced , produced.next(36).label
end
end