Implement binary emitter for Minus64Bit.
[libfirm] / ir / be / ia32 / ia32_new_nodes.c
index 5f90808..ecbcfb9 100644 (file)
@@ -38,7 +38,6 @@
 #include "ircons_t.h"
 #include "iropt_t.h"
 #include "irop.h"
-#include "firm_common_t.h"
 #include "irvrfy_t.h"
 #include "irprintf.h"
 #include "iredges.h"
@@ -46,7 +45,7 @@
 #include "raw_bitset.h"
 #include "xmalloc.h"
 
-#include "../bearch_t.h"
+#include "../bearch.h"
 #include "../beinfo.h"
 
 #include "bearch_ia32_t.h"
  *                       |_|
  ***********************************************************************************/
 
-/**
- * Dumps the register requirements for either in or out.
- */
-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 ? (int) arch_irn_get_n_outs(n) : get_irn_arity(n);
-       char  buf[1024];
-       int   i;
-
-       memset(buf, 0, sizeof(buf));
-
-       if (reqs) {
-               for (i = 0; i < max; i++) {
-                       fprintf(F, "%sreq #%d =", dir, i);
-
-                       if (reqs[i]->type == arch_register_req_type_none) {
-                               fprintf(F, " n/a");
-                       }
-
-                       if (reqs[i]->type & arch_register_req_type_normal) {
-                               fprintf(F, " %s", reqs[i]->cls->name);
-                       }
-
-                       if (reqs[i]->type & arch_register_req_type_limited) {
-                               fprintf(F, " %s",
-                                       arch_register_req_format(buf, sizeof(buf), reqs[i], n));
-                       }
-
-                       if (reqs[i]->type & arch_register_req_type_should_be_same) {
-                               unsigned other = reqs[i]->other_same;
-                               int i;
-
-                               ir_fprintf(F, " same as");
-                               for (i = 0; 1U << i <= other; ++i) {
-                                       if (other & (1U << i)) {
-                                               ir_fprintf(F, " %+F", get_irn_n(n, i));
-                                       }
-                               }
-                       }
-
-                       if (reqs[i]->type & arch_register_req_type_must_be_different) {
-                               unsigned other = reqs[i]->other_different;
-                               int i;
-
-                               ir_fprintf(F, " different from");
-                               for (i = 0; 1U << i <= other; ++i) {
-                                       if (other & (1U << i)) {
-                                               ir_fprintf(F, " %+F", get_irn_n(n, i));
-                                       }
-                               }
-                       }
-
-                       fprintf(F, "\n");
-               }
-
-               fprintf(F, "\n");
-       }
-       else {
-               fprintf(F, "%sreq = N/A\n", dir);
-       }
-}
-
 /**
  * Dumper interface for dumping ia32 nodes in vcg.
  * @param n        the node to dump
@@ -140,8 +76,6 @@ static void dump_reg_req(FILE *F, ir_node *n, const arch_register_req_t **reqs,
 static int ia32_dump_node(ir_node *n, FILE *F, dump_reason_t reason) {
        ir_mode     *mode = NULL;
        int          bad  = 0;
-       int          i, n_res, flags;
-       const arch_register_req_t **reqs;
 
        switch (reason) {
                case dump_node_opcode_txt:
@@ -163,6 +97,9 @@ static int ia32_dump_node(ir_node *n, FILE *F, dump_reason_t reason) {
                                                fputc('+', F);
                                        }
                                        fprintf(F, "%ld", attr->offset);
+                                       if (attr->no_pic_adjust) {
+                                               fputs("(no_pic_adjust)", F);
+                                       }
                                }
                        }
                        else {
@@ -176,6 +113,9 @@ static int ia32_dump_node(ir_node *n, FILE *F, dump_reason_t reason) {
                                                fputc('-', F);
                                        }
                                        fputs(get_entity_name(attr->am_sc), F);
+                                       if(attr->data.am_sc_no_pic_adjust) {
+                                               fputs("(no_pic_adjust)", F);
+                                       }
                                }
                                if(attr->am_offs != 0) {
                                        if(attr->am_offs > 0 && attr->am_sc != NULL) {
@@ -207,30 +147,7 @@ static int ia32_dump_node(ir_node *n, FILE *F, dump_reason_t reason) {
                        break;
 
                case dump_node_info_txt:
-                       n_res = arch_irn_get_n_outs(n);
-                       fprintf(F, "=== IA32 attr begin ===\n");
-
-                       /* dump IN requirements */
-                       if (get_irn_arity(n) > 0) {
-                               reqs = get_ia32_in_req_all(n);
-                               dump_reg_req(F, n, reqs, 0);
-                       }
-
-                       /* dump OUT requirements */
-                       if (n_res > 0) {
-                               reqs = get_ia32_out_req_all(n);
-                               dump_reg_req(F, n, reqs, 1);
-                       }
-
-                       /* dump assigned registers */
-                       if (n_res > 0) {
-                               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");
-                       }
+                       arch_dump_reqs_and_registers(F, n);
 
                        /* dump op type */
                        fprintf(F, "op = ");
