2014-10-05 00:05:18 +02:00
|
|
|
module Arm
|
|
|
|
|
|
|
|
class ConstantImplementation
|
|
|
|
def run block
|
|
|
|
block.codes.dup.each do |code|
|
|
|
|
next unless code.is_a? Register::LoadConstant
|
2015-06-26 19:01:52 +02:00
|
|
|
constant = code.constant
|
|
|
|
|
|
|
|
if constant.is_a?(Parfait::Object) or constant.is_a? Symbol
|
2015-06-26 19:36:00 +02:00
|
|
|
load = ArmMachine.add( code.register , constant )
|
2015-06-26 19:01:52 +02:00
|
|
|
else
|
|
|
|
load = ArmMachine.mov( code.register , code.constant )
|
|
|
|
end
|
2014-10-05 00:05:18 +02:00
|
|
|
block.replace(code , load )
|
2015-05-30 10:56:47 +02:00
|
|
|
#puts "replaced #{load.inspect.to_s[0..1000]}"
|
2014-10-05 00:05:18 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-06-01 07:40:17 +02:00
|
|
|
Virtual.machine.add_pass "Arm::ConstantImplementation"
|
2014-10-05 00:05:18 +02:00
|
|
|
end
|