2 * Copyright (C) 1995-2011 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 doubleword lowering operations
23 * @author Michael Beck, Matthias Braun
25 #ifndef FIRM_LOWER_LOWER_DW_H
26 #define FIRM_LOWER_LOWER_DW_H
29 * Every double word node will be replaced,
30 * we need some store to hold the replacement:
32 typedef struct lower64_entry_t {
33 ir_node *low_word; /**< the low word */
34 ir_node *high_word; /**< the high word */
39 * A callback type for creating an intrinsic entity for a given opcode.
41 * @param method the method type of the emulation function entity
42 * @param op the emulated ir_op
43 * @param imode the input mode of the emulated opcode
44 * @param omode the output mode of the emulated opcode
45 * @param context the context parameter
47 typedef ir_entity *(create_intrinsic_fkt)(ir_type *method, const ir_op *op,
49 const ir_mode *omode, void *context);
52 * The lowering parameter description.
54 typedef struct lwrdw_param_t {
55 unsigned little_endian : 1; /**< if true should be lowered for little endian, else big endian */
56 unsigned doubleword_size; /**< bitsize of the doubleword mode */
57 create_intrinsic_fkt *create_intrinsic; /**< callback that creates the intrinsic entity */
58 void *ctx; /**< context parameter for the creator function */
62 * Prepare the doubleword lowering algorithm. Creates an environment
63 * which can be used to register custom lowering functions
65 void ir_prepare_dw_lowering(const lwrdw_param_t *param);
68 * Lower all doubleword operations in the program.
69 * Must be called after ir_prepare_dw_lowering()
71 void ir_lower_dw_ops(void);
73 typedef void (*lower_dw_func)(ir_node *node, ir_mode *mode);
76 * register a custom lowering function.
77 * After lowering the custom function should call ir_set_dw_lowered()
79 void ir_register_dw_lower_function(ir_op *op, lower_dw_func func);
82 * After lowering a node a custom doubleword lowering function has to call this.
83 * It registers 2 new values for the high and low part of the lowered value.
85 void ir_set_dw_lowered(ir_node *old, ir_node *new_low,
89 * Query lowering results of a node. In a lowering callback you can use this
90 * on all predecessors of a node. The only exception are block and phi nodes.
91 * Their predecessors are not necessarily transformed yet.
93 lower64_entry_t *get_node_entry(ir_node *node);
95 static inline ir_node *get_lowered_low(ir_node *node)
97 return get_node_entry(node)->low_word;
100 static inline ir_node *get_lowered_high(ir_node *node)
102 return get_node_entry(node)->high_word;
106 * Default implementation. Context is unused.
108 ir_entity *def_create_intrinsic_fkt(ir_type *method, const ir_op *op,
109 const ir_mode *imode, const ir_mode *omode,