Search in sources :

Example 6 with AArch64MacroAssembler

use of org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler in project graal by oracle.

the class AArch64Move method reg2stack.

private static void reg2stack(CompilationResultBuilder crb, AArch64MacroAssembler masm, AllocatableValue result, AllocatableValue input) {
    AArch64Address dest = loadStackSlotAddress(crb, masm, asStackSlot(result), Value.ILLEGAL);
    Register src = asRegister(input);
    // use the slot kind to define the operand size
    AArch64Kind kind = (AArch64Kind) result.getPlatformKind();
    final int size = kind.getSizeInBytes() * Byte.SIZE;
    if (kind.isInteger()) {
        masm.str(size, src, dest);
    } else {
        masm.fstr(size, src, dest);
    }
}
Also used : Register(jdk.vm.ci.code.Register) ValueUtil.isRegister(jdk.vm.ci.code.ValueUtil.isRegister) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) ScratchRegister(org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler.ScratchRegister) AArch64Kind(jdk.vm.ci.aarch64.AArch64Kind) AArch64Address(org.graalvm.compiler.asm.aarch64.AArch64Address)

Example 7 with AArch64MacroAssembler

use of org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler in project graal by oracle.

the class AArch64Move method const2reg.

private static void const2reg(CompilationResultBuilder crb, AArch64MacroAssembler masm, Value result, JavaConstant input) {
    Register dst = asRegister(result);
    switch(input.getJavaKind().getStackKind()) {
        case Int:
            final int value = input.asInt();
            int maskedValue;
            switch(input.getJavaKind()) {
                case Boolean:
                case Byte:
                    maskedValue = value & 0xFF;
                    break;
                case Char:
                case Short:
                    maskedValue = value & 0xFFFF;
                    break;
                case Int:
                    maskedValue = value;
                    break;
                default:
                    throw GraalError.shouldNotReachHere();
            }
            masm.mov(dst, maskedValue);
            break;
        case Long:
            masm.mov(dst, input.asLong());
            break;
        case Float:
            if (AArch64MacroAssembler.isFloatImmediate(input.asFloat())) {
                masm.fmov(32, dst, input.asFloat());
            } else {
                masm.fldr(32, dst, (AArch64Address) crb.asFloatConstRef(input));
            }
            break;
        case Double:
            if (AArch64MacroAssembler.isDoubleImmediate(input.asDouble())) {
                masm.fmov(64, dst, input.asDouble());
            } else {
                masm.fldr(64, dst, (AArch64Address) crb.asDoubleConstRef(input));
            }
            break;
        case Object:
            if (input.isNull()) {
                masm.mov(dst, 0);
            } else if (crb.target.inlineObjects) {
                crb.recordInlineDataInCode(input);
                masm.movNativeAddress(dst, 0xDEADDEADDEADDEADL);
            } else {
                masm.ldr(64, dst, (AArch64Address) crb.recordDataReferenceInCode(input, 8));
            }
            break;
        default:
            throw GraalError.shouldNotReachHere("kind=" + input.getJavaKind().getStackKind());
    }
}
Also used : Register(jdk.vm.ci.code.Register) ValueUtil.isRegister(jdk.vm.ci.code.ValueUtil.isRegister) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) ScratchRegister(org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler.ScratchRegister) AArch64Address(org.graalvm.compiler.asm.aarch64.AArch64Address)

Example 8 with AArch64MacroAssembler

use of org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler in project graal by oracle.

the class AArch64ArrayEqualsOp method emit8ByteCompare.

/**
 * Emits code that uses 8-byte vector compares.
 */
private void emit8ByteCompare(CompilationResultBuilder crb, AArch64MacroAssembler masm, Register result, Register array1, Register array2, Register length, Label breakLabel, Register rscratch1) {
    Label loop = new Label();
    Label compareTail = new Label();
    Register temp = asRegister(temp4);
    // tail count (in bytes)
    masm.and(64, result, result, VECTOR_SIZE - 1);
    // vector count (in bytes)
    masm.ands(64, length, length, ~(VECTOR_SIZE - 1));
    masm.branchConditionally(ConditionFlag.EQ, compareTail);
    masm.lea(array1, AArch64Address.createRegisterOffsetAddress(array1, length, false));
    masm.lea(array2, AArch64Address.createRegisterOffsetAddress(array2, length, false));
    masm.sub(64, length, zr, length);
    // Align the main loop
    masm.align(crb.target.wordSize * 2);
    masm.bind(loop);
    masm.ldr(64, temp, AArch64Address.createRegisterOffsetAddress(array1, length, false));
    masm.ldr(64, rscratch1, AArch64Address.createRegisterOffsetAddress(array2, length, false));
    masm.eor(64, rscratch1, temp, rscratch1);
    masm.cbnz(64, rscratch1, breakLabel);
    masm.add(64, length, length, VECTOR_SIZE);
    masm.cbnz(64, length, loop);
    masm.cbz(64, result, breakLabel);
    /*
         * Compare the remaining bytes with an unaligned memory load aligned to the end of the
         * array.
         */
    masm.lea(array1, AArch64Address.createUnscaledImmediateAddress(array1, -VECTOR_SIZE));
    masm.lea(array2, AArch64Address.createUnscaledImmediateAddress(array2, -VECTOR_SIZE));
    masm.ldr(64, temp, AArch64Address.createRegisterOffsetAddress(array1, result, false));
    masm.ldr(64, rscratch1, AArch64Address.createRegisterOffsetAddress(array2, result, false));
    masm.eor(64, rscratch1, temp, rscratch1);
    masm.jmp(breakLabel);
    masm.bind(compareTail);
}
Also used : ScratchRegister(org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler.ScratchRegister) Register(jdk.vm.ci.code.Register) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) Label(org.graalvm.compiler.asm.Label)

