#include "beinfo.h"
#include "bearch.h"
-#include "benode_t.h"
+#include "benode.h"
#include "irgwalk.h"
#include "irnode_t.h"
#include "error.h"
struct obstack *obst;
backend_info_t *info;
- if (is_Anchor(node))
+ /* Projs need no be info, their tuple holds all information */
+ if (is_Proj(node))
return;
- if (is_Proj(node)) // Projs need no be info, their tuple holds all information
- return;
+ obst = be_get_birg_obst(current_ir_graph);
+ info = OALLOCZ(obst, backend_info_t);
- obst = get_irg_obstack(current_ir_graph);
- info = OALLOCZ(obst, backend_info_t);
+ assert(node->backend_info == NULL);
+ node->backend_info = info;
- if (is_Phi(node)) {
+ /* Hack! We still have middle end nodes in the backend (which was probably
+ a bad decision back then), which have no register constraints.
+ Set some none_requirements here.
+ */
+ if (get_irn_mode(node) != mode_T
+ && get_irn_opcode(node) <= iro_Last) {
info->out_infos = NEW_ARR_D(reg_out_info_t, obst, 1);
memset(info->out_infos, 0, 1 * sizeof(info->out_infos[0]));
+ info->out_infos[0].req = arch_no_register_req;
}
- assert(node->backend_info == NULL);
- node->backend_info = info;
}
static void new_Phi_copy_attr(const ir_node *old_node, ir_node *new_node)
{
- struct obstack *obst = get_irg_obstack(get_irn_irg(new_node));
backend_info_t *old_info = be_get_info(old_node);
backend_info_t *new_info = be_get_info(new_node);
+ *new_info = *old_info;
+
old_phi_copy_attr(old_node, new_node);
- new_info->out_infos = DUP_ARR_D(reg_out_info_t, obst, old_info->out_infos);
}
-int be_info_equal(const ir_node *node1, const ir_node *node2)
+int be_infos_equal(const backend_info_t *info1, const backend_info_t *info2)
{
- backend_info_t *info1 = be_get_info(node1);
- backend_info_t *info2 = be_get_info(node2);
int len = ARR_LEN(info1->out_infos);
int i;
if (ARR_LEN(info2->out_infos) != len)
- return 0;
+ return false;
for (i = 0; i < len; ++i) {
const reg_out_info_t *out1 = &info1->out_infos[i];
const reg_out_info_t *out2 = &info2->out_infos[i];
if (out1->reg != out2->reg)
- return 0;
+ return false;
if (!reg_reqs_equal(out1->req, out2->req))
- return 0;
+ return false;
}
- /* TODO: in reqs */
+ return true;
+}
- return 1;
+int be_nodes_equal(const ir_node *node1, const ir_node *node2)
+{
+ backend_info_t *info1 = be_get_info(node1);
+ backend_info_t *info2 = be_get_info(node2);
+ return be_infos_equal(info1, info2);
}
static void init_walker(ir_node *node, void *data)