GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "target.h"
#include "tree.h"
#include "diagnostic-core.h"
#include "fold-const.h"
#include "stor-layout.h"
#include "convert.h"
#include "langhooks.h"
#include "builtins.h"
#include "ubsan.h"
#include "stringpool.h"
#include "attribs.h"
#include "asan.h"
#include "selftest.h"
Macros | |
#define | maybe_fold_build1_loc(FOLD_P, LOC, CODE, TYPE, EXPR) |
#define | maybe_fold_build2_loc(FOLD_P, LOC, CODE, TYPE, EXPR1, EXPR2) |
#define | CASE_MATHFN(FN) |
#define CASE_MATHFN | ( | FN | ) |
Referenced by convert_to_real_1().
#define maybe_fold_build1_loc | ( | FOLD_P, | |
LOC, | |||
CODE, | |||
TYPE, | |||
EXPR ) |
Utility routines for data type conversion for GCC. Copyright (C) 1987-2025 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/>.
These routines are somewhat language-independent utility function intended to be called by the language-specific convert () functions.
Referenced by convert_to_complex_1(), convert_to_integer_1(), convert_to_pointer_1(), and convert_to_real_1().
#define maybe_fold_build2_loc | ( | FOLD_P, | |
LOC, | |||
CODE, | |||
TYPE, | |||
EXPR1, | |||
EXPR2 ) |
Referenced by convert_to_complex_1(), convert_to_integer_1(), and do_narrow().
A wrapper around convert_to_complex_1 that always folds the expression.
References convert_to_complex_1().
Convert EXPR to the complex type TYPE in the usual ways. If FOLD_P is true, try to fold the expression.
References build2(), build2_loc(), convert(), convert_to_complex_1(), error(), error_mark_node, error_operand_p(), EXPR_LOCATION, integer_zero_node, maybe_fold_build1_loc, maybe_fold_build2_loc, save_expr(), TREE_CODE, TREE_OPERAND, TREE_TYPE, and TYPE_MAIN_VARIANT.
Referenced by convert_to_complex(), convert_to_complex_1(), and convert_to_complex_maybe_fold().
A wrapper around convert_to_complex_1 that only folds the expression if DOFOLD, or if it is CONSTANT_CLASS_OR_WRAPPER_P.
References CONSTANT_CLASS_OR_WRAPPER_P, convert_to_complex_1(), and preserve_any_location_wrapper().
Referenced by convert_to_complex_nofold().
Convert EXPR to some fixed-point type TYPE. EXPR must be fixed-point, float, integer, or enumeral; in other cases error is called.
References ALL_SCALAR_ACCUM_MODE_P, build1(), build_fixed(), convert(), error(), error_mark_node, FCONST0, FCONST1, fold_build1, integer_onep(), integer_zerop(), TREE_CODE, TREE_TYPE, and TYPE_MODE.
Convert EXPR to some integer (or enum) type TYPE. EXPR must be pointer, integer, discrete (enum, char, or bool), float, fixed-point or vector; in other cases error is called. The result of this is always supposed to be a newly created tree node not in use in any existing structure.
References convert_to_integer_1().
Convert EXPR to some integer (or enum) type TYPE. EXPR must be pointer, integer, discrete (enum, char, or bool), float, fixed-point or vector; in other cases error is called. If DOFOLD is TRUE, we try to simplify newly-created patterns by folding. The result of this is always supposed to be a newly created tree node not in use in any existing structure.
References build1(), build2(), build2_loc(), build_call_expr(), build_int_cst(), builtin_mathfn_code(), CALL_EXPR_ARG, call_expr_nargs, CASE_CONVERT, CASE_FLT_FN, CASE_FLT_FN_FLOATN_NX, COMPLETE_TYPE_P, convert(), CONVERT_EXPR_P, convert_to_integer_1(), copy_node(), current_function_decl, do_narrow(), element_precision(), error(), error_mark_node, EXPR_LOCATION, fold_build1, fold_build3, fold_convert, function_c99_misc, gcc_fallthrough, GET_MODE_PRECISION(), GET_MODE_SIZE(), get_unwidened(), integer_all_onesp(), integer_type_node, integer_zerop(), long_integer_type_node, long_long_integer_type_node, mathfn_built_in(), maybe_fold_build1_loc, maybe_fold_build2_loc, NULL_TREE, POINTER_TYPE_P, sanitize_flags_p(), SANITIZE_FLOAT_CAST, SANITIZE_SI_OVERFLOW, save_expr(), SCALAR_FLOAT_TYPE_P, strip_float_extensions(), targetm, tcc_comparison, wi::to_widest(), TREE_CODE, TREE_CODE_CLASS, tree_int_cst_equal(), tree_int_cst_sgn(), TREE_OPERAND, TREE_OVERFLOW, TREE_SIDE_EFFECTS, tree_strip_any_location_wrapper(), TREE_TYPE, lang_hooks_for_types::type_for_mode, lang_hooks_for_types::type_for_size, type_has_mode_precision_p(), TYPE_MODE, TYPE_PRECISION, TYPE_SIZE, TYPE_UNSIGNED, lang_hooks::types, ubsan_instrument_float_cast(), unsigned_type_for(), and VOID_TYPE_P.
Referenced by convert_to_integer(), convert_to_integer_1(), and convert_to_integer_maybe_fold().
A wrapper around convert_to_complex_1 that only folds the expression if DOFOLD, or if it is CONSTANT_CLASS_OR_WRAPPER_P.
References CONSTANT_CLASS_OR_WRAPPER_P, convert_to_integer_1(), and preserve_any_location_wrapper().
Referenced by convert_to_integer_nofold().
A wrapper around convert_to_pointer_1 that always folds the expression.
References convert_to_pointer_1().
Referenced by oacc_rewrite_var_decl().
Convert EXPR to some pointer or reference type TYPE. EXPR must be pointer, reference, integer, enumeral, or literal zero; in other cases error is called. If FOLD_P is true, try to fold the expression.
References error(), error_mark_node, EXPR_LOCATION, maybe_fold_build1_loc, TREE_CODE, TREE_TYPE, TYPE_ADDR_SPACE, lang_hooks_for_types::type_for_size, TYPE_PRECISION, and lang_hooks::types.
Referenced by convert_to_pointer(), and convert_to_pointer_maybe_fold().
A wrapper around convert_to_pointer_1 that only folds the expression if DOFOLD, or if it is CONSTANT_CLASS_OR_WRAPPER_P.
References CONSTANT_CLASS_OR_WRAPPER_P, convert_to_pointer_1(), and preserve_any_location_wrapper().
Referenced by convert_to_pointer_nofold().
A wrapper around convert_to_real_1 that always folds the expression.
References convert_to_real_1().
Convert EXPR to some floating-point type TYPE. EXPR must be float, fixed-point, integer, or enumeral; in other cases error is called. If FOLD_P is true, try to fold the expression.
References build1(), build1_loc(), build2_loc(), build_call_expr(), builtin_mathfn_code(), CALL_EXPR_ARG, call_expr_nargs, CASE_MATHFN, convert(), convert_to_real_1(), DECIMAL_FLOAT_TYPE_P, double_type_node, element_precision(), error(), error_mark_node, EXPR_LOCATION, float_type_node, FLOAT_TYPE_P, gcc_fallthrough, mathfn_built_in(), maybe_fold_build1_loc, REAL_MODE_FORMAT, SCALAR_FLOAT_TYPE_P, strip_float_extensions(), TREE_CODE, TREE_OPERAND, TREE_TYPE, TYPE_MODE, and TYPE_PRECISION.
Referenced by convert_to_real(), convert_to_real_1(), and convert_to_real_maybe_fold().
A wrapper around convert_to_real_1 that only folds the expression if DOFOLD, or if it is CONSTANT_CLASS_OR_WRAPPER_P.
References CONSTANT_CLASS_OR_WRAPPER_P, convert_to_real_1(), and preserve_any_location_wrapper().
Referenced by convert_to_real_nofold().
Convert EXPR to the vector type TYPE in the usual ways.
References build1(), error(), error_mark_node, TREE_CODE, tree_int_cst_equal(), TREE_TYPE, and TYPE_SIZE.
|
static |
Try to narrow EX_FORM ARG0 ARG1 in narrowed arg types producing a result in TYPE.
References convert(), INTEGRAL_TYPE_P, maybe_fold_build2_loc, NULL_TREE, sanitize_flags_p(), SANITIZE_SI_OVERFLOW, signed_type_for(), TREE_CODE, TREE_TYPE, lang_hooks_for_types::type_for_size, TYPE_OVERFLOW_WRAPS, TYPE_PRECISION, TYPE_UNSIGNED, lang_hooks::types, and unsigned_type_for().
Referenced by convert_to_integer_1().
Subroutine of the various convert_to_*_maybe_fold routines. If a location wrapper has been folded to a constant (presumably of a different type), re-wrap the new constant with a location wrapper.
References CONSTANT_CLASS_P, EXPR_LOCATION, location_wrapper_p(), maybe_wrap_with_location(), and TREE_OPERAND.
Referenced by convert_to_complex_maybe_fold(), convert_to_integer_maybe_fold(), convert_to_pointer_maybe_fold(), and convert_to_real_maybe_fold().