module RubyVM::RJIT::OperandMatcher

Public Instance Methods

extended_reg?(reg) click to toggle source
# File ruby_vm/rjit/assembler.rb, line 1127
def extended_reg?(reg)
  reg_code_extended(reg).last
end
imm32?(imm) click to toggle source
# File ruby_vm/rjit/assembler.rb, line 1103
def imm32?(imm)
  (-0x8000_0000..0x7fff_ffff).include?(imm) # TODO: consider uimm
end
imm64?(imm) click to toggle source
# File ruby_vm/rjit/assembler.rb, line 1107
def imm64?(imm)
  (-0x8000_0000_0000_0000..0xffff_ffff_ffff_ffff).include?(imm)
end
imm8?(imm) click to toggle source
# File ruby_vm/rjit/assembler.rb, line 1099
def imm8?(imm)
  (-0x80..0x7f).include?(imm)
end
r32?(reg) click to toggle source
# File ruby_vm/rjit/assembler.rb, line 1111
def r32?(reg)
  if extended_reg?(reg)
    reg.end_with?('d')
  else
    reg.start_with?('e')
  end
end
r64?(reg) click to toggle source
# File ruby_vm/rjit/assembler.rb, line 1119
def r64?(reg)
  if extended_reg?(reg)
    reg.match?(/\Ar\d+\z/)
  else
    reg.start_with?('r')
  end
end
reg_code_extended(reg) click to toggle source
# File ruby_vm/rjit/assembler.rb, line 1131
def reg_code_extended(reg)
  case reg
  # Not extended
  when :al, :ax, :eax, :rax then [0, false]
  when :cl, :cx, :ecx, :rcx then [1, false]
  when :dl, :dx, :edx, :rdx then [2, false]
  when :bl, :bx, :ebx, :rbx then [3, false]
  when :ah, :sp, :esp, :rsp then [4, false]
  when :ch, :bp, :ebp, :rbp then [5, false]
  when :dh, :si, :esi, :rsi then [6, false]
  when :bh, :di, :edi, :rdi then [7, false]
  # Extended
  when :r8b,  :r8w,  :r8d,  :r8  then [0, true]
  when :r9b,  :r9w,  :r9d,  :r9  then [1, true]
  when :r10b, :r10w, :r10d, :r10 then [2, true]
  when :r11b, :r11w, :r11d, :r11 then [3, true]
  when :r12b, :r12w, :r12d, :r12 then [4, true]
  when :r13b, :r13w, :r13d, :r13 then [5, true]
  when :r14b, :r14w, :r14d, :r14 then [6, true]
  when :r15b, :r15w, :r15d, :r15 then [7, true]
  else raise ArgumentError, "unexpected reg: #{reg.inspect}"
  end
end