25 #if !defined (octave_pt_jit_h)
26 #define octave_pt_jit_h 1
49 #define DECL_ARG(n) const ARG ## n& arg ## n
50 #define JIT_CREATE_CHECKED(N) \
51 template <OCT_MAKE_DECL_LIST (typename, ARG, N)> \
52 jit_call *create_checked (OCT_MAKE_LIST (DECL_ARG, N)) \
54 jit_call *ret = factory.create<jit_call> (OCT_MAKE_ARG_LIST (arg, N)); \
55 return create_checked_impl (ret); \
63 #undef JIT_CREATE_CHECKED
68 const type_bound_vector& get_bounds (
void)
const {
return bounds; }
72 llvm::Function *get_function (
void)
const {
return function; }
74 const variable_map &get_variable_map (
void)
const {
return vmap; }
164 std::vector<std::pair<std::string, bool> > arguments;
165 type_bound_vector bounds;
167 bool converting_function;
183 llvm::Function *
function;
187 std::vector<jit_magic_end::context> end_context;
189 size_t iterator_count;
190 size_t for_bounds_count;
201 jit_variable *find_variable (
const std::string& vname)
const;
214 std::string next_iterator (
bool inc =
true)
215 {
return next_name (
"#iter", iterator_count, inc); }
217 std::string next_for_bounds (
bool inc =
true)
218 {
return next_name (
"#for_bounds", for_bounds_count, inc); }
220 std::string next_shortcircut_result (
bool inc =
true)
221 {
return next_name (
"#shortcircut_result", short_count, inc); }
223 std::string next_name (
const char *prefix,
size_t& count,
bool inc);
226 jit_value *extra_arg = 0,
bool lhs =
false);
229 bool artificial =
false);
232 bool artificial =
false);
240 block_list continues;
242 void finish_breaks (
jit_block *dest,
const block_list& lst);
250 llvm::Function *convert_loop (llvm::Module *module,
252 const std::list<jit_value *>& constants);
256 const std::list<jit_value *>& constants,
258 const std::vector<jit_type *>& args);
261 const std::vector<std::pair<std::string, bool> >& get_arguments(
void)
const
262 {
return argument_vec; }
264 #define JIT_METH(clname) \
265 virtual void visit (jit_ ## clname&);
272 std::map<std::string, int> argument_index;
274 std::vector<std::pair<std::string, bool> > argument_vec;
277 std::map<std::string, llvm::Value *> arguments;
279 bool converting_function;
284 llvm::Function *
function;
285 llvm::BasicBlock *prelude;
288 const std::list<jit_value *>& constants);
290 void finish_phi (
jit_phi *phi);
294 return visit (*jvalue);
311 const variable_map& avmap);
321 const variable_map& vmap;
322 std::list<jit_instruction *> worklist;
328 void construct_ssa (
void);
330 void do_construct_ssa (
jit_block& block,
size_t avisit_count);
336 void place_releases (
void);
342 void release_dead_phi (
jit_block& ablock);
344 void release_temp (
jit_block& ablock, std::set<jit_value *>& temp);
346 void simplify_phi (
void);
348 void simplify_phi (
jit_phi& phi);
365 llvm::ExecutionEngine *get_engine (
void)
const {
return engine; }
367 llvm::Module *get_module (
void)
const {
return module; }
369 void optimize (llvm::Function *fn);
388 llvm::Module *module;
389 #ifdef LEGACY_PASSMANAGER
390 llvm::legacy::PassManager *module_pass_manager;
391 llvm::legacy::FunctionPassManager *pass_manager;
393 llvm::PassManager *module_pass_manager;
394 llvm::FunctionPassManager *pass_manager;
396 llvm::ExecutionEngine *engine;
413 std::vector<jit_type *> argument_types;
414 jited_function
function;
422 typedef std::map<std::string, const octave_value *> vmap;
430 bool execute (
const vmap& extra_vars = vmap ())
const;
432 bool match (
const vmap& extra_vars = vmap ())
const;
442 llvm::ExecutionEngine *engine;
443 jited_function
function;
444 llvm::Function *llvm_function;
446 std::vector<std::pair<std::string, bool> > arguments;
447 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)
static octave_idx_type find(octave_idx_type i, octave_idx_type *pp)
std::pair< jit_type *, std::string > type_bound
static int convert(int x, int ibase, int obase)
std::map< std::string, jit_variable * > variable_map
static bool match(const std::string &filename_arg, const std::string &path_elt_arg)
static void initialize(void)
#define JIT_CREATE_CHECKED(N)
void visit(jit_value &jvalue)
std::vector< type_bound > type_bound_vector