GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "realmpfr.h"
#include "tree.h"
#include "stor-layout.h"
#include "options.h"
#include "fold-const.h"
#include "fold-const-call.h"
#include "case-cfn-macros.h"
#include "tm.h"
#include "builtins.h"
#include "gimple-expr.h"
#include "tree-vector-builder.h"
Functions | |
static bool | integer_cst_p (tree t) |
static bool | real_cst_p (tree t) |
static bool | complex_cst_p (tree t) |
static bool | size_t_cst_p (tree t, unsigned HOST_WIDE_INT *size_out) |
tree | build_cmp_result (tree type, int res) |
static bool | do_mpfr_ckconv (real_value *result, mpfr_srcptr m, bool inexact, const real_format *format) |
static bool | do_mpfr_arg1 (real_value *result, int(*func)(mpfr_ptr, mpfr_srcptr, mpfr_rnd_t), const real_value *arg, const real_format *format) |
static bool | do_mpfr_sincos (real_value *result_sin, real_value *result_cos, const real_value *arg, const real_format *format) |
static bool | do_mpfr_arg2 (real_value *result, int(*func)(mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t), const real_value *arg0, const real_value *arg1, const real_format *format) |
static bool | do_mpfr_arg2 (real_value *result, int(*func)(mpfr_ptr, long, mpfr_srcptr, mpfr_rnd_t), const wide_int_ref &arg0, const real_value *arg1, const real_format *format) |
static bool | do_mpfr_arg3 (real_value *result, int(*func)(mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t), const real_value *arg0, const real_value *arg1, const real_value *arg2, const real_format *format) |
static bool | do_mpc_ckconv (real_value *result_real, real_value *result_imag, mpc_srcptr m, bool inexact, const real_format *format) |
static bool | do_mpc_arg1 (real_value *result_real, real_value *result_imag, int(*func)(mpc_ptr, mpc_srcptr, mpc_rnd_t), const real_value *arg_real, const real_value *arg_imag, const real_format *format) |
static bool | do_mpc_arg2 (real_value *result_real, real_value *result_imag, int(*func)(mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t), const real_value *arg0_real, const real_value *arg0_imag, const real_value *arg1_real, const real_value *arg1_imag, const real_format *format) |
static bool | fold_const_logb (real_value *result, const real_value *arg, const real_format *format) |
static bool | fold_const_significand (real_value *result, const real_value *arg, const real_format *format) |
static bool | fold_const_conversion (wide_int *result, void(*fn)(real_value *, format_helper, const real_value *), const real_value *arg, unsigned int precision, const real_format *format) |
static bool | fold_const_pow (real_value *result, const real_value *arg0, const real_value *arg1, const real_format *format) |
static bool | fold_const_nextafter (real_value *result, const real_value *arg0, const real_value *arg1, const real_format *format) |
static bool | fold_const_builtin_load_exponent (real_value *result, const real_value *arg0, const wide_int_ref &arg1, const real_format *format) |
static tree | fold_const_builtin_nan (tree type, tree arg, bool quiet) |
static tree | fold_const_reduction (tree type, tree arg, tree_code code) |
static tree | fold_const_vec_convert (tree ret_type, tree arg) |
static tree | fold_while_ult (tree type, poly_uint64 arg0, poly_uint64 arg1) |
static bool | fold_const_call_ss (real_value *result, combined_fn fn, const real_value *arg, const real_format *format) |
static bool | fold_const_call_ss (wide_int *result, combined_fn fn, const real_value *arg, unsigned int precision, const real_format *format) |
static bool | fold_const_call_ss (wide_int *result, combined_fn fn, const wide_int_ref &arg, unsigned int precision, tree arg_type) |
static bool | fold_const_call_cs (real_value *result_real, real_value *result_imag, combined_fn fn, const real_value *arg, const real_format *format) |
static bool | fold_const_call_sc (real_value *result, combined_fn fn, const real_value *arg_real, const real_value *arg_imag, const real_format *format) |
static bool | fold_const_call_cc (real_value *result_real, real_value *result_imag, combined_fn fn, const real_value *arg_real, const real_value *arg_imag, const real_format *format) |
static tree | fold_const_call_1 (combined_fn fn, tree type, tree arg) |
tree | fold_const_call (combined_fn fn, tree type, tree arg) |
static tree | fold_const_fold_left (tree type, tree arg0, tree arg1, tree_code code) |
static bool | fold_const_call_sss (real_value *result, combined_fn fn, const real_value *arg0, const real_value *arg1, const real_format *format) |
static bool | fold_const_call_sss (real_value *result, combined_fn fn, const real_value *arg0, const wide_int_ref &arg1, const real_format *format) |
static bool | fold_const_call_sss (real_value *result, combined_fn fn, const wide_int_ref &arg0, const real_value *arg1, const real_format *format) |
static bool | fold_const_call_sss (wide_int *result, combined_fn fn, const wide_int_ref &arg0, const wide_int_ref &arg1, unsigned int precision, tree arg_type) |
static bool | fold_const_call_ccc (real_value *result_real, real_value *result_imag, combined_fn fn, const real_value *arg0_real, const real_value *arg0_imag, const real_value *arg1_real, const real_value *arg1_imag, const real_format *format) |
static tree | fold_const_call_1 (combined_fn fn, tree type, tree arg0, tree arg1) |
tree | fold_const_call (combined_fn fn, tree type, tree arg0, tree arg1) |
static bool | fold_const_call_ssss (real_value *result, combined_fn fn, const real_value *arg0, const real_value *arg1, const real_value *arg2, const real_format *format) |
static tree | fold_const_call_1 (combined_fn fn, tree type, tree arg0, tree arg1, tree arg2) |
tree | fold_const_call (combined_fn fn, tree type, tree arg0, tree arg1, tree arg2) |
RES is the result of a comparison in which < 0 means "less", 0 means "equal" and > 0 means "more". Canonicalize it to -1, 0 or 1 and return it in type TYPE.
References build_int_cst().
Referenced by fold_const_call(), fold_const_call(), and gimple_fold_builtin_string_compare().
References TREE_CODE.
Referenced by fold_const_call_1(), and fold_const_call_1().
|
static |
Try to evaluate: RESULT = f (ARG) in format FORMAT, given that FUNC is the mpc implementation of f. Return true on success. Both RESULT and ARG are represented as real and imaginary pairs.
References real_format::b, do_mpc_ckconv(), mpfr_from_real(), real_format::p, real_isfinite(), and real_format::round_towards_zero.
Referenced by fold_const_call_cc().
|
static |
Try to evaluate: RESULT = f (ARG0, ARG1) in format FORMAT, given that FUNC is the mpc implementation of f. Return true on success. RESULT, ARG0 and ARG1 are represented as real and imaginary pairs.
References do_mpc_ckconv(), mpfr_from_real(), real_format::p, real_isfinite(), and real_format::round_towards_zero.
Referenced by fold_const_call_ccc().
|
static |
M is the result of trying to constant-fold an expression (starting with clear MPFR flags) and INEXACT says whether the result in M is exact or inexact. Return true if M can be used as a constant-folded result in which the real and imaginary parts have format FORMAT. Store those parts in *RESULT_REAL and *RESULT_IMAG if so.
References real_convert(), real_from_mpfr(), real_identical(), real_isfinite(), REAL_VALUE_TYPE, and rvc_zero.
Referenced by do_mpc_arg1(), and do_mpc_arg2().
|
static |
Try to evaluate: *RESULT = f (*ARG) in format FORMAT, given that FUNC is the MPFR implementation of f. Return true on success.
References real_format::b, do_mpfr_ckconv(), mpfr_from_real(), real_format::p, real_isfinite(), and real_format::round_towards_zero.
Referenced by fold_const_call_ss().
|
static |
Try to evaluate: *RESULT = f (ARG0, *ARG1) in format FORMAT, given that FUNC is the MPFR implementation of f. Return true on success.
References real_format::b, do_mpfr_ckconv(), mpfr_from_real(), real_format::p, real_isfinite(), real_format::round_towards_zero, and generic_wide_int< storage >::to_shwi().
|
static |
Try to evaluate: *RESULT = f (*ARG0, *ARG1) in format FORMAT, given that FUNC is the MPFR implementation of f. Return true on success.
References real_format::b, do_mpfr_ckconv(), mpfr_from_real(), NULL, real_format::p, real_isfinite(), and real_format::round_towards_zero.
Referenced by fold_const_call_sc(), fold_const_call_sss(), fold_const_call_sss(), and fold_const_pow().
|
static |
Try to evaluate: *RESULT = f (*ARG0, *ARG1, *ARG2) in format FORMAT, given that FUNC is the MPFR implementation of f. Return true on success.
References real_format::b, do_mpfr_ckconv(), mpfr_from_real(), NULL, real_format::p, real_isfinite(), and real_format::round_towards_zero.
Referenced by fold_const_call_ssss().
|
static |
M is the result of trying to constant-fold an expression (starting with clear MPFR flags) and INEXACT says whether the result in M is exact or inexact. Return true if M can be used as a constant-folded result in format FORMAT, storing the value in *RESULT if so.
References real_convert(), real_from_mpfr(), real_identical(), real_isfinite(), REAL_VALUE_TYPE, and rvc_zero.
Referenced by do_mpfr_arg1(), do_mpfr_arg2(), do_mpfr_arg2(), do_mpfr_arg3(), and do_mpfr_sincos().
|
static |
Try to evaluate: *RESULT_SIN = sin (*ARG); *RESULT_COS = cos (*ARG); for format FORMAT. Return true on success.
References real_format::b, do_mpfr_ckconv(), mpfr_from_real(), NULL, real_format::p, real_isfinite(), and real_format::round_towards_zero.
Referenced by fold_const_call_cs().
|
static |
Try to evaluate: *RESULT = ldexp (*ARG0, ARG1) in format FORMAT. Return true on success.
References real_format::emax, real_format::emin, wi::ges_p(), wi::les_p(), real_equal(), real_isinf(), real_ldexp(), REAL_VALUE_ISSIGNALING_NAN, real_value_truncate(), REAL_VALUE_TYPE, and generic_wide_int< storage >::to_shwi().
Referenced by fold_const_call_sss().
Fold a call to __builtin_nan or __builtin_nans with argument ARG and return type TYPE. QUIET is true if a quiet rather than signalling NaN is required.
References build_real(), c_getstr(), NULL_TREE, real_nan(), REAL_VALUE_TYPE, and TYPE_MODE.
Referenced by fold_const_call().
tree fold_const_call | ( | combined_fn | fn, |
tree | type, | ||
tree | arg ) |
Try to fold FN (ARG) to a constant. Return the constant on success, otherwise return null. TYPE is the type of the return value.
References build_int_cst(), c_getstr(), CASE_FLT_FN_FLOATN_NX, fold_const_builtin_nan(), fold_const_call_1(), fold_const_reduction(), fold_const_vec_convert(), and NULL_TREE.
Referenced by expand_bitquery(), fold_builtin_1(), fold_builtin_2(), fold_builtin_3(), fold_builtin_sincos(), fully_constant_vn_reference_p(), gimple_resimplify1(), gimple_resimplify2(), gimple_resimplify3(), gimple_simplify(), gimple_simplify(), gimple_simplify(), and vect_recog_pow_pattern().
tree fold_const_call | ( | combined_fn | fn, |
tree | type, | ||
tree | arg0, | ||
tree | arg1 ) |
Try to fold FN (ARG0, ARG1) to a constant. Return the constant on success, otherwise return null. TYPE is the type of the return value.
References arith_overflowed_p(), build_cmp_result(), build_complex(), build_int_cst(), c_getstr(), drop_tree_overflow(), fold_build_pointer_plus_hwi, fold_const_call_1(), fold_const_fold_left(), fold_convert, int_const_binop(), integer_cst_p(), NULL, NULL_TREE, r, target_char_cst_p(), TREE_CODE, TREE_OVERFLOW, TREE_TYPE, and type().
Try to fold FN (ARG0, ARG1, ARG2) to a constant. Return the constant on success, otherwise return null. TYPE is the type of the return value.
References arith_overflowed_p(), build_cmp_result(), build_complex(), build_int_cst(), c_getstr(), drop_tree_overflow(), fold_build_pointer_plus_hwi, fold_const_call_1(), fold_convert, fold_while_ult(), getbyterep(), int_const_binop(), integer_cst_p(), MIN, NULL, NULL_TREE, poly_int_tree_p(), r, SIZE_MAX, size_t_cst_p(), target_char_cst_p(), TREE_CODE, TREE_OVERFLOW, TREE_SIDE_EFFECTS, and TREE_TYPE.
|
static |
Subroutine of fold_const_call, with the same interface. Handle cases where the arguments and result are numerical.
References build_complex(), build_real(), complex_cst_p(), COMPLEX_MODE_P, fold_const_call_cc(), fold_const_call_cs(), fold_const_call_sc(), fold_const_call_ss(), gcc_checking_assert, GET_MODE_INNER, integer_cst_p(), INTEGRAL_TYPE_P, NULL_TREE, real_cst_p(), REAL_MODE_FORMAT, REAL_VALUE_TYPE, SCALAR_FLOAT_MODE_P, SCALAR_INT_MODE_P, wi::to_wide(), TREE_IMAGPART, TREE_REAL_CST_PTR, TREE_REALPART, TREE_TYPE, TYPE_MODE, TYPE_PRECISION, and wide_int_to_tree().
Referenced by fold_const_call(), fold_const_call(), and fold_const_call().
|
static |
Subroutine of fold_const_call, with the same interface. Handle cases where the arguments and result are numerical.
References build_complex(), build_real(), complex_cst_p(), COMPLEX_MODE_P, fold_const_call_ccc(), fold_const_call_sss(), gcc_checking_assert, GET_MODE_INNER, integer_cst_p(), long_double_type_node, NULL_TREE, real_cst_p(), REAL_MODE_FORMAT, REAL_VALUE_TYPE, SCALAR_FLOAT_MODE_P, SCALAR_INT_MODE_P, wi::to_wide(), TREE_IMAGPART, TREE_REAL_CST_PTR, TREE_REALPART, TREE_TYPE, TYPE_MODE, TYPE_PRECISION, and wide_int_to_tree().
Subroutine of fold_const_call, with the same interface. Handle cases where the arguments and result are numerical.
References build_real(), fold_const_call_ssss(), gcc_checking_assert, NULL_TREE, real_cst_p(), REAL_MODE_FORMAT, REAL_VALUE_TYPE, SCALAR_FLOAT_MODE_P, TREE_REAL_CST_PTR, TREE_TYPE, and TYPE_MODE.
|
static |
Try to evaluate: RESULT = fn (ARG) where FORMAT is the format of the real and imaginary parts of RESULT (RESULT_REAL and RESULT_IMAG) and of ARG (ARG_REAL and ARG_IMAG). Return true on success.
References dconst0, dconstinf, do_mpc_arg1(), real_isinf(), and real_value::sign.
Referenced by fold_const_call_1().
|
static |
Try to evaluate: RESULT = fn (ARG0, ARG1) where FORMAT is the format of the real and imaginary parts of RESULT (RESULT_REAL and RESULT_IMAG), of ARG0 (ARG0_REAL and ARG0_IMAG) and of ARG1 (ARG1_REAL and ARG1_IMAG). Return true on success.
References do_mpc_arg2().
Referenced by fold_const_call_1().
|
static |
Try to evaluate: RESULT = FN (*ARG) where FORMAT is the format of ARG and of the real and imaginary parts of RESULT, passed as RESULT_REAL and RESULT_IMAG respectively. Return true on success.
References do_mpfr_sincos().
Referenced by fold_const_call_1().
|
static |
Try to evaluate: *RESULT = fn (ARG) where FORMAT is the format of RESULT and of the real and imaginary parts of ARG, passed as ARG_REAL and ARG_IMAG respectively. Return true on success.
References do_mpfr_arg2().
Referenced by fold_const_call_1().
|
static |
Try to evaluate: *RESULT = FN (*ARG) in format FORMAT. Return true on success.
References dconst0, dconst1, dconstm1, do_mpfr_arg1(), fold_const_logb(), fold_const_significand(), real_ceil(), real_compare(), real_floor(), real_round(), real_roundeven(), real_trunc(), and REAL_VALUE_ISSIGNALING_NAN.
Referenced by fold_const_call_1().
|
static |
Try to evaluate: *RESULT = FN (*ARG) where FORMAT is the format of ARG and PRECISION is the number of significant bits in the result. Return true on success.
References real_format::b, real_value::cl, fold_const_conversion(), wi::one(), real_ceil(), REAL_EXP, real_floor(), real_isfinite(), real_isinf(), real_isnan(), real_isneg(), real_issignaling_nan(), real_round(), rvc_normal, wi::shwi(), real_value::sign, and wi::zero().
|
static |
Try to evaluate: *RESULT = FN (ARG) where ARG_TYPE is the type of ARG and PRECISION is the number of bits in the result. Return true on success.
References arg_type, wi::bswap(), wi::clrsb(), wi::clz(), CLZ_DEFINED_VALUE_AT_ZERO, wi::ctz(), CTZ_DEFINED_VALUE_AT_ZERO, wi::ffs(), wide_int_storage::from(), wi::ne_p(), wi::parity(), wi::popcount(), SCALAR_INT_TYPE_MODE, wi::shwi(), TREE_CODE, TYPE_PRECISION, and TYPE_SIGN.
|
static |
Try to evaluate: *RESULT = FN (*ARG0, *ARG1) in format FORMAT. Return true on success.
References do_mpfr_arg2(), fold_const_nextafter(), fold_const_pow(), and real_copysign().
Referenced by fold_const_call_1().
|
static |
Try to evaluate: *RESULT = FN (*ARG0, ARG1) where FORMAT is the format of *RESULT and *ARG0. Return true on success.
References real_format::b, fold_const_builtin_load_exponent(), real_powi(), REAL_VALUE_ISSIGNALING_NAN, and generic_wide_int< storage >::to_shwi().
|
static |
Try to evaluate: *RESULT = FN (ARG0, *ARG1) where FORMAT is the format of *RESULT and *ARG1. Return true on success.
References dconst0, do_mpfr_arg2(), and real_compare().
|
static |
Try to evaluate: *RESULT = FN (ARG0, ARG1) where ARG_TYPE is the type of ARG0 and PRECISION is the number of bits in the result. Return true on success.
References wi::clz(), wi::ctz(), wi::ne_p(), wi::shwi(), and generic_wide_int< storage >::to_shwi().
|
static |
Try to evaluate: *RESULT = FN (*ARG0, *ARG1, *ARG2) in format FORMAT. Return true on success.
References do_mpfr_arg3(), and real_value_negate().
Referenced by fold_const_call_1().
|
static |
Try to evaluate: *RESULT = f (*ARG) where FORMAT is the format of *ARG and PRECISION is the number of significant bits in the result. Return true on success.
References real_isfinite(), and real_to_integer().
Referenced by fold_const_call_ss().
Fold a call to IFN_FOLD_LEFT_<CODE> (ARG0, ARG1), returning a value of type TYPE.
References const_binop(), CONSTANT_CLASS_P, i, NULL_TREE, TREE_CODE, VECTOR_CST_ELT, and VECTOR_CST_NELTS.
Referenced by fold_const_call().
|
static |
Try to evaluate: *RESULT = logb (*ARG) in format FORMAT. Return true on success.
References real_format::b, real_value::cl, REAL_EXP, real_from_integer(), rvc_inf, rvc_nan, rvc_normal, rvc_zero, real_value::sign, and SIGNED.
Referenced by fold_const_call_ss().
|
static |
Try to evaluate: *RESULT = nextafter (*ARG0, *ARG1) or *RESULT = nexttoward (*ARG0, *ARG1) in format FORMAT. Return true on success.
References real_format::b, real_value::cl, real_format::has_denorm, real_format::has_inf, real_format::p, real_format::pnan, real_convert(), real_nextafter(), REAL_VALUE_ISSIGNALING_NAN, and rvc_zero.
Referenced by fold_const_call_sss().
|
static |
Try to evaluate: *RESULT = pow (*ARG0, *ARG1) in format FORMAT. Return true on success.
References dconst0, do_mpfr_arg2(), real_equal(), real_from_integer(), real_identical(), real_powi(), real_to_integer(), REAL_VALUE_ISSIGNALING_NAN, REAL_VALUE_TYPE, and SIGNED.
Referenced by fold_const_call_sss().
Fold a call to IFN_REDUC_<CODE> (ARG), returning a value of type TYPE.
References const_binop(), CONSTANT_CLASS_P, i, NULL_TREE, TREE_CODE, VECTOR_CST_ELT, and VECTOR_CST_NELTS.
Referenced by fold_const_call().
|
static |
Try to evaluate: *RESULT = significand (*ARG) in format FORMAT. Return true on success.
References real_format::b, real_value::cl, rvc_inf, rvc_nan, rvc_normal, rvc_zero, and SET_REAL_EXP.
Referenced by fold_const_call_ss().
Fold a call to IFN_VEC_CONVERT (ARG) returning TYPE.
References arg_type, tree_vector_builder::build(), CONSTANT_CLASS_P, count, vector_builder< T, Shape, Derived >::encoded_nelts(), fold_unary, gcc_checking_assert, i, INTEGRAL_TYPE_P, vector_builder< T, Shape, Derived >::new_unary_operation(), NULL_TREE, SCALAR_FLOAT_TYPE_P, TREE_CODE, TREE_TYPE, TYPE_PRECISION, VECTOR_CST_ELT, and VECTOR_TYPE_P.
Referenced by fold_const_call().
|
static |
Try to evaluate: IFN_WHILE_ULT (ARG0, ARG1, (TYPE) { ... }) Return the value on success and null on failure.
References build_all_ones_cst(), build_minus_one_cst(), build_vector_a_then_b(), build_zero_cst(), known_ge, known_le, maybe_ge, NULL_TREE, TREE_TYPE, and TYPE_VECTOR_SUBPARTS().
Referenced by fold_const_call().
Constant folding for calls to built-in and internal functions. Copyright (C) 1988-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/>.
Functions that test for certain constant types, abstracting away the decision about whether to check for overflow.
References TREE_CODE, and TREE_OVERFLOW.
Referenced by fold_const_call(), fold_const_call(), fold_const_call_1(), fold_const_call_1(), and size_t_cst_p().
References TREE_CODE, and TREE_OVERFLOW.
Referenced by fold_const_call_1(), fold_const_call_1(), and fold_const_call_1().
Return true if ARG is a size_type_node constant. Store it in *SIZE_OUT if so.
References integer_cst_p(), size_type_node, tree_fits_uhwi_p(), tree_to_uhwi(), TREE_TYPE, and types_compatible_p().
Referenced by fold_const_call().