use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef in project graal by oracle.
the class LLVMGenerator method appendBasicBlock.
/* Basic blocks */
void appendBasicBlock(Block block) {
LLVMBasicBlockRef basicBlock = builder.appendBasicBlock(block.toString());
basicBlockMap.put(block.getBeginNode(), basicBlock);
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef in project graal by oracle.
the class NodeLLVMBuilder method emitTypeSwitch.
private void emitTypeSwitch(TypeSwitchNode switchNode) {
int numCases = switchNode.keyCount();
LLVMValueRef value = llvmOperand(switchNode.value());
LLVMBasicBlockRef defaultSuccessor = gen.getBlock(switchNode.defaultSuccessor());
switch(numCases) {
case 0:
builder.buildBranch(defaultSuccessor);
break;
case 1:
LLVMValueRef hub = gen.emitLLVMConstant(builder.objectType(false), (JavaConstant) switchNode.keyAt(0));
LLVMValueRef cond = builder.buildCompare(Condition.EQ, value, hub, false);
builder.buildIf(cond, gen.getBlock(switchNode.keySuccessor(0)), defaultSuccessor);
break;
default:
throw unimplemented();
}
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef in project graal by oracle.
the class LLVMHelperFunctions method buildAtomicObjectXchgFunction.
private LLVMValueRef buildAtomicObjectXchgFunction(boolean compressed) {
String funcName = compressed ? ATOMIC_COMPRESSED_OBJECT_XCHG_FUNCTION_NAME : ATOMIC_OBJECT_XCHG_FUNCTION_NAME;
LLVMValueRef func = builder.addFunction(funcName, builder.functionType(builder.objectType(compressed), builder.objectType(false), builder.objectType(compressed)));
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 address = LLVMIRBuilder.getParam(func, 0);
LLVMValueRef value = LLVMIRBuilder.getParam(func, 1);
LLVMValueRef castedValue = builder.buildPtrToInt(value);
LLVMValueRef ret = builder.buildLLVMAtomicXchg(address, castedValue);
ret = builder.buildLLVMIntToPtr(ret, builder.objectType(compressed));
builder.buildRet(ret);
return func;
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef in project graal by oracle.
the class LLVMHelperFunctions method buildUncompressFunction.
private LLVMValueRef buildUncompressFunction(boolean nonNull, int shift) {
String funcName = UNCOMPRESS_FUNCTION_BASE_NAME + (nonNull ? "_nonNull" : "") + "_" + shift;
LLVMValueRef func = builder.addFunction(funcName, builder.functionType(builder.objectType(false), builder.objectType(true), builder.wordType()));
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 compressed = builder.buildPtrToInt(LLVMIRBuilder.getParam(func, 0));
LLVMValueRef heapBase = LLVMIRBuilder.getParam(func, 1);
if (shift != 0) {
compressed = builder.buildShl(compressed, builder.constantInt(shift));
}
LLVMValueRef uncompressed = builder.buildAdd(compressed, heapBase);
if (!nonNull) {
LLVMValueRef isNull = builder.buildIsNull(compressed);
uncompressed = builder.buildSelect(isNull, compressed, uncompressed);
}
uncompressed = builder.buildLLVMIntToPtr(uncompressed, builder.objectType(false));
builder.buildRet(uncompressed);
return func;
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef in project graal by oracle.
the class LLVMIRBuilder method positionAtStart.
public void positionAtStart() {
LLVMBasicBlockRef firstBlock = LLVM.LLVMGetFirstBasicBlock(function);
LLVMValueRef firstInstruction = LLVM.LLVMGetFirstInstruction(firstBlock);
if (firstInstruction != null) {
LLVM.LLVMPositionBuilderBefore(builder, firstInstruction);
}
}
Aggregations