X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Firflag.c;h=fdfbd2df0b1eccbcc90f1db5a5eab538ac082a86;hb=e570f00fb465d212dde403160e97ab45d36d1d7e;hp=784d74b8081a01eac965ab65f81b20591f4d6976;hpb=a63062db7f43c0d0bec2779e62fa9493cd74d3af;p=libfirm diff --git a/ir/ir/irflag.c b/ir/ir/irflag.c index 784d74b80..fdfbd2df0 100644 --- a/ir/ir/irflag.c +++ b/ir/ir/irflag.c @@ -1,69 +1,276 @@ -/* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe -** All rights reserved. -** -** Authors: Christian Schaefer -** -** irflag --- optimization flags -*/ +/* + * Project: libFIRM + * File name: ir/ir/irflag.c + * Purpose: Flags to control optimizations. + * Author: Christian Schaefer, Goetz Lindenmaier + * Modified by: + * Created: + * CVS-ID: $Id$ + * Copyright: (c) 1999-2003 Universität Karlsruhe + * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. + */ #ifdef HAVE_CONFIG_H # include #endif +#include "firm_common.h" +#include "irflag_t.h" -/* 0 - don't do this optimization - 1 - lets see, if there is a better graph */ -int opt_cse = 1; -int opt_constant_folding = 1; -int opt_dead_node_elimination = 1; -int optimized = 1; +/* DISABLE - don't do this optimization + ENABLE - lets see, if there is a better graph */ +#define ENABLE(a) a +#define DISABLE(a) 0 + +optimization_state_t libFIRM_opt = + ENABLE(OPT_OPTIMIZED) | + ENABLE(OPT_CSE) | + DISABLE(OPT_GLOBAL_CSE) | + ENABLE(OPT_CONSTANT_FOLDING) | + ENABLE(OPT_UNREACHABLE_CODE) | + ENABLE(OPT_CONTROL_FLOW_STRAIGHTENING) | + ENABLE(OPT_CONTROL_FLOW_WEAK_SIMPLIFICATION) | + ENABLE(OPT_CONTROL_FLOW_STRONG_SIMPLIFICATION) | + ENABLE(OPT_CRITICAL_EDGES) | + ENABLE(OPT_DEAD_NODE_ELIMINATION) | + ENABLE(OPT_REASSOCIATION) | + ENABLE(OPT_INLINE) | + ENABLE(OPT_DYN_METH_DISPATCH) | + ENABLE(OPT_NORMALIZE); /* set the flags with set_flagname, get the flag with get_flagname */ +void set_opt_cse (int value) +{ + if (value) + libFIRM_opt |= OPT_CSE; + else + libFIRM_opt &= ~OPT_CSE; +} + +void set_opt_global_cse(int value) +{ + if (value) + libFIRM_opt |= OPT_GLOBAL_CSE; + else + libFIRM_opt &= ~OPT_GLOBAL_CSE; +} + +void +set_opt_constant_folding(int value) +{ + if (value) + libFIRM_opt |= OPT_CONSTANT_FOLDING; + else + libFIRM_opt &= ~OPT_CONSTANT_FOLDING; +} + +void +set_opt_unreachable_code(int value) +{ + if (value) + libFIRM_opt |= OPT_UNREACHABLE_CODE; + else + libFIRM_opt &= ~OPT_UNREACHABLE_CODE; +} + +void set_opt_control_flow(int value) +{ + set_opt_control_flow_straightening(value); + set_opt_control_flow_weak_simplification(value); + set_opt_control_flow_strong_simplification(value); + set_opt_critical_edges(value); +} + +/* Performs Straightening */ +void set_opt_control_flow_straightening(int value) +{ + if (value) + libFIRM_opt |= OPT_CONTROL_FLOW_STRAIGHTENING; + else + libFIRM_opt &= ~OPT_CONTROL_FLOW_STRAIGHTENING; +} + +/* Performs if simplifications in local optimizations. */ +void set_opt_control_flow_weak_simplification(int value) +{ + if (value) + libFIRM_opt |= OPT_CONTROL_FLOW_WEAK_SIMPLIFICATION; + else + libFIRM_opt &= ~OPT_CONTROL_FLOW_WEAK_SIMPLIFICATION; +} + +/* Performs strong if and loop simplification (in optimize_cf). */ +void set_opt_control_flow_strong_simplification(int value) +{ + if (value) + libFIRM_opt |= OPT_CONTROL_FLOW_STRONG_SIMPLIFICATION; + else + libFIRM_opt &= ~OPT_CONTROL_FLOW_STRONG_SIMPLIFICATION; +} -inline void -set_opt_cse (int value) +void set_opt_critical_edges(int value) { - opt_cse = value; + if (value) + libFIRM_opt |= OPT_CRITICAL_EDGES; + else + libFIRM_opt &= ~OPT_CRITICAL_EDGES; } -inline int -get_opt_cse (void) +void set_opt_reassociation(int value) { - return opt_cse; + if (value) + libFIRM_opt |= OPT_REASSOCIATION; + else + libFIRM_opt &= ~OPT_REASSOCIATION; } -inline void -set_opt_constant_folding (int value) +void set_opt_dead_node_elimination(int value) { - opt_constant_folding=value; + if (value) + libFIRM_opt |= OPT_DEAD_NODE_ELIMINATION; + else + libFIRM_opt &= ~OPT_DEAD_NODE_ELIMINATION; } -inline int -get_opt_constant_folding (void) +void set_optimize(int value) { - return opt_constant_folding; + if (value) + libFIRM_opt |= OPT_OPTIMIZED; + else + libFIRM_opt &= ~OPT_OPTIMIZED; } -inline void -set_opt_dead_node_elimination (int value) +int get_optimize(void) { - opt_dead_node_elimination = value; + return get_opt_optimize(); } -inline int -get_opt_dead_node_elimination (void) +void set_opt_inline(int value) { - return opt_dead_node_elimination; + if (value) + libFIRM_opt |= OPT_INLINE; + else + libFIRM_opt &= ~OPT_INLINE; } -inline void -set_optimize (int value) +/** Enable/Disable optimization of dynamic method dispatch + * + * This flag enables/disables the optimization of dynamic method dispatch. + * If the flag is turned on Sel nodes can be replaced by Const nodes representing + * the address of a function. + */ +void set_opt_dyn_meth_dispatch (int value) +{ + if (value) + libFIRM_opt |= OPT_DYN_METH_DISPATCH; + else + libFIRM_opt &= ~OPT_DYN_METH_DISPATCH; +} + +void set_opt_normalize(int value) +{ + if (value) + libFIRM_opt |= OPT_NORMALIZE; + else + libFIRM_opt &= ~OPT_NORMALIZE; +} + +/* Save the current optimization state. */ +void save_optimization_state(optimization_state_t *state) +{ + *state = libFIRM_opt; +} + +/* Restore the current optimization state. */ +void restore_optimization_state(const optimization_state_t *state) +{ + libFIRM_opt = *state; +} + +/* repeat 'inline' methods here */ + +# ifndef USE_GCC_INLINE + +/** Returns constant folding optimization setting. */ +int get_opt_cse(void) /* iropt.c */ { - optimized = value; + return libFIRM_opt & OPT_CSE; } -inline int -get_optimize (void) +/** Returns constant subexpression elimination setting. */ +int get_opt_global_cse(void) /* irgopt.c iropt.c */ { - return optimized; + return libFIRM_opt & OPT_GLOBAL_CSE; } + +/** Returns global constant subexpression elimination setting. */ +int get_opt_constant_folding(void) /* iropt.c */ +{ + return libFIRM_opt & OPT_CONSTANT_FOLDING; +} + +/** Returns unreachable code elimination setting. */ +int get_opt_unreachable_code(void) /* iropt.c */ +{ + return libFIRM_opt & OPT_UNREACHABLE_CODE; +} + +/** Returns Straightening setting. */ +int get_opt_control_flow_straightening(void) /* iropt.c, irgopt.c */ +{ + return libFIRM_opt & OPT_CONTROL_FLOW_STRAIGHTENING; +} + +/** Returns if simplifications in local optimizations setting. */ +int get_opt_control_flow_weak_simplification(void) /* iropt.c, irgopt.c */ +{ + return libFIRM_opt & OPT_CONTROL_FLOW_WEAK_SIMPLIFICATION; +} + +/** Returns strong if and loop simplification setting */ +int get_opt_control_flow_strong_simplification(void) /* irgopt.c */ +{ + return libFIRM_opt & OPT_CONTROL_FLOW_STRONG_SIMPLIFICATION; +} + +/** Returns whether critical edges are removed */ +int get_opt_critical_edges(void) /* irgopt.c */ +{ + return libFIRM_opt & OPT_CRITICAL_EDGES; +} + +/** Returns reassociation setting. */ +int get_opt_reassociation(void) /* iropt.c */ +{ + return libFIRM_opt & OPT_REASSOCIATION; +} + +/** Returns dead node elimination setting. */ +int get_opt_dead_node_elimination(void) /* irgopt.c */ +{ + return libFIRM_opt & OPT_DEAD_NODE_ELIMINATION; +} + +/** Returns global optimization setting */ +int get_opt_optimize(void) /* iropt.c, irgopt.c */ +{ + return libFIRM_opt & OPT_OPTIMIZED; +} + +/** Returns inlining setting. */ /* how appropriate */ +int get_opt_inline(void) /* irgopt.c */ +{ + return libFIRM_opt & OPT_INLINE; +} + +int get_opt_dyn_meth_dispatch(void) /* cgana.c */ +{ + return libFIRM_opt & OPT_DYN_METH_DISPATCH; +} + +int get_opt_normalize(void) /* irgopt.c, irnode.c, iropt.c */ +{ + return libFIRM_opt & OPT_NORMALIZE; +} + +# endif /* not defined USE_GCC_INLINE */