2 * Copyright (C) 1995-2007 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 /***************************************************************************************************
37 * | | | | | | / / | | | | | | | |
38 * __ _| |_| |_ _ __ ___ ___| |_ / /_ _ ___| |_ _ __ ___ ___| |_| |__ ___ __| |___
39 * / _` | __| __| '__| / __|/ _ \ __| / / _` |/ _ \ __| | '_ ` _ \ / _ \ __| '_ \ / _ \ / _` / __|
40 * | (_| | |_| |_| | \__ \ __/ |_ / / (_| | __/ |_ | | | | | | __/ |_| | | | (_) | (_| \__ \
41 * \__,_|\__|\__|_| |___/\___|\__/_/ \__, |\___|\__| |_| |_| |_|\___|\__|_| |_|\___/ \__,_|___/
44 ***************************************************************************************************/
47 * returns true if a node has x87 registers
49 int ia32_has_x87_register(const ir_node *n);
52 * Returns the attributes of an ia32 node.
54 ia32_attr_t *get_ia32_attr(ir_node *node);
55 const ia32_attr_t *get_ia32_attr_const(const ir_node *node);
57 ia32_x87_attr_t *get_ia32_x87_attr(ir_node *node);
58 const ia32_x87_attr_t *get_ia32_x87_attr_const(const ir_node *node);
60 const ia32_immediate_attr_t *get_ia32_immediate_attr_const(const ir_node *node);
63 * Gets the type of an ia32 node.
65 ia32_op_type_t get_ia32_op_type(const ir_node *node);
68 * Sets the type of an ia32 node.
70 void set_ia32_op_type(ir_node *node, ia32_op_type_t tp);
73 * Gets the immediate op type of an ia32 node.
75 ia32_immop_type_t get_ia32_immop_type(const ir_node *node);
78 * Sets the immediate op type of an ia32 node.
80 void set_ia32_immop_type(ir_node *node, ia32_immop_type_t tp);
83 * Gets the supported addrmode of an ia32 node
85 ia32_am_type_t get_ia32_am_support(const ir_node *node);
88 * Sets the supported addrmode of an ia32 node
90 void set_ia32_am_support(ir_node *node, ia32_am_type_t am_tp);
93 * Gets the addrmode flavour of an ia32 node
95 ia32_am_flavour_t get_ia32_am_flavour(const ir_node *node);
98 * Sets the addrmode flavour of an ia32 node
100 void set_ia32_am_flavour(ir_node *node, ia32_am_flavour_t am_flavour);
103 * Gets the addressmode offset as long.
105 int get_ia32_am_offs_int(const ir_node *node);
108 * Sets the addressmode offset
110 void set_ia32_am_offs_int(ir_node *node, int offset);
112 void add_ia32_am_offs_int(ir_node *node, int offset);
115 * Returns the symconst entity associated to addrmode.
117 ir_entity *get_ia32_am_sc(const ir_node *node);
120 * Sets the symconst entity associated to addrmode.
122 void set_ia32_am_sc(ir_node *node, ir_entity *sc);
125 * Sets the sign bit for address mode symconst.
127 void set_ia32_am_sc_sign(ir_node *node);
130 * Clears the sign bit for address mode symconst.
132 void clear_ia32_am_sc_sign(ir_node *node);
135 * Returns the sign bit for address mode symconst.
137 int is_ia32_am_sc_sign(const ir_node *node);
140 * Gets the addr mode const.
142 int get_ia32_am_scale(const ir_node *node);
145 * Sets the const for addr mode.
147 void set_ia32_am_scale(ir_node *node, int scale);
150 * Return the tarval of an immediate operation or NULL if none set
152 tarval *get_ia32_Immop_tarval(const ir_node *node);
155 * Return the symconst entity of an immediate operation or NULL if none set
157 ir_entity* get_ia32_Immop_symconst(const ir_node *node);
160 * Sets the attributes of an immediate operation to the specified tarval
162 void set_ia32_Immop_tarval(ir_node *node, tarval *tv);
165 * Sets the attributes of an immediate operation to the specified SymConst
167 void set_ia32_Immop_symconst(ir_node *node, ir_entity *entity);
170 * Sets the uses_frame flag.
172 void set_ia32_use_frame(ir_node *node);
175 * Clears the uses_frame flag.
177 void clear_ia32_use_frame(ir_node *node);
180 * Gets the uses_frame flag.
182 int is_ia32_use_frame(const ir_node *node);
185 * Sets node to commutative.
187 void set_ia32_commutative(ir_node *node);
190 * Sets node to non-commutative.
192 void clear_ia32_commutative(ir_node *node);
195 * Checks if node is commutative.
197 int is_ia32_commutative(const ir_node *node);
202 void set_ia32_emit_cl(ir_node *node);
205 * Clears node emit_cl.
207 void clear_ia32_emit_cl(ir_node *node);
210 * Checks if node is commutative.
212 int is_ia32_emit_cl(const ir_node *node);
217 void set_ia32_got_lea(ir_node *node);
220 * Clears node got_lea.
222 void clear_ia32_got_lea(ir_node *node);
225 * Checks if node got lea.
227 int is_ia32_got_lea(const ir_node *node);
230 * Sets node needs_stackent
232 void set_ia32_need_stackent(ir_node *node);
235 * Clears node needs_stackent
237 void clear_ia32_need_stackent(ir_node *node);
240 * Checks if node needs a stackentity assigned
242 int is_ia32_need_stackent(const ir_node *node);
245 * Gets the mode of the stored/loaded value (only set for Store/Load)
247 ir_mode *get_ia32_ls_mode(const ir_node *node);
250 * Sets the mode of the stored/loaded value (only set for Store/Load)
252 void set_ia32_ls_mode(ir_node *node, ir_mode *mode);
255 * Gets the frame entity assigned to this node;
257 ir_entity *get_ia32_frame_ent(const ir_node *node);
260 * Sets the frame entity for this node;
262 void set_ia32_frame_ent(ir_node *node, ir_entity *ent);
265 * Returns the argument register requirements of an ia32 node.
267 const arch_register_req_t **get_ia32_in_req_all(const ir_node *node);
270 * Sets the argument register requirements of an ia32 node.
272 void set_ia32_in_req_all(ir_node *node, const arch_register_req_t **reqs);
275 * Returns the result register requirements of an ia32 node.
277 const arch_register_req_t **get_ia32_out_req_all(const ir_node *node);
280 * Sets the result register requirements of an ia32 node.
282 void set_ia32_out_req_all(ir_node *node, const arch_register_req_t **reqs);
285 * Returns the argument register requirements of an ia32 node.
287 const arch_register_req_t *get_ia32_in_req(const ir_node *node, int pos);
290 * Returns the result register requirements of an ia32 node.
292 const arch_register_req_t *get_ia32_out_req(const ir_node *node, int pos);
295 * Sets the OUT register requirements at position pos.
297 void set_ia32_req_out(ir_node *node, const arch_register_req_t *req, int pos);
300 * Sets the IN register requirements at position pos.
302 void set_ia32_req_in(ir_node *node, const arch_register_req_t *req, int pos);
305 * Returns the register flag of an ia32 node.
307 arch_irn_flags_t get_ia32_flags(const ir_node *node);
310 * Sets the register flag of an ia32 node.
312 void set_ia32_flags(ir_node *node, arch_irn_flags_t flags);
315 * Returns the result register slots of an ia32 node.
317 const arch_register_t **get_ia32_slots(const ir_node *node);
320 * Returns the name of the OUT register at position pos.
322 const char *get_ia32_out_reg_name(const ir_node *node, int pos);
325 * Returns the index of the OUT register at position pos within its register class.
327 int get_ia32_out_regnr(const ir_node *node, int pos);
330 * Returns the OUT register at position pos.
332 const arch_register_t *get_ia32_out_reg(const ir_node *node, int pos);
335 * Returns the number of results.
337 int get_ia32_n_res(const ir_node *node);
340 * Returns the flavour of an ia32 node,
342 ia32_op_flavour_t get_ia32_flavour(const ir_node *node);
345 * Sets the flavour of an ia32 node to flavour_Div/Mod/DivMod/Mul/Mulh.
347 void set_ia32_flavour(ir_node *node, ia32_op_flavour_t op_flav);
350 * Returns the projnum code.
352 pn_Cmp get_ia32_pncode(const ir_node *node);
355 * Sets the projnum code
357 void set_ia32_pncode(ir_node *node, pn_Cmp code);
360 * Gets the instruction latency.
362 unsigned get_ia32_latency(const ir_node *node);
365 * Sets the instruction latency.
367 void set_ia32_latency(ir_node *node, unsigned latency);
371 * Sets the flags for the n'th out.
373 void set_ia32_out_flags(ir_node *node, arch_irn_flags_t flags, int pos);
376 * Gets the flags for the n'th out.
378 arch_irn_flags_t get_ia32_out_flags(const ir_node *node, int pos);
381 * Get the list of available execution units.
383 const be_execution_unit_t ***get_ia32_exec_units(const ir_node *node);
386 * Get the exception label attribute.
388 unsigned get_ia32_exc_label(const ir_node *node);
391 * Set the exception label attribute.
393 void set_ia32_exc_label(ir_node *node, unsigned flag);
398 * Returns the name of the original ir node.
400 const char *get_ia32_orig_node(const ir_node *node);
403 * Sets the name of the original ir node.
405 void set_ia32_orig_node(ir_node *node, const char *name);
409 /******************************************************************************************************
411 * (_) | | | | | | / _| | | (_)
412 * ___ _ __ ___ ___ _ __ _| | __ _| |_| |_ _ __ | |_ _ _ _ __ ___| |_ _ ___ _ __ ___
413 * / __| '_ \ / _ \/ __| |/ _` | | / _` | __| __| '__| | _| | | | '_ \ / __| __| |/ _ \| '_ \ / __|
414 * \__ \ |_) | __/ (__| | (_| | | | (_| | |_| |_| | | | | |_| | | | | (__| |_| | (_) | | | | \__ \
415 * |___/ .__/ \___|\___|_|\__,_|_| \__,_|\__|\__|_| |_| \__,_|_| |_|\___|\__|_|\___/|_| |_| |___/
418 ******************************************************************************************************/
421 * Returns the ident of an entity
422 * @param ent The entity
423 * @return The ident of the entity
425 ident *ia32_get_ent_ident(ir_entity *ent);
428 * Copy the attributes from Immop to an Immop
430 void copy_ia32_Immop_attr(ir_node *node, ir_node *src);
433 * Returns the proj of the result value for nodes that have the usual
434 * (res, Mem) result tuple
436 ir_node *get_ia32_result_proj(const ir_node *node);
439 * Copy the attributes from a Const to an ia32_Const
441 void set_ia32_Const_attr(ir_node *ia32_cnst, ir_node *cnst);
443 void set_ia32_Const_tarval(ir_node *node, tarval *tv);
446 * Sets the AddrMode attribute
447 * @param direction The "direction" of AM ('S' source or 'D' destination)
449 void set_ia32_AddrMode(ir_node *node, char direction);
452 * Returns whether or not the node is an immediate operation with Const.
454 int is_ia32_ImmConst(const ir_node *node);
457 * Returns whether or not the node is an immediate operation with SymConst.
459 int is_ia32_ImmSymConst(const ir_node *node);
462 * Returns whether or not the node is an AddrModeS node.
464 int is_ia32_AddrModeS(const ir_node *node);
467 * Returns whether or not the node is an AddrModeD node.
469 int is_ia32_AddrModeD(const ir_node *node);
472 * Checks if node is a Load or fLoad.
474 int is_ia32_Ld(const ir_node *node);
477 * Checks if node is a Store or fStore.
479 int is_ia32_St(const ir_node *node);
482 * Checks if node is a Const or fConst.
484 int is_ia32_Cnst(const ir_node *node);
487 * Initializes the nodes attributes.
489 void init_ia32_attributes(ir_node *node, arch_irn_flags_t flags,
490 const arch_register_req_t **in_reqs,
491 const arch_register_req_t **out_reqs,
492 const be_execution_unit_t ***execution_units,
493 int n_res, unsigned latency);
495 void init_ia32_x87_attributes(ir_node *node);
496 void init_ia32_asm_attributes(ir_node *node);
497 void init_ia32_immediate_attributes(ir_node *node, ir_entity *symconst,
498 int symconst_sign, tarval *offset);
501 * Registers the ia32_copy_attr function for all ia32 opcodes.
503 void ia32_register_copy_attr_func(void);
505 /* Include the generated headers */
506 #include "gen_ia32_new_nodes.h"
508 #endif /* FIRM_BE_IA32_IA32_NEW_NODES_H */