* @file
* @brief Lowering of high level constructs.
* @author Michael Beck
- * @version $Id$
*/
#ifndef FIRM_LOWERING_H
#define FIRM_LOWERING_H
#include "begin.h"
/**
- * Lower CopyB nodes of size smaller that max_size into Loads/Stores
+ * @defgroup ir_lowering Lowering
+ *
+ * Lowering is the process of transforming a highlevel representation
+ * (a representation closer to the sourcecode) into a lower-level representation
+ * (something closer to the target machine).
+ *
+ * @{
*/
-FIRM_API void lower_CopyB(ir_graph *irg, unsigned max_size,
- unsigned native_mode_bytes);
+
+/**
+ * Lower small CopyB nodes to Load/Store nodes, preserve medium-sized CopyB
+ * nodes and replace large CopyBs by a call to memcpy, depending on the given
+ * parameters.
+ *
+ * Small CopyB nodes (size <= max_small_size) are turned into a series of
+ * loads and stores.
+ * Medium-sized CopyB nodes (max_small_size < size < min_large_size) are
+ * left untouched.
+ * Large CopyB nodes (size >= min_large_size) are turned into a memcpy call.
+ *
+ * @param irg The graph to be lowered.
+ * @param max_small_size The maximum number of bytes for a CopyB node so
+ * that it is still considered 'small'.
+ * @param min_large_size The minimum number of bytes for a CopyB node so
+ * that it is regarded as 'large'.
+ * @param allow_misalignments Backend can handle misaligned loads and stores.
+ */
+FIRM_API void lower_CopyB(ir_graph *irg, unsigned max_small_size,
+ unsigned min_large_size, int allow_misalignments);
/**
* Lowers all Switches (Cond nodes with non-boolean mode) depending on spare_size.
* @param small_switch If switch has <= cases then change it to an if-cascade.
* @param spare_size Allowed spare size for table switches in machine words.
* (Default in edgfe: 128)
- * @param allow_out_of_bounds backend can handle out-of-bounds values
- * (values bigger than minimum and maximum proj
- * number)
+ * @param selector_mode mode which must be used for Switch selector
*/
FIRM_API void lower_switch(ir_graph *irg, unsigned small_switch,
- unsigned spare_size, int allow_out_of_bounds);
+ unsigned spare_size, ir_mode *selector_mode);
/**
* Replaces SymConsts by a real constant if possible.
- * Replace Sel nodes by address computation. Also resolves array access.
+ * Replaces Sel nodes by address computation. Also resolves array access.
* Handle bit fields by added And/Or calculations.
*
* @param irg the graph to lower
/**
* Replaces SymConsts by a real constant if possible.
- * Replace Sel nodes by address computation. Also resolves array access.
+ * Replaces Sel nodes by address computation. Also resolves array access.
* Handle bit fields by added And/Or calculations.
* Lowers all graphs.
*
*/
FIRM_API ir_prog_pass_t *lower_const_code_pass(const char *name);
-/**
- * Function which creates a "set" instraction. A "set" instruction takes a
- * condition value (a value with mode_b) as input and produces a value in a
- * general purpose integer mode.
- * Most architectures have special intrinsics for this. But if all else fails
- * you can just produces the an if-like construct.
- */
-typedef ir_node* (*create_set_func)(ir_node *cond);
-
-/**
- * implementation of create_set_func which produces a Mux node with 0/1 input
- */
-FIRM_API ir_node *ir_create_mux_set(ir_node *cond, ir_mode *dest_mode);
-
-/**
- * implementation of create_set_func which produces a cond with control
- * flow
- */
-FIRM_API ir_node *ir_create_cond_set(ir_node *cond, ir_mode *dest_mode);
-
-typedef struct lower_mode_b_config_t {
- /* mode that is used to transport 0/1 values */
- ir_mode *lowered_mode;
- /* callback for creating set-like instructions */
- create_set_func create_set;
- /* whether direct Cond(Cmp) should also be lowered */
- int lower_direct_cmp;
-} lower_mode_b_config_t;
-
-/**
- * Lowers mode_b operations to integer arithmetic. After the lowering the only
- * operations with mode_b are the Projs of Cmps; the only nodes with mode_b
- * inputs are Cond and Psi nodes.
- *
- * Example: Psi(a < 0, 1, 0) => a >> 31
- *
- * @param irg the firm graph to lower
- * @param config configuration for mode_b lowerer
- */
-FIRM_API void ir_lower_mode_b(ir_graph *irg,
- const lower_mode_b_config_t *config);
-
/**
* Used as callback, whenever a lowerable mux is found. The return value
* indicates, whether the mux should be lowered. This may be used, to lower
*/
typedef int (*i_mapper_func)(ir_node *node, void *ctx);
+/** kind of an instruction record
+ * @see #i_record */
enum ikind {
INTRINSIC_CALL = 0, /**< the record represents an intrinsic call */
INTRINSIC_INSTR /**< the record represents an intrinsic instruction */
* An intrinsic record.
*/
typedef union i_record {
- i_call_record i_call;
- i_instr_record i_instr;
+ enum ikind kind; /**< kind of record */
+ i_call_record i_call; /**< used for call records */
+ i_instr_record i_instr; /**< used for isnstruction records */
} i_record;
/**
* Every call or instruction is reported to its mapper function,
* which is responsible for rebuilding the graph.
*
- * current_ir_graph is always set.
- *
* @param list an array of intrinsic map records
* @param length the length of the array
* @param part_block_used set to true if part_block() must be using during lowering
* @return number of found intrinsics.
*/
FIRM_API size_t lower_intrinsics(i_record *list, size_t length,
- int part_block_used);
+ int part_block_used);
/**
* Creates an irprog pass for lower_intrinsics.
*/
FIRM_API int i_mapper_exp(ir_node *call, void *ctx);
-#define i_mapper_exp2 i_mapper_exp
-#define i_mapper_exp10 i_mapper_exp
+/**
+ * A mapper for the floating point exp2(a): floattype exp2(floattype a);
+ *
+ * @return 1 if the exp call was removed, 0 else.
+ */
+FIRM_API int i_mapper_exp2(ir_node *call, void *ctx);
+
+/**
+ * A mapper for the floating point exp10(a): floattype exp10(floattype a);
+ *
+ * @return 1 if the exp call was removed, 0 else.
+ */
+FIRM_API int i_mapper_exp10(ir_node *call, void *ctx);
/**
* A mapper for the floating point log(a): floattype log(floattype a);
*/
FIRM_API int i_mapper_log(ir_node *call, void *ctx);
-#define i_mapper_log2 i_mapper_log
-#define i_mapper_log10 i_mapper_log
+/**
+ * A mapper for the floating point log(a): floattype log(floattype a);
+ *
+ * @return 1 if the log call was removed, 0 else.
+ */
+FIRM_API int i_mapper_log2(ir_node *call, void *ctx);
+
+/**
+ * A mapper for the floating point log(a): floattype log(floattype a);
+ *
+ * @return 1 if the log call was removed, 0 else.
+ */
+FIRM_API int i_mapper_log10(ir_node *call, void *ctx);
/**
* A mapper for the floating point sin(a): floattype sin(floattype a);
*/
FIRM_API int i_mapper_RuntimeCall(ir_node *node, runtime_rt *rt);
+/** @} */
+
#include "end.h"
#endif