27 #define __STDC_LIMIT_MACROS
28 #define __STDC_CONSTANT_MACROS
30 #if defined (HAVE_CONFIG_H)
34 #if defined (HAVE_LLVM)
38 #if defined (HAVE_LLVM_IR_FUNCTION_H)
39 # include <llvm/IR/BasicBlock.h>
40 # include <llvm/IR/Instructions.h>
42 # include <llvm/BasicBlock.h>
43 # include <llvm/Instructions.h>
84 iter =
m_list.insert (iter, ablock);
107 os <<
"-------------------- " << header <<
" --------------------\n";
114 os <<
"-------------------- dom info --------------------\n";
115 for (
auto iter =
begin (); iter !=
end (); ++iter)
118 (*iter)->print_dom (os);
129 auto iter =
m_list.end ();
136 for (
auto iter = blocks.
begin (); iter != blocks.
end (); ++iter)
139 (*iter)->print (os, 0);
141 return os << std::endl;
161 if (! isa<jit_error_check> (use->
user ()))
181 #define JIT_METH(clname) \
183 jit_ ## clname::accept (jit_ir_walker& walker) \
185 walker.visit (*this); \
201 return avalue->
print (os);
225 return os <<
'#' <<
m_id;
231 for (
size_t i = start; i < end; ++i)
244 assert (isa<jit_block> (value));
263 node = node->
next ();
292 bool was_empty =
end () ==
begin ();
293 auto merge_begin =
end ();
299 merge_begin =
begin ();
305 for (
auto iter = merge_begin; iter !=
end (); ++iter)
326 for (
auto iter =
begin (); iter !=
end (); ++iter)
329 if (! isa<jit_phi> (temp))
404 os <<
" m_id: " <<
m_id << std::endl;
405 os <<
" predecessors: ";
407 os << *use->user_parent () <<
' ';
410 os <<
" successors: ";
426 os <<
" m_dom_succ: ";
427 for (
size_t i = 0; i <
m_dom_succ.size (); ++i)
430 return os << std::endl;
446 runner->
m_df.insert (
this);
462 bool changed =
false;
466 changed = pred->
update_idom (avisit_count) || changed;
473 for (; use; use = use->
next ())
499 pred->
label (avisit_count, number);
508 for (
auto iter =
begin (); iter !=
end (); ++iter)
529 for (
auto iter =
begin (); iter !=
end (); ++iter)
532 instr->
print (os, indent + 1) << std::endl;
582 while (i && j && i != j)
584 while (i && i->
id () > j->
id ())
587 while (i && j && j->
id () > i->
id ())
657 if (infered !=
type ())
677 for (
size_t i = 0; i < scount; ++i)
690 bool changed =
false;
691 for (
size_t i = 0; i <
m_alive.size (); ++i)
702 llvm::TerminatorInst *
740 std::stringstream ss;
741 ss <<
"Missing overload in type inference for ";
746 if (infered !=
type ())
762 return "error_state";
784 size_t aindex,
size_t acount)
785 : m_value (avalue), m_index (factory.create<
jit_const_index> (aindex)),
795 std::vector<context>::const_iterator iter;
804 for (idx = 0; idx <
m_contexts.size (); ++idx)
823 if (new_type !=
type ())
bool artificial(void) const
void insert_before(iterator iter, jit_block *ablock)
void push_back(jit_block *b)
std::list< jit_block * > m_list
void insert_after(iterator iter, jit_block *ablock)
std::list< jit_block * >::iterator iterator
std::ostream & print(std::ostream &os, const std::string &header) const
std::ostream & print_dom(std::ostream &os) const
llvm::BasicBlock * to_llvm(void) const
jit_block * maybe_merge()
void create_dom_tree(void)
void replace_in_phi(jit_block *ablock, jit_block *with)
void internal_append(jit_instruction *instr)
void merge(jit_block &merge)
jit_instruction * prepend_after_phi(jit_instruction *instr)
bool update_idom(size_t avisit_count)
instruction_list m_instructions
bool branch_alive(jit_block *asucc) const
instruction_list::iterator iterator
iterator remove(iterator iter)
jit_instruction * insert_after(iterator loc, jit_instruction *instr)
virtual void replace_with(jit_value *value)
virtual std::ostream & short_print(std::ostream &os) const
size_t successor_count(void) const
jit_block * maybe_split(jit_factory &factory, jit_block_list &blocks, jit_block *asuccessor)
jit_block * successor(size_t i) const
bool visited(size_t avisit_count)
std::ostream & print_dom(std::ostream &os) const
jit_instruction * prepend(jit_instruction *instr)
jit_terminator * terminator(void) const
void stash_location(std::list< jit_block * >::iterator alocation)
df_iterator df_begin(void) const
jit_use * first_use(void) const
size_t use_count(void) const
std::vector< jit_block * > m_dom_succ
df_iterator df_end(void) const
static jit_block * idom_intersect(jit_block *i, jit_block *j)
jit_instruction * insert_before(iterator loc, jit_instruction *instr)
virtual std::ostream & print(std::ostream &os, size_t indent=0) const
virtual bool needs_release(void) const
const jit_operation & m_operation
virtual std::ostream & print(std::ostream &os, size_t indent=0) const
virtual std::ostream & print(std::ostream &os, size_t indent=0) const
static std::string variable_to_string(variable v)
bool has_check_for(void) const
jit_call * check_for(void) const
T * create(const Args &... args)
void track_value(jit_value *v)
jit_type * result(void) const
void stash_parent(jit_block *aparent, std::list< jit_instruction * >::iterator alocation)
jit_type * argument_type(size_t i) const
void do_construct_ssa(size_t start, size_t end)
void stash_argument(size_t i, jit_value *arg)
llvm::BasicBlock * parent_llvm(void) const
void resize_arguments(size_t acount, jit_value *adefault=nullptr)
std::vector< jit_type * > m_already_infered
std::list< jit_instruction * >::iterator m_location
size_t argument_count(void) const
jit_block * parent(void) const
virtual void pop_variable(void)
jit_value * argument(size_t i) const
virtual std::ostream & short_print(std::ostream &os) const
jit_use * first_use(void) const
size_t use_count(void) const
NODE_T * next(void) const
void stash_value(LIST_T *avalue)
jit_const_index * m_index
jit_const_index * m_count
jit_magic_end(const std::vector< context > &full_context)
const jit_function & overload() const
virtual std::ostream & print(std::ostream &os, size_t indent=0) const
std::vector< context > m_contexts
virtual std::ostream & short_print(std::ostream &os) const
context resolve_context(void) const
jit_type * result(const signature_vec &types) const
jit_block * user_parent(void) const
std::vector< jit_phi_incoming > m_incoming
llvm::PHINode * to_llvm(void) const
jit_block * incoming(size_t i) const
std::ostream & print_successor(std::ostream &os, size_t idx=0) const
bool alive(const jit_block *asuccessor) const
size_t successor_count(void) const
virtual bool check_alive(size_t) const
jit_block * successor(size_t idx=0) const
std::vector< bool > m_alive
size_t successor_index(const jit_block *asuccessor) const
llvm::TerminatorInst * to_llvm(void) const
bool skip_paren(void) const
static const jit_function & get_release(jit_type *type)
static const jit_operation & end(void)
jit_block * user_parent(void) const
jit_instruction * user(void) const
virtual void replace_with(jit_value *m_value)
jit_type * type(void) const
void stash_type(jit_type *new_type)
jit_block * first_use_block(void)
virtual std::ostream & print(std::ostream &os, size_t indent=0) const =0
llvm::Value * to_llvm(void) const
llvm::Value * m_llvm_value
virtual std::ostream & short_print(std::ostream &os) const
std::ostream & print_indent(std::ostream &os, size_t indent=0) const
jit_value * top(void) const
#define panic_impossible()
#define JIT_VISIT_IR_NOTEMPLATE
std::ostream & operator<<(std::ostream &os, const jit_block_list &blocks)
jit_type * jit_type_join(jit_type *lhs, jit_type *rhs)
std::ostream & jit_print(std::ostream &os, jit_value *avalue)