move most code from method_compiler to builder
rather use builder in two ways, than sometimes compiler and sometimes builder Also makes it possible to reuse builtin code in mom’s to_risc, as both use builder. The builtin code by directly adding to compiler, the mom code not.
This commit is contained in:
@ -73,17 +73,17 @@ module Risc
|
||||
else
|
||||
raise "not implemented"
|
||||
end
|
||||
builder.add(ins) if builder
|
||||
builder.add_code(ins) if builder
|
||||
return ins
|
||||
end
|
||||
|
||||
def -( right )
|
||||
raise "operators only on registers, not #{right.class}" unless right.is_a? RiscValue
|
||||
op = Risc.op("#{self.type} - #{right.type}", :- , self , right )
|
||||
builder.add(op) if builder
|
||||
builder.add_code(op) if builder
|
||||
op
|
||||
end
|
||||
|
||||
|
||||
# just capture the values in an intermediary object (RValue)
|
||||
# The RValue then gets used in a RegToSlot ot SlotToReg, where
|
||||
# the values are unpacked to call Risc.reg_to_slot or Risc.slot_to_reg
|
||||
@ -105,7 +105,7 @@ module Risc
|
||||
def <<( reg )
|
||||
raise "not reg #{reg}" unless reg.is_a?(RiscValue)
|
||||
reg_to_slot = Risc.reg_to_slot("#{reg.type} -> #{register.type}[#{index}]" , reg , register, index)
|
||||
builder.add(reg_to_slot) if builder
|
||||
builder.add_code(reg_to_slot) if builder
|
||||
reg_to_slot
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user