ia32_new_nodes.h 7.8 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
/**
Christian Würdig's avatar
Christian Würdig committed
21
22
23
24
25
26
27
 * @file
 * @brief       Handling of ia32 specific firm opcodes.
 * @author      Christian Wuerdig
 * @version     $Id$
 *
 * This file implements the creation of the achitecture specific firm opcodes
 * and the coresponding node constructors for the ia32 assembler irg.
28
 */
Christian Würdig's avatar
Christian Würdig committed
29
30
#ifndef FIRM_BE_IA32_IA32_NEW_NODES_H
#define FIRM_BE_IA32_IA32_NEW_NODES_H
Christian Würdig's avatar
Christian Würdig committed
31

32
33
#include "ia32_nodes_attr.h"

34
35
36
37
38
39
40
41
42
43
/** indices for AM inputs */
enum {
	n_ia32_base         = 0,
	n_ia32_index        = 1,
	n_ia32_mem          = 2,
	n_ia32_unary_op     = 3,
	n_ia32_binary_left  = 3,
	n_ia32_binary_right = 4
};

44
45
46
47
/** proj numbers for "normal" one-result nodes (for the complicated cases where we not only
 * need the result) */
enum {
	pn_ia32_res   = 0,
48
	pn_ia32_flags = 1,
Christoph Mallon's avatar
Christoph Mallon committed
49
	pn_ia32_mem   = 2
50
51
};

52

53
54
55
56
57
/**
 * returns true if a node has x87 registers
 */
int ia32_has_x87_register(const ir_node *n);

58
59
60
/**
 * Returns the attributes of an ia32 node.
 */
61
ia32_attr_t *get_ia32_attr(ir_node *node);
62
63
const ia32_attr_t *get_ia32_attr_const(const ir_node *node);

64
65
ia32_x87_attr_t *get_ia32_x87_attr(ir_node *node);
const ia32_x87_attr_t *get_ia32_x87_attr_const(const ir_node *node);
66

67
ia32_immediate_attr_t *get_ia32_immediate_attr(ir_node *node);
68
69
const ia32_immediate_attr_t *get_ia32_immediate_attr_const(const ir_node *node);

70
71
const ia32_asm_attr_t *get_ia32_asm_attr_const(const ir_node *node);

Michael Beck's avatar
Michael Beck committed
72
73
74
75
76
77
/**
 * Gets the condcode attributes of a node.
 */
ia32_condcode_attr_t *get_ia32_condcode_attr(ir_node *node);
const ia32_condcode_attr_t *get_ia32_condcode_attr_const(const ir_node *node);

78
79
80
81
82
83
/**
 * Gets the Call node attributes.
 */
ia32_call_attr_t *get_ia32_call_attr(ir_node *node);
const ia32_call_attr_t *get_ia32_call_attr_const(const ir_node *node);

Michael Beck's avatar
Michael Beck committed
84
85
86
87
88
89
/**
 * Gets the CopyB node attributes.
 */
ia32_copyb_attr_t *get_ia32_copyb_attr(ir_node *node);
const ia32_copyb_attr_t *get_ia32_copyb_attr_const(const ir_node *node);

90
91
92
93
94
95
/**
 * Gets the ClimbFrame node attributes.
 */
ia32_climbframe_attr_t *get_ia32_climbframe_attr(ir_node *node);
const ia32_climbframe_attr_t *get_ia32_climbframe_attr_const(const ir_node *node);

96
97
98
ia32_switch_attr_t *get_ia32_switch_attr(ir_node *node);
const ia32_switch_attr_t *get_ia32_switch_attr_const(const ir_node *node);

99
100
101
/**
 * Gets the type of an ia32 node.
 */
102
ia32_op_type_t get_ia32_op_type(const ir_node *node);
103

104
105
106
/**
 * Sets the type of an ia32 node.
 */
107
void set_ia32_op_type(ir_node *node, ia32_op_type_t tp);
108
109

/**
110
 * Gets the supported address mode of an ia32 node
111
 */
