Search in sources :

Example 1 with AMD64CCall

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

the class AMD64HotSpotLIRGenerator method emitCCall.

@Override
public void emitCCall(long address, CallingConvention nativeCallingConvention, Value[] args, int numberOfFloatingPointArguments) {
    Value[] argLocations = new Value[args.length];
    getResult().getFrameMapBuilder().callsMethod(nativeCallingConvention);
    // TODO(mg): in case a native function uses floating point varargs, the ABI requires that
    // RAX contains the length of the varargs
    PrimitiveConstant intConst = JavaConstant.forInt(numberOfFloatingPointArguments);
    AllocatableValue numberOfFloatingPointArgumentsRegister = AMD64.rax.asValue(LIRKind.value(AMD64Kind.DWORD));
    emitMoveConstant(numberOfFloatingPointArgumentsRegister, intConst);
    for (int i = 0; i < args.length; i++) {
        Value arg = args[i];
        AllocatableValue loc = nativeCallingConvention.getArgument(i);
        emitMove(loc, arg);
        argLocations[i] = loc;
    }
    Value ptr = emitLoadConstant(LIRKind.value(AMD64Kind.QWORD), JavaConstant.forLong(address));
    append(new AMD64CCall(nativeCallingConvention.getReturn(), ptr, numberOfFloatingPointArgumentsRegister, argLocations));
}
Also used : PrimitiveConstant(jdk.vm.ci.meta.PrimitiveConstant) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) RegisterValue(jdk.vm.ci.code.RegisterValue) AMD64AddressValue(org.graalvm.compiler.lir.amd64.AMD64AddressValue) AMD64CCall(org.graalvm.compiler.lir.amd64.AMD64CCall) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Aggregations

RegisterValue (jdk.vm.ci.code.RegisterValue)1 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)1 PrimitiveConstant (jdk.vm.ci.meta.PrimitiveConstant)1 Value (jdk.vm.ci.meta.Value)1 AMD64AddressValue (org.graalvm.compiler.lir.amd64.AMD64AddressValue)1 AMD64CCall (org.graalvm.compiler.lir.amd64.AMD64CCall)1