25 #if ! defined (octave_jit_typeinfo_h) 26 #define octave_jit_typeinfo_h 1 28 #include "octave-config.h" 30 #if defined (HAVE_LLVM) 55 : m_base (from.base ()), m_limit (from.limit ()), m_inc (from.inc ()),
56 m_nelem (from.
numel ())
61 return Range (m_base, m_limit, m_inc);
64 bool all_elements_are_ints (
void)
const;
75 template <
typename T,
typename U>
88 m_ref_count = m_array->jit_ref_count ();
89 m_slice_data = m_array->jit_slice_data () - 1;
90 m_slice_len = m_array->numel ();
91 m_dimensions = m_array->jit_dimensions ();
119 namespace jit_convention
147 bool askip_paren,
int aid);
159 llvm::Type *
to_llvm (
void)
const {
return m_llvm_type; }
162 llvm::Type * to_llvm_arg (
void)
const;
164 size_t depth (
void)
const {
return m_depth; }
177 { m_sret[cc] =
true; }
185 { m_pointer_arg[cc] =
true; }
198 { m_unpack[cc] = fn; }
202 {
return m_packed_type[cc]; }
205 { m_packed_type[cc] = ty; }
248 const llvm::Twine& aname,
jit_type *aresult,
249 const std::vector<jit_type *>& aargs);
254 const std::vector<jit_type *>& aargs);
261 bool valid (
void)
const {
return m_llvm_function; }
265 llvm::BasicBlock * new_block (
const std::string& aname =
"body",
266 llvm::BasicBlock *insert_before =
nullptr);
274 const std::vector<jit_value *>& in_args)
const;
276 template <
typename ...Args>
278 llvm::Value * arg1, Args... other_args)
const 280 in_args.push_back (arg1);
281 return call (
builder, in_args, other_args...);
284 template <
typename T,
typename ...Args>
286 T * arg1, Args... other_args)
const 288 in_args.push_back (arg1->to_llvm ());
289 return call (
builder, in_args, other_args...);
292 template <
typename ...Args>
294 Args... other_args)
const 297 in_args.reserve (1 +
sizeof... (other_args));
298 in_args.push_back (arg1);
299 return call (
builder, in_args, other_args...);
302 template <
typename T,
typename ...Args>
304 Args... other_args)
const 307 in_args.reserve (1 +
sizeof... (other_args));
308 in_args.push_back (arg1->to_llvm ());
309 return call (
builder, in_args, other_args...);
317 llvm::Function *
to_llvm (
void)
const {
return m_llvm_function; }
320 bool sret (
void)
const {
return m_result && m_result->sret (m_call_conv); }
330 assert (idx < m_args.size ());
334 const std::vector<jit_type *>&
arguments (
void)
const {
return m_args; }
368 const signature_vec& args);
370 const jit_function& overload (
const signature_vec& types)
const;
372 template <
typename ...Args>
374 Args... other_args)
const 376 args.push_back (arg1);
377 return overload (args, other_args...);
380 template <
typename ...Args>
384 args.reserve (1 +
sizeof... (other_args));
385 args.push_back (arg1);
386 return overload (args, other_args...);
395 template <
typename ...Args>
397 Args... other_args)
const 399 args.push_back (arg1);
400 return overload (args, other_args...);
403 template <
typename ...Args>
407 args.reserve (1 +
sizeof... (other_args));
408 args.push_back (arg1);
409 return overload (args, other_args...);
418 virtual jit_function * generate (
const signature_vec& types)
const;
424 const jit_function& do_generate (
const signature_vec& types)
const;
431 typedef std::map<const signature_vec *, jit_function *, signature_cmp>
452 virtual jit_function * generate (
const signature_vec& types)
const;
454 virtual jit_function * generate_matrix (
const signature_vec& types)
const = 0;
460 size_t end_idx)
const;
473 void init_paren_scalar (
void);
492 void init_paren_scalar (
void);
525 llvm::Type *llvm_type,
bool skip_paren =
false)
537 llvm::Type *llvm_type,
bool skip_paren =
false);
605 jit_type *do_get_intN (
size_t nbits)
const;
709 return instance ().
do_cast (to, from);
757 assert (static_cast<size_t>(op) < m_binary_ops.size ());
758 return m_binary_ops[op];
763 assert (static_cast<size_t> (op) < m_unary_ops.size ());
764 return m_unary_ops[op];
771 return null_function;
774 if (
id >= m_casts.size ())
775 return null_function;
781 return do_cast (to).overload (from);
789 void add_binary_op (
jit_type *ty,
int op,
int llvm_op);
791 void add_binary_icmp (
jit_type *ty,
int op,
int llvm_op);
793 void add_binary_fcmp (
jit_type *ty,
int op,
int llvm_op);
800 template <
typename T>
805 template <
typename T,
typename ...Args>
808 jit_type * arg1, Args... other_args)
const 810 args.push_back (arg1);
811 return create_external (fn,
name, ret, args, other_args...);
814 template <
typename T,
typename ...Args>
816 jit_type * arg1, Args... other_args)
const 819 args.reserve (1 +
sizeof... (other_args));
820 args.push_back (arg1);
821 return create_external (fn,
name, ret, args, other_args...);
833 template <
typename ...Args>
836 jit_type * arg1, Args... other_args)
const 838 args.push_back (arg1);
839 return create_internal (
name, ret, args, other_args...);
842 template <
typename ...Args>
844 jit_type * arg1, Args... other_args)
const 847 args.reserve (1 +
sizeof... (other_args));
848 args.push_back (arg1);
849 return create_internal (
name, ret, args, other_args...);
863 std::vector<jit_type *> args (1, arg0);
868 const std::vector<jit_type *>& args);
873 std::vector<jit_type *> args (1, arg0);
878 const std::vector<jit_type *>& args);
884 llvm::Function * wrap_complex (llvm::Function *wrap);
886 llvm::Value * complex_real (llvm::Value *cx);
888 llvm::Value * complex_real (llvm::Value *cx, llvm::Value *
real);
890 llvm::Value * complex_imag (llvm::Value *cx);
892 llvm::Value * complex_imag (llvm::Value *cx, llvm::Value *
imag);
894 llvm::Value * complex_new (llvm::Value *
real, llvm::Value *
imag);
896 llvm::Value *do_pack_complex (
llvm::IRBuilderD& bld, llvm::Value *cplx)
const;
jit_type * result(const signature_vec &types) const
static const jit_operation & destroy(void)
static const jit_operation & for_init(void)
jit_operation m_release_fn
static jit_type * get_index(void)
const std::string & name(void) const
const jit_operation & do_binary_op(int op) const
llvm::Type * to_llvm(void) const
const std::vector< jit_type * > & arguments(void) const
jit_type * result(signature_vec &args, jit_type *arg1, Args... other_args) const
static const jit_function & cast(jit_type *to, jit_type *from)
llvm::Function * to_llvm(void) const
static jit_type * intN(size_t nbits)
jit_operation(const std::string &aname)
static llvm::Type * get_index_llvm(void)
jit_operation m_destroy_fn
jit_function * m_paren_scalar
std::vector< jit_type * > m_args
llvm::StructType * m_range_t
llvm::Value * call(llvm::IRBuilderD &builder, arg_vec &in_args, T *arg1, Args... other_args) const
static const jit_operation & paren_subsasgn(void)
const jit_function & do_end(jit_value *value, jit_value *index, jit_value *count)
static const jit_operation & cast(jit_type *result)
jit_convention::type m_call_conv
std::map< size_t, jit_type * > m_ints
jit_array< NDArray, double > jit_matrix
generated_map m_generated
static const jit_operation & binary_op(int op)
jit_type * jit_type_join(jit_type *lhs, jit_type *rhs)
jit_function create_internal(const llvm::Twine &name, jit_type *ret, jit_type *arg1, Args... other_args) const
static jit_type * get_matrix(void)
jit_function * m_paren_scalar
static jit_type * get_any_ptr(void)
static jit_type * get_scalar_ptr(void)
static llvm::Value * insert_interrupt_check(llvm::IRBuilderD &bld)
llvm::Value * do_insert_error_check(llvm::IRBuilderD &bld)
static llvm::Type * get_scalar_llvm(void)
static const jit_operation & for_index(void)
jit_type * do_type_of(const octave_value &ov) const
jit_type * argument_type(size_t idx) const
jit_function create_internal(const llvm::Twine &name, jit_type *ret, signature_vec &args, jit_type *arg1, Args... other_args) const
static const jit_operation & print_value(void)
llvm::Value * do_insert_interrupt_check(llvm::IRBuilderD &bld)
const jit_operation & do_unary_op(int op) const
llvm::Value * call(llvm::IRBuilderD &builder, llvm::Value *arg1, Args... other_args) const
static llvm::Value * create_complex(llvm::Value *real, llvm::Value *imag)
static llvm::IRBuilder builder(llvm::getGlobalContext())
llvm::Type * m_sig_atomic_type
void mark_can_error(void)
const jit_function & do_cast(jit_type *to, jit_type *from)
std::ostream & jit_print(std::ostream &os, jit_value *avalue)
void set_unpack(jit_convention::type cc, convert_fn fn)
jit_type * m_unknown_function
bool sret(jit_convention::type cc) const
void register_generic(const std::string &name, jit_type *result, jit_type *arg0)
static jit_type * get_range(void)
llvm::IRBuilderD & m_builder
std::map< const signature_vec *, jit_function *, signature_cmp > generated_map
const jit_operation & do_cast(jit_type *to)
const jit_function & overload(signature_vec &args, jit_type *arg1, Args... other_args) const
llvm::Type * packed_type(jit_convention::type cc)
std::map< std::string, jit_type * > m_builtins
void register_intrinsic(const std::string &name, size_t id, jit_type *result, jit_type *arg0)
jit_operation m_logically_true_fn
nd deftypefn *std::string name
static const jit_operation & release(void)
static const jit_operation & paren_subsref(void)
std::ostream & operator<<(std::ostream &os, const jit_block_list &blocks)
convert_fn unpack(jit_convention::type cc)
octave_idx_type m_slice_len
jit_type * parent(void) const
static jit_type * type_of(const octave_value &ov)
static const jit_operation & grab(void)
void add_overload(const jit_function &func)
jit_operation m_for_index_fn
llvm::StructType * m_complex_ret
jit_operation m_for_check_fn
const jit_function & overload(jit_type *arg1, Args... other_args) const
returns the type of the matrix and caches it for future use Called with more than one argument
static const jit_operation & logically_true(void)
convert_fn pack(jit_convention::type cc)
llvm::Value * do_pack_complex(llvm::IRBuilderD &bld, llvm::Value *cplx) const
static const jit_function & end(jit_value *value, jit_value *idx, jit_value *count)
static jit_type * register_new_type(const std::string &name, jit_type *parent, llvm::Type *llvm_type, bool skip_paren=false)
static const jit_operation & for_check(void)
std::vector< jit_operation > m_casts
std::vector< jit_type * > signature_vec
std::vector< jit_operation > m_unary_ops
jit_module * m_base_jit_module
jit_function create_external(T fn, const llvm::Twine &name, jit_type *ret, signature_vec &args, jit_type *arg1, Args... other_args) const
void set_pack(jit_convention::type cc, convert_fn fn)
void set_packed_type(jit_convention::type cc, llvm::Type *ty)
static jit_type * get_scalar(void)
jit_paren_subsasgn paren_subsasgn_fn
static const jit_function & get_release(jit_type *type)
void stash_name(const std::string &aname)
friend jit_paren_subsasgn
static const jit_function & get_grab(jit_type *type)
static const jit_operation & end(void)
std::vector< jit_type * > m_id_to_type
With real return the complex result
std::vector< jit_type * > signature_vec
llvm::Function * m_llvm_function
llvm::IRBuilderD * m_builder_ptr
std::vector< llvm::Value * > arg_vec
llvm::Value * complex_new(llvm::Value *real, llvm::Value *imag)
jit_type * result(void) const
static jit_type * get_string(void)
static jit_type * get_any(void)
jit_operation m_make_range_fn
T::size_type numel(const T &str)
static const jit_operation & unary_op(int op)
static llvm::Value * insert_error_check(llvm::IRBuilderD &bld)
jit_paren_subsref paren_subsref_fn
llvm::Value * call(llvm::IRBuilderD &builder, T *arg1, Args... other_args) const
static jit_type * get_bool(void)
jit_function create_external(T fn, const llvm::Twine &name, jit_type *ret, jit_type *arg1, Args... other_args) const
jit_operation m_create_undef_fn
bool skip_paren(void) const
bool pointer_arg(jit_convention::type cc) const
FloatComplex(* fptr)(const FloatComplex &, float, int, octave_idx_type &)
jit_type * do_register_new_type(const std::string &name, jit_type *parent, llvm::Type *llvm_type, bool skip_paren=false)
const jit_function & overload(const signature_vec &types) const
jit_type * result(jit_type *arg1, Args... other_args) const
void mark_sret(jit_convention::type cc)
static const jit_operation & make_range(void)
llvm::Value * call(llvm::IRBuilderD &builder, arg_vec &in_args, llvm::Value *arg1, Args... other_args) const
jit_function create_internal(const llvm::Twine &name, jit_type *ret, const signature_vec &args=signature_vec()) const
bool can_error(void) const
std::vector< jit_function > m_identities
static jit_type * get_complex(void)
llvm::StructType * m_matrix_t
octave_idx_type * m_dimensions
static bool s_in_construction
ColumnVector imag(const ComplexColumnVector &a)
llvm::GlobalVariable * m_lerror_state
static llvm::Value * pack_complex(llvm::IRBuilderD &bld, llvm::Value *cplx)
jit_range(const Range &from)
ColumnVector real(const ComplexColumnVector &a)
jit_operation m_for_init_fn
std::vector< Array< jit_function > > m_overloads
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
nd group nd example For each display the value
jit_index_operation(const jit_typeinfo &ti, const std::string &name)
void mark_pointer_arg(jit_convention::type cc)
const std::string & name(void) const
llvm::GlobalVariable * m_loctave_interrupt_state
jit_type * do_get_intN(size_t nbits) const
static const jit_operation & create_undef(void)
const jit_typeinfo & m_typeinfo
const jit_module * m_module
std::vector< jit_operation > m_binary_ops