use of com.oracle.truffle.llvm.parser.model.SymbolImpl in project sulong by graalvm.
the class DITypeExtractor method visit.
@Override
public void visit(MDGlobalVariable mdGlobal) {
final LLVMSourceType type = resolve(mdGlobal.getType());
parsedTypes.put(mdGlobal, type);
if (mdGlobal.getStaticMemberDeclaration() != MDVoidNode.INSTANCE && mdGlobal.getVariable() instanceof MDValue) {
final LLVMSourceType declType = resolve(mdGlobal.getStaticMemberDeclaration());
final SymbolImpl symbol = ((MDValue) mdGlobal.getVariable()).getValue();
if (declType instanceof LLVMSourceStaticMemberType) {
staticMembers.put((LLVMSourceStaticMemberType) declType, symbol);
}
}
}
use of com.oracle.truffle.llvm.parser.model.SymbolImpl 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.parser.model.SymbolImpl in project sulong by graalvm.
the class AggregateConstant method toString.
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < getElementCount(); i++) {
if (i > 0) {
sb.append(", ");
}
SymbolImpl value = getElement(i);
sb.append(value.getType()).append(" ").append(value);
}
return sb.toString();
}
use of com.oracle.truffle.llvm.parser.model.SymbolImpl in project sulong by graalvm.
the class LLVMBitcodeInstructionVisitor method visit.
@Override
public void visit(CallInstruction call) {
final Type targetType = call.getType();
int argumentCount = getArgumentCount(call.getArgumentCount(), targetType);
final LLVMExpressionNode[] argNodes = new LLVMExpressionNode[argumentCount];
final Type[] argTypes = new Type[argumentCount];
int argIndex = 0;
// stack pointer
argNodes[argIndex] = nodeFactory.createFrameRead(runtime, PointerType.VOID, getStackSlot());
argTypes[argIndex] = new PointerType(null);
argIndex++;
if (targetType instanceof StructureType) {
argTypes[argIndex] = new PointerType(targetType);
argNodes[argIndex] = nodeFactory.createAlloca(runtime, targetType);
argIndex++;
}
for (int i = 0; argIndex < argumentCount; i++) {
argNodes[argIndex] = symbols.resolve(call.getArgument(i));
argTypes[argIndex] = call.getArgument(i).getType();
final AttributesGroup paramAttr = call.getParameterAttributesGroup(i);
if (isByValue(paramAttr)) {
argNodes[argIndex] = capsuleAddressByValue(argNodes[argIndex], argTypes[argIndex], paramAttr);
}
argIndex++;
}
final LLVMSourceLocation source = sourceFunction.getSourceLocation(call);
final SymbolImpl target = call.getCallTarget();
LLVMExpressionNode result = nodeFactory.createLLVMBuiltin(runtime, target, argNodes, argCount, source);
if (result == null) {
if (target instanceof InlineAsmConstant) {
final InlineAsmConstant inlineAsmConstant = (InlineAsmConstant) target;
result = createInlineAssemblerNode(inlineAsmConstant, argNodes, argTypes, targetType, source);
} else {
LLVMExpressionNode function = symbols.resolve(target);
result = nodeFactory.createFunctionCall(runtime, function, argNodes, new FunctionType(targetType, argTypes, false), source);
}
}
// the SourceSection references the call, not the return value assignment
createFrameWrite(result, call, null);
}
use of com.oracle.truffle.llvm.parser.model.SymbolImpl in project sulong by graalvm.
the class LLVMBitcodeInstructionVisitor method visit.
@Override
public void visit(VoidInvokeInstruction call) {
final SymbolImpl target = call.getCallTarget();
// stackpointer
final int argumentCount = call.getArgumentCount() + 1;
final LLVMExpressionNode[] args = new LLVMExpressionNode[argumentCount];
final Type[] argsType = new Type[argumentCount];
int argIndex = 0;
args[argIndex] = nodeFactory.createFrameRead(runtime, PointerType.VOID, getStackSlot());
argsType[argIndex] = new PointerType(null);
argIndex++;
for (int i = 0; i < call.getArgumentCount(); i++) {
args[argIndex] = symbols.resolve(call.getArgument(i));
argsType[argIndex] = call.getArgument(i).getType();
final AttributesGroup paramAttr = call.getParameterAttributesGroup(i);
if (isByValue(paramAttr)) {
args[argIndex] = capsuleAddressByValue(args[argIndex], argsType[argIndex], paramAttr);
}
argIndex++;
}
int regularIndex = call.normalSuccessor().getBlockIndex();
int unwindIndex = call.unwindSuccessor().getBlockIndex();
List<FrameSlot> normalTo = new ArrayList<>();
List<FrameSlot> unwindTo = new ArrayList<>();
List<Type> normalType = new ArrayList<>();
List<Type> unwindType = new ArrayList<>();
List<LLVMExpressionNode> normalValue = new ArrayList<>();
List<LLVMExpressionNode> unwindValue = new ArrayList<>();
if (blockPhis != null) {
for (Phi phi : blockPhis) {
FrameSlot slot = getSlot(phi.getPhiValue().getName());
LLVMExpressionNode value = symbols.resolve(phi.getValue());
if (call.normalSuccessor() == phi.getBlock()) {
normalTo.add(slot);
normalType.add(phi.getValue().getType());
normalValue.add(value);
} else {
unwindTo.add(slot);
unwindType.add(phi.getValue().getType());
unwindValue.add(value);
}
}
}
LLVMExpressionNode normalPhi = nodeFactory.createPhi(runtime, normalValue.toArray(new LLVMExpressionNode[normalValue.size()]), normalTo.toArray(new FrameSlot[normalTo.size()]), normalType.toArray(Type.EMPTY_ARRAY));
LLVMExpressionNode unwindPhi = nodeFactory.createPhi(runtime, unwindValue.toArray(new LLVMExpressionNode[unwindValue.size()]), unwindTo.toArray(new FrameSlot[unwindTo.size()]), unwindType.toArray(Type.EMPTY_ARRAY));
final LLVMSourceLocation source = sourceFunction.getSourceLocation(call);
LLVMExpressionNode function = nodeFactory.createLLVMBuiltin(runtime, target, args, argCount, null);
if (function == null) {
function = symbols.resolve(target);
}
LLVMControlFlowNode result = nodeFactory.createFunctionInvoke(runtime, null, function, args, new FunctionType(call.getType(), argsType, false), regularIndex, unwindIndex, normalPhi, unwindPhi, source);
setControlFlowNode(result);
}
Aggregations