25 #if ! defined (octave_pt_jit_h) 26 #define octave_pt_jit_h 1 28 #include "octave-config.h" 30 #if defined (HAVE_LLVM) 44 #if defined (LEGACY_PASSMANAGER) 70 template <
typename ...Args>
74 return create_checked_impl (ret);
228 {
return next_name (
"#iter", m_iterator_count, inc); }
231 {
return next_name (
"#for_bounds", m_for_bounds_count, inc); }
234 {
return next_name (
"#shortcircut_result", m_short_count, inc); }
236 std::string next_name (
const char *prefix,
size_t& count,
bool inc);
239 jit_value *extra_arg =
nullptr,
bool lhs =
false);
242 bool artificial =
false);
245 bool artificial =
false);
264 llvm::Function * convert_loop (
const jit_module& module,
266 const std::list<jit_value *>& constants,
271 const std::list<jit_value *>& constants,
273 const std::vector<jit_type *>& args);
277 {
return m_argument_vec; }
279 #define JIT_METH(clname) \ 280 virtual void visit (jit_ ## clname&); 305 const std::list<jit_value *>& constants);
307 void finish_phi (
jit_phi *phi);
311 return visit (*jvalue);
348 void construct_ssa (
void);
350 void do_construct_ssa (
jit_block& block,
size_t avisit_count);
356 void place_releases (
void);
362 void release_dead_phi (
jit_block& ablock);
364 void release_temp (
jit_block& ablock, std::set<jit_value *>& temp);
366 void simplify_phi (
void);
368 void simplify_phi (
jit_phi& phi);
393 bool do_initialize (
void);
411 open_new_module (
const std::string& module_name = generate_unique_module_name ());
419 do_open_new_module (
const std::string& module_name)
const;
436 void do_unregister_jit_module (
jit_module* jm);
437 void do_dump_all_modules (
void)
const;
451 void* do_getPointerToNamedFunction (
const std::string &Name)
const;
462 + std::to_string (next_forloop_number ++);
469 + std::to_string (next_function_number ++);
476 + std::to_string (next_module_number ++);
492 {
return instance ().
do_execute (cmd, bounds); }
541 create_llvm_function (llvm::FunctionType *ftype,
542 const llvm::Twine &
name)
const;
545 llvm::GlobalVariable*
546 create_global_variable (llvm::Type *
type,
bool is_constant,
547 const llvm::Twine&
name)
const;
552 get_intrinsic_declaration (
size_t id,
553 std::vector<llvm::Type*> types)
const;
560 template <
typename ptr_type>
563 do_add_global_mapping (gv, reinterpret_cast<void *> (
p));
570 void optimize (llvm::Function *fn)
const;
574 void finalizeObject (
void);
578 void do_add_global_mapping (
const llvm::GlobalValue* gv,
void*
p)
const;
591 typedef std::map<std::string, const octave_value *>
vmap;
599 bool execute (
const vmap& extra_vars =
vmap ())
const;
601 bool match (
const vmap& extra_vars =
vmap ())
const;
size_t m_for_bounds_count
#define JIT_VISIT_IR_CLASSES
std::unique_ptr< llvm::Module > ModuleOwner
llvm::Function * m_function
std::string m_llvm_function_name
jit_factory & get_factory(void) const
uint64_t do_getSymbolAddress(const std::string &name) const
void visit(jit_value *jvalue)
std::list< jit_module * > jm_list
static const llvm::TargetMachine * get_target_machine(void)
std::map< std::string, const octave_value * > vmap
static std::string generate_unique_function_name(void)
static int next_function_number
std::vector< jit_magic_end::context > m_end_context
jit_convert::type_bound type_bound
std::map< std::string, int > m_argument_index
static void unregister_jit_module(jit_module *jm)
llvm::BasicBlock * m_prelude
void do_register_jit_module(jit_module *jm)
void * do_getPointerToNamedFunction(const std::string &Name) const
jit_block_list & get_blocks(void) const
jit_block & final_block(void)
bool m_converting_function
static bool execute(tree_while_command &cmd)
jited_function m_function
static bool execute(octave_user_function &fcn, const octave_value_list &args, octave_value_list &retval)
jited_function m_function
std::map< std::string, jit_variable * > variable_map
llvm::PassManager PassManager
const type_bound_vector & get_bounds(void) const
const variable_map & get_variable_map(void) const
llvm::FunctionPassManager FunctionPassManager
static void initialize(void)
std::string next_shortcircut_result(bool inc=true)
static void * getPointerToNamedFunction(const std::string &name)
std::string next_iterator(bool inc=true)
jit_convert::variable_map variable_map
std::unique_ptr< llvm::ExecutionEngine > EngineOwner
llvm::ExecutionEngine * m_engine
nd deftypefn *std::string name
jit_block * back(void) const
std::vector< std::pair< std::string, bool > > m_argument_vec
jit_call * create_checked(const Args &... args)
std::list< jit_block * > block_list
static void register_jit_module(jit_module *jm)
bool do_execute(tree_simple_for_command &cmd, const octave_value &bounds)
virtual void accept(jit_ir_walker &walker)=0
jit_block & entry_block(void)
jit_factory & get_factory(void)
llvm::Function * get_function(void) const
std::string next_for_bounds(bool inc=true)
void visit(jit_value &jvalue)
std::vector< std::pair< std::string, bool > > m_arguments
void add_global_mapping(const llvm::GlobalValue *gv, ptr_type p) const
jit_block_list & get_blocks(void)
const std::vector< std::pair< std::string, bool > > & get_arguments(void) const
static octave_idx_type find(octave_idx_type i, octave_idx_type *pp)
jit_block * front(void) const
std::string m_llvm_function_name
std::list< jit_instruction * > m_worklist
static int next_forloop_number
std::vector< type_bound > type_bound_vector
jit_convert::type_bound_vector type_bound_vector
static int next_module_number
std::vector< std::pair< std::string, bool > > m_arguments
jit_block * m_entry_block
jit_block * m_final_block
type_bound_vector m_bounds
std::pair< jit_type *, std::string > type_bound
static std::string get_variable(const char *name, const std::string &defval)
jit_block_list & m_blocks
jit_value * visit(tree *tee)
static bool execute(tree_simple_for_command &cmd, const octave_value &bounds)
void do_unregister_jit_module(jit_module *jm)
std::vector< jit_type * > m_argument_types
llvm::TargetMachine * target_machine
type_bound_vector m_bounds
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
bool m_converting_function
llvm::Function * m_function
static uint64_t getSymbolAddress(const std::string &name)
std::map< std::string, llvm::Value * > m_arguments
static std::string generate_unique_module_name(void)
static std::string generate_unique_forloop_name(void)
const variable_map & m_vmap