fix warnings because compare_attr gets const nodes now
[libfirm] / ir / be / arm / arm_new_nodes.c
index da31251..4f6ca20 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
+ * Copyright (C) 1995-2011 University of Karlsruhe.  All right reserved.
  *
  * This file is part of libFirm.
  *
@@ -37,7 +37,6 @@
 #include "ircons_t.h"
 #include "iropt_t.h"
 #include "irop.h"
-#include "irvrfy_t.h"
 #include "irprintf.h"
 #include "xmalloc.h"
 
@@ -65,14 +64,15 @@ const char *arm_get_fpa_imm_name(long imm_value)
        return fpa_imm[imm_value];
 }
 
-static bool arm_has_immediate(const ir_node *node)
+static bool arm_has_symconst_attr(const ir_node *node)
 {
-       return is_arm_SymConst(node) || is_arm_FrameAddr(node);
+       return is_arm_SymConst(node) || is_arm_FrameAddr(node) || is_arm_Bl(node);
 }
 
 static bool has_load_store_attr(const ir_node *node)
 {
-       return is_arm_Ldr(node) || is_arm_Str(node);
+       return is_arm_Ldr(node) || is_arm_Str(node) || is_arm_LinkLdrPC(node)
+               || is_arm_Ldf(node) || is_arm_Stf(node);
 }
 
 static bool has_shifter_operand(const ir_node *node)
@@ -80,7 +80,7 @@ static bool has_shifter_operand(const ir_node *node)
        return is_arm_Add(node) || is_arm_And(node) || is_arm_Or(node)
                || is_arm_Eor(node) || is_arm_Bic(node) || is_arm_Sub(node)
                || is_arm_Rsb(node) || is_arm_Mov(node) || is_arm_Mvn(node)
-               || is_arm_Cmp(node) || is_arm_Tst(node);
+               || is_arm_Cmp(node) || is_arm_Tst(node) || is_arm_LinkMovPC(node);
 }
 
 static bool has_cmp_attr(const ir_node *node)
@@ -88,6 +88,12 @@ static bool has_cmp_attr(const ir_node *node)
        return is_arm_Cmp(node) || is_arm_Tst(node);
 }
 
