/* Expand builtin functions.
- Copyright (C) 1988-2014 Free Software Foundation, Inc.
+ Copyright (C) 1988-2015 Free Software Foundation, Inc.
This file is part of GCC.
#include "system.h"
#include "coretypes.h"
#include "tm.h"
-#include "machmode.h"
#include "rtl.h"
+#include "alias.h"
+#include "symtab.h"
#include "tree.h"
+#include "fold-const.h"
#include "stringpool.h"
#include "stor-layout.h"
#include "calls.h"
#include "tree-object-size.h"
#include "realmpfr.h"
#include "predict.h"
-#include "vec.h"
-#include "hashtab.h"
-#include "hash-set.h"
#include "hard-reg-set.h"
-#include "input.h"
#include "function.h"
#include "cfgrtl.h"
#include "basic-block.h"
#include "tree-ssa-alias.h"
#include "internal-fn.h"
#include "gimple-expr.h"
-#include "is-a.h"
#include "gimple.h"
#include "flags.h"
#include "regs.h"
#include "except.h"
#include "insn-config.h"
+#include "expmed.h"
+#include "dojump.h"
+#include "explow.h"
+#include "emit-rtl.h"
+#include "stmt.h"
#include "expr.h"
#include "insn-codes.h"
#include "optabs.h"
#include "builtins.h"
#include "asan.h"
#include "cilk.h"
-#include "ipa-ref.h"
#include "lto-streamer.h"
#include "cgraph.h"
#include "tree-chkp.h"
#include "rtl-chkp.h"
+#include "gomp-constants.h"
static tree do_mpc_arg1 (tree, tree, int (*)(mpc_ptr, mpc_srcptr, mpc_rnd_t));
};
#undef DEF_BUILTIN
-/* Setup an array of _DECL trees, make sure each element is
+/* Setup an array of builtin_info_type, make sure each element decl is
initialized to NULL_TREE. */
-builtin_info_type builtin_info;
+builtin_info_type builtin_info[(int)END_BUILTINS];
/* Non-zero if __builtin_constant_p should be folded right away. */
bool force_folding_builtin_constant_p;
#if defined (HAVE_untyped_call) || defined (HAVE_untyped_return)
static rtx result_vector (int, rtx);
#endif
-static void expand_builtin_update_setjmp_buf (rtx);
static void expand_builtin_prefetch (tree);
static rtx expand_builtin_apply_args (void);
static rtx expand_builtin_apply_args_1 (void);
static tree fold_builtin_abs (location_t, tree, tree);
static tree fold_builtin_unordered_cmp (location_t, tree, tree, tree, enum tree_code,
enum tree_code);
-static tree fold_builtin_0 (location_t, tree, bool);
-static tree fold_builtin_1 (location_t, tree, tree, bool);
-static tree fold_builtin_2 (location_t, tree, tree, tree, bool);
-static tree fold_builtin_3 (location_t, tree, tree, tree, tree, bool);
-static tree fold_builtin_varargs (location_t, tree, tree*, int, bool);
+static tree fold_builtin_0 (location_t, tree);
+static tree fold_builtin_1 (location_t, tree, tree);
+static tree fold_builtin_2 (location_t, tree, tree, tree);
+static tree fold_builtin_3 (location_t, tree, tree, tree, tree);
+static tree fold_builtin_varargs (location_t, tree, tree*, int);
static tree fold_builtin_strpbrk (location_t, tree, tree, tree);
static tree fold_builtin_strstr (location_t, tree, tree, tree);
tree addr = TREE_OPERAND (exp, 0);
unsigned ptr_align;
unsigned HOST_WIDE_INT ptr_bitpos;
+ unsigned HOST_WIDE_INT ptr_bitmask = ~0;
+ /* If the address is explicitely aligned, handle that. */
if (TREE_CODE (addr) == BIT_AND_EXPR
&& TREE_CODE (TREE_OPERAND (addr, 1)) == INTEGER_CST)
{
- align = (TREE_INT_CST_LOW (TREE_OPERAND (addr, 1))
- & -TREE_INT_CST_LOW (TREE_OPERAND (addr, 1)));
- align *= BITS_PER_UNIT;
+ ptr_bitmask = TREE_INT_CST_LOW (TREE_OPERAND (addr, 1));
+ ptr_bitmask *= BITS_PER_UNIT;
+ align = ptr_bitmask & -ptr_bitmask;
addr = TREE_OPERAND (addr, 0);
}
= get_pointer_alignment_1 (addr, &ptr_align, &ptr_bitpos);
align = MAX (ptr_align, align);
+ /* Re-apply explicit alignment to the bitpos. */
+ ptr_bitpos &= ptr_bitmask;
+
/* The alignment of the pointer operand in a TARGET_MEM_REF
has to take the variable offset parts into account. */
if (TREE_CODE (exp) == TARGET_MEM_REF)
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. */
-#ifdef RETURN_ADDR_IN_PREVIOUS_FRAME
- if (fndecl_code == BUILT_IN_RETURN_ADDRESS)
+ if (RETURN_ADDR_IN_PREVIOUS_FRAME && fndecl_code == BUILT_IN_RETURN_ADDRESS)
count--;
-#endif
/* Scan back COUNT frames to the specified frame. */
for (i = 0; i < count; i++)
/* __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. */
+ It updates the stack pointer in that block to the current value. This is
+ also called directly by the SJLJ exception handling code. */
-static void
+void
expand_builtin_update_setjmp_buf (rtx buf_addr)
{
machine_mode sa_mode = STACK_SAVEAREA_MODE (SAVE_NONLOCAL);
reg = gen_rtx_REG (mode, savep ? regno : INCOMING_REGNO (regno));
mem = adjust_address (result, mode, size);
savevec[nelts++] = (savep
- ? gen_rtx_SET (VOIDmode, mem, reg)
- : gen_rtx_SET (VOIDmode, reg, mem));
+ ? gen_rtx_SET (mem, reg)
+ : gen_rtx_SET (reg, mem));
size += GET_MODE_SIZE (mode);
}
return gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (nelts, savevec));
/* Save the arg pointer to the block. */
tem = copy_to_reg (crtl->args.internal_arg_pointer);
-#ifdef STACK_GROWS_DOWNWARD
/* 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. */
- tem
- = force_operand (plus_constant (Pmode, tem, crtl->args.pretend_args_size),
- NULL_RTX);
-#endif
+ if (STACK_GROWS_DOWNWARD)
+ tem
+ = force_operand (plus_constant (Pmode, tem,
+ crtl->args.pretend_args_size),
+ NULL_RTX);
emit_move_insn (adjust_address (registers, Pmode, 0), tem);
size = GET_MODE_SIZE (Pmode);
saved on entry to this function. So we migrate the
call to the first insn of this function. */
rtx temp;
- rtx seq;
start_sequence ();
temp = expand_builtin_apply_args_1 ();
- seq = get_insns ();
+ rtx_insn *seq = get_insns ();
end_sequence ();
apply_args_value = temp;
/* Fetch the arg pointer from the ARGUMENTS block. */
incoming_args = gen_reg_rtx (Pmode);
emit_move_insn (incoming_args, gen_rtx_MEM (Pmode, arguments));
-#ifndef STACK_GROWS_DOWNWARD
- incoming_args = expand_simple_binop (Pmode, MINUS, incoming_args, argsize,
- incoming_args, 0, OPTAB_LIB_WIDEN);
-#endif
+ if (!STACK_GROWS_DOWNWARD)
+ incoming_args = expand_simple_binop (Pmode, MINUS, incoming_args, argsize,
+ incoming_args, 0, OPTAB_LIB_WIDEN);
/* Push a new argument block and copy the arguments. Do not allow
the (potential) memcpy call below to interfere with our stack
crtl->need_drap = true;
dest = virtual_outgoing_args_rtx;
-#ifndef STACK_GROWS_DOWNWARD
- if (CONST_INT_P (argsize))
- dest = plus_constant (Pmode, dest, -INTVAL (argsize));
- else
- dest = gen_rtx_PLUS (Pmode, dest, negate_rtx (Pmode, argsize));
-#endif
+ if (!STACK_GROWS_DOWNWARD)
+ {
+ if (CONST_INT_P (argsize))
+ dest = plus_constant (Pmode, dest, -INTVAL (argsize));
+ else
+ dest = gen_rtx_PLUS (Pmode, dest, negate_rtx (Pmode, argsize));
+ }
dest = gen_rtx_MEM (BLKmode, dest);
set_mem_align (dest, PARM_BOUNDARY);
src = gen_rtx_MEM (BLKmode, incoming_args);
/* Test the result; if it is NaN, set errno=EDOM because
the argument was not in the domain. */
do_compare_rtx_and_jump (target, target, EQ, 0, GET_MODE (target),
- NULL_RTX, NULL_RTX, lab,
+ NULL_RTX, NULL, lab,
/* The jump is very likely. */
REG_BR_PROB_BASE - (REG_BR_PROB_BASE / 2000 - 1));
#ifdef HAVE_trap
if (HAVE_trap)
{
- rtx insn = emit_insn (gen_trap ());
+ rtx_insn *insn = emit_insn (gen_trap ());
/* For trap insns when not accumulating outgoing args force
REG_ARGS_SIZE note to prevent crossjumping of calls with
different args sizes. */
mem = get_builtin_sync_mem (CALL_EXPR_ARG (exp, 0), mode);
val = expand_expr_force_mode (CALL_EXPR_ARG (exp, 1), mode);
- return expand_atomic_fetch_op (target, mem, val, code, MEMMODEL_SEQ_CST,
+ return expand_atomic_fetch_op (target, mem, val, code, MEMMODEL_SYNC_SEQ_CST,
after);
}
poval = ⌖
}
if (!expand_atomic_compare_and_swap (pbool, poval, mem, old_val, new_val,
- false, MEMMODEL_SEQ_CST,
- MEMMODEL_SEQ_CST))
+ false, MEMMODEL_SYNC_SEQ_CST,
+ MEMMODEL_SYNC_SEQ_CST))
return NULL_RTX;
return target;
/* Expand the operands. */
mem = get_builtin_sync_mem (CALL_EXPR_ARG (exp, 0), mode);
- expand_atomic_store (mem, const0_rtx, MEMMODEL_RELEASE, true);
+ expand_atomic_store (mem, const0_rtx, MEMMODEL_SYNC_RELEASE, true);
}
/* Given an integer representing an ``enum memmodel'', verify its
return MEMMODEL_SEQ_CST;
}
- if ((INTVAL (op) & MEMMODEL_MASK) >= MEMMODEL_LAST)
+ /* Should never see a user explicit SYNC memodel model, so >= LAST works. */
+ if (memmodel_base (val) >= MEMMODEL_LAST)
{
warning (OPT_Winvalid_memory_model,
"invalid memory model argument to builtin");
return MEMMODEL_SEQ_CST;
}
+ /* Workaround for Bugzilla 59448. GCC doesn't track consume properly, so
+ be conservative and promote consume to acquire. */
+ if (val == MEMMODEL_CONSUME)
+ val = MEMMODEL_ACQUIRE;
+
return (enum memmodel) val;
}
enum memmodel model;
model = get_memmodel (CALL_EXPR_ARG (exp, 2));
- if ((model & MEMMODEL_MASK) == MEMMODEL_CONSUME)
- {
- error ("invalid memory model for %<__atomic_exchange%>");
- return NULL_RTX;
- }
if (!flag_inline_atomics)
return NULL_RTX;
success = get_memmodel (CALL_EXPR_ARG (exp, 4));
failure = get_memmodel (CALL_EXPR_ARG (exp, 5));
- if ((failure & MEMMODEL_MASK) == MEMMODEL_RELEASE
- || (failure & MEMMODEL_MASK) == MEMMODEL_ACQ_REL)
+ if (failure > success)
{
- error ("invalid failure memory model for %<__atomic_compare_exchange%>");
- return NULL_RTX;
+ warning (OPT_Winvalid_memory_model,
+ "failure memory model cannot be stronger than success memory "
+ "model for %<__atomic_compare_exchange%>");
+ success = MEMMODEL_SEQ_CST;
}
-
- if (failure > success)
+
+ if (is_mm_release (failure) || is_mm_acq_rel (failure))
{
- error ("failure memory model cannot be stronger than success "
- "memory model for %<__atomic_compare_exchange%>");
- return NULL_RTX;
+ warning (OPT_Winvalid_memory_model,
+ "invalid failure memory model for "
+ "%<__atomic_compare_exchange%>");
+ failure = MEMMODEL_SEQ_CST;
+ success = MEMMODEL_SEQ_CST;
}
-
+
+
if (!flag_inline_atomics)
return NULL_RTX;
the normal case where EXPECT is totally private, i.e. a register. At
which point the store can be unconditional. */
label = gen_label_rtx ();
- emit_cmp_and_jump_insns (target, const0_rtx, NE, NULL, VOIDmode, 1, label);
+ emit_cmp_and_jump_insns (target, const0_rtx, NE, NULL,
+ GET_MODE (target), 1, label);
emit_move_insn (expect, oldval);
emit_label (label);
enum memmodel model;
model = get_memmodel (CALL_EXPR_ARG (exp, 1));
- if ((model & MEMMODEL_MASK) == MEMMODEL_RELEASE
- || (model & MEMMODEL_MASK) == MEMMODEL_ACQ_REL)
+ if (is_mm_release (model) || is_mm_acq_rel (model))
{
- error ("invalid memory model for %<__atomic_load%>");
- return NULL_RTX;
+ warning (OPT_Winvalid_memory_model,
+ "invalid memory model for %<__atomic_load%>");
+ model = MEMMODEL_SEQ_CST;
}
if (!flag_inline_atomics)
enum memmodel model;
model = get_memmodel (CALL_EXPR_ARG (exp, 2));
- if ((model & MEMMODEL_MASK) != MEMMODEL_RELAXED
- && (model & MEMMODEL_MASK) != MEMMODEL_SEQ_CST
- && (model & MEMMODEL_MASK) != MEMMODEL_RELEASE)
+ if (!(is_mm_relaxed (model) || is_mm_seq_cst (model)
+ || is_mm_release (model)))
{
- error ("invalid memory model for %<__atomic_store%>");
- return NULL_RTX;
+ warning (OPT_Winvalid_memory_model,
+ "invalid memory model for %<__atomic_store%>");
+ model = MEMMODEL_SEQ_CST;
}
if (!flag_inline_atomics)
mem = get_builtin_sync_mem (CALL_EXPR_ARG (exp, 0), mode);
model = get_memmodel (CALL_EXPR_ARG (exp, 1));
- if ((model & MEMMODEL_MASK) == MEMMODEL_ACQUIRE
- || (model & MEMMODEL_MASK) == MEMMODEL_ACQ_REL)
+ if (is_mm_consume (model) || is_mm_acquire (model) || is_mm_acq_rel (model))
{
- error ("invalid memory model for %<__atomic_store%>");
- return const0_rtx;
+ warning (OPT_Winvalid_memory_model,
+ "invalid memory model for %<__atomic_store%>");
+ model = MEMMODEL_SEQ_CST;
}
if (HAVE_atomic_clear)
static void
expand_builtin_sync_synchronize (void)
{
- expand_mem_thread_fence (MEMMODEL_SEQ_CST);
+ expand_mem_thread_fence (MEMMODEL_SYNC_SEQ_CST);
}
static rtx
prev = get_last_insn ();
emit_stack_restore (SAVE_BLOCK, sa);
+
+ record_new_stack_level ();
+
fixup_args_size_notes (prev, get_last_insn (), 0);
}
-
/* Emit code to save the current value of stack. */
static rtx
{
rtx ret = NULL_RTX;
- do_pending_stack_adjust ();
emit_stack_save (SAVE_BLOCK, &ret);
return ret;
}
+
+/* Expand OpenACC acc_on_device.
+
+ This has to happen late (that is, not in early folding; expand_builtin_*,
+ rather than fold_builtin_*), as we have to act differently for host and
+ acceleration device (ACCEL_COMPILER conditional). */
+
+static rtx
+expand_builtin_acc_on_device (tree exp ATTRIBUTE_UNUSED,
+ rtx target ATTRIBUTE_UNUSED)
+{
+#ifdef ACCEL_COMPILER
+ if (!validate_arglist (exp, INTEGER_TYPE, VOID_TYPE))
+ return NULL_RTX;
+
+ tree arg = CALL_EXPR_ARG (exp, 0);
+
+ /* Return (arg == v1 || arg == v2) ? 1 : 0. */
+ machine_mode v_mode = TYPE_MODE (TREE_TYPE (arg));
+ rtx v = expand_normal (arg), v1, v2;
+ v1 = GEN_INT (GOMP_DEVICE_NOT_HOST);
+ v2 = GEN_INT (ACCEL_COMPILER_acc_device);
+ machine_mode target_mode = TYPE_MODE (integer_type_node);
+ if (!target || !register_operand (target, target_mode))
+ target = gen_reg_rtx (target_mode);
+ emit_move_insn (target, const1_rtx);
+ rtx_code_label *done_label = gen_label_rtx ();
+ do_compare_rtx_and_jump (v, v1, EQ, false, v_mode, NULL_RTX,
+ NULL, done_label, PROB_EVEN);
+ do_compare_rtx_and_jump (v, v2, EQ, false, v_mode, NULL_RTX,
+ NULL, done_label, PROB_EVEN);
+ emit_move_insn (target, const0_rtx);
+ emit_label (done_label);
+
+ return target;
+#else
+ return NULL;
+#endif
+}
+
+
/* 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).
machine_mode target_mode = TYPE_MODE (TREE_TYPE (exp));
int flags;
+ if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD)
+ return targetm.expand_builtin (exp, target, subtarget, mode, ignore);
+
/* When ASan is enabled, we don't want to expand some memory/string
builtins and rely on libsanitizer's hooks. This allows us to avoid
redundant checks and be sure, that possible overflow will be detected
if ((flag_sanitize & SANITIZE_ADDRESS) && asan_intercepted_p (fcode))
return expand_call (exp, target, ignore);
- if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD)
- return targetm.expand_builtin (exp, target, subtarget, mode, ignore);
-
/* When not optimizing, generate calls to library functions for a certain
set of builtins. */
if (!optimize
rtx buf_addr = expand_expr (CALL_EXPR_ARG (exp, 0), subtarget,
VOIDmode, EXPAND_NORMAL);
tree label = TREE_OPERAND (CALL_EXPR_ARG (exp, 1), 0);
- rtx label_r = label_rtx (label);
+ rtx_insn *label_r = label_rtx (label);
/* This is copied from the handling of non-local gotos. */
expand_builtin_setjmp_setup (buf_addr, label_r);
if (validate_arglist (exp, POINTER_TYPE, VOID_TYPE))
{
tree label = TREE_OPERAND (CALL_EXPR_ARG (exp, 0), 0);
- rtx label_r = label_rtx (label);
+ rtx_insn *label_r = label_rtx (label);
expand_builtin_setjmp_receiver (label_r);
return const0_rtx;
expand_builtin_eh_return (CALL_EXPR_ARG (exp, 0),
CALL_EXPR_ARG (exp, 1));
return const0_rtx;
-#ifdef EH_RETURN_DATA_REGNO
case BUILT_IN_EH_RETURN_DATA_REGNO:
return expand_builtin_eh_return_data_regno (exp);
-#endif
case BUILT_IN_EXTEND_POINTER:
return expand_builtin_extend_pointer (CALL_EXPR_ARG (exp, 0));
case BUILT_IN_EH_POINTER:
error ("Your target platform does not support -fcheck-pointer-bounds");
break;
+ case BUILT_IN_ACC_ON_DEVICE:
+ target = expand_builtin_acc_on_device (exp, target);
+ if (target)
+ return target;
+ break;
+
default: /* just do library call, if unknown builtin */
break;
}
return NULL_TREE;
/* If there are no infinities, return arg. */
- if (! HONOR_INFINITIES (TYPE_MODE (TREE_TYPE (type))))
+ if (! HONOR_INFINITIES (type))
return non_lvalue_loc (loc, arg);
/* Calculate the result when the argument is a constant. */
return NULL_TREE;
}
-/* Fold function call to builtin stpcpy with arguments DEST and SRC.
- Return NULL_TREE if no simplification can be made. */
-
-static tree
-fold_builtin_stpcpy (location_t loc, tree fndecl, tree dest, tree src)
-{
- tree fn, len, lenp1, call, type;
-
- if (!validate_arg (dest, POINTER_TYPE)
- || !validate_arg (src, POINTER_TYPE))
- return NULL_TREE;
-
- len = c_strlen (src, 1);
- if (!len
- || TREE_CODE (len) != INTEGER_CST)
- return NULL_TREE;
-
- if (optimize_function_for_size_p (cfun)
- /* If length is zero it's small enough. */
- && !integer_zerop (len))
- return NULL_TREE;
-
- fn = builtin_decl_implicit (BUILT_IN_MEMCPY);
- if (!fn)
- return NULL_TREE;
-
- lenp1 = size_binop_loc (loc, PLUS_EXPR,
- fold_convert_loc (loc, size_type_node, len),
- build_int_cst (size_type_node, 1));
- /* We use dest twice in building our expression. Save it from
- multiple expansions. */
- dest = builtin_save_expr (dest);
- call = build_call_expr_loc (loc, fn, 3, dest, src, lenp1);
-
- type = TREE_TYPE (TREE_TYPE (fndecl));
- dest = fold_build_pointer_plus_loc (loc, dest, len);
- dest = fold_convert_loc (loc, type, dest);
- dest = omit_one_operand_loc (loc, type, dest, call);
- return dest;
-}
-
/* 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. */
return omit_one_operand_loc (loc, type, integer_zero_node, arg);
/* If ARG's format doesn't have signed zeros, return "arg < 0.0". */
- if (!HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (arg))))
+ if (!HONOR_SIGNED_ZEROS (arg))
return fold_convert (type,
fold_build2_loc (loc, LT_EXPR, boolean_type_node, arg,
build_real (TREE_TYPE (arg), dconst0)));
omit_one_operand() ensures we create a non-lvalue. */
if (TREE_CODE (arg0) == REAL_CST
&& real_isnan (&TREE_REAL_CST (arg0))
- && (! HONOR_SNANS (TYPE_MODE (TREE_TYPE (arg0)))
+ && (! HONOR_SNANS (arg0)
|| ! TREE_REAL_CST (arg0).signalling))
return omit_one_operand_loc (loc, type, arg1, arg0);
if (TREE_CODE (arg1) == REAL_CST
&& real_isnan (&TREE_REAL_CST (arg1))
- && (! HONOR_SNANS (TYPE_MODE (TREE_TYPE (arg1)))
+ && (! HONOR_SNANS (arg1)
|| ! TREE_REAL_CST (arg1).signalling))
return omit_one_operand_loc (loc, type, arg0, arg1);
switch (builtin_index)
{
case BUILT_IN_ISINF:
- if (!HONOR_INFINITIES (TYPE_MODE (TREE_TYPE (arg))))
+ if (!HONOR_INFINITIES (arg))
return omit_one_operand_loc (loc, type, integer_zero_node, arg);
if (TREE_CODE (arg) == REAL_CST)
}
case BUILT_IN_ISFINITE:
- if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg)))
- && !HONOR_INFINITIES (TYPE_MODE (TREE_TYPE (arg))))
+ if (!HONOR_NANS (arg)
+ && !HONOR_INFINITIES (arg))
return omit_one_operand_loc (loc, type, integer_one_node, arg);
if (TREE_CODE (arg) == REAL_CST)
return NULL_TREE;
case BUILT_IN_ISNAN:
- if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg))))
+ if (!HONOR_NANS (arg))
return omit_one_operand_loc (loc, type, integer_zero_node, arg);
if (TREE_CODE (arg) == REAL_CST)
if (unordered_code == UNORDERED_EXPR)
{
- if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0))))
+ if (!HONOR_NANS (arg0))
return omit_two_operands_loc (loc, type, integer_zero_node, arg0, arg1);
return fold_build2_loc (loc, UNORDERED_EXPR, type, arg0, arg1);
}
- code = HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0))) ? unordered_code
- : ordered_code;
+ code = HONOR_NANS (arg0) ? unordered_code : ordered_code;
return fold_build1_loc (loc, TRUTH_NOT_EXPR, type,
fold_build2_loc (loc, code, type, arg0, arg1));
}
}
/* 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. */
+ This function returns NULL_TREE if no simplification was possible. */
static tree
-fold_builtin_0 (location_t loc, tree fndecl, bool ignore ATTRIBUTE_UNUSED)
+fold_builtin_0 (location_t loc, tree fndecl)
{
tree type = TREE_TYPE (TREE_TYPE (fndecl));
enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
}
/* 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. */
+ This function returns NULL_TREE if no simplification was possible. */
static tree
-fold_builtin_1 (location_t loc, tree fndecl, tree arg0, bool)
+fold_builtin_1 (location_t loc, tree fndecl, tree arg0)
{
tree type = TREE_TYPE (TREE_TYPE (fndecl));
enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
CASE_FLT_FN (BUILT_IN_CREAL):
if (validate_arg (arg0, COMPLEX_TYPE)
&& TREE_CODE (TREE_TYPE (TREE_TYPE (arg0))) == REAL_TYPE)
- return non_lvalue_loc (loc, fold_build1_loc (loc, REALPART_EXPR, type, arg0));;
+ return non_lvalue_loc (loc, fold_build1_loc (loc, REALPART_EXPR, type, arg0));
break;
CASE_FLT_FN (BUILT_IN_CIMAG):
}
/* 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. */
+ This function returns NULL_TREE if no simplification was possible. */
static tree
-fold_builtin_2 (location_t loc, tree fndecl, tree arg0, tree arg1, bool ignore)
+fold_builtin_2 (location_t loc, tree fndecl, tree arg0, tree arg1)
{
tree type = TREE_TYPE (TREE_TYPE (fndecl));
enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
case BUILT_IN_RINDEX:
return fold_builtin_strrchr (loc, arg0, arg1, type);
- case BUILT_IN_STPCPY:
- if (ignore)
- {
- tree fn = builtin_decl_implicit (BUILT_IN_STRCPY);
- if (!fn)
- break;
-
- return build_call_expr_loc (loc, fn, 2, arg0, arg1);
- }
- else
- return fold_builtin_stpcpy (loc, fndecl, arg0, arg1);
- break;
-
case BUILT_IN_STRCMP:
return fold_builtin_strcmp (loc, arg0, arg1);
}
/* 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.
+ and ARG2.
This function returns NULL_TREE if no simplification was possible. */
static tree
fold_builtin_3 (location_t loc, tree fndecl,
- tree arg0, tree arg1, tree arg2, bool)
+ tree arg0, tree arg1, tree arg2)
{
tree type = TREE_TYPE (TREE_TYPE (fndecl));
enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
simplification was possible. */
tree
-fold_builtin_n (location_t loc, tree fndecl, tree *args, int nargs, bool ignore)
+fold_builtin_n (location_t loc, tree fndecl, tree *args, int nargs, bool)
{
tree ret = NULL_TREE;
switch (nargs)
{
case 0:
- ret = fold_builtin_0 (loc, fndecl, ignore);
+ ret = fold_builtin_0 (loc, fndecl);
break;
case 1:
- ret = fold_builtin_1 (loc, fndecl, args[0], ignore);
+ ret = fold_builtin_1 (loc, fndecl, args[0]);
break;
case 2:
- ret = fold_builtin_2 (loc, fndecl, args[0], args[1], ignore);
+ ret = fold_builtin_2 (loc, fndecl, args[0], args[1]);
break;
case 3:
- ret = fold_builtin_3 (loc, fndecl, args[0], args[1], args[2], ignore);
+ ret = fold_builtin_3 (loc, fndecl, args[0], args[1], args[2]);
break;
default:
- ret = fold_builtin_varargs (loc, fndecl, args, nargs, ignore);
+ ret = fold_builtin_varargs (loc, fndecl, args, nargs);
break;
}
if (ret)
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. */
+ function, EXP is the CALL_EXPR for the call. */
static tree
-fold_builtin_varargs (location_t loc, tree fndecl, tree *args, int nargs,
- bool ignore ATTRIBUTE_UNUSED)
+fold_builtin_varargs (location_t loc, tree fndecl, tree *args, int nargs)
{
enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
tree ret = NULL_TREE;
case BUILT_IN_LABS:
case BUILT_IN_LLABS:
case BUILT_IN_PREFETCH:
+ case BUILT_IN_ACC_ON_DEVICE:
return true;
default: