pass extra info into register init, not just value

extra info may be hash, maybe just type info
This commit is contained in:
Torsten Ruger
2018-07-16 11:23:09 +03:00
parent b410538d07
commit e3673e579c
5 changed files with 22 additions and 17 deletions

View File

@ -53,12 +53,13 @@ module Risc
end
# require a (temporary) register. code must give this back with release_reg
def use_reg( type , value = nil )
# Second extra parameter may give extra info about the value, see RegisterValue
def use_reg( type , extra = {} )
raise "Not type #{type.inspect}" unless type.is_a?(Symbol) or type.is_a?(Parfait::Type)
if @regs.empty?
reg = Risc.tmp_reg(type , value)
reg = Risc.tmp_reg(type , extra)
else
reg = @regs.last.next_reg_use(type , value)
reg = @regs.last.next_reg_use(type , extra)
end
@regs << reg
return reg