first local assignment risc test

comes with casualties
slot_load needs more work
This commit is contained in:
Torsten Ruger
2018-03-17 11:13:44 +05:30
parent 3eef27be76
commit 16c8fcbf66
6 changed files with 54 additions and 32 deletions

View File

@ -4,6 +4,9 @@ module Mom
class Instruction
include Common::List
def to_risc(m)
Risc::Label.new(self.class.name, self.class.name + "_todo")
end
# implement flatten as noop to avoid condition
def flatten( options = {} )
return self

View File

@ -32,11 +32,11 @@ module Mom
@left , @right = left , right
end
def to_risc_load(context)
reg = context.use_reg( @right.ct_type)
def to_risc(compiler)
reg = compiler.use_reg( @right.ct_type)
const = Risc.load_constant(self, @right , reg)
const.set_next Risc.reg_to_slot(self, reg , @left.known_object, @left.slots.first)
context.release_reg(reg)
const << Risc.reg_to_slot(self, reg , @left.known_object, @left.slots.first)
compiler.release_reg(reg)
return const
end

View File

@ -94,8 +94,8 @@ module Risc
# (adding moves the insertion point so the whole mom chain is added as a risc chain)
def add_mom( instruction )
raise "whats this a #{instruction}" unless instruction.is_a?(Mom::Instruction)
return
while( instruction )
#puts "adding #{instruction.to_s}:#{instruction.next.to_s}"
risc = instruction.to_risc( self )
add_code(risc)
instruction = instruction.next
@ -104,7 +104,7 @@ module Risc
# add a risc instruction after the current (insertion point)
# the added instruction will become the new insertion point
def add_code( instruction )
raise instruction.to_s unless instruction.is_a?(Risc::Instruction)
raise "Not an instruction:#{instruction.to_s}" unless instruction.is_a?(Risc::Instruction)
raise instruction.to_s if( instruction.class.name.split("::").first == "Arm")
@current.insert(instruction) #insert after current
@current = instruction