112
ia32_am_type_t get_ia32_am_support(const ir_node *node);
113

Christian Würdig's avatar
Christian Würdig committed
114
/**
Christian Würdig's avatar
Christian Würdig committed
115
 * Sets the supported addrmode of an ia32 node
Christian Würdig's avatar
Christian Würdig committed
116
 */
117
void set_ia32_am_support(ir_node *node, ia32_am_type_t am_arity);
Christian Würdig's avatar
Christian Würdig committed
118

119
120
121
/**
 * Gets the addressmode offset as long.
 */
122
int get_ia32_am_offs_int(const ir_node *node);
123

124
125
126
127
128
/**
 * Sets the addressmode offset
 */
void set_ia32_am_offs_int(ir_node *node, int offset);

129
130
void add_ia32_am_offs_int(ir_node *node, int offset);

131
/**
132
 * Returns the symconst entity associated to addrmode.
133
 */
134
ir_entity *get_ia32_am_sc(const ir_node *node);
135
136

/**
137
 * Sets the symconst entity associated to addrmode.
138
 */
139
void set_ia32_am_sc(ir_node *node, ir_entity *sc);
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155

/**
 * Sets the sign bit for address mode symconst.
 */
void set_ia32_am_sc_sign(ir_node *node);

/**
 * Clears the sign bit for address mode symconst.
 */
void clear_ia32_am_sc_sign(ir_node *node);

/**
 * Returns the sign bit for address mode symconst.
 */
int is_ia32_am_sc_sign(const ir_node *node);

156
157
158
159
void set_ia32_am_tls_segment(ir_node *node, bool value);

bool get_ia32_am_tls_segment(const ir_node *node);

160
161
162
/**
 * Gets the addr mode const.
 */
Michael Beck's avatar
Michael Beck committed
163
unsigned get_ia32_am_scale(const ir_node *node);
164
165
166
167

/**
 * Sets the const for addr mode.
 */
Michael Beck's avatar
Michael Beck committed
168
void set_ia32_am_scale(ir_node *node, unsigned scale);
169

170
/**
171
 * Sets the uses_frame flag.
172
 */
173
void set_ia32_use_frame(ir_node *node);
174
175

/**
176
 * Clears the uses_frame flag.
177
 */
178
179
180
181
182
183
184
void clear_ia32_use_frame(ir_node *node);

/**
 * Gets the uses_frame flag.
 */
int is_ia32_use_frame(const ir_node *node);

185
186
187
188
189
/**
 * copies all address-mode attributes from one node to the other
 */
void ia32_copy_am_attrs(ir_node *to, const ir_node *from);

190
191
192
193
194
195
196
197
198
199
200
201
202
203
/**
 * Sets node to commutative.
 */
void set_ia32_commutative(ir_node *node);

/**
 * Sets node to non-commutative.
 */
void clear_ia32_commutative(ir_node *node);

/**
 * Checks if node is commutative.
 */
int is_ia32_commutative(const ir_node *node);
204

Christian Würdig's avatar
Christian Würdig committed
205
/**
206
 * Sets node needs_stackent
Christian Würdig's avatar
Christian Würdig committed
207
 */
208
void set_ia32_need_stackent(ir_node *node);
Christian Würdig's avatar
Christian Würdig committed
209
210

/**
211
 * Clears node needs_stackent
Christian Würdig's avatar
Christian Würdig committed
212
 */
213
void clear_ia32_need_stackent(ir_node *node);
Christian Würdig's avatar
Christian Würdig committed
214
215

/**
216
 * Checks if node needs a stack entity assigned
Christian Würdig's avatar
Christian Würdig committed
217
 */
218
int is_ia32_need_stackent(const ir_node *node);
Christian Würdig's avatar
Christian Würdig committed
219

220
221
222
void set_ia32_is_reload(ir_node *node);
int is_ia32_is_reload(const ir_node *node);

223
224
225
226
227
228
void set_ia32_is_spill(ir_node *node);
int is_ia32_is_spill(const ir_node *node);

void set_ia32_is_remat(ir_node *node);
int is_ia32_is_remat(const ir_node *node);

