rubyx/lib/arm/passes/save_implementation.rb

20 lines
591 B
Ruby
Raw Normal View History

module Arm
# Arm stores the return address in a register (not on the stack)
2015-05-30 11:20:39 +02:00
# The register is called link , or lr for short .
# Maybe because it provides the "link" back to the caller (?)
2015-05-30 11:20:39 +02:00
# the vm defines a register for the location, so we store it there.
class SaveImplementation
def run block
block.codes.dup.each do |code|
next unless code.is_a? Register::SaveReturn
2015-06-28 09:52:02 +02:00
store = ArmMachine.str( :lr , code.register , 4 * code.index )
block.replace(code , store )
end
end
end
Virtual.machine.add_pass "Arm::SaveImplementation"
end