X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Firnode.c;h=c61f32a4c23e29949c65bf18e6ffecbdcd0beac5;hb=0f234e2d94155d13c0e4727871125beda0eaa66d;hp=19a36e91df995829de00602db843aeda2350f560;hpb=ef3f4288a57fc536e74087390be6d0f33771511d;p=libfirm diff --git a/ir/ir/irnode.c b/ir/ir/irnode.c index 19a36e91d..c61f32a4c 100644 --- a/ir/ir/irnode.c +++ b/ir/ir/irnode.c @@ -168,8 +168,12 @@ new_ir_node(dbg_info *db, ir_graph *irg, ir_node *block, ir_op *op, ir_mode *mod res->out = NULL; res->node_nr = get_irp_new_node_nr(); - for (i = 0; i < EDGE_KIND_LAST; ++i) + for (i = 0; i < EDGE_KIND_LAST; ++i) { INIT_LIST_HEAD(&res->edge_info[i].outs_head); + /* edges will be build immediately */ + res->edge_info[i].edges_built = 1; + res->edge_info[i].out_count = 0; + } /* don't put this into the for loop, arity is -1 for some nodes! */ edges_notify_edge(res, -1, res->in[0], NULL, irg); @@ -229,7 +233,7 @@ ir_node **get_irn_in(const ir_node *node) { void set_irn_in(ir_node *node, int arity, ir_node **in) { int i; ir_node *** pOld_in; - ir_graph *irg = current_ir_graph; + ir_graph *irg = get_irn_irg(node); assert(node); #ifdef INTERPROCEDURAL_VIEW @@ -814,10 +818,11 @@ ir_entity *create_Block_entity(ir_node *block) { glob = get_glob_type(); entity = new_entity(glob, id_unique("block_%u"), get_code_type()); + set_entity_visibility(entity, ir_visibility_local); + set_entity_linkage(entity, IR_LINKAGE_CONSTANT); nr = get_irp_next_label_nr(); set_entity_label(entity, nr); set_entity_compiler_generated(entity, 1); - set_entity_allocation(entity, allocation_static); block->attr.block.entity = entity; } @@ -991,49 +996,6 @@ void set_IJmp_target(ir_node *ijmp, ir_node *tgt) { set_irn_n(ijmp, 0, tgt); } -/* -> Implementing the case construct (which is where the constant Proj node is -> important) involves far more than simply determining the constant values. -> We could argue that this is more properly a function of the translator from -> Firm to the target machine. That could be done if there was some way of -> projecting "default" out of the Cond node. -I know it's complicated. -Basically there are two problems: - - determining the gaps between the Projs - - determining the biggest case constant to know the proj number for - the default node. -I see several solutions: -1. Introduce a ProjDefault node. Solves both problems. - This means to extend all optimizations executed during construction. -2. Give the Cond node for switch two flavors: - a) there are no gaps in the Projs (existing flavor) - b) gaps may exist, default proj is still the Proj with the largest - projection number. This covers also the gaps. -3. Fix the semantic of the Cond to that of 2b) - -Solution 2 seems to be the best: -Computing the gaps in the Firm representation is not too hard, i.e., -libFIRM can implement a routine that transforms between the two -flavours. This is also possible for 1) but 2) does not require to -change any existing optimization. -Further it should be far simpler to determine the biggest constant than -to compute all gaps. -I don't want to choose 3) as 2a) seems to have advantages for -dataflow analysis and 3) does not allow to convert the representation to -2a). -*/ - -const char *get_cond_kind_name(cond_kind kind) -{ -#define X(a) case a: return #a; - switch (kind) { - X(dense); - X(fragmentary); - } - return ""; -#undef X -} - ir_node * get_Cond_selector(const ir_node *node) { assert(is_Cond(node)); @@ -1046,18 +1008,6 @@ set_Cond_selector(ir_node *node, ir_node *selector) { set_irn_n(node, 0, selector); } -cond_kind -get_Cond_kind(const ir_node *node) { - assert(is_Cond(node)); - return node->attr.cond.kind; -} - -void -set_Cond_kind(ir_node *node, cond_kind kind) { - assert(is_Cond(node)); - node->attr.cond.kind = kind; -} - long get_Cond_default_proj(const ir_node *node) { assert(is_Cond(node)); @@ -2833,6 +2783,10 @@ int (is_irn_machine_user)(const ir_node *node, unsigned n) { return _is_irn_machine_user(node, n); } +/* Returns non-zero for nodes that are CSE neutral to its users. */ +int (is_irn_cse_neutral)(const ir_node *node) { + return _is_irn_cse_neutral(node); +} /* Gets the string representation of the jump prediction .*/ const char *get_cond_jmp_predicate_name(cond_jmp_predicate pred) { @@ -2973,7 +2927,11 @@ unsigned firm_default_hash(const ir_node *node) { /* consider all in nodes... except the block if not a control flow. */ for (i = is_cfop(node) ? -1 : 0; i < irn_arity; ++i) { - h = 9*h + HASH_PTR(get_irn_intra_n(node, i)); + ir_node *pred = get_irn_intra_n(node, i); + if (is_irn_cse_neutral(pred)) + h *= 9; + else + h = 9*h + HASH_PTR(pred); } /* ...mode,... */