229
230
231
232
233
234
235
236
237
238
/**
 * Gets the mode of the stored/loaded value (only set for Store/Load)
 */
ir_mode *get_ia32_ls_mode(const ir_node *node);

/**
 * Sets the mode of the stored/loaded value (only set for Store/Load)
 */
void set_ia32_ls_mode(ir_node *node, ir_mode *mode);

239
240
241
/**
 * Gets the frame entity assigned to this node;
 */
242
ir_entity *get_ia32_frame_ent(const ir_node *node);
243
244
245
246

/**
 * Sets the frame entity for this node;
 */
247
void set_ia32_frame_ent(ir_node *node, ir_entity *ent);
248

249
/**
Michael Beck's avatar
Michael Beck committed
250
251
 * Returns the condition code of a node.
 */
252
ia32_condition_code_t get_ia32_condcode(const ir_node *node);
Michael Beck's avatar
Michael Beck committed
253
254
255

/**
 * Sets the condition code of a node
256
 */
257
258
259
void set_ia32_condcode(ir_node *node, ia32_condition_code_t code);

long get_ia32_default_pn(const ir_node *node);
260

Michael Beck's avatar
Michael Beck committed
261
unsigned get_ia32_copyb_size(const ir_node *node);
262

Christian Würdig's avatar
Christian Würdig committed
263
264
265
266
267
/**
 * Gets the instruction latency.
 */
unsigned get_ia32_latency(const ir_node *node);

268

269
/**
270
 * Get the list of available execution units.
271
 */
272
const be_execution_unit_t ***get_ia32_exec_units(const ir_node *node);
273

274
275
276
277
278
279
280
281
282
283
/**
 * Get the exception label attribute.
 */
unsigned get_ia32_exc_label(const ir_node *node);

/**
 * Set the exception label attribute.
 */
void set_ia32_exc_label(ir_node *node, unsigned flag);

284
285
286
287
288
289
290
291
292
293
/**
 * Return the exception label id.
 */
ir_label_t get_ia32_exc_label_id(const ir_node *node);

/**
 * Assign the exception label id.
 */
void set_ia32_exc_label_id(ir_node *node, ir_label_t id);

Christian Würdig's avatar
Christian Würdig committed
294
295
296
297
298
299
300
301
302
303
#ifndef NDEBUG

/**
 * Returns the name of the original ir node.
 */
const char *get_ia32_orig_node(const ir_node *node);

/**
 * Sets the name of the original ir node.
 */
304
void set_ia32_orig_node(ir_node *node, const ir_node *old);
Christian Würdig's avatar
Christian Würdig committed
305
306

#endif /* NDEBUG */
307
308


309
310
311
312
313
314
315
/**
 * Returns the ident of an entity
 * @param ent The entity
 * @return The ident of the entity
 */
ident *ia32_get_ent_ident(ir_entity *ent);

316
317
318
319
320
/**
 * Copy the attributes from a Const to an ia32_Const
 */
void set_ia32_Const_attr(ir_node *ia32_cnst, ir_node *cnst);

Matthias Braun's avatar
Matthias Braun committed
321
void set_ia32_Const_tarval(ir_node *node, ir_tarval *tv);
322

323
/**
324
 * Returns whether or not the node is an AddrModeS node.
325
 */
Christian Würdig's avatar
Christian Würdig committed
326
int is_ia32_AddrModeS(const ir_node *node);
327
328

/**
329
 * Returns whether or not the node is an AddrModeD node.
330
 */
Christian Würdig's avatar
Christian Würdig committed
331
int is_ia32_AddrModeD(const ir_node *node);
332

333
/**
334
 * Swaps left/right input of a node (and sets ins_permuted accordingly)
335
336
337
 */
void ia32_swap_left_right(ir_node *node);

Christian Würdig's avatar
Christian Würdig committed
338
/* Include the generated headers */
Christian Würdig's avatar
Christian Würdig committed
339
#include "gen_ia32_new_nodes.h"
340

341
#endif