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
28 #include "firm_types.h"
31 * Every double word node will be replaced,
32 * we need some store to hold the replacement:
34 typedef struct lower64_entry_t {
35 ir_node *low_word; /**< the low word */
36 ir_node *high_word; /**< the high word */
41 * A callback type for creating an intrinsic entity for a given opcode.
43 * @param method the method type of the emulation function entity
44 * @param op the emulated ir_op
45 * @param imode the input mode of the emulated opcode
46 * @param omode the output mode of the emulated opcode
47 * @param context the context parameter
49 typedef ir_entity *(create_intrinsic_fkt)(ir_type *method, const ir_op *op,
51 const ir_mode *omode, void *context);
54 * The lowering parameter description.
56 typedef struct lwrdw_param_t {
57 unsigned little_endian : 1; /**< if true should be lowered for little endian, else big endian */
58 unsigned doubleword_size; /**< bitsize of the doubleword mode */
59 create_intrinsic_fkt *create_intrinsic; /**< callback that creates the intrinsic entity */
60 void *ctx; /**< context parameter for the creator function */
64 * Prepare the doubleword lowering algorithm. Creates an environment
65 * which can be used to register custom lowering functions
67 void ir_prepare_dw_lowering(const lwrdw_param_t *param);
70 * Lower all doubleword operations in the program.
71 * Must be called after ir_prepare_dw_lowering()
73 void ir_lower_dw_ops(void);
75 typedef void (*lower_dw_func)(ir_node *node, ir_mode *mode);
78 * register a custom lowering function.
79 * After lowering the custom function should call ir_set_dw_lowered()
81 void ir_register_dw_lower_function(ir_op *op, lower_dw_func func);
84 * After lowering a node a custom doubleword lowering function has to call this.
85 * It registers 2 new values for the high and low part of the lowered value.
87 void ir_set_dw_lowered(ir_node *old, ir_node *new_low,
91 * Query lowering results of a node. In a lowering callback you can use this
92 * on all predecessors of a node. The only exception are block and phi nodes.
93 * Their predecessors are not necessarily transformed yet.
95 lower64_entry_t *get_node_entry(ir_node *node);
97 static inline ir_node *get_lowered_low(ir_node *node)
99 return get_node_entry(node)->low_word;
102 static inline ir_node *get_lowered_high(ir_node *node)
104 return get_node_entry(node)->high_word;
108 * Default implementation. Context is unused.
110 ir_entity *def_create_intrinsic_fkt(ir_type *method, const ir_op *op,
111 const ir_mode *imode, const ir_mode *omode,