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 supported addrmode of an ia32 node
75 ia32_am_type_t get_ia32_am_support(const ir_node *node);
77 ia32_am_arity_t get_ia32_am_arity(const ir_node *node);
80 * Sets the supported addrmode of an ia32 node
82 void set_ia32_am_support(ir_node *node, ia32_am_type_t am_tp,
83 ia32_am_arity_t am_arity);
86 * Gets the addressmode offset as long.
88 int get_ia32_am_offs_int(const ir_node *node);
91 * Sets the addressmode offset
93 void set_ia32_am_offs_int(ir_node *node, int offset);
95 void add_ia32_am_offs_int(ir_node *node, int offset);
98 * Returns the symconst entity associated to addrmode.
100 ir_entity *get_ia32_am_sc(const ir_node *node);
103 * Sets the symconst entity associated to addrmode.
105 void set_ia32_am_sc(ir_node *node, ir_entity *sc);
108 * Sets the sign bit for address mode symconst.
110 void set_ia32_am_sc_sign(ir_node *node);
113 * Clears the sign bit for address mode symconst.
115 void clear_ia32_am_sc_sign(ir_node *node);
118 * Returns the sign bit for address mode symconst.
120 int is_ia32_am_sc_sign(const ir_node *node);
123 * Gets the addr mode const.
125 int get_ia32_am_scale(const ir_node *node);
128 * Sets the const for addr mode.
130 void set_ia32_am_scale(ir_node *node, int scale);
133 * Sets the uses_frame flag.
135 void set_ia32_use_frame(ir_node *node);
138 * Clears the uses_frame flag.
140 void clear_ia32_use_frame(ir_node *node);
143 * Gets the uses_frame flag.
145 int is_ia32_use_frame(const ir_node *node);
148 * Sets node to commutative.
150 void set_ia32_commutative(ir_node *node);
153 * Sets node to non-commutative.
155 void clear_ia32_commutative(ir_node *node);
158 * Checks if node is commutative.
160 int is_ia32_commutative(const ir_node *node);
165 void set_ia32_got_lea(ir_node *node);
168 * Clears node got_lea.
170 void clear_ia32_got_lea(ir_node *node);
173 * Checks if node got lea.
175 int is_ia32_got_lea(const ir_node *node);
178 * Sets node needs_stackent
180 void set_ia32_need_stackent(ir_node *node);
183 * Clears node needs_stackent
185 void clear_ia32_need_stackent(ir_node *node);
188 * Checks if node needs a stackentity assigned
190 int is_ia32_need_stackent(const ir_node *node);
193 * Gets the mode of the stored/loaded value (only set for Store/Load)
195 ir_mode *get_ia32_ls_mode(const ir_node *node);
198 * Sets the mode of the stored/loaded value (only set for Store/Load)
200 void set_ia32_ls_mode(ir_node *node, ir_mode *mode);
203 * Gets the frame entity assigned to this node;
205 ir_entity *get_ia32_frame_ent(const ir_node *node);
208 * Sets the frame entity for this node;
210 void set_ia32_frame_ent(ir_node *node, ir_entity *ent);
213 * Returns the argument register requirements of an ia32 node.
215 const arch_register_req_t **get_ia32_in_req_all(const ir_node *node);
218 * Sets the argument register requirements of an ia32 node.
220 void set_ia32_in_req_all(ir_node *node, const arch_register_req_t **reqs);
223 * Returns the result register requirements of an ia32 node.
225 const arch_register_req_t **get_ia32_out_req_all(const ir_node *node);
228 * Sets the result register requirements of an ia32 node.
230 void set_ia32_out_req_all(ir_node *node, const arch_register_req_t **reqs);
233 * Returns the argument register requirements of an ia32 node.
235 const arch_register_req_t *get_ia32_in_req(const ir_node *node, int pos);
238 * Returns the result register requirements of an ia32 node.
240 const arch_register_req_t *get_ia32_out_req(const ir_node *node, int pos);
243 * Sets the OUT register requirements at position pos.
245 void set_ia32_req_out(ir_node *node, const arch_register_req_t *req, int pos);
248 * Sets the IN register requirements at position pos.
250 void set_ia32_req_in(ir_node *node, const arch_register_req_t *req, int pos);
253 * Returns the register flag of an ia32 node.
255 arch_irn_flags_t get_ia32_flags(const ir_node *node);
258 * Sets the register flag of an ia32 node.
260 void set_ia32_flags(ir_node *node, arch_irn_flags_t flags);
263 * Returns the result register slots of an ia32 node.
265 const arch_register_t **get_ia32_slots(const ir_node *node);
268 * Returns the name of the OUT register at position pos.
270 const char *get_ia32_out_reg_name(const ir_node *node, int pos);
273 * Returns the index of the OUT register at position pos within its register class.
275 int get_ia32_out_regnr(const ir_node *node, int pos);
278 * Returns the OUT register at position pos.
280 const arch_register_t *get_ia32_out_reg(const ir_node *node, int pos);
283 * Returns the number of results.
285 int get_ia32_n_res(const ir_node *node);
288 * Returns the flavour of an ia32 node,
290 ia32_op_flavour_t get_ia32_flavour(const ir_node *node);
293 * Sets the flavour of an ia32 node to flavour_Div/Mod/DivMod/Mul/Mulh.
295 void set_ia32_flavour(ir_node *node, ia32_op_flavour_t op_flav);
298 * Returns the projnum code.
300 long get_ia32_pncode(const ir_node *node);
303 * Sets the projnum code
305 void set_ia32_pncode(ir_node *node, long code);
308 * Gets the instruction latency.
310 unsigned get_ia32_latency(const ir_node *node);
313 * Sets the instruction latency.
315 void set_ia32_latency(ir_node *node, unsigned latency);
319 * Sets the flags for the n'th out.
321 void set_ia32_out_flags(ir_node *node, arch_irn_flags_t flags, int pos);
324 * Gets the flags for the n'th out.
326 arch_irn_flags_t get_ia32_out_flags(const ir_node *node, int pos);
329 * Get the list of available execution units.
331 const be_execution_unit_t ***get_ia32_exec_units(const ir_node *node);
334 * Get the exception label attribute.
336 unsigned get_ia32_exc_label(const ir_node *node);
339 * Set the exception label attribute.
341 void set_ia32_exc_label(ir_node *node, unsigned flag);
346 * Returns the name of the original ir node.
348 const char *get_ia32_orig_node(const ir_node *node);
351 * Sets the name of the original ir node.
353 void set_ia32_orig_node(ir_node *node, const char *name);
357 /******************************************************************************************************
359 * (_) | | | | | | / _| | | (_)
360 * ___ _ __ ___ ___ _ __ _| | __ _| |_| |_ _ __ | |_ _ _ _ __ ___| |_ _ ___ _ __ ___
361 * / __| '_ \ / _ \/ __| |/ _` | | / _` | __| __| '__| | _| | | | '_ \ / __| __| |/ _ \| '_ \ / __|
362 * \__ \ |_) | __/ (__| | (_| | | | (_| | |_| |_| | | | | |_| | | | | (__| |_| | (_) | | | | \__ \
363 * |___/ .__/ \___|\___|_|\__,_|_| \__,_|\__|\__|_| |_| \__,_|_| |_|\___|\__|_|\___/|_| |_| |___/
366 ******************************************************************************************************/
369 * Returns the ident of an entity
370 * @param ent The entity
371 * @return The ident of the entity
373 ident *ia32_get_ent_ident(ir_entity *ent);
376 * Returns the proj of the result value for nodes that have the usual
377 * (res, Mem) result tuple
379 ir_node *get_ia32_result_proj(const ir_node *node);
382 * Copy the attributes from a Const to an ia32_Const
384 void set_ia32_Const_attr(ir_node *ia32_cnst, ir_node *cnst);
386 void set_ia32_Const_tarval(ir_node *node, tarval *tv);
389 * Sets the AddrMode attribute
390 * @param direction The "direction" of AM ('S' source or 'D' destination)
392 void set_ia32_AddrMode(ir_node *node, char direction);
395 * Returns whether or not the node is an AddrModeS node.
397 int is_ia32_AddrModeS(const ir_node *node);
400 * Returns whether or not the node is an AddrModeD node.
402 int is_ia32_AddrModeD(const ir_node *node);
405 * Checks if node is a Load or fLoad.
407 int is_ia32_Ld(const ir_node *node);
410 * Checks if node is a Store or fStore.
412 int is_ia32_St(const ir_node *node);
415 * Swaps left/right input of a node (and adjusts pnc if needed)
417 void ia32_swap_left_right(ir_node *node);
420 * Initializes the nodes attributes.
422 void init_ia32_attributes(ir_node *node, arch_irn_flags_t flags,
423 const arch_register_req_t **in_reqs,
424 const arch_register_req_t **out_reqs,
425 const be_execution_unit_t ***execution_units,
426 int n_res, unsigned latency);
428 void init_ia32_x87_attributes(ir_node *node);
429 void init_ia32_asm_attributes(ir_node *node);
430 void init_ia32_immediate_attributes(ir_node *node, ir_entity *symconst,
431 int symconst_sign, long offset);
433 /* Include the generated headers */
434 #include "gen_ia32_new_nodes.h"
436 #endif /* FIRM_BE_IA32_IA32_NEW_NODES_H */