starting on risc allocation
inserting allocator stage in method translation
This commit is contained in:
@ -5,11 +5,13 @@ module Risc
|
||||
# upon request. they must be returned in order
|
||||
class Allocator
|
||||
|
||||
def initialize()
|
||||
def initialize( compiler , platform)
|
||||
@compiler = compiler
|
||||
@platform = platform
|
||||
@regs = []
|
||||
reset_regs
|
||||
end
|
||||
attr_reader :regs
|
||||
attr_reader :regs , :compiler , :platform
|
||||
|
||||
def regs_empty?
|
||||
@regs.empty?
|
||||
|
@ -18,10 +18,8 @@ module Risc
|
||||
def initialize( callable , slot_label)
|
||||
raise "No method" unless callable
|
||||
@callable = callable
|
||||
@allocator = Allocator.new
|
||||
@constants = []
|
||||
@current = @risc_instructions = slot_label.risc_label(self)
|
||||
@allocator.reset_regs
|
||||
end
|
||||
attr_reader :risc_instructions , :constants , :callable , :current
|
||||
|
||||
@ -137,11 +135,24 @@ module Risc
|
||||
|
||||
# translate this method, which means the method itself and all blocks inside it
|
||||
# returns the array (of assemblers) that you pass in as collection
|
||||
def translate_method( translator , collection)
|
||||
collection << translate_cpu( translator )
|
||||
# first arg is the platform object representing the platform that we
|
||||
# translate to
|
||||
#
|
||||
# This calls allocate_regs first, to change register naming to the platform
|
||||
#
|
||||
def translate_method( platform , collection)
|
||||
allocate_regs( platform )
|
||||
collection << translate_cpu( platform.translator )
|
||||
collection
|
||||
end
|
||||
|
||||
# allocate registers to the platform specific names (and amount)
|
||||
# This is actually done by the Allocator , with the help of the Platform
|
||||
# The Platform specifies how many registers there are, and the
|
||||
# Allocator changes SSA names to allocated names
|
||||
def allocate_regs(platform)
|
||||
allocator = Allocator.new(self , platform)
|
||||
end
|
||||
end
|
||||
end
|
||||
require_relative "allocator"
|
||||
|
@ -122,7 +122,7 @@ module Parfait
|
||||
List: {indexed_length: :Integer , next_list: :List} ,
|
||||
Message: { next_message: :Message, receiver: :Object, frame: :Object ,
|
||||
return_address: :Integer, return_value: :Object,
|
||||
caller: :Message , method: :TypedMethod ,
|
||||
caller: :Message , method: :CallableMethod ,
|
||||
arguments_given: :Integer ,
|
||||
arg1: :Object , arg2: :Object, arg3: :Object,
|
||||
arg4: :Object, arg5: :Object, arg6: :Object,
|
||||
|
@ -29,7 +29,7 @@ module Risc
|
||||
end
|
||||
|
||||
def class_name
|
||||
return :fixnum unless @type
|
||||
return :Integer unless @type
|
||||
@type.class_name
|
||||
end
|
||||
|
||||
|
@ -42,7 +42,7 @@ module Risc
|
||||
platform = Platform.for(platform_sym)
|
||||
assemblers = []
|
||||
@method_compilers.each_compiler do |compiler|
|
||||
compiler.translate_method( platform.translator , assemblers)
|
||||
compiler.translate_method( platform , assemblers)
|
||||
end
|
||||
Risc::Linker.new(platform , assemblers , constants)
|
||||
end
|
||||
|
Reference in New Issue
Block a user