irop: Constify get_op_ops().
[libfirm] / include / libfirm / iropt.h
1 /*
2  * This file is part of libFirm.
3  * Copyright (C) 2012 University of Karlsruhe.
4  */
5
6 /**
7  * @file
8  * @brief   iropt --- optimizations of an ir node.
9  * @author  Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Michael Beck
10  */
11 #ifndef FIRM_IR_IROPT_H
12 #define FIRM_IR_IROPT_H
13
14 #include "firm_types.h"
15 #include "begin.h"
16
17 /**
18  * @ingroup iroptimize
19  * @defgroup iropt  Local Optimizations
20  * @{
21  */
22
23 /**
24  * The Floating point model.
25  *
26  * Several basic properties are defined:
27  * - fp_explicit_rounding
28  * - fp_strict_algebraic
29  * - fp_contradictions
30  * - fp_strict_eval_order
31  * - fp_exceptions
32  * - fp_environment_access
33  *
34  * From those basic properties three general models are defined,
35  * compatible to the VC8 compiler:
36  * - fp_model_precise:
37  *     Default mode. Associative and distributive law forbidden unless a transformation
38  *     is guaranteed to produce the same result.
39  *     No FPU environment access. No FP exception semantics.
40  * - fp_model_strict:
41  *     Slowest mode. Additionally to fp_model_precise allows correct handling of
42  *     FP exceptions and FPU environment access.
43  * - fp_model_fast:
44  *     Fastest mode. Associative and distributive law allowed at the expense
45  *     of floating point accuracy and correctness. Explicit rounding is disabled.
46  */
47 typedef enum fp_model_t {
48         fp_explicit_rounding  = (1u << 0),  /**< Explicit rounding at assignments, typecasts, return
49                                           and function calls. Conv nodes may NOT be removed, even
50                                           if they look useless. */
51         fp_strict_algebraic   = (1u << 1),  /**< Strict adherence to non-associative and non-distributive
52                                           algebra unless the same result is guaranteed. */
53         fp_contradictions     = (1u << 2),  /**< FP contradictions are enabled. Only for backend. */
54         fp_strict_eval_order  = (1u << 3),  /**< FP instructions must be strict evaluated in given order. */
55         fp_exceptions         = (1u << 4),  /**< FP exceptions are supported. No reordering that changes
56                                           the exception flow are allowed. Backends must generate
57                                           synchronized exception code. */
58         fp_environment_access = (1u << 5),  /**< FPU environment can be accessed. Even Constant folding
59                                           cannot be done. */
60
61         /** Precise floating point model. Default. */
62         fp_model_precise = fp_explicit_rounding|fp_strict_algebraic|fp_contradictions,
63         /** Strict floating point model. */
64         fp_model_strict  = fp_explicit_rounding|fp_strict_algebraic|fp_strict_eval_order|
65                            fp_exceptions|fp_environment_access,
66         /** Fast floating point model. */
67         fp_model_fast    = fp_contradictions
68 } fp_model_t;
69
70 /** If the expression referenced can be evaluated statically
71  *  computed_value returns a tarval representing the result.
72  *  Else returns tarval_bad. */
73 FIRM_API ir_tarval *computed_value(const ir_node *n);
74
75 /** Applies all optimizations to n that are expressible as a pattern
76  *  in Firm, i.e., they need not a walk of the graph.
77  *  Returns a better node for n.  Does not free n -- other nodes could
78  *  reference n.
79  *
80  *  An equivalent optimization is applied in the constructors defined in
81  *  ircons.ch.  There n is freed if a better node could be found.
82  */
83 FIRM_API ir_node *optimize_in_place(ir_node *n);
84
85 /**
86  * checks whether 1 value is the negated other value
87  */
88 FIRM_API int ir_is_negated_value(const ir_node *a, const ir_node *b);
89
90 /**
91  * (conservatively) approximates all possible relations when comparing
92  * the value @p left and @p right
93  */
94 FIRM_API ir_relation ir_get_possible_cmp_relations(const ir_node *left,
95                                                    const ir_node *right);
96
97 /** @} */
98
99 #include "end.h"
100
101 #endif