#include <stdlib.h>
+#include "irargs_t.h"
#include "irprog_t.h"
#include "irgraph_t.h"
#include "irnode_t.h"
#include "../beinfo.h"
#include "bearch_ia32_t.h"
+#include "ia32_common_transform.h"
#include "ia32_nodes_attr.h"
#include "ia32_new_nodes.h"
#include "gen_ia32_regalloc_if.h"
break;
case dump_node_info_txt:
- n_res = arch_irn_get_n_outs(n);
fprintf(F, "=== IA32 attr begin ===\n");
/* dump IN requirements */
dump_reg_req(F, n, reqs, 0);
}
- /* dump OUT requirements */
+ n_res = arch_irn_get_n_outs(n);
if (n_res > 0) {
+ /* dump OUT requirements */
reqs = get_ia32_out_req_all(n);
dump_reg_req(F, n, reqs, 1);
- }
- /* dump assigned registers */
- if (n_res > 0) {
+ /* dump assigned registers */
for (i = 0; i < n_res; i++) {
const arch_register_t *reg = arch_irn_get_register(n, i);
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, "n_res = %d\n", n_res);
+ 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));
+ 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 =");
return copyb_attr;
}
+ia32_climbframe_attr_t *get_ia32_climbframe_attr(ir_node *node) {
+ ia32_attr_t *attr = get_ia32_attr(node);
+ ia32_climbframe_attr_t *climbframe_attr = CAST_IA32_ATTR(ia32_climbframe_attr_t, attr);
+
+ return climbframe_attr;
+}
+
+const ia32_climbframe_attr_t *get_ia32_climbframe_attr_const(const ir_node *node) {
+ const ia32_attr_t *attr = get_ia32_attr_const(node);
+ const ia32_climbframe_attr_t *climbframe_attr = CONST_CAST_IA32_ATTR(ia32_climbframe_attr_t, attr);
+
+ return climbframe_attr;
+}
+
/**
* Gets the type of an ia32 node.
*/
/**
* Gets the addr mode const.
*/
-int get_ia32_am_scale(const ir_node *node) {
+unsigned get_ia32_am_scale(const ir_node *node) {
const ia32_attr_t *attr = get_ia32_attr_const(node);
return attr->data.am_scale;
}
/**
* Sets the index register scale for address mode.
*/
-void set_ia32_am_scale(ir_node *node, int scale) {
+void set_ia32_am_scale(ir_node *node, unsigned scale) {
ia32_attr_t *attr = get_ia32_attr(node);
- assert(0 <= scale && scale < 4 && "AM scale out of range");
+ assert(scale <= 3 && "AM scale out of range [0 ... 3]");
attr->data.am_scale = scale;
}
/**
* Returns the name of the original ir node.
*/
-const char *get_ia32_orig_node(const ir_node *node) {
+const char *get_ia32_orig_node(const ir_node *node)
+{
const ia32_attr_t *attr = get_ia32_attr_const(node);
return attr->orig_node;
}
+static const char *ia32_get_old_node_name(const ir_node *irn)
+{
+ struct obstack *obst = env_cg->isa->name_obst;
+
+ lc_eoprintf(firm_get_arg_env(), obst, "%+F", irn);
+ obstack_1grow(obst, 0);
+ return obstack_finish(obst);
+}
+
/**
* Sets the name of the original ir node.
*/
-void set_ia32_orig_node(ir_node *node, const char *name) {
+void set_ia32_orig_node(ir_node *node, const ir_node *old)
+{
+ const char *name = ia32_get_old_node_name(old);
ia32_attr_t *attr = get_ia32_attr(node);
attr->orig_node = name;
}
attr->offset = offset;
}
-void init_ia32_call_attributes(ir_node *const res, unsigned const pop, ir_type *const call_tp)
+void init_ia32_call_attributes(ir_node* res, unsigned pop, ir_type* call_tp)
{
ia32_call_attr_t *attr = get_irn_generic_attr(res);
attr->pn_code = pnc;
}
+void
+init_ia32_climbframe_attributes(ir_node *res, unsigned count) {
+ ia32_climbframe_attr_t *attr = get_irn_generic_attr(res);
+
+#ifndef NDEBUG
+ attr->attr.attr_type |= IA32_ATTR_ia32_climbframe_attr_t;
+#endif
+ attr->count = count;
+}
+
/***************************************************************************************
* _ _ _
* | | | | | |
***************************************************************************************/
/* default compare operation to compare attributes */
-int ia32_compare_attr(const ia32_attr_t *a, const ia32_attr_t *b) {
+int ia32_compare_attr(const ia32_attr_t *a, const ia32_attr_t *b)
+{
if (a->data.tp != b->data.tp)
return 1;
|| a->frame_ent != b->frame_ent)
return 1;
- if (a->data.tp != b->data.tp)
- return 1;
-
if (a->data.has_except_label != b->data.has_except_label)
return 1;
attr_a = get_ia32_condcode_attr_const(a);
attr_b = get_ia32_condcode_attr_const(b);
- if(attr_a->pn_code != attr_b->pn_code)
+ if (attr_a->pn_code != attr_b->pn_code)
return 1;
return 0;
}
+/** Compare node attributes for call nodes. */
static int ia32_compare_call_attr(ir_node *a, ir_node *b)
{
const ia32_call_attr_t *attr_a;
attr_a = get_ia32_copyb_attr_const(a);
attr_b = get_ia32_copyb_attr_const(b);
- if(attr_a->size != attr_b->size)
+ if (attr_a->size != attr_b->size)
return 1;
return 0;
const ia32_asm_attr_t *attr_a;
const ia32_asm_attr_t *attr_b;
- if(ia32_compare_nodes_attr(a, b))
+ if (ia32_compare_nodes_attr(a, b))
return 1;
attr_a = get_ia32_asm_attr_const(a);
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->offset != attr_b->offset)
return 1;
return 0;
return ia32_compare_nodes_attr(a, b);
}
+/** Compare node attributes for ClimbFrame nodes. */
+static
+int ia32_compare_climbframe_attr(ir_node *a, ir_node *b)
+{
+ const ia32_climbframe_attr_t *attr_a;
+ const ia32_climbframe_attr_t *attr_b;
+
+ if (ia32_compare_nodes_attr(a, b))
+ return 1;
+
+ attr_a = get_ia32_climbframe_attr_const(a);
+ attr_b = get_ia32_climbframe_attr_const(b);
+
+ if (attr_a->count != attr_b->count)
+ return 1;
+
+ return 0;
+}
/* copies the ia32 attributes */
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)));