+static bool has_farith_attr(const ir_node *node)
+{
+       return is_arm_Adf(node) || is_arm_Muf(node) || is_arm_Suf(node)
+           || is_arm_Dvf(node) || is_arm_Mvf(node) || is_arm_FltX(node);
+}
+
 /**
  * Dumper interface for dumping arm nodes in vcg.
  * @param F        the output file
@@ -100,8 +106,8 @@ static void arm_dump_node(FILE *F, ir_node *n, dump_reason_t reason)
        case dump_node_opcode_txt:
                fprintf(F, "%s", get_irn_opname(n));
 
-               if (arm_has_immediate(n)) {
-                       const arm_SymConst_attr_t *attr = get_arm_SymConst_attr_const(n);
+               if (arm_has_symconst_attr(n)) {
+                       const arm_SymConst_attr_t *attr = get_arm_SymConst_attr_const(n);
                        if (attr->entity != NULL) {
                                fputc(' ', F);
                                fputs(get_entity_name(attr->entity), F);
@@ -183,7 +189,23 @@ static void arm_dump_node(FILE *F, ir_node *n, dump_reason_t reason)
                        if (attr->ins_permuted) {
                                fprintf(F, " inputs swapped");
                        }
-                       fprintf(F, "\n");
+                       fputc('\n', F);
+               }
+               if (arm_has_symconst_attr(n)) {
+                       const arm_SymConst_attr_t *attr = get_arm_SymConst_attr_const(n);
+
+                       fprintf(F, "entity = ");
+                       if (attr->entity != NULL) {
+                               fprintf(F, "'%s'", get_entity_name(attr->entity));
+                       } else {
+                               fputs("NULL", F);
+                       }
+                       fputc('\n', F);
+                       fprintf(F, "frame offset = %d\n", attr->fp_offset);
+               }
+               if (has_farith_attr(n)) {
+                       const arm_farith_attr_t *attr = get_arm_farith_attr_const(n);
+                       ir_fprintf(F, "arithmetic mode = %+F\n", attr->mode);
                }
                break;
        }
@@ -192,113 +214,114 @@ static void arm_dump_node(FILE *F, ir_node *n, dump_reason_t reason)
 arm_attr_t *get_arm_attr(ir_node *node)
 {
        assert(is_arm_irn(node) && "need arm node to get attributes");
-       return get_irn_generic_attr(node);
+       return (arm_attr_t*)get_irn_generic_attr(node);
 }
 
 const arm_attr_t *get_arm_attr_const(const ir_node *node)
 {
        assert(is_arm_irn(node) && "need arm node to get attributes");
-       return get_irn_generic_attr_const(node);
+       return (const arm_attr_t*)get_irn_generic_attr_const(node);
 }
 
 static bool has_symconst_attr(const ir_node *node)
 {
-       return is_arm_SymConst(node) || is_arm_FrameAddr(node);
+       return is_arm_SymConst(node) || is_arm_FrameAddr(node) || is_arm_Bl(node);
 }
 
 arm_SymConst_attr_t *get_arm_SymConst_attr(ir_node *node)
 {
        assert(has_symconst_attr(node));
-       return get_irn_generic_attr(node);
+       return (arm_SymConst_attr_t*)get_irn_generic_attr(node);
 }
 
 const arm_SymConst_attr_t *get_arm_SymConst_attr_const(const ir_node *node)
 {
        assert(has_symconst_attr(node));
-       return get_irn_generic_attr_const(node);
+       return (const arm_SymConst_attr_t*)get_irn_generic_attr_const(node);
 }
 
-static const arm_fpaConst_attr_t *get_arm_fpaConst_attr_const(
-               const ir_node *node)
+static const arm_fConst_attr_t *get_arm_fConst_attr_const(const ir_node *node)
 {
-       const arm_attr_t          *attr     = get_arm_attr_const(node);
-       const arm_fpaConst_attr_t *fpa_attr = CONST_CAST_ARM_ATTR(arm_fpaConst_attr_t, attr);
+       assert(is_arm_fConst(node));
+       return (const arm_fConst_attr_t*)get_irn_generic_attr_const(node);
+}
 
-       return fpa_attr;
+static arm_fConst_attr_t *get_arm_fConst_attr(ir_node *node)
+{
+       assert(is_arm_fConst(node));
+       return (arm_fConst_attr_t*)get_irn_generic_attr(node);
 }
 
-static arm_fpaConst_attr_t *get_arm_fpaConst_attr(ir_node *node)
+arm_farith_attr_t *get_arm_farith_attr(ir_node *node)
 {
-       arm_attr_t          *attr     = get_arm_attr(node);
-       arm_fpaConst_attr_t *fpa_attr = CAST_ARM_ATTR(arm_fpaConst_attr_t, attr);
+       assert(has_farith_attr(node));
+       return (arm_farith_attr_t*)get_irn_generic_attr(node);
+}
 
-       return fpa_attr;
+const arm_farith_attr_t *get_arm_farith_attr_const(const ir_node *node)
+{
+       assert(has_farith_attr(node));
+       return (const arm_farith_attr_t*)get_irn_generic_attr_const(node);
 }
 
 arm_CondJmp_attr_t *get_arm_CondJmp_attr(ir_node *node)
 {
        assert(is_arm_B(node));
-       return get_irn_generic_attr(node);
+       return (arm_CondJmp_attr_t*)get_irn_generic_attr(node);
 }
 
 const arm_CondJmp_attr_t *get_arm_CondJmp_attr_const(const ir_node *node)
 {
        assert(is_arm_B(node));
-       return get_irn_generic_attr_const(node);
+       return (const arm_CondJmp_attr_t*)get_irn_generic_attr_const(node);
 }
 
 arm_SwitchJmp_attr_t *get_arm_SwitchJmp_attr(ir_node *node)
 {
        assert(is_arm_SwitchJmp(node));
-       return get_irn_generic_attr(node);
+       return (arm_SwitchJmp_attr_t*)get_irn_generic_attr(node);
 }
 
 const arm_SwitchJmp_attr_t *get_arm_SwitchJmp_attr_const(const ir_node *node)
 {
        assert(is_arm_SwitchJmp(node));
-       return get_irn_generic_attr_const(node);
+       return (const arm_SwitchJmp_attr_t*)get_irn_generic_attr_const(node);
 }
 
-void set_arm_in_req_all(ir_node *node, const arch_register_req_t **reqs)
+arm_CopyB_attr_t *get_arm_CopyB_attr(ir_node *node)
 {
-       arm_attr_t *attr = get_arm_attr(node);
-       attr->in_req = reqs;
+       assert(is_arm_CopyB(node));
+       return (arm_CopyB_attr_t*)get_irn_generic_attr(node);
 }
 
-const arch_register_req_t *get_arm_in_req(const ir_node *node, int pos)
+const arm_CopyB_attr_t *get_arm_CopyB_attr_const(const ir_node *node)
 {
-       const arm_attr_t *attr = get_arm_attr_const(node);
-       return attr->in_req[pos];
+       assert(is_arm_CopyB(node));
+       return (const arm_CopyB_attr_t*)get_irn_generic_attr_const(node);
 }
 
-void set_arm_req_in(ir_node *node, const arch_register_req_t *req, int pos)
+ir_tarval *get_fConst_value(const ir_node *node)
 {
-       arm_attr_t *attr  = get_arm_attr(node);
-       attr->in_req[pos] = req;
-}
-
-tarval *get_fpaConst_value(const ir_node *node)
-{
-       const arm_fpaConst_attr_t *attr = get_arm_fpaConst_attr_const(node);
+       const arm_fConst_attr_t *attr = get_arm_fConst_attr_const(node);
        return attr->tv;
 }
 
-void set_fpaConst_value(ir_node *node, tarval *tv)
+void set_fConst_value(ir_node *node, ir_tarval *tv)
 {
-       arm_fpaConst_attr_t *attr = get_arm_fpaConst_attr(node);
+       arm_fConst_attr_t *attr = get_arm_fConst_attr(node);
        attr->tv = tv;
 }
 
-pn_Cmp get_arm_CondJmp_pnc(const ir_node *node)
+ir_relation get_arm_CondJmp_relation(const ir_node *node)
 {
        const arm_CondJmp_attr_t *attr = get_arm_CondJmp_attr_const(node);
-       return attr->pnc;
+       return attr->relation;
 }
 
-void set_arm_CondJmp_pnc(ir_node *node, pn_Cmp pnc)
+void set_arm_CondJmp_relation(ir_node *node, ir_relation relation)
 {
        arm_CondJmp_attr_t *attr = get_arm_CondJmp_attr(node);
-       attr->pnc = pnc;
+       attr->relation = relation;
 }
 
 int get_arm_SwitchJmp_n_projs(const ir_node *node)
@@ -326,7 +349,7 @@ void set_arm_SwitchJmp_default_proj_num(ir_node *node, long default_proj_num)
 }
 
 /* Set the ARM machine node attributes to default values. */
