renamed type opcode to ir_opcode
[libfirm] / ir / ir / iropt.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/ir/iropt.h
4  * Purpose:     iropt --- optimizations of an ir node.
5  * Author:      Martin Trapp, Christian Schaefer
6  * Modified by: Goetz Lindenmaier, Michael Beck
7  * Created:
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 1998-2003 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12
13 /**
14  * @file iropt.h
15  *
16  * Declarations for optimizations of an ir node.
17  *
18  * @author Martin Trapp, Christian Schaefer
19  */
20 #ifndef _FIRM_IR_IROPT_H_
21 #define _FIRM_IR_IROPT_H_
22
23 #include "firm_types.h"
24
25 /**
26  * The Floating point model.
27  *
28  * Several basic properties are defined:
29  * - fp_explicit_rounding
30  * - fp_strict_algebraic
31  * - fp_contradictions
32  * - fp_strict_eval_order
33  * - fp_exceptions
34  * - fp_environment_access
35  *
36  * From those basic properties three general models are defined,
37  * compatible to the VC8 compiler:
38  * - fp_model_precise:
39  *     Default mode. Associative and distributive law forbidden unless a transformation
40  *     is guaranteed to produce the same result.
41  *     No FPU environment access. No FP exception semantics.
42  * - fp_model_strict:
43  *     Slowest mode. Additionally to fp_model_precise allows correct handling of
44  *     FP exceptions and FPU environment access.
45  * - fp_model_fast:
46  *     Fastest mode. Associative and distributive law allowed at the expense
47  *     of floating point accuracy and correctness. Explicit rounding is disabled.
48  */
49 typedef enum _fp_model_t {
50   fp_explicit_rounding  =  1,  /**< Explicit rounding at assignments, typecasts, return
51                                     and function calls. Conv nodes may NOT be removed, even
52                                     if they look useless. */
53   fp_strict_algebraic   =  2,  /**< Strict adherence to non-associative and non-distributive
54                                     algebra unless the same result is guaranteed. */
55   fp_contradictions     =  4,  /**< FP contradictions are enabled. Only for backend. */
56   fp_strict_eval_order  =  8,  /**< FP instructions must be strict evaluated in given order. */
57   fp_exceptions         = 16,  /**< FP exceptions are supported. No reordering that changes
58                                     the exception flow are allowed. Backends must generate
59                                     synchronized exception code. */
60   fp_environment_access = 32,  /**< FPU environment can be accessed. Even Constant folding
61                                     cannot be done. */
62
63   /** Precise floating point model. Default. */
64   fp_model_precise = fp_explicit_rounding|fp_strict_algebraic|fp_contradictions,
65   /** Strict floating point model. */
66   fp_model_strict  = fp_explicit_rounding|fp_strict_algebraic|fp_strict_eval_order|
67                      fp_exceptions|fp_environment_access,
68   /** Fast floating point model. */
69   fp_model_fast    = fp_contradictions,
70 } fp_model_t;
71
72 /** If the expression referenced can be evaluated statically
73  *  computed_value returns a tarval representing the result.
74  *  Else returns tarval_bad. */
75 tarval *computed_value(ir_node *n);
76
77 /** Applies all optimizations to n that are expressible as a pattern
78  *  in Firm, i.e., they need not a walk of the graph.
79  *  Returns a better node for n.  Does not free n -- other nodes could
80  *  reference n.
81  *
82  *  An equivalent optimization is applied in the constructors defined in
83  *  ircons.ch.  There n is freed if a better node could be found.
84  */
85 ir_node *optimize_in_place(ir_node *n);
86
87 #endif /* _FIRM_IR_IROPT_H_ */