use of com.oracle.truffle.llvm.runtime.nodes.func.LLVMInlineAssemblyRootNode in project graal by oracle.
the class BasicNodeFactory method createInlineAssemblerExpression.
@Override
public LLVMExpressionNode createInlineAssemblerExpression(String asmExpression, String asmFlags, LLVMExpressionNode[] args, Type.TypeArrayBuilder argTypes, Type retType) {
Type[] retTypes = null;
long[] retOffsets = null;
if (retType instanceof StructureType) {
// multiple out values
StructureType struct = (StructureType) retType;
retOffsets = new long[struct.getNumberOfElementsInt()];
retTypes = new Type[struct.getNumberOfElementsInt()];
long currentOffset = 0;
try {
for (int i = 0; i < struct.getNumberOfElements(); i++) {
Type elemType = struct.getElementType(i);
if (!struct.isPacked()) {
currentOffset = Type.addUnsignedExact(currentOffset, getBytePadding(currentOffset, elemType));
}
retOffsets[i] = currentOffset;
retTypes[i] = elemType;
currentOffset = Type.addUnsignedExact(currentOffset, getByteSize(elemType));
}
assert currentOffset <= getByteSize(retType) : "currentOffset " + currentOffset + " vs. byteSize " + getByteSize(retType);
} catch (TypeOverflowException e) {
return Type.handleOverflowExpression(e);
}
}
LLVMInlineAssemblyRootNode assemblyRoot;
try {
assemblyRoot = InlineAssemblyParser.parseInlineAssembly(asmExpression, new AsmFactory(language, argTypes, asmFlags, retType, retTypes, retOffsets, this));
} catch (AsmParseException e) {
assemblyRoot = getLazyUnsupportedInlineRootNode(asmExpression, e);
}
LLVMIRFunction function = new LLVMIRFunction(assemblyRoot.getCallTarget(), null);
LLVMFunction functionDetail = LLVMFunction.create("<asm>", function, new FunctionType(MetaType.UNKNOWN, 0, false), IDGenerater.INVALID_ID, LLVMSymbol.INVALID_INDEX, false, assemblyRoot.getName(), false);
// The function descriptor for the inline assembly does not require a language.
LLVMFunctionDescriptor asm = new LLVMFunctionDescriptor(functionDetail, new LLVMFunctionCode(functionDetail));
LLVMManagedPointerLiteralNode asmFunction = LLVMManagedPointerLiteralNodeGen.create(LLVMManagedPointer.create(asm));
return LLVMCallNode.create(new FunctionType(MetaType.UNKNOWN, argTypes, false), asmFunction, args, false);
}
use of com.oracle.truffle.llvm.runtime.nodes.func.LLVMInlineAssemblyRootNode in project graal by oracle.
the class BasicNodeFactory method getLazyUnsupportedInlineRootNode.
private LLVMInlineAssemblyRootNode getLazyUnsupportedInlineRootNode(String asmExpression, AsmParseException e) {
LLVMInlineAssemblyRootNode assemblyRoot;
String message = asmExpression + ": " + e.getMessage();
FrameDescriptor.Builder builder = FrameDescriptor.newBuilder();
addStackSlots(builder);
assemblyRoot = new LLVMInlineAssemblyRootNode(language, builder.build(), createStackAccess(), Collections.singletonList(LLVMUnsupportedInstructionNode.create(UnsupportedReason.INLINE_ASSEMBLER, message)), Collections.emptyList(), null);
return assemblyRoot;
}
Aggregations