Commit 06a65e80 by Richard Sandiford Committed by Richard Sandiford

Simplify ira_setup_alts

ira_setup_alts has its own code to calculate the start of the
constraint string for each operand/alternative combination,
but preprocess_constraints now provides that information in (almost)
constant time for non-asm instructions.  Using it here should speed
up the common case at the cost of potentially slowing down the handling
of asm statements.

The real reason for doing this is that a later patch wants to use
more of the operand_alternative information.

2019-07-01  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* ira.c (ira_setup_alts): Use preprocess_constraints to get the
	constraint string for each operand/alternative combo.  Only handle
	'%' at the start of constraint strings, and look for it outside
	the main loop.

From-SVN: r272848
parent 73bb8fe9
2019-07-01 Richard Sandiford <richard.sandiford@arm.com> 2019-07-01 Richard Sandiford <richard.sandiford@arm.com>
* ira.c (ira_setup_alts): Use preprocess_constraints to get the
constraint string for each operand/alternative combo. Only handle
'%' at the start of constraint strings, and look for it outside
the main loop.
2019-07-01 Richard Sandiford <richard.sandiford@arm.com>
* ira-int.h (ira_setup_alts, ira_get_dup_out_num): Use * ira-int.h (ira_setup_alts, ira_get_dup_out_num): Use
alternative_mask instead of HARD_REG_SET to represent a alternative_mask instead of HARD_REG_SET to represent a
bitmask of alternatives. bitmask of alternatives.
......
...@@ -1791,60 +1791,42 @@ setup_prohibited_mode_move_regs (void) ...@@ -1791,60 +1791,42 @@ setup_prohibited_mode_move_regs (void)
alternative_mask alternative_mask
ira_setup_alts (rtx_insn *insn) ira_setup_alts (rtx_insn *insn)
{ {
/* MAP nalt * nop -> start of constraints for given operand and
alternative. */
static vec<const char *> insn_constraints;
int nop, nalt; int nop, nalt;
bool curr_swapped; bool curr_swapped;
const char *p; const char *p;
int commutative = -1; int commutative = -1;
extract_insn (insn); extract_insn (insn);
preprocess_constraints (insn);
alternative_mask preferred = get_preferred_alternatives (insn); alternative_mask preferred = get_preferred_alternatives (insn);
alternative_mask alts = 0; alternative_mask alts = 0;
insn_constraints.release ();
insn_constraints.safe_grow_cleared (recog_data.n_operands
* recog_data.n_alternatives + 1);
/* Check that the hard reg set is enough for holding all /* Check that the hard reg set is enough for holding all
alternatives. It is hard to imagine the situation when the alternatives. It is hard to imagine the situation when the
assertion is wrong. */ assertion is wrong. */
ira_assert (recog_data.n_alternatives ira_assert (recog_data.n_alternatives
<= (int) MAX (sizeof (HARD_REG_ELT_TYPE) * CHAR_BIT, <= (int) MAX (sizeof (HARD_REG_ELT_TYPE) * CHAR_BIT,
FIRST_PSEUDO_REGISTER)); FIRST_PSEUDO_REGISTER));
for (nop = 0; nop < recog_data.n_operands; nop++)
if (recog_data.constraints[nop][0] == '%')
{
commutative = nop;
break;
}
for (curr_swapped = false;; curr_swapped = true) for (curr_swapped = false;; curr_swapped = true)
{ {
/* Calculate some data common for all alternatives to speed up the
function. */
for (nop = 0; nop < recog_data.n_operands; nop++)
{
for (nalt = 0, p = recog_data.constraints[nop];
nalt < recog_data.n_alternatives;
nalt++)
{
insn_constraints[nop * recog_data.n_alternatives + nalt] = p;
while (*p && *p != ',')
{
/* We only support one commutative marker, the first
one. We already set commutative above. */
if (*p == '%' && commutative < 0)
commutative = nop;
p++;
}
if (*p)
p++;
}
}
for (nalt = 0; nalt < recog_data.n_alternatives; nalt++) for (nalt = 0; nalt < recog_data.n_alternatives; nalt++)
{ {
if (!TEST_BIT (preferred, nalt) || TEST_BIT (alts, nalt)) if (!TEST_BIT (preferred, nalt) || TEST_BIT (alts, nalt))
continue; continue;
const operand_alternative *op_alt
= &recog_op_alt[nalt * recog_data.n_operands];
for (nop = 0; nop < recog_data.n_operands; nop++) for (nop = 0; nop < recog_data.n_operands; nop++)
{ {
int c, len; int c, len;
rtx op = recog_data.operand[nop]; rtx op = recog_data.operand[nop];
p = insn_constraints[nop * recog_data.n_alternatives + nalt]; p = op_alt[nop].constraint;
if (*p == 0 || *p == ',') if (*p == 0 || *p == ',')
continue; continue;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment