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 * @brief This file implements the creation of the achitecture specific firm
23 * opcodes and the coresponding node constructors for the TEMPLATE
32 #include "irgraph_t.h"
41 #include "../bearch.h"
43 #include "TEMPLATE_nodes_attr.h"
44 #include "TEMPLATE_new_nodes.h"
45 #include "gen_TEMPLATE_regalloc_if.h"
48 * Dumper interface for dumping TEMPLATE nodes in vcg.
49 * @param F the output file
50 * @param n the node to dump
51 * @param reason indicates which kind of information should be dumped
53 static void TEMPLATE_dump_node(FILE *F, ir_node *n, dump_reason_t reason)
58 case dump_node_opcode_txt:
59 fprintf(F, "%s", get_irn_opname(n));
62 case dump_node_mode_txt:
63 mode = get_irn_mode(n);
66 fprintf(F, "[%s]", get_mode_name(mode));
68 fprintf(F, "[?NOMODE?]");
72 case dump_node_nodeattr_txt:
74 /* TODO: dump some attributes which should show up */
75 /* in node name in dump (e.g. consts or the like) */
79 case dump_node_info_txt:
80 arch_dump_reqs_and_registers(F, n);
85 const TEMPLATE_attr_t *get_TEMPLATE_attr_const(const ir_node *node)
87 assert(is_TEMPLATE_irn(node) && "need TEMPLATE node to get attributes");
88 return (const TEMPLATE_attr_t *)get_irn_generic_attr_const(node);
91 TEMPLATE_attr_t *get_TEMPLATE_attr(ir_node *node)
93 assert(is_TEMPLATE_irn(node) && "need TEMPLATE node to get attributes");
94 return (TEMPLATE_attr_t *)get_irn_generic_attr(node);
98 * Initializes the nodes attributes.
100 static void init_TEMPLATE_attributes(ir_node *node, arch_irn_flags_t flags,
101 const arch_register_req_t **in_reqs,
102 const be_execution_unit_t ***execution_units,
105 ir_graph *irg = get_irn_irg(node);
106 struct obstack *obst = get_irg_obstack(irg);
107 backend_info_t *info;
108 (void) execution_units;
110 arch_irn_set_flags(node, flags);
111 arch_set_in_register_reqs(node, in_reqs);
113 info = be_get_info(node);
114 info->out_infos = NEW_ARR_D(reg_out_info_t, obst, n_res);
115 memset(info->out_infos, 0, n_res * sizeof(info->out_infos[0]));
118 static void set_TEMPLATE_value(ir_node *node, ir_tarval *value)
120 TEMPLATE_attr_t *attr = get_TEMPLATE_attr(node);
124 static int TEMPLATE_compare_attr(ir_node *a, ir_node *b)
126 const TEMPLATE_attr_t *attr_a = get_TEMPLATE_attr_const(a);
127 const TEMPLATE_attr_t *attr_b = get_TEMPLATE_attr_const(b);
134 static void TEMPLATE_copy_attr(ir_graph *irg, const ir_node *old_node,
137 struct obstack *obst = get_irg_obstack(irg);
138 const void *attr_old = get_irn_generic_attr_const(old_node);
139 void *attr_new = get_irn_generic_attr(new_node);
140 backend_info_t *old_info = be_get_info(old_node);
141 backend_info_t *new_info = be_get_info(new_node);
143 /* copy the attributes */
144 memcpy(attr_new, attr_old, get_op_attr_size(get_irn_op(old_node)));
147 new_info->out_infos =
148 DUP_ARR_D(reg_out_info_t, obst, old_info->out_infos);
149 new_info->in_reqs = old_info->in_reqs;
152 /* Include the generated constructor functions */
153 #include "gen_TEMPLATE_new_nodes.c.inl"