fixing and testing operators
This commit is contained in:
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user