GCC Middle and Back End API Reference
|
#include <sreal.h>
Public Member Functions | |
sreal () | |
sreal (int64_t sig, int exp=0) | |
void | dump (FILE *) const |
int64_t | to_int () const |
int64_t | to_nearest_int () const |
double | to_double () const |
void | stream_out (struct output_block *) |
sreal | operator+ (const sreal &other) const |
sreal | operator- (const sreal &other) const |
sreal | operator* (const sreal &other) const |
sreal | operator/ (const sreal &other) const |
bool | operator< (const sreal &other) const |
bool | operator== (const sreal &other) const |
sreal | operator- () const |
sreal | shift (int s) const |
Static Public Member Functions | |
static sreal | stream_in (class lto_input_block *) |
static sreal | min () |
static sreal | max () |
Private Member Functions | |
void | normalize (int64_t new_sig, signed int new_exp) |
void | normalize_up (int64_t new_sig, signed int new_exp) |
void | normalize_down (int64_t new_sig, signed int new_exp) |
void | shift_right (int amount) |
Static Private Member Functions | |
static sreal | signedless_plus (const sreal &a, const sreal &b, bool negative) |
static sreal | signedless_minus (const sreal &a, const sreal &b, bool negative) |
Private Attributes | |
int32_t | m_sig |
signed int | m_exp |
Structure for holding a simple real number.
|
inline |
|
inline |
References exp(), and normalize().
void sreal::dump | ( | FILE * | file | ) | const |
Simple data type for real numbers for the GNU compiler. Copyright (C) 2002-2024 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>.
This library supports real numbers; inf and nan are NOT supported. It is written to be simple and fast. Value of sreal is x = sig * 2 ^ exp where sig = significant (for < 64-bit machines sig = sig_lo + sig_hi * 2 ^ SREAL_PART_BITS) exp = exponent One uint64_t is used for the significant. Only a half of significant bits is used (in normalized sreals) so that we do not have problems with overflow, for example when c->sig = a->sig * b->sig. So the precision is 32-bit. Invariant: The numbers are normalized before and after each call of sreal_*. Normalized sreals: All numbers (except zero) meet following conditions: SREAL_MIN_SIG <= sig && sig <= SREAL_MAX_SIG -SREAL_MAX_EXP <= exp && exp <= SREAL_MAX_EXP If the number would be too large, it is set to upper bounds of these conditions. If the number is zero or would be too small it meets following conditions: sig == 0 && exp == -SREAL_MAX_EXP
Print the content of struct sreal.
References m_exp, m_sig, and PRIi64.
Referenced by debug().
|
inlinestatic |
References m_exp, m_sig, max(), SREAL_MAX_EXP, and SREAL_MAX_SIG.
Referenced by edge_badness(), slpg_layout_cost::impossible(), slpg_layout_cost::is_possible(), and max().
|
inlinestatic |
References m_exp, m_sig, min(), SREAL_MAX_EXP, and SREAL_MAX_SIG.
Referenced by min(), and recursive_inlining().
|
inlineprivate |
Normalize *this; the hot path.
References absu_hwi(), m_exp, m_sig, normalize_down(), normalize_up(), SREAL_MAX_EXP, SREAL_MAX_SIG, and SREAL_MIN_SIG.
Referenced by operator*(), and sreal().
|
inlineprivate |
Make significant to be <= SREAL_MAX_SIG. Make this separate method so inliner can handle hot path better.
References absu_hwi(), floor_log2(), gcc_checking_assert, m_exp, m_sig, shift(), SREAL_MAX_EXP, SREAL_MAX_SIG, SREAL_MIN_SIG, SREAL_PART_BITS, and SREAL_SIGN.
Referenced by normalize().
|
inlineprivate |
Make significant to be >= SREAL_MIN_SIG. Make this separate method so inliner can handle hot path better.
References absu_hwi(), floor_log2(), gcc_checking_assert, m_exp, m_sig, shift(), SREAL_MAX_EXP, SREAL_MIN_SIG, SREAL_PART_BITS, and SREAL_SIGN.
Referenced by normalize().
Return *this * other.
References absu_hwi(), m_exp, m_sig, normalize(), r, SREAL_MAX_EXP, and SREAL_MIN_SIG.
Return *this + other.
References m_exp, m_sig, r, shift_right(), and SREAL_BITS.
Return *this - other.
References m_exp, m_sig, r, shift_right(), and SREAL_BITS.
Return *this / other.
References gcc_checking_assert, m_exp, m_sig, r, SREAL_ABS, SREAL_PART_BITS, and SREAL_SIGN.
|
inline |
References gcc_checking_assert, m_exp, m_sig, and SREAL_MAX_EXP.
Referenced by edge_badness(), normalize_down(), normalize_up(), operator<<(), and operator>>().
|
private |
Shift this right by S bits. Needed: 0 < S <= SREAL_BITS. When the most significant bit shifted out is 1, add 1 to this (rounding).
References gcc_checking_assert, m_exp, m_sig, SREAL_BITS, and SREAL_MAX_EXP.
Referenced by operator+(), and operator-().
|
staticprivate |
|
staticprivate |
|
static |
Read sreal value from IB.
References m_exp, m_sig, and streamer_read_hwi().
Referenced by inline_read_section().
void sreal::stream_out | ( | struct output_block * | ob | ) |
Stream sreal value to OB.
References m_exp, m_sig, and streamer_write_hwi().
Referenced by ipa_fn_summary_write().
double sreal::to_double | ( | ) | const |
Return value of *this as double. This should be used for debug output only.
References ldexp(), m_exp, and m_sig.
Referenced by ipa_fn_summary::account_size_time(), analyze_function_body(), compute_branch_probabilities(), vect_optimize_slp_pass::dump(), dump_overall_stats(), dump_split_point(), edge_badness(), estimate_bb_frequencies(), estimate_calls_size_and_time(), estimate_local_effects(), ipa_call_context::estimate_size_and_time(), execute_split_functions(), expand_call_inline(), gimple_account_profile_record(), good_cloning_opportunity_p(), inline_small_functions(), ipa_dump_fn_summary(), maybe_flat_loop_profile(), ipcp_lattice< valtype >::print(), print_loop_info(), profile_record_check_consistency(), propagate_freq(), rtl_account_profile_record(), scale_loop_profile(), and update_edge_key().
int64_t sreal::to_int | ( | ) | const |
Return integer value of *this.
References INTTYPE_MAXIMUM, m_exp, m_sig, SREAL_ABS, SREAL_BITS, SREAL_PART_BITS, and SREAL_SIGN.
Referenced by good_cloning_opportunity_p().
int64_t sreal::to_nearest_int | ( | ) | const |
Return nearest integer value of *this.
References INTTYPE_MAXIMUM, m_exp, m_sig, SREAL_ABS, SREAL_BITS, SREAL_PART_BITS, and SREAL_SIGN.
Referenced by branch_prob(), estimate_bb_frequencies(), estimate_numbers_of_iterations(), expected_loop_iterations_unbounded(), get_estimated_loop_iterations(), and maybe_flat_loop_profile().
|
private |
Referenced by dump(), max(), min(), normalize(), normalize_down(), normalize_up(), operator*(), operator+(), operator-(), operator/(), operator<(), operator==(), shift(), shift_right(), stream_in(), stream_out(), to_double(), to_int(), and to_nearest_int().
|
private |
Referenced by dump(), max(), min(), normalize(), normalize_down(), normalize_up(), operator*(), operator+(), operator-(), operator-(), operator/(), operator<(), operator==(), shift(), shift_right(), stream_in(), stream_out(), to_double(), to_int(), and to_nearest_int().