GCC Middle and Back End API Reference
builtins.c File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "machmode.h"
#include "rtl.h"
#include "tree.h"
#include "realmpfr.h"
#include "gimple.h"
#include "flags.h"
#include "regs.h"
#include "hard-reg-set.h"
#include "except.h"
#include "function.h"
#include "insn-config.h"
#include "expr.h"
#include "optabs.h"
#include "libfuncs.h"
#include "recog.h"
#include "output.h"
#include "typeclass.h"
#include "predict.h"
#include "tm_p.h"
#include "target.h"
#include "langhooks.h"
#include "basic-block.h"
#include "tree-ssanames.h"
#include "tree-dfa.h"
#include "value-prof.h"
#include "diagnostic-core.h"
#include "builtins.h"
#include "ubsan.h"
#include "cilk.h"
#include "builtins.def"
Include dependency graph for builtins.c:

Macros

#define DEF_BUILTIN(X, N, C, T, LT, B, F, NA, AT, IM, COND)   #X,
#define apply_args_mode   (this_target_builtins->x_apply_args_mode)
#define apply_result_mode   (this_target_builtins->x_apply_result_mode)
#define CASE_MATHFN(BUILT_IN_MATHFN)
#define CASE_MATHFN_REENT(BUILT_IN_MATHFN)
#define HAVE_movstr   0
#define CODE_FOR_movstr   CODE_FOR_nothing
#define HAVE_atomic_clear   0
#define gen_atomic_clear(x, y)   (gcc_unreachable (), NULL_RTX)
#define MAX_ARGS_TO_FOLD_BUILTIN   4

Functions

static tree do_mpc_arg1 (tree, tree, int(*)(mpc_ptr, mpc_srcptr, mpc_rnd_t))
static const char * c_getstr (tree)
static rtx c_readstr (const char *, enum machine_mode)
static int target_char_cast (tree, char *)
static rtx get_memory_rtx (tree, tree)
static int apply_args_size (void)
static int apply_result_size (void)
static void expand_builtin_update_setjmp_buf (rtx)
static void expand_builtin_prefetch (tree)
static rtx expand_builtin_apply_args (void)
static rtx expand_builtin_apply_args_1 (void)
static rtx expand_builtin_apply (rtx, rtx, rtx)
static void expand_builtin_return (rtx)
static enum type_class type_to_class (tree)
static rtx expand_builtin_classify_type (tree)
static void expand_errno_check (tree, rtx)
static rtx expand_builtin_mathfn (tree, rtx, rtx)
static rtx expand_builtin_mathfn_2 (tree, rtx, rtx)
static rtx expand_builtin_mathfn_3 (tree, rtx, rtx)
static rtx expand_builtin_mathfn_ternary (tree, rtx, rtx)
static rtx expand_builtin_interclass_mathfn (tree, rtx)
static rtx expand_builtin_sincos (tree)
static rtx expand_builtin_cexpi (tree, rtx)
static rtx expand_builtin_int_roundingfn (tree, rtx)
static rtx expand_builtin_int_roundingfn_2 (tree, rtx)
static rtx expand_builtin_next_arg (void)
static rtx expand_builtin_va_start (tree)
static rtx expand_builtin_va_end (tree)
static rtx expand_builtin_va_copy (tree)
static rtx expand_builtin_memcmp (tree, rtx, enum machine_mode)
static rtx expand_builtin_strcmp (tree, rtx)
static rtx expand_builtin_strncmp (tree, rtx, enum machine_mode)
static rtx builtin_memcpy_read_str (void *, HOST_WIDE_INT, enum machine_mode)
static rtx expand_builtin_memcpy (tree, rtx)
static rtx expand_builtin_mempcpy (tree, rtx, enum machine_mode)
static rtx expand_builtin_mempcpy_args (tree, tree, tree, rtx, enum machine_mode, int)
static rtx expand_builtin_strcpy (tree, rtx)
static rtx expand_builtin_strcpy_args (tree, tree, rtx)
static rtx expand_builtin_stpcpy (tree, rtx, enum machine_mode)
static rtx expand_builtin_strncpy (tree, rtx)
static rtx builtin_memset_gen_str (void *, HOST_WIDE_INT, enum machine_mode)
static rtx expand_builtin_memset (tree, rtx, enum machine_mode)
static rtx expand_builtin_memset_args (tree, tree, tree, rtx, enum machine_mode, tree)
static rtx expand_builtin_bzero (tree)
static rtx expand_builtin_strlen (tree, rtx, enum machine_mode)
static rtx expand_builtin_alloca (tree, bool)
static rtx expand_builtin_unop (enum machine_mode, tree, rtx, rtx, optab)
static rtx expand_builtin_frame_address (tree, tree)
static tree stabilize_va_list_loc (location_t, tree, int)
static rtx expand_builtin_expect (tree, rtx)
static tree fold_builtin_constant_p (tree)
static tree fold_builtin_expect (location_t, tree, tree)
static tree fold_builtin_classify_type (tree)
static tree fold_builtin_strlen (location_t, tree, tree)
static tree fold_builtin_inf (location_t, tree, int)
static tree fold_builtin_nan (tree, tree, int)
static tree rewrite_call_expr (location_t, tree, int, tree, int,...)
static bool validate_arg (const_tree, enum tree_code code)
static bool integer_valued_real_p (tree)
static tree fold_trunc_transparent_mathfn (location_t, tree, tree)
static bool readonly_data_expr (tree)
static rtx expand_builtin_fabs (tree, rtx, rtx)
static rtx expand_builtin_signbit (tree, rtx)
static tree fold_builtin_sqrt (location_t, tree, tree)
static tree fold_builtin_cbrt (location_t, tree, tree)
static tree fold_builtin_pow (location_t, tree, tree, tree, tree)
static tree fold_builtin_powi (location_t, tree, tree, tree, tree)
static tree fold_builtin_cos (location_t, tree, tree, tree)
static tree fold_builtin_cosh (location_t, tree, tree, tree)
static tree fold_builtin_tan (tree, tree)
static tree fold_builtin_trunc (location_t, tree, tree)
static tree fold_builtin_floor (location_t, tree, tree)
static tree fold_builtin_ceil (location_t, tree, tree)
static tree fold_builtin_round (location_t, tree, tree)
static tree fold_builtin_int_roundingfn (location_t, tree, tree)
static tree fold_builtin_bitop (tree, tree)
static tree fold_builtin_memory_op (location_t, tree, tree, tree, tree, bool, int)
static tree fold_builtin_strchr (location_t, tree, tree, tree)
static tree fold_builtin_memchr (location_t, tree, tree, tree, tree)
static tree fold_builtin_memcmp (location_t, tree, tree, tree)
static tree fold_builtin_strcmp (location_t, tree, tree)
static tree fold_builtin_strncmp (location_t, tree, tree, tree)
static tree fold_builtin_signbit (location_t, tree, tree)
static tree fold_builtin_copysign (location_t, tree, tree, tree, tree)
static tree fold_builtin_isascii (location_t, tree)
static tree fold_builtin_toascii (location_t, tree)
static tree fold_builtin_isdigit (location_t, tree)
static tree fold_builtin_fabs (location_t, tree, tree)
static tree fold_builtin_abs (location_t, tree, tree)
static tree fold_builtin_unordered_cmp (location_t, tree, tree, tree, enum tree_code, enum tree_code)
static tree fold_builtin_n (location_t, tree, tree *, int, bool)
static tree fold_builtin_0 (location_t, tree, bool)
static tree fold_builtin_1 (location_t, tree, tree, bool)
static tree fold_builtin_2 (location_t, tree, tree, tree, bool)
static tree fold_builtin_3 (location_t, tree, tree, tree, tree, bool)
static tree fold_builtin_4 (location_t, tree, tree, tree, tree, tree, bool)
static tree fold_builtin_varargs (location_t, tree, tree, bool)
static tree fold_builtin_strpbrk (location_t, tree, tree, tree)
static tree fold_builtin_strstr (location_t, tree, tree, tree)
static tree fold_builtin_strrchr (location_t, tree, tree, tree)
static tree fold_builtin_strcat (location_t, tree, tree)
static tree fold_builtin_strncat (location_t, tree, tree, tree)
static tree fold_builtin_strspn (location_t, tree, tree)
static tree fold_builtin_strcspn (location_t, tree, tree)
static tree fold_builtin_sprintf (location_t, tree, tree, tree, int)
static tree fold_builtin_snprintf (location_t, tree, tree, tree, tree, int)
static rtx expand_builtin_object_size (tree)
static rtx expand_builtin_memory_chk (tree, rtx, enum machine_mode, enum built_in_function)
static void maybe_emit_chk_warning (tree, enum built_in_function)
static void maybe_emit_sprintf_chk_warning (tree, enum built_in_function)
static void maybe_emit_free_warning (tree)
static tree fold_builtin_object_size (tree, tree)
static tree fold_builtin_strcat_chk (location_t, tree, tree, tree, tree)
static tree fold_builtin_strncat_chk (location_t, tree, tree, tree, tree, tree)
static tree fold_builtin_sprintf_chk (location_t, tree, enum built_in_function)
static tree fold_builtin_printf (location_t, tree, tree, tree, bool, enum built_in_function)
static tree fold_builtin_fprintf (location_t, tree, tree, tree, tree, bool, enum built_in_function)
static bool init_target_chars (void)
static tree do_mpfr_arg1 (tree, tree, int(*)(mpfr_ptr, mpfr_srcptr, mp_rnd_t), const REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *, bool)
static tree do_mpfr_arg2 (tree, tree, tree, int(*)(mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mp_rnd_t))
static tree do_mpfr_arg3 (tree, tree, tree, tree, int(*)(mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_srcptr, mp_rnd_t))
static tree do_mpfr_sincos (tree, tree, tree)
static tree do_mpfr_bessel_n (tree, tree, tree, int(*)(mpfr_ptr, long, mpfr_srcptr, mp_rnd_t), const REAL_VALUE_TYPE *, bool)
static tree do_mpfr_remquo (tree, tree, tree)
static tree do_mpfr_lgamma_r (tree, tree, tree)
static void expand_builtin_sync_synchronize (void)
static bool is_builtin_name ()
bool is_builtin_fn ()
bool default_libc_has_function ()
bool gnu_libc_has_function ()
bool no_c99_libc_has_function ()
static bool called_as_built_in ()
static bool get_object_alignment_2 (tree exp, unsigned int *alignp, unsigned HOST_WIDE_INT *bitposp, bool addr_p)
bool get_object_alignment_1 (tree exp, unsigned int *alignp, unsigned HOST_WIDE_INT *bitposp)
unsigned int get_object_alignment ()
bool get_pointer_alignment_1 (tree exp, unsigned int *alignp, unsigned HOST_WIDE_INT *bitposp)
unsigned int get_pointer_alignment ()
tree c_strlen ()
static const char * c_getstr ()
static rtx c_readstr ()
static int target_char_cast ()
static tree builtin_save_expr ()
static rtx expand_builtin_return_addr ()
void expand_builtin_setjmp_setup ()
void expand_builtin_setjmp_receiver ()
static void expand_builtin_longjmp ()
static rtx expand_builtin_nonlocal_goto ()
static void expand_builtin_update_setjmp_buf ()
static void expand_builtin_prefetch ()
static rtx get_memory_rtx ()
static rtx expand_builtin_apply ()
static void expand_builtin_return ()
static enum type_class type_to_class ()
static rtx expand_builtin_classify_type ()
static tree mathfn_built_in_1 ()
tree mathfn_built_in ()
static void expand_errno_check ()
static rtx expand_builtin_mathfn ()
static rtx expand_builtin_mathfn_2 ()
static rtx expand_builtin_mathfn_ternary ()
static rtx expand_builtin_mathfn_3 ()
static enum insn_code interclass_mathfn_icode ()
static rtx expand_builtin_interclass_mathfn ()
static rtx expand_builtin_sincos ()
static rtx expand_builtin_cexpi ()
static tree build_call_nofold_loc ()
static rtx expand_builtin_int_roundingfn ()
static rtx expand_builtin_int_roundingfn_2 ()
static rtx expand_builtin_powi ()
static rtx expand_builtin_memcpy ()
static rtx expand_builtin_mempcpy ()
static rtx expand_movstr ()
static rtx expand_builtin_strcpy ()
static rtx expand_builtin_strcpy_args ()
static rtx expand_builtin_stpcpy ()
rtx builtin_strncpy_read_str (void *data, HOST_WIDE_INT offset, enum machine_mode mode)
static rtx expand_builtin_strncpy ()
rtx builtin_memset_read_str (void *data, HOST_WIDE_INT offset, enum machine_mode mode)
static rtx expand_builtin_memset ()
static rtx expand_builtin_bzero ()
static rtx expand_builtin_strcmp ()
rtx expand_builtin_saveregs ()
static tree stabilize_va_list_loc ()
tree std_build_builtin_va_list ()
tree std_fn_abi_va_list ()
tree std_canonical_va_list_type ()
void std_expand_builtin_va_start ()
static rtx expand_builtin_va_start ()
static rtx expand_builtin_va_end ()
static rtx expand_builtin_va_copy ()
static rtx expand_builtin_frame_address ()
static rtx expand_builtin_alloca ()
static rtx expand_builtin_bswap (enum machine_mode target_mode, tree exp, rtx target, rtx subtarget)
static rtx expand_builtin_expect ()
static rtx expand_builtin_assume_aligned ()
void expand_builtin_trap ()
static void expand_builtin_unreachable ()
static rtx expand_builtin_fabs ()
static rtx expand_builtin_copysign ()
tree build_string_literal ()
static rtx expand_builtin___clear_cache ()
static rtx round_trampoline_addr ()
static rtx expand_builtin_init_trampoline ()
static rtx expand_builtin_adjust_trampoline ()
static rtx expand_builtin_signbit ()
static rtx expand_builtin_fork_or_exec ()
static enum machine_mode get_builtin_sync_mode ()
static rtx get_builtin_sync_mem ()
static rtx expand_expr_force_mode ()
static rtx expand_builtin_sync_operation (enum machine_mode mode, tree exp, enum rtx_code code, bool after, rtx target)
static rtx expand_builtin_compare_and_swap (enum machine_mode mode, tree exp, bool is_bool, rtx target)
static rtx expand_builtin_sync_lock_test_and_set (enum machine_mode mode, tree exp, rtx target)
static void expand_builtin_sync_lock_release ()
static enum memmodel get_memmodel ()
static rtx expand_builtin_atomic_exchange ()
static rtx expand_builtin_atomic_compare_exchange (enum machine_mode mode, tree exp, rtx target)
static rtx expand_builtin_atomic_load ()
static rtx expand_builtin_atomic_store ()
static rtx expand_builtin_atomic_fetch_op (enum machine_mode mode, tree exp, rtx target, enum rtx_code code, bool fetch_after, bool ignore, enum built_in_function ext_call)
static rtx expand_builtin_atomic_clear ()
static rtx expand_builtin_atomic_test_and_set ()
static tree fold_builtin_atomic_always_lock_free ()
static rtx expand_builtin_atomic_always_lock_free ()
static tree fold_builtin_atomic_is_lock_free ()
static rtx expand_builtin_atomic_is_lock_free ()
static void expand_builtin_atomic_thread_fence ()
static void expand_builtin_atomic_signal_fence ()
static rtx expand_builtin_thread_pointer ()
static void expand_builtin_set_thread_pointer ()
rtx expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode, int ignore)
enum built_in_function builtin_mathfn_code ()
static tree fold_builtin_constant_p ()
static tree build_builtin_expect_predicate ()
static tree fold_builtin_expect ()
static tree fold_builtin_classify_type ()
static tree fold_builtin_strlen ()
static tree fold_builtin_inf ()
static tree fold_builtin_nan ()
static bool integer_valued_real_p ()
static tree fold_trunc_transparent_mathfn ()
static tree fold_fixed_mathfn ()
static tree fold_builtin_cabs ()
static tree build_complex_cproj ()
static tree fold_builtin_cproj ()
static tree fold_builtin_sqrt ()
static tree fold_builtin_cbrt ()
static tree fold_builtin_cosh ()
static tree fold_builtin_ccos (location_t loc, tree arg, tree type, tree fndecl, bool hyper)
static tree fold_builtin_tan ()
static tree fold_builtin_sincos (location_t loc, tree arg0, tree arg1, tree arg2)
static tree fold_builtin_cexp ()
static tree fold_builtin_trunc ()
static tree fold_builtin_floor ()
static tree fold_builtin_ceil ()
static tree fold_builtin_round ()
static tree fold_builtin_int_roundingfn ()
static tree fold_builtin_bitop ()
static tree fold_builtin_bswap ()
static tree fold_builtin_logarithm (location_t loc, tree fndecl, tree arg, int(*func)(mpfr_ptr, mpfr_srcptr, mp_rnd_t))
static tree fold_builtin_hypot (location_t loc, tree fndecl, tree arg0, tree arg1, tree type)
static tree fold_builtin_pow ()
static tree fold_builtin_exponent (location_t loc, tree fndecl, tree arg, int(*func)(mpfr_ptr, mpfr_srcptr, mp_rnd_t))
static bool var_decl_component_p ()
static tree fold_builtin_memset (location_t loc, tree dest, tree c, tree len, tree type, bool ignore)
static tree fold_builtin_bzero ()
tree fold_builtin_strcpy ()
static tree fold_builtin_stpcpy ()
tree fold_builtin_strncpy (location_t loc, tree fndecl, tree dest, tree src, tree len, tree slen)
static tree fold_builtin_memchr ()
static tree fold_builtin_memcmp ()
static tree fold_builtin_strcmp ()
static tree fold_builtin_strncmp ()
static tree fold_builtin_signbit ()
static tree fold_builtin_isascii ()
static tree fold_builtin_toascii ()
static tree fold_builtin_isdigit ()
static tree fold_builtin_fabs ()
static tree fold_builtin_abs ()
tree fold_fma (location_t loc, tree type, tree arg0, tree arg1, tree arg2)
static tree fold_builtin_fma ()
static tree fold_builtin_fmin_fmax (location_t loc, tree arg0, tree arg1, tree type, bool max)
static tree fold_builtin_carg ()
static tree fold_builtin_logb ()
static tree fold_builtin_significand ()
static tree fold_builtin_frexp ()
static tree fold_builtin_load_exponent (location_t loc, tree arg0, tree arg1, tree type, bool ldexp)
static tree fold_builtin_modf ()
static tree fold_builtin_interclass_mathfn ()
static tree fold_builtin_classify ()
static tree fold_builtin_fpclassify ()
static tree fold_builtin_0 ()
static tree fold_builtin_1 ()
static tree fold_builtin_2 ()
static tree fold_builtin_n ()
bool avoid_folding_inline_builtin ()
tree fold_call_expr ()
tree build_call_expr_loc_array ()
tree build_call_expr_loc_vec ()
tree build_call_expr_loc ()
tree build_call_expr ()
tree fold_builtin_call_array (location_t loc, tree type, tree fn, int n, tree *argarray)
static tree rewrite_call_expr_valist (location_t loc, int oldnargs, tree *args, int skip, tree fndecl, int n, va_list newargs)
static tree rewrite_call_expr_array (location_t loc, int oldnargs, tree *args, int skip, tree fndecl, int n,...)
static tree rewrite_call_expr ()
static bool validate_arg ()
bool validate_gimple_arglist ()
bool validate_arglist ()
rtx default_expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode, int ignore)
static bool readonly_data_expr ()
static tree fold_builtin_strstr ()
static tree fold_builtin_strchr ()
static tree fold_builtin_strrchr ()
static tree fold_builtin_strpbrk ()
static tree fold_builtin_strcat ()
static tree fold_builtin_strncat ()
static tree fold_builtin_strspn ()
static tree fold_builtin_strcspn ()
tree fold_builtin_fputs (location_t loc, tree arg0, tree arg1, bool ignore, bool unlocked, tree len)
bool fold_builtin_next_arg ()
rtx expand_builtin_object_size ()
static void maybe_emit_chk_warning ()
static void maybe_emit_sprintf_chk_warning ()
static void maybe_emit_free_warning ()
tree fold_builtin_object_size ()
tree fold_builtin_memory_chk (location_t loc, tree fndecl, tree dest, tree src, tree len, tree size, tree maxlen, bool ignore, enum built_in_function fcode)
tree fold_builtin_stxcpy_chk (location_t loc, tree fndecl, tree dest, tree src, tree size, tree maxlen, bool ignore, enum built_in_function fcode)
tree fold_builtin_stxncpy_chk (location_t loc, tree dest, tree src, tree len, tree size, tree maxlen, bool ignore, enum built_in_function fcode)
static tree fold_builtin_sprintf_chk_1 (location_t loc, int nargs, tree *args, enum built_in_function fcode)
static tree fold_builtin_snprintf_chk_1 (location_t loc, int nargs, tree *args, tree maxlen, enum built_in_function fcode)
tree fold_builtin_snprintf_chk (location_t loc, tree exp, tree maxlen, enum built_in_function fcode)
static tree do_mpfr_ckconv ()
static tree do_mpc_ckconv ()
static tree do_mpfr_sincos ()
static tree do_mpfr_remquo ()
static tree do_mpfr_lgamma_r ()
tree do_mpc_arg2 (tree arg0, tree arg1, tree type, int do_nonfinite, int(*func)(mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t))
static tree gimple_fold_builtin_sprintf_chk ()
tree gimple_fold_builtin_snprintf_chk (gimple stmt, tree maxlen, enum built_in_function fcode)
static tree gimple_fold_builtin_varargs (tree fndecl, gimple stmt, bool ignore)
tree fold_call_stmt ()
void set_builtin_user_assembler_name ()
bool is_simple_builtin ()
bool is_inexpensive_builtin ()

