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
|
||||
# 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
|
||||
tmp = function.new_local
|
||||
function.instance_eval do
|
||||
sub( remainder , number , 10 )
|
||||
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: 16)
|
||||
mov( number , number , shift_lsr: 3)
|
||||
tmp = function.new_local
|
||||
add( tmp , number , number , shift_lsl: 2)
|
||||
sub( remainder , remainder , tmp , shift_lsl: 1 , update_status: 1)
|
||||
add( number , number, 1 , condition_code: :pl )
|
||||
|
@ -24,6 +24,7 @@ module Vm
|
||||
def initialize options
|
||||
@attributes = options
|
||||
end
|
||||
attr_reader :attributes
|
||||
def opcode
|
||||
@attributes[:opcode]
|
||||
end
|
||||
|
@ -30,9 +30,12 @@ module Vm
|
||||
next if n.nil?
|
||||
next unless kode.is_a? LogicInstruction
|
||||
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
|
||||
puts "KODE #{kode.result.inspect}"
|
||||
puts "N #{n.from.inspect}"
|
||||
puts "KODE #{kode.inspect} , #{kode.attributes.length}"
|
||||
puts "N #{n.inspect} , #{n.attributes.length}"
|
||||
kode.result = n.to
|
||||
block.codes.delete(n)
|
||||
end
|
||||
@ -50,6 +53,9 @@ module Vm
|
||||
next if n.nil?
|
||||
next unless kode.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
|
||||
kode.to = n.to
|
||||
block.codes.delete(n)
|
||||
@ -63,9 +69,12 @@ module Vm
|
||||
def run block
|
||||
block.codes.dup.each_with_index do |kode , index|
|
||||
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
|
||||
block.codes.delete(kode)
|
||||
puts "deleted noop move in #{block.name}"
|
||||
puts "deleted noop move in #{block.name} #{kode.inspect}"
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -89,9 +98,9 @@ module Vm
|
||||
block.codes.delete(push)
|
||||
block.next.codes.delete(pop)
|
||||
else
|
||||
puts "PUSH #{push}"
|
||||
#puts "PUSH #{push}"
|
||||
push.set_registers(locals)
|
||||
puts "POP #{pop}"
|
||||
#puts "POP #{pop}"
|
||||
pop.set_registers(locals)
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user