@@ -291,31 +208,11 @@ static int ia32_dump_node(ir_node *n, FILE *F, dump_reason_t reason) {
                                fprintf(F, "size = %u\n", get_ia32_copyb_size(n));
                        }
 
-                       fprintf(F, "n_res = %d\n", arch_irn_get_n_outs(n));
-                       fprintf(F, "use_frame = %d\n", is_ia32_use_frame(n));
-                       fprintf(F, "commutative = %d\n", is_ia32_commutative(n));
+                       fprintf(F, "use_frame = %d\n",     is_ia32_use_frame(n));
+                       fprintf(F, "commutative = %d\n",   is_ia32_commutative(n));
                        fprintf(F, "need stackent = %d\n", is_ia32_need_stackent(n));
-                       fprintf(F, "is reload = %d\n", is_ia32_is_reload(n));
-                       fprintf(F, "latency = %d\n", get_ia32_latency(n));
-
-                       /* dump flags */
-                       fprintf(F, "flags =");
-                       flags = arch_irn_get_flags(n);
-                       if (flags == arch_irn_flags_none) {
-                               fprintf(F, " none");
-                       }
-                       else {
-                               if (flags & arch_irn_flags_dont_spill) {
-                                       fprintf(F, " unspillable");
-                               }
-                               if (flags & arch_irn_flags_rematerializable) {
-                                       fprintf(F, " remat");
-                               }
-                               if (flags & arch_irn_flags_modify_flags) {
-                                       fprintf(F, " modify_flags");
-                               }
-                       }
-                       fprintf(F, " (%d)\n", flags);
+                       fprintf(F, "is reload = %d\n",     is_ia32_is_reload(n));
+                       fprintf(F, "latency = %d\n",       get_ia32_latency(n));
 
                        /* dump frame entity */
                        fprintf(F, "frame entity = ");
@@ -349,8 +246,6 @@ static int ia32_dump_node(ir_node *n, FILE *F, dump_reason_t reason) {
                        fprintf(F, "\n");
 #endif /* NDEBUG */
 
-                       fprintf(F, "=== IA32 attr end ===\n");
-                       /* end of: case dump_node_info_txt */
                        break;
        }
 
@@ -749,22 +644,6 @@ void set_ia32_in_req_all(ir_node *node, const arch_register_req_t **reqs) {
        attr->in_req      = reqs;
 }
 
-/**
- * Returns the result register requirements of an ia32 node.
- */
-const arch_register_req_t **get_ia32_out_req_all(const ir_node *node) {
-       const ia32_attr_t *attr = get_ia32_attr_const(node);
-       return attr->out_req;
-}
-
-/**
- * Sets the result register requirements of an ia32 node.
- */
-void set_ia32_out_req_all(ir_node *node, const arch_register_req_t **reqs) {
-       ia32_attr_t *attr = get_ia32_attr(node);
-       attr->out_req     = reqs;
-}
-
 /**
  * Returns the argument register requirement at position pos of an ia32 node.
  */
@@ -776,29 +655,11 @@ const arch_register_req_t *get_ia32_in_req(const ir_node *node, int pos) {
        return attr->in_req[pos];
 }
 
-/**
- * Returns the result register requirement at position pos of an ia32 node.
- */
-const arch_register_req_t *get_ia32_out_req(const ir_node *node, int pos) {
-       const ia32_attr_t *attr = get_ia32_attr_const(node);
-       if(attr->out_req == NULL)
-               return arch_no_register_req;
-
-       return attr->out_req[pos];
-}
-
-/**
- * Sets the OUT register requirements at position pos.
- */
-void set_ia32_req_out(ir_node *node, const arch_register_req_t *req, int pos) {
-       ia32_attr_t *attr  = get_ia32_attr(node);
-       attr->out_req[pos] = req;
-}
-
 /**
  * Sets the IN register requirements at position pos.
  */
