use of com.oracle.truffle.llvm.parser.model.functions.FunctionDeclaration in project sulong by graalvm.
the class Module method createFunction.
private void createFunction(long[] args) {
final int recordOffset = useStrTab() ? STRTAB_RECORD_OFFSET : 0;
Type type = types.get(args[FUNCTION_TYPE + recordOffset]);
if (type instanceof PointerType) {
type = ((PointerType) type).getPointeeType();
}
final FunctionType functionType = (FunctionType) type;
final boolean isPrototype = args[FUNCTION_ISPROTOTYPE + recordOffset] != 0;
final Linkage linkage = Linkage.decode(args[FUNCTION_LINKAGE + recordOffset]);
final AttributesCodeEntry paramAttr = paramAttributes.getCodeEntry(args[FUNCTION_PARAMATTR + recordOffset]);
if (isPrototype) {
final FunctionDeclaration function = new FunctionDeclaration(functionType, linkage, paramAttr);
module.addFunctionDeclaration(function);
scope.addSymbol(function, function.getType());
if (useStrTab()) {
readNameFromStrTab(args, function);
}
} else {
final FunctionDefinition function = new FunctionDefinition(functionType, linkage, paramAttr);
module.addFunctionDefinition(function);
scope.addSymbol(function, function.getType());
if (useStrTab()) {
readNameFromStrTab(args, function);
}
functionQueue.addLast(function);
}
}
use of com.oracle.truffle.llvm.parser.model.functions.FunctionDeclaration 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.parser.model.functions.FunctionDeclaration in project sulong by graalvm.
the class LLVMLivenessAnalysis method resolve.
private static int resolve(FrameDescriptor frame, SymbolImpl symbol) {
if (symbol instanceof ValueSymbol && !(symbol instanceof GlobalValueSymbol || symbol instanceof FunctionDefinition || symbol instanceof FunctionDeclaration)) {
String name = ((ValueSymbol) symbol).getName();
assert name != null;
FrameSlot frameSlot = frame.findFrameSlot(name);
assert frameSlot != null : "No Frameslot for ValueSymbol: " + symbol;
return frameSlot.getIndex();
}
return -1;
}
Aggregations