+2019-09-30 Richard Sandiford <richard.sandiford@arm.com>
+
+ * regrename.h (du_head::call_clobber_mask): New field.
+ (du_head::need_caller_save_reg): Replace with...
+ (du_head::call_abis): ...this new field.
+ * regrename.c: Include function-abi.h.
+ (call_clobbered_in_chain_p): New function.
+ (check_new_reg_p): Use crtl->abi when deciding whether a register
+ is free for use after RA. Use call_clobbered_in_chain_p to test
+ whether a candidate register would be clobbered by a call.
+ (find_rename_reg): Don't add call-clobber conflicts here.
+ (rename_chains): Check call_abis instead of need_caller_save_reg.
+ (merge_chains): Update for changes to du_head.
+ (build_def_use): Use insn_callee_abi to get the ABI of the call insn
+ target. Record the ABI identifier in call_abis and the set of
+ fully or partially clobbered registers in call_clobber_mask.
+ Add fully-clobbered registers to hard_conflicts here rather
+ than in find_rename_reg.
+ * config/aarch64/cortex-a57-fma-steering.c: Include function-abi.h.
+ (rename_single_chain): Check call_abis instead of need_caller_save_reg.
+ * config/aarch64/falkor-tag-collision-avoidance.c: Include
+ function-abi.h.
+ * config/c6x/c6x.c: Likewise.
+
2019-09-30 Richard Sandiford <richard.sandiford@arm.com>
* regcprop.c (copyprop_hardreg_forward_1): Use the recorded
#include "addresses.h"
#include "cfganal.h"
#include "tree-pass.h"
+#include "function-abi.h"
#include "regrename.h"
/* This file implements the RTL register renaming pass of the compiler. It is
}
}
+/* Return true if (reg:MODE REGNO) would be clobbered by a call covered
+ by THIS_HEAD. */
+
+static bool
+call_clobbered_in_chain_p (du_head *this_head, machine_mode mode,
+ unsigned int regno)
+{
+ return call_clobbered_in_region_p (this_head->call_abis,
+ this_head->call_clobber_mask,
+ mode, regno);
+}
+
/* Check if NEW_REG can be the candidate register to rename for
REG in THIS_HEAD chain. THIS_UNAVAILABLE is a set of unavailable hard
registers. */
|| global_regs[new_reg + i]
/* Can't use regs which aren't saved by the prologue. */
|| (! df_regs_ever_live_p (new_reg + i)
- && ! call_used_or_fixed_reg_p (new_reg + i))
+ && ! crtl->abi->clobbers_full_reg_p (new_reg + i))
#ifdef LEAF_REGISTERS
/* We can't use a non-leaf register if we're in a
leaf function. */
for (tmp = this_head->first; tmp; tmp = tmp->next_use)
if ((!targetm.hard_regno_mode_ok (new_reg, GET_MODE (*tmp->loc))
&& ! DEBUG_INSN_P (tmp->insn))
- || (this_head->need_caller_save_reg
- && ! (targetm.hard_regno_call_part_clobbered
- (0, reg, GET_MODE (*tmp->loc)))
- && (targetm.hard_regno_call_part_clobbered
- (0, new_reg, GET_MODE (*tmp->loc)))))
+ || call_clobbered_in_chain_p (this_head, GET_MODE (*tmp->loc),
+ new_reg))
return false;
return true;
int pass;
int best_new_reg = old_reg;
- /* Further narrow the set of registers we can use for renaming.
- If the chain needs a call-saved register, mark the call-used
- registers as unavailable. */
- if (this_head->need_caller_save_reg)
- *unavailable |= call_used_or_fixed_regs;
-
/* Mark registers that overlap this chain's lifetime as unavailable. */
merge_overlapping_regs (unavailable, this_head);
{
fprintf (dump_file, "Register %s in insn %d",
reg_names[reg], INSN_UID (this_head->first->insn));
- if (this_head->need_caller_save_reg)
+ if (this_head->call_abis)
fprintf (dump_file, " crosses a call");
}
c1->hard_conflicts |= c2->hard_conflicts;
bitmap_ior_into (&c1->conflicts, &c2->conflicts);
- c1->need_caller_save_reg |= c2->need_caller_save_reg;
+ c1->call_clobber_mask |= c2->call_clobber_mask;
+ c1->call_abis |= c2->call_abis;
c1->cannot_rename |= c2->cannot_rename;
}
requires a caller-saved reg. */
if (CALL_P (insn))
{
+ function_abi callee_abi = insn_callee_abi (insn);
class du_head *p;
for (p = open_chains; p; p = p->next_chain)
- p->need_caller_save_reg = 1;
+ {
+ p->call_abis |= (1 << callee_abi.id ());
+ p->call_clobber_mask
+ |= callee_abi.full_and_partial_reg_clobbers ();
+ p->hard_conflicts |= callee_abi.full_reg_clobbers ();
+ }
}
/* Step 5: Close open chains that overlap writes. Similar to
bitmap_head conflicts;
/* Conflicts with untracked hard registers. */
HARD_REG_SET hard_conflicts;
+ /* Which registers are fully or partially clobbered by the calls that
+ the chain crosses. */
+ HARD_REG_SET call_clobber_mask;
- /* Nonzero if the chain crosses a call. */
- unsigned int need_caller_save_reg:1;
+ /* A bitmask of ABIs used by the calls that the chain crosses. */
+ unsigned int call_abis : NUM_ABI_IDS;
/* Nonzero if the register is used in a way that prevents renaming,
such as the SET_DEST of a CALL_INSN or an asm operand that used
to be a hard register. */