Commit 618f76da authored by Matthias Braun's avatar Matthias Braun
Browse files

cleanup flag code

Settle on 1 flag type and no different I_FLAG and E_FLAG
parent 3d377d6b
......@@ -68,6 +68,9 @@ FIRM_API int get_opt_constant_folding(void);
*/
FIRM_API void set_opt_algebraic_simplification(int value);
/** Returns algebraic simplification setting. */
FIRM_API int get_opt_algebraic_simplification(void);
/** Enables/Disables common subexpression elimination.
*
* If opt_cse == 1 perform common subexpression elimination.
......@@ -89,6 +92,9 @@ FIRM_API int get_opt_cse(void);
*/
FIRM_API void set_opt_global_cse(int value);
/** Returns global constant subexpression elimination setting. */
FIRM_API int get_opt_global_cse(void);
/**
* Enable/Disable Global Null Pointer Test Elimination.
*
......@@ -100,6 +106,9 @@ FIRM_API void set_opt_global_cse(int value);
*/
FIRM_API void set_opt_global_null_ptr_elimination(int value);
/** Returns global null pointer test elimination setting. */
FIRM_API int get_opt_global_null_ptr_elimination(void);
/** Enable/Disable closed world assumption.
*
* If enabled, optimizations expect to know the "whole world", i.e. no
......@@ -108,6 +117,9 @@ FIRM_API void set_opt_global_null_ptr_elimination(int value);
*/
FIRM_API void set_opt_closed_world(int value);
/** Returns closed world assumption setting. */
FIRM_API int get_opt_closed_world(void);
/**
* Save the current optimization state.
*/
......
......@@ -21,46 +21,29 @@
#define ON -1
#define OFF 0
#define FLAG(name, value, def) (irf_##name & def) |
#define E_FLAG(name, value, def) FLAG(name, value, def)
#define I_FLAG(name, value, def) FLAG(name, value, def)
optimization_state_t libFIRM_opt =
#define FLAG(name, value, def) (irf_##name & def) |
#include "irflag_t.def"
0;
#undef FLAG
#undef E_FLAG
#undef I_FLAG
optimization_state_t libFIRM_running = 0;
optimization_state_t libFIRM_verb = 0;
0;
void set_opt_optimize(int value);
int get_opt_optimize(void);
/* an external flag can be set and get from outside */
#define E_FLAG(name, value, def) \
#define FLAG(name, value, def) \
void set_opt_##name(int flag) { \
if (flag) libFIRM_opt |= irf_##name; \
else libFIRM_opt &= ~irf_##name; \
} \
int (get_opt_##name)(void) { \
return get_opt_##name##_(); \
return (libFIRM_opt & irf_##name) != 0; \
}
/* an internal flag can only be set from outside */
#define I_FLAG(name, value, def) \
void set_opt_##name(int flag) { \
if (flag) libFIRM_opt |= irf_##name; \
else libFIRM_opt &= ~irf_##name; \
} \
/* generate them */
#include "irflag_t.def"
#undef I_FLAG
#undef E_FLAG
#undef FLAG
void set_optimize(int value)
{
......@@ -88,11 +71,9 @@ void all_optimizations_off(void)
}
static const lc_opt_table_entry_t firm_flags[] = {
#define I_FLAG(name, val, def) LC_OPT_ENT_BIT(#name, #name, &libFIRM_opt, (1 << val)),
#define E_FLAG(name, val, def) LC_OPT_ENT_BIT(#name, #name, &libFIRM_opt, (1 << val)),
#define FLAG(name, val, def) LC_OPT_ENT_BIT(#name, #name, &libFIRM_opt, (1 << val)),
#include "irflag_t.def"
#undef I_FLAG
#undef E_FLAG
#undef FLAG
LC_OPT_LAST
};
......
......@@ -9,32 +9,26 @@
* @author Michael Beck, Sebastian Hack
*/
/*
* We have 3 kinds of flags:
* I_FLAGS are INTERNAL flags: There is only a public set_opt_<flag> function
* E_FLAGS are EXTERNAL flags: Public get_opt_<flag> and set_opt_<flag> fucntions exists
*/
/** Turn off all optimizations. */
I_FLAG(optimize , 0, ON)
FLAG(optimize , 0, ON)
/** Common subexpression eliminations: Hash the nodes. */
E_FLAG(cse , 1, ON)
FLAG(cse , 1, ON)
/** Don't use block predecessor for comparison.
* Default must be zero as code placement must
* be run right after a local optimize walk with
* global_cse on. */
I_FLAG(global_cse , 2, OFF)
FLAG(global_cse , 2, OFF)
/** Evaluate operations. */
E_FLAG(constant_folding , 3, ON)
FLAG(constant_folding , 3, ON)
/** Algebraic simplifications. */
I_FLAG(algebraic_simplification , 4, ON)
FLAG(algebraic_simplification , 4, ON)
/** Use Global Null Pointer Test elimination. */
I_FLAG(global_null_ptr_elimination , 5, ON)
FLAG(global_null_ptr_elimination , 5, ON)
/** Closed world assumption. */
I_FLAG(closed_world , 12, OFF)
FLAG(closed_world , 12, OFF)
......@@ -13,60 +13,45 @@
#include "irflag.h"
#define get_opt_cse() get_opt_cse_()
#define get_optimize() get_optimize_()
#define get_opt_constant_folding() get_opt_constant_folding_()
#define get_opt_algebraic_simplification() get_opt_algebraic_simplification_()
/**
* libFIRM optimizations flags
*/
typedef enum {
#define E_FLAG(name, value, def) irf_##name = (1 << value),
#define I_FLAG(name, value, def) irf_##name = (1 << value),
#define FLAG(name, value, def) irf_##name = (1 << value),
#include "irflag_t.def"
irf_last
#undef I_FLAG
#undef E_FLAG
#undef FLAG
} libfirm_opts_t;
/**
* libFIRM running flags
*/
typedef enum {
#define E_FLAG(name, value, def)
#define I_FLAG(name, value, def)
#include "irflag_t.def"
ir_rf_last
#undef I_FLAG
#undef E_FLAG
} libfirm_running_t;
extern optimization_state_t libFIRM_opt, libFIRM_running, libFIRM_verb;
extern optimization_state_t libFIRM_opt;
/** initialises the flags */
void firm_init_flags(void);
/* generate the getter functions for external access */
#define E_FLAG(name, value, def) \
static inline int get_opt_##name##_(void) { \
return libFIRM_opt & irf_##name; \
static inline int get_opt_cse_(void)
{
return (libFIRM_opt & irf_cse) != 0;
}
/* generate the getter functions for internal access */
#define I_FLAG(name, value, def) \
static inline int get_opt_##name(void) { \
return libFIRM_opt & irf_##name; \
static inline int get_opt_constant_folding_(void)
{
return (libFIRM_opt & irf_constant_folding) != 0;
}
#include "irflag_t.def"
#undef I_FLAG
#undef E_FLAG
static inline int get_opt_algebraic_simplification_(void)
{
return (libFIRM_opt & irf_algebraic_simplification) != 0;
}
static inline int get_optimize_(void)
{
return get_opt_optimize();
return (libFIRM_opt & irf_optimize) != 0;
}
#define get_optimize() get_optimize_()
#define get_opt_cse() get_opt_cse_()
#endif
......@@ -189,7 +189,7 @@ static void move_edges(ir_node *node, ir_node *from_bl, ir_node *to_bl)
void part_block(ir_node *node)
{
/* Turn off optimizations so that blocks are not merged again. */
int rem_opt = get_opt_optimize();
int rem_opt = get_optimize();
set_optimize(0);
/* Transform the control flow */
......
......@@ -1399,7 +1399,7 @@ static bool is_kept_alive(const ir_node *node)
*/
static ir_node *equivalent_node_Phi(ir_node *n)
{
if (!get_opt_optimize() &&
if (!get_optimize() &&
!irg_is_constrained(get_irn_irg(n), IR_GRAPH_CONSTRAINT_CONSTRUCTION))
return n;
......@@ -7588,7 +7588,7 @@ ir_node *optimize_node(ir_node *n)
unsigned iro = get_irn_opcode(n);
/* Always optimize Phi nodes: part of the construction. */
if ((!get_opt_optimize()) && (iro != iro_Phi)) return n;
if ((!get_optimize()) && (iro != iro_Phi)) return n;
ir_graph *irg = get_irn_irg(n);
......@@ -7674,7 +7674,7 @@ ir_node *optimize_node(ir_node *n)
ir_node *optimize_in_place_2(ir_node *n)
{
if (!get_opt_optimize() && !is_Phi(n)) return n;
if (!get_optimize() && !is_Phi(n)) return n;
if (is_Deleted(n))
return n;
......
......@@ -356,7 +356,7 @@ static bool inline_method(ir_node *const call, ir_graph *called_graph)
DB((dbg, LEVEL_1, "Inlining %+F(%+F) into %+F\n", call, called_graph, irg));
/* optimizations can cause problems when allocating new nodes */
int rem_opt = get_opt_optimize();
int rem_opt = get_optimize();
set_optimize(0);
/* Handle graph state */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment