/*
- * Project: libFIRM
- * File name: ir/ir/irgraph.c
- * Purpose: Flags to control optimizations, inline implementation.
- * Author: Michael Beck
- * Created:
- * CVS-ID: $Id$
- * Copyright: (c) 1998-2004 Universität Karlsruhe
- * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
+ * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
*/
/**
- * @file irflag_t.h
- *
- * Inline implementation of Optimization flags.
- *
- * @author Michael Beck
+ * @file
+ * @brief Flags to control optimizations, inline implementation.
+ * @author Michael Beck, Sebastian Hack
+ * @version $Id$
*/
-#ifndef _IRFLAG_T_H_
-#define _IRFLAG_T_H_
+#ifndef FIRM_IR_IRFLAG_T_H
+#define FIRM_IR_IRFLAG_T_H
#include "irflag.h"
/**
- * current libFIRM optimizations
+ * libFIRM optimizations flags
*/
typedef enum {
- /** Common subexpression eliminations: Hash the nodes. */
- OPT_CSE = 0x00000001,
-
- /** Don't use block predecessor for comparison.
- * Default must be zero as code placement must
- * be run right after a local optimize walk with
- * opt_global_cse on. */
- OPT_GLOBAL_CSE = 0x00000002,
-
- /** Evaluate operations. */
- OPT_CONSTANT_FOLDING = 0x00000004,
-
- /** Bad node propagation. */
- OPT_UNREACHABLE_CODE = 0x00000008,
-
- /** */
- OPT_CONTROL_FLOW_STRAIGHTENING = 0x00000010,
-
- /** */
- OPT_CONTROL_FLOW_WEAK_SIMPLIFICATION = 0x00000020,
-
- /** */
- OPT_CONTROL_FLOW_STRONG_SIMPLIFICATION = 0x00000040,
-
- /** */
- OPT_CRITICAL_EDGES = 0x00000080,
-
- /** Reclaim memory. */
- OPT_DEAD_NODE_ELIMINATION = 0x00000100,
-
- /** Reassociate nodes. */
- OPT_REASSOCIATION = 0x00000200,
-
- /** Do inlining transformation. */
- OPT_INLINE = 0x00000400,
-
- /** Remove dynamic method dispatch. */
- OPT_DYN_METH_DISPATCH = 0x00000800,
-
- /** Transformations that normalize the firm representation
- * as removing Ids and Tuples, useless Phis, SymConst(id) -> Const(entity) ...
- */
- OPT_NORMALIZE = 0x00001000,
-
- /** Remove tail-recursion. */
- OPT_TAIL_RECURSION = 0x00002000,
-
- /** Free never called methods */
- OPT_DEAD_METHOD_ELIMINATION = 0x00008000,
-
- /** Free never called methods */
- OPT_DEAD_METHOD_ELIMINATION_VERBOSE = 0x00010000,
-
- /** Turn off all optimizations. */
- OPT_OPTIMIZED = 0x40000000,
+#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
+#undef R_FLAG
} libfirm_opts_t;
-extern optimization_state_t libFIRM_opt;
-
-/** Returns constant folding optimization setting. */
-static INLINE int get_opt_cse(void)
-{
- return libFIRM_opt & OPT_CSE;
-}
-
-/** Returns constant subexpression elimination setting. */
-static INLINE int get_opt_global_cse(void)
-{
- return libFIRM_opt & OPT_GLOBAL_CSE;
-}
-
-/** Returns global constant subexpression elimination setting. */
-static INLINE int get_opt_constant_folding(void)
-{
- return libFIRM_opt & OPT_CONSTANT_FOLDING;
-}
-
-/** Returns unreachable code elimination setting. */
-static INLINE int get_opt_unreachable_code(void)
-{
- return libFIRM_opt & OPT_UNREACHABLE_CODE;
-}
-
-/** Returns Straightening setting. */
-static INLINE int get_opt_control_flow_straightening(void)
-{
- return libFIRM_opt & OPT_CONTROL_FLOW_STRAIGHTENING;
-}
-
-/** Returns if simplifications in local optimizations setting. */
-static INLINE int get_opt_control_flow_weak_simplification(void)
-{
- return libFIRM_opt & OPT_CONTROL_FLOW_WEAK_SIMPLIFICATION;
-}
+/**
+ * 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),
-/** Returns strong if and loop simplification setting */
-static INLINE int get_opt_control_flow_strong_simplification(void)
-{
- return libFIRM_opt & OPT_CONTROL_FLOW_STRONG_SIMPLIFICATION;
-}
+#include "irflag_t.def"
+ ir_rf_last
+#undef I_FLAG
+#undef E_FLAG
+#undef R_FLAG
+} libfirm_running_t;
-/** Returns whether critical edges are removed */
-static INLINE int get_opt_critical_edges(void)
-{
- return libFIRM_opt & OPT_CRITICAL_EDGES;
-}
+extern optimization_state_t libFIRM_opt, libFIRM_running, libFIRM_verb;
+extern firm_verification_t opt_do_node_verification;
-/** Returns reassociation setting. */
-static INLINE int get_opt_reassociation(void)
-{
- return libFIRM_opt & OPT_REASSOCIATION;
-}
+/** initialises the flags */
+void firm_init_flags(void);
-/** Returns dead node elimination setting. */
-static INLINE int get_opt_dead_node_elimination(void)
-{
- return libFIRM_opt & OPT_DEAD_NODE_ELIMINATION;
+/* 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; \
}
-/** Returns dead method elimination setting. */
-static INLINE int get_opt_dead_method_elimination(void)
-{
- return libFIRM_opt & OPT_DEAD_METHOD_ELIMINATION;
+/* 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; \
}
-/** Returns dead method elimination setting. */
-static INLINE int get_opt_dead_method_elimination_verbose(void)
-{
- return libFIRM_opt & OPT_DEAD_METHOD_ELIMINATION_VERBOSE;
+/* 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; \
}
-/** Returns global optimization setting */
-static INLINE int get_opt_optimize(void)
-{
- return libFIRM_opt & OPT_OPTIMIZED;
-}
+#include "irflag_t.def"
-/** Returns inlining setting. */
-static INLINE int get_opt_inline(void)
-{
- return libFIRM_opt & OPT_INLINE;
-}
+#undef I_FLAG
+#undef E_FLAG
+#undef R_FLAG
-static INLINE int get_opt_dyn_meth_dispatch(void)
-{
- return libFIRM_opt & OPT_DYN_METH_DISPATCH;
+static inline int _get_optimize(void) {
+ return get_opt_optimize();
}
-static INLINE int get_opt_normalize(void)
-{
- return libFIRM_opt & OPT_NORMALIZE;
+static inline firm_verification_t
+get_node_verification_mode(void) {
+ return opt_do_node_verification;
}
-/** Returns tail-recursion setting. */
-static INLINE int get_opt_tail_recursion(void)
-{
- return libFIRM_opt & OPT_TAIL_RECURSION;
-}
-
-
+#define get_optimize() _get_optimize()
+#define get_opt_cse() _get_opt_cse()
+#define get_opt_dyn_meth_dispatch() _get_opt_dyn_meth_dispatch()
+#define get_opt_optimize_class_casts() _get_opt_optimize_class_casts()
+#define get_opt_suppress_downcast_optimization() _get_opt_suppress_downcast_optimization()
-#endif /* _IRFLAG_T_H_ */
+#endif