2 * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * File name: ir/ir/iropt.h
23 * Purpose: iropt --- optimizations of an ir node.
24 * Author: Martin Trapp, Christian Schaefer
25 * Modified by: Goetz Lindenmaier, Michael Beck
28 * Copyright: (c) 1998-2003 Universität Karlsruhe
34 * Declarations for optimizations of an ir node.
36 * @author Martin Trapp, Christian Schaefer
38 #ifndef _FIRM_IR_IROPT_H_
39 #define _FIRM_IR_IROPT_H_
41 #include "firm_types.h"
44 * The Floating point model.
46 * Several basic properties are defined:
47 * - fp_explicit_rounding
48 * - fp_strict_algebraic
50 * - fp_strict_eval_order
52 * - fp_environment_access
54 * From those basic properties three general models are defined,
55 * compatible to the VC8 compiler:
57 * Default mode. Associative and distributive law forbidden unless a transformation
58 * is guaranteed to produce the same result.
59 * No FPU environment access. No FP exception semantics.
61 * Slowest mode. Additionally to fp_model_precise allows correct handling of
62 * FP exceptions and FPU environment access.
64 * Fastest mode. Associative and distributive law allowed at the expense
65 * of floating point accuracy and correctness. Explicit rounding is disabled.
67 typedef enum _fp_model_t {
68 fp_explicit_rounding = 1, /**< Explicit rounding at assignments, typecasts, return
69 and function calls. Conv nodes may NOT be removed, even
70 if they look useless. */
71 fp_strict_algebraic = 2, /**< Strict adherence to non-associative and non-distributive
72 algebra unless the same result is guaranteed. */
73 fp_contradictions = 4, /**< FP contradictions are enabled. Only for backend. */
74 fp_strict_eval_order = 8, /**< FP instructions must be strict evaluated in given order. */
75 fp_exceptions = 16, /**< FP exceptions are supported. No reordering that changes
76 the exception flow are allowed. Backends must generate
77 synchronized exception code. */
78 fp_environment_access = 32, /**< FPU environment can be accessed. Even Constant folding
81 /** Precise floating point model. Default. */
82 fp_model_precise = fp_explicit_rounding|fp_strict_algebraic|fp_contradictions,
83 /** Strict floating point model. */
84 fp_model_strict = fp_explicit_rounding|fp_strict_algebraic|fp_strict_eval_order|
85 fp_exceptions|fp_environment_access,
86 /** Fast floating point model. */
87 fp_model_fast = fp_contradictions,
90 /** If the expression referenced can be evaluated statically
91 * computed_value returns a tarval representing the result.
92 * Else returns tarval_bad. */
93 tarval *computed_value(ir_node *n);
95 /** Applies all optimizations to n that are expressible as a pattern
96 * in Firm, i.e., they need not a walk of the graph.
97 * Returns a better node for n. Does not free n -- other nodes could
100 * An equivalent optimization is applied in the constructors defined in
101 * ircons.ch. There n is freed if a better node could be found.
103 ir_node *optimize_in_place(ir_node *n);
105 #endif /* _FIRM_IR_IROPT_H_ */