#include <map>
#include <string>
#include <vector>
+#include <functional>
namespace llvm {
uint64_t RemoveMapping(StringRef Name);
};
+using FunctionCreator = std::function<void *(const std::string &)>;
+
/// \brief Abstract interface for implementation execution of LLVM modules,
/// designed to support both interpreter and just-in-time (JIT) compiler
/// implementations.
/// LazyFunctionCreator - If an unknown function is needed, this function
/// pointer is invoked to create it. If this returns null, the JIT will
/// abort.
- void *(*LazyFunctionCreator)(const std::string &);
+ FunctionCreator LazyFunctionCreator;
/// getMangledName - Get mangled name.
std::string getMangledName(const GlobalValue *GV);
/// M is found.
virtual bool removeModule(Module *M);
- /// FindFunctionNamed - Search all of the active modules to find the one that
+ /// FindFunctionNamed - Search all of the active modules to find the function that
/// defines FnName. This is very slow operation and shouldn't be used for
/// general code.
virtual Function *FindFunctionNamed(const char *FnName);
+ /// FindGlobalVariableNamed - Search all of the active modules to find the global variable
+ /// that defines Name. This is very slow operation and shouldn't be used for
+ /// general code.
+ virtual GlobalVariable *FindGlobalVariableNamed(const char *Name, bool AllowInternal = false);
+
/// runFunction - Execute the specified function with the specified arguments,
/// and return the result.
virtual GenericValue runFunction(Function *F,
- const std::vector<GenericValue> &ArgValues) = 0;
+ ArrayRef<GenericValue> ArgValues) = 0;
/// getPointerToNamedFunction - This method returns the address of the
/// specified function by using the dlsym function call. As such it is only
/// InstallLazyFunctionCreator - If an unknown function is needed, the
/// specified function pointer is invoked to create it. If it returns null,
/// the JIT will abort.
- void InstallLazyFunctionCreator(void* (*P)(const std::string &)) {
- LazyFunctionCreator = P;
+ void InstallLazyFunctionCreator(FunctionCreator C) {
+ LazyFunctionCreator = C;
}
protected: