use of com.oracle.truffle.llvm.parser.model.symbols.constants.integer.IntegerConstant in project sulong by graalvm.
the class ParseUtil method asLong.
public static long asLong(long[] args, int index, Metadata md) {
final int typeIndex = index << 1;
if (typeIndex >= args.length) {
return DEFAULT_NUMBER;
}
final Type type = md.getTypeById(args[typeIndex]);
if (type == MetaType.METADATA || VoidType.INSTANCE.equals(type)) {
return DEFAULT_NUMBER;
}
final int valueIndex = typeIndex + 1;
final SymbolImpl value = md.getScope().getSymbols().getOrNull((int) args[valueIndex]);
if (value instanceof IntegerConstant) {
return ((IntegerConstant) value).getValue();
} else if (value instanceof BigIntegerConstant) {
return ((BigIntegerConstant) value).getValue().longValue();
} else if (value instanceof NullConstant || value instanceof UndefinedConstant) {
return 0L;
} else {
return DEFAULT_NUMBER;
}
}
use of com.oracle.truffle.llvm.parser.model.symbols.constants.integer.IntegerConstant in project sulong by graalvm.
the class LLVMBitcodeInstructionVisitor method visit.
@Override
public void visit(AllocateInstruction allocate) {
final Type type = allocate.getPointeeType();
int alignment;
if (allocate.getAlign() == 0) {
alignment = runtime.getContext().getByteAlignment(type);
} else {
alignment = 1 << (allocate.getAlign() - 1);
}
if (alignment == 0) {
alignment = LLVMStack.NO_ALIGNMENT_REQUIREMENTS;
}
final SymbolImpl count = allocate.getCount();
final LLVMExpressionNode result;
if (count instanceof NullConstant) {
result = nodeFactory.createAlloca(runtime, type, alignment);
} else if (count instanceof IntegerConstant) {
long numElements = (int) ((IntegerConstant) count).getValue();
if (numElements == 1) {
result = nodeFactory.createAlloca(runtime, type, alignment);
} else {
assert numElements == (int) numElements;
ArrayType arrayType = new ArrayType(type, (int) numElements);
result = nodeFactory.createAlloca(runtime, arrayType, alignment);
}
} else {
LLVMExpressionNode num = symbols.resolve(count);
result = nodeFactory.createAllocaArray(runtime, type, num, alignment);
}
// we never want to step on allocations, only to actual assignments in the source
createFrameWrite(result, allocate, null);
}
use of com.oracle.truffle.llvm.parser.model.symbols.constants.integer.IntegerConstant 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;
}
Aggregations