1/*******************************************************************\
3Module: Symbolic Execution
5Author: Daniel Kroening, kroening@kroening.com
7\*******************************************************************/
56 // FMA needs rounding mode added (3 operands -> 4)
82 for(
const auto &op : expr.
operands())
97 // Note that we do the recursion twice here; once in
98 // `have_to_adjust_float_expressions` and once here. Presumably this is to
99 // avoid breaking sharing (calling the non-const operands() function breaks
117 "arithmetic operations must have two or more operands");
119 // make sure we have binary expressions
126 // now add rounding mode
138 // Add rounding mode to FMA
155 // Casts from bigger to smaller float-type might round.
156 // For smaller to bigger it is strictly redundant but
157 // we leave this optimisation until later to simplify
158 // the representation.
168 // casts from integer to float-type might round
177 // casts from bool or c_bool to float-type do not need rounding
184 // In C, casts from float to integer always round to zero,
185 // irrespectively of the rounding mode that is currently set.
186 // We will have to consider other programming languages
190 * 6.3.1.4 Real floating and integer
191 * 1 When a finite value of real floating type is converted
192 * to an integer type other than _Bool, the fractional part
193 * is discarded (i.e., the value is truncated toward zero).
220 for(
auto &i : goto_function.body.instructions)
221 i.transform([&ns](
exprt expr) -> std::optional<exprt> {
static bool have_to_adjust_float_expressions(const exprt &expr)
Iterate over an expression and check it or any of its subexpressions are floating point operations th...
irep_idt rounding_mode_identifier()
Return the identifier of the program symbol used to store the current rounding mode.
void adjust_float_expressions(exprt &expr, const exprt &rounding_mode)
Replaces arithmetic operations and typecasts involving floating point numbers with their equivalent f...
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
typet & type()
Return the type of the expression.
const source_locationt & source_location() const
source_locationt & add_source_location()
A collection of goto functions.
function_mapt function_map
::goto_functiont goto_functiont
symbol_tablet symbol_table
Symbol table.
goto_functionst goto_functions
GOTO functions.
const irep_idt & id() const
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
Expression to hold a symbol (variable)
Semantic type conversion.
The type of an expression, extends irept.
exprt make_binary(const exprt &expr)
splits an expression with >=3 operands into nested binary expressions
Deprecated expression utility functions.
API to expression classes for floating-point arithmetic.
const ieee_float_op_exprt & to_ieee_float_op_expr(const exprt &expr)
Cast an exprt to an ieee_float_op_exprt.
const floatbv_fma_exprt & to_floatbv_fma_expr(const exprt &expr)
const floatbv_typecast_exprt & to_floatbv_typecast_expr(const exprt &expr)
Cast an exprt to a floatbv_typecast_exprt.
#define CHECK_RETURN(CONDITION)
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
API to expression classes.
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
const complex_typet & to_complex_type(const typet &type)
Cast a typet to a complex_typet.