26 #define __STDC_LIMIT_MACROS
27 #define __STDC_CONSTANT_MACROS
37 #ifdef HAVE_LLVM_IR_FUNCTION_H
38 #include <llvm/IR/BasicBlock.h>
39 #include <llvm/IR/Instructions.h>
41 #include <llvm/BasicBlock.h>
42 #include <llvm/Instructions.h>
50 for (value_list::iterator iter =
all_values.begin ();
80 iter =
mlist.insert (iter, ablock);
103 os <<
"-------------------- " << header <<
" --------------------\n";
110 os <<
"-------------------- dom info --------------------\n";
114 (*iter)->print_dom (os);
133 iter != blocks.
end (); ++iter)
136 (*iter)->print (os, 0);
138 return os << std::endl;
158 if (! isa<jit_error_check> (use->
user ()))
178 #define JIT_METH(clname) \
180 jit_ ## clname::accept (jit_ir_walker& walker) \
182 walker.visit (*this); \
198 return avalue->
print (os);
222 return os <<
"#" <<
mid;
228 for (
size_t i = start; i < end; ++i)
241 assert (isa<jit_block> (value));
260 node = node->
next ();
289 bool was_empty =
end () ==
begin ();
296 merge_begin =
begin ();
302 for (
iterator iter = merge_begin; iter !=
end (); ++iter)
326 if (! isa<jit_phi> (temp))
394 return llvm::cast<llvm::BasicBlock> (
llvm_value);
402 os <<
" mid: " <<
mid << std::endl;
403 os <<
" predecessors: ";
405 os << *use->user_parent () <<
" ";
408 os <<
" successors: ";
425 for (
size_t i = 0; i <
dom_succ.size (); ++i)
428 return os << std::endl;
442 while (runner !=
idom)
444 runner->
mdf.insert (
this);
445 runner = runner->
idom;
460 bool changed =
false;
464 changed = pred->
update_idom (avisit_count) || changed;
471 for (; use; use = use->
next ())
479 if (
idom != new_idom)
497 pred->
label (avisit_count, number);
530 instr->
print (os, indent + 1) << std::endl;
580 while (i && j && i != j)
582 while (i && i->
id () > j->
id ())
585 while (i && j && j->
id () > i->
id ())
624 if (new_idx != argument_count ())
630 assert (argument_count () > 0);
655 if (infered !=
type ())
675 for (
size_t i = 0; i < scount; ++i)
688 bool changed =
false;
689 for (
size_t i = 0; i <
malive.size (); ++i)
700 llvm::TerminatorInst *
738 std::stringstream ss;
739 ss <<
"Missing overload in type inference for ";
744 if (infered !=
type ())
760 return "error_state";
782 size_t aindex,
size_t acount)
793 std::vector<context>::const_iterator iter;
802 for (idx = 0; idx <
contexts.size (); ++idx)
821 if (new_type !=
type ())
835 return os << *ctx.
index <<
", " << *ctx.
count <<
")";
jit_type * result(void) const
void stash_type(jit_type *new_ty)
void stash_parent(jit_block *aparent, std::list< jit_instruction * >::iterator alocation)
jit_instruction * insert_after(iterator loc, jit_instruction *instr)
instruction_list::iterator iterator
void stash_location(std::list< jit_block * >::iterator alocation)
jit_instruction * insert_before(iterator loc, jit_instruction *instr)
virtual std::ostream & short_print(std::ostream &os) const
virtual std::ostream & short_print(std::ostream &os) const
static const jit_operation & end(void)
virtual void replace_with(jit_value *value)
jit_block * user_parent(void) const
jit_block * user_parent(void) const
jit_block * incomming(size_t i) const
df_iterator df_end(void) const
const jit_operation & moperation
std::list< jit_block * >::const_iterator const_iterator
size_t use_count(void) const
jit_terminator * terminator(void) const
df_iterator df_begin(void) const
const jit_function & overload() const
jit_block * parent(void) const
llvm::Value * to_llvm(void) const
jit_instruction * prepend(jit_instruction *instr)
#define JIT_VISIT_IR_NOTEMPLATE
static jit_type * join(jit_type *lhs, jit_type *rhs)
void merge(jit_block &merge)
jit_instruction * prepend_after_phi(jit_instruction *instr)
jit_type * argument_type(size_t i) const
jit_type * type(void) const
void stash_value(LIST_T *avalue)
jit_block * first_use_block(void)
instruction_list instructions
virtual bool needs_release(void) const
virtual std::ostream & print(std::ostream &os, size_t indent=0) const
void insert_after(iterator iter, jit_block *ablock)
bool visited(size_t avisit_count)
void create_dom_tree(void)
std::vector< jit_block * > dom_succ
llvm::TerminatorInst * to_llvm(void) const
std::list< jit_instruction * >::iterator mlocation
void push_back(jit_block *b)
void resize_arguments(size_t acount, jit_value *adefault=0)
static jit_block * idom_intersect(jit_block *i, jit_block *j)
void track_value(jit_value *v)
std::list< jit_block * >::iterator location(void) const
iterator remove(iterator iter)
jit_block * maybe_merge()
jit_magic_end(const std::vector< context > &full_context)
bool alive(const jit_block *asuccessor) const
std::vector< bool > malive
jit_call * check_for(void) const
virtual void replace_with(jit_value *value)
llvm::BasicBlock * parent_llvm(void) const
jit_block * successor(size_t idx=0) const
bool artificial(void) const
context resolve_context(void) const
std::ostream & print(std::ostream &os, const std::string &header) const
#define panic_impossible()
jit_value * argument(size_t i) const
void replace_in_phi(jit_block *ablock, jit_block *with)
llvm::PHINode * to_llvm(void) const
bool has_check_for(void) const
std::vector< jit_phi_incomming > mincomming
size_t argument_count(void) const
std::vector< context > contexts
void stash_argument(size_t i, jit_value *arg)
virtual void pop_variable(void)
std::ostream & print_indent(std::ostream &os, size_t indent=0) const
llvm::BasicBlock * to_llvm(void) const
size_t successor_index(const jit_block *asuccessor) const
df_set::const_iterator df_iterator
std::ostream & jit_print(std::ostream &os, jit_value *avalue)
size_t use_count(void) const
static const jit_function & get_release(jit_type *type)
std::vector< jit_type * > already_infered
std::list< jit_block * > mlist
jit_use * first_use(void) const
virtual std::ostream & print(std::ostream &os, size_t indent=0) const
size_t successor_count(void) const
std::ostream & print_dom(std::ostream &os) const
bool update_idom(size_t avisit_count)
void internal_append(jit_instruction *instr)
jit_type * result(const signature_vec &types) const
bool branch_alive(jit_block *asucc) const
std::list< jit_block * >::iterator iterator
void insert_before(iterator iter, jit_block *ablock)
jit_block * successor(size_t i) const
virtual std::ostream & print(std::ostream &os, size_t indent=0) const
jit_block * maybe_split(jit_factory &factory, jit_block_list &blocks, jit_block *asuccessor)
instruction_list::const_iterator const_iterator
std::ostream & operator<<(std::ostream &os, const jit_block_list &blocks)
bool skip_paren(void) const
virtual bool check_alive(size_t) const
std::ostream & print_successor(std::ostream &os, size_t idx=0) const
virtual std::ostream & short_print(std::ostream &os) const
NODE_T * next(void) const
jit_use * first_use(void) const
std::ostream & print_dom(std::ostream &os) const
jit_instruction * user(void) const
jit_value * top(void) const
size_t successor_count(void) const
void do_construct_ssa(size_t start, size_t end)
virtual std::ostream & print(std::ostream &os, size_t indent=0) const
static std::string variable_to_string(variable v)
virtual std::ostream & short_print(std::ostream &os) const
virtual std::ostream & print(std::ostream &os, size_t indent=0) const =0