- add support for statistics and merge debug info
[libfirm] / ir / be / ppc32 / ppc32_new_nodes.c
index f2b437d..9d97cba 100644 (file)
 
 /**
  * @file
- * @brief  This file implements the creation of the achitecture specific firm
- *         opcodes and the coresponding node constructors for the ppc assembler
+ * @brief  This file implements the creation of the architecture specific firm
+ *         opcodes and the corresponding node constructors for the ppc assembler
  *         irg.
  * @author  Moritz Kroll, Jens Mueller
  * @version $Id$
  */
-#ifdef HAVE_CONFIG_H
 #include "config.h"
-#endif
 
 #include <stdlib.h>
 
@@ -67,7 +65,7 @@
  */
 static void dump_reg_req(FILE *F, ir_node *n, const arch_register_req_t **reqs, int inout) {
        char *dir = inout ? "out" : "in";
-       int   max = inout ? get_ppc32_n_res(n) : get_irn_arity(n);
+       int   max = inout ? (int) arch_irn_get_n_outs(n)  : get_irn_arity(n);
        char  buf[1024];
        int   i;
 
@@ -102,7 +100,7 @@ static void dump_reg_req(FILE *F, ir_node *n, const arch_register_req_t **reqs,
                                }
                        }
 
-                       if (reqs[i]->type & arch_register_req_type_should_be_different) {
+                       if (reqs[i]->type & arch_register_req_type_must_be_different) {
                                const unsigned other = reqs[i]->other_different;
                                int i;
 
@@ -134,10 +132,8 @@ static void dump_reg_req(FILE *F, ir_node *n, const arch_register_req_t **reqs,
 static int ppc32_dump_node(ir_node *n, FILE *F, dump_reason_t reason) {
        ir_mode     *mode = NULL;
        int          bad  = 0;
-       int          i;
-       ppc32_attr_t *attr;
+       int          i, n_res, flags;
        const arch_register_req_t **reqs;
-       const arch_register_t     **slots;
 
        switch (reason) {
                case dump_node_opcode_txt:
@@ -163,7 +159,6 @@ static int ppc32_dump_node(ir_node *n, FILE *F, dump_reason_t reason) {
                        break;
 
                case dump_node_info_txt:
-                       attr = get_ppc32_attr(n);
                        fprintf(F, "=== ppc attr begin ===\n");
 
                        /* dump IN requirements */
@@ -172,46 +167,42 @@ static int ppc32_dump_node(ir_node *n, FILE *F, dump_reason_t reason) {
                                dump_reg_req(F, n, reqs, 0);
                        }
 
-                       /* dump OUT requirements */
-                       if (ARR_LEN(attr->slots) > 0) {
+                       n_res = arch_irn_get_n_outs(n);
+                       if (n_res > 0) {
+                               /* dump OUT requirements */
                                reqs = get_ppc32_out_req_all(n);
                                dump_reg_req(F, n, reqs, 1);
-                       }
 
-                       /* dump assigned registers */
-                       slots = get_ppc32_slots(n);
-                       if (slots && ARR_LEN(attr->slots) > 0) {
-                               for (i = 0; i < ARR_LEN(attr->slots); i++) {
-                                       if (slots[i]) {
-                                               fprintf(F, "reg #%d = %s\n", i, slots[i]->name);
-                                       }
-                                       else {
-                                               fprintf(F, "reg #%d = n/a\n", i);
-                                       }
+                               /* dump assigned registers */
+                               for (i = 0; i < n_res; i++) {
+                                       const arch_register_t *reg = arch_irn_get_register(n, i);
+
+                                       fprintf(F, "reg #%d = %s\n", i, reg ? arch_register_get_name(reg) : "n/a");
                                }
+                               fprintf(F, "\n");
                        }
-                       fprintf(F, "\n");
 
                        /* dump n_res */
-                       fprintf(F, "n_res = %d\n", get_ppc32_n_res(n));
+                       fprintf(F, "n_res = %d\n", n_res);
 
                        /* dump flags */
                        fprintf(F, "flags =");
-                       if (attr->flags == arch_irn_flags_none) {
+                       flags = arch_irn_get_flags(n);
+                       if (flags == arch_irn_flags_none) {
                                fprintf(F, " none");
                        }
                        else {
-                               if (attr->flags & arch_irn_flags_dont_spill) {
+                               if (flags & arch_irn_flags_dont_spill) {
                                        fprintf(F, " unspillable");
                                }
-                               if (attr->flags & arch_irn_flags_rematerializable) {
+                               if (flags & arch_irn_flags_rematerializable) {
                                        fprintf(F, " remat");
                                }
-                               if (attr->flags & arch_irn_flags_ignore) {
-                                       fprintf(F, " ignore");
+                               if (flags & arch_irn_flags_modify_flags) {
+                                       fprintf(F, " modify_flags");
                                }
                        }
-                       fprintf(F, " (%d)\n", attr->flags);
+                       fprintf(F, " (%d)\n", flags);
 
                        /* TODO: dump all additional attributes */
 
@@ -297,77 +288,6 @@ void set_ppc32_req_in(ir_node *node, const arch_register_req_t *req, int pos) {
        attr->in_req[pos] = req;
 }
 
-/**
- * Returns the register flag of an ppc node.
- */
-arch_irn_flags_t get_ppc32_flags(const ir_node *node) {
-       const ppc32_attr_t *attr = get_ppc32_attr_const(node);
-       return attr->flags;
-}
-
-/**
- * Sets the register flag of an ppc node.
- */
-void set_ppc32_flags(ir_node *node, arch_irn_flags_t flags) {
-       ppc32_attr_t *attr = get_ppc32_attr(node);
-       attr->flags      = flags;
-}
-
-/**
- * Returns the result register slots of an ppc node.
- */
-const arch_register_t **get_ppc32_slots(const ir_node *node) {
-       const ppc32_attr_t *attr = get_ppc32_attr_const(node);
-       return attr->slots;
-}
-
-/**
- * Returns the name of the OUT register at position pos.
- */
-const char *get_ppc32_out_reg_name(const ir_node *node, int pos) {
-       const ppc32_attr_t *attr = get_ppc32_attr_const(node);
-
-       assert(is_ppc32_irn(node) && "Not an ppc node.");
-       assert(pos < ARR_LEN(attr->slots) && "Invalid OUT position.");
-       assert(attr->slots[pos]  && "No register assigned");
-
-       return arch_register_get_name(attr->slots[pos]);
-}
-
-/**
- * Returns the index of the OUT register at position pos within its register class.
- */
-int get_ppc32_out_regnr(const ir_node *node, int pos) {
-       const ppc32_attr_t *attr = get_ppc32_attr_const(node);
-
-       assert(is_ppc32_irn(node) && "Not an ppc node.");
-       assert(pos < ARR_LEN(attr->slots) && "Invalid OUT position.");
-       assert(attr->slots[pos]  && "No register assigned");
-
-       return arch_register_get_index(attr->slots[pos]);
-}
-
-/**
- * Returns the OUT register at position pos.
- */
-const arch_register_t *get_ppc32_out_reg(const ir_node *node, int pos) {
-       const ppc32_attr_t *attr = get_ppc32_attr_const(node);
-
-       assert(is_ppc32_irn(node) && "Not an ppc node.");
-       assert(pos < ARR_LEN(attr->slots) && "Invalid OUT position.");
-       assert(attr->slots[pos]  && "No register assigned");
-
-       return attr->slots[pos];
-}
-
-/**
- * Returns the number of results.
- */
-int get_ppc32_n_res(const ir_node *node) {
-       const ppc32_attr_t *attr = get_ppc32_attr_const(node);
-       return ARR_LEN(attr->slots);
-}
-
 /**
  * Sets the type of the constant (if any)
  * May be either iro_Const or iro_SymConst
@@ -517,9 +437,10 @@ void init_ppc32_attributes(ir_node *node, int flags,
        ir_graph       *irg  = get_irn_irg(node);
        struct obstack *obst = get_irg_obstack(irg);
        ppc32_attr_t   *attr = get_ppc32_attr(node);
+       backend_info_t  *info;
        (void) execution_units;
 
-       attr->flags   = flags;
+       arch_irn_set_flags(node, flags);
        attr->in_req  = in_reqs;
        attr->out_req = out_reqs;
 
@@ -527,8 +448,9 @@ void init_ppc32_attributes(ir_node *node, int flags,
        attr->offset_mode  = ppc32_ao_Illegal;
        attr->data.empty   = NULL;
 
-       attr->slots = NEW_ARR_D(const arch_register_t*, obst, n_res);
-       memset(attr->slots, 0, n_res * sizeof(attr->slots[0]));
+       info            = be_get_info(node);
+       info->out_infos = NEW_ARR_D(reg_out_info_t, obst, n_res);
+       memset(info->out_infos, 0, n_res * sizeof(info->out_infos[0]));
 }