unifying register comstants
were in several files with different names many files touched, but just renames
This commit is contained in:
@ -12,10 +12,12 @@ module Builtin
|
||||
function.info.blocks.last.codes.pop # no Method return
|
||||
#Set up the Space as self upon init
|
||||
space = Parfait::Space.object_space
|
||||
function.info.add_code Register::LoadConstant.new( space , Virtual::Slot::SELF_REGISTER)
|
||||
function.info.add_code Register::LoadConstant.new( space , Register::RegisterReference.self_reg)
|
||||
message_ind = space.get_layout().index_of( :next_message )
|
||||
# Load the message to message register (0)
|
||||
function.info.add_code Register::GetSlot.new( Virtual::Slot::SELF_REGISTER , message_ind , Virtual::Slot::MESSAGE_REGISTER)
|
||||
function.info.add_code Register::GetSlot.new( Register::RegisterReference.self_reg , message_ind , Register::RegisterReference.new_message_reg)
|
||||
# And store the space as the new self (so the call can move it back as self)
|
||||
function.info.add_code Register::SetSlot.new( Register::RegisterReference.self_reg , Register::RegisterReference.new_message_reg , Virtual::SELF_INDEX)
|
||||
# now we are set up to issue a call to the main
|
||||
function.info.add_code Virtual::MethodCall.new(Virtual.machine.space.get_main)
|
||||
emit_syscall( function , :exit )
|
||||
@ -56,22 +58,22 @@ module Builtin
|
||||
ind = Parfait::Space.object_space.get_layout().index_of( :syscall_message )
|
||||
raise "index not found for :syscall_message" unless ind
|
||||
function.info.add_code Register::LoadConstant.new( Parfait::Space.object_space , space_tmp)
|
||||
function.info.add_code Register::SetSlot.new( Virtual::Slot::MESSAGE_REGISTER , space_tmp , ind)
|
||||
function.info.add_code Register::SetSlot.new( Register::RegisterReference.message_reg , space_tmp , ind)
|
||||
end
|
||||
def restore_message(function)
|
||||
# get the sys return out of the way
|
||||
return_tmp = Register::RegisterReference.tmp_reg
|
||||
# load the space into the base register
|
||||
function.info.add_code Register::RegisterTransfer.new( return_tmp , Virtual::Slot::MESSAGE_REGISTER )
|
||||
function.info.add_code Register::RegisterTransfer.new( return_tmp , Register::RegisterReference.message_reg )
|
||||
slot = Virtual::Slot
|
||||
# find the stored message
|
||||
ind = Parfait::Space.object_space.get_layout().index_of( :syscall_message )
|
||||
raise "index not found for #{kind}.#{kind.class}" unless ind
|
||||
# and load it into the base RegisterMachine
|
||||
function.info.add_code Register::GetSlot.new( slot::MESSAGE_REGISTER , ind , slot::MESSAGE_REGISTER )
|
||||
function.info.add_code Register::GetSlot.new( Register::RegisterReference.message_reg , ind , Register::RegisterReference.message_reg )
|
||||
# and "unroll" self and frame
|
||||
function.info.add_code Register::GetSlot.new( slot::MESSAGE_REGISTER , Virtual::SELF_INDEX, slot::SELF_REGISTER )
|
||||
function.info.add_code Register::GetSlot.new( slot::MESSAGE_REGISTER , Virtual::FRAME_INDEX, slot::FRAME_REGISTER )
|
||||
function.info.add_code Register::GetSlot.new( Register::RegisterReference.message_reg , Virtual::SELF_INDEX, Register::RegisterReference.self_reg )
|
||||
function.info.add_code Register::GetSlot.new( Register::RegisterReference.message_reg , Virtual::FRAME_INDEX, Register::RegisterReference.frame_reg )
|
||||
end
|
||||
end
|
||||
extend ClassMethods
|
||||
|
@ -14,9 +14,9 @@ module Register
|
||||
new_codes = []
|
||||
slot = Virtual::Slot
|
||||
# move the current new_message to message
|
||||
new_codes << RegisterTransfer.new( slot::NEW_MESSAGE_REGISTER , slot::MESSAGE_REGISTER )
|
||||
new_codes << RegisterTransfer.new( RegisterReference.new_message_reg , RegisterReference.message_reg )
|
||||
# "roll out" self into its register
|
||||
new_codes << GetSlot.new( slot::MESSAGE_REGISTER , Virtual::SELF_INDEX, slot::SELF_REGISTER )
|
||||
new_codes << GetSlot.new( RegisterReference.message_reg , Virtual::SELF_INDEX, RegisterReference.self_reg )
|
||||
# do the register call
|
||||
new_codes << FunctionCall.new( code.method )
|
||||
block.replace(code , new_codes )
|
||||
|
@ -6,14 +6,14 @@ module Register
|
||||
next unless code.is_a? Virtual::MethodReturn
|
||||
new_codes = []
|
||||
# move the current message to new_message
|
||||
new_codes << RegisterTransfer.new( slot::MESSAGE_REGISTER , slot::NEW_MESSAGE_REGISTER )
|
||||
new_codes << RegisterTransfer.new( RegisterReference.message_reg , RegisterReference.new_message_reg )
|
||||
# and restore the message from saved value in new_message
|
||||
new_codes << GetSlot.new( slot::NEW_MESSAGE_REGISTER , Virtual::CALLER_INDEX , slot::MESSAGE_REGISTER)
|
||||
new_codes << GetSlot.new( RegisterReference.new_message_reg , Virtual::CALLER_INDEX , RegisterReference.message_reg)
|
||||
# "roll out" self and frame into their registers
|
||||
new_codes << GetSlot.new( slot::MESSAGE_REGISTER , Virtual::SELF_INDEX , slot::SELF_REGISTER )
|
||||
new_codes << GetSlot.new( slot::MESSAGE_REGISTER , Virtual::FRAME_INDEX , slot::FRAME_REGISTER )
|
||||
new_codes << GetSlot.new( RegisterReference.message_reg , Virtual::SELF_INDEX , RegisterReference.self_reg )
|
||||
new_codes << GetSlot.new( RegisterReference.message_reg , Virtual::FRAME_INDEX , RegisterReference.frame_reg )
|
||||
#load the return address into pc, affecting return. (other cpus have commands for this, but not arm)
|
||||
new_codes << FunctionReturn.new( slot::MESSAGE_REGISTER , Virtual::RETURN_INDEX )
|
||||
new_codes << FunctionReturn.new( RegisterReference.message_reg , Virtual::RETURN_INDEX )
|
||||
block.replace(code , new_codes )
|
||||
end
|
||||
end
|
||||
|
@ -48,27 +48,27 @@ module Register
|
||||
RegisterReference.new( sym )
|
||||
end
|
||||
|
||||
SELF_REG = :r0
|
||||
MESSAGE_REG = :r1
|
||||
FRAME_REG = :r2
|
||||
NEW_MESSAGE_REG = :r3
|
||||
MESSAGE_REGISTER = :r0
|
||||
SELF_REGISTER = :r1
|
||||
FRAME_REGISTER = :r2
|
||||
NEW_MESSAGE_REGISTER = :r3
|
||||
|
||||
TMP_REG = :r4
|
||||
TMP_REGISTER = :r4
|
||||
|
||||
def self.self_reg
|
||||
new SELF_REG
|
||||
new SELF_REGISTER
|
||||
end
|
||||
def self.message_reg
|
||||
new MESSAGE_REG
|
||||
new MESSAGE_REGISTER
|
||||
end
|
||||
def self.frame_reg
|
||||
new FRAME_REG
|
||||
new FRAME_REGISTER
|
||||
end
|
||||
def self.new_message_reg
|
||||
new NEW_MESSAGE_REG
|
||||
new NEW_MESSAGE_REGISTER
|
||||
end
|
||||
def self.tmp_reg
|
||||
new TMP_REG
|
||||
new TMP_REGISTER
|
||||
end
|
||||
|
||||
def sof_reference_name
|
||||
|
Reference in New Issue
Block a user