no unnecessary and cryptic abreviations: rename vrfy to verify
[libfirm] / ir / be / TEMPLATE / TEMPLATE_new_nodes.c
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
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.
10  *
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.
14  *
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
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief   This file implements the creation of the achitecture specific firm
23  *          opcodes and the coresponding node constructors for the TEMPLATE
24  *          assembler irg.
25  * @version $Id$
26  */
27 #include "config.h"
28
29 #include <stdlib.h>
30
31 #include "irprog_t.h"
32 #include "irgraph_t.h"
33 #include "irnode_t.h"
34 #include "irmode_t.h"
35 #include "ircons_t.h"
36 #include "iropt_t.h"
37 #include "irop.h"
38 #include "irprintf.h"
39 #include "xmalloc.h"
40
41 #include "../bearch.h"
42
43 #include "TEMPLATE_nodes_attr.h"
44 #include "TEMPLATE_new_nodes.h"
45 #include "gen_TEMPLATE_regalloc_if.h"
46
47 /**
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
52  */
53 static void TEMPLATE_dump_node(FILE *F, ir_node *n, dump_reason_t reason)
54 {
55         ir_mode *mode = NULL;
56
57         switch (reason) {
58         case dump_node_opcode_txt:
59                 fprintf(F, "%s", get_irn_opname(n));
60                 break;
61
62         case dump_node_mode_txt:
63                 mode = get_irn_mode(n);
64
65                 if (mode) {
66                         fprintf(F, "[%s]", get_mode_name(mode));
67                 } else {
68                         fprintf(F, "[?NOMODE?]");
69                 }
70                 break;
71
72         case dump_node_nodeattr_txt:
73
74                 /* TODO: dump some attributes which should show up */
75                 /* in node name in dump (e.g. consts or the like)  */
76
77                 break;
78
79         case dump_node_info_txt:
80                 arch_dump_reqs_and_registers(F, n);
81                 break;
82         }
83 }
84
85 const TEMPLATE_attr_t *get_TEMPLATE_attr_const(const ir_node *node)
86 {
87         assert(is_TEMPLATE_irn(node) && "need TEMPLATE node to get attributes");
88         return (const TEMPLATE_attr_t *)get_irn_generic_attr_const(node);
89 }
90
91 TEMPLATE_attr_t *get_TEMPLATE_attr(ir_node *node)
92 {
93         assert(is_TEMPLATE_irn(node) && "need TEMPLATE node to get attributes");
94         return (TEMPLATE_attr_t *)get_irn_generic_attr(node);
95 }
96
97 /**
98  * Returns the argument register requirements of a TEMPLATE node.
99  */
100 const arch_register_req_t **get_TEMPLATE_in_req_all(const ir_node *node)
101 {
102         const TEMPLATE_attr_t *attr = get_TEMPLATE_attr_const(node);
103         return attr->in_req;
104 }
105
106 /**
107  * Returns the argument register requirement at position pos of an TEMPLATE node.
108  */
109 const arch_register_req_t *get_TEMPLATE_in_req(const ir_node *node, int pos)
110 {
111         const TEMPLATE_attr_t *attr = get_TEMPLATE_attr_const(node);
112         return attr->in_req[pos];
113 }
114
115 /**
116  * Sets the IN register requirements at position pos.
117  */
118 void set_TEMPLATE_req_in(ir_node *node, const arch_register_req_t *req, int pos)
119 {
120         TEMPLATE_attr_t *attr  = get_TEMPLATE_attr(node);
121         attr->in_req[pos] = req;
122 }
123
124 /**
125  * Initializes the nodes attributes.
126  */
127 static void init_TEMPLATE_attributes(ir_node *node, arch_irn_flags_t flags,
128                                      const arch_register_req_t **in_reqs,
129                                      const be_execution_unit_t ***execution_units,
130                                      int n_res)
131 {
132         ir_graph        *irg  = get_irn_irg(node);
133         struct obstack  *obst = get_irg_obstack(irg);
134         TEMPLATE_attr_t *attr = get_TEMPLATE_attr(node);
135         backend_info_t  *info;
136         (void) execution_units;
137
138         arch_irn_set_flags(node, flags);
139         attr->in_req  = in_reqs;
140
141         info            = be_get_info(node);
142         info->out_infos = NEW_ARR_D(reg_out_info_t, obst, n_res);
143         memset(info->out_infos, 0, n_res * sizeof(info->out_infos[0]));
144 }
145
146 static void set_TEMPLATE_value(ir_node *node, tarval *value)
147 {
148         TEMPLATE_attr_t *attr = get_TEMPLATE_attr(node);
149         attr->value = value;
150 }
151
152 static int TEMPLATE_compare_attr(ir_node *a, ir_node *b)
153 {
154         const TEMPLATE_attr_t *attr_a = get_TEMPLATE_attr_const(a);
155         const TEMPLATE_attr_t *attr_b = get_TEMPLATE_attr_const(b);
156         (void) attr_a;
157         (void) attr_b;
158
159         return 0;
160 }
161
162 /* Include the generated constructor functions */
163 #include "gen_TEMPLATE_new_nodes.c.inl"