Variables

struct target_builtins default_target_builtins
const char *const built_in_class_names [BUILT_IN_LAST] = {"NOT_BUILT_IN", "BUILT_IN_FRONTEND", "BUILT_IN_MD", "BUILT_IN_NORMAL"}
const char * built_in_names [(int) END_BUILTINS]
builtin_info_type builtin_info
bool force_folding_builtin_constant_p
static unsigned HOST_WIDE_INT target_newline
static unsigned HOST_WIDE_INT target_percent
static unsigned HOST_WIDE_INT target_c
static unsigned HOST_WIDE_INT target_s
static char target_percent_c [3]
static char target_percent_s [3]
static char target_percent_s_newline [4]
static alias_set_type setjmp_alias_set = -1

Macro Definition Documentation

#define apply_args_mode   (this_target_builtins->x_apply_args_mode)

Built-in functions to perform an untyped call and return.

#define apply_result_mode   (this_target_builtins->x_apply_result_mode)
#define CASE_MATHFN (   BUILT_IN_MATHFN)
Value:
case BUILT_IN_MATHFN: case BUILT_IN_MATHFN##F: case BUILT_IN_MATHFN##L: \
fcode = BUILT_IN_MATHFN; fcodef = BUILT_IN_MATHFN##F ; \
fcodel = BUILT_IN_MATHFN##L ; break;

This helper macro, meant to be used in mathfn_built_in below, determines which among a set of three builtin math functions is appropriate for a given type mode. The `F' and `L' cases are automatically generated from the `double' case.

Referenced by convert_to_real().

#define CASE_MATHFN_REENT (   BUILT_IN_MATHFN)
Value:
case BUILT_IN_MATHFN##_R: case BUILT_IN_MATHFN##F_R: case BUILT_IN_MATHFN##L_R: \
fcode = BUILT_IN_MATHFN##_R; fcodef = BUILT_IN_MATHFN##F_R ; \
fcodel = BUILT_IN_MATHFN##L_R ; break;

Similar to above, but appends _R after any F/L suffix.

#define CODE_FOR_movstr   CODE_FOR_nothing
#define DEF_BUILTIN (   X,
  N,
  C,
  T,
  LT,
  B,
  F,
  NA,
  AT,
  IM,
  COND 
)    #X,
#define gen_atomic_clear (   x,
 
)    (gcc_unreachable (), NULL_RTX)
#define HAVE_atomic_clear   0
#define HAVE_movstr   0
#define MAX_ARGS_TO_FOLD_BUILTIN   4

Fold a call to built-in function FNDECL. ARGS is an array of NARGS arguments, where NARGS <= 4. IGNORE is true if the result of the function call is ignored. This function returns NULL_TREE if no simplification was possible. Note that this only folds builtins with fixed argument patterns. Foldings that do varargs-to-varargs transformations, or that match calls with more than 4 arguments, need to be handled with fold_builtin_varargs instead.


Function Documentation

static int apply_args_size ( )
static

Return the size required for the block returned by __builtin_apply_args, and initialize apply_args_mode.

 The values computed by this function never change.   
     The first value is the incoming arg-pointer.   
     The second value is the structure value address unless this is
     passed as an "invisible" first argument.   

References adjust_address, BITS_PER_UNIT, CEIL, gen_rtx_REG(), GET_MODE_ALIGNMENT, GET_MODE_SIZE, and INCOMING_REGNO.

static int apply_result_size ( )
static

Return the size required for the block returned by __builtin_apply, and initialize apply_result_mode.

The values computed by this function never change.

     Allow targets that use untyped_call and untyped_return to override
     the size so that machine-specific information can be stored here.   
bool avoid_folding_inline_builtin ( )

Return true if FNDECL shouldn't be folded right now. If a built-in function has an inline attribute always_inline wrapper, defer folding it after always_inline functions have been inlined, otherwise e.g. -D_FORTIFY_SOURCE checking might not be performed.

References builtin_decl_implicit(), and NULL_TREE.

static tree build_builtin_expect_predicate ( )
static

Create builtin_expect with PRED and EXPECTED as its arguments and return it as a truthvalue.

tree build_call_expr ( )

Like build_call_expr_loc (UNKNOWN_LOCATION, ...). Duplicated because varargs macros aren't supported by all bootstrap compilers.

References build_int_cst(), c_getstr(), omit_two_operands_loc(), size_type_node, and size_zero_node.

Referenced by assign_parms(), convert_to_integer(), convert_to_real(), default_stack_protect_guard(), gimplify_return_expr(), tsan_pass(), and vn_reference_maybe_forwprop_address().

tree build_call_expr_loc ( )

Conveniently construct a function call expression. FNDECL names the function to be called, N is the number of arguments, and the "..." parameters are the argument expressions.

References validate_arg().

Referenced by expand_omp_sections(), fold_builtin_4(), fold_builtin_cexp(), fold_builtin_fputs(), fold_builtin_int_roundingfn(), fold_builtin_logarithm(), fold_trunc_transparent_mathfn(), integer_valued_real_p(), maybe_emit_chk_warning(), and rewrite_call_expr().

tree build_call_expr_loc_array ( )

Conveniently construct a function call expression. FNDECL names the function to be called and N arguments are passed in the array ARGARRAY.

tree build_call_expr_loc_vec ( )

Conveniently construct a function call expression. FNDECL names the function to be called and the arguments are passed in the vector VEC.

static tree build_call_nofold_loc ( )
static

Conveniently construct a function call expression. FNDECL names the function to be called, N is the number of arguments, and the "..." parameters are the argument expressions. Unlike build_call_exr this doesn't fold the call, hence it will always return a CALL_EXPR.

Referenced by expand_builtin_memset_args().

static tree build_complex_cproj ( )
static

Build a complex (inf +- 0i) for the result of cproj. TYPE is the complex tree type of the result. If NEG is true, the imaginary zero is negative.

References real_floor(), REAL_VALUE_ISNAN, REAL_VALUE_TYPE, TREE_REAL_CST, TREE_TYPE, and TYPE_MODE.

tree build_string_literal ( )

Create a new constant string literal and return a char* pointer to it. The STRING_CST value is the LEN characters at STR.

Referenced by maybe_emit_chk_warning().

enum built_in_function builtin_mathfn_code ( )

Determine whether a tree node represents a call to a built-in function. If the tree T is a call to a built-in function with the right number of arguments of the appropriate types, return the DECL_FUNCTION_CODE of the call, e.g. BUILT_IN_SQRT. Otherwise the return value is END_BUILTINS.

If a function doesn't take a variable number of arguments,
the last element in the list will have type `void'.   

Variable-length argument list.

Referenced by convert_to_integer(), fold_builtin_bitop(), and fold_builtin_tan().

static rtx builtin_memcpy_read_str ( void *  data,
HOST_WIDE_INT  offset,
enum machine_mode  mode 
)
static

Callback routine for store_by_pieces. Read GET_MODE_BITSIZE (MODE) bytes from constant string DATA + OFFSET and return it as target constant.

static rtx builtin_memset_gen_str ( void *  data,
HOST_WIDE_INT  offset,
enum machine_mode  mode 
)
static

Callback routine for store_by_pieces. Return the RTL of a register containing GET_MODE_SIZE (MODE) consecutive copies of the unsigned char value given in the RTL register data. For example, if mode is 4 bytes wide, return the RTL for 0x01010101*data.

References INTVAL, and set_mem_size().

rtx builtin_memset_read_str ( void *  data,
HOST_WIDE_INT  offset,
enum machine_mode  mode 
)

Callback routine for store_by_pieces. Read GET_MODE_BITSIZE (MODE) bytes from constant string DATA + OFFSET and return it as target constant.

static tree builtin_save_expr ( )
static

Similar to save_expr, but assumes that arbitrary code is not executed in between the multiple evaluations. In particular, we assume that a non-addressable local variable will not be modified.

Referenced by expand_builtin_memset_args(), expand_builtin_sincos(), and expand_builtin_va_start().

rtx builtin_strncpy_read_str ( void *  data,
HOST_WIDE_INT  offset,
enum machine_mode  mode 
)

Callback routine for store_by_pieces. Read GET_MODE_BITSIZE (MODE) bytes from constant string DATA + OFFSET and return it as target constant.

static const char* c_getstr ( )
static

Return a char pointer for a C string if it is a string constant or sum of string constant and integer constant.

static rtx c_readstr ( const char *  ,
enum  machine_mode 
)
static
static rtx c_readstr ( )
static

Return a CONST_INT or CONST_DOUBLE corresponding to target reading GET_MODE_BITSIZE (MODE) bits from string constant STR.

tree c_strlen ( )

Compute the length of a C string. TREE_STRING_LENGTH is not the right way, because it could contain a zero byte in the middle. TREE_STRING_LENGTH is the size of the character array, not the string.

ONLY_VALUE should be nonzero if the result is not going to be emitted into the instruction stream and zero if it is going to be expanded. E.g. with i++ ? "foo" : "bar", if ONLY_VALUE is nonzero, constant 3 is returned, otherwise NULL, since len = c_strlen (src, 1); if (len) expand_expr (len, ...); would not evaluate the side-effects.

The value returned is of type `ssizetype'.

Unfortunately, string_constant can't access the values of const char arrays with initializers, so neither can we do so here.

     If the string has an internal zero byte (e.g., "foo\0bar"), we can't
     compute the offset to the following null if we don't know where to
     start searching for it.   
     We don't know the starting offset, but we do know that the string
     has no internal zero bytes.  We can assume that the offset falls
     within the bounds of the string; otherwise, the programmer deserves
     what he gets.  Subtract the offset from the length of the string,
     and return that.  This would perhaps not be valid if we were dealing
     with named arrays in addition to literal string constants.   
 We have a known offset into the string.  Start searching there for
 a null character if we can represent it as a single HOST_WIDE_INT.   
 If the offset is known to be out of bounds, warn, and call strlen at
 runtime.   
    Suppress multiple warnings for propagated constant strings.   
 Use strlen to search for the first zero byte.  Since any strings
 constructed with build_string will have nulls appended, we win even
 if we get handed something like (char[4])"abcd".

 Since OFFSET is our starting index into the string, no further
 calculation is needed.   

Referenced by expand_builtin_memset_args(), fold_builtin_strspn(), fold_builtin_strstr(), fold_call_expr(), and get_pointer_alignment().

static bool called_as_built_in ( )
static

Return true if NODE should be considered for inline expansion regardless of the optimization level. This means whenever a function is invoked with its "internal" name, which normally contains the prefix "__builtin".

Note that we must use DECL_NAME, not DECL_ASSEMBLER_NAME_SET_P since we want the name used to call the function, not the name it will have.

References BITS_PER_UNIT, HOST_WIDE_INT, and offset.

rtx default_expand_builtin ( tree  exp,
rtx  target,
rtx  subtarget,
enum machine_mode  mode,
int  ignore 
)

Default target-specific builtin expander that does nothing.

References NULL, NULL_TREE, and validate_arg().

bool default_libc_has_function ( )

By default we assume that c99 functions are present at the runtime, but sincos is not.

static tree do_mpc_arg1 ( tree  arg,
tree  type,
int(*)(mpc_ptr, mpc_srcptr, mpc_rnd_t)  func 
)
static

Expand builtin functions. Copyright (C) 1988-2013 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/.

If argument ARG is a COMPLEX_CST, call the one-argument mpc function FUNC on it and return the resulting value as a tree with type TYPE. The mpfr precision is set to the precision of TYPE. We assume that function FUNC returns zero if the result could be calculated exactly within the requested precision.

To proceed, MPFR must exactly represent the target floating point format, which only happens when the target base equals two.

tree do_mpc_arg2 ( tree  arg0,
tree  arg1,
tree  type,
int  do_nonfinite,
int(*)(mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t)  func 
)

If arguments ARG0 and ARG1 are a COMPLEX_CST, call the two-argument mpc function FUNC on it and return the resulting value as a tree with type TYPE. The mpfr precision is set to the precision of TYPE. We assume that function FUNC returns zero if the result could be calculated exactly within the requested precision. If DO_NONFINITE is true, then fold expressions containing Inf or NaN in the arguments and/or results.

To proceed, MPFR must exactly represent the target floating point format, which only happens when the target base equals two.

Referenced by fold_builtin_classify().

static tree do_mpc_ckconv ( )
static

Helper function for do_mpc_arg*(). Ensure M is a normal complex number and no overflow/underflow occurred. INEXACT is true if M was not exactly calculated. TYPE is the tree type for the result. This function assumes that you cleared the MPFR flags and then calculated M to see if anything subsequently set a flag prior to entering this function. Return NULL_TREE if any checks fail, if FORCE_CONVERT is true, then bypass the checks.

 Proceed iff we get a normal number, i.e. not NaN or Inf and no
 overflow/underflow occurred.  If -frounding-math, proceed iff the
 result of calling FUNC was exact.   
     Proceed iff GCC's REAL_VALUE_TYPE can hold the MPFR values,
     check for overflow/underflow.  If the REAL_VALUE_TYPE is zero
     but the mpft_t is not, then we underflowed in the
     conversion.   
         Proceed iff the specified mode can hold the value.   
static tree do_mpfr_arg1 ( tree  arg,
tree  type,
int(*)(mpfr_ptr, mpfr_srcptr, mp_rnd_t)  func,
const REAL_VALUE_TYPE min,
const REAL_VALUE_TYPE max,
bool  inclusive 
)
static

If argument ARG is a REAL_CST, call the one-argument mpfr function FUNC on it and return the resulting value as a tree with type TYPE. If MIN and/or MAX are not NULL, then the supplied ARG must be within those bounds. If INCLUSIVE is true, then MIN/MAX are acceptable values, otherwise they are not. The mpfr precision is set to the precision of TYPE. We assume that function FUNC returns zero if the result could be calculated exactly within the requested precision.

To proceed, MPFR must exactly represent the target floating point format, which only happens when the target base equals two.

Referenced by fold_builtin_tan(), and fold_trunc_transparent_mathfn().

static tree do_mpfr_arg2 ( tree  arg1,
tree  arg2,
tree  type,
int(*)(mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mp_rnd_t)  func 
)
static

If argument ARG is a REAL_CST, call the two-argument mpfr function FUNC on it and return the resulting value as a tree with type TYPE. The mpfr precision is set to the precision of TYPE. We assume that function FUNC returns zero if the result could be calculated exactly within the requested precision.

To proceed, MPFR must exactly represent the target floating point format, which only happens when the target base equals two.

Referenced by fold_builtin_classify().

static tree do_mpfr_arg3 ( tree  arg1,
tree  arg2,
tree  arg3,
tree  type,
int(*)(mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_srcptr, mp_rnd_t)  func 
)
static

If argument ARG is a REAL_CST, call the three-argument mpfr function FUNC on it and return the resulting value as a tree with type TYPE. The mpfr precision is set to the precision of TYPE. We assume that function FUNC returns zero if the result could be calculated exactly within the requested precision.

To proceed, MPFR must exactly represent the target floating point format, which only happens when the target base equals two.

static tree do_mpfr_bessel_n ( tree  arg1,
tree  arg2,
tree  type,
int(*)(mpfr_ptr, long, mpfr_srcptr, mp_rnd_t)  func,
const REAL_VALUE_TYPE min,
bool  inclusive 
)
static

If argument ARG1 is an INTEGER_CST and ARG2 is a REAL_CST, call the two-argument mpfr order N Bessel function FUNC on them and return the resulting value as a tree with type TYPE. The mpfr precision is set to the precision of TYPE. We assume that function FUNC returns zero if the result could be calculated exactly within the requested precision.

To proceed, MPFR must exactly represent the target floating point format, which only happens when the target base equals two.

Referenced by fold_builtin_classify().

static tree do_mpfr_ckconv ( )
static

Helper function for do_mpfr_arg*(). Ensure M is a normal number and no overflow/underflow occurred. INEXACT is true if M was not exactly calculated. TYPE is the tree type for the result. This function assumes that you cleared the MPFR flags and then calculated M to see if anything subsequently set a flag prior to entering this function. Return NULL_TREE if any checks fail.

 Proceed iff we get a normal number, i.e. not NaN or Inf and no
 overflow/underflow occurred.  If -frounding-math, proceed iff the
 result of calling FUNC was exact.   
     Proceed iff GCC's REAL_VALUE_TYPE can hold the MPFR value,
     check for overflow/underflow.  If the REAL_VALUE_TYPE is zero
     but the mpft_t is not, then we underflowed in the
     conversion.   
         Proceed iff the specified mode can hold the value.   

Referenced by fold_builtin_sprintf_chk_1(), and fold_builtin_strncat_chk().

static tree do_mpfr_lgamma_r ( tree  ,
tree  ,
tree   
)
static

Referenced by fold_builtin_classify().

static tree do_mpfr_lgamma_r ( )
static

If ARG is a REAL_CST, call mpfr_lgamma() on it and return the resulting value as a tree with type TYPE. The mpfr precision is set to the precision of TYPE. We assume that this mpfr function returns zero if the result could be calculated exactly within the requested precision. In addition, the integer pointer represented by ARG_SG will be dereferenced and set to the appropriate signgam (-1,1) value.

 To proceed, MPFR must exactly represent the target floating point
 format, which only happens when the target base equals two.  Also
 verify ARG is a constant and that ARG_SG is an int pointer.   
     In addition to NaN and Inf, the argument cannot be zero or a
     negative integer.   
             Dereference the arg_sg pointer argument.   
             Assign the signgam value into *arg_sg.  
             Combine the signgam assignment with the lgamma result.   
static tree do_mpfr_remquo ( tree  ,
tree  ,
tree   
)
static
static tree do_mpfr_remquo ( )
static

If arguments ARG0 and ARG1 are REAL_CSTs, call mpfr_remquo() to set the pointer *(ARG_QUO) and return the result. The type is taken from the type of ARG0 and is used for setting the precision of the calculation and results.

 To proceed, MPFR must exactly represent the target floating point
 format, which only happens when the target base equals two.   
         Remquo is independent of the rounding mode, so pass
         inexact=0 to do_mpfr_ckconv().   
             MPFR calculates quo in the host's long so it may
             return more bits in quo than the target int can hold
             if sizeof(host long) > sizeof(target int).  This can
             happen even for native compilers in LP64 mode.  In
             these cases, modulo the quo value with the largest
             number that the target int can hold while leaving one
             bit for the sign.   
             Dereference the quo pointer argument.   
             Proceed iff a valid pointer type was passed in.   
                 Set the value.  
                 Combine the quo assignment with the rem.   
static tree do_mpfr_sincos ( tree  ,
tree  ,
tree   
)
static
static tree do_mpfr_sincos ( )
static

If argument ARG is a REAL_CST, call mpfr_sin_cos() on it and set the pointers *(ARG_SINP) and *(ARG_COSP) to the resulting values. If ARG_SINP and ARG_COSP are NULL then the result is returned as a complex value. The type is taken from the type of ARG and is used for setting the precision of the calculation and results.

 To proceed, MPFR must exactly represent the target floating point
 format, which only happens when the target base equals two.   
             If we are to return in a complex value do so.   
             Dereference the sin/cos pointer arguments.   
             Proceed if valid pointer type were passed in.   
                 Set the values.  
                 Combine the assignments into a compound expr.   
rtx expand_builtin ( tree  exp,
rtx  target,
rtx  subtarget,
enum machine_mode  mode,
int  ignore 
)

