diff --git a/src/util/floatbv_expr.h b/src/util/floatbv_expr.h index fdfdc58d015..c34f1c15af5 100644 --- a/src/util/floatbv_expr.h +++ b/src/util/floatbv_expr.h @@ -438,6 +438,72 @@ inline ieee_float_op_exprt &to_ieee_float_op_expr(exprt &expr) return ret; } +/// \brief IEEE floating-point mod +/// +/// Note that this expression does not have a rounding mode. +class floatbv_mod_exprt : public binary_exprt +{ +public: + floatbv_mod_exprt(exprt _lhs, exprt _rhs) + : binary_exprt(_lhs, ID_floatbv_mod, _rhs, _lhs.type()) + { + } +}; + +/// \brief Cast an exprt to a \ref floatbv_mod_exprt +/// +/// \a expr must be known to be \ref floatbv_mod_exprt. +/// +/// \param expr: Source expression +/// \return Object of type \ref floatbv_mod_exprt +inline const floatbv_mod_exprt &to_floatbv_mod_expr(const exprt &expr) +{ + PRECONDITION(expr.id() == ID_floatbv_mod); + floatbv_mod_exprt::check(expr); + return static_cast(expr); +} + +/// \copydoc to_floatbv_mod_expr(const exprt &) +inline floatbv_mod_exprt &to_floatbv_mod_expr(exprt &expr) +{ + PRECONDITION(expr.id() == ID_floatbv_mod); + floatbv_mod_exprt::check(expr); + return static_cast(expr); +} + +/// \brief IEEE floating-point rem +/// +/// Note that this expression does not have a rounding mode. +class floatbv_rem_exprt : public binary_exprt +{ +public: + floatbv_rem_exprt(exprt _lhs, exprt _rhs) + : binary_exprt(_lhs, ID_floatbv_rem, _rhs, _lhs.type()) + { + } +}; + +/// \brief Cast an exprt to a \ref floatbv_rem_exprt +/// +/// \a expr must be known to be \ref floatbv_rem_exprt. +/// +/// \param expr: Source expression +/// \return Object of type \ref floatbv_rem_exprt +inline const floatbv_rem_exprt &to_floatbv_rem_expr(const exprt &expr) +{ + PRECONDITION(expr.id() == ID_floatbv_rem); + floatbv_rem_exprt::check(expr); + return static_cast(expr); +} + +/// \copydoc to_floatbv_rem_expr(const exprt &) +inline floatbv_rem_exprt &to_floatbv_rem_expr(exprt &expr) +{ + PRECONDITION(expr.id() == ID_floatbv_rem); + floatbv_rem_exprt::check(expr); + return static_cast(expr); +} + /// \brief returns the a rounding mode expression for a given /// IEEE rounding mode, encoded using the recommendation in /// C11 5.2.4.2.2 diff --git a/src/util/format_expr.cpp b/src/util/format_expr.cpp index 8b61a436aab..eb32bf90351 100644 --- a/src/util/format_expr.cpp +++ b/src/util/format_expr.cpp @@ -354,7 +354,8 @@ void format_expr_configt::setup() expr_map[ID_floatbv_minus] = ternary_expr; expr_map[ID_floatbv_mult] = ternary_expr; expr_map[ID_floatbv_div] = ternary_expr; - expr_map[ID_floatbv_mod] = ternary_expr; + expr_map[ID_floatbv_mod] = binary_infix_expr; + expr_map[ID_floatbv_rem] = binary_infix_expr; expr_map[ID_constant] = [](std::ostream &os, const exprt &expr) -> std::ostream & {