fix weak external functions
[libfirm] / ir / ir / irnode.c
index f61d90a..83bf3ed 100644 (file)
@@ -184,6 +184,25 @@ new_ir_node(dbg_info *db, ir_graph *irg, ir_node *block, ir_op *op, ir_mode *mod
        if (get_irg_phase_state(irg) == phase_backend) {
                be_info_new_node(res);
        }
+       // Init the VRP structures
+       res->vrp.range_type = VRP_UNDEFINED;
+       res->vrp.valid = 0;
+       if(mode_is_int(mode)) {
+               // We are assuming that 0 is always represented as 0x0000
+               res->vrp.bits_set = new_tarval_from_long(0, mode);
+               res->vrp.bits_not_set = new_tarval_from_long(0, mode);
+               res->vrp.range_bottom = get_tarval_top();
+               res->vrp.range_top = get_tarval_top();
+       } else {
+               res->vrp.bits_set = get_tarval_bad();
+               res->vrp.bits_not_set = get_tarval_bad();
+               res->vrp.range_bottom = get_tarval_bad();
+               res->vrp.range_top = get_tarval_bad();
+       }
+       res->vrp.bits_node = NULL;
+       res->vrp.range_node = NULL;
+       res->vrp.range_op = VRP_NONE;
+
 
        return res;
 }
@@ -233,7 +252,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
@@ -818,10 +837,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;
        }
@@ -995,49 +1015,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 "<unknown>";
-#undef X
-}
-
 ir_node *
 get_Cond_selector(const ir_node *node) {
        assert(is_Cond(node));
@@ -1050,18 +1027,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));
@@ -2837,6 +2802,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) {
@@ -2977,7 +2946,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,... */