use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef in project graal by oracle.
the class LLVMIRBuilder method buildBinaryNumberOp.
private LLVMValueRef buildBinaryNumberOp(LLVMValueRef a, LLVMValueRef b, BinaryBuilder integerBuilder, BinaryBuilder realBuilder) {
LLVMTypeRef aType = LLVM.LLVMTypeOf(a);
LLVMTypeRef bType = LLVM.LLVMTypeOf(b);
assert compatibleTypes(aType, bType) : dumpValues("invalid binary operation arguments", a, b);
BinaryBuilder binaryBuilder;
switch(LLVM.LLVMGetTypeKind(aType)) {
case LLVM.LLVMIntegerTypeKind:
binaryBuilder = integerBuilder;
break;
case LLVM.LLVMFloatTypeKind:
case LLVM.LLVMDoubleTypeKind:
binaryBuilder = realBuilder;
break;
default:
throw shouldNotReachHere(dumpValues("invalid binary operation arguments", a, b));
}
return binaryBuilder.build(builder, a, b, DEFAULT_INSTR_NAME);
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef in project graal by oracle.
the class LLVMIRBuilder method buildCompare.
public LLVMValueRef buildCompare(Condition cond, LLVMValueRef a, LLVMValueRef b, boolean unordered) {
LLVMTypeRef aType = LLVM.LLVMTypeOf(a);
LLVMTypeRef bType = LLVM.LLVMTypeOf(b);
assert compatibleTypes(aType, bType) : dumpTypes("comparison", aType, bType);
switch(LLVM.LLVMGetTypeKind(aType)) {
case LLVM.LLVMIntegerTypeKind:
case LLVM.LLVMPointerTypeKind:
return buildICmp(cond, a, b);
case LLVM.LLVMFloatTypeKind:
case LLVM.LLVMDoubleTypeKind:
return buildFCmp(cond, a, b, unordered);
default:
throw shouldNotReachHere(dumpTypes("comparison", aType, bType));
}
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef in project graal by oracle.
the class LLVMIRBuilder method buildStackmap.
public void buildStackmap(LLVMValueRef patchpointId, LLVMValueRef... liveValues) {
LLVMTypeRef stackmapType = functionType(voidType(), true, longType(), intType());
LLVMValueRef[] allArgs = new LLVMValueRef[2 + liveValues.length];
allArgs[0] = patchpointId;
allArgs[1] = constantInt(0);
System.arraycopy(liveValues, 0, allArgs, 2, liveValues.length);
buildIntrinsicCall("llvm.experimental.stackmap", stackmapType, allArgs);
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef in project graal by oracle.
the class LLVMIRBuilder method buildNeg.
public LLVMValueRef buildNeg(LLVMValueRef a) {
LLVMTypeRef type = LLVM.LLVMTypeOf(a);
UnaryBuilder unaryBuilder;
switch(LLVM.LLVMGetTypeKind(type)) {
case LLVM.LLVMIntegerTypeKind:
unaryBuilder = LLVM::LLVMBuildNeg;
break;
case LLVM.LLVMFloatTypeKind:
case LLVM.LLVMDoubleTypeKind:
unaryBuilder = LLVM::LLVMBuildFNeg;
break;
default:
throw shouldNotReachHere(dumpTypes("invalid negation type", type));
}
return unaryBuilder.build(builder, a, DEFAULT_INSTR_NAME);
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef 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;
}
Aggregations