2 * This file is part of libFirm.
3 * Copyright (C) 2012 University of Karlsruhe.
8 * @brief This file implements the creation of the achitecture specific firm
9 * opcodes and the coresponding node constructors for the TEMPLATE
17 #include "irgraph_t.h"
28 #include "TEMPLATE_nodes_attr.h"
29 #include "TEMPLATE_new_nodes.h"
30 #include "gen_TEMPLATE_regalloc_if.h"
33 * Dumper interface for dumping TEMPLATE nodes in vcg.
34 * @param F the output file
35 * @param n the node to dump
36 * @param reason indicates which kind of information should be dumped
38 static void TEMPLATE_dump_node(FILE *F, const ir_node *n, dump_reason_t reason)
43 case dump_node_opcode_txt:
44 fprintf(F, "%s", get_irn_opname(n));
47 case dump_node_mode_txt:
48 mode = get_irn_mode(n);
51 fprintf(F, "[%s]", get_mode_name(mode));
53 fprintf(F, "[?NOMODE?]");
57 case dump_node_nodeattr_txt:
59 /* TODO: dump some attributes which should show up */
60 /* in node name in dump (e.g. consts or the like) */
64 case dump_node_info_txt:
65 arch_dump_reqs_and_registers(F, n);
70 const TEMPLATE_attr_t *get_TEMPLATE_attr_const(const ir_node *node)
72 assert(is_TEMPLATE_irn(node) && "need TEMPLATE node to get attributes");
73 return (const TEMPLATE_attr_t *)get_irn_generic_attr_const(node);
76 TEMPLATE_attr_t *get_TEMPLATE_attr(ir_node *node)
78 assert(is_TEMPLATE_irn(node) && "need TEMPLATE node to get attributes");
79 return (TEMPLATE_attr_t *)get_irn_generic_attr(node);
83 * Initializes the nodes attributes.
85 static void init_TEMPLATE_attributes(ir_node *node, arch_irn_flags_t flags,
86 const arch_register_req_t **in_reqs,
89 ir_graph *irg = get_irn_irg(node);
90 struct obstack *obst = get_irg_obstack(irg);
93 arch_set_irn_flags(node, flags);
94 arch_set_irn_register_reqs_in(node, in_reqs);
96 info = be_get_info(node);
97 info->out_infos = NEW_ARR_DZ(reg_out_info_t, obst, n_res);
100 static void set_TEMPLATE_value(ir_node *node, ir_tarval *value)
102 TEMPLATE_attr_t *attr = get_TEMPLATE_attr(node);
106 static int TEMPLATE_compare_attr(const ir_node *a, const ir_node *b)
108 const TEMPLATE_attr_t *attr_a = get_TEMPLATE_attr_const(a);
109 const TEMPLATE_attr_t *attr_b = get_TEMPLATE_attr_const(b);
116 static void TEMPLATE_copy_attr(ir_graph *irg, const ir_node *old_node,
119 struct obstack *obst = get_irg_obstack(irg);
120 const void *attr_old = get_irn_generic_attr_const(old_node);
121 void *attr_new = get_irn_generic_attr(new_node);
122 backend_info_t *old_info = be_get_info(old_node);
123 backend_info_t *new_info = be_get_info(new_node);
125 /* copy the attributes */
126 memcpy(attr_new, attr_old, get_op_attr_size(get_irn_op(old_node)));
129 new_info->flags = old_info->flags;
130 new_info->out_infos =
131 DUP_ARR_D(reg_out_info_t, obst, old_info->out_infos);
132 new_info->in_reqs = old_info->in_reqs;
135 /* Include the generated constructor functions */
136 #include "gen_TEMPLATE_new_nodes.c.inl"