Fixed some obviously wrong conditions.
[libfirm] / ir / ir / irnode.c
index 565f918..19a36e9 100644 (file)
@@ -269,11 +269,11 @@ void set_irn_in(ir_node *node, int arity, ir_node **in) {
 }
 
 ir_node *(get_irn_intra_n)(const ir_node *node, int n) {
-       return _get_irn_intra_n (node, n);
+       return _get_irn_intra_n(node, n);
 }
 
 ir_node *(get_irn_inter_n)(const ir_node *node, int n) {
-       return _get_irn_inter_n (node, n);
+       return _get_irn_inter_n(node, n);
 }
 
 ir_node *(*_get_irn_n)(const ir_node *node, int n) = _get_irn_intra_n;
@@ -288,6 +288,7 @@ void set_irn_n(ir_node *node, int n, ir_node *in) {
        assert(n < get_irn_arity(node));
        assert(in && in->kind == k_ir_node);
 
+#ifdef INTERPROCEDURAL_VIEW
        if ((n == -1) && (get_irn_opcode(node) == iro_Filter)) {
                /* Change block pred in both views! */
                node->in[n + 1] = in;
@@ -295,7 +296,6 @@ void set_irn_n(ir_node *node, int n, ir_node *in) {
                node->attr.filter.in_cg[n + 1] = in;
                return;
        }
-#ifdef INTERPROCEDURAL_VIEW
        if (get_interprocedural_view()) { /* handle Filter and Block specially */
                if (get_irn_opcode(node) == iro_Filter) {
                        assert(node->attr.filter.in_cg);
@@ -518,9 +518,9 @@ symconst_attr *get_irn_symconst_attr(ir_node *node) {
        return &node->attr.symc;
 }
 
-ir_type *get_irn_call_attr(ir_node *node) {
+call_attr *get_irn_call_attr(ir_node *node) {
        assert(is_Call(node));
-       return node->attr.call.type = skip_tid(node->attr.call.type);
+       return &node->attr.call;
 }
 
 sel_attr *get_irn_sel_attr(ir_node *node) {
@@ -782,6 +782,7 @@ ir_node *get_Block_MacroBlock(const ir_node *block) {
 /* Sets the macro block header of a block. */
 void set_Block_MacroBlock(ir_node *block, ir_node *mbh) {
        assert(is_Block(block));
+       mbh = skip_Id(mbh);
        assert(is_Block(mbh));
        set_irn_n(block, -1, mbh);
 }
@@ -1144,7 +1145,6 @@ int (is_Const_all_one)(const ir_node *node) {
 ir_type *
 get_Const_type(ir_node *node) {
        assert(is_Const(node));
-       node->attr.con.tp = skip_tid(node->attr.con.tp);
        return node->attr.con.tp;
 }
 
@@ -1178,7 +1178,7 @@ get_SymConst_type(const ir_node *node) {
        ir_node *irn = (ir_node *)node;
        assert(is_SymConst(node) &&
               (SYMCONST_HAS_TYPE(get_SymConst_kind(node))));
-       return irn->attr.symc.sym.type_p = skip_tid(irn->attr.symc.sym.type_p);
+       return irn->attr.symc.sym.type_p;
 }
 
 void
@@ -1237,7 +1237,6 @@ set_SymConst_symbol(ir_node *node, union symconst_symbol sym) {
 ir_type *
 get_SymConst_value_type(ir_node *node) {
        assert(is_SymConst(node));
-       if (node->attr.symc.tp) node->attr.symc.tp = skip_tid(node->attr.symc.tp);
        return node->attr.symc.tp;
 }
 
@@ -1375,7 +1374,7 @@ set_Call_param(ir_node *node, int pos, ir_node *param) {
 ir_type *
 get_Call_type(ir_node *node) {
        assert(is_Call(node));
-       return node->attr.call.type = skip_tid(node->attr.call.type);
+       return node->attr.call.type;
 }
 
 void
@@ -1385,6 +1384,18 @@ set_Call_type(ir_node *node, ir_type *tp) {
        node->attr.call.type = tp;
 }
 
+unsigned
+get_Call_tail_call(const ir_node *node) {
+       assert(is_Call(node));
+       return node->attr.call.tail_call;
+}
+
+void
+set_Call_tail_call(ir_node *node, unsigned tail_call) {
+       assert(is_Call(node));
+       node->attr.call.tail_call = tail_call != 0;
+}
+
 ir_node *
 get_Builtin_mem(const ir_node *node) {
        assert(is_Builtin(node));
@@ -1436,7 +1447,7 @@ set_Builtin_param(ir_node *node, int pos, ir_node *param) {
 ir_type *
 get_Builtin_type(ir_node *node) {
        assert(is_Builtin(node));
-       return node->attr.builtin.type = skip_tid(node->attr.builtin.type);
+       return node->attr.builtin.type;
 }
 
 void
@@ -1639,7 +1650,6 @@ void set_Conv_strict(ir_node *node, int strict_flag) {
 ir_type *
 get_Cast_type(ir_node *node) {
        assert(is_Cast(node));
-       node->attr.cast.type = skip_tid(node->attr.cast.type);
        return node->attr.cast.type;
 }
 
@@ -1965,7 +1975,7 @@ set_Alloc_size(ir_node *node, ir_node *size) {
 ir_type *
 get_Alloc_type(ir_node *node) {
        assert(is_Alloc(node));
-       return node->attr.alloc.type = skip_tid(node->attr.alloc.type);
+       return node->attr.alloc.type;
 }
 
 void
@@ -2026,7 +2036,7 @@ set_Free_size(ir_node *node, ir_node *size) {
 ir_type *
 get_Free_type(ir_node *node) {
        assert(is_Free(node));
-       return node->attr.free.type = skip_tid(node->attr.free.type);
+       return node->attr.free.type;
 }
 
 void
@@ -2359,7 +2369,7 @@ void set_CopyB_src(ir_node *node, ir_node *src) {
 
 ir_type *get_CopyB_type(ir_node *node) {
        assert(is_CopyB(node));
-       return node->attr.copyb.type = skip_tid(node->attr.copyb.type);
+       return node->attr.copyb.type;
 }
 
 void set_CopyB_type(ir_node *node, ir_type *data_type) {
@@ -2371,7 +2381,7 @@ void set_CopyB_type(ir_node *node, ir_type *data_type) {
 ir_type *
 get_InstOf_type(ir_node *node) {
        assert(node->op == op_InstOf);
-       return node->attr.instof.type = skip_tid(node->attr.instof.type);
+       return node->attr.instof.type;
 }
 
 void
@@ -2539,10 +2549,8 @@ get_irn_irg(const ir_node *node) {
         */
        if (! is_Block(node))
                node = get_irn_n(node, -1);
-       if (is_Bad(node))  /* sometimes bad is predecessor of nodes instead of block: in case of optimization */
-               node = get_irn_n(node, -1);
-       assert(is_Block(node));
-       return node->attr.block.irg;
+       /* note that get_Block_irg() can handle Bad nodes */
+       return get_Block_irg(node);
 }
 
 
@@ -2740,7 +2748,7 @@ ir_node *get_fragile_op_mem(ir_node *node) {
        case iro_Alloc :
        case iro_Bound :
        case iro_CopyB :
-               return get_irn_n(node, pn_Generic_M_regular);
+               return get_irn_n(node, pn_Generic_M);
        case iro_Bad   :
        case iro_Unknown:
                return node;
@@ -2769,7 +2777,7 @@ int (is_irn_forking)(const ir_node *node) {
 }
 
 void (copy_node_attr)(const ir_node *old_node, ir_node *new_node) {
-       return _copy_node_attr(old_node, new_node);
+       _copy_node_attr(old_node, new_node);
 }
 
 /* Return the type associated with the value produced by n