make operator_instruction single ass
create result register automatically usually not used, but register allocation will sort that
This commit is contained in:
23
test/risc/instructions/test_operator_instruction.rb
Normal file
23
test/risc/instructions/test_operator_instruction.rb
Normal file
@ -0,0 +1,23 @@
|
||||
require_relative "../helper"
|
||||
|
||||
module Risc
|
||||
class TestOperatorInstruction < MiniTest::Test
|
||||
def setup
|
||||
Parfait.boot!({})
|
||||
@left = RegisterValue.new(:left , :Integer)
|
||||
@right = RegisterValue.new(:right , :Integer)
|
||||
end
|
||||
def risc(i)
|
||||
@left.op :- , @right
|
||||
end
|
||||
def test_min
|
||||
assert_operator 1 , :- , :left , :right , "op_-_"
|
||||
end
|
||||
def test_reg
|
||||
result = risc(1).result
|
||||
assert_equal RegisterValue , result.class
|
||||
assert_equal "Integer_Type" , result.type.name
|
||||
assert result.symbol.to_s.start_with?("op_-_")
|
||||
end
|
||||
end
|
||||
end
|
@ -94,7 +94,7 @@ module Minitest
|
||||
assert_equal Risc::Branch , branch.class , "Class at:#{branch_i}"
|
||||
assert_label branch.label , label_name , "Label at #{branch_i}"
|
||||
end
|
||||
def assert_operator ins_i , op , left , right
|
||||
def assert_operator ins_i , op , left , right , result
|
||||
if(ins_i.is_a?(Integer))
|
||||
ins = risc(ins_i)
|
||||
else
|
||||
@ -105,6 +105,7 @@ module Minitest
|
||||
assert_equal op , ins.operator
|
||||
assert_register :left , left , ins.left , ins_i
|
||||
assert_register :right , right , ins.right, ins_i
|
||||
assert_register :result , result , ins.result, ins_i
|
||||
end
|
||||
def assert_zero ins_i , label
|
||||
assert_equal Integer , ins_i.class, "assert_zero #{ins_i}"
|
||||
|
Reference in New Issue
Block a user