Search in sources :

Example 1 with AMD64ShiftOp

use of org.graalvm.compiler.lir.amd64.AMD64ShiftOp in project graal by oracle.

the class AMD64ArithmeticLIRGenerator method emitShift.

private Variable emitShift(AMD64Shift op, OperandSize size, Value a, Value b) {
    Variable result = getLIRGen().newVariable(LIRKind.combine(a, b).changeType(a.getPlatformKind()));
    AllocatableValue input = getLIRGen().asAllocatable(a);
    if (isJavaConstant(b)) {
        JavaConstant c = asJavaConstant(b);
        if (c.asLong() == 1) {
            getLIRGen().append(new AMD64Unary.MOp(op.m1Op, size, result, input));
        } else {
            /*
                 * c is implicitly masked to 5 or 6 bits by the CPU, so casting it to (int) is
                 * always correct, even without the NumUtil.is32bit() test.
                 */
            getLIRGen().append(new AMD64Binary.ConstOp(op.miOp, size, result, input, (int) c.asLong()));
        }
    } else {
        getLIRGen().emitMove(RCX_I, b);
        getLIRGen().append(new AMD64ShiftOp(op.mcOp, size, result, input, RCX_I));
    }
    return result;
}
Also used : AMD64Unary(org.graalvm.compiler.lir.amd64.AMD64Unary) Variable(org.graalvm.compiler.lir.Variable) AMD64Binary(org.graalvm.compiler.lir.amd64.AMD64Binary) AMD64ShiftOp(org.graalvm.compiler.lir.amd64.AMD64ShiftOp) JavaConstant(jdk.vm.ci.meta.JavaConstant) LIRValueUtil.asJavaConstant(org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant) LIRValueUtil.isJavaConstant(org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Aggregations

AllocatableValue (jdk.vm.ci.meta.AllocatableValue)1 JavaConstant (jdk.vm.ci.meta.JavaConstant)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 AMD64Binary (org.graalvm.compiler.lir.amd64.AMD64Binary)1 AMD64ShiftOp (org.graalvm.compiler.lir.amd64.AMD64ShiftOp)1 AMD64Unary (org.graalvm.compiler.lir.amd64.AMD64Unary)1