From db69559bac8ab03ccddfe3a42be630e65c277812 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Mon, 4 Sep 2017 07:30:53 +0000 Subject: 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 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 (neg2): 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 (neg2): 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 --- gcc/optabs.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'gcc/optabs.c') diff --git a/gcc/optabs.c b/gcc/optabs.c index 2c4de74..b7f1e2c 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -1759,7 +1759,7 @@ expand_binop (machine_mode mode, optab binoptab, rtx op0, rtx op1, /* Pass 1 for NO_QUEUE so we don't lose any increments if the libcall is cse'd or moved. */ value = emit_library_call_value (libfunc, - NULL_RTX, LCT_CONST, mode, 2, + NULL_RTX, LCT_CONST, mode, op0, mode, op1x, op1_mode); insns = get_insns (); @@ -2092,7 +2092,7 @@ expand_twoval_binop_libfunc (optab binoptab, rtx op0, rtx op1, libval_mode = smallest_int_mode_for_size (2 * GET_MODE_BITSIZE (mode)); start_sequence (); libval = emit_library_call_value (libfunc, NULL_RTX, LCT_CONST, - libval_mode, 2, + libval_mode, op0, mode, op1, mode); /* Get the part of VAL containing the value that we want. */ @@ -2966,7 +2966,7 @@ expand_unop (machine_mode mode, optab unoptab, rtx op0, rtx target, /* Pass 1 for NO_QUEUE so we don't lose any increments if the libcall is cse'd or moved. */ value = emit_library_call_value (libfunc, NULL_RTX, LCT_CONST, outmode, - 1, op0, mode); + op0, mode); insns = get_insns (); end_sequence (); @@ -3917,7 +3917,7 @@ prepare_cmp_insn (rtx x, rtx y, enum rtx_code comparison, rtx size, ret_mode = targetm.libgcc_cmp_return_mode (); result = emit_library_call_value (libfunc, NULL_RTX, LCT_CONST, - ret_mode, 2, x, mode, y, mode); + ret_mode, x, mode, y, mode); /* There are two kinds of comparison routines. Biased routines return 0/1/2, and unbiased routines return -1/0/1. Other parts @@ -4171,7 +4171,7 @@ prepare_float_lib_cmp (rtx x, rtx y, enum rtx_code comparison, start_sequence (); value = emit_library_call_value (libfunc, NULL_RTX, LCT_CONST, - cmp_mode, 2, x, mode, y, mode); + cmp_mode, x, mode, y, mode); insns = get_insns (); end_sequence (); @@ -4811,8 +4811,7 @@ expand_float (rtx to, rtx from, int unsignedp) start_sequence (); value = emit_library_call_value (libfunc, NULL_RTX, LCT_CONST, - GET_MODE (to), 1, from, - GET_MODE (from)); + GET_MODE (to), from, GET_MODE (from)); insns = get_insns (); end_sequence (); @@ -5004,8 +5003,7 @@ expand_fix (rtx to, rtx from, int unsignedp) start_sequence (); value = emit_library_call_value (libfunc, NULL_RTX, LCT_CONST, - GET_MODE (to), 1, from, - GET_MODE (from)); + GET_MODE (to), from, GET_MODE (from)); insns = get_insns (); end_sequence (); @@ -5097,7 +5095,7 @@ expand_fixed_convert (rtx to, rtx from, int uintp, int satp) start_sequence (); value = emit_library_call_value (libfunc, NULL_RTX, LCT_CONST, to_mode, - 1, from, from_mode); + from, from_mode); insns = get_insns (); end_sequence (); @@ -5944,7 +5942,7 @@ maybe_emit_sync_lock_test_and_set (rtx target, rtx mem, rtx val, addr = convert_memory_address (ptr_mode, XEXP (mem, 0)); return emit_library_call_value (libfunc, NULL_RTX, LCT_NORMAL, - mode, 2, addr, ptr_mode, + mode, addr, ptr_mode, val, mode); } } @@ -6252,7 +6250,7 @@ expand_atomic_compare_and_swap (rtx *ptarget_bool, rtx *ptarget_oval, { rtx addr = convert_memory_address (ptr_mode, XEXP (mem, 0)); rtx target = emit_library_call_value (libfunc, NULL_RTX, LCT_NORMAL, - mode, 3, addr, ptr_mode, + mode, addr, ptr_mode, expected, mode, desired, mode); emit_move_insn (target_oval, target); @@ -6313,7 +6311,7 @@ expand_mem_thread_fence (enum memmodel model) else if (targetm.have_memory_barrier ()) emit_insn (targetm.gen_memory_barrier ()); else if (synchronize_libfunc != NULL_RTX) - emit_library_call (synchronize_libfunc, LCT_NORMAL, VOIDmode, 0); + emit_library_call (synchronize_libfunc, LCT_NORMAL, VOIDmode); else expand_asm_memory_barrier (); } @@ -6813,7 +6811,7 @@ expand_atomic_fetch_op (rtx target, rtx mem, rtx val, enum rtx_code code, { rtx addr = convert_memory_address (ptr_mode, XEXP (mem, 0)); result = emit_library_call_value (libfunc, NULL, LCT_NORMAL, mode, - 2, addr, ptr_mode, val, mode); + addr, ptr_mode, val, mode); if (!unused_result && fixup) result = expand_simple_binop (mode, code, result, val, target, -- cgit v1.1