2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @author Matthias Braun
36 static copy_attr_func old_phi_copy_attr;
38 void be_info_new_node(ir_node *node)
46 if (is_Proj(node)) // Projs need no be info, their tuple holds all information
49 obst = get_irg_obstack(current_ir_graph);
50 info = OALLOCZ(obst, backend_info_t);
53 info->out_infos = NEW_ARR_D(reg_out_info_t, obst, 1);
54 memset(info->out_infos, 0, 1 * sizeof(info->out_infos[0]));
56 assert(node->backend_info == NULL);
57 node->backend_info = info;
60 static void new_Phi_copy_attr(const ir_node *old_node, ir_node *new_node)
62 struct obstack *obst = get_irg_obstack(get_irn_irg(new_node));
63 backend_info_t *old_info = be_get_info(old_node);
64 backend_info_t *new_info = be_get_info(new_node);
66 old_phi_copy_attr(old_node, new_node);
67 new_info->out_infos = DUP_ARR_D(reg_out_info_t, obst, old_info->out_infos);
70 int be_info_equal(const ir_node *node1, const ir_node *node2)
72 backend_info_t *info1 = be_get_info(node1);
73 backend_info_t *info2 = be_get_info(node2);
74 int len = ARR_LEN(info1->out_infos);
77 if (ARR_LEN(info2->out_infos) != len)
80 for (i = 0; i < len; ++i) {
81 const reg_out_info_t *out1 = &info1->out_infos[i];
82 const reg_out_info_t *out2 = &info2->out_infos[i];
83 if (out1->reg != out2->reg)
85 if (!reg_reqs_equal(out1->req, out2->req))
94 static void init_walker(ir_node *node, void *data)
97 be_info_new_node(node);
100 static bool initialized = false;
102 void be_info_init(void)
105 panic("double initialization of be_info");
107 old_phi_copy_attr = op_Phi->ops.copy_attr;
108 op_Phi->ops.copy_attr = new_Phi_copy_attr;
111 /* phis have register and register requirements now which we want to dump */
112 assert(op_Phi->ops.dump_node == NULL);
113 op_Phi->ops.dump_node = be_dump_phi_reg_reqs;
116 void be_info_init_irg(ir_graph *irg)
118 irg_walk_anchors(irg, init_walker, NULL, NULL);
121 void be_info_free(void)
124 panic("be_info_free called without prior init");
126 assert(op_Phi->ops.copy_attr == new_Phi_copy_attr);
127 op_Phi->ops.copy_attr = old_phi_copy_attr;
130 assert(op_Phi->ops.dump_node == be_dump_phi_reg_reqs);
131 op_Phi->ops.dump_node = NULL;
134 int be_info_initialized(const ir_graph *irg)