Search in sources :

Example 6 with AArch64Kind

use of jdk.vm.ci.aarch64.AArch64Kind in project graal by oracle.

the class AArch64LIRGenerator method emitCompare.

/**
 * This method emits the compare instruction, and may reorder the operands. It returns true if
 * it did so.
 *
 * @param a the left operand of the comparison. Has to have same type as b. Non null.
 * @param b the right operand of the comparison. Has to have same type as a. Non null.
 * @return true if mirrored (i.e. "b cmp a" instead of "a cmp b" was done).
 */
protected boolean emitCompare(PlatformKind cmpKind, Value a, Value b, Condition condition, boolean unorderedIsTrue) {
    Value left;
    Value right;
    boolean mirrored;
    AArch64Kind kind = (AArch64Kind) cmpKind;
    if (kind.isInteger()) {
        Value aExt = a;
        Value bExt = b;
        int compareBytes = cmpKind.getSizeInBytes();
        // AArch64 compares 32 or 64 bits: sign extend a and b as required.
        if (compareBytes < a.getPlatformKind().getSizeInBytes()) {
            aExt = arithmeticLIRGen.emitSignExtend(a, compareBytes * 8, 64);
        }
        if (compareBytes < b.getPlatformKind().getSizeInBytes()) {
            bExt = arithmeticLIRGen.emitSignExtend(b, compareBytes * 8, 64);
        }
        if (LIRValueUtil.isVariable(bExt)) {
            left = load(bExt);
            right = loadNonConst(aExt);
            mirrored = true;
        } else {
            left = load(aExt);
            right = loadNonConst(bExt);
            mirrored = false;
        }
        append(new AArch64Compare.CompareOp(left, loadNonCompareConst(right)));
    } else if (kind.isSIMD()) {
        if (AArch64Compare.FloatCompareOp.isFloatCmpConstant(a, condition, unorderedIsTrue)) {
            left = load(b);
            right = a;
            mirrored = true;
        } else if (AArch64Compare.FloatCompareOp.isFloatCmpConstant(b, condition, unorderedIsTrue)) {
            left = load(a);
            right = b;
            mirrored = false;
        } else {
            left = load(a);
            right = loadReg(b);
            mirrored = false;
        }
        append(new AArch64Compare.FloatCompareOp(left, asAllocatable(right), condition, unorderedIsTrue));
    } else {
        throw GraalError.shouldNotReachHere();
    }
    return mirrored;
}
Also used : AArch64Compare(org.graalvm.compiler.lir.aarch64.AArch64Compare) AArch64AddressValue(org.graalvm.compiler.lir.aarch64.AArch64AddressValue) RegisterValue(jdk.vm.ci.code.RegisterValue) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) AArch64Kind(jdk.vm.ci.aarch64.AArch64Kind)

Example 7 with AArch64Kind

use of jdk.vm.ci.aarch64.AArch64Kind in project graal by oracle.

the class AArch64AddressLoweringByUse method doLower.

private AddressNode doLower(Stamp stamp, ValueNode base, ValueNode index) {
    AArch64AddressNode ret = new AArch64AddressNode(base, index);
    AArch64Kind aarch64Kind = (stamp == null ? null : getAArch64Kind(stamp));
    // improve the address as much as possible
    boolean changed;
    do {
        changed = improve(aarch64Kind, ret);
    } while (changed);
    // avoid duplicates
    return base.graph().unique(ret);
}
Also used : AArch64Kind(jdk.vm.ci.aarch64.AArch64Kind)

Example 8 with AArch64Kind

use of jdk.vm.ci.aarch64.AArch64Kind in project graal by oracle.

the class AArch64Move method stack2reg.

