Return to_risc

remove the index from FunctionReturn, just jump to the register address
This commit is contained in:
Torsten Ruger 2018-03-21 15:48:50 +05:30
parent b4489b1093
commit 61a801b00c
2 changed files with 18 additions and 9 deletions

View File

@ -19,8 +19,18 @@ module Mom
# set of lower level instructions.
#
class ReturnSequence < Instruction
def to_risc(context)
Risc::Label.new(self,"ReturnSequence")
def to_risc(compiler)
return_move = SlotLoad.new( [:message ,:return_value] , [:message , :next_message, :return_value])
moves = return_move.to_risc(compiler)
caller_reg = compiler.use_reg(:int)
return_reg = compiler.use_reg(:int)
compiler.reset_regs
caller_index = Risc.resolve_to_index(:message , :caller)
return_index = Risc.resolve_to_index(:message , :return_address)
moves << Risc::SlotToReg.new(self, Risc.message_reg , caller_index , caller_reg)
moves << Risc::Transfer.new(self, caller_reg , Risc.message_reg)
moves << Risc::SlotToReg.new(self, Risc.message_reg, return_index , return_reg)
moves << Risc::FunctionReturn.new(self, return_reg)
end
end

View File

@ -1,22 +1,21 @@
module Risc
# return from a function call
# register and index specify where the return address is stored
# register specifes where the return address is stored
class FunctionReturn < Instruction
def initialize( source , register , index)
def initialize( source , register )
super(source)
@register = register
@index = index
end
attr_reader :register , :index
attr_reader :register
def to_s
"FunctionReturn: #{register} [#{index}]"
"FunctionReturn: #{register} "
end
end
def self.function_return( source , register , index)
FunctionReturn.new( source , register , index)
def self.function_return( source , register )
FunctionReturn.new( source , register )
end
end