GCC Middle and Back End API Reference
|
Variables | |
struct target_builtins | default_target_builtins |
struct target_builtins * | this_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 |
|
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 gen_rtx_REG().
|
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().
|
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(), and omit_two_operands_loc().
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 |
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 |
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().
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 |
Callback routine for store_by_pieces. Read GET_MODE_BITSIZE (MODE) bytes from constant string DATA + OFFSET and return it as target constant.
|
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 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 |
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 |
|
static |
Return a char pointer for a C string if it is a string constant or sum of string constant and integer constant.
|
static |
Referenced by expand_builtin_mempcpy_args().
|
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 |
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 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 validate_arg().
bool default_libc_has_function | ( | ) |
By default we assume that c99 functions are present at the runtime, but sincos is not.
@verbatim
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 |
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 |
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 |
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 |
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 |
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 |
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().
Referenced by fold_builtin_classify().
|
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 |
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 |
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.
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 |
Expand a call to __builtin___clear_cache.
There is no "clear_cache" insn, and __clear_cache() in libgcc does something. Just do the default expansion to a call to __clear_cache().
There is no "clear_cache" insn, and __clear_cache() in libgcc does nothing. There is no need to call it. Do nothing.
We have a "clear_cache" insn, and it will handle everything.
We must not expand to a library call. If we did, any fallback library function in libgcc that might contain a call to __builtin___clear_cache() would recurse infinitely.
References mode_for_size().
|
static |
|
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 |
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.
Locate the unique return register. It is not possible to express a call that sets more than one return register using call_value; use untyped_call for that. In fact, untyped_call only needs to save the return registers in the given block.
Find the CALL insn we just emitted, and attach the register usage information.
Restore the stack.
Return the address of the result block.
|
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 |
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.
We need the pointer as the caller actually passed them to us, not as we might have pretended they were passed. Make sure it's a valid operand, as emit_move_insn isn't expected to handle a PLUS.
Save the structure value address unless this is passed as an "invisible" first argument.
Return the address of the block.
Referenced by result_vector().
|
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 operand_subword_force(), and word_mode.
|
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 |
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 |
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 expand_mem_thread_fence(), and get_memmodel().
|
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 error(), and fold_builtin_atomic_is_lock_free().
|
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 |
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 |
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 |
Expand the __atomic_signal_fence intrinsic: void __atomic_signal_fence (enum memmodel) EXP is the CALL_EXPR.
|
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 |
Expand an atomic test_and_set operation. bool _atomic_test_and_set (BOOL *obj, enum memmodel) EXP is the call expression.
|
static |
Expand the __atomic_thread_fence intrinsic: void __atomic_thread_fence (enum memmodel) EXP is the CALL_EXPR.
|
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 expand_normal(), round_trampoline_addr(), and targetm.
|
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 get_pointer_alignment(), insn_data, len, and validate_arglist().
|
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 |
Expand a call EXP to __builtin_classify_type.
References mathfn_built_in_1().
|
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 expand_atomic_test_and_set(), get_builtin_sync_mem(), get_memmodel(), and mode_for_size().
|
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 |
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, and real_format::has_signed_zero.
|
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 |
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 |
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 |
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 |
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 |
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 |
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 |
__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.
We have to pass a value to the nonlocal_goto pattern that will get copied into the static_chain pointer, but it does not matter what that value is, because builtin_setjmp does not use it.
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().
|
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 |
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 |
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 |
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.
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.
If we don't have POINTER_TYPE, call the function.
Make a place to write the result of the instruction.
Set MEM_SIZE as appropriate.
Return the value in the proper mode for this function.
|
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 expand_builtin_strcpy_args(), and validate_arglist().
|
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().
|
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 |
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 strlen().
|
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 |
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 build_call_nofold_loc(), builtin_save_expr(), c_strlen(), convert_move(), convert_to_mode(), emit_insn(), expand_call(), expand_normal(), gen_reg_rtx(), get_callee_fndecl(), get_memory_rtx(), get_pointer_alignment(), insn_data, len, and tree_int_cst_lt().
|
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 |
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.
??? We no longer need to pass the static chain value, afaik.
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.
rtx expand_builtin_object_size | ( | ) |
Expand a call EXP to __builtin_object_size.
References host_integerp(), len, and tree_int_cst_lt().
|
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 |
|
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_int_cst(), build_range_type(), exp(), expand_expr(), EXPAND_NORMAL, gen_rtx_MEM(), get_base_address(), is_gimple_mem_ref_addr(), ptr_mode, set_mem_alias_set(), and set_mem_attributes().
|
static |
|
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 |
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(), and gen_frame_mem().
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_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.
If the argument pointer can be eliminated in favor of the frame pointer, we don't need to restore it. We assume here that if such an elimination is present, it can always be used. This is the case on all known machines; if we don't make this assumption, we do unnecessary saving on many machines.
Now restore our arg pointer from the address at which it was saved in our stack frame.
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 |
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 |
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(), emit_insn(), end_sequence(), expand_expr(), EXPAND_NORMAL, expand_sfix_optab(), gen_reg_rtx(), get_callee_fndecl(), get_insns(), start_sequence(), and validate_arglist().
|
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 |
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.
If we don't have POINTER_TYPE, call the function.
Stabilize the arguments in case gen_cmpstr(n)si fail.
Try to call cmpstrsi.
Make a place to write the result of the instruction.
Try to determine at least one length and call cmpstrnsi.
If we don't have a constant length for the first, use the length of the second, if we know it. We don't require a constant for this case; some cost analysis could be done if both are available but neither is constant. For now, assume they're equally cheap, unless one has side effects. If both strings have constant lengths, use the smaller.
If both arguments have side effects, we cannot optimize.
Make a place to write the result of the instruction.
Return the value in the proper mode for this function.
Expand the library call ourselves using a stabilized argument list to avoid re-evaluating the function's arguments twice.
References targetm.
|
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).
Referenced by expand_builtin_memcpy().
|
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 expand_expr(), and EXPAND_NORMAL.
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 -- 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.
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).
If we don't have a constant length for the first, use the length of the second, if we know it. We don't require a constant for this case; some cost analysis could be done if both are available but neither is constant. For now, assume they're equally cheap, unless one has side effects. If both strings have constant lengths, use the smaller.
If both arguments have side effects, we cannot optimize.
The actual new length parameter is MIN(len,arg3).
If we don't have POINTER_TYPE, call the function.
Make a place to write the result of the instruction.
Stabilize the arguments in case gen_cmpstrnsi fails.
Return the value in the proper mode for this function.
Expand the library call ourselves using a stabilized argument list to avoid re-evaluating the function's arguments twice.
References error_at(), expand_builtin_next_arg(), fold_builtin_next_arg(), stabilize_va_list_loc(), std_expand_builtin_va_start(), and targetm.
|
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 |
Expand the __sync_lock_release intrinsic. EXP is the CALL_EXPR.
Expand the operands.
|
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 |
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(), and OPTAB_LIB_WIDEN.
|
static |
Expand the __sync_synchronize intrinsic.
|
static |
void expand_builtin_trap | ( | void | ) |
For trap insns when not accumulating outgoing args force REG_ARGS_SIZE note to prevent crossjumping of calls with different args sizes.
|
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 |
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 |
|
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(), and maybe_expand_insn().
|
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 build_array_type(), build_index_type(), build_pointer_type(), build_string(), and type().
|
static |
Expand EXP, a call to __builtin_va_end.
Evaluate for side effects, if needed. I hate macros that don't do that.
References expand_copysign(), expand_expr(), EXPAND_NORMAL, and expand_normal().
|
static |
Expand EXP, a call to __builtin_va_start.
References builtin_save_expr(), expand_abs(), expand_expr(), EXPAND_NORMAL, and safe_from_p().
|
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.
If this built-in doesn't throw an exception, set errno directly.
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 |
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 |
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 |
|
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 |
|
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 |
|
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 rewrite_call_expr_valist().
|
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 |
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(), target_char_cast(), and validate_arg().
|
static |
|
static |
Fold a call to abs, labs, llabs or imaxabs with argument ARG.
|
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 |
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 |
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(), and fold_convert_loc().
|
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 |
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 |
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 |
Fold a call to builtin carg(a+bi) -> atan2(b,a).
References fold_builtin_constant_p().
|
static |
|
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 ctz_hwi(), ffs_hwi(), floor_log2(), HOST_BITS_PER_WIDE_INT, HOST_WIDE_INT, HOST_WIDE_INT_M1U, type(), and validate_arg().
|
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 |
|
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(), and real_powi().
|
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().
|
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(), 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(), and validate_arg().
|
static |
Fold a call to __builtin_classify_type with argument ARG.
Referenced by fold_builtin_carg().
|
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(), OEP_PURE_SAME, operand_equal_p(), real_value_truncate(), and real_zerop().
|
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 |
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 |
|
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 |
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 |
|
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 |
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(), strlen(), target_char_cast(), tree_low_cst(), and validate_arg().
|
static |
|
static |
Fold a call to fabs, fabsf or fabsl with argument ARG.
References build_real(), and real_inf().
|
static |
|
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 |
Fold a call to fma, fmaf, or fmal with arguments ARG[012].
??? Only expand to FMA_EXPR if it's directly supported.
|
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 |
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 |
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(), len, omit_one_operand_loc(), operand_equal_p(), tree_int_cst_lt(), and validate_arg().
Referenced by fold_builtin_classify().
|
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 |
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 |
|
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 |
|
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(), and tree_expr_nonnegative_p().
|
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 |
|
static |
Fold a call to builtin isascii with argument ARG.
Transform isascii(c) -> ((c & ~0x7f) == 0).
References real_isnan().
|
static |
|
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 |
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 |
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(), 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(), operand_equal_p(), ranges_overlap_p(), readonly_data_expr(), refs_may_alias_p_1(), and tree_low_cst().
|
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 |
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 |
|
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 |
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 |
Fold function call to builtin memset. Return NULL_TREE if no simplification can be made.
If the LEN parameter is zero, return DEST.
|
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 |
|
static |
|
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().
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 |
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 |
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 |
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 |
|
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 |
|
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 |
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 |
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(), dconst2, dconsthalf, real_from_integer(), and real_value_truncate().
|
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(), and real_format::round_towards_zero.
|
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 |
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 |
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 |
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_int_cst(), do_mpfr_ckconv(), mpfr_from_real(), real_format::p, real_isfinite(), and real_format::round_towards_zero.
|
static |
|
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 |
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 |
Referenced by fold_builtin_classify().
|
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 |
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 |
Referenced by fold_builtin_classify().
|
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 |
|
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_fma(), and optab_handler().
Referenced by fold_builtin_classify().
|
static |
Referenced by fold_builtin_classify().
|
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(), tree_int_cst_sgn(), tree_low_cst(), and validate_arg().
|
static |
|
static |
Fold a call to __builtin_strlen with argument ARG.
|
static |
|
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 |
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(), real_format::p, real_compare(), real_isfinite(), real_format::round_towards_zero, and tree_low_cst().
|
static |
|
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).
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(), real_inf(), real_isinf(), real_isneg(), rvc_inf, rvc_nan, rvc_normal, rvc_zero, and validate_arg().
|
static |
|
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 |
Referenced by fold_builtin_classify().
|
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 |
Referenced by fold_builtin_classify().
|
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(), and host_integerp().
|
static |
Referenced by fold_builtin_classify().
|
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().
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 |
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_mathfn_code(), dconst0, do_mpfr_arg1(), and fold_convert_loc().
|
static |
|
static |
Fold a call to builtin toascii with argument ARG.
Transform toascii(c) -> (c & 0x7f).
References type().
|
static |
|
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 |
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 |
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().
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 |
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).
Fold a fma operation with arguments ARG[012].
Referenced by fold_builtin_strcpy().
|
static |
|
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(), and validate_arg().
|
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 expand_expr_force_mode(), and get_memmodel().
Referenced by expand_builtin_compare_and_swap().
|
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 |
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 error(), and fold_builtin_atomic_always_lock_free().
Referenced by expand_builtin_atomic_compare_exchange(), expand_builtin_compare_and_swap(), and get_builtin_sync_mem().
Referenced by expand_builtin_memset_args().
|
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 get_object_alignment_2(), and get_ptr_info_alignment().
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 |
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(), HOST_WIDE_INT, offset, string_constant(), and tree_int_cst_equal().
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 |
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.
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 |
Initialize format string characters in the target charset.
Referenced by maybe_emit_sprintf_chk_warning().
|
static |
|
static |
Return true if the floating point expression T has an integer value. We also allow +Inf, -Inf and NaN to be considered integer values.
References build_call_expr_loc(), build_real(), dconst_third_ptr(), mathfn_built_in(), real_arithmetic(), real_value_truncate(), and tree_expr_nonnegative_p().
|
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 |
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 |
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(), and word_mode.
Referenced by expand_builtin_classify_type().
|
static |
|
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(), integer_zerop(), string_constant(), and strlen().
|
static |
|
static |
Emit warning if a free is called with address of a variable.
|
static |
|
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(), and validate_arg().
bool no_c99_libc_has_function | ( | ) |
References is_builtin_name().
|
static |
Referenced by fold_builtin_logarithm().
|
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 |
Create a vector describing the result block RESULT. If SAVEP is true, the result block is used to save the values; otherwise it is used to restore the values.
References emit_insn_before(), end_sequence(), entry_of_function(), expand_builtin_apply_args_1(), get_insns(), pop_topmost_sequence(), push_topmost_sequence(), and start_sequence().
|
static |
|
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(), and build_int_cst().
|
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 |
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(), and validate_arg().
Referenced by fold_builtin_2().
|
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 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 |
Referenced by expand_builtin_strncmp().
|
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 convert_to_mode(), expand_expr(), EXPAND_NORMAL, and expand_unop().
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 |
Referenced by fold_builtin_4(), and fold_builtin_exponent().
|
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.
|
static |
|
static |
Used by expand_builtin_classify_type and fold_builtin_classify_type.
|
static |
Referenced by build_call_expr_loc(), default_expand_builtin(), fold_builtin_4(), fold_builtin_cbrt(), fold_builtin_classify(), fold_builtin_exponent(), fold_builtin_fputs(), fold_builtin_n(), fold_builtin_strcspn(), fold_builtin_strncpy(), fold_trunc_transparent_mathfn(), maybe_emit_sprintf_chk_warning(), rewrite_call_expr_valist(), and var_decl_component_p().
|
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 |
Return true if VAR is a VAR_DECL or a component thereof.
References validate_arg().
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.
|
static |
Alias set used for setjmp buffer.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
struct target_builtins* this_target_builtins = &default_target_builtins |