-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjitmodule.h
More file actions
82 lines (69 loc) · 2.22 KB
/
jitmodule.h
File metadata and controls
82 lines (69 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#ifndef __JITMODULE_HPP__
#define __JITMODULE_HPP__
#ifndef __cplusplus
typedef struct _JitModule JitModule;
#else
class JitModule;
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef enum
{
JIT_MODULE_DEFAULT_FLAGS = 0x0,
JIT_MODULE_DEBUG_AST = 0x0100,
JIT_MODULE_DEBUG_LLVM = 0x0200,
JIT_MODULE_VERBOSE = 0x0400
} JitModuleFlags;
JitModule *jit_module_for_src(const char *src, unsigned int module_flags);
void *jit_module_get_iteration(JitModule *jm, const char *function_name, const char *return_type, ...);
void *jit_module_get_range_iteration(JitModule *jm, const char *function_name, const char *return_type, ...);
unsigned int jit_module_is_fallback_function(JitModule *jm, void *func);
void jit_module_destroy(JitModule *jm);
#ifdef __cplusplus
};
#endif
#ifdef __cplusplus
#include <map>
#include <list>
namespace llvm {
class Module;
class Function;
};
class JitModuleException : public std::exception
{
std::string error_string;
public:
JitModuleException (const char *e) : error_string(e) {}
JitModuleException (std::string e) : error_string(e) {}
~JitModuleException() throw() {}
const char* what() const throw() { return error_string.c_str(); }
};
class JitModuleIterationData
{
public:
llvm::Module *module;
llvm::Function *function;
void *compiledFunciton;
bool voidFunction;
JitModuleIterationData() : module(NULL), function(NULL), compiledFunciton(NULL), voidFunction(false) {};
};
class JitModuleState;
class JitModule
{
llvm::Module *module;
JitModuleState *internal;
unsigned int flags;
std::map<std::string, JitModuleIterationData> liveFunctions;
public:
JitModule(const char *sourcecode, unsigned int module_flags);
void *getIteration(const char *function_name, const char *return_type, ...) __attribute__ ((sentinel));
void *getIteration(const char *function_name, const std::list<std::string> &argstrs);
void *getRangeIteration(const char *function_name, const char *return_type, ...) __attribute__ ((sentinel));
void *getRangeIteration(const char *function_name, const std::list<std::string> &argstrs);
bool isFallbackFunction(void *function);
~JitModule();
std::string getLLVMCode();
};
#endif /* __cplusplus */
#endif /* __JITMODULE_HPP__ */