Search in sources :

Example 1 with AArch64Address

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

the class AArch64HotSpotBackend method emitCodePrefix.

private void emitCodePrefix(CompilationResultBuilder crb, ResolvedJavaMethod installedCodeOwner, AArch64MacroAssembler masm, RegisterConfig regConfig, Label verifiedStub) {
    HotSpotProviders providers = getProviders();
    if (installedCodeOwner != null && !isStatic(installedCodeOwner.getModifiers())) {
        crb.recordMark(config.MARKID_UNVERIFIED_ENTRY);
        CallingConvention cc = regConfig.getCallingConvention(HotSpotCallingConventionType.JavaCallee, null, new JavaType[] { providers.getMetaAccess().lookupJavaType(Object.class) }, this);
        // See definition of IC_Klass in c1_LIRAssembler_aarch64.cpp
        // equal to scratch(1) careful!
        Register inlineCacheKlass = AArch64HotSpotRegisterConfig.inlineCacheRegister;
        Register receiver = asRegister(cc.getArgument(0));
        int transferSize = config.useCompressedClassPointers ? 4 : 8;
        AArch64Address klassAddress = masm.makeAddress(receiver, config.hubOffset, transferSize);
        // Are r10 and r11 available scratch registers here? One would hope so.
        Register klass = r10;
        if (config.useCompressedClassPointers) {
            masm.ldr(32, klass, klassAddress);
            AArch64HotSpotMove.decodeKlassPointer(masm, klass, klass, providers.getRegisters().getHeapBaseRegister(), config.getKlassEncoding());
        } else {
            masm.ldr(64, klass, klassAddress);
        }
        masm.cmp(64, inlineCacheKlass, klass);
        /*
             * Conditional jumps have a much lower range than unconditional ones, which can be a
             * problem because the miss handler could be out of range.
             */
        masm.branchConditionally(AArch64Assembler.ConditionFlag.EQ, verifiedStub);
        AArch64Call.directJmp(crb, masm, getForeignCalls().lookupForeignCall(IC_MISS_HANDLER));
    }
    masm.align(config.codeEntryAlignment);
    crb.recordMark(config.MARKID_OSR_ENTRY);
    masm.bind(verifiedStub);
    crb.recordMark(config.MARKID_VERIFIED_ENTRY);
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) Register(jdk.vm.ci.code.Register) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) ScratchRegister(org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler.ScratchRegister) HotSpotProviders(org.graalvm.compiler.hotspot.meta.HotSpotProviders) AArch64Address(org.graalvm.compiler.asm.aarch64.AArch64Address)

Example 2 with AArch64Address

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

the class AArch64Move method emitStackMove.

private static void emitStackMove(CompilationResultBuilder crb, AArch64MacroAssembler masm, AllocatableValue result, Value input) {
    try (ScratchRegister r1 = masm.getScratchRegister()) {
        try (ScratchRegister r2 = masm.getScratchRegister()) {
            Register rscratch1 = r1.getRegister();
            Register rscratch2 = r2.getRegister();
            // use the slot kind to define the operand size
            PlatformKind kind = input.getPlatformKind();
            final int size = kind.getSizeInBytes() * Byte.SIZE;
            // Always perform stack -> stack copies through integer registers
            crb.blockComment("[stack -> stack copy]");
            AArch64Address src = loadStackSlotAddress(crb, masm, asStackSlot(input), rscratch2);
            masm.ldr(size, rscratch1, src);
            AArch64Address dst = loadStackSlotAddress(crb, masm, asStackSlot(result), rscratch2);
            masm.str(size, rscratch1, dst);
        }
    }
}
Also used : ScratchRegister(org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler.ScratchRegister) 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) PlatformKind(jdk.vm.ci.meta.PlatformKind) AArch64Address(org.graalvm.compiler.asm.aarch64.AArch64Address)

Example 3 with AArch64Address

use of org.graalvm.compiler.asm.aarch64.AArch64Address 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 4 with AArch64Address

use of org.graalvm.compiler.asm.aarch64.AArch64Address 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 5 with AArch64Address

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

the class AArch64MacroAssemblerTest method testLoadAddressUnscaled.

@Test
public void testLoadAddressUnscaled() {
    Register dst = AArch64.r26;
    AArch64Address address = AArch64Address.createUnscaledImmediateAddress(base, NumUtil.getNbitNumberInt(8));
    masm.loadAddress(dst, address, 8);
    asm.add(64, dst, base, NumUtil.getNbitNumberInt(8));
    compareAssembly();
}
Also used : Register(jdk.vm.ci.code.Register) AArch64Address(org.graalvm.compiler.asm.aarch64.AArch64Address) Test(org.junit.Test) GraalTest(org.graalvm.compiler.test.GraalTest)

Aggregations

AArch64Address (org.graalvm.compiler.asm.aarch64.AArch64Address)25 Register (jdk.vm.ci.code.Register)16 GraalTest (org.graalvm.compiler.test.GraalTest)16 Test (org.junit.Test)16 ScratchRegister (org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler.ScratchRegister)8 ValueUtil.asRegister (jdk.vm.ci.code.ValueUtil.asRegister)6 ValueUtil.isRegister (jdk.vm.ci.code.ValueUtil.isRegister)3 AArch64Kind (jdk.vm.ci.aarch64.AArch64Kind)2 ValueUtil.asAllocatableValue (jdk.vm.ci.code.ValueUtil.asAllocatableValue)2 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)2 CallingConvention (jdk.vm.ci.code.CallingConvention)1 StackSlot (jdk.vm.ci.code.StackSlot)1 ValueUtil.asStackSlot (jdk.vm.ci.code.ValueUtil.asStackSlot)1 ValueUtil.isStackSlot (jdk.vm.ci.code.ValueUtil.isStackSlot)1 PlatformKind (jdk.vm.ci.meta.PlatformKind)1 Value (jdk.vm.ci.meta.Value)1 Label (org.graalvm.compiler.asm.Label)1 AArch64Assembler (org.graalvm.compiler.asm.aarch64.AArch64Assembler)1 ExtendType (org.graalvm.compiler.asm.aarch64.AArch64Assembler.ExtendType)1 AArch64MacroAssembler (org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler)1