Commit 73bb8fe9 by Richard Sandiford Committed by Richard Sandiford

Use alternative_mask for add_insn_allocno_copies

add_insn_allocno_copies and its subroutines used HARD_REG_SET to
represent a bitmask of alternatives.  There's not really any connection
between the number of registers and the maximum number of alternatives,
so this patch uses alternative_mask instead (which wasn't around when
this code was added).

This is just a minor clean-up making way for later patches.

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

gcc/
	* ira-int.h (ira_setup_alts, ira_get_dup_out_num): Use
	alternative_mask instead of HARD_REG_SET to represent a
	bitmask of alternatives.
	* ira.c (ira_setup_alts, ira_get_dup_out_num): Likewise.
	* ira-conflicts.c (add_insn_allocno_copies): Likewise.

From-SVN: r272847
parent c53930bb
2019-07-01 Richard Sandiford <richard.sandiford@arm.com>
* ira-int.h (ira_setup_alts, ira_get_dup_out_num): Use
alternative_mask instead of HARD_REG_SET to represent a
bitmask of alternatives.
* ira.c (ira_setup_alts, ira_get_dup_out_num): Likewise.
* ira-conflicts.c (add_insn_allocno_copies): Likewise.
2019-07-01 Martin Liska <mliska@suse.cz> 2019-07-01 Martin Liska <mliska@suse.cz>
* edit-context.c (test_applying_fixits_unreadable_file): Do not * edit-context.c (test_applying_fixits_unreadable_file): Do not
......
...@@ -358,7 +358,7 @@ add_insn_allocno_copies (rtx_insn *insn) ...@@ -358,7 +358,7 @@ add_insn_allocno_copies (rtx_insn *insn)
rtx set, operand, dup; rtx set, operand, dup;
bool bound_p[MAX_RECOG_OPERANDS]; bool bound_p[MAX_RECOG_OPERANDS];
int i, n, freq; int i, n, freq;
HARD_REG_SET alts; alternative_mask alts;
freq = REG_FREQ_FROM_BB (BLOCK_FOR_INSN (insn)); freq = REG_FREQ_FROM_BB (BLOCK_FOR_INSN (insn));
if (freq == 0) if (freq == 0)
...@@ -379,7 +379,7 @@ add_insn_allocno_copies (rtx_insn *insn) ...@@ -379,7 +379,7 @@ add_insn_allocno_copies (rtx_insn *insn)
there are no dead registers, there will be no such copies. */ there are no dead registers, there will be no such copies. */
if (! find_reg_note (insn, REG_DEAD, NULL_RTX)) if (! find_reg_note (insn, REG_DEAD, NULL_RTX))
return; return;
ira_setup_alts (insn, alts); alts = ira_setup_alts (insn);
for (i = 0; i < recog_data.n_operands; i++) for (i = 0; i < recog_data.n_operands; i++)
bound_p[i] = false; bound_p[i] = false;
for (i = 0; i < recog_data.n_operands; i++) for (i = 0; i < recog_data.n_operands; i++)
......
...@@ -963,8 +963,8 @@ extern void ira_print_disposition (FILE *); ...@@ -963,8 +963,8 @@ extern void ira_print_disposition (FILE *);
extern void ira_debug_disposition (void); extern void ira_debug_disposition (void);
extern void ira_debug_allocno_classes (void); extern void ira_debug_allocno_classes (void);
extern void ira_init_register_move_cost (machine_mode); extern void ira_init_register_move_cost (machine_mode);
extern void ira_setup_alts (rtx_insn *insn, HARD_REG_SET &alts); extern alternative_mask ira_setup_alts (rtx_insn *);
extern int ira_get_dup_out_num (int op_num, HARD_REG_SET &alts); extern int ira_get_dup_out_num (int, alternative_mask);
/* ira-build.c */ /* ira-build.c */
......
...@@ -1784,9 +1784,12 @@ setup_prohibited_mode_move_regs (void) ...@@ -1784,9 +1784,12 @@ setup_prohibited_mode_move_regs (void)
/* Setup possible alternatives in ALTS for INSN. */ /* Extract INSN and return the set of alternatives that we should consider.
void This excludes any alternatives whose constraints are obviously impossible
ira_setup_alts (rtx_insn *insn, HARD_REG_SET &alts) to meet (e.g. because the constraint requires a constant and the operand
is nonconstant). */
alternative_mask
ira_setup_alts (rtx_insn *insn)
{ {
/* MAP nalt * nop -> start of constraints for given operand and /* MAP nalt * nop -> start of constraints for given operand and
alternative. */ alternative. */
...@@ -1798,7 +1801,7 @@ ira_setup_alts (rtx_insn *insn, HARD_REG_SET &alts) ...@@ -1798,7 +1801,7 @@ ira_setup_alts (rtx_insn *insn, HARD_REG_SET &alts)
extract_insn (insn); extract_insn (insn);
alternative_mask preferred = get_preferred_alternatives (insn); alternative_mask preferred = get_preferred_alternatives (insn);
CLEAR_HARD_REG_SET (alts); alternative_mask alts = 0;
insn_constraints.release (); insn_constraints.release ();
insn_constraints.safe_grow_cleared (recog_data.n_operands insn_constraints.safe_grow_cleared (recog_data.n_operands
* recog_data.n_alternatives + 1); * recog_data.n_alternatives + 1);
...@@ -1833,8 +1836,7 @@ ira_setup_alts (rtx_insn *insn, HARD_REG_SET &alts) ...@@ -1833,8 +1836,7 @@ ira_setup_alts (rtx_insn *insn, HARD_REG_SET &alts)
} }
for (nalt = 0; nalt < recog_data.n_alternatives; nalt++) for (nalt = 0; nalt < recog_data.n_alternatives; nalt++)
{ {
if (!TEST_BIT (preferred, nalt) if (!TEST_BIT (preferred, nalt) || TEST_BIT (alts, nalt))
|| TEST_HARD_REG_BIT (alts, nalt))
continue; continue;
for (nop = 0; nop < recog_data.n_operands; nop++) for (nop = 0; nop < recog_data.n_operands; nop++)
...@@ -1906,7 +1908,7 @@ ira_setup_alts (rtx_insn *insn, HARD_REG_SET &alts) ...@@ -1906,7 +1908,7 @@ ira_setup_alts (rtx_insn *insn, HARD_REG_SET &alts)
; ;
} }
if (nop >= recog_data.n_operands) if (nop >= recog_data.n_operands)
SET_HARD_REG_BIT (alts, nalt); alts |= ALTERNATIVE_BIT (nalt);
} }
if (commutative < 0) if (commutative < 0)
break; break;
...@@ -1916,6 +1918,7 @@ ira_setup_alts (rtx_insn *insn, HARD_REG_SET &alts) ...@@ -1916,6 +1918,7 @@ ira_setup_alts (rtx_insn *insn, HARD_REG_SET &alts)
if (curr_swapped) if (curr_swapped)
break; break;
} }
return alts;
} }
/* Return the number of the output non-early clobber operand which /* Return the number of the output non-early clobber operand which
...@@ -1923,7 +1926,7 @@ ira_setup_alts (rtx_insn *insn, HARD_REG_SET &alts) ...@@ -1923,7 +1926,7 @@ ira_setup_alts (rtx_insn *insn, HARD_REG_SET &alts)
negative value if there is no such operand). The function takes negative value if there is no such operand). The function takes
only really possible alternatives into consideration. */ only really possible alternatives into consideration. */
int int
ira_get_dup_out_num (int op_num, HARD_REG_SET &alts) ira_get_dup_out_num (int op_num, alternative_mask alts)
{ {
int curr_alt, c, original, dup; int curr_alt, c, original, dup;
bool ignore_p, use_commut_op_p; bool ignore_p, use_commut_op_p;
...@@ -1940,7 +1943,7 @@ ira_get_dup_out_num (int op_num, HARD_REG_SET &alts) ...@@ -1940,7 +1943,7 @@ ira_get_dup_out_num (int op_num, HARD_REG_SET &alts)
{ {
rtx op = recog_data.operand[op_num]; rtx op = recog_data.operand[op_num];
for (curr_alt = 0, ignore_p = !TEST_HARD_REG_BIT (alts, curr_alt), for (curr_alt = 0, ignore_p = !TEST_BIT (alts, curr_alt),
original = -1;;) original = -1;;)
{ {
c = *str; c = *str;
...@@ -1951,7 +1954,7 @@ ira_get_dup_out_num (int op_num, HARD_REG_SET &alts) ...@@ -1951,7 +1954,7 @@ ira_get_dup_out_num (int op_num, HARD_REG_SET &alts)
else if (c == ',') else if (c == ',')
{ {
curr_alt++; curr_alt++;
ignore_p = !TEST_HARD_REG_BIT (alts, curr_alt); ignore_p = !TEST_BIT (alts, curr_alt);
} }
else if (! ignore_p) else if (! ignore_p)
switch (c) switch (c)
......
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