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