Search in sources :

Example 16 with AMD64Kind

use of jdk.vm.ci.amd64.AMD64Kind in project graal by oracle.

the class AMD64ArithmeticLIRGenerator method emitAdd.

@Override
public Variable emitAdd(LIRKind resultKind, Value a, Value b, boolean setFlags) {
    TargetDescription target = getLIRGen().target();
    boolean isAvx = ((AMD64) target.arch).getFeatures().contains(CPUFeature.AVX);
    switch((AMD64Kind) a.getPlatformKind()) {
        case DWORD:
            if (isJavaConstant(b) && !setFlags) {
                long displacement = asJavaConstant(b).asLong();
                if (NumUtil.isInt(displacement) && displacement != 1 && displacement != -1) {
                    return emitBaseOffsetLea(resultKind, a, (int) displacement, OperandSize.DWORD);
                }
            }
            return emitBinary(resultKind, ADD, DWORD, true, a, b, setFlags);
        case QWORD:
            if (isJavaConstant(b) && !setFlags) {
                long displacement = asJavaConstant(b).asLong();
                if (NumUtil.isInt(displacement) && displacement != 1 && displacement != -1) {
                    return emitBaseOffsetLea(resultKind, a, (int) displacement, OperandSize.QWORD);
                }
            }
            return emitBinary(resultKind, ADD, QWORD, true, a, b, setFlags);
        case SINGLE:
            if (isAvx) {
                return emitBinary(resultKind, AVXOp.ADD, SS, true, a, b);
            } else {
                return emitBinary(resultKind, SSEOp.ADD, SS, true, a, b);
            }
        case DOUBLE:
            if (isAvx) {
                return emitBinary(resultKind, AVXOp.ADD, SD, true, a, b);
            } else {
                return emitBinary(resultKind, SSEOp.ADD, SD, true, a, b);
            }
        default:
            throw GraalError.shouldNotReachHere();
    }
}
Also used : AMD64Kind(jdk.vm.ci.amd64.AMD64Kind) TargetDescription(jdk.vm.ci.code.TargetDescription)

Example 17 with AMD64Kind

use of jdk.vm.ci.amd64.AMD64Kind in project graal by oracle.

the class AMD64ArithmeticLIRGenerator method emitReinterpret.

@Override
public Value emitReinterpret(LIRKind to, Value inputVal) {
    ValueKind<?> from = inputVal.getValueKind();
    if (to.equals(from)) {
        return inputVal;
    }
    AllocatableValue input = getLIRGen().asAllocatable(inputVal);
    /*
         * Conversions between integer to floating point types require moves between CPU and FPU
         * registers.
         */
    AMD64Kind fromKind = (AMD64Kind) from.getPlatformKind();
    switch((AMD64Kind) to.getPlatformKind()) {
        case DWORD:
            switch(fromKind) {
                case SINGLE:
                    return emitConvertOp(to, AMD64MROp.MOVD, DWORD, input);
            }
            break;
        case QWORD:
            switch(fromKind) {
                case DOUBLE:
                    return emitConvertOp(to, AMD64MROp.MOVQ, QWORD, input);
            }
            break;
        case SINGLE:
            switch(fromKind) {
                case DWORD:
                    return emitConvertOp(to, AMD64RMOp.MOVD, DWORD, input);
            }
            break;
        case DOUBLE:
            switch(fromKind) {
                case QWORD:
                    return emitConvertOp(to, AMD64RMOp.MOVQ, QWORD, input);
            }
            break;
    }
    throw GraalError.shouldNotReachHere();
}
Also used : AMD64Kind(jdk.vm.ci.amd64.AMD64Kind) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Example 18 with AMD64Kind

use of jdk.vm.ci.amd64.AMD64Kind in project graal by oracle.

the class AMD64ArithmeticLIRGenerator method emitSub.

@Override
public Variable emitSub(LIRKind resultKind, Value a, Value b, boolean setFlags) {
    TargetDescription target = getLIRGen().target();
    boolean isAvx = ((AMD64) target.arch).getFeatures().contains(CPUFeature.AVX);
    switch((AMD64Kind) a.getPlatformKind()) {
        case DWORD:
            return emitBinary(resultKind, SUB, DWORD, false, a, b, setFlags);
        case QWORD:
            return emitBinary(resultKind, SUB, QWORD, false, a, b, setFlags);
        case SINGLE:
            if (isAvx) {
                return emitBinary(resultKind, AVXOp.SUB, SS, false, a, b);
            } else {
                return emitBinary(resultKind, SSEOp.SUB, SS, false, a, b);
            }
        case DOUBLE:
            if (isAvx) {
                return emitBinary(resultKind, AVXOp.SUB, SD, false, a, b);
            } else {
                return emitBinary(resultKind, SSEOp.SUB, SD, false, a, b);
            }
        default:
            throw GraalError.shouldNotReachHere();
    }
}
Also used : AMD64Kind(jdk.vm.ci.amd64.AMD64Kind) TargetDescription(jdk.vm.ci.code.TargetDescription)

