becopyopt: Inline the thin wrapper nodes_interfere(), so we do not need to fetch...
[libfirm] / ir / be / TEMPLATE / TEMPLATE_new_nodes.c
1 /*
2  * This file is part of libFirm.
3  * Copyright (C) 2012 University of Karlsruhe.
4  */
5
6 /**
7  * @file
8  * @brief   This file implements the creation of the achitecture specific firm
9  *          opcodes and the coresponding node constructors for the TEMPLATE
10  *          assembler irg.
11  */
12 #include "config.h"
13
14 #include <stdlib.h>
15
16 #include "irprog_t.h"
17 #include "irgraph_t.h"
18 #include "irnode_t.h"
19 #include "irmode_t.h"
20 #include "ircons_t.h"
21 #include "iropt_t.h"
22 #include "irop.h"
23 #include "irprintf.h"
24 #include "xmalloc.h"
25
26 #include "bearch.h"
27
28 #include "TEMPLATE_nodes_attr.h"
29 #include "TEMPLATE_new_nodes.h"
30 #include "gen_TEMPLATE_regalloc_if.h"
31
32 /**
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
37  */
38 static void TEMPLATE_dump_node(FILE *F, const ir_node *n, dump_reason_t reason)
39 {
40         ir_mode *mode = NULL;
41
42         switch (reason) {
43         case dump_node_opcode_txt:
44                 fprintf(F, "%s", get_irn_opname(n));
45                 break;
46
47         case dump_node_mode_txt:
48                 mode = get_irn_mode(n);
49
50                 if (mode) {
51                         fprintf(F, "[%s]", get_mode_name(mode));
52                 } else {
53                         fprintf(F, "[?NOMODE?]");
54                 }
55                 break;
56
57         case dump_node_nodeattr_txt:
58
59                 /* TODO: dump some attributes which should show up */
60                 /* in node name in dump (e.g. consts or the like)  */
61
62                 break;
63
64         case dump_node_info_txt:
65                 arch_dump_reqs_and_registers(F, n);
66                 break;
67         }
68 }
69
70 const TEMPLATE_attr_t *get_TEMPLATE_attr_const(const ir_node *node)
71 {
72         assert(is_TEMPLATE_irn(node) && "need TEMPLATE node to get attributes");
73         return (const TEMPLATE_attr_t *)get_irn_generic_attr_const(node);
74 }
75
76 TEMPLATE_attr_t *get_TEMPLATE_attr(ir_node *node)
77 {
78         assert(is_TEMPLATE_irn(node) && "need TEMPLATE node to get attributes");
79         return (TEMPLATE_attr_t *)get_irn_generic_attr(node);
80 }
81
82 /**
83  * Initializes the nodes attributes.
84  */
85 static void init_TEMPLATE_attributes(ir_node *node, arch_irn_flags_t flags,
86                                      const arch_register_req_t **in_reqs,
87                                      int n_res)
88 {
89         ir_graph        *irg  = get_irn_irg(node);
90         struct obstack  *obst = get_irg_obstack(irg);
91         backend_info_t  *info;
92
93         arch_set_irn_flags(node, flags);
94         arch_set_irn_register_reqs_in(node, in_reqs);
95
96         info            = be_get_info(node);
97         info->out_infos = NEW_ARR_DZ(reg_out_info_t, obst, n_res);
98 }
99
100 static void set_TEMPLATE_value(ir_node *node, ir_tarval *value)
101 {
102         TEMPLATE_attr_t *attr = get_TEMPLATE_attr(node);
103         attr->value = value;
104 }
105
106 static int TEMPLATE_compare_attr(const ir_node *a, const ir_node *b)
107 {
108         const TEMPLATE_attr_t *attr_a = get_TEMPLATE_attr_const(a);
109         const TEMPLATE_attr_t *attr_b = get_TEMPLATE_attr_const(b);
110         (void) attr_a;
111         (void) attr_b;
112
113         return 0;
114 }
115
116 static void TEMPLATE_copy_attr(ir_graph *irg, const ir_node *old_node,
117                                ir_node *new_node)
118 {
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);
124
125         /* copy the attributes */
126         memcpy(attr_new, attr_old, get_op_attr_size(get_irn_op(old_node)));
127
128         /* copy out flags */
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;
133 }
134
135 /* Include the generated constructor functions */
136 #include "gen_TEMPLATE_new_nodes.c.inl"