Expand an expression EXP that calls a built-in function, with result going to TARGET if that's convenient (and in mode MODE if that's convenient). SUBTARGET may be used as the target for computing one of EXP's operands. IGNORE is nonzero if the value is to be ignored.

 When not optimizing, generate calls to library functions for a certain
 set of builtins.   
 The built-in function expanders test for target == const0_rtx
 to determine whether the function's result will be ignored.   
 If the result of a pure or const built-in function is ignored, and
 none of its arguments are volatile, we can avoid expanding the
 built-in call and just evaluate the arguments for side-effects.   
     Just do a normal library call if we were unable to fold
     the values.   
     Treat these like sqrt only if unsafe math optimizations are allowed,
     because of possible accuracy problems.   
     __builtin_apply (FUNCTION, ARGUMENTS, ARGSIZE) invokes
     FUNCTION with a copy of the parameters described by
     ARGUMENTS, and ARGSIZE.  It returns a block of memory
     allocated on the stack into which is stored all the registers
     that might possibly be used for returning the result of a
     function.  ARGUMENTS is the value returned by
     __builtin_apply_args.  ARGSIZE is the number of bytes of
     arguments that must be copied.  ??? How should this value be
     computed?  We'll also need a safe worst case value for varargs
     functions.   
     __builtin_return (RESULT) causes the function to return the
     value described by RESULT.  RESULT is address of the block of
     memory returned by __builtin_apply.   
     All valid uses of __builtin_va_arg_pack () are removed during
     inlining.   
     All valid uses of __builtin_va_arg_pack_len () are removed during
     inlining.   
     Return the address of the first anonymous stack arg.   
   Returns the address of the area where the structure is returned.
   0 otherwise.   
     If the allocation stems from the declaration of a variable-sized
     object, it cannot accumulate.   
     This should have been lowered to the builtins below.   
     __builtin_setjmp_setup is passed a pointer to an array of five words
      and the receiver label.   
         This is copied from the handling of non-local gotos.   
         ??? Do not let expand_label treat us as such since we would
         not want to be both on the list of non-local labels and on
         the list of forced labels.   
      __builtin_setjmp_dispatcher is passed the dispatcher label.   
         Remove the dispatcher label from the list of non-local labels
         since the receiver labels have been added to it above.   
      __builtin_setjmp_receiver is passed the receiver label.   
     __builtin_longjmp is passed a pointer to an array of five words.
     It's similar to the C library longjmp function but works with
     __builtin_setjmp above.   
     This updates the setjmp buffer that is its argument with the value
     of the current stack pointer.   
     Various hooks for the DWARF 2 __throw routine.   
       If this is turned into an external library call, the weak parameter
       must be dropped to match the expected parameter list.   
       Skip the boolean weak parameter.   
     We allow user CHKP builtins if Pointer Bounds
     Checker is off.   
     FALLTHROUGH  
     Software implementation of pointers checker is NYI.
     Target support is required.   
 The switch statement above can drop through to cause the function
 to be called normally.   
static rtx expand_builtin___clear_cache ( )
static

Expand a call to builtin_clear_cache.

There is no "clear_cache" insn, and __clear_cache() in libgcc does nothing. There is no need to call it. Do nothing.

References BITS_PER_UNIT, and mode_for_size().

static rtx expand_builtin_adjust_trampoline ( )
static
static rtx expand_builtin_alloca ( tree  ,
bool   
)
static
static rtx expand_builtin_alloca ( )
static

Expand EXP, a call to the alloca builtin. Return NULL_RTX if we failed and the caller should emit a normal call. CANNOT_ACCUMULATE is the same as for allocate_dynamic_stack_space.

 Compute the argument.   
 Compute the alignment.   
 Allocate the desired space.   
static rtx expand_builtin_apply ( rtx  ,
rtx  ,
rtx   
)
static
static rtx expand_builtin_apply ( )
static

Perform an untyped call and save the state required to perform an untyped return of whatever value was returned by the given function.

 Create a block where the return registers can be saved.   
 Fetch the arg pointer from the ARGUMENTS block.   
 Push a new argument block and copy the arguments.  Do not allow
 the (potential) memcpy call below to interfere with our stack
 manipulations.   
 Save the stack with nonlocal if available.   
 Allocate a block of memory onto the stack and copy the memory
 arguments to the outgoing arguments address.  We can pass TRUE
 as the 4th argument because we just saved the stack pointer
 and will restore it right after the call.   
 Set DRAP flag to true, even though allocate_dynamic_stack_space
 may have already set current_function_calls_alloca to true.
 current_function_calls_alloca won't be set if argsize is zero,
 so we have to guarantee need_drap is true here.   
 Refer to the argument block.   
 Walk past the arg-pointer and structure value address.   
 Restore each of the registers previously saved.  Make USE insns
 for each of these registers for use in making the call.   
 Restore the structure value address unless this is passed as an
 "invisible" first argument.   
 All arguments and registers used for the call are set up by now!   
 Ensure address is valid.  SYMBOL_REF is already valid, so no need,
 and we don't want to load it into a register as an optimization,
 because prepare_call_address already did it if it should be done.   
 Generate the actual call instruction and save the return value.   
 Find the CALL insn we just emitted, and attach the register usage
 information.   
 Restore the stack.   
 Return the address of the result block.   
static rtx expand_builtin_apply_args ( )
static

__builtin_apply_args returns block of memory allocated on the stack into which is stored the arg pointer, structure value address, static chain, and all the registers that might possibly be used in performing a function call. The code is moved to the start of the function so the incoming values are saved.

 Don't do __builtin_apply_args more than once in a function.
 Save the result of the first call and reuse it.   
   When this function is called, it means that registers must be
   saved on entry to this function.  So we migrate the
   call to the first insn of this function.   
   Put the insns after the NOTE that starts the function.
   If this is inside a start_sequence, make the outer-level insn
   chain current, so the code is placed at the start of the
   function.  If internal_arg_pointer is a non-virtual pseudo,
   it needs to be placed after the function that initializes
   that pseudo.   
static rtx expand_builtin_apply_args_1 ( )
static

Save the state required to perform an untyped call with the same arguments as were passed to the current function.

 Create a block where the arg-pointer, structure value address,
 and argument registers can be saved.   
 Walk past the arg-pointer and structure value address.   
 Save each register used in calling a function to the block.   
 Save the arg pointer to the block.   
 Save the structure value address unless this is passed as an
 "invisible" first argument.   
 Return the address of the block.   
static rtx expand_builtin_assume_aligned ( )
static

Expand a call to __builtin_assume_aligned. We just return our first argument as the builtin_assume_aligned semantic should've been already executed by CCP.

References BITS_PER_WORD, FLOAT_WORDS_BIG_ENDIAN, GET_MODE_BITSIZE, operand_subword_force(), and word_mode.

static rtx expand_builtin_atomic_always_lock_free ( )
static

Return true if the parameters to call EXP represent an object which will always generate lock free instructions. The first argument represents the size of the object, and the second parameter is a pointer to the object itself. If NULL is passed for the object, then the result is based on typical alignment for an object of the specified size. Otherwise return false.

static rtx expand_builtin_atomic_clear ( )
static

Expand an atomic clear operation. void _atomic_clear (BOOL *obj, enum memmodel) EXP is the call expression.

Try issuing an __atomic_store, and allow fallback to __sync_lock_release. Failing that, a store is issued by __atomic_store. The only way this can fail is if the bool type is larger than a word size. Unlikely, but handle it anyway for completeness. Assume a single threaded model since there is no atomic support in this case, and no barriers are required.

static rtx expand_builtin_atomic_compare_exchange ( enum machine_mode  mode,
tree  exp,
rtx  target 
)
static

Expand the __atomic_compare_exchange intrinsic: bool __atomic_compare_exchange (TYPE *object, TYPE *expect, TYPE desired, BOOL weak, enum memmodel success, enum memmodel failure) EXP is the CALL_EXPR. TARGET is an optional place for us to store the results.

Expand the operands.

References CALL_EXPR_ARG, expand_mem_thread_fence(), and get_memmodel().

static rtx expand_builtin_atomic_exchange ( )
static

Expand the __atomic_exchange intrinsic: TYPE __atomic_exchange (TYPE *object, TYPE desired, enum memmodel) EXP is the CALL_EXPR. TARGET is an optional place for us to store the results.

Expand the operands.

References boolean_true_node, CALL_EXPR_ARG, const1_rtx, error(), fold_builtin_atomic_is_lock_free(), INTEGRAL_TYPE_P, NULL_RTX, and TREE_TYPE.

static rtx expand_builtin_atomic_fetch_op ( enum machine_mode  mode,
tree  exp,
rtx  target,
enum rtx_code  code,
bool  fetch_after,
bool  ignore,
enum built_in_function  ext_call 
)
static

Expand the __atomic_fetch_XXX intrinsic: TYPE __atomic_fetch_XXX (TYPE *object, TYPE val, enum memmodel) EXP is the CALL_EXPR. TARGET is an optional place for us to store the results. CODE is the operation, PLUS, MINUS, ADD, XOR, or IOR. FETCH_AFTER is true if returning the result of the operation. FETCH_AFTER is false if returning the value before the operation. IGNORE is true if the result is not used. EXT_CALL is the correct builtin for an external call if this cannot be resolved to an instruction sequence.

 Expand the operands.   
 Only try generating instructions if inlining is turned on.   
 Return if a different routine isn't needed for the library call.   
 Change the call to the specified function.   
 Expand the call here so we can emit trailing code.   
 Replace the original function just in case it matters.   
 Then issue the arithmetic correction to return the right result.   
static rtx expand_builtin_atomic_is_lock_free ( )
static

Return true if the parameters to call EXP represent an object which will always generate lock free instructions. The first argument represents the size of the object, and the second parameter is a pointer to the object itself. If NULL is passed for the object, then the result is based on typical alignment for an object of the specified size. Otherwise return NULL

If the value is known at compile time, return the RTX for it.

static rtx expand_builtin_atomic_load ( )
static

Expand the __atomic_load intrinsic: TYPE __atomic_load (TYPE *object, enum memmodel) EXP is the CALL_EXPR. TARGET is an optional place for us to store the results.

Expand the operand.

static void expand_builtin_atomic_signal_fence ( )
static

Expand the __atomic_signal_fence intrinsic: void __atomic_signal_fence (enum memmodel) EXP is the CALL_EXPR.

static rtx expand_builtin_atomic_store ( )
static

Expand the __atomic_store intrinsic: void __atomic_store (TYPE *object, TYPE desired, enum memmodel) EXP is the CALL_EXPR. TARGET is an optional place for us to store the results.

Expand the operands.

static rtx expand_builtin_atomic_test_and_set ( )
static

Expand an atomic test_and_set operation. bool _atomic_test_and_set (BOOL *obj, enum memmodel) EXP is the call expression.

static void expand_builtin_atomic_thread_fence ( )
static

Expand the __atomic_thread_fence intrinsic: void __atomic_thread_fence (enum memmodel) EXP is the CALL_EXPR.

static rtx expand_builtin_bswap ( enum machine_mode  target_mode,
tree  exp,
rtx  target,
rtx  subtarget 
)
static

Expand a call to bswap builtin in EXP. Return NULL_RTX if a normal call should be emitted rather than expanding the function in-line. If convenient, the result should be placed in TARGET. SUBTARGET may be used as the target for computing one of EXP's operands.

References CALL_EXPR_ARG, expand_normal(), NULL_RTX, round_trampoline_addr(), and targetm.

static rtx expand_builtin_bzero ( tree  )
static
static rtx expand_builtin_bzero ( )
static

Expand expression EXP, which is a call to the bzero builtin. Return NULL_RTX if we failed the caller should emit a normal call.

New argument list transforming bzero(ptr x, int y) to memset(ptr x, int 0, size_t y). This is done this way so that if it isn't expanded inline, we fallback to calling bzero instead of memset.

References BITS_PER_UNIT, CALL_EXPR_ARG, EXPR_LOCATION, get_pointer_alignment(), insn_data, NULL_RTX, and validate_arglist().

static rtx expand_builtin_cexpi ( tree  ,
rtx   
)
static
static rtx expand_builtin_cexpi ( )
static

Expand a call to the internal cexpi builtin to the sincos math function. EXP is the expression that is a call to the builtin function; if convenient, the result should be placed in TARGET.

 Try expanding via a sincos optab, fall back to emitting a libcall
 to sincos or cexp.  We are sure we have sincos or cexp because cexpi
 is only generated from sincos, cexp or if we have either of them.   
     Compute into op1 and op2.   
     Make sure not to fold the sincos call again.   
     If we don't have a decl for cexp create one.  This is the
     friendliest fallback if the user calls __builtin_cexpi
     without full target C99 function support.   
     Make sure not to fold the cexp call again.   
 Now build the proper return type.   
static rtx expand_builtin_classify_type ( tree  )
static
static rtx expand_builtin_classify_type ( )
static

Expand a call EXP to __builtin_classify_type.

References mathfn_built_in_1().

static rtx expand_builtin_compare_and_swap ( enum machine_mode  mode,
tree  exp,
bool  is_bool,
rtx  target 
)
static

Expand the __sync_val_compare_and_swap and __sync_bool_compare_and_swap intrinsics. EXP is the CALL_EXPR. IS_BOOL is true if this is the boolean form. TARGET is a place for us to store the results; this is NOT optional if IS_BOOL is true.

Expand the operands.

References BOOL_TYPE_SIZE, CALL_EXPR_ARG, expand_atomic_test_and_set(), get_builtin_sync_mem(), get_memmodel(), and mode_for_size().

static rtx expand_builtin_copysign ( )
static

Expand EXP, a call to copysign, copysignf, or copysignl. Return NULL is a normal call should be emitted rather than expanding the function inline. If convenient, the result should be placed in TARGET. SUBTARGET may be used as the target for computing the operand.

static rtx expand_builtin_expect ( tree  ,
rtx   
)
static
static rtx expand_builtin_expect ( )
static

Expand a call to __builtin_expect. We just return our argument as the builtin_expect semantic should've been already executed by tree branch prediction pass.

When guessing was done, the hints should be already stripped away.

References build_real(), dconst0, expand_expr(), EXPAND_NORMAL, fold_build2_loc, real_format::has_signed_zero, HONOR_SIGNED_ZEROS, NULL_RTX, and TREE_TYPE.

static rtx expand_builtin_fabs ( tree  ,
rtx  ,
rtx   
)
static
static rtx expand_builtin_fabs ( )
static

Expand EXP, a call to fabs, fabsf or fabsl. Return NULL_RTX if a normal call should be emitted rather than expanding the function inline. If convenient, the result should be placed in TARGET. SUBTARGET may be used as the target for computing the operand.

References get_identifier().

static rtx expand_builtin_fork_or_exec ( )
static

Expand fork or exec calls. TARGET is the desired target of the call. EXP is the call. FN is the identificator of the actual function. IGNORE is nonzero if the value is to be ignored.

If we are not profiling, just call the function.

 Otherwise call the wrapper.  This should be equivalent for the rest of
 compiler, so the code does not diverge, and the wrapper may run the
 code necessary for keeping the profiling sane.   
static rtx expand_builtin_frame_address ( tree  ,
tree   
)
static
static rtx expand_builtin_frame_address ( )
static

Expand a call to one of the builtin functions __builtin_frame_address or __builtin_return_address.

 The argument must be a nonnegative integer constant.
 It counts the number of frames to scan up the stack.
 The value is the return address saved in that frame.   
   Warning about missing arg was already issued.   
     Some ports cannot access arbitrary stack frames.   
     For __builtin_frame_address, return what we've got.   
static rtx expand_builtin_init_trampoline ( )
static
 If ONSTACK, the TRAMP argument should be the address of a field
 within the local function's FRAME decl.  Either way, let's see if
 we can fill in the MEM_ATTRs for this memory.   
 Creator of a heap trampoline is responsible for making sure the
 address is aligned to at least STACK_BOUNDARY.  Normally malloc
 will ensure this anyhow.   
 The FUNC argument should be the address of the nested function.
 Extract the actual function decl to pass to the hook.   
 Generate insns to initialize the trampoline.   
static rtx expand_builtin_int_roundingfn ( tree  ,
rtx   
)
static
static rtx expand_builtin_int_roundingfn ( )
static

Expand a call to one of the builtin rounding functions gcc defines as an extension (lfloor and lceil). As these are gcc extensions we do not need to worry about setting errno to EDOM. If expanding via optab fails, lower expression to (int)(floor(x)). EXP is the expression that is a call to the builtin function; if convenient, the result should be placed in TARGET.

 Make a suitable register to place result in.   
 Wrap the computation of the argument in a SAVE_EXPR, as we may
 need to expand the argument again.  This way, we will not perform
 side-effects more the once.   
 Compute into TARGET.   
     Output the entire sequence.   
 If we were unable to expand via the builtin, stop the sequence
 (without outputting the insns).   
 Fall back to floating point rounding optab.   
 For non-C99 targets we may end up without a fallback fndecl here
 if the user called __builtin_lfloor directly.  In this case emit
 a call to the floor/ceil variants nevertheless.  This should result
 in the best user experience for not full C99 targets.   
 Truncate the result of floating point optab to integer
 via expand_fix ().   
static rtx expand_builtin_int_roundingfn_2 ( tree  ,
rtx   
)
static
static rtx expand_builtin_int_roundingfn_2 ( )
static

Expand a call to one of the builtin math functions doing integer conversion (lrint). Return 0 if a normal call should be emitted rather than expanding the function in-line. EXP is the expression that is a call to the builtin function; if convenient, the result should be placed in TARGET.

     FALLTHRU  
     FALLTHRU  
 There's no easy way to detect the case we need to set EDOM.   
 Make a suitable register to place result in.   
 There's no easy way to detect the case we need to set EDOM.   
     Wrap the computation of the argument in a SAVE_EXPR, as we may
     need to expand the argument again.  This way, we will not perform
     side-effects more the once.   
         Output the entire sequence.   
     If we were unable to expand via the builtin, stop the sequence
     (without outputting the insns) and call to the library function
     with the stabilized argument list.   
     Fall back to rounding to long int.  Use implicit_p 0 - for non-C99
     targets, (int) round (x) should never be transformed into
     BUILT_IN_IROUND and if __builtin_iround is called directly, emit
     a call to lround in the hope that the target provides at least some
     C99 functions.  This should result in the best user experience for
     not full C99 targets.   
static rtx expand_builtin_interclass_mathfn ( tree  ,
rtx   
)
static
static rtx expand_builtin_interclass_mathfn ( )
static

Expand a call to one of the builtin math functions that operate on floating point argument and output an integer result (ilogb, isinf, isnan, etc). Return 0 if a normal call should be emitted rather than expanding the function in-line. EXP is the expression that is a call to the builtin function; if convenient, the result should be placed in TARGET.

Wrap the computation of the argument in a SAVE_EXPR, as we may need to expand the argument again. This way, we will not perform side-effects more the once.

static void expand_builtin_longjmp ( )
static

__builtin_longjmp is passed a pointer to an array of five words (not all will be used on all machines). It operates similarly to the C library function of the same name, but is more efficient. Much of the code below is copied from the handling of non-local gotos.

 DRAP is needed for stack realign if longjmp is expanded to current
 function   
 We require that the user must pass a second argument of 1, because
 that is what builtin_setjmp will return.   
     Pick up FP, label, and SP from the block and jump.  This code is
     from expand_goto in stmt.c; see there for detailed comments.   
 Search backwards and mark the jump insn as a non-local goto.
 Note that this precludes the use of __builtin_longjmp to a
 __builtin_setjmp target in the same function.  However, we've
 already cautioned the user that these functions are for
 internal exception handling use only.   

References add_reg_note(), CALL_P, const0_rtx, gcc_assert, and JUMP_P.

static rtx expand_builtin_mathfn ( tree  ,
rtx  ,
rtx   
)
static
static rtx expand_builtin_mathfn ( )
static

Expand a call to one of the builtin math functions (sqrt, exp, or log). Return NULL_RTX if a normal call should be emitted rather than expanding the function in-line. EXP is the expression that is a call to the builtin function; if convenient, the result should be placed in TARGET. SUBTARGET may be used as the target for computing one of EXP's operands.

Else fallthrough and expand as rint.   
 Make a suitable register to place result in.   


 Before working hard, check whether the instruction is available, but try
 to widen the mode for specific operations.   
     Wrap the computation of the argument in a SAVE_EXPR, as we may
     need to expand the argument again.  This way, we will not perform
     side-effects more the once.   
     Compute into RESULT.
     Set RESULT to wherever the result comes back.   
         Output the entire sequence.   
     If we were unable to expand via the builtin, stop the sequence
     (without outputting the insns) and call to the library function
     with the stabilized argument list.   
static rtx expand_builtin_mathfn_2 ( tree  ,
rtx  ,
rtx   
)
static
static rtx expand_builtin_mathfn_2 ( )
static

Expand a call to the builtin binary math functions (pow and atan2). Return NULL_RTX if a normal call should be emitted rather than expanding the function in-line. EXP is the expression that is a call to the builtin function; if convenient, the result should be placed in TARGET. SUBTARGET may be used as the target for computing one of EXP's operands.

   Fall through...  
 Make a suitable register to place result in.   
 Before working hard, check whether the instruction is available.   
 Always stabilize the argument list.   
 Compute into RESULT.
 Set RESULT to wherever the result comes back.   
 If we were unable to expand via the builtin, stop the sequence
 (without outputting the insns) and call to the library function
 with the stabilized argument list.   
 Output the entire sequence.   
static rtx expand_builtin_mathfn_3 ( tree  ,
rtx  ,
rtx   
)
static
static rtx expand_builtin_mathfn_3 ( )
static

