* @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.
* Handle bit fields by added And/Or calculations.
*
* @param irg the graph to lower
- * @param lower_bitfields the graph contains old-style bitfield
- * constructs
*
* @note: There is NO lowering ob objects oriented types. This is highly compiler
* and ABI specific and should be placed directly in the compiler.
*/
-FIRM_API void lower_highlevel_graph(ir_graph *irg, int lower_bitfields);
+FIRM_API void lower_highlevel_graph(ir_graph *irg);
/**
* Creates an ir_graph pass for lower_highlevel_graph().
*
* @param name the name of this pass or NULL
- * @param lower_bitfields the graph contains old-style bitfield
- * constructs
*
* @return the newly created ir_graph pass
*/
-FIRM_API ir_graph_pass_t *lower_highlevel_graph_pass(const char *name,
- int lower_bitfields);
+FIRM_API ir_graph_pass_t *lower_highlevel_graph_pass(const char *name);
/**
* Replaces SymConsts by a real constant if possible.
* @note There is NO lowering of objects oriented types. This is highly compiler
* and ABI specific and should be placed directly in the compiler.
*/
-FIRM_API void lower_highlevel(int lower_bitfields);
+FIRM_API void lower_highlevel(void);
/**
* does the same as lower_highlevel for all nodes on the const code irg
*/
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
*/
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