-static void init_arm_attributes(ir_node *node, int flags,
+static void init_arm_attributes(ir_node *node, arch_irn_flags_t flags,
                          const arch_register_req_t ** in_reqs,
                          const be_execution_unit_t ***execution_units,
                                                 int n_res)
@@ -338,8 +361,8 @@ static void init_arm_attributes(ir_node *node, int flags,
        (void) execution_units;
 
        arch_irn_set_flags(node, flags);
-       attr->in_req           = in_reqs;
-       attr->instr_fl         = 0;
+       arch_set_in_register_reqs(node, in_reqs);
+       attr->is_load_store    = false;
 
        info            = be_get_info(node);
        info->out_infos = NEW_ARR_D(reg_out_info_t, obst, n_res);
@@ -351,7 +374,7 @@ static void init_arm_load_store_attributes(ir_node *res, ir_mode *ls_mode,
                                            int entity_sign, long offset,
                                            bool is_frame_entity)
 {
-       arm_load_store_attr_t *attr = get_irn_generic_attr(res);
+       arm_load_store_attr_t *attr = get_arm_load_store_attr(res);
        attr->load_store_mode    = ls_mode;
        attr->entity             = entity;
        attr->entity_sign        = entity_sign;
@@ -364,7 +387,7 @@ static void init_arm_shifter_operand(ir_node *res, unsigned immediate_value,
                                      arm_shift_modifier_t shift_modifier,
                                      unsigned shift_immediate)
 {
-       arm_shifter_operand_t *attr = get_irn_generic_attr(res);
+       arm_shifter_operand_t *attr = get_arm_shifter_operand_attr(res);
        attr->immediate_value = immediate_value;
        attr->shift_modifier  = shift_modifier;
        attr->shift_immediate = shift_immediate;
@@ -372,7 +395,7 @@ static void init_arm_shifter_operand(ir_node *res, unsigned immediate_value,
 
 static void init_arm_cmp_attr(ir_node *res, bool ins_permuted, bool is_unsigned)
 {
-       arm_cmp_attr_t *attr = get_irn_generic_attr(res);
+       arm_cmp_attr_t *attr = get_arm_cmp_attr(res);
        attr->ins_permuted = ins_permuted;
        attr->is_unsigned  = is_unsigned;
 }
@@ -380,25 +403,31 @@ static void init_arm_cmp_attr(ir_node *res, bool ins_permuted, bool is_unsigned)
 static void init_arm_SymConst_attributes(ir_node *res, ir_entity *entity,
                                          int symconst_offset)
 {
-       arm_SymConst_attr_t *attr = get_irn_generic_attr(res);
+       arm_SymConst_attr_t *attr = get_arm_SymConst_attr(res);
        attr->entity    = entity;
        attr->fp_offset = symconst_offset;
 }
 
+static void init_arm_farith_attributes(ir_node *res, ir_mode *mode)
+{
+       arm_farith_attr_t *attr = get_arm_farith_attr(res);
+       attr->mode = mode;
+}
+
 static void init_arm_CopyB_attributes(ir_node *res, unsigned size)
 {
-       arm_CopyB_attr_t *attr = get_irn_generic_attr(res);
+       arm_CopyB_attr_t *attr = get_arm_CopyB_attr(res);
        attr->size = size;
 }
 
-static int cmp_attr_arm(ir_node *a, ir_node *b)
+static int cmp_attr_arm(const ir_node *a, const ir_node *b)
 {
-       arm_attr_t *attr_a = get_irn_generic_attr(a);
-       arm_attr_t *attr_b = get_irn_generic_attr(b);
-       return attr_a->instr_fl != attr_b->instr_fl;
+       (void) a;
+       (void) b;
+       return 0;
 }
 
-static int cmp_attr_arm_SymConst(ir_node *a, ir_node *b)
+static int cmp_attr_arm_SymConst(const ir_node *a, const ir_node *b)
 {
        const arm_SymConst_attr_t *attr_a;
        const arm_SymConst_attr_t *attr_b;
@@ -406,13 +435,13 @@ static int cmp_attr_arm_SymConst(ir_node *a, ir_node *b)
        if (cmp_attr_arm(a, b))
                return 1;
 
-       attr_a = get_irn_generic_attr_const(a);
-       attr_b = get_irn_generic_attr_const(b);
+       attr_a = get_arm_SymConst_attr_const(a);
+       attr_b = get_arm_SymConst_attr_const(b);
        return attr_a->entity != attr_b->entity
                || attr_a->fp_offset != attr_b->fp_offset;
 }
 
-static int cmp_attr_arm_CopyB(ir_node *a, ir_node *b)
+static int cmp_attr_arm_CopyB(const ir_node *a, const ir_node *b)
 {
        const arm_CopyB_attr_t *attr_a;
        const arm_CopyB_attr_t *attr_b;
@@ -420,12 +449,12 @@ static int cmp_attr_arm_CopyB(ir_node *a, ir_node *b)
        if (cmp_attr_arm(a, b))
                return 1;
 
-       attr_a = get_irn_generic_attr_const(a);
-       attr_b = get_irn_generic_attr_const(b);
+       attr_a = get_arm_CopyB_attr_const(a);
+       attr_b = get_arm_CopyB_attr_const(b);
        return attr_a->size != attr_b->size;
 }
 
-static int cmp_attr_arm_CondJmp(ir_node *a, ir_node *b)
+static int cmp_attr_arm_CondJmp(const ir_node *a, const ir_node *b)
 {
        (void) a;
        (void) b;
@@ -433,7 +462,7 @@ static int cmp_attr_arm_CondJmp(ir_node *a, ir_node *b)
        return 1;
 }
 
-static int cmp_attr_arm_SwitchJmp(ir_node *a, ir_node *b)
+static int cmp_attr_arm_SwitchJmp(const ir_node *a, const ir_node *b)
 {
        (void) a;
        (void) b;
@@ -441,16 +470,16 @@ static int cmp_attr_arm_SwitchJmp(ir_node *a, ir_node *b)
        return 1;
 }
 
-static int cmp_attr_arm_fpaConst(ir_node *a, ir_node *b)
+static int cmp_attr_arm_fConst(const ir_node *a, const ir_node *b)
 {
-       const arm_fpaConst_attr_t *attr_a;
-       const arm_fpaConst_attr_t *attr_b;
+       const arm_fConst_attr_t *attr_a;
+       const arm_fConst_attr_t *attr_b;
 
        if (cmp_attr_arm(a, b))
                return 1;
 
-       attr_a = get_arm_fpaConst_attr_const(a);
-       attr_b = get_arm_fpaConst_attr_const(b);
+       attr_a = get_arm_fConst_attr_const(a);
+       attr_b = get_arm_fConst_attr_const(b);
 
        return attr_a->tv != attr_b->tv;
 }
@@ -487,7 +516,7 @@ const arm_cmp_attr_t *get_arm_cmp_attr_const(const ir_node *node)
        return (const arm_cmp_attr_t*) get_irn_generic_attr_const(node);
 }
 
-static int cmp_attr_arm_load_store(ir_node *a, ir_node *b)
+static int cmp_attr_arm_load_store(const ir_node *a, const ir_node *b)
 {
        const arm_load_store_attr_t *attr_a;
        const arm_load_store_attr_t *attr_b;
@@ -495,8 +524,8 @@ static int cmp_attr_arm_load_store(ir_node *a, ir_node *b)
        if (cmp_attr_arm(a, b))
                return 1;
 
-       attr_a = get_arm_load_store_attr(a);
-       attr_b = get_arm_load_store_attr(b);
+       attr_a = get_arm_load_store_attr_const(a);
+       attr_b = get_arm_load_store_attr_const(b);
        if (attr_a->entity != attr_b->entity
                        || attr_a->entity_sign != attr_b->entity_sign
                        || attr_a->offset != attr_b->offset)
@@ -505,7 +534,7 @@ static int cmp_attr_arm_load_store(ir_node *a, ir_node *b)
        return 0;
 }
 
-static int cmp_attr_arm_shifter_operand(ir_node *a, ir_node *b)
+static int cmp_attr_arm_shifter_operand(const ir_node *a, const ir_node *b)
 {
        const arm_shifter_operand_t *attr_a;
        const arm_shifter_operand_t *attr_b;
@@ -513,8 +542,8 @@ static int cmp_attr_arm_shifter_operand(ir_node *a, ir_node *b)
        if (cmp_attr_arm(a, b))
                return 1;
 
-       attr_a = get_arm_shifter_operand_attr(a);
-       attr_b = get_arm_shifter_operand_attr(b);
+       attr_a = get_arm_shifter_operand_attr_const(a);
+       attr_b = get_arm_shifter_operand_attr_const(b);
        if (attr_a->shift_modifier != attr_b->shift_modifier
                        || attr_a->immediate_value != attr_b->immediate_value
                        || attr_a->shift_immediate != attr_b->shift_immediate)
@@ -523,7 +552,7 @@ static int cmp_attr_arm_shifter_operand(ir_node *a, ir_node *b)
        return 0;
 }
 
-static int cmp_attr_arm_cmp(ir_node *a, ir_node *b)
+static int cmp_attr_arm_cmp(const ir_node *a, const ir_node *b)
 {
        const arm_cmp_attr_t *attr_a;
        const arm_cmp_attr_t *attr_b;
@@ -531,14 +560,27 @@ static int cmp_attr_arm_cmp(ir_node *a, ir_node *b)
        if (cmp_attr_arm(a, b))
                return 1;
 
-       attr_a = get_irn_generic_attr_const(a);
-       attr_b = get_irn_generic_attr_const(b);
+       attr_a = get_arm_cmp_attr_const(a);
+       attr_b = get_arm_cmp_attr_const(b);
        if (attr_a->ins_permuted != attr_b->ins_permuted
                        || attr_a->is_unsigned != attr_b->is_unsigned)
                return 1;
        return 0;
 }
 
+static int cmp_attr_arm_farith(const ir_node *a, const ir_node *b)
+{
+       const arm_farith_attr_t *attr_a;
+       const arm_farith_attr_t *attr_b;
+
+       if (cmp_attr_arm(a, b))
+               return 1;
+
+       attr_a = get_arm_farith_attr_const(a);
+       attr_b = get_arm_farith_attr_const(b);
+       return attr_a->mode != attr_b->mode;
+}
+
 /** copies the ARM attributes of a node. */
 static void arm_copy_attr(ir_graph *irg, const ir_node *old_node,
                           ir_node *new_node)
@@ -555,6 +597,7 @@ static void arm_copy_attr(ir_graph *irg, const ir_node *old_node,
        /* copy out flags */
        new_info->out_infos =
                DUP_ARR_D(reg_out_info_t, obst, old_info->out_infos);
+       new_info->in_reqs = old_info->in_reqs;
 }