aboutsummaryrefslogtreecommitdiff
path: root/gcc/calls.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-09-04 07:30:53 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-09-04 07:30:53 +0000
commitdb69559bac8ab03ccddfe3a42be630e65c277812 (patch)
tree2cf080b045129f4dea972ab956100f6ec25bddbc /gcc/calls.c
parent77701e2346bee936056ff33e1a94b214e359b4d2 (diff)
downloadgcc-db69559bac8ab03ccddfe3a42be630e65c277812.zip
gcc-db69559bac8ab03ccddfe3a42be630e65c277812.tar.gz
gcc-db69559bac8ab03ccddfe3a42be630e65c277812.tar.bz2
PR82045: Avoid passing machine modes through "..."
PR82045 is about a bootstrap failure on sparc-sun-solaris2.11. The problem was that we were passing the new machine_mode wrapper classes through "..." to emit_library_call(_value), which then read them back as ints instead. The simplest fix seemed to be replace "..." with an array of rtx_mode_ts, then provide wrappers for the common cases. This bulks out rtl.h a bit, but it does make things a bit more typesafe. 2017-09-04 Richard Sandiford <richard.sandiford@linaro.org> gcc/ PR bootstrap/82045 * rtl.h (emit_library_call_value_1): Declare. (emit_library_call): Replace declaration with a series of overloads. Remove the parameter count argument. (emit_library_call_value): Likewise. * calls.c (emit_library_call_value_1): Make global. Replace varargs with an "rtx_mode_t *". (emit_library_call_value): Delete. (emit_library_call): Likewise. * asan.c (asan_emit_stack_protection): Update calls accordingly. (asan_emit_allocas_unpoison): Likewise. * builtins.c (expand_builtin_powi): Likewise. (expand_asan_emit_allocas_unpoison): Likewise. * cfgexpand.c (expand_main_function): Likewise. * config/aarch64/aarch64.c (aarch64_trampoline_init): Likewise. * config/aarch64/aarch64.h (PROFILE_HOOK): Likewise. * config/alpha/alpha.c (alpha_trampoline_init): Likewise. * config/arm/arm.c (arm_trampoline_init): Likewise. (arm_call_tls_get_addr): Likewise. (arm_expand_divmod_libfunc): Likewise. * config/bfin/bfin.md (umulsi3_highpart): Likewise. (smulsi3_highpart): Likewise. * config/c6x/c6x.c (c6x_initialize_trampoline): Likewise. (c6x_expand_compare): Likewise. (c6x_expand_movmem): Likewise. * config/frv/frv.c (frv_trampoline_init): Likewise. * config/i386/i386.c (ix86_trampoline_init): Likewise. (ix86_expand_divmod_libfunc): Likewise. * config/ia64/ia64.c (ia64_expand_tls_address): Likewise. (ia64_expand_compare): Likewise. (ia64_profile_hook): Likewise. * config/ia64/ia64.md (save_stack_nonlocal): Likewise. (nonlocal_goto): Likewise. (restore_stack_nonlocal): Likewise. * config/m32r/m32r.c (block_move_call): Likewise. (m32r_trampoline_init): Likewise. * config/m68k/linux.h (FINALIZE_TRAMPOLINE): Likewise. * config/m68k/m68k.c (m68k_call_tls_get_addr): Likewise. (m68k_call_m68k_read_tp): Likewise. * config/microblaze/microblaze.c (microblaze_call_tls_get_addr) (microblaze_expand_divide): Likewise. * config/mips/mips.h (mips_args): Likewise. * config/mips/sdemtk.h (mips_sync_icache): Likewise. (MIPS_ICACHE_SYNC): Likewise. * config/nios2/nios2.c (nios2_emit_expensive_div): Likewise. (nios2_trampoline_init): Likewise. * config/pa/pa.c (hppa_tls_call): Likewise. (pa_trampoline_init): Likewise. * config/pa/pa.md (canonicalize_funcptr_for_compare): Likewise. * config/powerpcspe/powerpcspe.c (rs6000_legitimize_tls_address) (expand_strn_compare): Likewise. (rs6000_generate_compare): Likewise. (rs6000_expand_float128_convert): Likewise. (output_profile_hook): Likewise. (rs6000_trampoline_init): Likewise. * config/powerpcspe/powerpcspe.md (neg<mode>2): Likewise. * config/riscv/riscv.h (PROFILE_HOOK): Likewise. * config/rs6000/rs6000-string.c (expand_strn_compare): Likewise. * config/rs6000/rs6000.c (rs6000_legitimize_tls_address): Likewise. (rs6000_generate_compare): Likewise. (rs6000_expand_float128_convert): Likewise. (output_profile_hook): Likewise. (rs6000_trampoline_init): Likewise. * config/rs6000/rs6000.md (neg<mode>2): Likewise. * config/sh/sh.c (sh_trampoline_init): Likewise. * config/sparc/sparc.c (emit_soft_tfmode_libcall): Likewise. (sparc_emit_float_lib_cmp): Likewise. (sparc32_initialize_trampoline): Likewise. (sparc64_initialize_trampoline): Likewise. (sparc_profile_hook): Likewise. * config/spu/spu.c (ea_load_store): Likewise. * config/spu/spu.md (floatunssidf2): Likewise. * config/tilegx/tilegx.c (tilegx_trampoline_init): Likewise. * config/tilepro/tilepro.c (tilepro_trampoline_init): Likewise. * config/visium/visium.c (expand_block_move_4): Likewise. (expand_block_move_2): Likewise. (expand_block_move_1): Likewise. (expand_block_set_4): Likewise. (expand_block_set_2): Likewise. (expand_block_set_1): Likewise. (visium_trampoline_init): Likewise. (visium_profile_hook): Likewise. * config/xtensa/xtensa.c (xtensa_expand_nonlocal_goto): Likewise. (xtensa_setup_frame_addresses): Likewise. (xtensa_trampoline_init): Likewise. * except.c (sjlj_emit_function_enter): Likewise. (sjlj_emit_function_exit): Likewise. * explow.c (allocate_dynamic_stack_space): Likewise. (probe_stack_range): Likewise. * expr.c (convert_mode_scalar): Likewise. * optabs.c (expand_binop): Likewise. (expand_twoval_binop_libfunc): Likewise. (expand_unop): Likewise. (prepare_cmp_insn): Likewise. (prepare_float_lib_cmp): Likewise. (expand_float): Likewise. (expand_fix): Likewise. (expand_fixed_convert): Likewise. (maybe_emit_sync_lock_test_and_set): Likewise. (expand_atomic_compare_and_swap): Likewise. (expand_mem_thread_fence): Likewise. (expand_atomic_fetch_op): Likewise. From-SVN: r251637
Diffstat (limited to 'gcc/calls.c')
-rw-r--r--gcc/calls.c70
1 files changed, 15 insertions, 55 deletions
diff --git a/gcc/calls.c b/gcc/calls.c
index 79b6e25..4b34ab2 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -164,8 +164,6 @@ static void compute_argument_addresses (struct arg_data *, rtx, int);
static rtx rtx_for_function_call (tree, tree);
static void load_register_parameters (struct arg_data *, int, rtx *, int,
int, int *);
-static rtx emit_library_call_value_1 (int, rtx, rtx, enum libcall_type,
- machine_mode, int, va_list);
static int special_function_p (const_tree, int);
static int check_sibcall_argument_overlap_1 (rtx);
static int check_sibcall_argument_overlap (rtx_insn *, struct arg_data *, int);
@@ -4364,14 +4362,21 @@ split_complex_types (tree types)
return types;
}
-/* Output a library call to function FUN (a SYMBOL_REF rtx).
- The RETVAL parameter specifies whether return value needs to be saved, other
- parameters are documented in the emit_library_call function below. */
+/* Output a library call to function ORGFUN (a SYMBOL_REF rtx)
+ for a value of mode OUTMODE,
+ with NARGS different arguments, passed as ARGS.
+ Store the return value if RETVAL is nonzero: store it in VALUE if
+ VALUE is nonnull, otherwise pick a convenient location. In either
+ case return the location of the stored value.
-static rtx
+ FN_TYPE should be LCT_NORMAL for `normal' calls, LCT_CONST for
+ `const' calls, LCT_PURE for `pure' calls, or another LCT_ value for
+ other types of library calls. */
+
+rtx
emit_library_call_value_1 (int retval, rtx orgfun, rtx value,
enum libcall_type fn_type,
- machine_mode outmode, int nargs, va_list p)
+ machine_mode outmode, int nargs, rtx_mode_t *args)
{
/* Total size in bytes of all the stack-parms scanned so far. */
struct args_size args_size;
@@ -4553,10 +4558,10 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value,
count++;
}
- for (; count < nargs; count++)
+ for (unsigned int i = 0; count < nargs; i++, count++)
{
- rtx val = va_arg (p, rtx);
- machine_mode mode = (machine_mode) va_arg (p, int);
+ rtx val = args[i].first;
+ machine_mode mode = args[i].second;
int unsigned_p = 0;
/* We cannot convert the arg value to the mode the library wants here;
@@ -5128,51 +5133,6 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value,
}
-/* Output a library call to function FUN (a SYMBOL_REF rtx)
- (emitting the queue unless NO_QUEUE is nonzero),
- for a value of mode OUTMODE,
- with NARGS different arguments, passed as alternating rtx values
- and machine_modes to convert them to.
-
- FN_TYPE should be LCT_NORMAL for `normal' calls, LCT_CONST for
- `const' calls, LCT_PURE for `pure' calls, or other LCT_ value for
- other types of library calls. */
-
-void
-emit_library_call (rtx orgfun, enum libcall_type fn_type,
- machine_mode outmode, int nargs, ...)
-{
- va_list p;
-
- va_start (p, nargs);
- emit_library_call_value_1 (0, orgfun, NULL_RTX, fn_type, outmode, nargs, p);
- va_end (p);
-}
-
-/* Like emit_library_call except that an extra argument, VALUE,
- comes second and says where to store the result.
- (If VALUE is zero, this function chooses a convenient way
- to return the value.
-
- This function returns an rtx for where the value is to be found.
- If VALUE is nonzero, VALUE is returned. */
-
-rtx
-emit_library_call_value (rtx orgfun, rtx value,
- enum libcall_type fn_type,
- machine_mode outmode, int nargs, ...)
-{
- rtx result;
- va_list p;
-
- va_start (p, nargs);
- result = emit_library_call_value_1 (1, orgfun, value, fn_type, outmode,
- nargs, p);
- va_end (p);
-
- return result;
-}
-
/* Store pointer bounds argument ARG into Bounds Table entry
associated with PARM. */