use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef in project graal by oracle.
the class LLVMHelperFunctions method buildObjectsCmpxchgFunction.
private LLVMValueRef buildObjectsCmpxchgFunction(boolean compressed, MemoryOrderMode memoryOrder, boolean returnsValue) {
String funcName = compressed ? returnsValue ? COMPRESSED_OBJECTS_VALUE_CMPXCHG_FUNCTION_NAME : COMPRESSED_OBJECTS_LOGIC_CMPXCHG_FUNCTION_NAME : returnsValue ? OBJECTS_VALUE_CMPXCHG_FUNCTION_NAME : OBJECTS_LOGIC_CMPXCHG_FUNCTION_NAME;
LLVMTypeRef exchangeType = builder.objectType(compressed);
LLVMValueRef func = builder.addFunction(funcName, builder.functionType(returnsValue ? exchangeType : builder.booleanType(), builder.pointerType(exchangeType, true, false), exchangeType, exchangeType));
LLVMIRBuilder.setLinkage(func, LinkageType.LinkOnce);
builder.setFunctionAttribute(func, Attribute.AlwaysInline);
builder.setFunctionAttribute(func, Attribute.GCLeafFunction);
LLVMBasicBlockRef block = builder.appendBasicBlock(func, "main");
builder.positionAtEnd(block);
LLVMValueRef addr = LLVMIRBuilder.getParam(func, 0);
LLVMValueRef expected = LLVMIRBuilder.getParam(func, 1);
LLVMValueRef newVal = LLVMIRBuilder.getParam(func, 2);
LLVMValueRef result = builder.buildAtomicCmpXchg(addr, expected, newVal, memoryOrder, returnsValue);
builder.buildRet(result);
return func;
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef in project graal by oracle.
the class LLVMUtils method dumpValues.
public static String dumpValues(String prefix, LLVMValueRef... values) {
StringBuilder builder = new StringBuilder(prefix);
for (LLVMValueRef value : values) {
builder.append(" ");
builder.append(LLVM.LLVMPrintValueToString(value).getString());
}
return builder.toString();
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef 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.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef 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);
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef in project graal by oracle.
the class LLVMGenerator method emitReadCallerStackPointer.
@Override
public Value emitReadCallerStackPointer(Stamp wordStamp) {
LLVMValueRef basePointer = builder.buildFrameAddress(builder.constantInt(0));
LLVMValueRef callerSP = builder.buildAdd(builder.buildPtrToInt(basePointer), builder.constantLong(16));
return new LLVMVariable(callerSP);
}
Aggregations