Example 19 with AMD64Kind

use of jdk.vm.ci.amd64.AMD64Kind in project graal by oracle.

the class AMD64ArithmeticLIRGenerator method emitOr.

@Override
public Variable emitOr(Value a, Value b) {
    LIRKind resultKind = LIRKind.combine(a, b);
    TargetDescription target = getLIRGen().target();
    boolean isAvx = ((AMD64) target.arch).getFeatures().contains(CPUFeature.AVX);
    switch((AMD64Kind) a.getPlatformKind()) {
        case DWORD:
            return emitBinary(resultKind, OR, DWORD, true, a, b, false);
        case QWORD:
            return emitBinary(resultKind, OR, QWORD, true, a, b, false);
        case SINGLE:
            if (isAvx) {
                return emitBinary(resultKind, AVXOp.OR, PS, true, a, b);
            } else {
                return emitBinary(resultKind, SSEOp.OR, PS, true, a, b);
            }
        case DOUBLE:
            if (isAvx) {
                return emitBinary(resultKind, AVXOp.OR, PD, true, a, b);
            } else {
                return emitBinary(resultKind, SSEOp.OR, PD, true, a, b);
            }
        default:
            throw GraalError.shouldNotReachHere();
    }
}
Also used : AMD64Kind(jdk.vm.ci.amd64.AMD64Kind) TargetDescription(jdk.vm.ci.code.TargetDescription) LIRKind(org.graalvm.compiler.core.common.LIRKind)

Example 20 with AMD64Kind

use of jdk.vm.ci.amd64.AMD64Kind in project graal by oracle.

the class AMD64ArithmeticLIRGenerator method emitAnd.

@Override
public Variable emitAnd(Value a, Value b) {
    LIRKind resultKind = LIRKind.combine(a, b);
    TargetDescription target = getLIRGen().target();
    boolean isAvx = ((AMD64) target.arch).getFeatures().contains(CPUFeature.AVX);
    switch((AMD64Kind) a.getPlatformKind()) {
        case DWORD:
            return emitBinary(resultKind, AND, DWORD, true, a, b, false);
        case QWORD:
            return emitBinary(resultKind, AND, QWORD, true, a, b, false);
        case SINGLE:
            if (isAvx) {
                return emitBinary(resultKind, AVXOp.AND, PS, true, a, b);
            } else {
                return emitBinary(resultKind, SSEOp.AND, PS, true, a, b);
            }
        case DOUBLE:
            if (isAvx) {
                return emitBinary(resultKind, AVXOp.AND, PD, true, a, b);
            } else {
                return emitBinary(resultKind, SSEOp.AND, PD, true, a, b);
            }
        default:
            throw GraalError.shouldNotReachHere();
    }
}
Also used : AMD64Kind(jdk.vm.ci.amd64.AMD64Kind) TargetDescription(jdk.vm.ci.code.TargetDescription) LIRKind(org.graalvm.compiler.core.common.LIRKind)

Aggregations

AMD64Kind (jdk.vm.ci.amd64.AMD64Kind)24 TargetDescription (jdk.vm.ci.code.TargetDescription)9 AMD64AddressValue (org.graalvm.compiler.lir.amd64.AMD64AddressValue)8 Variable (org.graalvm.compiler.lir.Variable)7 LIRKind (org.graalvm.compiler.core.common.LIRKind)6 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)5 RegisterValue (jdk.vm.ci.code.RegisterValue)3 Register (jdk.vm.ci.code.Register)2 JavaConstant (jdk.vm.ci.meta.JavaConstant)2 Value (jdk.vm.ci.meta.Value)2 AMD64Address (org.graalvm.compiler.asm.amd64.AMD64Address)2 AMD64RMOp (org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64RMOp)2 OperandSize (org.graalvm.compiler.asm.amd64.AMD64Assembler.OperandSize)2 CanonicalCondition (org.graalvm.compiler.core.common.calc.CanonicalCondition)2 Condition (org.graalvm.compiler.core.common.calc.Condition)2 NodeLIRBuilder (org.graalvm.compiler.core.gen.NodeLIRBuilder)2 ComplexMatchResult (org.graalvm.compiler.core.match.ComplexMatchResult)2 LabelRef (org.graalvm.compiler.lir.LabelRef)2 AMD64Move (org.graalvm.compiler.lir.amd64.AMD64Move)2 CompareAndSwapOp (org.graalvm.compiler.lir.amd64.AMD64Move.CompareAndSwapOp)2