use of com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMVariable in project graal by oracle.
the class LLVMGenerator method emitLoadConstant.
@Override
public AllocatableValue emitLoadConstant(ValueKind<?> kind, Constant constant) {
LLVMValueRef value = builder.buildLoad(getLLVMPlaceholderForConstant(constant), ((LLVMKind) kind.getPlatformKind()).get());
AllocatableValue rawConstant = new LLVMVariable(value);
if (SubstrateOptions.SpawnIsolates.getValue() && ((LIRKind) kind).isReference(0) && !((LIRKind) kind).isCompressedReference(0)) {
return (AllocatableValue) emitUncompress(rawConstant, ReferenceAccess.singleton().getCompressEncoding(), false);
}
return rawConstant;
}
use of com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMVariable in project graal by oracle.
the class LLVMGenerator method emitLogicCompareAndSwap.
@Override
public Variable emitLogicCompareAndSwap(LIRKind accessKind, Value address, Value expectedValue, Value newValue, Value trueValue, Value falseValue, MemoryOrderMode memoryOrder) {
LLVMValueRef success = buildCmpxchg(getVal(address), getVal(expectedValue), getVal(newValue), memoryOrder, false);
LLVMValueRef result = builder.buildSelect(success, getVal(trueValue), getVal(falseValue));
return new LLVMVariable(result);
}
use of com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMVariable in project graal by oracle.
the class LLVMGenerator method emitConditionalMove.
@Override
public Variable emitConditionalMove(PlatformKind cmpKind, Value leftVal, Value rightVal, Condition cond, boolean unorderedIsTrue, Value trueVal, Value falseVal) {
LLVMValueRef condition = builder.buildCompare(cond, getVal(leftVal), getVal(rightVal), unorderedIsTrue);
LLVMValueRef select;
LLVMValueRef trueValue = getVal(trueVal);
LLVMValueRef falseValue = getVal(falseVal);
if (LLVMVersionChecker.useExplicitSelects() && LLVMIRBuilder.isObjectType(typeOf(trueValue))) {
select = buildExplicitSelect(condition, trueValue, falseValue);
} else {
select = builder.buildSelect(condition, trueValue, falseValue);
}
return new LLVMVariable(select);
}
use of com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMVariable in project graal by oracle.
the class LLVMGenerator method emitIntegerTestMove.
@Override
public Variable emitIntegerTestMove(Value left, Value right, Value trueValue, Value falseValue) {
LLVMValueRef and = builder.buildAnd(getVal(left), getVal(right));
LLVMValueRef isNull = builder.buildIsNull(and);
LLVMValueRef select = builder.buildSelect(isNull, getVal(trueValue), getVal(falseValue));
return new LLVMVariable(select);
}
use of com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMVariable in project graal by oracle.
the class LLVMGenerator method emitForeignCall.
public Variable emitForeignCall(ForeignCallLinkage linkage, LIRFrameState state, LLVMBasicBlockRef successor, LLVMBasicBlockRef handler, Value... arguments) {
ResolvedJavaMethod targetMethod = ((SnippetRuntime.SubstrateForeignCallDescriptor) linkage.getDescriptor()).findMethod(getMetaAccess());
DebugInfo debugInfo = null;
if (state != null) {
state.initDebugInfo(null, false);
debugInfo = state.debugInfo();
}
long patchpointId = nextPatchpointId.getAndIncrement();
compilationResult.recordCall(NumUtil.safeToInt(patchpointId), 0, targetMethod, debugInfo, true);
LLVMValueRef callee = getFunction(targetMethod);
LLVMValueRef[] args = Arrays.stream(arguments).map(LLVMUtils::getVal).toArray(LLVMValueRef[]::new);
CallingConvention.Type callType = ((SubstrateCallingConvention) linkage.getOutgoingCallingConvention()).getType();
LLVMValueRef[] callArguments = getCallArguments(args, callType);
LLVMValueRef call;
boolean nativeABI = ((SubstrateCallingConventionType) callType).nativeABI();
if (successor == null && handler == null) {
call = buildStatepointCall(callee, nativeABI, patchpointId, callArguments);
} else {
assert successor != null && handler != null;
call = buildStatepointInvoke(callee, nativeABI, successor, handler, patchpointId, callArguments);
}
return (isVoidReturnType(getLLVMFunctionReturnType(targetMethod, false))) ? null : new LLVMVariable(call);
}
Aggregations