use of com.oracle.truffle.llvm.runtime.nodes.intrinsics.llvm.LLVMAssume in project graal by oracle.
the class LLVMBitcodeInstructionVisitor method visit.
@Override
public void visit(VoidCallInstruction call) {
// stackpointer
final int argumentCount = call.getArgumentCount() + 1;
final LLVMExpressionNode[] argNodes = new LLVMExpressionNode[argumentCount];
final TypeArrayBuilder argTypes = new TypeArrayBuilder(argumentCount);
int argIndex = 0;
argNodes[argIndex] = nodeFactory.createGetStackFromFrame();
argTypes.set(argIndex, new PointerType(null));
argIndex++;
SymbolImpl target = call.getCallTarget();
int realArgumentCount = call.getCallTarget().getType() instanceof FunctionType ? ((FunctionType) call.getCallTarget().getType()).getNumberOfArguments() : argumentCount;
for (int i = call.getArgumentCount() - 1; i >= 0; i--) {
argNodes[argIndex + i] = resolveOptimized(call.getArgument(i), i, target, call.getArguments());
argTypes.set(argIndex + i, call.getArgument(i).getType());
final AttributesGroup paramAttr = call.getParameterAttributesGroup(i);
boolean isVarArg = i >= realArgumentCount;
if (isByValue(paramAttr)) {
argNodes[argIndex + i] = capsuleAddressByValue(argNodes[argIndex + i], argTypes.get(argIndex + i), paramAttr);
} else if (isVarArg && isArrayByValue(argTypes.get(argIndex + i), argNodes[argIndex + i])) {
argNodes[argIndex + i] = capsuleArrayByValue(argNodes[argIndex + i], argTypes.get(argIndex + i));
}
}
LLVMExpressionNode result = nodeFactory.createLLVMBuiltin(target, argNodes, argTypes, argCount);
if (call.getOperandBundle() != null && !(result instanceof LLVMAssume)) {
throw new LLVMParserException("Unsupported operand bundle on call of " + target.toString());
}
SourceInstrumentationStrategy intent = SourceInstrumentationStrategy.ONLY_FIRST_STATEMENT_ON_LOCATION;
if (result == null) {
if (target instanceof InlineAsmConstant) {
final InlineAsmConstant inlineAsmConstant = (InlineAsmConstant) target;
result = createInlineAssemblerNode(inlineAsmConstant, argNodes, argTypes, call.getType());
assignSourceLocation(result, call);
} else {
final LLVMExpressionNode function = resolveOptimized(target, call.getArguments());
final FunctionType functionType = new FunctionType(call.getType(), argTypes, false);
result = CommonNodeFactory.createFunctionCall(function, argNodes, functionType);
// the callNode needs to be instrumentable so that the debugger can see the CallTag.
// If it did not provide a source location, the debugger may not be able to show the
// node on the call stack or offer stepping into the call.
intent = SourceInstrumentationStrategy.FORCED;
}
}
addStatement(result, call, intent);
}
use of com.oracle.truffle.llvm.runtime.nodes.intrinsics.llvm.LLVMAssume in project graal by oracle.
the class LLVMBitcodeInstructionVisitor method visit.
@Override
public void visit(CallInstruction call) {
final Type targetType = call.getType();
int argumentCount = getArgumentCount(call.getArgumentCount(), targetType);
final LLVMExpressionNode[] argNodes = new LLVMExpressionNode[argumentCount];
final TypeArrayBuilder argTypes = new TypeArrayBuilder(argumentCount);
int argIndex = 0;
// stack pointer
argNodes[argIndex] = nodeFactory.createGetStackFromFrame();
argTypes.set(argIndex, new PointerType(null));
argIndex++;
if (targetType instanceof StructureType) {
argTypes.set(argIndex, new PointerType(targetType));
argNodes[argIndex] = nodeFactory.createGetUniqueStackSpace(targetType, uniquesRegion);
argIndex++;
}
// realArgumentCount = argumentCount - varArgCount
int realArgumentCount = call.getCallTarget().getType() instanceof FunctionType ? ((FunctionType) call.getCallTarget().getType()).getNumberOfArguments() : argumentCount;
final SymbolImpl target = call.getCallTarget();
for (int i = call.getArgumentCount() - 1; i >= 0; i--) {
argNodes[argIndex + i] = resolveOptimized(call.getArgument(i), i, target, call.getArguments());
argTypes.set(argIndex + i, call.getArgument(i).getType());
boolean isVarArg = i >= realArgumentCount;
final AttributesGroup paramAttr = call.getParameterAttributesGroup(i);
if (isByValue(paramAttr)) {
argNodes[argIndex + i] = capsuleAddressByValue(argNodes[argIndex + i], argTypes.get(argIndex + i), paramAttr);
} else if (isVarArg && isArrayByValue(argTypes.get(argIndex + i), argNodes[argIndex + i])) {
argNodes[argIndex + i] = capsuleArrayByValue(argNodes[argIndex + i], argTypes.get(argIndex + i));
}
}
LLVMExpressionNode result = nodeFactory.createLLVMBuiltin(target, argNodes, argTypes, argCount);
if (call.getOperandBundle() != null && !(result instanceof LLVMAssume)) {
throw new LLVMParserException("Unsupported operand bundle on call of " + target.toString());
}
SourceInstrumentationStrategy intent = SourceInstrumentationStrategy.ONLY_FIRST_STATEMENT_ON_LOCATION;
if (result == null) {
if (target instanceof InlineAsmConstant) {
final InlineAsmConstant inlineAsmConstant = (InlineAsmConstant) target;
result = createInlineAssemblerNode(inlineAsmConstant, argNodes, argTypes, targetType);
} else {
LLVMExpressionNode function = symbols.resolve(target);
result = CommonNodeFactory.createFunctionCall(function, argNodes, new FunctionType(targetType, argTypes, false));
// the callNode needs to be instrumentable so that the debugger can see the CallTag.
// If it did not provide a source location, the debugger may not be able to show the
// node on the call stack or offer stepping into the call.
intent = SourceInstrumentationStrategy.FORCED;
}
}
// the SourceSection references the call, not the return value assignment
createFrameWrite(result, call, intent);
}
Aggregations