-void set_ia32_req_in(ir_node *node, const arch_register_req_t *req, int pos) {
+void set_ia32_req_in(ir_node *node, const arch_register_req_t *req, int pos)
+{
        ia32_attr_t *attr = get_ia32_attr(node);
        attr->in_req[pos] = req;
 }
@@ -833,7 +694,8 @@ unsigned get_ia32_copyb_size(const ir_node *node)
 /**
  * Get the list of available execution units.
  */
-const be_execution_unit_t ***get_ia32_exec_units(const ir_node *node) {
+const be_execution_unit_t ***get_ia32_exec_units(const ir_node *node)
+{
        const ia32_attr_t *attr = get_ia32_attr_const(node);
        return attr->exec_units;
 }
@@ -841,7 +703,8 @@ const be_execution_unit_t ***get_ia32_exec_units(const ir_node *node) {
 /**
  * Get the exception label attribute.
  */
-unsigned get_ia32_exc_label(const ir_node *node) {
+unsigned get_ia32_exc_label(const ir_node *node)
+{
        const ia32_attr_t *attr = get_ia32_attr_const(node);
        return attr->data.has_except_label;
 }
@@ -849,7 +712,8 @@ unsigned get_ia32_exc_label(const ir_node *node) {
 /**
  * Set the exception label attribute.
  */
-void set_ia32_exc_label(ir_node *node, unsigned flag) {
+void set_ia32_exc_label(ir_node *node, unsigned flag)
+{
        ia32_attr_t *attr = get_ia32_attr(node);
        attr->data.has_except_label = flag;
 }
@@ -857,7 +721,8 @@ void set_ia32_exc_label(ir_node *node, unsigned flag) {
 /**
  * Return the exception label id.
  */
-ir_label_t get_ia32_exc_label_id(const ir_node *node) {
+ir_label_t get_ia32_exc_label_id(const ir_node *node)
+{
        const ia32_attr_t *attr = get_ia32_attr_const(node);
 
        assert(attr->data.has_except_label);
@@ -867,7 +732,8 @@ ir_label_t get_ia32_exc_label_id(const ir_node *node) {
 /**
  * Assign the exception label id.
  */
-void set_ia32_exc_label_id(ir_node *node, ir_label_t id) {
+void set_ia32_exc_label_id(ir_node *node, ir_label_t id)
+{
        ia32_attr_t *attr = get_ia32_attr(node);
 
        assert(attr->data.has_except_label);
@@ -950,7 +816,6 @@ void ia32_swap_left_right(ir_node *node)
  */
 void init_ia32_attributes(ir_node *node, arch_irn_flags_t flags,
                           const arch_register_req_t **in_reqs,
-                          const arch_register_req_t **out_reqs,
                           const be_execution_unit_t ***execution_units,
                           int n_res)
 {
@@ -961,7 +826,6 @@ void init_ia32_attributes(ir_node *node, arch_irn_flags_t flags,
 
        arch_irn_set_flags(node, flags);
        set_ia32_in_req_all(node, in_reqs);
-       set_ia32_out_req_all(node, out_reqs);
 
        attr->exec_units  = execution_units;
 #ifndef NDEBUG
@@ -998,16 +862,18 @@ init_ia32_asm_attributes(ir_node *res)
 
 void
 init_ia32_immediate_attributes(ir_node *res, ir_entity *symconst,
-                               int symconst_sign, long offset)
+                               int symconst_sign, int no_pic_adjust,
+                                                          long offset)
 {
        ia32_immediate_attr_t *attr = get_irn_generic_attr(res);
 
 #ifndef NDEBUG
        attr->attr.attr_type  |= IA32_ATTR_ia32_immediate_attr_t;
 #endif
-       attr->symconst = symconst;
-       attr->sc_sign  = symconst_sign;
-       attr->offset   = offset;
+       attr->symconst      = symconst;
+       attr->sc_sign       = symconst_sign;
+       attr->no_pic_adjust = no_pic_adjust;
+       attr->offset        = offset;
 }
 
 void init_ia32_call_attributes(ir_node* res, unsigned pop, ir_type* call_tp)
@@ -1071,6 +937,7 @@ int ia32_compare_attr(const ia32_attr_t *a, const ia32_attr_t *b)
            || a->data.am_sc_sign != b->data.am_sc_sign
            || a->am_offs != b->am_offs
            || a->am_sc != b->am_sc
+               || a->data.am_sc_no_pic_adjust != b->data.am_sc_no_pic_adjust
            || a->ls_mode != b->ls_mode)
                return 1;
 
@@ -1200,10 +1067,12 @@ int ia32_compare_immediate_attr(ir_node *a, ir_node *b)
        const ia32_immediate_attr_t *attr_a = get_ia32_immediate_attr_const(a);
        const ia32_immediate_attr_t *attr_b = get_ia32_immediate_attr_const(b);
 
-       if (attr_a->symconst != attr_b->symconst ||
-           attr_a->sc_sign != attr_b->sc_sign ||
-           attr_a->offset != attr_b->offset)
+       if (attr_a->symconst != attr_b->symconst
+               || attr_a->sc_sign != attr_b->sc_sign
+               || attr_a->no_pic_adjust != attr_b->no_pic_adjust
+               || attr_a->offset != attr_b->offset) {
                return 1;
+       }
 
        return 0;
 }
@@ -1242,9 +1111,7 @@ static void ia32_copy_attr(const ir_node *old_node, ir_node *new_node)
        const ia32_attr_t *attr_old = get_ia32_attr_const(old_node);
        ia32_attr_t       *attr_new = get_ia32_attr(new_node);
        backend_info_t    *old_info = be_get_info(old_node);
-       backend_info_t    *new_info;
-
-       new_info = be_get_info(new_node);
+       backend_info_t    *new_info = be_get_info(new_node);
 
        /* copy the attributes */
        memcpy(attr_new, attr_old, get_op_attr_size(get_irn_op(old_node)));