Expand a call to the builtin sin and cos math functions. Return NULL_RTX if a normal call should be emitted rather than expanding the function in-line. EXP is the expression that is a call to the builtin function; if convenient, the result should be placed in TARGET. SUBTARGET may be used as the target for computing one of EXP's operands.

 Make a suitable register to place result in.   
 Check if sincos insn is available, otherwise fallback
 to sin or cos insn.   
 Before working hard, check whether the instruction is available.   
     Wrap the computation of the argument in a SAVE_EXPR, as we may
     need to expand the argument again.  This way, we will not perform
     side-effects more the once.   
     Compute into RESULT.
     Set RESULT to wherever the result comes back.   
         Output the entire sequence.   
     If we were unable to expand via the builtin, stop the sequence
     (without outputting the insns) and call to the library function
     with the stabilized argument list.   
static rtx expand_builtin_mathfn_ternary ( tree  ,
rtx  ,
rtx   
)
static
static rtx expand_builtin_mathfn_ternary ( )
static

Expand a call to the builtin trinary math functions (fma). Return NULL_RTX if a normal call should be emitted rather than expanding the function in-line. EXP is the expression that is a call to the builtin function; if convenient, the result should be placed in TARGET. SUBTARGET may be used as the target for computing one of EXP's operands.

 Make a suitable register to place result in.   
 Before working hard, check whether the instruction is available.   
 Always stabilize the argument list.   
 Compute into RESULT.
 Set RESULT to wherever the result comes back.   
 If we were unable to expand via the builtin, stop the sequence
 (without outputting the insns) and call to the library function
 with the stabilized argument list.   
 Output the entire sequence.   
static rtx expand_builtin_memcmp ( tree  exp,
rtx  target,
enum machine_mode  mode 
)
static

