- fixed wrong condition in iropt.c
[r15896]
*/
void set_opt_alias_analysis(int value);
*/
void set_opt_alias_analysis(int value);
-/** Internal Flag, set if architecture dependent Mul to SASL chain was running.
- *
- * If set, some local optimizations that collide with the SASL conversion are disabled.
- */
-void set_opt_arch_dep_running(int value);
-
/** Enable/Disable closed world assumption.
*
* If enabled, optimizations expect to know the "whole world", i.e. no
/** Enable/Disable closed world assumption.
*
* If enabled, optimizations expect to know the "whole world", i.e. no
void arch_dep_set_opts(arch_dep_opts_t the_opts) {
opts = the_opts;
void arch_dep_set_opts(arch_dep_opts_t the_opts) {
opts = the_opts;
-
- if (opts & arch_dep_mul_to_shift)
- set_opt_arch_dep_running(1);
}
/** check, whether a mode allows a Mulh instruction. */
}
/** check, whether a mode allows a Mulh instruction. */
if (params == NULL || (opts & arch_dep_mul_to_shift) == 0)
return irn;
if (params == NULL || (opts & arch_dep_mul_to_shift) == 0)
return irn;
- if (is_Mul(irn) && mode_is_int(mode)) {
- ir_node *left = get_binop_left(irn);
- ir_node *right = get_binop_right(irn);
- tarval *tv = NULL;
- ir_node *operand = NULL;
-
- /* Look, if one operand is a constant. */
- if (is_Const(left)) {
- tv = get_Const_tarval(left);
- operand = right;
- } else if (is_Const(right)) {
- tv = get_Const_tarval(right);
- operand = left;
- }
+ set_arch_dep_running(1);
+ {
+ if (is_Mul(irn) && mode_is_int(mode)) {
+ ir_node *left = get_binop_left(irn);
+ ir_node *right = get_binop_right(irn);
+ tarval *tv = NULL;
+ ir_node *operand = NULL;
+
+ /* Look, if one operand is a constant. */
+ if (is_Const(left)) {
+ tv = get_Const_tarval(left);
+ operand = right;
+ } else if (is_Const(right)) {
+ tv = get_Const_tarval(right);
+ operand = left;
+ }
- if (tv != NULL) {
- res = do_decomposition(irn, operand, tv);
+ if (tv != NULL) {
+ res = do_decomposition(irn, operand, tv);
- if (res != irn) {
- hook_arch_dep_replace_mul_with_shifts(irn);
- exchange(irn, res);
+ if (res != irn) {
+ hook_arch_dep_replace_mul_with_shifts(irn);
+ exchange(irn, res);
+ }
+ set_arch_dep_running(0);
#define ON (-1)
#define OFF (0)
#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)
+#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)
+#define R_FLAG(name, value)
optimization_state_t libFIRM_opt =
#include "irflag_t.def"
optimization_state_t libFIRM_opt =
#include "irflag_t.def"
#undef FLAG
#undef E_FLAG
#undef I_FLAG
#undef FLAG
#undef E_FLAG
#undef I_FLAG
+/** The bitset of currently running phases. */
+optimization_state_t libFIRM_running = 0;
/* verbose is always off on default */
optimization_state_t libFIRM_verb = 0;
/* verbose is always off on default */
optimization_state_t libFIRM_verb = 0;
else libFIRM_verb &= ~irf_##name; \
}
else libFIRM_verb &= ~irf_##name; \
}
+#define R_FLAG(name, value)
+
/* generate them */
#include "irflag_t.def"
#undef I_FLAG
#undef E_FLAG
/* generate them */
#include "irflag_t.def"
#undef I_FLAG
#undef E_FLAG
/* for compatibility reasons */
void set_optimize(int value) {
/* for compatibility reasons */
void set_optimize(int value) {
printf("Firm optimization state:\n");
#define E_FLAG(name, value, def) printf(" %-20s = %s\n", #name, get_opt_##name() ? "ON" : "OFF");
#define I_FLAG(name, value, def) printf(" %-20s = %s\n", #name, get_opt_##name() ? "ON" : "OFF");
printf("Firm optimization state:\n");
#define E_FLAG(name, value, def) printf(" %-20s = %s\n", #name, get_opt_##name() ? "ON" : "OFF");
#define I_FLAG(name, value, def) printf(" %-20s = %s\n", #name, get_opt_##name() ? "ON" : "OFF");
+#define R_FLAG(name, value) printf(" %-20s = %s\n", #name, is_##name##_running() ? "is running" : "not running");
#include "irflag_t.def"
#undef I_FLAG
#undef E_FLAG
#include "irflag_t.def"
#undef I_FLAG
#undef E_FLAG
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)),
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 R_FLAG(name, val)
#include "irflag_t.def"
#undef I_FLAG
#undef E_FLAG
#include "irflag_t.def"
#undef I_FLAG
#undef E_FLAG
-void firm_init_flags(void)
-{
+void firm_init_flags(void) {
#ifdef WITH_LIBCORE
lc_opt_entry_t *grp = lc_opt_get_grp(firm_opt_get_root(), "opt");
lc_opt_add_table(grp, firm_flags);
#ifdef WITH_LIBCORE
lc_opt_entry_t *grp = lc_opt_get_grp(firm_opt_get_root(), "opt");
lc_opt_add_table(grp, firm_flags);
+/*
+ * We have 3 kinds of flags:
+ * I_FLAGS are INTERNAL flags: The is only a public set_opt_<flag> function
+ * E_FLAGS are EXTERNAL flags: Public get_opt_<flag> and set_opt_<flag> fucntions exists
+ * R_FLAGS are RUNNING flags: Use only internally in libfirm to indicate running states
+ */
+
/** Turn off all optimizations. */
I_FLAG(optimize , 0, ON)
/** Turn off all optimizations. */
I_FLAG(optimize , 0, ON)
/** Enable Alias-analysis. */
I_FLAG(alias_analysis , 28, ON)
/** Enable Alias-analysis. */
I_FLAG(alias_analysis , 28, ON)
+/** Closed world assumption. */
+I_FLAG(closed_world , 31, OFF)
+
+/* -------------------- RUNNING flags ------------------- */
+
/** This flag is set while the reassociation optimizations are running */
/** This flag is set while the reassociation optimizations are running */
-I_FLAG(reassoc_running , 29, OFF)
/** This flag is set while architecture dependent optimizations are running */
/** This flag is set while architecture dependent optimizations are running */
-I_FLAG(arch_dep_running , 30, OFF)
-
-/** Closed world assumption. */
-I_FLAG(closed_world , 31, OFF)
- * current libFIRM optimizations
+ * libFIRM optimizations flags
-#define E_FLAG(name, value, def) irf_##name = (1 << value),
-#define I_FLAG(name, value, def) irf_##name = (1 << value),
+#define E_FLAG(name, value, def) irf_##name = (1 << value),
+#define I_FLAG(name, value, def) irf_##name = (1 << value),
+#define R_FLAG(name, value)
#include "irflag_t.def"
irf_last
#undef I_FLAG
#undef E_FLAG
#include "irflag_t.def"
irf_last
#undef I_FLAG
#undef E_FLAG
-extern optimization_state_t libFIRM_opt;
-extern optimization_state_t libFIRM_verb;
+/**
+ * libFIRM running flags
+ */
+typedef enum {
+#define E_FLAG(name, value, def)
+#define I_FLAG(name, value, def)
+#define R_FLAG(name, value) ir_rf_##name = (1 << value),
+
+#include "irflag_t.def"
+ ir_rf_last
+#undef I_FLAG
+#undef E_FLAG
+#undef R_FLAG
+} libfirm_opts_t;
+
+extern optimization_state_t libFIRM_opt, libFIRM_running, libFIRM_verb;
extern firm_verification_t opt_do_node_verification;
extern int firm_verbosity_level;
extern firm_verification_t opt_do_node_verification;
extern int firm_verbosity_level;
return libFIRM_verb & irf_##name; \
}
return libFIRM_verb & irf_##name; \
}
+/* generate getter and setter functions for running flags */
+#define R_FLAG(name, value) \
+static INLINE int is_##name##_running(void) { \
+ return libFIRM_running & ir_rf_##name; \
+} \
+static INLINE void set_##name##_running(int flag) {\
+ if (flag) libFIRM_running |= ir_rf_##name; \
+ else libFIRM_running &= ~ir_rf_##name; \
+}
+
#include "irflag_t.def"
#undef I_FLAG
#undef E_FLAG
#include "irflag_t.def"
#undef I_FLAG
#undef E_FLAG
static INLINE int _get_firm_verbosity (void) {
return firm_verbosity_level;
static INLINE int _get_firm_verbosity (void) {
return firm_verbosity_level;
if (mode_is_num(mode)) {
/* the following code leads to endless recursion when Mul are replaced by a simple instruction chain */
if (mode_is_num(mode)) {
/* the following code leads to endless recursion when Mul are replaced by a simple instruction chain */
- if (!get_opt_arch_dep_running() && a == b && mode_is_int(mode)) {
+ if (!is_arch_dep_running() && a == b && mode_is_int(mode)) {
ir_node *block = get_irn_n(n, -1);
n = new_rd_Mul(
ir_node *block = get_irn_n(n, -1);
n = new_rd_Mul(
DBG_OPT_ALGSIM0(oldn, n, FS_OPT_ADD_A_MINUS_B);
return n;
}
DBG_OPT_ALGSIM0(oldn, n, FS_OPT_ADD_A_MINUS_B);
return n;
}
- if (! get_opt_reassoc_running()) {
+ if (! is_reassoc_running()) {
/* do NOT execute this code if reassociation is enabled, it does the inverse! */
if (is_Mul(a)) {
ir_node *ma = get_Mul_left(a);
/* do NOT execute this code if reassociation is enabled, it does the inverse! */
if (is_Mul(a)) {
ir_node *ma = get_Mul_left(a);
}
}
/* do NOT execute this code if reassociation is enabled, it does the inverse! */
}
}
/* do NOT execute this code if reassociation is enabled, it does the inverse! */
- if (get_opt_reassoc_running() && is_Mul(a)) {
+ if (!is_reassoc_running() && is_Mul(a)) {
ir_node *ma = get_Mul_left(a);
ir_node *mb = get_Mul_right(a);
ir_node *ma = get_Mul_left(a);
ir_node *mb = get_Mul_right(a);
env.wq = new_waitq();
/* disable some optimizations while reassoc is running to prevent endless loops */
env.wq = new_waitq();
/* disable some optimizations while reassoc is running to prevent endless loops */
- set_opt_reassoc_running(1);
+ set_reassoc_running(1);
{
/* now we have collected enough information, optimize */
irg_walk_graph(irg, NULL, wq_walker, &env);
{
/* now we have collected enough information, optimize */
irg_walk_graph(irg, NULL, wq_walker, &env);
/* reverse those rules that do not result in collapsed constants */
irg_walk_graph(irg, NULL, reverse_rules, &env);
}
/* reverse those rules that do not result in collapsed constants */
irg_walk_graph(irg, NULL, reverse_rules, &env);
}
- set_opt_reassoc_running(0);
+ set_reassoc_running(0);
/* Handle graph state */
if (env.changes) {
/* Handle graph state */
if (env.changes) {