use of com.oracle.truffle.llvm.runtime.types.Type in project sulong by graalvm.
the class Function method createLoad.
private void createLoad(long[] args) {
int i = 0;
final int src = getIndex(args[i++]);
final Type srcType;
if (scope.isValueForwardRef(src)) {
srcType = types.get(args[i++]);
} else {
srcType = scope.getValueType(src);
}
final Type opType;
if (i + LOAD_ARGS_EXPECTED_AFTER_TYPE == args.length) {
opType = types.get(args[i++]);
} else {
opType = ((PointerType) srcType).getPointeeType();
}
final int align = getAlign(args[i++]);
final boolean isVolatile = args[i] != 0;
emit(LoadInstruction.fromSymbols(scope.getSymbols(), opType, src, align, isVolatile));
}
use of com.oracle.truffle.llvm.runtime.types.Type in project sulong by graalvm.
the class Function method createLandingpad.
private void createLandingpad(long[] args) {
int i = 0;
final Type type = types.get(args[i++]);
final boolean isCleanup = args[i++] != 0;
final int numClauses = (int) args[i++];
// catch = 0, filter = 1
long[] clauseKinds = new long[numClauses];
long[] clauseTypes = new long[numClauses];
for (int j = 0; j < numClauses; j++) {
clauseKinds[j] = args[i++];
clauseTypes[j] = getIndex(args[i++]);
if (scope.isValueForwardRef(clauseTypes[j])) {
i++;
}
}
emit(LandingpadInstruction.generate(scope.getSymbols(), type, isCleanup, clauseKinds, clauseTypes));
}
use of com.oracle.truffle.llvm.runtime.types.Type in project sulong by graalvm.
the class Function method createInvoke.
private void createInvoke(long[] args) {
int i = 0;
final AttributesCodeEntry paramAttr = paramAttributes.getCodeEntry(args[i++]);
final long ccInfo = args[i++];
final InstructionBlock normalSuccessor = function.getBlock(args[i++]);
final InstructionBlock unwindSuccessor = function.getBlock(args[i++]);
FunctionType functionType = null;
if (((ccInfo >> INVOKE_HASEXPLICITFUNCTIONTYPE_SHIFT) & 1) != 0) {
functionType = (FunctionType) types.get(args[i++]);
}
final int target = getIndex(args[i++]);
final Type calleeType;
if (scope.isValueForwardRef(target)) {
calleeType = types.get(args[i++]);
} else {
calleeType = scope.getValueType(target);
}
if (functionType == null) {
if (calleeType instanceof PointerType) {
functionType = (FunctionType) ((PointerType) calleeType).getPointeeType();
} else if (calleeType instanceof FunctionType) {
functionType = (FunctionType) calleeType;
} else {
throw new AssertionError("Cannot find Type of invoked function: " + calleeType.toString());
}
}
int[] arguments = new int[args.length - i];
int skipped = 0;
int j = 0;
while (j < functionType.getArgumentTypes().length && i < args.length) {
arguments[j++] = getIndex(args[i++]);
}
while (i < args.length) {
int index = getIndex(args[i++]);
arguments[j++] = index;
if (scope.isValueForwardRef(index)) {
i++;
skipped++;
}
}
if (skipped > 0) {
arguments = Arrays.copyOf(arguments, arguments.length - skipped);
}
final Type returnType = functionType.getReturnType();
if (returnType == VoidType.INSTANCE) {
emit(VoidInvokeInstruction.fromSymbols(scope, target, arguments, normalSuccessor, unwindSuccessor, paramAttr));
} else {
emit(InvokeInstruction.fromSymbols(scope, returnType, target, arguments, normalSuccessor, unwindSuccessor, paramAttr));
}
isLastBlockTerminated = true;
}
use of com.oracle.truffle.llvm.runtime.types.Type in project sulong by graalvm.
the class Function method createGetElementPointerOld.
private void createGetElementPointerOld(long[] args, boolean isInbounds) {
int i = 0;
int pointer = getIndex(args[i++]);
Type base;
if (scope.isValueForwardRef(pointer)) {
base = types.get(args[i++]);
} else {
base = scope.getValueType(pointer);
}
List<Integer> indices = getIndices(args, i);
Type type = new PointerType(getElementPointerType(base, indices));
emit(GetElementPointerInstruction.fromSymbols(scope.getSymbols(), type, pointer, indices, isInbounds));
}
use of com.oracle.truffle.llvm.runtime.types.Type in project sulong by graalvm.
the class Function method createShuffleVector.
private void createShuffleVector(long[] args) {
int i = 0;
int vector1 = getIndex(args[i++]);
Type vectorType;
if (scope.isValueForwardRef(vector1)) {
vectorType = types.get(args[i++]);
} else {
vectorType = scope.getValueType(vector1);
}
int vector2 = getIndex(args[i++]);
int mask = getIndex(args[i]);
Type subtype = ((VectorType) vectorType).getElementType();
int length = ((VectorType) scope.getValueType(mask)).getNumberOfElements();
Type type = new VectorType(subtype, length);
emit(ShuffleVectorInstruction.fromSymbols(scope.getSymbols(), type, vector1, vector2, mask));
}
Aggregations