25 #if ! defined (octave_pt_jit_h)
26 #define octave_pt_jit_h 1
28 #include "octave-config.h"
30 #if defined (HAVE_LLVM)
51 #define DECL_ARG(n) const ARG ## n& arg ## n
52 #define JIT_CREATE_CHECKED(N) \
53 template <OCT_MAKE_DECL_LIST (typename, ARG, N)> \
54 jit_call *create_checked (OCT_MAKE_LIST (DECL_ARG, N)) \
56 jit_call *ret = factory.create<jit_call> (OCT_MAKE_ARG_LIST (arg, N)); \
57 return create_checked_impl (ret); \
65 #undef JIT_CREATE_CHECKED
70 const type_bound_vector& get_bounds (
void)
const {
return bounds; }
74 llvm::Function *get_function (
void)
const {
return function; }
76 const variable_map &get_variable_map (
void)
const {
return vmap; }
166 std::vector<std::pair<std::string, bool> >
arguments;
167 type_bound_vector bounds;
169 bool converting_function;
185 llvm::Function *
function;
189 std::vector<jit_magic_end::context> end_context;
191 size_t iterator_count;
192 size_t for_bounds_count;
217 {
return next_name (
"#iter", iterator_count, inc); }
220 {
return next_name (
"#for_bounds", for_bounds_count, inc); }
222 std::string next_shortcircut_result (
bool inc =
true)
223 {
return next_name (
"#shortcircut_result", short_count, inc); }
225 std::string next_name (
const char *prefix,
size_t& count,
bool inc);
228 jit_value *extra_arg = 0,
bool lhs =
false);
231 bool artificial =
false);
234 bool artificial =
false);
242 block_list continues;
244 void finish_breaks (
jit_block *dest,
const block_list& lst);
252 llvm::Function *convert_loop (llvm::Module *module,
254 const std::list<jit_value *>& constants);
258 const std::list<jit_value *>& constants,
260 const std::vector<jit_type *>&
args);
263 const std::vector<std::pair<std::string, bool> >& get_arguments(
void)
const
264 {
return argument_vec; }
266 #define JIT_METH(clname) \
267 virtual void visit (jit_ ## clname&);
274 std::map<std::string, int> argument_index;
276 std::vector<std::pair<std::string, bool> > argument_vec;
281 bool converting_function;
286 llvm::Function *
function;
287 llvm::BasicBlock *prelude;
290 const std::list<jit_value *>& constants);
292 void finish_phi (
jit_phi *phi);
296 return visit (*jvalue);
313 const variable_map& avmap);
323 const variable_map& vmap;
324 std::list<jit_instruction *> worklist;
330 void construct_ssa (
void);
332 void do_construct_ssa (
jit_block& block,
size_t avisit_count);
338 void place_releases (
void);
344 void release_dead_phi (
jit_block& ablock);
346 void release_temp (
jit_block& ablock, std::set<jit_value *>& temp);
348 void simplify_phi (
void);
350 void simplify_phi (
jit_phi& phi);
367 llvm::ExecutionEngine *get_engine (
void)
const {
return engine; }
369 llvm::Module *get_module (
void)
const {
return module; }
371 void optimize (llvm::Function *fn);
390 llvm::Module *module;
391 #if defined (LEGACY_PASSMANAGER)
392 llvm::legacy::PassManager *module_pass_manager;
393 llvm::legacy::FunctionPassManager *pass_manager;
395 llvm::PassManager *module_pass_manager;
396 llvm::FunctionPassManager *pass_manager;
398 llvm::ExecutionEngine *engine;
415 std::vector<jit_type *> argument_types;
416 jited_function
function;
424 typedef std::map<std::string, const octave_value *> vmap;
432 bool execute (
const vmap& extra_vars = vmap ())
const;
434 bool match (
const vmap& extra_vars = vmap ())
const;
444 llvm::ExecutionEngine *engine;
445 jited_function
function;
446 llvm::Function *llvm_function;
448 std::vector<std::pair<std::string, bool> >
arguments;
449 type_bound_vector bounds;
#define JIT_VISIT_IR_CLASSES
virtual void accept(jit_ir_walker &walker)=0
jit_block * back(void) const
std::list< jit_block * > block_list
jit_block * front(void) const
static std::string get_variable(const char *name, const std::string &defval)
With real return the complex result
static octave_idx_type find(octave_idx_type i, octave_idx_type *pp)
std::pair< jit_type *, std::string > type_bound
std::map< std::string, jit_variable * > variable_map
static void initialize(void)
#define JIT_CREATE_CHECKED(N)
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
void visit(jit_value &jvalue)
std::vector< type_bound > type_bound_vector