ia32_new_nodes.h 6.26 KB
Newer Older
Christian Würdig's avatar
Christian Würdig committed
1
2
/*
 * This file is part of libFirm.
3
 * Copyright (C) 2012 University of Karlsruhe.
Christian Würdig's avatar
Christian Würdig committed
4
5
 */

6
/**
Christian Würdig's avatar
Christian Würdig committed
7
8
9
10
11
12
 * @file
 * @brief       Handling of ia32 specific firm opcodes.
 * @author      Christian Wuerdig
 *
 * This file implements the creation of the achitecture specific firm opcodes
 * and the coresponding node constructors for the ia32 assembler irg.
13
 */
Christian Würdig's avatar
Christian Würdig committed
14
15
#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
16

17
18
#include "ia32_nodes_attr.h"

19
20
21
22
23
24
25
/** 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,
26
	n_ia32_binary_right = 4,
27
28
};

29
30
31
32
/** proj numbers for "normal" one-result nodes (for the complicated cases where we not only
 * need the result) */
enum {
	pn_ia32_res   = 0,
33
	pn_ia32_flags = 1,
34
	pn_ia32_M     = 2,
35
36
};

Matthias Braun's avatar
Matthias Braun committed
37
extern struct obstack opcodes_obst;
38
39
40
41

/**
 * Returns the attributes of an ia32 node.
 */
42
ia32_attr_t *get_ia32_attr(ir_node *node);
43
44
const ia32_attr_t *get_ia32_attr_const(const ir_node *node);

45
46
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);
47

48
ia32_immediate_attr_t *get_ia32_immediate_attr(ir_node *node);
49
50
const ia32_immediate_attr_t *get_ia32_immediate_attr_const(const ir_node *node);

51
52
const ia32_asm_attr_t *get_ia32_asm_attr_const(const ir_node *node);

Michael Beck's avatar
Michael Beck committed
53
54
55
56
57
58
/**
 * 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);

59
60
61
62
63
64
/**
 * 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
65
66
67
68
69
70
/**
 * 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);

71
72
73
74
75
76
/**
 * 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);

77
78
79
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);

80
81
82
ia32_return_attr_t *get_ia32_return_attr(ir_node *node);
const ia32_return_attr_t *get_ia32_return_attr_const(const ir_node *node);

83
84
85
/**
 * Gets the type of an ia32 node.
 */
86
ia32_op_type_t get_ia32_op_type(const ir_node *node);
87

88
89
90
/**
 * Sets the type of an ia32 node.
 */
91
void set_ia32_op_type(ir_node *node, ia32_op_type_t tp);
92
93

/**
94
 * Gets the supported address mode of an ia32 node
95
 */
96
ia32_am_type_t get_ia32_am_support(const ir_node *node);
97

Christian Würdig's avatar
Christian Würdig committed
98
/**
Christian Würdig's avatar
Christian Würdig committed
99
 * Sets the supported addrmode of an ia32 node
Christian Würdig's avatar
Christian Würdig committed
100
 */
101
void set_ia32_am_support(ir_node *node, ia32_am_type_t am_arity);
Christian Würdig's avatar
Christian Würdig committed
102

103
104
105
/**
 * Gets the addressmode offset as long.
 */
106
int32_t get_ia32_am_offs_int(const ir_node *node);
107

108
109
110
/**
 * Sets the addressmode offset
 */
111
void set_ia32_am_offs_int(ir_node *node, int32_t offset);
112

113
void add_ia32_am_offs_int(ir_node *node, int32_t offset);
114

115
/**
116
 * Returns the entity associated to addrmode.
117
 */
118
ir_entity *get_ia32_am_ent(const ir_node *node);
119
120

/**
121
 * Sets the entity associated to addrmode.
122
 */
123
void set_ia32_am_ent(ir_node *node, ir_entity *sc);
124

125
126
127
128
void set_ia32_am_tls_segment(ir_node *node, bool value);

bool get_ia32_am_tls_segment(const ir_node *node);

129
130
131
/**
 * Gets the addr mode const.
 */
Michael Beck's avatar
Michael Beck committed
132
unsigned get_ia32_am_scale(const ir_node *node);
133
134
135
136

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

139
140
141
142
143
/**
 * copies all address-mode attributes from one node to the other
 */
void ia32_copy_am_attrs(ir_node *to, const ir_node *from);

144
145
146
147
148
149
150
151
152
153
154
155
156
157
/**
 * 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);
158

159
160
161
162
static inline void set_ia32_frame_use(ir_node *const node, ia32_frame_use_t const val)
{
	ia32_attr_t *const attr = get_ia32_attr(node);
	/* Only allow more specific, the same or reset. */
163
164
165
166
	assert(attr->frame_use == IA32_FRAME_USE_NONE
	    || attr->frame_use == IA32_FRAME_USE_AUTO
	    || (ia32_frame_use_t)attr->frame_use == val
	    || val == IA32_FRAME_USE_NONE);
167
168
169
170
171
172
173
174
	attr->frame_use = val;
}

static inline ia32_frame_use_t get_ia32_frame_use(ir_node const *const node)
{
	ia32_attr_t const *const attr = get_ia32_attr_const(node);
	return (ia32_frame_use_t)attr->frame_use;
}
Christian Würdig's avatar
Christian Würdig committed
175

176
177
178
void set_ia32_is_reload(ir_node *node);
int is_ia32_is_reload(const ir_node *node);

179
180
181
182
183
184
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);

185
186
187
188
189
190
191
192
193
194
/**
 * 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);

195
196
197
/**
 * Gets the frame entity assigned to this node;
 */
198
ir_entity *get_ia32_frame_ent(const ir_node *node);
199
200
201
202

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

205
/**
Michael Beck's avatar
Michael Beck committed
206
207
 * Returns the condition code of a node.
 */
208
x86_condition_code_t get_ia32_condcode(const ir_node *node);
Michael Beck's avatar
Michael Beck committed
209
210
211

/**
 * Sets the condition code of a node
212
 */
213
void set_ia32_condcode(ir_node *node, x86_condition_code_t code);
214

Matthias Braun's avatar
Matthias Braun committed
215
const ir_switch_table *get_ia32_switch_table(const ir_node *node);
216

Michael Beck's avatar
Michael Beck committed
217
unsigned get_ia32_copyb_size(const ir_node *node);
218

Christian Würdig's avatar
Christian Würdig committed
219
220
221
222
223
/**
 * Gets the instruction latency.
 */
unsigned get_ia32_latency(const ir_node *node);

224
225
226
227
228
229
230
231
232
233
/**
 * 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);

234
235
236
237
238
239
240
241
242
243
/**
 * 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
244
245
246
247
#ifndef NDEBUG
/**
 * Sets the name of the original ir node.
 */
248
void set_ia32_orig_node(ir_node *node, const ir_node *old);
249
#endif
250

251
/**
252
 * Swaps left/right input of a node (and sets ins_permuted accordingly)
253
254
255
 */
void ia32_swap_left_right(ir_node *node);

Christian Würdig's avatar
Christian Würdig committed
256
/* Include the generated headers */
Christian Würdig's avatar
Christian Würdig committed
257
#include "gen_ia32_new_nodes.h"
258

259
#endif