2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
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.
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.
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
22 * @brief Handling of ia32 specific firm opcodes.
23 * @author Christian Wuerdig
26 * This file implements the creation of the achitecture specific firm opcodes
27 * and the coresponding node constructors for the ia32 assembler irg.
29 #ifndef FIRM_BE_IA32_IA32_NEW_NODES_H
30 #define FIRM_BE_IA32_IA32_NEW_NODES_H
32 #include "firm_config.h"
33 #include "ia32_nodes_attr.h"
35 /** indices for AM inputs */
41 n_ia32_binary_left = 3,
42 n_ia32_binary_right = 4
45 /** proj numbers for "normal" one-result nodes (for the complicated cases where we not only
55 /***************************************************************************************************
57 * | | | | | | / / | | | | | | | |
58 * __ _| |_| |_ _ __ ___ ___| |_ / /_ _ ___| |_ _ __ ___ ___| |_| |__ ___ __| |___
59 * / _` | __| __| '__| / __|/ _ \ __| / / _` |/ _ \ __| | '_ ` _ \ / _ \ __| '_ \ / _ \ / _` / __|
60 * | (_| | |_| |_| | \__ \ __/ |_ / / (_| | __/ |_ | | | | | | __/ |_| | | | (_) | (_| \__ \
61 * \__,_|\__|\__|_| |___/\___|\__/_/ \__, |\___|\__| |_| |_| |_|\___|\__|_| |_|\___/ \__,_|___/
64 ***************************************************************************************************/
67 * returns true if a node has x87 registers
69 int ia32_has_x87_register(const ir_node *n);
72 * Returns the attributes of an ia32 node.
74 ia32_attr_t *get_ia32_attr(ir_node *node);
75 const ia32_attr_t *get_ia32_attr_const(const ir_node *node);
77 ia32_x87_attr_t *get_ia32_x87_attr(ir_node *node);
78 const ia32_x87_attr_t *get_ia32_x87_attr_const(const ir_node *node);
80 ia32_immediate_attr_t *get_ia32_immediate_attr(ir_node *node);
81 const ia32_immediate_attr_t *get_ia32_immediate_attr_const(const ir_node *node);
84 * Gets the condcode attributes of a node.
86 ia32_condcode_attr_t *get_ia32_condcode_attr(ir_node *node);
87 const ia32_condcode_attr_t *get_ia32_condcode_attr_const(const ir_node *node);
90 * Gets the CopyB node attributes.
92 ia32_copyb_attr_t *get_ia32_copyb_attr(ir_node *node);
93 const ia32_copyb_attr_t *get_ia32_copyb_attr_const(const ir_node *node);
96 * Gets the type of an ia32 node.
98 ia32_op_type_t get_ia32_op_type(const ir_node *node);
101 * Sets the type of an ia32 node.
103 void set_ia32_op_type(ir_node *node, ia32_op_type_t tp);
106 * Gets the supported address mode of an ia32 node
108 ia32_am_type_t get_ia32_am_support(const ir_node *node);
111 * Sets the supported addrmode of an ia32 node
113 void set_ia32_am_support(ir_node *node, ia32_am_type_t am_arity);
116 * Gets the addressmode offset as long.
118 int get_ia32_am_offs_int(const ir_node *node);
121 * Sets the addressmode offset
123 void set_ia32_am_offs_int(ir_node *node, int offset);
125 void add_ia32_am_offs_int(ir_node *node, int offset);
128 * Returns the symconst entity associated to addrmode.
130 ir_entity *get_ia32_am_sc(const ir_node *node);
133 * Sets the symconst entity associated to addrmode.
135 void set_ia32_am_sc(ir_node *node, ir_entity *sc);
138 * Sets the sign bit for address mode symconst.
140 void set_ia32_am_sc_sign(ir_node *node);
143 * Clears the sign bit for address mode symconst.
145 void clear_ia32_am_sc_sign(ir_node *node);
148 * Returns the sign bit for address mode symconst.
150 int is_ia32_am_sc_sign(const ir_node *node);
153 * Gets the addr mode const.
155 int get_ia32_am_scale(const ir_node *node);
158 * Sets the const for addr mode.
160 void set_ia32_am_scale(ir_node *node, int scale);
163 * Sets the uses_frame flag.
165 void set_ia32_use_frame(ir_node *node);
168 * Clears the uses_frame flag.
170 void clear_ia32_use_frame(ir_node *node);
173 * Gets the uses_frame flag.
175 int is_ia32_use_frame(const ir_node *node);
178 * copies all address-mode attributes from one node to the other
180 void ia32_copy_am_attrs(ir_node *to, const ir_node *from);
183 * Sets node to commutative.
185 void set_ia32_commutative(ir_node *node);
188 * Sets node to non-commutative.
190 void clear_ia32_commutative(ir_node *node);
193 * Checks if node is commutative.
195 int is_ia32_commutative(const ir_node *node);
198 * Sets node needs_stackent
200 void set_ia32_need_stackent(ir_node *node);
203 * Clears node needs_stackent
205 void clear_ia32_need_stackent(ir_node *node);
208 * Checks if node needs a stack entity assigned
210 int is_ia32_need_stackent(const ir_node *node);
212 void set_ia32_is_reload(ir_node *node);
213 int is_ia32_is_reload(const ir_node *node);
215 void set_ia32_is_spill(ir_node *node);
216 int is_ia32_is_spill(const ir_node *node);
218 void set_ia32_is_remat(ir_node *node);
219 int is_ia32_is_remat(const ir_node *node);
222 * Gets the mode of the stored/loaded value (only set for Store/Load)
224 ir_mode *get_ia32_ls_mode(const ir_node *node);
227 * Sets the mode of the stored/loaded value (only set for Store/Load)
229 void set_ia32_ls_mode(ir_node *node, ir_mode *mode);
232 * Gets the frame entity assigned to this node;
234 ir_entity *get_ia32_frame_ent(const ir_node *node);
237 * Sets the frame entity for this node;
239 void set_ia32_frame_ent(ir_node *node, ir_entity *ent);
242 * Returns the argument register requirements of an ia32 node.
244 const arch_register_req_t **get_ia32_in_req_all(const ir_node *node);
247 * Sets the argument register requirements of an ia32 node.
249 void set_ia32_in_req_all(ir_node *node, const arch_register_req_t **reqs);
252 * Returns the result register requirements of an ia32 node.
254 const arch_register_req_t **get_ia32_out_req_all(const ir_node *node);
257 * Sets the result register requirements of an ia32 node.
259 void set_ia32_out_req_all(ir_node *node, const arch_register_req_t **reqs);
262 * Returns the argument register requirements of an ia32 node.
264 const arch_register_req_t *get_ia32_in_req(const ir_node *node, int pos);
267 * Returns the result register requirements of an ia32 node.
269 const arch_register_req_t *get_ia32_out_req(const ir_node *node, int pos);
272 * Sets the OUT register requirements at position pos.
274 void set_ia32_req_out(ir_node *node, const arch_register_req_t *req, int pos);
277 * Sets the IN register requirements at position pos.
279 void set_ia32_req_in(ir_node *node, const arch_register_req_t *req, int pos);
282 * Returns the register flag of an ia32 node.
284 arch_irn_flags_t get_ia32_flags(const ir_node *node);
287 * Sets the register flag of an ia32 node.
289 void set_ia32_flags(ir_node *node, arch_irn_flags_t flags);
291 void add_ia32_flags(ir_node *node, arch_irn_flags_t flags);
294 * Returns the result register slots of an ia32 node.
296 const arch_register_t **get_ia32_slots(const ir_node *node);
299 * Returns the name of the OUT register at position pos.
301 const char *get_ia32_out_reg_name(const ir_node *node, int pos);
304 * Returns the index of the OUT register at position pos within its register class.
306 int get_ia32_out_regnr(const ir_node *node, int pos);
309 * Returns the OUT register at position pos.
311 const arch_register_t *get_ia32_out_reg(const ir_node *node, int pos);
314 * Returns the number of results.
316 int get_ia32_n_res(const ir_node *node);
319 * Returns the condition code of a node.
321 long get_ia32_condcode(const ir_node *node);
324 * Sets the condition code of a node
326 void set_ia32_condcode(ir_node *node, long code);
329 * Returns the condition code of a node.
331 unsigned get_ia32_copyb_size(const ir_node *node);
334 * Gets the instruction latency.
336 unsigned get_ia32_latency(const ir_node *node);
340 * Sets the flags for the n'th out.
342 void set_ia32_out_flags(ir_node *node, arch_irn_flags_t flags, int pos);
345 * Gets the flags for the n'th out.
347 arch_irn_flags_t get_ia32_out_flags(const ir_node *node, int pos);
350 * Get the list of available execution units.
352 const be_execution_unit_t ***get_ia32_exec_units(const ir_node *node);
355 * Get the exception label attribute.
357 unsigned get_ia32_exc_label(const ir_node *node);
360 * Set the exception label attribute.
362 void set_ia32_exc_label(ir_node *node, unsigned flag);
365 * Return the exception label id.
367 ir_label_t get_ia32_exc_label_id(const ir_node *node);
370 * Assign the exception label id.
372 void set_ia32_exc_label_id(ir_node *node, ir_label_t id);
377 * Returns the name of the original ir node.
379 const char *get_ia32_orig_node(const ir_node *node);
382 * Sets the name of the original ir node.
384 void set_ia32_orig_node(ir_node *node, const char *name);
388 /******************************************************************************************************
390 * (_) | | | | | | / _| | | (_)
391 * ___ _ __ ___ ___ _ __ _| | __ _| |_| |_ _ __ | |_ _ _ _ __ ___| |_ _ ___ _ __ ___
392 * / __| '_ \ / _ \/ __| |/ _` | | / _` | __| __| '__| | _| | | | '_ \ / __| __| |/ _ \| '_ \ / __|
393 * \__ \ |_) | __/ (__| | (_| | | | (_| | |_| |_| | | | | |_| | | | | (__| |_| | (_) | | | | \__ \
394 * |___/ .__/ \___|\___|_|\__,_|_| \__,_|\__|\__|_| |_| \__,_|_| |_|\___|\__|_|\___/|_| |_| |___/
397 ******************************************************************************************************/
400 * Returns the ident of an entity
401 * @param ent The entity
402 * @return The ident of the entity
404 ident *ia32_get_ent_ident(ir_entity *ent);
407 * Returns the proj of the result value for nodes that have the usual
408 * (res, Mem) result tuple
410 ir_node *get_ia32_result_proj(const ir_node *node);
413 * Copy the attributes from a Const to an ia32_Const
415 void set_ia32_Const_attr(ir_node *ia32_cnst, ir_node *cnst);
417 void set_ia32_Const_tarval(ir_node *node, tarval *tv);
420 * Returns whether or not the node is an AddrModeS node.
422 int is_ia32_AddrModeS(const ir_node *node);
425 * Returns whether or not the node is an AddrModeD node.
427 int is_ia32_AddrModeD(const ir_node *node);
430 * Checks if node is a Load or fLoad.
432 int is_ia32_Ld(const ir_node *node);
435 * Checks if node is a Store or fStore.
437 int is_ia32_St(const ir_node *node);
440 * Swaps left/right input of a node (and adjusts pnc if needed)
442 void ia32_swap_left_right(ir_node *node);
445 * Initializes the nodes attributes.
447 void init_ia32_attributes(ir_node *node, arch_irn_flags_t flags,
448 const arch_register_req_t **in_reqs,
449 const arch_register_req_t **out_reqs,
450 const be_execution_unit_t ***execution_units,
453 void init_ia32_x87_attributes(ir_node *node);
454 void init_ia32_asm_attributes(ir_node *node);
455 void init_ia32_immediate_attributes(ir_node *node, ir_entity *symconst,
456 int symconst_sign, long offset);
457 void init_ia32_copyb_attributes(ir_node *res, unsigned size);
458 void init_ia32_condcode_attributes(ir_node *res, long pnc);
460 /* Include the generated headers */
461 #include "gen_ia32_new_nodes.h"
463 #endif /* FIRM_BE_IA32_IA32_NEW_NODES_H */