J'ai un module LLVM (version 2.7) avec une fonction qui prend un pointeur vers une structure. Cette structure contient un pointeur de fonction vers une fonction C++. La fonction du module va être compilée par JIT, et j'ai besoin de construire cette structure en C++ en utilisant l'API LLVM. Je n'arrive pas à obtenir le pointeur sur la fonction en tant que valeur LLVM, et encore moins à passer un pointeur sur le ConstantStruct que je ne peux pas construire.LLVM: Passer un pointeur vers une structure, qui contient un pointeur sur une fonction, vers une fonction JIT
Je ne suis pas sûr si je suis même sur la bonne voie, mais c'est ce que j'ai jusqu'à présent:
void print(char*);
vector<Constant*> functions;
functions.push_back(ConstantExpr::getIntToPtr(
ConstantInt::get(Type::getInt32Ty(context), (int)print),
/* function pointer type here, FunctionType::get(...) doesn't seem to work */
));
ConstantStruct* struct = cast<ConstantStruct>(ConstantStruct::get(
cast<StructType>(m->getTypeByName("printer")),
functions
));
Function* main = m->getFunction("main");
vector<GenericValue> args;
args[0].PointerVal = /* not sure what goes here */
ee->runFunction(main, args);