GCC Middle and Back End API Reference
realmpfr.h
Go to the documentation of this file.
1/* Definitions of floating-point conversion from compiler
2 internal format to MPFR.
3 Copyright (C) 2010-2024 Free Software Foundation, Inc.
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
11
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
20
21#ifndef GCC_REALGMP_H
22#define GCC_REALGMP_H
23
24#include <mpfr.h>
25#include <mpc.h>
26
28{
29public:
31 explicit auto_mpfr (mpfr_prec_t prec) { mpfr_init2 (m_mpfr, prec); }
33
34 operator mpfr_t& () { return m_mpfr; }
35 mpfr_ptr operator-> () { return m_mpfr; }
36
37 auto_mpfr (const auto_mpfr &) = delete;
38 auto_mpfr &operator= (const auto_mpfr &) = delete;
39
40#if GCC_VERSION < 4008 || GCC_VERSION >= 5000
41 /* GCC 4.8 and 4.9 don't support this, only fixed in PR62101 for 5.0. */
42 friend void mpfr_clear (auto_mpfr&) = delete;
43 friend void mpfr_init (auto_mpfr&) = delete;
44 friend void mpfr_init2 (auto_mpfr&, mpfr_prec_t) = delete;
45#endif
46
47private:
48 mpfr_t m_mpfr;
49};
50
51/* Convert between MPFR and REAL_VALUE_TYPE. The caller is
52 responsible for initializing and clearing the MPFR parameter. */
53
54extern void real_from_mpfr (REAL_VALUE_TYPE *, mpfr_srcptr, tree, mpfr_rnd_t);
55extern void real_from_mpfr (REAL_VALUE_TYPE *, mpfr_srcptr,
56 const real_format *, mpfr_rnd_t);
57extern void mpfr_from_real (mpfr_ptr, const REAL_VALUE_TYPE *, mpfr_rnd_t);
58
59#endif /* ! GCC_REALGMP_H */
Definition realmpfr.h:28
mpfr_t m_mpfr
Definition realmpfr.h:48
friend void mpfr_clear(auto_mpfr &)=delete
mpfr_ptr operator->()
Definition realmpfr.h:35
friend void mpfr_init(auto_mpfr &)=delete
friend void mpfr_init2(auto_mpfr &, mpfr_prec_t)=delete
~auto_mpfr()
Definition realmpfr.h:32
auto_mpfr & operator=(const auto_mpfr &)=delete
auto_mpfr(mpfr_prec_t prec)
Definition realmpfr.h:31
auto_mpfr(const auto_mpfr &)=delete
auto_mpfr()
Definition realmpfr.h:30
union tree_node * tree
Definition coretypes.h:97
#define REAL_VALUE_TYPE
Definition real.h:68
void real_from_mpfr(REAL_VALUE_TYPE *, mpfr_srcptr, tree, mpfr_rnd_t)
Definition realmpfr.cc:108
void mpfr_from_real(mpfr_ptr, const REAL_VALUE_TYPE *, mpfr_rnd_t)
Definition realmpfr.cc:31
Definition real.h:119