Example 9 with AArch64MacroAssembler

use of org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler in project graal by oracle.

the class AArch64ArrayEqualsOp method emitCode.

@Override
public void emitCode(CompilationResultBuilder crb, AArch64MacroAssembler masm) {
    Register result = asRegister(resultValue);
    Register array1 = asRegister(temp1);
    Register array2 = asRegister(temp2);
    Register length = asRegister(temp3);
    Label breakLabel = new Label();
    try (ScratchRegister sc1 = masm.getScratchRegister()) {
        Register rscratch1 = sc1.getRegister();
        // Load array base addresses.
        masm.lea(array1, AArch64Address.createUnscaledImmediateAddress(asRegister(array1Value), arrayBaseOffset));
        masm.lea(array2, AArch64Address.createUnscaledImmediateAddress(asRegister(array2Value), arrayBaseOffset));
        // Get array length in bytes.
        masm.mov(rscratch1, arrayIndexScale);
        masm.smaddl(length, asRegister(lengthValue), rscratch1, zr);
        // copy
        masm.mov(64, result, length);
        emit8ByteCompare(crb, masm, result, array1, array2, length, breakLabel, rscratch1);
        emitTailCompares(masm, result, array1, array2, breakLabel, rscratch1);
        // Return: rscratch1 is non-zero iff the arrays differ
        masm.bind(breakLabel);
        masm.cmp(64, rscratch1, zr);
        masm.cset(result, ConditionFlag.EQ);
    }
}
Also used : ScratchRegister(org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler.ScratchRegister) ScratchRegister(org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler.ScratchRegister) Register(jdk.vm.ci.code.Register) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) Label(org.graalvm.compiler.asm.Label)

Example 10 with AArch64MacroAssembler

use of org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler in project graal by oracle.

the class AArch64HotSpotJumpToExceptionHandlerInCallerOp method emitCode.

@Override
public void emitCode(CompilationResultBuilder crb, AArch64MacroAssembler masm) {
    leaveFrame(crb, masm, /* emitSafepoint */
    false);
    if (System.getProperty("java.specification.version").compareTo("1.8") < 0) {
        // Restore sp from fp if the exception PC is a method handle call site.
        try (ScratchRegister sc = masm.getScratchRegister()) {
            Register scratch = sc.getRegister();
            AArch64Address address = masm.makeAddress(thread, isMethodHandleReturnOffset, scratch, 4, /* allowOverwrite */
            false);
            masm.ldr(32, scratch, address);
            Label noRestore = new Label();
            masm.cbz(32, scratch, noRestore);
            masm.mov(64, sp, fp);
            masm.bind(noRestore);
        }
    }
    masm.jmp(asRegister(handlerInCallerPc));
}
Also used : ScratchRegister(org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler.ScratchRegister) ScratchRegister(org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler.ScratchRegister) Register(jdk.vm.ci.code.Register) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) Label(org.graalvm.compiler.asm.Label) AArch64Address(org.graalvm.compiler.asm.aarch64.AArch64Address)

Aggregations

ScratchRegister (org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler.ScratchRegister)15 Register (jdk.vm.ci.code.Register)13 ValueUtil.asRegister (jdk.vm.ci.code.ValueUtil.asRegister)11 AArch64Address (org.graalvm.compiler.asm.aarch64.AArch64Address)9 Label (org.graalvm.compiler.asm.Label)6 ValueUtil.isRegister (jdk.vm.ci.code.ValueUtil.isRegister)4 AArch64MacroAssembler (org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler)4 AArch64Kind (jdk.vm.ci.aarch64.AArch64Kind)3 ValueUtil.asAllocatableValue (jdk.vm.ci.code.ValueUtil.asAllocatableValue)2 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)2 HotSpotProviders (org.graalvm.compiler.hotspot.meta.HotSpotProviders)2 CallingConvention (jdk.vm.ci.code.CallingConvention)1 RegisterConfig (jdk.vm.ci.code.RegisterConfig)1 StackSlot (jdk.vm.ci.code.StackSlot)1 TargetDescription (jdk.vm.ci.code.TargetDescription)1 ValueUtil.asStackSlot (jdk.vm.ci.code.ValueUtil.asStackSlot)1 ValueUtil.isStackSlot (jdk.vm.ci.code.ValueUtil.isStackSlot)1 AArch64HotSpotRegisterConfig (jdk.vm.ci.hotspot.aarch64.AArch64HotSpotRegisterConfig)1 PlatformKind (jdk.vm.ci.meta.PlatformKind)1 Value (jdk.vm.ci.meta.Value)1