Search in sources :

Example 56 with AllocatableValue

use of jdk.vm.ci.meta.AllocatableValue in project graal by oracle.

the class AMD64ArithmeticLIRGenerator method emitMathSin.

@Override
public Value emitMathSin(Value input) {
    LIRGenerator gen = getLIRGen();
    Variable result = maths.emitSin(gen, input);
    if (result == null) {
        result = gen.newVariable(LIRKind.combine(input));
        AllocatableValue stackSlot = gen.getResult().getFrameMapBuilder().allocateSpillSlot(LIRKind.value(AMD64Kind.QWORD));
        gen.append(new AMD64MathIntrinsicUnaryOp(getAMD64LIRGen(), SIN, result, gen.asAllocatable(input), stackSlot));
    }
    return result;
}
Also used : AMD64MathIntrinsicUnaryOp(org.graalvm.compiler.lir.amd64.AMD64MathIntrinsicUnaryOp) Variable(org.graalvm.compiler.lir.Variable) ArithmeticLIRGenerator(org.graalvm.compiler.lir.gen.ArithmeticLIRGenerator) LIRGenerator(org.graalvm.compiler.lir.gen.LIRGenerator) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Example 57 with AllocatableValue

use of jdk.vm.ci.meta.AllocatableValue in project graal by oracle.

the class AMD64ArithmeticLIRGenerator method emitNot.

@Override
public Variable emitNot(Value inputVal) {
    AllocatableValue input = getLIRGen().asAllocatable(inputVal);
    Variable result = getLIRGen().newVariable(LIRKind.combine(input));
    switch((AMD64Kind) input.getPlatformKind()) {
        case DWORD:
            getLIRGen().append(new AMD64Unary.MOp(NOT, DWORD, result, input));
            break;
        case QWORD:
            getLIRGen().append(new AMD64Unary.MOp(NOT, QWORD, result, input));
            break;
        default:
            throw GraalError.shouldNotReachHere();
    }
    return result;
}
Also used : AMD64Unary(org.graalvm.compiler.lir.amd64.AMD64Unary) AMD64Kind(jdk.vm.ci.amd64.AMD64Kind) Variable(org.graalvm.compiler.lir.Variable) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Example 58 with AllocatableValue

use of jdk.vm.ci.meta.AllocatableValue in project graal by oracle.

the class AMD64ArithmeticLIRGenerator method emitNegate.

@Override
public Variable emitNegate(Value inputVal) {
    AllocatableValue input = getLIRGen().asAllocatable(inputVal);
    Variable result = getLIRGen().newVariable(LIRKind.combine(input));
    TargetDescription target = getLIRGen().target();
    boolean isAvx = ((AMD64) target.arch).getFeatures().contains(CPUFeature.AVX);
    switch((AMD64Kind) input.getPlatformKind()) {
        case DWORD:
            getLIRGen().append(new AMD64Unary.MOp(NEG, DWORD, result, input));
            break;
        case QWORD:
            getLIRGen().append(new AMD64Unary.MOp(NEG, QWORD, result, input));
            break;
        case SINGLE:
            if (isAvx) {
                getLIRGen().append(new AMD64Binary.DataThreeOp(AVXOp.XOR, PS, result, input, JavaConstant.forFloat(Float.intBitsToFloat(0x80000000)), 16));
            } else {
                getLIRGen().append(new AMD64Binary.DataTwoOp(SSEOp.XOR, PS, result, input, JavaConstant.forFloat(Float.intBitsToFloat(0x80000000)), 16));
            }
            break;
        case DOUBLE:
            if (isAvx) {
                getLIRGen().append(new AMD64Binary.DataThreeOp(AVXOp.XOR, PD, result, input, JavaConstant.forDouble(Double.longBitsToDouble(0x8000000000000000L)), 16));
            } else {
                getLIRGen().append(new AMD64Binary.DataTwoOp(SSEOp.XOR, PD, result, input, JavaConstant.forDouble(Double.longBitsToDouble(0x8000000000000000L)), 16));
            }
            break;
        default:
            throw GraalError.shouldNotReachHere(input.getPlatformKind().toString());
    }
    return result;
}
Also used : AMD64Unary(org.graalvm.compiler.lir.amd64.AMD64Unary) AMD64Kind(jdk.vm.ci.amd64.AMD64Kind) Variable(org.graalvm.compiler.lir.Variable) AMD64Binary(org.graalvm.compiler.lir.amd64.AMD64Binary) TargetDescription(jdk.vm.ci.code.TargetDescription) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Example 59 with AllocatableValue

use of jdk.vm.ci.meta.AllocatableValue 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 60 with AllocatableValue

use of jdk.vm.ci.meta.AllocatableValue in project graal by oracle.

the class AMD64ArithmeticLIRGenerator method emitMathExp.

@Override
public Value emitMathExp(Value input) {
    Variable result = getLIRGen().newVariable(LIRKind.combine(input));
    AllocatableValue stackSlot = getLIRGen().getResult().getFrameMapBuilder().allocateSpillSlot(LIRKind.value(AMD64Kind.QWORD));
    getLIRGen().append(new AMD64MathIntrinsicUnaryOp(getAMD64LIRGen(), EXP, result, getLIRGen().asAllocatable(input), stackSlot));
    return result;
}
Also used : AMD64MathIntrinsicUnaryOp(org.graalvm.compiler.lir.amd64.AMD64MathIntrinsicUnaryOp) Variable(org.graalvm.compiler.lir.Variable) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Aggregations

AllocatableValue (jdk.vm.ci.meta.AllocatableValue)87 Value (jdk.vm.ci.meta.Value)22 Variable (org.graalvm.compiler.lir.Variable)20 LIRKind (org.graalvm.compiler.core.common.LIRKind)13 LIRInstruction (org.graalvm.compiler.lir.LIRInstruction)11 Indent (org.graalvm.compiler.debug.Indent)10 RegisterValue (jdk.vm.ci.code.RegisterValue)9 ValueUtil.asAllocatableValue (jdk.vm.ci.code.ValueUtil.asAllocatableValue)8 DebugContext (org.graalvm.compiler.debug.DebugContext)8 Register (jdk.vm.ci.code.Register)6 JavaConstant (jdk.vm.ci.meta.JavaConstant)6 AMD64MathIntrinsicUnaryOp (org.graalvm.compiler.lir.amd64.AMD64MathIntrinsicUnaryOp)5 LIRValueUtil.asJavaConstant (org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant)4 LIRValueUtil.isJavaConstant (org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant)4 ValueMoveOp (org.graalvm.compiler.lir.StandardOp.ValueMoveOp)4 ArithmeticLIRGenerator (org.graalvm.compiler.lir.gen.ArithmeticLIRGenerator)4 LIRGenerator (org.graalvm.compiler.lir.gen.LIRGenerator)4 SPARCAddressValue (org.graalvm.compiler.lir.sparc.SPARCAddressValue)4 AMD64Kind (jdk.vm.ci.amd64.AMD64Kind)3 ValueUtil.isAllocatableValue (jdk.vm.ci.code.ValueUtil.isAllocatableValue)3