fixing and testing operators

This commit is contained in:
Torsten Ruger
2015-10-15 09:32:47 +03:00
parent e436581ce8
commit 3d83f203ca
9 changed files with 69 additions and 33 deletions

View File

@ -49,15 +49,17 @@ module Register
# This relies on linux to save and restore all registers
#
def save_message(function)
function.source.add_code RegisterTransfer.new(function, Register.message_reg , :r8 )
r8 = RegisterValue.new( :r8 , :Message)
function.source.add_code RegisterTransfer.new(function, Register.message_reg , r8 )
end
def restore_message(function)
r8 = RegisterValue.new( :r8 , :Message)
return_tmp = Register.tmp_reg function.source.return_type
# get the sys return out of the way
function.source.add_code RegisterTransfer.new(function, Register.message_reg , return_tmp )
# load the stored message into the base RegisterMachine
function.source.add_code RegisterTransfer.new(function, :r8 , Register.message_reg )
function.source.add_code RegisterTransfer.new(function, r8 , Register.message_reg )
# save the return value into the message
function.source.add_code Register.set_slot( function, return_tmp , :message , :return_value )
# and "unroll" self and frame

View File

@ -30,12 +30,6 @@ module Register
def assigns
raise "abstract called for #{self.class}"
end
# wrap symbols into regsiter reference if needed
def wrap_register reg , type
return reg if reg.is_a? RegisterValue
RegisterValue.new(reg , type)
end
end
end

View File

@ -18,8 +18,10 @@ module Register
# Note: this may be reversed from some assembler notations (also arm)
def initialize source , from , to
super(source)
@from = wrap_register(from,:int)
@to = wrap_register(to,:int)
@from = from
@to = to
raise "Fix me #{from}" unless from.is_a? RegisterValue
raise "Fix me #{to}" unless to.is_a? RegisterValue
end
attr_reader :from, :to

View File

@ -10,6 +10,7 @@ module Register
raise "wrong type for register init #{r}" unless r.is_a? Symbol
raise "double r #{r}" if r.to_s[0,1] == "rr"
raise "not reg #{r}" unless self.class.look_like_reg r
raise "Legacy type error, should be class" if (type == :int) or (type == :ref)
@type = type
@symbol = r
@value = value
@ -39,10 +40,10 @@ module Register
end
#helper method to calculate with register symbols
def next_reg_use type
def next_reg_use type , value = nil
int = @symbol[1,3].to_i
sym = "r#{int + 1}".to_sym
RegisterValue.new( sym , type)
RegisterValue.new( sym , type, value)
end
def sof_reference_name