use of com.oracle.truffle.llvm.runtime.except.LLVMParserException in project graal by oracle.
the class ParameterAttributes method decodeCodeEntry.
private void decodeCodeEntry(RecordBuffer buffer) {
final List<AttributesGroup> attrGroup = new ArrayList<>();
while (buffer.remaining() > 0) {
long groupId = buffer.read();
for (AttributesGroup attr : attributes) {
if (attr.getGroupId() == groupId) {
attrGroup.add(attr);
break;
}
}
}
if (attrGroup.size() != buffer.size()) {
throw new LLVMParserException("Mismatching number of defined and found attributes in AttributesGroup");
}
parameterCodeEntry.add(new AttributesCodeEntry(attrGroup));
}
use of com.oracle.truffle.llvm.runtime.except.LLVMParserException in project graal by oracle.
the class Function method createInvoke.
private void createInvoke(RecordBuffer buffer) {
AttributesCodeEntry paramAttr = paramAttributes.getCodeEntry(buffer.read());
long ccInfo = buffer.read();
InstructionBlock normalSuccessor = function.getBlock(buffer.read());
InstructionBlock unwindSuccessor = function.getBlock(buffer.read());
FunctionType functionType = null;
if (((ccInfo >> INVOKE_HASEXPLICITFUNCTIONTYPE_SHIFT) & 1) != 0) {
functionType = Types.castToFunction(readType(buffer));
}
int target = readIndex(buffer);
Type calleeType = readValueType(buffer, target);
if (functionType == null) {
if (calleeType instanceof PointerType) {
functionType = Types.castToFunction(((PointerType) calleeType).getPointeeType());
} else if (calleeType instanceof FunctionType) {
functionType = (FunctionType) calleeType;
} else {
throw new LLVMParserException("Cannot find Type of invoked function: " + calleeType);
}
}
int[] args = new int[buffer.remaining()];
int j = 0;
// the formal parameters are read without forward types
while (j < functionType.getNumberOfArguments() && buffer.remaining() > 0) {
args[j++] = readIndex(buffer);
}
// now varargs are read with forward types
while (buffer.remaining() > 0) {
args[j++] = readIndexSkipType(buffer);
}
if (args.length != j) {
args = Arrays.copyOf(args, j);
}
final Type returnType = functionType.getReturnType();
if (returnType == VoidType.INSTANCE) {
emit(VoidInvokeInstruction.fromSymbols(scope, target, args, normalSuccessor, unwindSuccessor, paramAttr, operandBundle));
} else {
emit(InvokeInstruction.fromSymbols(scope, returnType, target, args, normalSuccessor, unwindSuccessor, paramAttr, operandBundle));
}
operandBundle = null;
isLastBlockTerminated = true;
}
use of com.oracle.truffle.llvm.runtime.except.LLVMParserException in project graal by oracle.
the class RecursiveTypesTest method createConfig.
private static void createConfig(ArrayList<Object[]> configs, TypeFactory rootFactory, List<TypeFactory> otherFactories) {
try {
String name = Stream.concat(Stream.of(rootFactory), otherFactories.stream()).map(TypeFactory::toString).collect(Collectors.joining("-"));
Type rootType = createRecursiveType(rootFactory, otherFactories);
Type copyType = createRecursiveType(rootFactory, otherFactories);
configs.add(new Object[] { name, rootType, copyType });
Type indirectRootType = rootFactory.create(rootType);
Type indirectCopyType = rootFactory.create(copyType);
configs.add(new Object[] { name + "_indirect", indirectRootType, indirectCopyType });
} catch (LLVMParserException | AssertionError e) {
// cannot create type
}
}
use of com.oracle.truffle.llvm.runtime.except.LLVMParserException in project graal by oracle.
the class LLVMBitcodeInstructionVisitor method visit.
@Override
public void visit(InsertValueInstruction insert) {
if (!(insert.getAggregate().getType() instanceof StructureType || insert.getAggregate().getType() instanceof ArrayType)) {
throw new LLVMParserException("\'insertvalue\' can only insert values into arrays and structs!");
}
final AggregateType sourceType = (AggregateType) insert.getAggregate().getType();
final LLVMExpressionNode sourceAggregate = symbols.resolve(insert.getAggregate());
final LLVMExpressionNode valueToInsert = symbols.resolve(insert.getValue());
final Type valueType = insert.getValue().getType();
final int targetIndex = insert.getIndex();
final LLVMExpressionNode resultAggregate = nodeFactory.createGetUniqueStackSpace(sourceType, uniquesRegion);
LLVMExpressionNode result;
try {
final long offset = sourceType.getOffsetOf(targetIndex, dataLayout);
result = nodeFactory.createInsertValue(resultAggregate, sourceAggregate, sourceType.getSize(dataLayout), offset, valueToInsert, valueType);
} catch (TypeOverflowException e) {
// FIXME is that the right thing to do?
result = Type.handleOverflowExpression(e);
}
createFrameWrite(result, insert);
}
use of com.oracle.truffle.llvm.runtime.except.LLVMParserException in project graal by oracle.
the class LLVMBitcodeInstructionVisitor method assignSourceLocation.
private void assignSourceLocation(LLVMInstrumentableNode node, Instruction sourceInstruction, SourceInstrumentationStrategy instrumentationStrategy) {
if (node == null) {
return;
}
final LLVMSourceLocation location = sourceInstruction.getSourceLocation();
if (location == null) {
return;
}
node.setSourceLocation(location);
assert instrumentationStrategy != null;
switch(instrumentationStrategy) {
case FORCED:
node.setHasStatementTag(true);
lastLocation = location;
break;
case ONLY_FIRST_STATEMENT_ON_LOCATION:
if (lastLocation == location) {
// shortcut for locations assigned by DEBUG_LOC_AGAIN
break;
} else if (lastLocation != null && Objects.equals(lastLocation.describeFile(), location.describeFile()) && lastLocation.getLine() == location.getLine()) {
// though llvm debug information does not actually describe statement boundaries
break;
} else {
node.setHasStatementTag(true);
lastLocation = location;
}
break;
case DISABLED:
break;
default:
throw new LLVMParserException("Unknown instrumentation strategy: " + instrumentationStrategy);
}
}
Aggregations