use of com.oracle.truffle.llvm.runtime.types.Type in project sulong by graalvm.
the class Module method createGlobalAliasOld.
private void createGlobalAliasOld(long[] args) {
final int recordOffset = useStrTab() ? STRTAB_RECORD_OFFSET : 0;
final Type type = types.get(args[GLOBALALIAS_TYPE + recordOffset]);
int value = (int) args[GLOBALALIAS_OLD_VALUE + recordOffset];
long linkage = args[GLOBALALIAS_OLD_LINKAGE + recordOffset];
final GlobalAlias global = GlobalAlias.create(type, linkage, Visibility.DEFAULT.ordinal(), scope.getSymbols(), value);
if (useStrTab()) {
readNameFromStrTab(args, global);
}
module.addGlobalSymbol(global);
scope.addSymbol(global, global.getType());
}
use of com.oracle.truffle.llvm.runtime.types.Type in project sulong by graalvm.
the class ParseUtil method resolveReference.
static MDBaseNode resolveReference(long[] args, int index, MDBaseNode dependent, Metadata md) {
final int typeIndex = index << 1;
if (typeIndex >= args.length) {
return MDVoidNode.INSTANCE;
}
final int valueIndex = typeIndex + 1;
final Type type = md.getTypeById(args[typeIndex]);
final long value = args[valueIndex];
if (type == MetaType.METADATA) {
return md.getScope().getMetadata().getNonNullable(value, dependent);
} else if (type != VoidType.INSTANCE) {
return MDValue.create(value, md.getScope());
} else {
return MDVoidNode.INSTANCE;
}
}
use of com.oracle.truffle.llvm.runtime.types.Type in project sulong by graalvm.
the class ParseUtil method isInteger.
public static boolean isInteger(long[] args, int index, Metadata md) {
final int typeIndex = index << 1;
final Type type = md.getTypeById(args[typeIndex]);
if (type == MetaType.METADATA || VoidType.INSTANCE.equals(type)) {
return false;
}
final int valueIndex = typeIndex + 1;
final SymbolImpl value = md.getScope().getSymbols().getOrNull((int) args[valueIndex]);
return value instanceof IntegerConstant || value instanceof BigIntegerConstant || value instanceof NullConstant || value instanceof UndefinedConstant;
}
use of com.oracle.truffle.llvm.runtime.types.Type in project sulong by graalvm.
the class FunctionStart method parseArguments.
static void parseArguments(IRScope scope, SymbolImpl callTarget, Instruction inst, SymbolImpl[] target, int[] src) {
if (src.length == 0) {
return;
}
final Type[] paramTypes;
if (callTarget instanceof FunctionDefinition) {
paramTypes = ((FunctionDefinition) (callTarget)).getType().getArgumentTypes();
} else if (callTarget instanceof FunctionDeclaration) {
paramTypes = ((FunctionDeclaration) (callTarget)).getType().getArgumentTypes();
} else {
paramTypes = Type.EMPTY_ARRAY;
}
final SymbolTable symbols = scope.getSymbols();
for (int i = Math.min(paramTypes.length, src.length) - 1; i >= 0; i--) {
if (paramTypes[i] == MetaType.METADATA) {
target[i] = MetadataSymbol.create(scope.getMetadata(), src[i]);
} else {
target[i] = symbols.getForwardReferenced(src[i], inst);
}
}
// parse varargs
for (int i = paramTypes.length; i < src.length; i++) {
target[i] = symbols.getForwardReferenced(src[i], inst);
}
}
use of com.oracle.truffle.llvm.runtime.types.Type in project sulong by graalvm.
the class BasicNodeFactory method createStructureConstantNode.
@Override
public LLVMExpressionNode createStructureConstantNode(LLVMParserRuntime runtime, Type structType, boolean packed, Type[] types, LLVMExpressionNode[] constants) {
int[] offsets = new int[types.length];
LLVMStoreNode[] nodes = new LLVMStoreNode[types.length];
int currentOffset = 0;
LLVMExpressionNode alloc = createAlloca(runtime, structType);
for (int i = 0; i < types.length; i++) {
Type resolvedType = types[i];
if (!packed) {
currentOffset += runtime.getContext().getBytePadding(currentOffset, resolvedType);
}
offsets[i] = currentOffset;
int byteSize = runtime.getContext().getByteSize(resolvedType);
nodes[i] = createMemoryStore(runtime, resolvedType);
currentOffset += byteSize;
}
return StructLiteralNodeGen.create(offsets, nodes, constants, alloc);
}
Aggregations