fix putint (too eager optimization broke it)
This commit is contained in:
parent
506f98da5a
commit
8da1bc4645
@ -110,6 +110,7 @@ module Arm
|
|||||||
# Note about division: devision is MUCH more expensive than one would have thought
|
# Note about division: devision is MUCH more expensive than one would have thought
|
||||||
# And coding it is a bit of a mind leap: it's all about finding a a result that gets the
|
# And coding it is a bit of a mind leap: it's all about finding a a result that gets the
|
||||||
# remainder smaller than an int. i'll post some links sometime. This is from the arm manual
|
# remainder smaller than an int. i'll post some links sometime. This is from the arm manual
|
||||||
|
tmp = function.new_local
|
||||||
function.instance_eval do
|
function.instance_eval do
|
||||||
sub( remainder , number , 10 )
|
sub( remainder , number , 10 )
|
||||||
sub( number , number , number , shift_lsr: 2)
|
sub( number , number , number , shift_lsr: 2)
|
||||||
@ -117,7 +118,6 @@ module Arm
|
|||||||
add( number , number , number , shift_lsr: 8)
|
add( number , number , number , shift_lsr: 8)
|
||||||
add( number , number , number , shift_lsr: 16)
|
add( number , number , number , shift_lsr: 16)
|
||||||
mov( number , number , shift_lsr: 3)
|
mov( number , number , shift_lsr: 3)
|
||||||
tmp = function.new_local
|
|
||||||
add( tmp , number , number , shift_lsl: 2)
|
add( tmp , number , number , shift_lsl: 2)
|
||||||
sub( remainder , remainder , tmp , shift_lsl: 1 , update_status: 1)
|
sub( remainder , remainder , tmp , shift_lsl: 1 , update_status: 1)
|
||||||
add( number , number, 1 , condition_code: :pl )
|
add( number , number, 1 , condition_code: :pl )
|
||||||
|
@ -24,6 +24,7 @@ module Vm
|
|||||||
def initialize options
|
def initialize options
|
||||||
@attributes = options
|
@attributes = options
|
||||||
end
|
end
|
||||||
|
attr_reader :attributes
|
||||||
def opcode
|
def opcode
|
||||||
@attributes[:opcode]
|
@attributes[:opcode]
|
||||||
end
|
end
|
||||||
|
@ -30,9 +30,12 @@ module Vm
|
|||||||
next if n.nil?
|
next if n.nil?
|
||||||
next unless kode.is_a? LogicInstruction
|
next unless kode.is_a? LogicInstruction
|
||||||
next unless n.is_a? MoveInstruction
|
next unless n.is_a? MoveInstruction
|
||||||
|
# specific arm instructions, don't optimize as don't know what the extra mean
|
||||||
|
# small todo. This does not catch condition_code that are not :al
|
||||||
|
next if (n.attributes.length > 3) or (kode.attributes.length > 3)
|
||||||
if kode.result == n.from
|
if kode.result == n.from
|
||||||
puts "KODE #{kode.result.inspect}"
|
puts "KODE #{kode.inspect} , #{kode.attributes.length}"
|
||||||
puts "N #{n.from.inspect}"
|
puts "N #{n.inspect} , #{n.attributes.length}"
|
||||||
kode.result = n.to
|
kode.result = n.to
|
||||||
block.codes.delete(n)
|
block.codes.delete(n)
|
||||||
end
|
end
|
||||||
@ -50,6 +53,9 @@ module Vm
|
|||||||
next if n.nil?
|
next if n.nil?
|
||||||
next unless kode.is_a? MoveInstruction
|
next unless kode.is_a? MoveInstruction
|
||||||
next unless n.is_a? MoveInstruction
|
next unless n.is_a? MoveInstruction
|
||||||
|
# specific arm instructions, don't optimize as don't know what the extra mean
|
||||||
|
# small todo. This does not catch condition_code that are not :al
|
||||||
|
next if (n.attributes.length > 3) or (kode.attributes.length > 3)
|
||||||
if kode.to == n.from
|
if kode.to == n.from
|
||||||
kode.to = n.to
|
kode.to = n.to
|
||||||
block.codes.delete(n)
|
block.codes.delete(n)
|
||||||
@ -63,9 +69,12 @@ module Vm
|
|||||||
def run block
|
def run block
|
||||||
block.codes.dup.each_with_index do |kode , index|
|
block.codes.dup.each_with_index do |kode , index|
|
||||||
next unless kode.is_a? MoveInstruction
|
next unless kode.is_a? MoveInstruction
|
||||||
|
# specific arm instructions, don't optimize as don't know what the extra mean
|
||||||
|
# small todo. This does not catch condition_code that are not :al
|
||||||
|
next if (kode.attributes.length > 3)
|
||||||
if kode.to == kode.from
|
if kode.to == kode.from
|
||||||
block.codes.delete(kode)
|
block.codes.delete(kode)
|
||||||
puts "deleted noop move in #{block.name}"
|
puts "deleted noop move in #{block.name} #{kode.inspect}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -89,9 +98,9 @@ module Vm
|
|||||||
block.codes.delete(push)
|
block.codes.delete(push)
|
||||||
block.next.codes.delete(pop)
|
block.next.codes.delete(pop)
|
||||||
else
|
else
|
||||||
puts "PUSH #{push}"
|
#puts "PUSH #{push}"
|
||||||
push.set_registers(locals)
|
push.set_registers(locals)
|
||||||
puts "POP #{pop}"
|
#puts "POP #{pop}"
|
||||||
pop.set_registers(locals)
|
pop.set_registers(locals)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user