+2019-09-30 Richard Sandiford <richard.sandiford@arm.com>
+
+ * target.def (hard_regno_call_part_clobbered): Take an ABI
+ identifier instead of an rtx_insn.
+ * doc/tm.texi: Regenerate.
+ * hooks.h (hook_bool_insn_uint_mode_false): Delete.
+ (hook_bool_uint_uint_mode_false): New function.
+ * hooks.c (hook_bool_insn_uint_mode_false): Delete.
+ (hook_bool_uint_uint_mode_false): New function.
+ * config/aarch64/aarch64.c (aarch64_hard_regno_call_part_clobbered):
+ Take an ABI identifier instead of an rtx_insn.
+ * config/avr/avr.c (avr_hard_regno_call_part_clobbered): Likewise.
+ * config/i386/i386.c (ix86_hard_regno_call_part_clobbered): Likewise.
+ * config/mips/mips.c (mips_hard_regno_call_part_clobbered): Likewise.
+ * config/pru/pru.c (pru_hard_regno_call_part_clobbered): Likewise.
+ * config/rs6000/rs6000.c (rs6000_hard_regno_call_part_clobbered):
+ Likewise.
+ * config/s390/s390.c (s390_hard_regno_call_part_clobbered): Likewise.
+ * cselib.c: Include function-abi.h.
+ (cselib_process_insn): Update call to
+ targetm.hard_regno_call_part_clobbered, using insn_callee_abi
+ to get the appropriate ABI identifier.
+ * function-abi.cc (predefined_function_abi::initialize): Update call
+ to targetm.hard_regno_call_part_clobbered.
+ * ira-conflicts.c (ira_build_conflicts): Likewise.
+ * ira-costs.c (ira_tune_allocno_costs): Likewise.
+ * lra-constraints.c: Include function-abi.h.
+ (need_for_call_save_p): Update call to
+ targetm.hard_regno_call_part_clobbered, using insn_callee_abi
+ to get the appropriate ABI identifier.
+ * lra-lives.c (check_pseudos_live_through_calls): Likewise.
+ * regcprop.c (copyprop_hardreg_forward_1): Update call
+ to targetm.hard_regno_call_part_clobbered.
+ * reginfo.c (choose_hard_reg_mode): Likewise.
+ * regrename.c (check_new_reg_p): Likewise.
+ * reload.c (find_equiv_reg): Likewise.
+ * reload1.c (emit_reload_insns): Likewise.
+ * sched-deps.c: Include function-abi.h.
+ (deps_analyze_insn): Update call to
+ targetm.hard_regno_call_part_clobbered, using insn_callee_abi
+ to get the appropriate ABI identifier.
+ * sel-sched.c (init_regs_for_mode, mark_unavailable_hard_regs): Update
+ call to targetm.hard_regno_call_part_clobbered.
+ * targhooks.c (default_dwarf_frame_reg_mode): Likewise.
+
2019-09-30 Richard Sandiford <richard.sandiford@arm.com>
* config/i386/i386.c: Include function-abi.h.
clobbers the top 64 bits when restoring the bottom 64 bits. */
static bool
-aarch64_hard_regno_call_part_clobbered (rtx_insn *insn, unsigned int regno,
+aarch64_hard_regno_call_part_clobbered (unsigned int abi_id,
+ unsigned int regno,
machine_mode mode)
{
if (FP_REGNUM_P (regno))
{
- bool simd_p = insn && CALL_P (insn) && aarch64_simd_call_p (insn);
+ bool simd_p = (abi_id == ARM_PCS_SIMD);
poly_int64 per_register_size = GET_MODE_SIZE (mode);
unsigned int nregs = hard_regno_nregs (regno, mode);
if (nregs > 1)
/* Implement TARGET_HARD_REGNO_CALL_PART_CLOBBERED. */
static bool
-avr_hard_regno_call_part_clobbered (rtx_insn *insn ATTRIBUTE_UNUSED,
- unsigned regno, machine_mode mode)
+avr_hard_regno_call_part_clobbered (unsigned, unsigned regno,
+ machine_mode mode)
{
/* FIXME: This hook gets called with MODE:REGNO combinations that don't
represent valid hard registers like, e.g. HI:29. Returning TRUE
the low 16 bytes are saved. */
static bool
-ix86_hard_regno_call_part_clobbered (rtx_insn *insn ATTRIBUTE_UNUSED,
- unsigned int regno, machine_mode mode)
+ix86_hard_regno_call_part_clobbered (unsigned int, unsigned int regno,
+ machine_mode mode)
{
return SSE_REGNO_P (regno) && GET_MODE_SIZE (mode) > 16;
}
registers with MODE > 64 bits are part clobbered too. */
static bool
-mips_hard_regno_call_part_clobbered (rtx_insn *insn ATTRIBUTE_UNUSED,
- unsigned int regno, machine_mode mode)
+mips_hard_regno_call_part_clobbered (unsigned int, unsigned int regno,
+ machine_mode mode)
{
if (TARGET_FLOATXX
&& hard_regno_nregs (regno, mode) == 1
/* Implement TARGET_HARD_REGNO_CALL_PART_CLOBBERED. */
static bool
-pru_hard_regno_call_part_clobbered (rtx_insn *insn ATTRIBUTE_UNUSED,
- unsigned regno, machine_mode mode)
+pru_hard_regno_call_part_clobbered (unsigned, unsigned regno,
+ machine_mode mode)
{
HARD_REG_SET caller_saved_set;
HARD_REG_SET callee_saved_set;
/* Implement TARGET_HARD_REGNO_CALL_PART_CLOBBERED. */
static bool
-rs6000_hard_regno_call_part_clobbered (rtx_insn *insn ATTRIBUTE_UNUSED,
- unsigned int regno, machine_mode mode)
+rs6000_hard_regno_call_part_clobbered (unsigned int, unsigned int regno,
+ machine_mode mode)
{
if (TARGET_32BIT
&& TARGET_POWERPC64
bytes are saved across calls, however. */
static bool
-s390_hard_regno_call_part_clobbered (rtx_insn *insn ATTRIBUTE_UNUSED,
- unsigned int regno, machine_mode mode)
+s390_hard_regno_call_part_clobbered (unsigned int, unsigned int regno,
+ machine_mode mode)
{
if (!TARGET_64BIT
&& TARGET_ZARCH
#include "dumpfile.h"
#include "cselib.h"
#include "params.h"
+#include "function-abi.h"
/* A list of cselib_val structures. */
struct elt_list
memory. */
if (CALL_P (insn))
{
+ function_abi callee_abi = insn_callee_abi (insn);
for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
if (call_used_or_fixed_reg_p (i)
|| (REG_VALUES (i) && REG_VALUES (i)->elt
&& (targetm.hard_regno_call_part_clobbered
- (insn, i, GET_MODE (REG_VALUES (i)->elt->val_rtx)))))
+ (callee_abi.id (), i,
+ GET_MODE (REG_VALUES (i)->elt->val_rtx)))))
cselib_invalidate_regno (i, reg_raw_mode[i]);
/* Since it is not clear how cselib is going to be used, be
@cindex call-used register
@cindex call-clobbered register
@cindex call-saved register
-@deftypefn {Target Hook} bool TARGET_HARD_REGNO_CALL_PART_CLOBBERED (rtx_insn *@var{insn}, unsigned int @var{regno}, machine_mode @var{mode})
-This hook should return true if @var{regno} is partly call-saved and
-partly call-clobbered, and if a value of mode @var{mode} would be partly
-clobbered by call instruction @var{insn}. If @var{insn} is NULL then it
-should return true if any call could partly clobber the register.
-For example, if the low 32 bits of @var{regno} are preserved across a call
-but higher bits are clobbered, this hook should return true for a 64-bit
-mode but false for a 32-bit mode.
+@deftypefn {Target Hook} bool TARGET_HARD_REGNO_CALL_PART_CLOBBERED (unsigned int @var{abi_id}, unsigned int @var{regno}, machine_mode @var{mode})
+ABIs usually specify that calls must preserve the full contents
+of a particular register, or that calls can alter any part of a
+particular register. This information is captured by the target macro
+@code{CALL_REALLY_USED_REGISTERS}. However, some ABIs specify that calls
+must preserve certain bits of a particular register but can alter others.
+This hook should return true if this applies to at least one of the
+registers in @samp{(reg:@var{mode} @var{regno})}, and if as a result the
+call would alter part of the @var{mode} value. For example, if a call
+preserves the low 32 bits of a 64-bit hard register @var{regno} but can
+clobber the upper 32 bits, this hook should return true for a 64-bit mode
+but false for a 32-bit mode.
+
+The value of @var{abi_id} comes from the @code{predefined_function_abi}
+structure that describes the ABI of the call; see the definition of the
+structure for more details. If (as is usual) the target uses the same ABI
+for all functions in a translation unit, @var{abi_id} is always 0.
The default implementation returns false, which is correct
for targets that don't have partly call-clobbered registers.
If the ABI specifies that part of a hard register R is call-clobbered,
we should be able to find a single-register mode M for which
- targetm.hard_regno_call_part_clobbered (NULL, R, M) is true.
+ targetm.hard_regno_call_part_clobbered (m_id, R, M) is true.
In other words, it shouldn't be the case that R can hold all
single-register modes across a call, but can't hold part of
a multi-register mode.
for (unsigned int regno = 0; regno < FIRST_PSEUDO_REGISTER; ++regno)
if (targetm.hard_regno_mode_ok (regno, mode)
&& hard_regno_nregs (regno, mode) == 1
- && targetm.hard_regno_call_part_clobbered (NULL, regno, mode))
+ && targetm.hard_regno_call_part_clobbered (m_id, regno, mode))
SET_HARD_REG_BIT (m_full_and_partial_reg_clobbers, regno);
}
for (unsigned int regno = 0; regno < FIRST_PSEUDO_REGISTER; ++regno)
if (targetm.hard_regno_mode_ok (regno, mode)
&& !overlaps_hard_reg_set_p (m_full_reg_clobbers, mode, regno)
- && !targetm.hard_regno_call_part_clobbered (NULL, regno, mode))
+ && !targetm.hard_regno_call_part_clobbered (m_id, regno, mode))
remove_from_hard_reg_set (&m_mode_clobbers[i], mode, regno);
}
for (unsigned int regno = 0; regno < FIRST_PSEUDO_REGISTER; ++regno)
if (targetm.hard_regno_mode_ok (regno, mode)
&& !overlaps_hard_reg_set_p (m_full_reg_clobbers, mode, regno)
- && targetm.hard_regno_call_part_clobbered (NULL, regno, mode))
+ && targetm.hard_regno_call_part_clobbered (m_id, regno, mode))
gcc_assert (overlaps_hard_reg_set_p (all_clobbers, mode, regno)
&& overlaps_hard_reg_set_p (m_mode_clobbers[i],
mode, regno));
return true;
}
-/* Generic hook that takes (unsigned int, machine_mode) and returns false. */
bool
-hook_bool_insn_uint_mode_false (rtx_insn *, unsigned int, machine_mode)
+hook_bool_uint_uint_mode_false (unsigned int, unsigned int, machine_mode)
{
return false;
}
extern bool hook_bool_mode_uhwi_false (machine_mode,
unsigned HOST_WIDE_INT);
extern bool hook_bool_puint64_puint64_true (poly_uint64, poly_uint64);
-extern bool hook_bool_insn_uint_mode_false (rtx_insn *, unsigned int,
+extern bool hook_bool_uint_uint_mode_false (unsigned int, unsigned int,
machine_mode);
extern bool hook_bool_uint_mode_true (unsigned int, machine_mode);
extern bool hook_bool_tree_false (tree);
regs must conflict with them. */
for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
if (!TEST_HARD_REG_BIT (call_used_or_fixed_regs, regno)
- && targetm.hard_regno_call_part_clobbered (NULL, regno,
+ && targetm.hard_regno_call_part_clobbered (0, regno,
obj_mode))
{
SET_HARD_REG_BIT (OBJECT_CONFLICT_HARD_REGS (obj), regno);
*crossed_calls_clobber_regs)
&& (ira_hard_reg_set_intersection_p (regno, mode,
call_used_or_fixed_regs)
- || targetm.hard_regno_call_part_clobbered (NULL, regno,
+ || targetm.hard_regno_call_part_clobbered (0, regno,
mode)))
cost += (ALLOCNO_CALL_FREQ (a)
* (ira_memory_move_cost[mode][rclass][0]
#include "lra.h"
#include "lra-int.h"
#include "print-rtl.h"
+#include "function-abi.h"
/* Value of LRA_CURR_RELOAD_NUM at the beginning of BB of the current
insn. Remember that LRA_CURR_RELOAD_NUM is the number of emitted
: call_used_or_fixed_regs,
PSEUDO_REGNO_MODE (regno), reg_renumber[regno])
|| (targetm.hard_regno_call_part_clobbered
- (lra_reg_info[regno].call_insn,
+ (lra_reg_info[regno].call_insn
+ ? insn_callee_abi (lra_reg_info[regno].call_insn).id () : 0,
reg_renumber[regno], PSEUDO_REGNO_MODE (regno)))));
}
if (! sparseset_bit_p (pseudos_live_through_calls, regno))
return;
- gcc_assert (call_insn && CALL_P (call_insn));
+ function_abi callee_abi = insn_callee_abi (call_insn);
old_call_insn = lra_reg_info[regno].call_insn;
if (!old_call_insn
|| (targetm.return_call_with_max_clobbers
lra_reg_info[regno].conflict_hard_regs |= last_call_used_reg_set;
for (hr = 0; HARD_REGISTER_NUM_P (hr); hr++)
- if (targetm.hard_regno_call_part_clobbered (call_insn, hr,
+ if (targetm.hard_regno_call_part_clobbered (callee_abi.id (), hr,
PSEUDO_REGNO_MODE (regno)))
add_to_hard_reg_set (&lra_reg_info[regno].conflict_hard_regs,
PSEUDO_REGNO_MODE (regno), hr);
for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
if ((callee_abi.clobbers_full_reg_p (regno)
|| (targetm.hard_regno_call_part_clobbered
- (insn, regno, vd->e[regno].mode)))
+ (callee_abi.id (), regno, vd->e[regno].mode)))
&& (regno < set_regno || regno >= set_regno + set_nregs))
kill_value_regno (regno, 1, vd);
if (hard_regno_nregs (regno, mode) == nregs
&& targetm.hard_regno_mode_ok (regno, mode)
&& (!call_saved
- || !targetm.hard_regno_call_part_clobbered (NULL, regno, mode))
+ || !targetm.hard_regno_call_part_clobbered (0, regno, mode))
&& maybe_gt (GET_MODE_SIZE (mode), GET_MODE_SIZE (found_mode)))
found_mode = mode;
if (hard_regno_nregs (regno, mode) == nregs
&& targetm.hard_regno_mode_ok (regno, mode)
&& (!call_saved
- || !targetm.hard_regno_call_part_clobbered (NULL, regno, mode))
+ || !targetm.hard_regno_call_part_clobbered (0, regno, mode))
&& maybe_gt (GET_MODE_SIZE (mode), GET_MODE_SIZE (found_mode)))
found_mode = mode;
if (hard_regno_nregs (regno, mode) == nregs
&& targetm.hard_regno_mode_ok (regno, mode)
&& (!call_saved
- || !targetm.hard_regno_call_part_clobbered (NULL, regno, mode))
+ || !targetm.hard_regno_call_part_clobbered (0, regno, mode))
&& maybe_gt (GET_MODE_SIZE (mode), GET_MODE_SIZE (found_mode)))
found_mode = mode;
if (hard_regno_nregs (regno, mode) == nregs
&& targetm.hard_regno_mode_ok (regno, mode)
&& (!call_saved
- || !targetm.hard_regno_call_part_clobbered (NULL, regno, mode))
+ || !targetm.hard_regno_call_part_clobbered (0, regno, mode))
&& maybe_gt (GET_MODE_SIZE (mode), GET_MODE_SIZE (found_mode)))
found_mode = mode;
if (hard_regno_nregs (regno, mode) == nregs
&& targetm.hard_regno_mode_ok (regno, mode)
&& (!call_saved
- || !targetm.hard_regno_call_part_clobbered (NULL, regno, mode)))
+ || !targetm.hard_regno_call_part_clobbered (0, regno, mode)))
return mode;
}
&& ! DEBUG_INSN_P (tmp->insn))
|| (this_head->need_caller_save_reg
&& ! (targetm.hard_regno_call_part_clobbered
- (NULL, reg, GET_MODE (*tmp->loc)))
+ (0, reg, GET_MODE (*tmp->loc)))
&& (targetm.hard_regno_call_part_clobbered
- (NULL, new_reg, GET_MODE (*tmp->loc)))))
+ (0, new_reg, GET_MODE (*tmp->loc)))))
return false;
return true;
if (regno >= 0 && regno < FIRST_PSEUDO_REGISTER)
for (i = 0; i < nregs; ++i)
if (call_used_or_fixed_reg_p (regno + i)
- || targetm.hard_regno_call_part_clobbered (NULL, regno + i,
+ || targetm.hard_regno_call_part_clobbered (0, regno + i,
mode))
return 0;
if (valueno >= 0 && valueno < FIRST_PSEUDO_REGISTER)
for (i = 0; i < valuenregs; ++i)
if (call_used_or_fixed_reg_p (valueno + i)
- || targetm.hard_regno_call_part_clobbered (NULL, valueno + i,
+ || targetm.hard_regno_call_part_clobbered (0, valueno + i,
mode))
return 0;
}
: out_regno + k);
reg_reloaded_insn[regno + k] = insn;
SET_HARD_REG_BIT (reg_reloaded_valid, regno + k);
- if (targetm.hard_regno_call_part_clobbered (NULL,
- regno + k,
+ if (targetm.hard_regno_call_part_clobbered (0, regno + k,
mode))
SET_HARD_REG_BIT (reg_reloaded_call_part_clobbered,
regno + k);
: in_regno + k);
reg_reloaded_insn[regno + k] = insn;
SET_HARD_REG_BIT (reg_reloaded_valid, regno + k);
- if (targetm.hard_regno_call_part_clobbered (NULL,
- regno + k,
+ if (targetm.hard_regno_call_part_clobbered (0, regno + k,
mode))
SET_HARD_REG_BIT (reg_reloaded_call_part_clobbered,
regno + k);
CLEAR_HARD_REG_BIT (reg_reloaded_dead, src_regno + k);
SET_HARD_REG_BIT (reg_reloaded_valid, src_regno + k);
if (targetm.hard_regno_call_part_clobbered
- (NULL, src_regno + k, mode))
+ (0, src_regno + k, mode))
SET_HARD_REG_BIT (reg_reloaded_call_part_clobbered,
src_regno + k);
else
#include "sched-int.h"
#include "params.h"
#include "cselib.h"
+#include "function-abi.h"
#ifdef INSN_SCHEDULING
}
else
{
+ function_abi callee_abi = insn_callee_abi (insn);
for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
/* A call may read and modify global register variables. */
if (global_regs[i])
Since we only have a choice between 'might be clobbered'
and 'definitely not clobbered', we must include all
partly call-clobbered registers here. */
- else if (targetm.hard_regno_call_part_clobbered (insn, i,
- reg_raw_mode[i])
+ else if (targetm.hard_regno_call_part_clobbered
+ (callee_abi.id (), i, reg_raw_mode[i])
|| TEST_HARD_REG_BIT (regs_invalidated_by_call, i))
SET_REGNO_REG_SET (reg_pending_clobbers, i);
/* We don't know what set of fixed registers might be used
if (i >= 0)
continue;
- if (targetm.hard_regno_call_part_clobbered (NULL, cur_reg, mode))
+ if (targetm.hard_regno_call_part_clobbered (0, cur_reg, mode))
SET_HARD_REG_BIT (sel_hrd.regs_for_call_clobbered[mode],
cur_reg);
/* Exclude registers that are partially call clobbered. */
if (def->crosses_call
- && !targetm.hard_regno_call_part_clobbered (NULL, regno, mode))
+ && !targetm.hard_regno_call_part_clobbered (0, regno, mode))
reg_rename_p->available_for_renaming
&= ~sel_hrd.regs_for_call_clobbered[mode];
DEFHOOK
(hard_regno_call_part_clobbered,
- "This hook should return true if @var{regno} is partly call-saved and\n\
-partly call-clobbered, and if a value of mode @var{mode} would be partly\n\
-clobbered by call instruction @var{insn}. If @var{insn} is NULL then it\n\
-should return true if any call could partly clobber the register.\n\
-For example, if the low 32 bits of @var{regno} are preserved across a call\n\
-but higher bits are clobbered, this hook should return true for a 64-bit\n\
-mode but false for a 32-bit mode.\n\
+ "ABIs usually specify that calls must preserve the full contents\n\
+of a particular register, or that calls can alter any part of a\n\
+particular register. This information is captured by the target macro\n\
+@code{CALL_REALLY_USED_REGISTERS}. However, some ABIs specify that calls\n\
+must preserve certain bits of a particular register but can alter others.\n\
+This hook should return true if this applies to at least one of the\n\
+registers in @samp{(reg:@var{mode} @var{regno})}, and if as a result the\n\
+call would alter part of the @var{mode} value. For example, if a call\n\
+preserves the low 32 bits of a 64-bit hard register @var{regno} but can\n\
+clobber the upper 32 bits, this hook should return true for a 64-bit mode\n\
+but false for a 32-bit mode.\n\
+\n\
+The value of @var{abi_id} comes from the @code{predefined_function_abi}\n\
+structure that describes the ABI of the call; see the definition of the\n\
+structure for more details. If (as is usual) the target uses the same ABI\n\
+for all functions in a translation unit, @var{abi_id} is always 0.\n\
\n\
The default implementation returns false, which is correct\n\
for targets that don't have partly call-clobbered registers.",
- bool, (rtx_insn *insn, unsigned int regno, machine_mode mode),
- hook_bool_insn_uint_mode_false)
+ bool, (unsigned int abi_id, unsigned int regno, machine_mode mode),
+ hook_bool_uint_uint_mode_false)
DEFHOOK
(return_call_with_max_clobbers,
{
machine_mode save_mode = reg_raw_mode[regno];
- if (targetm.hard_regno_call_part_clobbered (NULL, regno, save_mode))
+ if (targetm.hard_regno_call_part_clobbered (0, regno, save_mode))
save_mode = choose_hard_reg_mode (regno, 1, true);
return save_mode;
}