TEMPLATE_new_nodes.c 6.43 KB
Newer Older
Christian Würdig's avatar
Christian Würdig committed
1
/*
Michael Beck's avatar
Michael Beck committed
2
 * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
Christian Würdig's avatar
Christian Würdig committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 *
 * This file is part of libFirm.
 *
 * This file may be distributed and/or modified under the terms of the
 * GNU General Public License version 2 as published by the Free Software
 * Foundation and appearing in the file LICENSE.GPL included in the
 * packaging of this file.
 *
 * Licensees holding valid libFirm Professional Edition licenses may use
 * this file in accordance with the libFirm Commercial License.
 * Agreement provided with the Software.
 *
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE.
 */

20
/**
Matthias Braun's avatar
Matthias Braun committed
21
22
23
24
25
 * @file
 * @brief   This file implements the creation of the achitecture specific firm
 *          opcodes and the coresponding node constructors for the TEMPLATE
 *          assembler irg.
 * @version $Id$
26
 */
27
#include "config.h"
28
29
30
31
32
33
34
35
36
37
38

#include <stdlib.h>

#include "irprog_t.h"
#include "irgraph_t.h"
#include "irnode_t.h"
#include "irmode_t.h"
#include "ircons_t.h"
#include "iropt_t.h"
#include "irop.h"
#include "irvrfy_t.h"
Christian Würdig's avatar
Christian Würdig committed
39
#include "irprintf.h"
40
#include "xmalloc.h"
41

42
#include "../bearch.h"
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67

#include "TEMPLATE_nodes_attr.h"
#include "TEMPLATE_new_nodes.h"
#include "gen_TEMPLATE_regalloc_if.h"



/***********************************************************************************
 *      _                                   _       _             __
 *     | |                                 (_)     | |           / _|
 *   __| |_   _ _ __ ___  _ __   ___ _ __   _ _ __ | |_ ___ _ __| |_ __ _  ___ ___
 *  / _` | | | | '_ ` _ \| '_ \ / _ \ '__| | | '_ \| __/ _ \ '__|  _/ _` |/ __/ _ \
 * | (_| | |_| | | | | | | |_) |  __/ |    | | | | | ||  __/ |  | || (_| | (_|  __/
 *  \__,_|\__,_|_| |_| |_| .__/ \___|_|    |_|_| |_|\__\___|_|  |_| \__,_|\___\___|
 *                       | |
 *                       |_|
 ***********************************************************************************/

/**
 * Dumper interface for dumping TEMPLATE nodes in vcg.
 * @param n        the node to dump
 * @param F        the output file
 * @param reason   indicates which kind of information should be dumped
 * @return 0 on success or != 0 on failure
 */
68
69
70
static int TEMPLATE_dump_node(ir_node *n, FILE *F, dump_reason_t reason)
{
  	ir_mode *mode = NULL;
71
72

	switch (reason) {
73
74
75
	case dump_node_opcode_txt:
		fprintf(F, "%s", get_irn_opname(n));
		break;
76

77
78
	case dump_node_mode_txt:
		mode = get_irn_mode(n);
Christian Würdig's avatar
Christian Würdig committed
79

80
81
82
83
84
85
86
87
		if (mode) {
			fprintf(F, "[%s]", get_mode_name(mode));
		} else {
			fprintf(F, "[?NOMODE?]");
		}
		break;

	case dump_node_nodeattr_txt:
88

89
90
		/* TODO: dump some attributes which should show up */
		/* in node name in dump (e.g. consts or the like)  */
91

92
93
94
95
96
97
98
99
100
		break;

	case dump_node_info_txt:
		arch_dump_reqs_and_registers(F, n);
		break;
	}

	return 0;
}
101
102
103
104
105
106
107
108
109
110
111
112

/***************************************************************************************************
 *        _   _                   _       __        _                    _   _               _
 *       | | | |                 | |     / /       | |                  | | | |             | |
 *   __ _| |_| |_ _ __   ___  ___| |_   / /_ _  ___| |_   _ __ ___   ___| |_| |__   ___   __| |___
 *  / _` | __| __| '__| / __|/ _ \ __| / / _` |/ _ \ __| | '_ ` _ \ / _ \ __| '_ \ / _ \ / _` / __|
 * | (_| | |_| |_| |    \__ \  __/ |_ / / (_| |  __/ |_  | | | | | |  __/ |_| | | | (_) | (_| \__ \
 *  \__,_|\__|\__|_|    |___/\___|\__/_/ \__, |\___|\__| |_| |_| |_|\___|\__|_| |_|\___/ \__,_|___/
 *                                        __/ |
 *                                       |___/
 ***************************************************************************************************/

