making good headway with register machine implementation in arm
This commit is contained in:
parent
7968cadaf9
commit
3aca3cc33d
@ -15,5 +15,5 @@ module Arm
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Virtual::BootSpace.space.add_pass_after "Arm::CallImplementation" , "Register::SetImplementation"
|
Virtual::BootSpace.space.add_pass "Arm::CallImplementation"
|
||||||
end
|
end
|
||||||
|
13
lib/arm/passes/constant_implementation.rb
Normal file
13
lib/arm/passes/constant_implementation.rb
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
module Arm
|
||||||
|
|
||||||
|
class ConstantImplementation
|
||||||
|
def run block
|
||||||
|
block.codes.dup.each do |code|
|
||||||
|
next unless code.is_a? Register::LoadConstant
|
||||||
|
load = ArmMachine.ldr( code.value , code.constant )
|
||||||
|
block.replace(code , load )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Virtual::BootSpace.space.add_pass "Arm::ConstantImplementation"
|
||||||
|
end
|
13
lib/arm/passes/get_implementation.rb
Normal file
13
lib/arm/passes/get_implementation.rb
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
module Arm
|
||||||
|
|
||||||
|
class GetImplementation
|
||||||
|
def run block
|
||||||
|
block.codes.dup.each do |code|
|
||||||
|
next unless code.is_a? Register::GetSlot
|
||||||
|
load = ArmMachine.ldr( code.value , code.reference , code.index )
|
||||||
|
block.replace(code , load )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Virtual::BootSpace.space.add_pass "Arm::GetImplementation"
|
||||||
|
end
|
13
lib/arm/passes/return_implementation.rb
Normal file
13
lib/arm/passes/return_implementation.rb
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
module Arm
|
||||||
|
|
||||||
|
class ReturnImplementation
|
||||||
|
def run block
|
||||||
|
block.codes.dup.each do |code|
|
||||||
|
next unless code.is_a? Register::FunctionReturn
|
||||||
|
load = ArmMachine.ldr( :pc , code.register , code.index )
|
||||||
|
block.replace(code , load )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Virtual::BootSpace.space.add_pass "Arm::ReturnImplementation"
|
||||||
|
end
|
18
lib/arm/passes/save_implementation.rb
Normal file
18
lib/arm/passes/save_implementation.rb
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
module Arm
|
||||||
|
|
||||||
|
# Arm stores the return address in a register (not on the stack)
|
||||||
|
# The register is called link , or lr for short . Maybe because it provides the "link" back to the caller (?)
|
||||||
|
|
||||||
|
# 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
|
||||||
|
store = ArmMachine.str( :lr , code.register , code.index )
|
||||||
|
block.replace(code , store )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Virtual::BootSpace.space.add_pass "Arm::SaveImplementation"
|
||||||
|
end
|
13
lib/arm/passes/set_implementation.rb
Normal file
13
lib/arm/passes/set_implementation.rb
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
module Arm
|
||||||
|
|
||||||
|
class SetImplementation
|
||||||
|
def run block
|
||||||
|
block.codes.dup.each do |code|
|
||||||
|
next unless code.is_a? Register::SetSlot
|
||||||
|
store = ArmMachine.str( code.value , code.reference , code.index )
|
||||||
|
block.replace(code , store )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Virtual::BootSpace.space.add_pass "Arm::SetImplementation"
|
||||||
|
end
|
13
lib/arm/passes/transfer_implementation.rb
Normal file
13
lib/arm/passes/transfer_implementation.rb
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
module Arm
|
||||||
|
|
||||||
|
class TransferImplementation
|
||||||
|
def run block
|
||||||
|
block.codes.dup.each do |code|
|
||||||
|
next unless code.is_a? Register::RegisterTransfer
|
||||||
|
move = ArmMachine.mov( code.from , code.to )
|
||||||
|
block.replace(code , move )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Virtual::BootSpace.space.add_pass "Arm::TransferImplementation"
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user