Expand expression EXP, which is a call to the memcmp built-in function. Return NULL_RTX if we failed and the caller should emit a normal call, otherwise try to get the result in TARGET, if convenient (and in mode MODE, if that's convenient).

Note: The cmpstrnsi pattern, if it exists, is not suitable for implementing memcmp because it will stop if it encounters two zero bytes.

static rtx expand_builtin_memcpy ( tree  ,
rtx   
)
static
static rtx expand_builtin_memcpy ( )
static

Expand a call EXP to the memcpy builtin. Return NULL_RTX if we failed, the caller should emit a normal call, otherwise try to get the result in TARGET, if convenient (and in mode MODE if that's convenient).

     If DEST is not a pointer type, call the normal function.   
     If either SRC is not a pointer type, don't do this
     operation in-line.   
     If SRC is a string constant and block move would be done
     by pieces, we can avoid loading the string from memory
     and only stored the computed constants.   
     Copy word part most expediently.   

References CALL_EXPR_ARG, expand_builtin_strcpy_args(), NULL_RTX, and validate_arglist().

static rtx expand_builtin_memory_chk ( tree  exp,
rtx  target,
enum machine_mode  mode,
enum built_in_function  fcode 
)
static

Expand EXP, a call to the __mem{cpy,pcpy,move,set}_chk builtin. FCODE is the BUILT_IN_* to use. Return NULL_RTX if we failed; the caller should emit a normal call, otherwise try to get the result in TARGET, if convenient (and in mode MODE if that's convenient).

     If __builtin_mem{cpy,pcpy,move,set}_chk is used, assume
     mem{cpy,pcpy,move,set} is available.   
     If DEST is not a pointer type, call the normal function.   
     If SRC and DEST are the same (and not volatile), do nothing.   
             Evaluate and ignore LEN in case it has side-effects.   
     __memmove_chk special case.   
         If src is categorized for a readonly section we can use
         normal __memcpy_chk.   

References c_getstr(), NULL, and NULL_TREE.

static rtx expand_builtin_mempcpy ( tree  ,
rtx  ,
enum  machine_mode 
)
static
static rtx expand_builtin_mempcpy ( )
static

Expand a call EXP to the mempcpy builtin. Return NULL_RTX if we failed; the caller should emit a normal call, otherwise try to get the result in TARGET, if convenient (and in mode MODE if that's convenient). If ENDP is 0 return the destination pointer, if ENDP is 1 return the end pointer ala mempcpy, and if ENDP is 2 return the end pointer minus one ala stpcpy.

static rtx expand_builtin_mempcpy_args ( tree  dest,
tree  src,
tree  len,
rtx  target,
enum machine_mode  mode,
int  endp 
)
static

Helper function to do the actual work for expand_builtin_mempcpy. The arguments to the builtin_mempcpy call DEST, SRC, and LEN are broken out so that this can also be called without constructing an actual CALL_EXPR. The other arguments and return value are the same as for expand_builtin_mempcpy.

   If return value is ignored, transform mempcpy into memcpy.   
     If either SRC or DEST is not a pointer type, don't do this
     operation in-line.   
     If LEN is not constant, call the normal function.   
     If SRC is a string constant and block move would be done
     by pieces, we can avoid loading the string from memory
     and only stored the computed constants.   

References c_readstr(), and const0_rtx.

static rtx expand_builtin_memset ( tree  ,
rtx  ,
enum  machine_mode 
)
static
static rtx expand_builtin_memset ( )
static

Expand expression EXP, which is a call to the memset builtin. Return NULL_RTX if we failed the caller should emit a normal call, otherwise try to get the result in TARGET, if convenient (and in mode MODE if that's convenient).

References convert_move().

static rtx expand_builtin_memset_args ( tree  dest,
tree  val,
tree  len,
rtx  target,
enum machine_mode  mode,
tree  orig_exp 
)
static

Helper function to do the actual work for expand_builtin_memset. The arguments to the builtin_memset call DEST, VAL, and LEN are broken out so that this can also be called without constructing an actual CALL_EXPR. The other arguments and return value are the same as for expand_builtin_memset.

 If DEST is not a pointer type, don't do this operation in-line.   
 If the LEN parameter is zero, return DEST.   
     Evaluate and ignore VAL in case it has side-effects.   
 Stabilize the arguments in case we fail.   
     Assume that we can memset by pieces if we can store
     the coefficients by pieces (in the required modes).
     We can't pass builtin_memset_gen_str as that emits RTL.   

References BITS_PER_UNIT, build_call_nofold_loc(), builtin_save_expr(), c_strlen(), CALL_EXPR_ARG, CALL_EXPR_TAILCALL, const0_rtx, convert_move(), convert_to_mode(), emit_insn(), expand_call(), expand_normal(), EXPR_LOCATION, gcc_assert, GEN_INT, gen_reg_rtx(), get_callee_fndecl(), get_memory_rtx(), GET_MODE, get_pointer_alignment(), insn_data, MIN, NULL, NULL_RTX, REG_P, REGNO, size_binop, ssize_int, TREE_CODE, tree_int_cst_lt(), TREE_SIDE_EFFECTS, TREE_TYPE, and TYPE_MODE.

static rtx expand_builtin_next_arg ( )
static

Expand a call to __builtin_next_arg.

Checking arguments is already done in fold_builtin_next_arg that must be called before this function.

Referenced by expand_builtin_strncmp().

static rtx expand_builtin_nonlocal_goto ( )
static

Expand a call to __builtin_nonlocal_goto. We're passed the target label and the address of the save area.

 Copy the address of the save location to a register just in case it was
 based on the frame pointer.    
     Restore frame pointer for containing function.   
     USE of hard_frame_pointer_rtx added for consistency;
     not clear if really needed.   
     If the architecture is using a GP register, we must
     conservatively assume that the target function makes use of it.
     The prologue of functions with nonlocal gotos must therefore
     initialize the GP register to the appropriate value, and we
     must then make sure that this value is live at the point
     of the jump.  (Note that this doesn't necessarily apply
     to targets with a nonlocal_goto pattern; they are free
     to implement it in their own way.  Note also that this is
     a no-op if the GP register is a global invariant.)   
 Search backwards to the jump insn and mark it as a
 non-local goto.   
static rtx expand_builtin_object_size ( tree  )
static
rtx expand_builtin_object_size ( )

Expand a call EXP to __builtin_object_size.

References host_integerp(), NULL_TREE, and tree_int_cst_lt().

static rtx expand_builtin_powi ( )
static

Expand a call to the powi built-in mathematical function. Return NULL_RTX if a normal call should be emitted rather than expanding the function in-line. EXP is the expression that is a call to the builtin function; if convenient, the result should be placed in TARGET.

Emit a libcall to libgcc.

 Mode of the 2nd argument must match that of an int.   
static void expand_builtin_prefetch ( tree  )
static
static void expand_builtin_prefetch ( )
static

Expand a call to __builtin_prefetch. For a target that does not support data prefetch, evaluate the memory address argument in case it has side effects.

 Arguments 1 and 2 are optional; argument 1 (read/write) defaults to
 zero (read) and argument 2 (locality) defaults to 3 (high degree of
 locality).   
 Argument 0 is an address.   
 Argument 1 (read/write flag) must be a compile-time constant int.   
 Argument 1 must be either zero or one.   
 Argument 2 (locality) must be a compile-time constant int.   
 Argument 2 must be 0, 1, 2, or 3.   
 Don't do anything with direct references to volatile memory, but
 generate code to handle other side effects.   

References build_array_type(), build_fold_addr_expr, build_int_cst(), build_range_type(), char_type_node, CONVERT_EXPR_P, exp(), expand_expr(), EXPAND_NORMAL, fold_build2, gen_rtx_MEM(), get_base_address(), is_gimple_mem_ref_addr(), memory_address, NULL, NULL_RTX, POINTER_TYPE_P, ptr_mode, ptr_type_node, SAVE_EXPR_RESOLVED_P, set_mem_alias_set(), set_mem_attributes(), size_one_node, size_zero_node, sizetype, TREE_CODE, TREE_OPERAND, and TREE_TYPE.

static void expand_builtin_return ( rtx  )
static
static void expand_builtin_return ( )
static

Perform an untyped return.

 Restore the return value and note that each value is used.   
 Put the USE insns before the return.   
 Return whatever values was restored by jumping directly to the end
 of the function.   
static rtx expand_builtin_return_addr ( )
static

Given TEM, a pointer to a stack frame, follow the dynamic chain COUNT times to get the address of either a higher stack frame, or a return address located within it (depending on FNDECL_CODE).

 For a zero count with __builtin_return_address, we don't care what
 frame address we return, because target-specific definitions will
 override us.  Therefore frame pointer elimination is OK, and using
 the soft frame pointer is OK.

 For a nonzero count, or a zero count with __builtin_frame_address,
 we require a stable offset from the current frame pointer to the
 previous one, so we must use the hard frame pointer, and
 we must disable frame pointer elimination.   
     Tell reload not to eliminate the frame pointer.   
 Some machines need special handling before we can access
 arbitrary frames.  For example, on the SPARC, we must first flush
 all register windows to the stack.   
 On the SPARC, the return address is not in the frame, it is in a
 register.  There is no way to access it off of the current frame
 pointer, but it can be accessed off the previous frame pointer by
 reading the value from the register window save area.   
 Scan back COUNT frames to the specified frame.   
     Assume the dynamic chain pointer is in the word that the
     frame address points to, unless otherwise specified.   
 For __builtin_frame_address, return what we've got.  But, on
 the SPARC for example, we may have to add a bias.   
 For __builtin_return_address, get the return address from that frame.   

References copy_to_reg(), gen_frame_mem(), and memory_address.

rtx expand_builtin_saveregs ( void  )

Expand a call to __builtin_saveregs, generating the result in TARGET, if that's convenient.

 Don't do __builtin_saveregs more than once in a function.
 Save the result of the first call and reuse it.   
 When this function is called, it means that registers must be
 saved on entry to this function.  So we migrate the call to the
 first insn of this function.   
 Do whatever the machine needs done in this case.   
 Put the insns after the NOTE that starts the function.  If this
 is inside a start_sequence, make the outer-level insn chain current, so
 the code is placed at the start of the function.   
static void expand_builtin_set_thread_pointer ( )
static
void expand_builtin_setjmp_receiver ( )

Construct the trailing part of a __builtin_setjmp call. This is also called directly by the SJLJ exception handling code. If RECEIVER_LABEL is NULL, instead contruct a nonlocal goto handler.

 Mark the FP as used when we get here, so we have to make sure it's
 marked as used by this function.   
 Mark the static chain as clobbered here so life information
 doesn't get messed up for it.   
 Now put in the code to restore the frame pointer, and argument
 pointer, if needed.   
   First adjust our frame pointer to its actual value.  It was
   previously set to the start of the virtual area corresponding to
   the stacked variables when we branched here and now needs to be
   adjusted to the actual hardware fp value.

   Assignments to virtual registers are converted by
   instantiate_virtual_regs into the corresponding assignment
   to the underlying register (fp in this case) that makes
   the original assignment true.
   So the following insn will actually be decrementing fp by
   STARTING_FRAME_OFFSET.   
 We must not allow the code we just generated to be reordered by
 scheduling.  Specifically, the update of the frame pointer must
 happen immediately, not later.  Similarly, we must block
 (frame-related) register values to be used across this code.   
void expand_builtin_setjmp_setup ( )

Construct the leading half of a __builtin_setjmp call. Control will return to RECEIVER_LABEL. This is also called directly by the SJLJ exception handling code.

 We store the frame pointer and the address of receiver_label in
 the buffer and use the rest of it for the stack save area, which
 is machine-dependent.   
 If there is further processing to do, do it.   
 We have a nonlocal label.    

References targetm.

static rtx expand_builtin_signbit ( tree  ,
rtx   
)
static
static rtx expand_builtin_signbit ( )
static

Expand the call EXP to the built-in signbit, signbitf or signbitl function. The function first checks whether the back end provides an insn to implement signbit for the respective mode. If not, it checks whether the floating point format of the value is such that the sign bit can be extracted. If that is not the case, the function returns NULL_RTX to indicate that a normal call should be emitted rather than expanding the function in-line. EXP is the expression that is a call to the builtin function; if convenient, the result should be placed in TARGET.

 Expand the argument yielding a RTX expression.  
 Check if the back end provides an insn that handles signbit for the
 argument's mode.  
 For floating point formats without a sign bit, implement signbit
 as "ARG < 0.0".   
   But we can't do this if the format supports signed zero.   
     Handle targets with different FP word orders.   
 Force the intermediate word_mode (or narrower) result into a
 register.  This avoids attempting to create paradoxical SUBREGs
 of floating point modes below.   
 If the bitpos is within the "result mode" lowpart, the operation
 can be implement with a single bitwise AND.  Otherwise, we need
 a right shift and an AND.   
     Perform a logical right shift to place the signbit in the least
     significant bit, then truncate the result to the desired mode
     and mask just this bit.   
static rtx expand_builtin_sincos ( tree  )
static
static rtx expand_builtin_sincos ( )
static

Expand a call to the builtin sincos math function. Return NULL_RTX if a normal call should be emitted rather than expanding the function in-line. EXP is the expression that is a call to the builtin function.

 Make a suitable register to place result in.   
 Check if sincos insn is available, otherwise emit the call.   
 Compute into target1 and target2.
 Set TARGET to wherever the result comes back.   
 Move target1 and target2 to the memory locations indicated
 by op1 and op2.   

References builtin_save_expr(), CALL_EXPR_ARG, CASE_FLT_FN, DECL_FUNCTION_CODE, emit_insn(), end_sequence(), expand_expr(), EXPAND_NORMAL, expand_sfix_optab(), gcc_unreachable, gen_reg_rtx(), get_callee_fndecl(), get_insns(), NULL, start_sequence(), TREE_TYPE, TYPE_MODE, and validate_arglist().

static rtx expand_builtin_stpcpy ( tree  ,
rtx  ,
enum  machine_mode 
)
static
static rtx expand_builtin_stpcpy ( )
static

Expand a call EXP to the stpcpy builtin. Return NULL_RTX if we failed the caller should emit a normal call, otherwise try to get the result in TARGET, if convenient (and in mode MODE if that's convenient).

If return value is ignored, transform stpcpy into strcpy.

     Ensure we get an actual string whose length can be evaluated at
     compile-time, not an expression containing a string.  This is
     because the latter will potentially produce pessimized code
     when used to produce the return value.   
static rtx expand_builtin_strcmp ( tree  ,
rtx   
)
static
static rtx expand_builtin_strcmp ( )
static

Expand expression EXP, which is a call to the strcmp builtin. Return NULL_RTX if we failed the caller should emit a normal call, otherwise try to get the result in TARGET, if convenient.

References targetm.

static rtx expand_builtin_strcpy ( tree  ,
rtx   
)
static
static rtx expand_builtin_strcpy ( )
static

Expand expression EXP, which is a call to the strcpy builtin. Return NULL_RTX if we failed the caller should emit a normal call, otherwise try to get the result in TARGET, if convenient (and in mode MODE if that's convenient).

static rtx expand_builtin_strcpy_args ( tree  ,
tree  ,
rtx   
)
static

Referenced by expand_builtin_memcpy().

static rtx expand_builtin_strcpy_args ( )
static

Helper function to do the actual work for expand_builtin_strcpy. The arguments to the builtin_strcpy call DEST and SRC are broken out so that this can also be called without constructing an actual CALL_EXPR. The other arguments and return value are the same as for expand_builtin_strcpy.

References const0_rtx, expand_expr(), and EXPAND_NORMAL.

static rtx expand_builtin_strlen ( tree  exp,
rtx  target,
enum machine_mode  target_mode 
)
static

Expand expression EXP which is a call to the strlen builtin. Return NULL_RTX if we failed the caller should emit a normal call, otherwise try to get the result in TARGET, if convenient.

     If the length can be computed at compile-time, return it.   
     If the length can be computed at compile-time and is constant
     integer, but there are side-effects in src, evaluate
     src for side-effects, then return len.
     E.g. x = strlen (i++ ? "xfoo" + 1 : "bar");
     can be optimized into: i++; x = 3;   
     If SRC is not a pointer type, don't do this operation inline.   
     Bail out if we can't compute strlen in the right mode.   
     Make a place to hold the source address.  We will not expand
     the actual source until we are sure that the expansion will
     not fail &ndash; there are trees that cannot be expanded twice.   
     Mark the beginning of the strlen sequence so we can emit the
     source operand later.   
     Now that we are assured of success, expand the source.   
     Return the value in the proper mode for this function.   
static rtx expand_builtin_strncmp ( tree  exp,
rtx  target,
enum machine_mode  mode 
)
static

Expand expression EXP, which is a call to the strncmp builtin. Return NULL_RTX if we failed the caller should emit a normal call, otherwise try to get the result in TARGET, if convenient.

If c_strlen can determine an expression for one of the string lengths, and it doesn't have side effects, then emit cmpstrnsi using length MIN(strlen(string)+1, arg3).

References CALL_EXPR_ARG, call_expr_nargs, const0_rtx, error_at(), expand_builtin_next_arg(), EXPR_LOCATION, fold_builtin_next_arg(), stabilize_va_list_loc(), std_expand_builtin_va_start(), and targetm.

static rtx expand_builtin_strncpy ( tree  ,
rtx   
)
static
static rtx expand_builtin_strncpy ( )
static

Expand expression EXP, which is a call to the strncpy builtin. Return NULL_RTX if we failed the caller should emit a normal call.

We must be passed a constant len and src parameter.

     We're required to pad with trailing zeros if the requested
     len is greater than strlen(s2)+1.  In that case try to
     use store_by_pieces, if it fails, punt.   
static void expand_builtin_sync_lock_release ( )
static

Expand the __sync_lock_release intrinsic. EXP is the CALL_EXPR.

Expand the operands.

static rtx expand_builtin_sync_lock_test_and_set ( enum machine_mode  mode,
tree  exp,
rtx  target 
)
static

Expand the __sync_lock_test_and_set intrinsic. Note that the most general form is actually an atomic exchange, and some targets only support a reduced form with the second argument being a constant 1. EXP is the CALL_EXPR; TARGET is an optional place for us to store the results.

Expand the operands.

static rtx expand_builtin_sync_operation ( enum machine_mode  mode,
tree  exp,
enum rtx_code  code,
bool  after,
rtx  target 
)
static

Expand the __sync_xxx_and_fetch and __sync_fetch_and_xxx intrinsics. EXP is the CALL_EXPR. CODE is the rtx code that corresponds to the arithmetic or logical operation from the name; an exception here is that NOT actually means NAND. TARGET is an optional place for us to store the results; AFTER is true if this is the fetch_and_xxx form.

Expand the operands.

References expand_simple_binop(), expand_simple_unop(), NULL_RTX, and OPTAB_LIB_WIDEN.

static void expand_builtin_sync_synchronize ( )
static

Expand the __sync_synchronize intrinsic.

static rtx expand_builtin_thread_pointer ( )
static
void expand_builtin_trap ( void  )
static rtx expand_builtin_unop ( enum machine_mode  target_mode,
tree  exp,
rtx  target,
rtx  subtarget,
optab  op_optab 
)
static

Expand a call to a unary builtin in EXP. Return NULL_RTX if a normal call should be emitted rather than expanding the function in-line. If convenient, the result should be placed in TARGET. SUBTARGET may be used as the target for computing one of EXP's operands.

Compute the argument.

 Compute op, into TARGET if possible.
 Set TARGET to wherever the result comes back.   
static void expand_builtin_unreachable ( )
static

Expand a call to __builtin_unreachable. We do nothing except emit a barrier saying that control flow will not pass here.

It is the responsibility of the program being compiled to ensure that control flow does never reach __builtin_unreachable.

static void expand_builtin_update_setjmp_buf ( rtx  )
static
static void expand_builtin_update_setjmp_buf ( )
static

__builtin_update_setjmp_buf is passed a pointer to an array of five words (not all will be used on all machines) that was passed to __builtin_setjmp. It updates the stack pointer in that block to correspond to the current stack pointer.

References create_address_operand(), create_integer_operand(), INTVAL, and maybe_expand_insn().

static rtx expand_builtin_va_copy ( tree  )
static
static rtx expand_builtin_va_copy ( )
static

Expand EXP, a call to __builtin_va_copy. We do this as a builtin rather than just as an assignment in stdarg.h because of the nastiness of array-type va_list types.

     Evaluate to pointers.   
     "Dereference" to BLKmode memories.   
     Copy.   

References build1, build4, build_array_type(), build_index_type(), build_pointer_type(), build_string(), build_type_variant, char_type_node, integer_zero_node, NULL_TREE, size_int, TREE_CONSTANT, TREE_READONLY, TREE_STATIC, TREE_TYPE, and type().

static rtx expand_builtin_va_end ( tree  )
static
static rtx expand_builtin_va_end ( )
static

Expand EXP, a call to __builtin_va_end.

Evaluate for side effects, if needed. I hate macros that don't do that.

References CALL_EXPR_ARG, expand_copysign(), expand_expr(), EXPAND_NORMAL, expand_normal(), and NULL_RTX.

static rtx expand_builtin_va_start ( tree  )
static
static rtx expand_builtin_va_start ( )
static

Expand EXP, a call to __builtin_va_start.

References builtin_save_expr(), CALL_EXPR_ARG, expand_abs(), expand_expr(), EXPAND_NORMAL, NULL_RTX, safe_from_p(), TREE_TYPE, and TYPE_MODE.

static void expand_errno_check ( tree  ,
rtx   
)
static
static void expand_errno_check ( )
static

If errno must be maintained, expand the RTL to check if the result, TARGET, of a built-in function call, EXP, is NaN, and if so set errno to EDOM.

 Test the result; if it is NaN, set errno=EDOM because
 the argument was not in the domain.   
                          The jump is very likely.   
 Make sure the library call isn't expanded as a tail call.   
 We can't set errno=EDOM directly; let the library call do it.
 Pop the arguments right away in case the call gets deleted.   
static rtx expand_expr_force_mode ( )
static

Make sure an argument is in the right mode. EXP is the tree argument. MODE is the mode it should be in.

If VAL is promoted to a wider mode, convert it back to MODE. Take care of CONST_INTs, where we know the old_mode only from the call argument.

Referenced by get_builtin_sync_mem().

static rtx expand_movstr ( )
static

Expand into a movstr instruction, if one is available. Return NULL_RTX if we failed, the caller should emit a normal call, otherwise try to get the result in TARGET, if convenient. If ENDP is 0 return the destination pointer, if ENDP is 1 return the end pointer ala mempcpy, and if ENDP is 2 return the end pointer minus one ala stpcpy.

movstr is supposed to set end to the address of the NUL terminator. If the caller requested a mempcpy-like return value, adjust it.

static tree fold_builtin_0 ( location_t  ,
tree  ,
bool   
)
static
static tree fold_builtin_0 ( )
static

Fold a call to built-in function FNDECL with 0 arguments. IGNORE is true if the result of the function call is ignored. This function returns NULL_TREE if no simplification was possible.

static tree fold_builtin_1 ( location_t  ,
tree  ,
tree  ,
bool   
)
static
static tree fold_builtin_1 ( )
static

Fold a call to built-in function FNDECL with 1 argument, ARG0. IGNORE is true if the result of the function call is ignored. This function returns NULL_TREE if no simplification was possible.

Gimplification will pull the CALL_EXPR for the builtin out of an if condition. When not optimizing, we'll not CSE it back. To avoid link error types of regressions, return false now.

static tree fold_builtin_2 ( location_t  ,
tree  ,
tree  ,
tree  ,
bool   
)
static
static tree fold_builtin_2 ( )
static

Fold a call to built-in function FNDECL with 2 arguments, ARG0 and ARG1. IGNORE is true if the result of the function call is ignored. This function returns NULL_TREE if no simplification was possible.

We do the folding for va_start in the expander.

References CALL_EXPR_ARGP, call_expr_nargs, and rewrite_call_expr_valist().

static tree fold_builtin_3 ( location_t  loc,
tree  fndecl,
tree  arg0,
tree  arg1,
tree  arg2,
bool  ignore 
)
static

Fold a call to built-in function FNDECL with 3 arguments, ARG0, ARG1, and ARG2. IGNORE is true if the result of the function call is ignored. This function returns NULL_TREE if no simplification was possible.

static tree fold_builtin_4 ( location_t  loc,
tree  fndecl,
tree  arg0,
tree  arg1,
tree  arg2,
tree  arg3,
bool  ignore 
)
static

Fold a call to built-in function FNDECL with 4 arguments, ARG0, ARG1, ARG2, and ARG3. IGNORE is true if the result of the function call is ignored. This function returns NULL_TREE if no simplification was possible.

References build_call_expr_loc(), build_int_cst(), builtin_decl_implicit(), c_getstr(), fold_build_pointer_plus_hwi_loc(), fold_convert_loc(), integer_zerop(), NULL, NULL_TREE, target_char_cast(), TREE_CODE, TREE_TYPE, and validate_arg().

static tree fold_builtin_abs ( location_t  ,
tree  ,
tree   
)
static
static tree fold_builtin_abs ( )
static

Fold a call to abs, labs, llabs or imaxabs with argument ARG.

static tree fold_builtin_atomic_always_lock_free ( )
static

Return true if (optional) argument ARG1 of size ARG0 is always lock free on this architecture. If ARG1 is NULL, use typical alignment for size ARG0.

     This function is usually invoked and folded immediately by the front
     end before anything else has a chance to look at it.  The pointer
     parameter at this point is usually cast to a void *, so check for that
     and look past the cast.   
     Get the underlying type of the object.   
 If the object has smaller alignment, the the lock free routines cannot
 be used.   
 Check if a compare_and_swap pattern exists for the mode which represents
 the required size.  The pattern is not allowed to fail, so the existence
 of the pattern indicates support is present.   

Referenced by get_memmodel().

static tree fold_builtin_atomic_is_lock_free ( )
static

Return a one or zero if it can be determined that object ARG1 of size ARG is lock free on this architecture.

If it isn't always lock free, don't generate a result.

Referenced by expand_builtin_atomic_exchange().

static tree fold_builtin_bitop ( tree  ,
tree   
)
static
static tree fold_builtin_bitop ( )
static

Fold function call to builtin ffs, clz, ctz, popcount and parity and their long and long long variants (i.e. ffsl and ffsll). ARG is the argument to the call. Return NULL_TREE if no simplification can be made.

Optimize for constant argument.

     Clear all the bits that are beyond the type's precision.   

References builtin_mathfn_code(), CALL_EXPR_ARG, and fold_convert_loc().

static tree fold_builtin_bswap ( )
static

Fold function call to builtin_bswap and the short, long and long long variants. Return NULL_TREE if no simplification can be made.

Optimize constant value.

static tree fold_builtin_bzero ( )
static

Fold function call to builtin memset. Return NULL_TREE if no simplification can be made.

New argument list transforming bzero(ptr x, int y) to memset(ptr x, int 0, size_t y). This is done this way so that if it isn't expanded inline, we fallback to calling bzero instead of memset.

Referenced by fold_builtin_classify().

static tree fold_builtin_cabs ( )
static

Fold call to builtin cabs, cabsf or cabsl with argument ARG. TYPE is the return type. Return NULL_TREE if no simplification can be made.

 Calculate the result when the argument is a constant.   
     If either part is zero, cabs is fabs of the other.   
     cabs(x+xi) -> fabs(x)*sqrt(2).   
 Optimize cabs(-z) and cabs(conj(z)) as cabs(z).   
 Don't do this when optimizing for size.   

References targetm.

tree fold_builtin_call_array ( location_t  loc,
tree  type,
tree  fn,
int  n,
tree argarray 
)

Construct a CALL_EXPR with type TYPE with FN as the function expression. N arguments are passed in the array ARGARRAY.

       If last argument is __builtin_va_arg_pack (), arguments to this
       function are not finalized yet.  Defer folding until they are.   
           First try the transformations that don't require consing up
           an exp.   
       If we got this far, we need to build an exp.   
static tree fold_builtin_carg ( )
static

Fold a call to builtin carg(a+bi) -> atan2(b,a).

References fold_builtin_constant_p(), and integer_zero_node.

static tree fold_builtin_cbrt ( location_t  ,
tree  ,
tree   
)
static
static tree fold_builtin_cbrt ( )
static

Fold a builtin function call to cbrt, cbrtf, or cbrtl with argument ARG. Return NULL_TREE if no simplification can be made.

 Calculate the result when the argument is a constant.   
     Optimize cbrt(expN(x)) -> expN(x/3).   
     Optimize cbrt(sqrt(x)) -> pow(x,1/6).   
     Optimize cbrt(cbrt(x)) -> pow(x,1/9) iff x is nonnegative.   
     Optimize cbrt(pow(x,y)) -> pow(x,y/3) iff x is nonnegative.   

References CASE_INT_FN, CLZ_DEFINED_VALUE_AT_ZERO, CTZ_DEFINED_VALUE_AT_ZERO, ctz_hwi(), DECL_FUNCTION_CODE, ffs_hwi(), floor_log2(), HOST_BITS_PER_DOUBLE_INT, HOST_BITS_PER_WIDE_INT, HOST_WIDE_INT, HOST_WIDE_INT_M1U, NULL_TREE, TREE_CODE, TREE_INT_CST_HIGH, TREE_INT_CST_LOW, TREE_OVERFLOW, TREE_TYPE, type(), TYPE_MODE, TYPE_PRECISION, and validate_arg().

static tree fold_builtin_ccos ( location_t  loc,
tree  arg,
tree  type,
tree  fndecl,
bool  hyper 
)
static

Fold function call to builtin ccos (or ccosh if HYPER is TRUE) with argument ARG. TYPE is the type of the return value. Return NULL_TREE if no simplification can be made.

Calculate the result when the argument is a constant.

     Optimize fn(-x) into fn(x).   
static tree fold_builtin_ceil ( location_t  ,
tree  ,
tree   
)
static
static tree fold_builtin_ceil ( )
static

Fold function call to builtin ceil, ceilf or ceill with argument ARG. Return NULL_TREE if no simplification can be made.

Optimize ceil of constant value.

References build_real(), real_powi(), REAL_VALUE_TYPE, TREE_REAL_CST, and TYPE_MODE.

static tree fold_builtin_cexp ( )
static

Fold function call to builtin cexp, cexpf, or cexpl. Return NULL_TREE if no simplification can be made.

 Calculate the result when the argument is a constant.   
 In case we can figure out the real part of arg0 and it is constant zero
 fold to cexpi.   
 In case we can easily decompose real and imaginary parts split cexp
 to exp (r) * cexpi (i).   

References build_call_expr_loc(), and fold_build2_loc.

static tree fold_builtin_classify ( )
static

Fold a call to __builtin_isnan(), __builtin_isinf, __builtin_finite. ARG is the argument for the call.

isinf_sign(x) -> isinf(x) ? (signbit(x) ? -1 : 1) : 0

       In a boolean context, GCC will fold the inner COND_EXPR to
       1.  So e.g. "if (isinf_sign(x))" would be folded to just
       "if (isinf(x) ? 1 : 0)" which becomes "if (isinf(x))".  

References builtin_decl_implicit(), CASE_FLT_FN, CASE_FLT_FN_REENT, dconst0, do_mpc_arg2(), do_mpfr_arg2(), do_mpfr_bessel_n(), do_mpfr_lgamma_r(), fold_builtin_bzero(), fold_builtin_fputs(), fold_builtin_frexp(), fold_builtin_hypot(), fold_builtin_load_exponent(), fold_builtin_modf(), fold_builtin_strcat(), fold_builtin_strchr(), fold_builtin_strcpy(), fold_builtin_strcspn(), fold_builtin_strrchr(), fold_builtin_strspn(), fold_builtin_strstr(), NULL, NULL_TREE, TREE_CODE, TREE_TYPE, and validate_arg().

static tree fold_builtin_classify_type ( tree  )
static
static tree fold_builtin_classify_type ( )
static

Fold a call to __builtin_classify_type with argument ARG.

static tree fold_builtin_constant_p ( tree  )
static

Referenced by fold_builtin_carg().

static tree fold_builtin_constant_p ( )
static

Fold a call to __builtin_constant_p, if we know its argument ARG will evaluate to a constant.

 We return 1 for a numeric type that's known to be a constant
 value at compile-time or for an aggregate type that's a
 literal constant.   
 If we know this is a constant, emit the constant of one.   
 If this expression has side effects, show we don't know it to be a
 constant.  Likewise if it's a pointer or aggregate type since in
 those case we only want literals, since those are only optimized
 when generating RTL, not later.
 And finally, if we are compiling an initializer, not code, we
 need to return a definite result now; there's not going to be any
 more optimization done.   

References build_real(), dconst_sqrt2, fold_build1_loc, fold_build2_loc, OEP_PURE_SAME, operand_equal_p(), real_value_truncate(), REAL_VALUE_TYPE, real_zerop(), STRIP_NOPS, TREE_OPERAND, and TYPE_MODE.

static tree fold_builtin_copysign ( location_t  loc,
tree  fndecl,
tree  arg1,
tree  arg2,
tree  type 
)
static

Fold function call to builtin copysign, copysignf or copysignl with arguments ARG1 and ARG2. Return NULL_TREE if no simplification can be made.

 copysign(X,X) is X.   
 If ARG1 and ARG2 are compile-time constants, determine the result.   
     c1.sign := c2.sign.   
 copysign(X, Y) is fabs(X) when Y is always non-negative.
 Remember to evaluate Y for side-effects.   
 Strip sign changing operations for the first argument.   
static tree fold_builtin_cos ( location_t  loc,
tree  arg,
tree  type,
tree  fndecl 
)
static

Fold function call to builtin cos, cosf, or cosl with argument ARG. TYPE is the type of the return value. Return NULL_TREE if no simplification can be made.

Calculate the result when the argument is a constant.

 Optimize cos(-x) into cos (x).   
static tree fold_builtin_cosh ( location_t  ,
tree  ,
tree  ,
tree   
)
static
static tree fold_builtin_cosh ( )
static

Fold function call to builtin cosh, coshf, or coshl with argument ARG. Return NULL_TREE if no simplification can be made.

Calculate the result when the argument is a constant.

     Optimize cosh(-x) into cosh (x).   
static tree fold_builtin_cproj ( )
static

Fold call to builtin cproj, cprojf or cprojl with argument ARG. TYPE is the return type. Return NULL_TREE if no simplification can be made.

 If there are no infinities, return arg.   
 Calculate the result when the argument is a constant.   
     If the real part is inf and the imag part is known to be
     nonnegative, return (inf + 0i).  Remember side-effects are
     possible in the imag part.   
     If the imag part is inf, return (inf+I*copysign(0,imag)).
     Remember side-effects are possible in the real part.   
static tree fold_builtin_expect ( location_t  ,
tree  ,
tree   
)
static
static tree fold_builtin_expect ( )
static

Fold a call to builtin_expect with arguments ARG0 and ARG1. Return NULL_TREE if no simplification is possible.

 Distribute the expected value over short-circuiting operators.
 See through the cast from truthvalue_type_node to long.   
 If this is a builtin_expect within a builtin_expect keep the
 inner one.  See through a comparison against a constant.  It
 might have been added to create a thruthvalue.   
 If the argument isn't invariant then there's nothing else we can do.   
 If we expect that a comparison against the argument will fold to
 a constant return the constant.  In practice, this means a true
 constant or the address of a non-weak symbol.   
 Otherwise, ARG0 already has the proper type for the return value.   
static tree fold_builtin_exponent ( location_t  loc,
tree  fndecl,
tree  arg,
int(*)(mpfr_ptr, mpfr_srcptr, mp_rnd_t)  func 
)
static

A subroutine of fold_builtin to fold the various exponent functions. Return NULL_TREE if no simplification can be made. FUNC is the corresponding MPFR exponent function.

Calculate the result when the argument is a constant.

     Optimize expN(logN(x)) = x.   

References build_int_cst(), c_getstr(), compare_tree_int(), fold_build_pointer_plus_hwi_loc(), fold_convert_loc(), host_integerp(), NULL, NULL_TREE, target_char_cast(), TREE_CODE, tree_low_cst(), TREE_TYPE, and validate_arg().

static tree fold_builtin_fabs ( location_t  ,
tree  ,
tree   
)
static
static tree fold_builtin_fabs ( )
static

Fold a call to fabs, fabsf or fabsl with argument ARG.

References build_real(), fold_build2_loc, fold_build3_loc, integer_type_node, and real_inf().

static tree fold_builtin_floor ( location_t  ,
tree  ,
tree   
)
static
static tree fold_builtin_floor ( )
static

Fold function call to builtin floor, floorf or floorl with argument ARG. Return NULL_TREE if no simplification can be made.

Optimize floor of constant value.

 Fold floor (x) where x is nonnegative to trunc (x).   
static tree fold_builtin_fma ( )
static

Fold a call to fma, fmaf, or fmal with arguments ARG[012].

??? Only expand to FMA_EXPR if it's directly supported.

static tree fold_builtin_fmin_fmax ( location_t  loc,
tree  arg0,
tree  arg1,
tree  type,
bool  max 
)
static

Fold a call to builtin fmin or fmax.

     Calculate the result when the argument is a constant.   
     If either argument is NaN, return the other one.  Avoid the
     transformation if we get (and honor) a signalling NaN.  Using
     omit_one_operand() ensures we create a non-lvalue.   
     Transform fmin/fmax(x,x) -> x.   
     Convert fmin/fmax to MIN_EXPR/MAX_EXPR.  C99 requires these
     functions to return the numeric arg if the other one is NaN.
     These tree codes don't honor that, so only transform if
     -ffinite-math-only is set.  C99 doesn't require -0.0 to be
     handled, so we don't have to worry about it either.   
static tree fold_builtin_fpclassify ( )
static

Fold a call to __builtin_fpclassify(int, int, int, int, int, ...). This builtin will generate code to return the appropriate floating point classification depending on the value of the floating point number passed in. The possible return values must be supplied as int arguments to the call in the following order: FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL and FP_ZERO. The ellipses is for exactly one floating point argument which is "type generic".

Verify the required arguments in the original call.

 fpclassify(x) ->
   isnan(x) ? FP_NAN :
     (fabs(x) == Inf ? FP_INFINITE :
       (fabs(x) >= DBL_MIN ? FP_NORMAL :
         (x == 0 ? FP_ZERO : FP_SUBNORMAL))).   
static tree fold_builtin_fprintf ( location_t  loc,
tree  fndecl,
tree  fp,
tree  fmt,
tree  arg,
bool  ignore,
enum built_in_function  fcode 
)
static

Fold a call to the {,v}fprintf{,_unlocked} and __{,v}printf_chk builtins. FP, FMT, and ARG are the arguments to the call. We don't fold calls with more than 3 arguments, and ARG may be null in the 2-argument case.

Return NULL_TREE if no simplification was possible, otherwise return the simplified form of the call as a tree. FCODE is the BUILT_IN_* code of the function to be simplified.

 If the return value is used, don't do the transformation.   
 Verify the required arguments in the original call.   
 Check whether the format is a literal string constant.   
     If we're using an unlocked function, assume the other
     unlocked functions exist explicitly.   
 If the format doesn't contain % args or %%, use strcpy.   
     If the format specifier was "", fprintf does nothing.   
         If FP has side-effects, just wait until gimplification is
         done.   
     When "string" doesn't contain %, replace all cases of
     fprintf (fp, string) with fputs (string, fp).  The fputs
     builtin will take care of special cases like length == 1.   
 The other optimizations can be done only on the non-va_list variants.   
 If the format specifier was "%s", call __builtin_fputs (arg, fp).   
 If the format specifier was "%c", call __builtin_fputc (arg, fp).   
tree fold_builtin_fputs ( location_t  loc,
tree  arg0,
tree  arg1,
bool  ignore,
bool  unlocked,
tree  len 
)

Fold a call to the fputs builtin. ARG0 and ARG1 are the arguments to the call. IGNORE is true if the value returned by the builtin will be ignored. UNLOCKED is true is true if this actually a call to fputs_unlocked. If LEN in non-NULL, it represents the known length of the string. Return NULL_TREE if no simplification was possible.

 If we're using an unlocked function, assume the other unlocked
 functions exist explicitly.   
 If the return value is used, don't do the transformation.   
 Verify the arguments in the original call.   
 Get the length of the string passed to fputs.  If the length
 can't be determined, punt.   
     FALLTHROUGH  
       If optimizing for size keep fputs.   
       New argument list transforming fputs(string, stream) to
       fwrite(string, 1, len, stream).   

References build_call_expr_loc(), builtin_decl_explicit(), fold_build_pointer_plus_loc(), fold_convert_loc(), host_integerp(), integer_all_onesp(), NULL_TREE, omit_one_operand_loc(), operand_equal_p(), tree_int_cst_lt(), TREE_TYPE, and validate_arg().

Referenced by fold_builtin_classify().

static tree fold_builtin_frexp ( )
static

Fold a call to builtin frexp, we can assume the base is 2.

 Proceed if a valid pointer type was passed in.   
       For +-0, return (*exp = 0, +-0).   
       For +-NaN or +-Inf, *exp is unspecified, return arg0.   
         Since the frexp function always expects base 2, and in
         GCC normalized significands are already in the range
         [0.5, 1.0), we have exactly what frexp wants.   
     Create the COMPOUND_EXPR (*arg1 = trunc, frac).  

Referenced by fold_builtin_classify().

static tree fold_builtin_hypot ( location_t  loc,
tree  fndecl,
tree  arg0,
tree  arg1,
tree  type 
)
static

Fold a builtin function call to hypot, hypotf, or hypotl. Return NULL_TREE if no simplification can be made.

 Calculate the result when the argument is a constant.   
 If either argument to hypot has a negate or abs, strip that off.
 E.g. hypot(-x,fabs(y)) -> hypot(x,y).   
 If either argument is zero, hypot is fabs of the other.   
 hypot(x,x) -> fabs(x)*sqrt(2).   

Referenced by fold_builtin_classify().

static tree fold_builtin_inf ( location_t  ,
tree  ,
int   
)
static
static tree fold_builtin_inf ( )
static

Fold a call to __builtin_inf or __builtin_huge_val.

__builtin_inff is intended to be usable to define INFINITY on all targets. If an infinity is not available, INFINITY expands "to a positive constant of type float that overflows at translation time", footnote "In this case, using INFINITY will violate the constraint in 6.4.4 and thus require a diagnostic." (C99 7.12#4). Thus we pedwarn to ensure this constraint violation is diagnosed.

static tree fold_builtin_int_roundingfn ( location_t  ,
tree  ,
tree   
)
static
static tree fold_builtin_int_roundingfn ( )
static

Fold function call to builtin lround, lroundf or lroundl (or the corresponding long long versions) and other rounding functions. ARG is the argument to the call. Return NULL_TREE if no simplification can be made.

Optimize lround of constant value.

     Fold lfloor (x) where x is nonnegative to FIX_TRUNC (x).   

References build_call_expr_loc(), CALL_EXPR_ARG, fold_build2_loc, and tree_expr_nonnegative_p().

static tree fold_builtin_interclass_mathfn ( )
static

Given a location LOC, an interclass builtin function decl FNDECL and its single argument ARG, return an folded expression computing the same, or NULL_TREE if we either couldn't or didn't want to fold (the latter happen if there's an RTL instruction available).

 If there is no optab, try generic code.   
       isinf(x) -> isgreater(fabs(x),DBL_MAX).   
       isfinite(x) -> islessequal(fabs(x),DBL_MAX).   
       isnormal(x) -> isgreaterequal(fabs(x),DBL_MIN) &
       islessequal(fabs(x),DBL_MAX).   
static tree fold_builtin_isascii ( location_t  ,
tree   
)
static
static tree fold_builtin_isascii ( )
static

Fold a call to builtin isascii with argument ARG.

Transform isascii(c) -> ((c & ~0x7f) == 0).

References integer_one_node, integer_zero_node, real_isnan(), and TREE_REAL_CST.

static tree fold_builtin_isdigit ( location_t  ,
tree   
)
static
static tree fold_builtin_isdigit ( )
static

Fold a call to builtin isdigit with argument ARG.

Transform isdigit(c) -> (unsigned)(c) - '0' <= 9.

     According to the C standard, isdigit is unaffected by locale.
     However, it definitely is affected by the target character set.   
static tree fold_builtin_load_exponent ( location_t  loc,
tree  arg0,
tree  arg1,
tree  type,
bool  ldexp 
)
static

Fold a call to builtin ldexp or scalbn/scalbln. If LDEXP is true then we can assume the base is two. If it's false, then we have to check the mode of the TYPE parameter in certain cases.

     If arg0 is 0, Inf or NaN, or if arg1 is 0, then return arg0.   
     If both arguments are constant, then try to evaluate it.   
         Bound the maximum adjustment to twice the range of the
         mode's valid exponents.  Use abs to ensure the range is
         positive as a sanity check.   
         Get the user-requested adjustment.   
         The requested adjustment must be inside this range.  This
         is a preliminary cap to avoid things like overflow, we
         may still fail to compute the result for other reasons.   
             Ensure we didn't overflow.   
                 Only proceed if the target mode can hold the
                 resulting value.   

Referenced by fold_builtin_classify().

static tree fold_builtin_logarithm ( location_t  loc,
tree  fndecl,
tree  arg,
int(*)(mpfr_ptr, mpfr_srcptr, mp_rnd_t)  func 
)
static

A subroutine of fold_builtin to fold the various logarithmic functions. Return NULL_TREE if no simplification can me made. FUNC is the corresponding MPFR logarithm function.

     Calculate the result when the argument is a constant.   
     Special case, optimize logN(expN(x)) = x.   
     Optimize logN(func()) for various exponential functions.  We
     want to determine the value "x" and the power "exponent" in
     order to transform logN(x**exponent) into exponent*logN(x).   
           Prepare to do logN(exp(exponent) -> exponent*logN(e).   
           Prepare to do logN(exp2(exponent) -> exponent*logN(2).   
           Prepare to do logN(exp10(exponent) -> exponent*logN(10).   
           Prepare to do logN(sqrt(x) -> 0.5*logN(x).   
           Prepare to do logN(cbrt(x) -> (1/3)*logN(x).   
           Prepare to do logN(pow(x,exponent) -> exponent*logN(x).   
         Now perform the optimization.   

References ao_ref_init_from_ptr_and_size(), BITS_PER_UNIT, build_call_expr_loc(), builtin_decl_implicit(), double_int::fits_shwi(), double_int::from_shwi(), get_pointer_alignment(), get_ref_base_and_extent(), host_integerp(), is_gimple_min_invariant(), double_int::low, mem_ref_offset(), MIN, NULL_TREE, operand_equal_p(), ranges_overlap_p(), readonly_data_expr(), refs_may_alias_p_1(), SSA_VAR_P, TREE_CODE, tree_low_cst(), and TREE_OPERAND.

static tree fold_builtin_logb ( )
static

Fold a call to builtin logb/ilogb.

       If arg is Inf or NaN and we're logb, return it.   
           For logb(-Inf) we have to return +Inf.   
       Fall through...  
       Zero may set errno and/or raise an exception for logb, also
       for ilogb we don't know FP_ILOGB0.   
       For normal numbers, proceed iff radix == 2.  In GCC,
       normalized significands are in the range [0.5, 1.0).  We
       want the exponent as if they were [1.0, 2.0) so get the
       exponent and subtract 1.   
static tree fold_builtin_memchr ( location_t  ,
tree  ,
tree  ,
tree  ,
tree   
)
static
static tree fold_builtin_memchr ( )
static

Fold function call to builtin memchr. ARG1, ARG2 and LEN are the arguments to the call, and TYPE is its return type. Return NULL_TREE if no simplification can be made.

static tree fold_builtin_memcmp ( location_t  ,
tree  ,
tree  ,
tree   
)
static
static tree fold_builtin_memcmp ( )
static

Fold function call to builtin memcmp with arguments ARG1 and ARG2. Return NULL_TREE if no simplification can be made.

 If the LEN parameter is zero, return zero.   
 If ARG1 and ARG2 are the same (and not volatile), return zero.   
 If all arguments are constant, and the value of len is not greater
 than the lengths of arg1 and arg2, evaluate at compile-time.   
 If len parameter is one, return an expression corresponding to
 (*(const unsigned char*)arg1 - (const unsigned char*)arg2).   
tree fold_builtin_memory_chk ( location_t  loc,
tree  fndecl,
tree  dest,
tree  src,
tree  len,
tree  size,
tree  maxlen,
bool  ignore,
enum built_in_function  fcode 
)

Fold a call to the __mem{cpy,pcpy,move,set}_chk builtin. DEST, SRC, LEN, and SIZE are the arguments to the call. IGNORE is true, if return value can be ignored. FCODE is the BUILT_IN_* code of the builtin. If MAXLEN is not NULL, it is maximum length passed as third argument.

 If SRC and DEST are the same (and not volatile), return DEST
 (resp. DEST+LEN for __mempcpy_chk).   
         If LEN is not constant, try MAXLEN too.
         For MAXLEN only allow optimizing into non-_ocs function
         if SIZE is >= MAXLEN, never convert to __ocs_fail ().   
                 (void) __mempcpy_chk () can be optimized into
                 (void) __memcpy_chk ().   
 If __builtin_mem{cpy,pcpy,move,set}_chk is used, assume
 mem{cpy,pcpy,move,set} is available.   
static tree fold_builtin_memory_op ( location_t  loc,
tree  dest,
tree  src,
tree  len,
tree  type,
bool  ignore,
int  endp 
)
static

Fold function call to builtin mem{{,p}cpy,move}. Return NULL_TREE if no simplification can be made. If ENDP is 0, return DEST (like memcpy). If ENDP is 1, return DEST+LEN (like mempcpy). If ENDP is 2, return DEST+LEN-1 (like stpcpy). If ENDP is 3, return DEST, additionally *SRC and *DEST may overlap (memmove).

 If the LEN parameter is zero, return DEST.   
 If SRC and DEST are the same (and not volatile), return
 DEST{,+LEN,+LEN-1}.   
         Both DEST and SRC must be pointer types.
         ??? This is what old code did.  Is the testing for pointer types
         really mandatory?

         If either SRC is readonly or length is 1, we can use memcpy.   
         If *src and *dest can't overlap, optimize into memcpy as well.   
         If the destination and source do not alias optimize into
         memcpy as well.   
     FIXME:
     This logic lose for arguments like (type *)malloc (sizeof (type)),
     since we strip the casts of up to VOID return value from malloc.
     Perhaps we ought to inherit type from non-VOID argument here?   
     As we fold (void *)(p + CST) to (void *)p + CST undo this here.   
     Build accesses at offset zero with a ref-all character type.   
static tree fold_builtin_memset ( location_t  loc,
tree  dest,
tree  c,
tree  len,
tree  type,
bool  ignore 
)
static

Fold function call to builtin memset. Return NULL_TREE if no simplification can be made.

If the LEN parameter is zero, return DEST.

static tree fold_builtin_modf ( )
static

Fold a call to builtin modf.

 Proceed if a valid pointer type was passed in.   
       For +-NaN or +-0, return (*arg1 = arg0, arg0).   
       For +-Inf, return (*arg1 = arg0, +-0).   
       Return (*arg1 = trunc(arg0), arg0-trunc(arg0)).   
       If the original number was negative and already
       integral, then the fractional part is -0.0.   
     Create the COMPOUND_EXPR (*arg1 = trunc, frac).  

Referenced by fold_builtin_classify().

static tree fold_builtin_n ( location_t  ,
tree  ,
tree ,
int  ,
bool   
)
static
static tree fold_builtin_nan ( tree  ,
tree  ,
int   
)
static
static tree fold_builtin_nan ( )
static

Fold a call to __builtin_nan or __builtin_nans with argument ARG.

bool fold_builtin_next_arg ( )

Fold the next_arg or va_start call EXP. Returns true if there was an error produced. False otherwise. This is done so that we don't output the error or warning twice or three times.

 There is good chance the current input_location points inside the
 definition of the va_start macro (perhaps on the token for
 builtin) in a system header, so warnings will not be emitted.
 Use the location in real source code.   
 We use __builtin_va_start (ap, 0, 0) or __builtin_next_arg (0, 0)
 when we checked the arguments and if needed issued a warning.   
         Evidently an out of date version of <stdarg.h>; can't validate
         va_start's second argument, but can still work as intended.   
 We destructively modify the call to be __builtin_va_start (ap, 0)
 or __builtin_next_arg (0) the first time we see it, after checking
 the arguments and if needed issuing a warning.   
     Strip off all nops for the sake of the comparison.  This
     is not quite the same as STRIP_NOPS.  It does more.
     We must also strip off INDIRECT_EXPR for C++ reference
     parameters.   
         FIXME: Sometimes with the tree optimizers we can get the
         not the last argument even though the user used the last
         argument.  We just warn and set the arg to be the last
         argument so that we will get wrong-code because of
         it.   
     Undefined by C99 7.15.1.4p4 (va_start):
     "If the parameter parmN is declared with the register storage
     class, with a function or array type, or with a type that is
     not compatible with the type that results after application of
     the default argument promotions, the behavior is undefined."
     We want to verify the second parameter just once before the tree
     optimizers are run and then avoid keeping it in the tree,
     as otherwise we could warn even for correct code like:
     void foo (int i, ...)
     { va_list ap; i++; va_start (ap, i); va_end (ap); }   

Referenced by expand_builtin_strncmp().

static tree fold_builtin_object_size ( tree  ,
tree   
)
static
tree fold_builtin_object_size ( )

Fold a call to __builtin_object_size with arguments PTR and OST, if possible.

__builtin_object_size doesn't evaluate side-effects in its arguments; if there are any side-effects, it returns (size_t) -1 for types 0 and 1 and (size_t) 0 for types 2 and 3.

     If object size is not known yet, delay folding until
   later.  Maybe subsequent passes will help determining
   it.   
static tree fold_builtin_pow ( location_t  ,
tree  ,
tree  ,
tree  ,
tree   
)
static
static tree fold_builtin_pow ( )
static

Fold a builtin function call to pow, powf, or powl. Return NULL_TREE if no simplification can be made.

 Calculate the result when the argument is a constant.   
 Optimize pow(1.0,y) = 1.0.   
     Optimize pow(x,0.0) = 1.0.   
     Optimize pow(x,1.0) = x.   
     Optimize pow(x,-1.0) = 1.0/x.   
     Optimize pow(x,0.5) = sqrt(x).   
     Optimize pow(x,1.0/3.0) = cbrt(x).   
     Check for an integer exponent.   
         Attempt to evaluate pow at compile-time, unless this should
         raise an exception.   
         Strip sign ops from even integer powers.   
     Optimize pow(expN(x),y) = expN(x*y).   
     Optimize pow(sqrt(x),y) = pow(x,y*0.5).   
     Optimize pow(cbrt(x),y) = pow(x,y/3) iff x is nonnegative.   
     Optimize pow(pow(x,y),z) = pow(x,y*z) iff x is nonnegative.   
static tree fold_builtin_powi ( location_t  loc,
tree  fndecl,
tree  arg0,
tree  arg1,
tree  type 
)
static

Fold a builtin function call to powi, powif, or powil with argument ARG. Return NULL_TREE if no simplification can be made.

 Optimize pow(1.0,y) = 1.0.   
     Evaluate powi at compile-time.   
     Optimize pow(x,0) = 1.0.   
     Optimize pow(x,1) = x.   
     Optimize pow(x,-1) = 1.0/x.   
static tree fold_builtin_printf ( location_t  loc,
tree  fndecl,
tree  fmt,
tree  arg,
bool  ignore,
enum built_in_function  fcode 
)
static

Fold a call to the {,v}printf{,_unlocked} and __{,v}printf_chk builtins. FMT and ARG are the arguments to the call; we don't fold cases with more than 2 arguments, and ARG may be null if this is a 1-argument case.

Return NULL_TREE if no simplification was possible, otherwise return the simplified form of the call as a tree. FCODE is the BUILT_IN_* code of the function to be simplified.

 If the return value is used, don't do the transformation.   
 Verify the required arguments in the original call.   
 Check whether the format is a literal string constant.   
     If we're using an unlocked function, assume the other
     unlocked functions exist explicitly.   
         The format specifier doesn't contain any '%' characters.   
     If the string was "", printf does nothing.   
     If the string has length of 1, call putchar.   
         Given printf("c"), (where c is any one character,)
         convert "c"[0] to an int and pass that to the replacement
         function.   
         If the string was "string\n", call puts("string").   
             Create a NUL-terminated string that's one char shorter
             than the original, stripping off the trailing '\n'.   
             build_string_literal creates a new STRING_CST,
             modify it in place to avoid double copying.   
           We'd like to arrange to call fputs(string,stdout) here,
           but we need stdout and don't have a way to get it yet.   
 The other optimizations can be done only on the non-va_list variants.   
 If the format specifier was "%s\n", call __builtin_puts(arg).   
 If the format specifier was "%c", call __builtin_putchar(arg).   
static tree fold_builtin_round ( location_t  ,
tree  ,
tree   
)
static
static tree fold_builtin_round ( )
static

Fold function call to builtin round, roundf or roundl with argument ARG. Return NULL_TREE if no simplification can be made.

Optimize round of constant value.

static tree fold_builtin_signbit ( location_t  ,
tree  ,
tree   
)
static
static tree fold_builtin_signbit ( )
static

Fold function call to builtin signbit, signbitf or signbitl with argument ARG. Return NULL_TREE if no simplification can be made.

 If ARG is a compile-time constant, determine the result.   
 If ARG is non-negative, the result is always zero.   
 If ARG's format doesn't have signed zeros, return "arg < 0.0".   
static tree fold_builtin_significand ( )
static

Fold a call to builtin significand, if radix == 2.

       If arg is +-0, +-Inf or +-NaN, then return it.   
       For normal numbers, proceed iff radix == 2.   
           In GCC, normalized significands are in the range [0.5,
           1.0).  We want them to be [1.0, 2.0) so set the
           exponent to 1.   
static tree fold_builtin_sincos ( location_t  loc,
tree  arg0,
tree  arg1,
tree  arg2 
)
static

Fold function call to builtin sincos, sincosf, or sincosl. Return NULL_TREE if no simplification can be made.

Calculate the result when the argument is a constant.

 Canonicalize sincos to cexpi.   

References build_real(), CALL_EXPR_ARG, CASE_FLT_FN, dconst2, dconst_e, dconst_third, dconsthalf, real_from_integer(), real_value_truncate(), REAL_VALUE_TYPE, and TYPE_MODE.

static tree fold_builtin_snprintf ( location_t  loc,
tree  dest,
tree  destsize,
tree  fmt,
tree  orig,
int  ignored 
)
static

Simplify a call to the snprintf builtin with arguments DEST, DESTSIZE, FMT, and ORIG. ORIG may be null if this is a 3-argument call. We don't attempt to simplify calls with more than 4 arguments.

Return NULL_TREE if no simplification was possible, otherwise return the simplified form of the call as a tree. If IGNORED is true, it means that the caller does not use the returned value of the function.

 Verify the required arguments in the original call.  We deal with two
 types of snprintf() calls: 'snprintf (str, cst, fmt)' and
 'snprintf (dest, cst, "%s", orig)'.   
 Check whether the format is a literal string constant.   
 If the format doesn't contain % args or %%, use strcpy.   
     Don't optimize snprintf (buf, 4, "abc", ptr++).   
     We could expand this as
     memcpy (str, fmt, cst - 1); str[cst - 1] = '\0';
     or to
     memcpy (str, fmt_with_nul_at_cstm1, cst);
     but in the former case that might increase code size
     and in the latter case grow .rodata section too much.
     So punt for now.   
     Convert snprintf (str, cst, fmt) into strcpy (str, fmt) when
     'format' is known to contain no % formats and
     strlen (fmt) < cst.   
 If the format is "%s", use strcpy if the result isn't used.   
     Don't crash on snprintf (str1, cst, "%s").   
     We could expand this as
     memcpy (str1, str2, cst - 1); str1[cst - 1] = '\0';
     or to
     memcpy (str1, str2_with_nul_at_cstm1, cst);
     but in the former case that might increase code size
     and in the latter case grow .rodata section too much.
     So punt for now.   
     Convert snprintf (str1, cst, "%s", str2) into
     strcpy (str1, str2) if strlen (str2) < cst.   
tree fold_builtin_snprintf_chk ( location_t  loc,
tree  exp,
tree  maxlen,
enum built_in_function  fcode 
)

Fold a call EXP to {,v}snprintf. Return NULL_TREE if a normal call should be emitted rather than expanding the function inline. FCODE is either BUILT_IN_SNPRINTF_CHK or BUILT_IN_VSNPRINTF_CHK. If MAXLEN is not NULL, it is maximum length passed as second argument.

References real_format::p, real_isfinite(), REAL_MODE_FORMAT, REAL_VALUE_TYPE, real_format::round_towards_zero, TREE_IMAGPART, TREE_REAL_CST_PTR, TREE_REALPART, TREE_TYPE, and TYPE_MODE.

static tree fold_builtin_snprintf_chk_1 ( location_t  loc,
int  nargs,
tree args,
tree  maxlen,
enum built_in_function  fcode 
)
static

Fold a call EXP to {,v}snprintf having NARGS passed as ARGS. Return NULL_TREE if a normal call should be emitted rather than expanding the function inline. FCODE is either BUILT_IN_SNPRINTF_CHK or BUILT_IN_VSNPRINTF_CHK. If MAXLEN is not NULL, it is maximum length passed as second argument.

 Verify the required arguments in the original call.   
         If LEN is not constant, try MAXLEN too.
         For MAXLEN only allow optimizing into non-_ocs function
         if SIZE is >= MAXLEN, never convert to __ocs_fail ().   
 Only convert __{,v}snprintf_chk to {,v}snprintf if flag is 0
 or if format doesn't contain % chars or is "%s".   
 If __builtin_{,v}snprintf_chk is used, assume {,v}snprintf is
 available.   
static tree fold_builtin_sprintf ( location_t  loc,
tree  dest,
tree  fmt,
tree  orig,
int  ignored 
)
static

Simplify a call to the sprintf builtin with arguments DEST, FMT, and ORIG. ORIG may be null if this is a 2-argument call. We don't attempt to simplify calls with more than 3 arguments.

Return NULL_TREE if no simplification was possible, otherwise return the simplified form of the call as a tree. If IGNORED is true, it means that the caller does not use the returned value of the function.

 Verify the required arguments in the original call.  We deal with two
 types of sprintf() calls: 'sprintf (str, fmt)' and
 'sprintf (dest, "%s", orig)'.   
 Check whether the format is a literal string constant.   
 If the format doesn't contain % args or %%, use strcpy.   
     Don't optimize sprintf (buf, "abc", ptr++).   
     Convert sprintf (str, fmt) into strcpy (str, fmt) when
     'format' is known to contain no % formats.   
 If the format is "%s", use strcpy if the result isn't used.   
     Don't crash on sprintf (str1, "%s").   
     Convert sprintf (str1, "%s", str2) into strcpy (str1, str2).   
static tree fold_builtin_sprintf_chk ( location_t  loc,
tree  exp,
enum built_in_function  fcode 
)
static

Fold a call EXP to __{,v}sprintf_chk. Return NULL_TREE if a normal call should be emitted rather than expanding the function inline. FCODE is either BUILT_IN_SPRINTF_CHK or BUILT_IN_VSPRINTF_CHK.

static tree fold_builtin_sprintf_chk_1 ( location_t  loc,
int  nargs,
tree args,
enum built_in_function  fcode 
)
static

Fold a call EXP to __{,v}sprintf_chk having NARGS passed as ARGS. Return NULL_TREE if a normal call should be emitted rather than expanding the function inline. FCODE is either BUILT_IN_SPRINTF_CHK or BUILT_IN_VSPRINTF_CHK.

 Verify the required arguments in the original call.   
 Check whether the format is a literal string constant.   
     If the format doesn't contain % args or %%, we know the size.   
     If the format is "%s" and first ... argument is a string literal,
     we know the size too.   
 Only convert __{,v}sprintf_chk to {,v}sprintf if flag is 0
 or if format doesn't contain % chars or is "%s".   
 If __builtin_{,v}sprintf_chk is used, assume {,v}sprintf is available.   

References build_fold_indirect_ref, build_int_cst(), CHAR_BIT, do_mpfr_ckconv(), fold_build2, INT_TYPE_SIZE, integer_type_node, mpfr_from_real(), non_lvalue, NULL, real_format::p, real_isfinite(), REAL_MODE_FORMAT, REAL_VALUE_TYPE, real_format::round_towards_zero, TREE_REAL_CST_PTR, TREE_SIDE_EFFECTS, TREE_TYPE, TYPE_MAIN_VARIANT, and TYPE_MODE.

static tree fold_builtin_sqrt ( location_t  ,
tree  ,
tree   
)
static
static tree fold_builtin_sqrt ( )
static

Fold a builtin function call to sqrt, sqrtf, or sqrtl with argument ARG. Return NULL_TREE if no simplification can be made.

 Calculate the result when the argument is a constant.   
 Optimize sqrt(expN(x)) = expN(x*0.5).   
 Optimize sqrt(Nroot(x)) -> pow(x,1/(2*N)).   
         The inner root was either sqrt or cbrt.   
         This was a conditional expression but it triggered a bug
         in Sun C 5.5.   
         Adjust for the outer root.   
 Optimize sqrt(pow(x,y)) = pow(|x|,y*0.5).   
static tree fold_builtin_stpcpy ( )
static

Fold function call to builtin stpcpy with arguments DEST and SRC. Return NULL_TREE if no simplification can be made.

If length is zero it's small enough.   

We use dest twice in building our expression. Save it from multiple expansions.

static tree fold_builtin_strcat ( location_t  ,
tree  ,
tree   
)
static

Referenced by fold_builtin_classify().

static tree fold_builtin_strcat ( )
static

Simplify a call to the strcat builtin. DST and SRC are the arguments to the call.

Return NULL_TREE if no simplification was possible, otherwise return the simplified form of the call as a tree.

The simplified form may be a constant or other expression which computes the same value, but in a more efficient manner (including calls to other builtin functions).

The call may contain arguments which need to be evaluated, but which are not useful to determine the result of the call. In this case we return a chain of COMPOUND_EXPRs. The LHS of each COMPOUND_EXPR will be an argument which must be evaluated. COMPOUND_EXPRs are chained through their RHS. The RHS of the last COMPOUND_EXPR in the chain will contain the tree for the simplified form of the builtin function call.

     If the string length is zero, return the dst parameter.   
         See if we can store by pieces into (dst + strlen(dst)).   
         If we don't have a movstr we don't want to emit an strcpy
         call.  We have to do that if the length of the source string
         isn't computable (in that case we can use memcpy probably
         later expanding to a sequence of mov instructions).  If we
         have movstr instructions we can emit strcpy calls.   
         Stabilize the argument list.   
         Create strlen (dst).   
         Create (dst p+ strlen (dst)).   
static tree fold_builtin_strcat_chk ( location_t  loc,
tree  fndecl,
tree  dest,
tree  src,
tree  size 
)
static

Fold a call to the __strcat_chk builtin FNDECL. DEST, SRC, and SIZE are the arguments to the call.

If the SRC parameter is "", return DEST.

 If __builtin_strcat_chk is used, assume strcat is available.   
static tree fold_builtin_strchr ( location_t  ,
tree  ,
tree  ,
tree   
)
static

Referenced by fold_builtin_classify().

static tree fold_builtin_strchr ( )
static

Simplify a call to the strchr builtin. S1 and S2 are the arguments to the call, and TYPE is its return type.

Return NULL_TREE if no simplification was possible, otherwise return the simplified form of the call as a tree.

The simplified form may be a constant or other expression which computes the same value, but in a more efficient manner (including calls to other builtin functions).

The call may contain arguments which need to be evaluated, but which are not useful to determine the result of the call. In this case we return a chain of COMPOUND_EXPRs. The LHS of each COMPOUND_EXPR will be an argument which must be evaluated. COMPOUND_EXPRs are chained through their RHS. The RHS of the last COMPOUND_EXPR in the chain will contain the tree for the simplified form of the builtin function call.

Return an offset into the constant string argument.

static tree fold_builtin_strcmp ( location_t  ,
tree  ,
tree   
)
static
static tree fold_builtin_strcmp ( )
static

Fold function call to builtin strcmp with arguments ARG1 and ARG2. Return NULL_TREE if no simplification can be made.

 If ARG1 and ARG2 are the same (and not volatile), return zero.   
 If the second arg is "", return *(const unsigned char*)arg1.   
 If the first arg is "", return -*(const unsigned char*)arg2.   
tree fold_builtin_strcpy ( )

Fold function call to builtin strcpy with arguments DEST and SRC. If LEN is not NULL, it represents the length of the string to be copied. Return NULL_TREE if no simplification can be made.

If SRC and DEST are the same (and not volatile), return DEST.

References fold_build3_loc, fold_fma(), optab_handler(), and TYPE_MODE.

Referenced by fold_builtin_classify().

static tree fold_builtin_strcspn ( location_t  ,
tree  ,
tree   
)
static

Referenced by fold_builtin_classify().

static tree fold_builtin_strcspn ( )
static

Simplify a call to the strcspn builtin. S1 and S2 are the arguments to the call.

Return NULL_TREE if no simplification was possible, otherwise return the simplified form of the call as a tree.

The simplified form may be a constant or other expression which computes the same value, but in a more efficient manner (including calls to other builtin functions).

The call may contain arguments which need to be evaluated, but which are not useful to determine the result of the call. In this case we return a chain of COMPOUND_EXPRs. The LHS of each COMPOUND_EXPR will be an argument which must be evaluated. COMPOUND_EXPRs are chained through their RHS. The RHS of the last COMPOUND_EXPR in the chain will contain the tree for the simplified form of the builtin function call.

     If both arguments are constants, evaluate at compile-time.   
     If the first argument is "", return NULL_TREE.   
         Evaluate and ignore argument s2 in case it has
         side-effects.   
     If the second argument is "", return __builtin_strlen(s1).   
         If the replacement _DECL isn't initialized, don't do the
         transformation.   

References build_int_cst_type(), build_int_cstu(), compare_tree_int(), compute_builtin_object_size(), double_int_fits_to_tree_p(), double_int::from_uhwi(), NULL_TREE, size_type_node, STRIP_NOPS, TREE_CODE, tree_int_cst_sgn(), tree_low_cst(), TREE_SIDE_EFFECTS, and validate_arg().

static tree fold_builtin_strlen ( location_t  ,
tree  ,
tree   
)
static
static tree fold_builtin_strlen ( )
static

Fold a call to __builtin_strlen with argument ARG.

static tree fold_builtin_strncat ( location_t  ,
tree  ,
tree  ,
tree   
)
static
static tree fold_builtin_strncat ( )
static

Simplify a call to the strncat builtin. DST, SRC, and LEN are the arguments to the call.

Return NULL_TREE if no simplification was possible, otherwise return the simplified form of the call as a tree.

The simplified form may be a constant or other expression which computes the same value, but in a more efficient manner (including calls to other builtin functions).

The call may contain arguments which need to be evaluated, but which are not useful to determine the result of the call. In this case we return a chain of COMPOUND_EXPRs. The LHS of each COMPOUND_EXPR will be an argument which must be evaluated. COMPOUND_EXPRs are chained through their RHS. The RHS of the last COMPOUND_EXPR in the chain will contain the tree for the simplified form of the builtin function call.

     If the requested length is zero, or the src parameter string
     length is zero, return the dst parameter.   
     If the requested len is greater than or equal to the string
     length, call strcat.   
         If the replacement _DECL isn't initialized, don't do the
         transformation.   
static tree fold_builtin_strncat_chk ( location_t  loc,
tree  fndecl,
tree  dest,
tree  src,
tree  len,
tree  size 
)
static

Fold a call to the __strncat_chk builtin with arguments DEST, SRC, LEN, and SIZE.

 If the SRC parameter is "" or if LEN is 0, return DEST.   
         If LEN >= strlen (SRC), optimize into __strcat_chk.   
 If __builtin_strncat_chk is used, assume strncat is available.   

References real_format::b, do_mpfr_ckconv(), host_integerp(), mpfr_from_real(), NULL_TREE, real_format::p, real_compare(), real_isfinite(), REAL_MODE_FORMAT, REAL_VALUE_TYPE, real_format::round_towards_zero, STRIP_NOPS, TREE_CODE, tree_low_cst(), TREE_OVERFLOW, TREE_REAL_CST, and TYPE_MODE.

static tree fold_builtin_strncmp ( location_t  ,
tree  ,
tree  ,
tree   
)
static
static tree fold_builtin_strncmp ( )
static

Fold function call to builtin strncmp with arguments ARG1, ARG2, and LEN. Return NULL_TREE if no simplification can be made.

 If the LEN parameter is zero, return zero.   
 If ARG1 and ARG2 are the same (and not volatile), return zero.   
 If the second arg is "", and the length is greater than zero,
 return *(const unsigned char*)arg1.   
 If the first arg is "", and the length is greater than zero,
 return -*(const unsigned char*)arg2.   
 If len parameter is one, return an expression corresponding to
 (*(const unsigned char*)arg1 - (const unsigned char*)arg2).   
tree fold_builtin_strncpy ( location_t  loc,
tree  fndecl,
tree  dest,
tree  src,
tree  len,
tree  slen 
)

Fold function call to builtin strncpy with arguments DEST, SRC, and LEN. If SLEN is not NULL, it represents the length of the source string. Return NULL_TREE if no simplification can be made.

 If the LEN parameter is zero, return DEST.   
 We can't compare slen with len as constants below if len is not a
 constant.   
 Now, we must be passed a constant src ptr parameter.   
 We do not support simplification of this case, though we do
 support it when expanding trees into RTL.   
 FIXME: generate a call to __builtin_memset.   
 OK transform into builtin memcpy.   

References build_int_cst(), build_real(), fold_convert_loc(), integer_type_node, NULL_TREE, REAL_EXP, real_inf(), real_isinf(), real_isneg(), REAL_MODE_FORMAT, REAL_VALUE_TYPE, rvc_inf, rvc_nan, rvc_normal, rvc_zero, STRIP_NOPS, TREE_CODE, TREE_OVERFLOW, TREE_REAL_CST_PTR, TREE_TYPE, TYPE_MODE, and validate_arg().

static tree fold_builtin_strpbrk ( location_t  ,
tree  ,
tree  ,
tree   
)
static
static tree fold_builtin_strpbrk ( )
static

Simplify a call to the strpbrk builtin. S1 and S2 are the arguments to the call, and TYPE is its return type.

Return NULL_TREE if no simplification was possible, otherwise return the simplified form of the call as a tree.

The simplified form may be a constant or other expression which computes the same value, but in a more efficient manner (including calls to other builtin functions).

The call may contain arguments which need to be evaluated, but which are not useful to determine the result of the call. In this case we return a chain of COMPOUND_EXPRs. The LHS of each COMPOUND_EXPR will be an argument which must be evaluated. COMPOUND_EXPRs are chained through their RHS. The RHS of the last COMPOUND_EXPR in the chain will contain the tree for the simplified form of the builtin function call.

         Return an offset into the constant string argument.   
       strpbrk(x, "") == NULL.
       Evaluate and ignore s1 in case it had side-effects.   
     New argument list transforming strpbrk(s1, s2) to
     strchr(s1, s2[0]).   
static tree fold_builtin_strrchr ( location_t  ,
tree  ,
tree  ,
tree   
)
static

Referenced by fold_builtin_classify().

static tree fold_builtin_strrchr ( )
static

Simplify a call to the strrchr builtin. S1 and S2 are the arguments to the call, and TYPE is its return type.

Return NULL_TREE if no simplification was possible, otherwise return the simplified form of the call as a tree.

The simplified form may be a constant or other expression which computes the same value, but in a more efficient manner (including calls to other builtin functions).

The call may contain arguments which need to be evaluated, but which are not useful to determine the result of the call. In this case we return a chain of COMPOUND_EXPRs. The LHS of each COMPOUND_EXPR will be an argument which must be evaluated. COMPOUND_EXPRs are chained through their RHS. The RHS of the last COMPOUND_EXPR in the chain will contain the tree for the simplified form of the builtin function call.

Return an offset into the constant string argument.   

Transform strrchr(s1, '\0') to strchr(s1, '\0').

static tree fold_builtin_strspn ( location_t  ,
tree  ,
tree   
)
static

Referenced by fold_builtin_classify().

static tree fold_builtin_strspn ( )
static

Simplify a call to the strspn builtin. S1 and S2 are the arguments to the call.

Return NULL_TREE if no simplification was possible, otherwise return the simplified form of the call as a tree.

The simplified form may be a constant or other expression which computes the same value, but in a more efficient manner (including calls to other builtin functions).

The call may contain arguments which need to be evaluated, but which are not useful to determine the result of the call. In this case we return a chain of COMPOUND_EXPRs. The LHS of each COMPOUND_EXPR will be an argument which must be evaluated. COMPOUND_EXPRs are chained through their RHS. The RHS of the last COMPOUND_EXPR in the chain will contain the tree for the simplified form of the builtin function call.

     If both arguments are constants, evaluate at compile-time.   
     If either argument is "", return NULL_TREE.   
       Evaluate and ignore both arguments in case either one has
       side-effects.   

References c_strlen(), CALL_EXPR_ARG, host_integerp(), POINTER_TYPE_P, and TREE_TYPE.

static tree fold_builtin_strstr ( location_t  ,
tree  ,
tree  ,
tree   
)
static

Referenced by fold_builtin_classify().

static tree fold_builtin_strstr ( )
static

Simplify a call to the strstr builtin. S1 and S2 are the arguments to the call, and TYPE is its return type.

Return NULL_TREE if no simplification was possible, otherwise return the simplified form of the call as a tree.

The simplified form may be a constant or other expression which computes the same value, but in a more efficient manner (including calls to other builtin functions).

The call may contain arguments which need to be evaluated, but which are not useful to determine the result of the call. In this case we return a chain of COMPOUND_EXPRs. The LHS of each COMPOUND_EXPR will be an argument which must be evaluated. COMPOUND_EXPRs are chained through their RHS. The RHS of the last COMPOUND_EXPR in the chain will contain the tree for the simplified form of the builtin function call.

Return an offset into the constant string argument.   
     The argument is const char *, and the result is char *, so we need
     a type conversion here to avoid a warning.   


     New argument list transforming strstr(s1, s2) to
     strchr(s1, s2[0]).   

References c_strlen(), NULL_TREE, and TREE_CODE.

tree fold_builtin_stxcpy_chk ( location_t  loc,
tree  fndecl,
tree  dest,
tree  src,
tree  size,
tree  maxlen,
bool  ignore,
enum built_in_function  fcode 
)

Fold a call to the __st[rp]cpy_chk builtin. DEST, SRC, and SIZE are the arguments to the call. IGNORE is true if return value can be ignored. FCODE is the BUILT_IN_* code of the builtin. If MAXLEN is not NULL, it is maximum length of strings passed as second argument.

 If SRC and DEST are the same (and not volatile), return DEST.   
         If LEN is not constant, try MAXLEN too.
         For MAXLEN only allow optimizing into non-_ocs function
         if SIZE is >= MAXLEN, never convert to __ocs_fail ().   
                 If return value of __stpcpy_chk is ignored,
                 optimize into __strcpy_chk.   
             If c_strlen returned something, but not a constant,
             transform __strcpy_chk into __memcpy_chk.   
 If __builtin_st{r,p}cpy_chk is used, assume st{r,p}cpy is available.   
tree fold_builtin_stxncpy_chk ( location_t  loc,
tree  dest,
tree  src,
tree  len,
tree  size,
tree  maxlen,
bool  ignore,
enum built_in_function  fcode 
)

Fold a call to the __st{r,p}ncpy_chk builtin. DEST, SRC, LEN, and SIZE are the arguments to the call. If MAXLEN is not NULL, it is maximum length passed as third argument. IGNORE is true if return value can be ignored. FCODE is the BUILT_IN_* code of the builtin.

      If return value of __stpncpy_chk is ignored,
      optimize into __strncpy_chk.   
         If LEN is not constant, try MAXLEN too.
         For MAXLEN only allow optimizing into non-_ocs function
         if SIZE is >= MAXLEN, never convert to __ocs_fail ().   
 If __builtin_st{r,p}ncpy_chk is used, assume st{r,p}ncpy is available.   
static tree fold_builtin_tan ( tree  ,
tree   
)
static
static tree fold_builtin_tan ( )
static

Fold function call to builtin tan, tanf, or tanl with argument ARG. Return NULL_TREE if no simplification can be made.

Calculate the result when the argument is a constant.

 Optimize tan(atan(x)) = x.   

References BUILTIN_EXP10_P, builtin_mathfn_code(), CALL_EXPR_ARG, dconst0, do_mpfr_arg1(), fold_convert_loc(), NULL, and TREE_TYPE.

static tree fold_builtin_toascii ( location_t  ,
tree   
)
static
static tree fold_builtin_toascii ( )
static

Fold a call to builtin toascii with argument ARG.

Transform toascii(c) -> (c & 0x7f).

References REAL_VALUE_TYPE, and type().

static tree fold_builtin_trunc ( location_t  ,
tree  ,
tree   
)
static
static tree fold_builtin_trunc ( )
static

Fold function call to builtin trunc, truncf or truncl with argument ARG. Return NULL_TREE if no simplification can be made.

Optimize trunc of constant value.

static tree fold_builtin_unordered_cmp ( location_t  loc,
tree  fndecl,
tree  arg0,
tree  arg1,
enum tree_code  unordered_code,
enum tree_code  ordered_code 
)
static

Fold a call to an unordered comparison function such as __builtin_isgreater(). FNDECL is the FUNCTION_DECL for the function being called and ARG0 and ARG1 are the arguments for the call. UNORDERED_CODE and ORDERED_CODE are comparison codes that give the opposite of the desired result. UNORDERED_CODE is used for modes that can hold NaNs and ORDERED_CODE is used for the rest.

Choose the wider of two real types.

static tree fold_builtin_varargs ( location_t  loc,
tree  fndecl,
tree  exp,
bool  ignore 
)
static

Builtins with folding operations that operate on "..." arguments need special handling; we need to store the arguments in a convenient data structure before attempting any folding. Fortunately there are only a few builtins that fall into this category. FNDECL is the function, EXP is the CALL_EXPR for the call, and IGNORE is true if the result of the function call is ignored.

tree fold_call_expr ( )

A wrapper function for builtin folding that prevents warnings for "statement without effect" and the like, caused by removing the call node earlier than the warning is generated.

If CALL_EXPR_VA_ARG_PACK is set, the arguments aren't finalized yet. Defer folding until we see all the arguments (after inlining).

     Before gimplification CALL_EXPR_VA_ARG_PACK is not set, but
     instead last argument is __builtin_va_arg_pack ().  Defer folding
     even in that case, until arguments are finalized.   

References c_strlen(), NULL_TREE, and TREE_SIDE_EFFECTS.

tree fold_call_stmt ( )

A wrapper function for builtin folding that prevents warnings for "statement without effect" and the like, caused by removing the call node earlier than the warning is generated.

Propagate location information from original call to expansion of builtin. Otherwise things like maybe_emit_chk_warning, that operate on the expansion of a builtin, will use the wrong location information.

static tree fold_fixed_mathfn ( )
static

FNDECL is assumed to be builtin which can narrow the FP type of the argument, for instance lround((double)f) -> lroundf (f). Do the transformation for a call with argument ARG.

 If argument is already integer valued, and we don't need to worry
 about setting errno, there's no need to perform rounding.   
 Canonicalize iround (x) to lround (x) on ILP32 targets where
 sizeof (int) == sizeof (long).   
 Canonicalize llround (x) to lround (x) on LP64 targets where
 sizeof (long long) == sizeof (long).   
tree fold_fma ( location_t  loc,
tree  type,
tree  arg0,
tree  arg1,
tree  arg2 
)

Fold a fma operation with arguments ARG[012].

References NULL_TREE, TREE_CODE, and TREE_TYPE.

Referenced by fold_builtin_strcpy().

static tree fold_trunc_transparent_mathfn ( location_t  ,
tree  ,
tree   
)
static
static tree fold_trunc_transparent_mathfn ( )
static

FNDECL is assumed to be a builtin where truncation can be propagated across (for instance floor((double)f) == (double)floorf (f). Do the transformation for a call with argument ARG.

Integer rounding functions are idempotent.

 If argument is already integer valued, and we don't need to worry
 about setting errno, there's no need to perform rounding.   

References build_call_expr_loc(), do_mpfr_arg1(), fold_strip_sign_ops(), NULL, NULL_TREE, and validate_arg().

static rtx get_builtin_sync_mem ( )
static

Expand the memory expression LOC and return the appropriate memory operand for the builtin_sync operations.

Note that we explicitly do not want any alias information for this memory, so that we kill all other live memories. Otherwise we don't satisfy the full barrier semantics of the intrinsic.

 The alignment needs to be at least according to that of the mode.   

References CALL_EXPR_ARG, expand_expr_force_mode(), and get_memmodel().

Referenced by expand_builtin_compare_and_swap().

static enum machine_mode get_builtin_sync_mode ( )
inlinestatic

Reconstitute a mode for a __sync intrinsic operation. Since the type of the pointer in these functions is void*, the tree optimizers may remove casts. The mode computed in expand_builtin isn't reliable either, due to __sync_bool_compare_and_swap.

FCODE_DIFF should be fcode - base, where base is the FOO_1 code for the group of builtins. This gives us log2 of the mode size.

The size is not negotiable, so ask not to get BLKmode in return if the target indicates that a smaller size would be better.

static enum memmodel get_memmodel ( )
static

Given an integer representing an ``enum memmodel'', verify its correctness and return the memory model enum.

If the parameter is not a constant, it's a run time value so we'll just convert it to MEMMODEL_SEQ_CST to avoid annoying runtime checking.

References boolean_true_node, CALL_EXPR_ARG, const0_rtx, const1_rtx, error(), fold_builtin_atomic_always_lock_free(), and TREE_CODE.

Referenced by expand_builtin_atomic_compare_exchange(), expand_builtin_compare_and_swap(), and get_builtin_sync_mem().

static rtx get_memory_rtx ( tree  ,
tree   
)
static
static rtx get_memory_rtx ( )
static

Get a MEM rtx for expression EXP which is the address of an operand to be used in a string instruction (cmpstrsi, movmemsi, ..). LEN is the maximum length of the block of memory that might be accessed or NULL if unknown.

 When EXP is not resolved SAVE_EXPR, MEM_ATTRS can be still derived
 from its expression, for expr->a.b only <variable>.a.b is recorded.   
 Get an expression we can use to find the attributes to assign to MEM.
 First remove any nops.   
 Build a MEM_REF representing the whole accessed area as a byte blob,
 (as builtin stringops may alias with anything).   
 If the MEM_REF has no acceptable address, try to get the base object
 from the original address we got, and build an all-aliasing
 unknown-sized access to that one.   
unsigned int get_object_alignment ( )

Return the alignment in bits of EXP, an object.

align and bitpos now specify known low bits of the pointer. ptr & (align - 1) == bitpos.

References BITS_PER_UNIT, get_object_alignment_2(), get_ptr_info_alignment(), POINTER_TYPE_P, SSA_NAME_PTR_INFO, STRIP_NOPS, TREE_CODE, TREE_OPERAND, and TREE_TYPE.

Referenced by propagate_dereference_distances().

bool get_object_alignment_1 ( tree  exp,
unsigned int *  alignp,
unsigned HOST_WIDE_INT bitposp 
)

For a memory reference expression EXP compute values M and N such that M divides (&EXP - N) and such that N < M. If these numbers can be determined, store M in alignp and N in *BITPOSP and return true. Otherwise return false and store BITS_PER_UNIT to *alignp and any bit-offset to *bitposp.

static bool get_object_alignment_2 ( tree  exp,
unsigned int *  alignp,
unsigned HOST_WIDE_INT bitposp,
bool  addr_p 
)
static

Compute values M and N such that M divides (address of EXP - N) and such that N < M. If these numbers can be determined, store M in alignp and N in *BITPOSP and return true. Otherwise return false and store BITS_PER_UNIT to *alignp and any bit-offset to *bitposp.

Note that the address (and thus the alignment) computed here is based on the address to which a symbol resolves, whereas DECL_ALIGN is based on the address at which an object is actually located. These two addresses are not always the same. For example, on ARM targets, the address &foo of a Thumb function foo() has the lowest bit set, whereas foo() itself starts on an even address.

If ADDR_P is true we are taking the address of the memory reference EXP and thus cannot rely on the access taking place.

 Get the innermost object and the constant (bitpos) and possibly
 variable (offset) offset of the access.   
 Extract alignment information from the innermost object and
 possibly adjust bitpos and offset.   
     Function addresses can encode extra information besides their
     alignment.  However, if TARGET_PTRMEMFUNC_VBIT_LOCATION
     allows the low bit to be used as a virtual bit, we know
     that the address itself must be at least 2-byte aligned.   
     The alignment of a CONST_DECL is determined by its initializer.   
     The alignment of the pointer operand in a TARGET_MEM_REF
     has to take the variable offset parts into account.   
     When EXP is an actual memory reference then we can use
     TYPE_ALIGN of a pointer indirection to derive alignment.
     Do so only if get_pointer_alignment_1 did not reveal absolute
     alignment knowledge and if using that alignment would
     improve the situation.   
         Else adjust bitpos accordingly.   
     STRING_CST are the only constant objects we allow to be not
     wrapped inside a CONST_DECL.   
 If there is a non-constant offset part extract the maximum
 alignment that can prevail.   
         Any overflow in calculating offset_bits won't change
         the alignment.   
         Any overflow in calculating offset_factor won't change
         the alignment.   
 Alignment is innermost object alignment adjusted by the constant
 and non-constant offset parts.   

Referenced by get_object_alignment().

unsigned int get_pointer_alignment ( )

Return the alignment in bits of EXP, a pointer valued expression. The alignment returned is, by default, the alignment of the thing that EXP points to. If it is not a POINTER_TYPE, 0 is returned.

Otherwise, look at the expression to see if we can do better, i.e., if the expression is actually pointing at an object whose alignment is tighter.

align and bitpos now specify known low bits of the pointer. ptr & (align - 1) == bitpos.

References c_strlen(), EXPR_LOC_OR_HERE, HOST_WIDE_INT, NULL_TREE, offset, string_constant(), STRIP_NOPS, TREE_CODE, tree_int_cst_equal(), TREE_OPERAND, and TREE_SIDE_EFFECTS.

Referenced by expand_builtin_bzero(), expand_builtin_memset_args(), and fold_builtin_logarithm().

bool get_pointer_alignment_1 ( tree  exp,
unsigned int *  alignp,
unsigned HOST_WIDE_INT bitposp 
)

For a pointer valued expression EXP compute values M and N such that M divides (EXP - N) and such that N < M. If these numbers can be determined, store M in alignp and N in *BITPOSP and return true. Return false if the results are just a conservative approximation.

If EXP is not a pointer, false is returned too.

We cannot really tell whether this result is an approximation.

tree gimple_fold_builtin_snprintf_chk ( gimple  stmt,
tree  maxlen,
enum built_in_function  fcode 
)

Fold a call STMT to {,v}snprintf. Return NULL_TREE if a normal call should be emitted rather than expanding the function inline. FCODE is either BUILT_IN_SNPRINTF_CHK or BUILT_IN_VSNPRINTF_CHK. If MAXLEN is not NULL, it is maximum length passed as second argument.

static tree gimple_fold_builtin_sprintf_chk ( )
static

Fold a call STMT to __{,v}sprintf_chk. Return NULL_TREE if a normal call should be emitted rather than expanding the function inline. FCODE is either BUILT_IN_SPRINTF_CHK or BUILT_IN_VSPRINTF_CHK.

static tree gimple_fold_builtin_varargs ( tree  fndecl,
gimple  stmt,
bool  ignore 
)
static

Builtins with folding operations that operate on "..." arguments need special handling; we need to store the arguments in a convenient data structure before attempting any folding. Fortunately there are only a few builtins that fall into this category. FNDECL is the function, EXP is the CALL_EXPR for the call, and IGNORE is true if the result of the function call is ignored.

bool gnu_libc_has_function ( )
static bool init_target_chars ( )
static

Initialize format string characters in the target charset.

Referenced by maybe_emit_sprintf_chk_warning().

static bool integer_valued_real_p ( tree  )
static
static bool integer_valued_real_p ( )
static
static enum insn_code interclass_mathfn_icode ( )
static

Given an interclass math builtin decl FNDECL and it's argument ARG return an RTL instruction code that implements the functionality. If that isn't possible or available return CODE_FOR_nothing.

These builtins have no optabs (yet).   
 There's no easy way to detect the case we need to set EDOM.   


 Optab mode depends on the mode of the input argument.   
bool is_builtin_fn ( )

Return true if DECL is a function symbol representing a built-in.

References function_c94, function_c99_math_complex, and function_c99_misc.

static bool is_builtin_name ( )
static

Return true if NAME starts with __builtin_ or __sync_.

Referenced by no_c99_libc_has_function().

bool is_inexpensive_builtin ( )

Return true if DECL is a builtin that is not expensive, i.e., they are most probably expanded inline into reasonably simple code. This is a superset of is_simple_builtin.

bool is_simple_builtin ( )

Return true if DECL is a builtin that expands to a constant or similarly simple code.

       Builtins that expand to constants.   
       Simple register moves or loads from stack.   
       Exception state returns or moves registers around.   
tree mathfn_built_in ( )

Like mathfn_built_in_1(), but always use the implicit array.

Referenced by convert_to_integer(), convert_to_real(), and integer_valued_real_p().

static tree mathfn_built_in_1 ( )
static

Return mathematic function equivalent to FN but operating directly on TYPE, if available. If IMPLICIT is true use the implicit builtin declaration, otherwise use the explicit declaration. If we can't do the conversion, return zero.

References emit_label(), emit_move_insn(), gen_int_mode(), gen_rtx_MEM(), GET_MODE, and word_mode.

Referenced by expand_builtin_classify_type().

static void maybe_emit_chk_warning ( tree  ,
enum  built_in_function 
)
static
static void maybe_emit_chk_warning ( )
static

Emit warning if a buffer overflow is detected at compile time.

For __strcat_chk the warning will be emitted only if overflowing by at least strlen (dest) + 1 bytes.

References build_call_expr_loc(), build_string_literal(), CONST_CAST, gcc_checking_assert, integer_zerop(), NULL_TREE, string_constant(), TREE_STRING_LENGTH, and TREE_STRING_POINTER.

static void maybe_emit_free_warning ( tree  )
static
static void maybe_emit_free_warning ( )
static

Emit warning if a free is called with address of a variable.

static void maybe_emit_sprintf_chk_warning ( tree  ,
enum  built_in_function 
)
static
static void maybe_emit_sprintf_chk_warning ( )
static

Emit warning if a buffer overflow is detected at compile time in sprintf_chk/vsprintf_chk calls.

 Verify the required arguments in the original call.   
 Check whether the format is a literal string constant.   
 If the format doesn't contain % args or %%, we know its size.   
 If the format is "%s" and first ... argument is a string literal,
 we know it too.   

References build_int_cst(), builtin_decl_explicit(), builtin_decl_implicit(), c_getstr(), init_target_chars(), NULL, NULL_TREE, TREE_SIDE_EFFECTS, TREE_TYPE, and validate_arg().

bool no_c99_libc_has_function ( )
static bool readonly_data_expr ( tree  )
static

Referenced by fold_builtin_logarithm().

static bool readonly_data_expr ( )
static

Returns true is EXP represents data that would potentially reside in a readonly section.

Make sure we call decl_readonly_section only for trees it can handle (since it returns true for everything it doesn't understand).

static tree rewrite_call_expr ( location_t  ,
tree  ,
int  ,
tree  ,
int  ,
  ... 
)
static
static tree rewrite_call_expr ( )
static

Construct a new CALL_EXPR using the tail of the argument list of EXP along with N new arguments specified as the "..." parameters. SKIP is the number of arguments in EXP to be omitted. This function is used to do varargs-to-varargs transformations.

References build_call_expr_loc(), build_int_cst(), integer_type_node, and NULL_TREE.

static tree rewrite_call_expr_array ( location_t  loc,
int  oldnargs,
tree args,
int  skip,
tree  fndecl,
int  n,
  ... 
)
static

Construct a new CALL_EXPR to FNDECL using the tail of the argument list ARGS along with N new arguments specified as the "..." parameters. SKIP is the number of arguments in ARGS to be omitted. OLDNARGS is the number of elements in ARGS.

static tree rewrite_call_expr_valist ( location_t  loc,
int  oldnargs,
tree args,
int  skip,
tree  fndecl,
int  n,
va_list  newargs 
)
static

Construct a new CALL_EXPR to FNDECL using the tail of the argument list ARGS along with N new arguments in NEWARGS. SKIP is the number of arguments in ARGS to be omitted. OLDNARGS is the number of elements in ARGS.

References builtin_decl_explicit(), builtin_decl_implicit(), NULL_TREE, and validate_arg().

Referenced by fold_builtin_2().

static rtx round_trampoline_addr ( )
static

Given a trampoline address, make sure it satisfies TRAMPOLINE_ALIGNMENT.

If we don't need too much alignment, we'll have been guaranteed proper alignment by get_trampoline_type.

 Round address up to desired boundary.   

References DECL_FUNCTION_CODE, EXPR_LOCATION, and get_callee_fndecl().

Referenced by expand_builtin_bswap().

void set_builtin_user_assembler_name ( )

Look up the function in builtin_decl that corresponds to DECL and set ASMSPEC as its user assembler name. DECL must be a function decl that declares a builtin.

static tree stabilize_va_list_loc ( location_t  ,
tree  ,
int   
)
static

Referenced by expand_builtin_strncmp().

static tree stabilize_va_list_loc ( )
static

Make it easier for the backends by protecting the valist argument from multiple evaluations.

The current way of determining the type of valist is completely bogus. We should have the information on the va builtin instead.

     For this case, the backends will be expecting a pointer to
     vatype, but it's possible we've actually been given an array
     (an actual TARGET_CANONICAL_VA_LIST_TYPE (valist)).
     So fix it.   

References CALL_EXPR_ARG, convert_to_mode(), expand_expr(), EXPAND_NORMAL, expand_unop(), gcc_assert, GET_MODE, and NULL_RTX.

tree std_build_builtin_va_list ( void  )

The "standard" definition of va_list is void*.

tree std_canonical_va_list_type ( )

The "standard" type of va_list is va_list_type_node.

Treat structure va_list types.

     If va_list is an array type, the argument may have decayed
     to a pointer type, e.g. by being passed to another function.
     In that case, unwrap both types so that we can compare the
     underlying records.   
void std_expand_builtin_va_start ( )

The "standard" implementation of va_start: just assign `nextarg' to the variable.

References emit_barrier().

Referenced by expand_builtin_strncmp().

tree std_fn_abi_va_list ( )

The "standard" abi va_list is va_list_type_node.

static int target_char_cast ( tree  ,
char *   
)
static
static int target_char_cast ( )
static

Cast a target constant CST to target CHAR and if that value fits into host char type, return zero and put that value into variable pointed to by P.

References frame_pointer_rtx, and hard_frame_pointer_rtx.

static enum type_class type_to_class ( tree  )
static
static enum type_class type_to_class ( )
static

Used by expand_builtin_classify_type and fold_builtin_classify_type.

static bool validate_arg ( )
static

Validate a single argument ARG against a tree code CODE representing a type.

bool validate_arglist ( )

This function validates the types of a function call argument list against a specified list of tree_codes. If the last specifier is a 0, that represents an ellipses, otherwise the last specifier must be a VOID_TYPE.

         This signifies an ellipses, any further arguments are all ok.   
         This signifies an endlink, if no arguments remain, return
         true, otherwise return false.   
         If no parameters remain or the parameter's code does not
         match the specified code, return false.  Otherwise continue
         checking any remaining arguments.   
 We need gotos here since we can only have one VA_CLOSE in a
 function.   

Referenced by expand_builtin_bzero(), expand_builtin_memcpy(), and expand_builtin_sincos().

bool validate_gimple_arglist ( )

This function validates the types of a function call argument list against a specified list of tree_codes. If the last specifier is a 0, that represents an ellipses, otherwise the last specifier must be a VOID_TYPE.

This is the GIMPLE version of validate_arglist. Eventually we want to completely convert builtins.c to work from GIMPLEs and the tree based validate_arglist will then be removed.

         This signifies an ellipses, any further arguments are all ok.   
         This signifies an endlink, if no arguments remain, return
         true, otherwise return false.   
         If no parameters remain or the parameter's code does not
         match the specified code, return false.  Otherwise continue
         checking any remaining arguments.   
 We need gotos here since we can only have one VA_CLOSE in a
 function.   
static bool var_decl_component_p ( )
static

Return true if VAR is a VAR_DECL or a component thereof.

References NULL_TREE, and validate_arg().


Variable Documentation

const char* const built_in_class_names[BUILT_IN_LAST] = {"NOT_BUILT_IN", "BUILT_IN_FRONTEND", "BUILT_IN_MD", "BUILT_IN_NORMAL"}

Define the names of the builtin function types and codes.

const char* built_in_names[(int) END_BUILTINS]
builtin_info_type builtin_info

Setup an array of _DECL trees, make sure each element is initialized to NULL_TREE.

Referenced by truth_value_p().

struct target_builtins default_target_builtins
bool force_folding_builtin_constant_p

Non-zero if __builtin_constant_p should be folded right away.

alias_set_type setjmp_alias_set = -1
static

Alias set used for setjmp buffer.

unsigned HOST_WIDE_INT target_c
static
unsigned HOST_WIDE_INT target_newline
static
unsigned HOST_WIDE_INT target_percent
static
char target_percent_c[3]
static
char target_percent_s[3]
static
char target_percent_s_newline[4]
static
unsigned HOST_WIDE_INT target_s
static