private static void stack2reg(CompilationResultBuilder crb, AArch64MacroAssembler masm, AllocatableValue result, AllocatableValue input) {
    AArch64Kind kind = (AArch64Kind) input.getPlatformKind();
    // use the slot kind to define the operand size
    final int size = kind.getSizeInBytes() * Byte.SIZE;
    if (kind.isInteger()) {
        AArch64Address src = loadStackSlotAddress(crb, masm, asStackSlot(input), result);
        masm.ldr(size, asRegister(result), src);
    } else {
        try (ScratchRegister sc = masm.getScratchRegister()) {
            AllocatableValue scratchRegisterValue = sc.getRegister().asValue(LIRKind.combine(input));
            AArch64Address src = loadStackSlotAddress(crb, masm, asStackSlot(input), scratchRegisterValue);
            masm.fldr(size, asRegister(result), src);
        }
    }
}
Also used : ScratchRegister(org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler.ScratchRegister) AArch64Kind(jdk.vm.ci.aarch64.AArch64Kind) AArch64Address(org.graalvm.compiler.asm.aarch64.AArch64Address) ValueUtil.asAllocatableValue(jdk.vm.ci.code.ValueUtil.asAllocatableValue) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Example 9 with AArch64Kind

use of jdk.vm.ci.aarch64.AArch64Kind in project graal by oracle.

the class AArch64ReinterpretOp method emitCode.

@Override
public void emitCode(CompilationResultBuilder crb, AArch64MacroAssembler masm) {
    Register result = asRegister(resultValue);
    Register input = asRegister(inputValue);
    AArch64Kind to = (AArch64Kind) resultValue.getPlatformKind();
    final int size = to.getSizeInBytes() * Byte.SIZE;
    masm.fmov(size, result, input);
}
Also used : ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) Register(jdk.vm.ci.code.Register) AArch64Kind(jdk.vm.ci.aarch64.AArch64Kind)

Example 10 with AArch64Kind

use of jdk.vm.ci.aarch64.AArch64Kind in project graal by oracle.

the class AArch64ReadNode method generate.

@Override
public void generate(NodeLIRBuilderTool gen) {
    AArch64LIRGenerator lirgen = (AArch64LIRGenerator) gen.getLIRGeneratorTool();
    AArch64ArithmeticLIRGenerator arithgen = (AArch64ArithmeticLIRGenerator) lirgen.getArithmetic();
    AArch64Kind readKind = (AArch64Kind) lirgen.getLIRKind(accessStamp).getPlatformKind();
    int resultBits = ((IntegerStamp) stamp(NodeView.DEFAULT)).getBits();
    gen.setResult(this, arithgen.emitExtendMemory(isSigned, readKind, resultBits, (AArch64AddressValue) gen.operand(getAddress()), gen.state(this)));
}
Also used : AArch64ArithmeticLIRGenerator(org.graalvm.compiler.core.aarch64.AArch64ArithmeticLIRGenerator) IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp) AArch64LIRGenerator(org.graalvm.compiler.core.aarch64.AArch64LIRGenerator) AArch64Kind(jdk.vm.ci.aarch64.AArch64Kind) AArch64AddressValue(org.graalvm.compiler.lir.aarch64.AArch64AddressValue)

Aggregations

AArch64Kind (jdk.vm.ci.aarch64.AArch64Kind)10 AArch64AddressValue (org.graalvm.compiler.lir.aarch64.AArch64AddressValue)5 Register (jdk.vm.ci.code.Register)3 ValueUtil.asRegister (jdk.vm.ci.code.ValueUtil.asRegister)3 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)3 ScratchRegister (org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler.ScratchRegister)3 RegisterValue (jdk.vm.ci.code.RegisterValue)2 ValueUtil.isRegister (jdk.vm.ci.code.ValueUtil.isRegister)2 AArch64Address (org.graalvm.compiler.asm.aarch64.AArch64Address)2 StoreOp (org.graalvm.compiler.lir.aarch64.AArch64Move.StoreOp)2 ValueUtil.asAllocatableValue (jdk.vm.ci.code.ValueUtil.asAllocatableValue)1 JavaConstant (jdk.vm.ci.meta.JavaConstant)1 Value (jdk.vm.ci.meta.Value)1 AArch64ArithmeticLIRGenerator (org.graalvm.compiler.core.aarch64.AArch64ArithmeticLIRGenerator)1 AArch64LIRGenerator (org.graalvm.compiler.core.aarch64.AArch64LIRGenerator)1 LIRKind (org.graalvm.compiler.core.common.LIRKind)1 IntegerStamp (org.graalvm.compiler.core.common.type.IntegerStamp)1 LIRValueUtil.asJavaConstant (org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant)1 LIRValueUtil.isJavaConstant (org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant)1 Variable (org.graalvm.compiler.lir.Variable)1