use of com.oracle.truffle.llvm.runtime.types.Type in project sulong by graalvm.
the class Function method createCompareExchange.
private void createCompareExchange(long[] args, FunctionRecord record) {
int i = 0;
final Type ptrType;
final int ptr = getIndex(args[i]);
if (scope.isValueForwardRef(ptr)) {
ptrType = types.get(args[++i]);
} else {
ptrType = scope.getValueType(ptr);
}
final int cmp = getIndex(args[++i]);
if (record == FunctionRecord.CMPXCHG && scope.isValueForwardRef(cmp)) {
// type of cmp
++i;
}
final int replace = getIndex(args[++i]);
final boolean isVolatile = args[++i] != 0;
final long successOrdering = args[++i];
final long synchronizationScope = args[++i];
final long failureOrdering = i < args.length - 1 ? args[++i] : -1L;
final boolean addExtractValue = i >= args.length - 1;
final boolean isWeak = addExtractValue || (args[++i] != 0);
final Type type = findCmpxchgResultType(((PointerType) ptrType).getPointeeType());
emit(CompareExchangeInstruction.fromSymbols(scope.getSymbols(), type, ptr, cmp, replace, isVolatile, successOrdering, synchronizationScope, failureOrdering, isWeak));
if (addExtractValue) {
// in older llvm versions cmpxchg just returned the new value at the pointer, to emulate
// this we have to add an extractelvalue instruction. llvm does the same thing
createExtractValue(new long[] { 1, 0 });
// register the implicit index
implicitIndices.add(scope.getNextValueIndex() - 1);
}
}
use of com.oracle.truffle.llvm.runtime.types.Type in project sulong by graalvm.
the class Function method createBinaryOperation.
private void createBinaryOperation(long[] args) {
int i = 0;
Type type;
int lhs = getIndex(args[i++]);
if (scope.isValueForwardRef(lhs)) {
type = types.get(args[i++]);
} else {
type = scope.getValueType(lhs);
}
int rhs = getIndex(args[i++]);
int opcode = (int) args[i++];
int flags = i < args.length ? (int) args[i] : 0;
emit(BinaryOperationInstruction.fromSymbols(scope.getSymbols(), type, opcode, flags, lhs, rhs));
}
use of com.oracle.truffle.llvm.runtime.types.Type in project sulong by graalvm.
the class Function method createLoadAtomic.
private void createLoadAtomic(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 + LOADATOMIC_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;
final long atomicOrdering = args[i++];
final long synchronizationScope = args[i];
emit(LoadInstruction.fromSymbols(scope.getSymbols(), opType, src, align, isVolatile, atomicOrdering, synchronizationScope));
}
use of com.oracle.truffle.llvm.runtime.types.Type in project sulong by graalvm.
the class Function method createExtractElement.
private void createExtractElement(long[] args) {
int i = 0;
int vector = getIndex(args[i++]);
Type vectorType;
if (scope.isValueForwardRef(vector)) {
vectorType = types.get(args[i++]);
} else {
vectorType = scope.getValueType(vector);
}
int index = getIndex(args[i]);
final Type elementType = ((VectorType) vectorType).getElementType();
emit(ExtractElementInstruction.fromSymbols(scope.getSymbols(), elementType, vector, index));
}
use of com.oracle.truffle.llvm.runtime.types.Type in project sulong by graalvm.
the class Function method createCompare2.
private void createCompare2(long[] args) {
int i = 0;
Type operandType;
int lhs = getIndex(args[i++]);
if (scope.isValueForwardRef(lhs)) {
operandType = types.get(args[i++]);
} else {
operandType = scope.getValueType(lhs);
}
int rhs = getIndex(args[i++]);
int opcode = (int) args[i];
Type type = operandType instanceof VectorType ? new VectorType(PrimitiveType.I1, ((VectorType) operandType).getNumberOfElements()) : PrimitiveType.I1;
emit(CompareInstruction.fromSymbols(scope.getSymbols(), type, opcode, lhs, rhs));
}
Aggregations