remove NumLiteral, replace with IntegerConstant
This commit is contained in:
parent
d6b5d46165
commit
a5b4f3d9ad
@ -32,14 +32,14 @@ module Arm
|
|||||||
arg = @attributes[:left]
|
arg = @attributes[:left]
|
||||||
#puts "BLAB #{arg.inspect}"
|
#puts "BLAB #{arg.inspect}"
|
||||||
if( arg.is_a? Fixnum ) #HACK to not have to change the code just now
|
if( arg.is_a? Fixnum ) #HACK to not have to change the code just now
|
||||||
arg = Arm::NumLiteral.new( arg )
|
arg = Vm::IntegerConstant.new( arg )
|
||||||
end
|
end
|
||||||
if arg.is_a? Vm::Code
|
if arg.is_a? Vm::Block
|
||||||
diff = arg.position - self.position - 8
|
diff = arg.position - self.position - 8
|
||||||
arg = Arm::NumLiteral.new(diff)
|
arg = Vm::IntegerConstant.new(diff)
|
||||||
end
|
end
|
||||||
if (arg.is_a?(Arm::NumLiteral))
|
if (arg.is_a?(Vm::IntegerConstant))
|
||||||
jmp_val = arg.value >> 2
|
jmp_val = arg.integer >> 2
|
||||||
packed = [jmp_val].pack('l')
|
packed = [jmp_val].pack('l')
|
||||||
# signed 32-bit, condense to 24-bit
|
# signed 32-bit, condense to 24-bit
|
||||||
# TODO add check that the value fits into 24 bits
|
# TODO add check that the value fits into 24 bits
|
||||||
@ -51,10 +51,10 @@ module Arm
|
|||||||
when :swi
|
when :swi
|
||||||
arg = @attributes[:left]
|
arg = @attributes[:left]
|
||||||
if( arg.is_a? Fixnum ) #HACK to not have to change the code just now
|
if( arg.is_a? Fixnum ) #HACK to not have to change the code just now
|
||||||
arg = Arm::NumLiteral.new( arg )
|
arg = Vm::IntegerConstant.new( arg )
|
||||||
end
|
end
|
||||||
if (arg.is_a?(Arm::NumLiteral))
|
if (arg.is_a?(Vm::IntegerConstant))
|
||||||
packed = [arg.value].pack('L')[0,3]
|
packed = [arg.integer].pack('L')[0,3]
|
||||||
io << packed
|
io << packed
|
||||||
io.write_uint8 0b1111 | (COND_CODES[@attributes[:condition_code]] << 4)
|
io.write_uint8 0b1111 | (COND_CODES[@attributes[:condition_code]] << 4)
|
||||||
else
|
else
|
||||||
|
@ -25,19 +25,19 @@ module Arm
|
|||||||
if arg.is_a?(Vm::StringConstant)
|
if arg.is_a?(Vm::StringConstant)
|
||||||
# do pc relative addressing with the difference to the instuction
|
# do pc relative addressing with the difference to the instuction
|
||||||
# 8 is for the funny pipeline adjustment (ie oc pointing to fetch and not execute)
|
# 8 is for the funny pipeline adjustment (ie oc pointing to fetch and not execute)
|
||||||
arg = Arm::NumLiteral.new( arg.position - self.position - 8 )
|
arg = Vm::IntegerConstant.new( arg.position - self.position - 8 )
|
||||||
@rn = :pc
|
@rn = :pc
|
||||||
end
|
end
|
||||||
if( arg.is_a? Fixnum ) #HACK to not have to change the code just now
|
if( arg.is_a? Fixnum ) #HACK to not have to change the code just now
|
||||||
arg = Arm::NumLiteral.new( arg )
|
arg = Vm::IntegerConstant.new( arg )
|
||||||
end
|
end
|
||||||
if( arg.is_a? Vm::Integer ) #HACK to not have to change the code just now
|
if( arg.is_a? Vm::Integer ) #HACK to not have to change the code just now
|
||||||
arg = Arm::NumLiteral.new( arg.value )
|
arg = Vm::IntegerConstant.new( arg.value )
|
||||||
end
|
end
|
||||||
if (arg.is_a?(Arm::NumLiteral))
|
if (arg.is_a?(Vm::IntegerConstant))
|
||||||
if (arg.value.fits_u8?)
|
if (arg.integer.fits_u8?)
|
||||||
# no shifting needed
|
# no shifting needed
|
||||||
@operand = arg.value
|
@operand = arg.integer
|
||||||
@i = 1
|
@i = 1
|
||||||
elsif (op_with_rot = calculate_u8_with_rr(arg))
|
elsif (op_with_rot = calculate_u8_with_rr(arg))
|
||||||
@operand = op_with_rot
|
@operand = op_with_rot
|
||||||
@ -59,7 +59,7 @@ module Arm
|
|||||||
end
|
end
|
||||||
|
|
||||||
arg1 = arg.value
|
arg1 = arg.value
|
||||||
if (arg1.is_a?(Arm::NumLiteral))
|
if (arg1.is_a?(Vm::IntegerConstant))
|
||||||
if (arg1.value >= 32)
|
if (arg1.value >= 32)
|
||||||
raise "cannot shift by more than 31 #{arg1} #{inspect}"
|
raise "cannot shift by more than 31 #{arg1} #{inspect}"
|
||||||
end
|
end
|
||||||
|
@ -57,7 +57,7 @@ module Arm
|
|||||||
if (@operand.abs > 4095)
|
if (@operand.abs > 4095)
|
||||||
raise "reference offset too large/small (max 4095) #{arg} #{inspect}"
|
raise "reference offset too large/small (max 4095) #{arg} #{inspect}"
|
||||||
end
|
end
|
||||||
elsif (arg.is_a?(Arm::Label) or arg.is_a?(Arm::NumLiteral))
|
elsif (arg.is_a?(Arm::Label) or arg.is_a?(Vm::IntegerConstant))
|
||||||
@pre_post_index = 1
|
@pre_post_index = 1
|
||||||
@rn = pc
|
@rn = pc
|
||||||
@use_addrtable_reloc = true
|
@use_addrtable_reloc = true
|
||||||
|
@ -34,11 +34,4 @@ module Arm
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class NumLiteral
|
|
||||||
attr_accessor :value
|
|
||||||
def initialize val
|
|
||||||
@value = val
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user