113
114
const TEMPLATE_attr_t *get_TEMPLATE_attr_const(const ir_node *node)
{
115
	assert(is_TEMPLATE_irn(node) && "need TEMPLATE node to get attributes");
Matthias Braun's avatar
Matthias Braun committed
116
	return (const TEMPLATE_attr_t *)get_irn_generic_attr_const(node);
117
118
}

119
120
TEMPLATE_attr_t *get_TEMPLATE_attr(ir_node *node)
{
121
	assert(is_TEMPLATE_irn(node) && "need TEMPLATE node to get attributes");
122
	return (TEMPLATE_attr_t *)get_irn_generic_attr(node);
123
124
125
126
127
}

/**
 * Returns the argument register requirements of a TEMPLATE node.
 */
128
129
const arch_register_req_t **get_TEMPLATE_in_req_all(const ir_node *node)
{
130
	const TEMPLATE_attr_t *attr = get_TEMPLATE_attr_const(node);
131
132
133
134
135
136
	return attr->in_req;
}

/**
 * Returns the argument register requirement at position pos of an TEMPLATE node.
 */
137
138
const arch_register_req_t *get_TEMPLATE_in_req(const ir_node *node, int pos)
{
139
	const TEMPLATE_attr_t *attr = get_TEMPLATE_attr_const(node);
140
141
142
143
144
145
	return attr->in_req[pos];
}

/**
 * Sets the IN register requirements at position pos.
 */
146
147
void set_TEMPLATE_req_in(ir_node *node, const arch_register_req_t *req, int pos)
{
148
149
150
151
	TEMPLATE_attr_t *attr  = get_TEMPLATE_attr(node);
	attr->in_req[pos] = req;
}

Matthias Braun's avatar
Matthias Braun committed
152
153
154
155
156
157
/**
 * Initializes the nodes attributes.
 */
void init_TEMPLATE_attributes(ir_node *node, arch_irn_flags_t flags,
                              const arch_register_req_t **in_reqs,
                              const be_execution_unit_t ***execution_units,
158
                              int n_res)
Matthias Braun's avatar
Matthias Braun committed
159
{
160
161
	ir_graph        *irg  = get_irn_irg(node);
	struct obstack  *obst = get_irg_obstack(irg);
Matthias Braun's avatar
Matthias Braun committed
162
	TEMPLATE_attr_t *attr = get_TEMPLATE_attr(node);
163
	backend_info_t  *info;
Matthias Braun's avatar
Matthias Braun committed
164
	(void) execution_units;
Matthias Braun's avatar
Matthias Braun committed
165

166
	arch_irn_set_flags(node, flags);
167
	attr->in_req  = in_reqs;
168

169
170
171
	info            = be_get_info(node);
	info->out_infos = NEW_ARR_D(reg_out_info_t, obst, n_res);
	memset(info->out_infos, 0, n_res * sizeof(info->out_infos[0]));
Matthias Braun's avatar
Matthias Braun committed
172
}
173
174
175
176
177
178
179
180
181
182
183

/***************************************************************************************
 *                  _                            _                   _
 *                 | |                          | |                 | |
 *  _ __   ___   __| | ___    ___ ___  _ __  ___| |_ _ __ _   _  ___| |_ ___  _ __ ___
 * | '_ \ / _ \ / _` |/ _ \  / __/ _ \| '_ \/ __| __| '__| | | |/ __| __/ _ \| '__/ __|
 * | | | | (_) | (_| |  __/ | (_| (_) | | | \__ \ |_| |  | |_| | (__| || (_) | |  \__ \
 * |_| |_|\___/ \__,_|\___|  \___\___/|_| |_|___/\__|_|   \__,_|\___|\__\___/|_|  |___/
 *
 ***************************************************************************************/

184
static int TEMPLATE_compare_attr(ir_node *a, ir_node *b)
185
186
187
{
	const TEMPLATE_attr_t *attr_a = get_TEMPLATE_attr_const(a);
	const TEMPLATE_attr_t *attr_b = get_TEMPLATE_attr_const(b);
Matthias Braun's avatar
Matthias Braun committed
188
189
	(void) attr_a;
	(void) attr_b;
190
191
192
193
194

	return 0;
}


195
196
/* Include the generated constructor functions */
#include "gen_TEMPLATE_new_nodes.c.inl"