@Nonnull private BuilderInstruction51l newBuilderInstruction51l(@Nonnull Instruction51l instruction) { return new BuilderInstruction51l( instruction.getOpcode(), instruction.getRegisterA(), instruction.getWideLiteral()); }
public static BuilderInstruction buildConstant(double value, int register) { long longBits = Double.doubleToLongBits(value); String binaryValue = Long.toBinaryString(longBits); BuilderInstruction result; if (binaryValue.endsWith(LAST_48_BITS_ZERO)) { result = new BuilderInstruction21lh(Opcode.CONST_WIDE_HIGH16, register, longBits); } else { result = new BuilderInstruction51l(Opcode.CONST_WIDE, register, longBits); } return result; }
public static BuilderInstruction buildConstant(long value, int register) { BuilderInstruction result; int bitCount = Long.SIZE - Long.numberOfLeadingZeros(value); if (bitCount < 16 && (register & 0xFFFFFF00) == 0) { result = new BuilderInstruction21s(Opcode.CONST_WIDE_16, register, (int) value); } else if (bitCount < 32 && (register & 0xFFFFFF00) == 0) { result = new BuilderInstruction31i(Opcode.CONST_WIDE_32, register, (int) value); } else { result = new BuilderInstruction51l(Opcode.CONST_WIDE, register, value); } return result; }
@Override protected BuilderInstruction getRealInsn0(LabelAssigner assigner) { return new BuilderInstruction51l(opc, (short) getRegA().getNumber(), getLitB()); }
@Test public void withLast48BitsNotZero() { double value = 127.01; long longBits = Double.doubleToLongBits(value); Instruction expected = new BuilderInstruction51l(Opcode.CONST_WIDE, REGISTER, longBits); Instruction actual = ConstantBuilder.buildConstant(value, REGISTER); testEquals(expected, actual); }
@Test public void withNegative25BitLiteral() { long value = 0 - (long) (Math.pow(2, 25) - 1); Instruction expected = new BuilderInstruction51l(Opcode.CONST_WIDE, REGISTER, value); Instruction actual = ConstantBuilder.buildConstant(value, REGISTER); testEquals(expected, actual); } }
@Test public void with64BitLiteral() { long value = Long.MAX_VALUE; Instruction expected = new BuilderInstruction51l(Opcode.CONST_WIDE, REGISTER, value); Instruction actual = ConstantBuilder.buildConstant(value, REGISTER); testEquals(expected, actual); }
method_stack.peek().methodBuilder.addInstruction(new BuilderInstruction51l(opcode, regA, litB));
@Nonnull private BuilderInstruction51l newBuilderInstruction51l(@Nonnull Instruction51l instruction) { return new BuilderInstruction51l( instruction.getOpcode(), instruction.getRegisterA(), instruction.getWideLiteral()); }
@Nonnull private BuilderInstruction51l newBuilderInstruction51l(@Nonnull Instruction51l instruction) { return new BuilderInstruction51l( instruction.getOpcode(), instruction.getRegisterA(), instruction.getWideLiteral()); }
@Nonnull private BuilderInstruction51l newBuilderInstruction51l(@Nonnull Instruction51l instruction) { return new BuilderInstruction51l( instruction.getOpcode(), instruction.getRegisterA(), instruction.getWideLiteral()); }
@Nonnull private BuilderInstruction51l newBuilderInstruction51l(@Nonnull Instruction51l instruction) { return new BuilderInstruction51l( instruction.getOpcode(), instruction.getRegisterA(), instruction.getWideLiteral()); }
method_stack.peek().methodBuilder.addInstruction(new BuilderInstruction51l(opcode, regA, litB));
method_stack.peek().methodBuilder.addInstruction(new BuilderInstruction51l(opcode, regA, litB));