2014-10-05 00:05:18 +02:00
|
|
|
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 (?)
|
2014-10-05 00:05:18 +02:00
|
|
|
|
2015-05-30 11:20:39 +02:00
|
|
|
# the vm defines a register for the location, so we store it there.
|
2014-10-05 00:05:18 +02:00
|
|
|
|
|
|
|
class SaveImplementation
|
|
|
|
def run block
|
|
|
|
block.codes.dup.each do |code|
|
|
|
|
next unless code.is_a? Register::SaveReturn
|
|
|
|
store = ArmMachine.str( :lr , code.register , code.index )
|
|
|
|
block.replace(code , store )
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-05-12 14:36:44 +02:00
|
|
|
Virtual::Machine.instance.add_pass "Arm::SaveImplementation"
|
2014-10-05 00:05:18 +02:00
|
|
|
end
|