mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-11 14:47:45 +08:00
tm.texi (REGISTER_MOVE_COST): Add a mode argument.
* tm.texi (REGISTER_MOVE_COST): Add a mode argument. * reload.c (REGISTER_MOVE_COST): Likewise. Adjust all callers. * reload1.c (REGISTER_MOVE_COST): Likewise. * regclass.c (REGISTER_MOVE_COST): Likewise. (move_cost, may_move_in_cost, may_move_out_cost): Add mode dimension. Adjust all users. (init_reg_sets_1): Iterate on all modes. * config/1750a/1750a.h (REGISTER_MOVE_COST): Adjust. * config/a29k/a29k.h (REGISTER_MOVE_COST): Adjust. * config/alpha/alpha.h (REGISTER_MOVE_COST): Adjust. * config/arc/arc.h (REGISTER_MOVE_COST): Adjust. * config/arm/arm.h (REGISTER_MOVE_COST): Adjust. * config/avr/avr.h (REGISTER_MOVE_COST): Adjust. * config/c4x/c4x.h (REGISTER_MOVE_COST): Adjust. * config/d30v/d30v.h (REGISTER_MOVE_COST): Adjust. * config/dsp16xx/dsp16xx.h (REGISTER_MOVE_COST): Adjust. * config/h8300/h8300.h (REGISTER_MOVE_COST): Adjust. * config/i386/i386.h (REGISTER_MOVE_COST): Adjust. * config/ia64/ia64.h (REGISTER_MOVE_COST): Adjust. * config/m32r/m32r.h (REGISTER_MOVE_COST): Adjust. * config/m68hc11/m68hc11.h (REGISTER_MOVE_COST): Adjust. * config/m68k/m68k.h (REGISTER_MOVE_COST): Adjust. * config/mcore/mcore.h (REGISTER_MOVE_COST): Adjust. * config/mips/mips.h (REGISTER_MOVE_COST): Adjust. * config/mn10200/mn10200.h (REGISTER_MOVE_COST): Adjust. * config/mn10300/mn10300.h (REGISTER_MOVE_COST): Adjust. * config/ns32k/ns32k.h (REGISTER_MOVE_COST): Adjust. * config/pa/pa.h (REGISTER_MOVE_COST): Adjust. * config/pdp11/pdp11.h (REGISTER_MOVE_COST): Adjust. * config/pj/pj.h (REGISTER_MOVE_COST): Adjust. * config/romp/romp.h (REGISTER_MOVE_COST): Adjust. * config/rs6000/rs6000.h (REGISTER_MOVE_COST): Adjust. * config/sh/sh.h (REGISTER_MOVE_COST): Adjust. * config/sparc/sparc.h (REGISTER_MOVE_COST): Adjust. From-SVN: r38604
This commit is contained in:
parent
5b1ef59457
commit
e56b459443
@ -1,6 +1,6 @@
|
||||
/* Compute register class preferences for pseudo-registers.
|
||||
Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996
|
||||
1997, 1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU CC.
|
||||
|
||||
@ -42,7 +42,7 @@ Boston, MA 02111-1307, USA. */
|
||||
#include "ggc.h"
|
||||
|
||||
#ifndef REGISTER_MOVE_COST
|
||||
#define REGISTER_MOVE_COST(x, y) 2
|
||||
#define REGISTER_MOVE_COST(m, x, y) 2
|
||||
#endif
|
||||
|
||||
static void init_reg_sets_1 PARAMS ((void));
|
||||
@ -177,17 +177,17 @@ enum machine_mode reg_raw_mode[FIRST_PSEUDO_REGISTER];
|
||||
/* Maximum cost of moving from a register in one class to a register in
|
||||
another class. Based on REGISTER_MOVE_COST. */
|
||||
|
||||
static int move_cost[N_REG_CLASSES][N_REG_CLASSES];
|
||||
static int move_cost[MAX_MACHINE_MODE][N_REG_CLASSES][N_REG_CLASSES];
|
||||
|
||||
/* Similar, but here we don't have to move if the first index is a subset
|
||||
of the second so in that case the cost is zero. */
|
||||
|
||||
static int may_move_in_cost[N_REG_CLASSES][N_REG_CLASSES];
|
||||
static int may_move_in_cost[MAX_MACHINE_MODE][N_REG_CLASSES][N_REG_CLASSES];
|
||||
|
||||
/* Similar, but here we don't have to move if the first index is a superset
|
||||
of the second so in that case the cost is zero. */
|
||||
|
||||
static int may_move_out_cost[N_REG_CLASSES][N_REG_CLASSES];
|
||||
static int may_move_out_cost[MAX_MACHINE_MODE][N_REG_CLASSES][N_REG_CLASSES];
|
||||
|
||||
#ifdef FORBIDDEN_INC_DEC_CLASSES
|
||||
|
||||
@ -287,6 +287,7 @@ static void
|
||||
init_reg_sets_1 ()
|
||||
{
|
||||
register unsigned int i, j;
|
||||
register unsigned int /* enum machine_mode */ m;
|
||||
|
||||
/* This macro allows the fixed or call-used registers
|
||||
and the register classes to depend on target flags. */
|
||||
@ -426,39 +427,40 @@ init_reg_sets_1 ()
|
||||
/* Initialize the move cost table. Find every subset of each class
|
||||
and take the maximum cost of moving any subset to any other. */
|
||||
|
||||
for (i = 0; i < N_REG_CLASSES; i++)
|
||||
for (j = 0; j < N_REG_CLASSES; j++)
|
||||
{
|
||||
int cost = i == j ? 2 : REGISTER_MOVE_COST (i, j);
|
||||
enum reg_class *p1, *p2;
|
||||
for (m = 0; m < MAX_MACHINE_MODE; m++)
|
||||
for (i = 0; i < N_REG_CLASSES; i++)
|
||||
for (j = 0; j < N_REG_CLASSES; j++)
|
||||
{
|
||||
int cost = i == j ? 2 : REGISTER_MOVE_COST (m, i, j);
|
||||
enum reg_class *p1, *p2;
|
||||
|
||||
for (p2 = ®_class_subclasses[j][0]; *p2 != LIM_REG_CLASSES; p2++)
|
||||
if (*p2 != i)
|
||||
cost = MAX (cost, REGISTER_MOVE_COST (i, *p2));
|
||||
for (p2 = ®_class_subclasses[j][0]; *p2 != LIM_REG_CLASSES; p2++)
|
||||
if (*p2 != i)
|
||||
cost = MAX (cost, REGISTER_MOVE_COST (m, i, *p2));
|
||||
|
||||
for (p1 = ®_class_subclasses[i][0]; *p1 != LIM_REG_CLASSES; p1++)
|
||||
{
|
||||
if (*p1 != j)
|
||||
cost = MAX (cost, REGISTER_MOVE_COST (*p1, j));
|
||||
for (p1 = ®_class_subclasses[i][0]; *p1 != LIM_REG_CLASSES; p1++)
|
||||
{
|
||||
if (*p1 != j)
|
||||
cost = MAX (cost, REGISTER_MOVE_COST (m, *p1, j));
|
||||
|
||||
for (p2 = ®_class_subclasses[j][0];
|
||||
*p2 != LIM_REG_CLASSES; p2++)
|
||||
if (*p1 != *p2)
|
||||
cost = MAX (cost, REGISTER_MOVE_COST (*p1, *p2));
|
||||
}
|
||||
for (p2 = ®_class_subclasses[j][0];
|
||||
*p2 != LIM_REG_CLASSES; p2++)
|
||||
if (*p1 != *p2)
|
||||
cost = MAX (cost, REGISTER_MOVE_COST (m, *p1, *p2));
|
||||
}
|
||||
|
||||
move_cost[i][j] = cost;
|
||||
move_cost[m][i][j] = cost;
|
||||
|
||||
if (reg_class_subset_p (i, j))
|
||||
may_move_in_cost[i][j] = 0;
|
||||
else
|
||||
may_move_in_cost[i][j] = cost;
|
||||
if (reg_class_subset_p (i, j))
|
||||
may_move_in_cost[m][i][j] = 0;
|
||||
else
|
||||
may_move_in_cost[m][i][j] = cost;
|
||||
|
||||
if (reg_class_subset_p (j, i))
|
||||
may_move_out_cost[i][j] = 0;
|
||||
else
|
||||
may_move_out_cost[i][j] = cost;
|
||||
}
|
||||
if (reg_class_subset_p (j, i))
|
||||
may_move_out_cost[m][i][j] = 0;
|
||||
else
|
||||
may_move_out_cost[m][i][j] = cost;
|
||||
}
|
||||
|
||||
#ifdef CLASS_CANNOT_CHANGE_MODE
|
||||
{
|
||||
@ -564,9 +566,9 @@ memory_move_secondary_cost (mode, class, in)
|
||||
return 0;
|
||||
|
||||
if (in)
|
||||
partial_cost = REGISTER_MOVE_COST (altclass, class);
|
||||
partial_cost = REGISTER_MOVE_COST (mode, altclass, class);
|
||||
else
|
||||
partial_cost = REGISTER_MOVE_COST (class, altclass);
|
||||
partial_cost = REGISTER_MOVE_COST (mode, class, altclass);
|
||||
|
||||
if (class == altclass)
|
||||
/* This isn't simply a copy-to-temporary situation. Can't guess
|
||||
@ -1403,10 +1405,10 @@ record_reg_classes (n_alts, n_ops, ops, modes,
|
||||
for (class = 0; class < N_REG_CLASSES; class++)
|
||||
pp->cost[class]
|
||||
= ((recog_data.operand_type[i] != OP_OUT
|
||||
? may_move_in_cost[class][(int) classes[i]]
|
||||
? may_move_in_cost[mode][class][(int) classes[i]]
|
||||
: 0)
|
||||
+ (recog_data.operand_type[i] != OP_IN
|
||||
? may_move_out_cost[(int) classes[i]][class]
|
||||
? may_move_out_cost[mode][(int) classes[i]][class]
|
||||
: 0));
|
||||
|
||||
/* If the alternative actually allows memory, make things
|
||||
@ -1428,7 +1430,8 @@ record_reg_classes (n_alts, n_ops, ops, modes,
|
||||
|
||||
if (reg_pref)
|
||||
alt_cost
|
||||
+= (may_move_in_cost[(unsigned char) reg_pref[REGNO (op)].prefclass]
|
||||
+= (may_move_in_cost[mode]
|
||||
[(unsigned char) reg_pref[REGNO (op)].prefclass]
|
||||
[(int) classes[i]]);
|
||||
|
||||
if (REGNO (ops[i]) != REGNO (ops[j])
|
||||
@ -1615,10 +1618,10 @@ record_reg_classes (n_alts, n_ops, ops, modes,
|
||||
for (class = 0; class < N_REG_CLASSES; class++)
|
||||
pp->cost[class]
|
||||
= ((recog_data.operand_type[i] != OP_OUT
|
||||
? may_move_in_cost[class][(int) classes[i]]
|
||||
? may_move_in_cost[mode][class][(int) classes[i]]
|
||||
: 0)
|
||||
+ (recog_data.operand_type[i] != OP_IN
|
||||
? may_move_out_cost[(int) classes[i]][class]
|
||||
? may_move_out_cost[mode][(int) classes[i]][class]
|
||||
: 0));
|
||||
|
||||
/* If the alternative actually allows memory, make things
|
||||
@ -1640,7 +1643,8 @@ record_reg_classes (n_alts, n_ops, ops, modes,
|
||||
|
||||
if (reg_pref)
|
||||
alt_cost
|
||||
+= (may_move_in_cost[(unsigned char) reg_pref[REGNO (op)].prefclass]
|
||||
+= (may_move_in_cost[mode]
|
||||
[(unsigned char) reg_pref[REGNO (op)].prefclass]
|
||||
[(int) classes[i]]);
|
||||
}
|
||||
}
|
||||
@ -1729,7 +1733,7 @@ record_reg_classes (n_alts, n_ops, ops, modes,
|
||||
|
||||
if ((reg_class_size[(unsigned char) pref]
|
||||
== CLASS_MAX_NREGS (pref, mode))
|
||||
&& REGISTER_MOVE_COST (pref, pref) < 10 * 2)
|
||||
&& REGISTER_MOVE_COST (mode, pref, pref) < 10 * 2)
|
||||
op_costs[i].cost[(unsigned char) pref] = -1;
|
||||
}
|
||||
else if (regno < FIRST_PSEUDO_REGISTER)
|
||||
@ -1797,7 +1801,7 @@ copy_cost (x, mode, class, to_p)
|
||||
#endif
|
||||
|
||||
if (secondary_class != NO_REGS)
|
||||
return (move_cost[(int) secondary_class][(int) class]
|
||||
return (move_cost[mode][(int) secondary_class][(int) class]
|
||||
+ copy_cost (x, mode, secondary_class, 2));
|
||||
#endif /* HAVE_SECONDARY_RELOADS */
|
||||
|
||||
@ -1809,7 +1813,7 @@ copy_cost (x, mode, class, to_p)
|
||||
return MEMORY_MOVE_COST (mode, class, to_p);
|
||||
|
||||
else if (GET_CODE (x) == REG)
|
||||
return move_cost[(int) REGNO_REG_CLASS (REGNO (x))][(int) class];
|
||||
return move_cost[mode][(int) REGNO_REG_CLASS (REGNO (x))][(int) class];
|
||||
|
||||
else
|
||||
/* If this is a constant, we may eventually want to call rtx_cost here. */
|
||||
@ -1986,7 +1990,7 @@ record_address_regs (x, class, scale)
|
||||
pp->mem_cost += (MEMORY_MOVE_COST (Pmode, class, 1) * scale) / 2;
|
||||
|
||||
for (i = 0; i < N_REG_CLASSES; i++)
|
||||
pp->cost[i] += (may_move_in_cost[i][(int) class] * scale) / 2;
|
||||
pp->cost[i] += (may_move_in_cost[Pmode][i][(int) class] * scale) / 2;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* Search an insn for pseudo regs that must be in hard regs and are not.
|
||||
Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
||||
1999, 2000 Free Software Foundation, Inc.
|
||||
1999, 2000, 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU CC.
|
||||
|
||||
@ -104,7 +104,7 @@ a register with any other reload. */
|
||||
#include "toplev.h"
|
||||
|
||||
#ifndef REGISTER_MOVE_COST
|
||||
#define REGISTER_MOVE_COST(x, y) 2
|
||||
#define REGISTER_MOVE_COST(m, x, y) 2
|
||||
#endif
|
||||
|
||||
#ifndef REGNO_MODE_OK_FOR_BASE_P
|
||||
@ -2467,7 +2467,8 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
|
||||
&& REGNO (SET_DEST (body)) < FIRST_PSEUDO_REGISTER
|
||||
&& GET_CODE (SET_SRC (body)) == REG
|
||||
&& REGNO (SET_SRC (body)) < FIRST_PSEUDO_REGISTER
|
||||
&& REGISTER_MOVE_COST (REGNO_REG_CLASS (REGNO (SET_SRC (body))),
|
||||
&& REGISTER_MOVE_COST (GET_MODE (SET_SRC (body)),
|
||||
REGNO_REG_CLASS (REGNO (SET_SRC (body))),
|
||||
REGNO_REG_CLASS (REGNO (SET_DEST (body)))) == 2)
|
||||
return 0;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* Reload pseudo regs into hard regs for insns that require hard regs.
|
||||
Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
||||
1999, 2000 Free Software Foundation, Inc.
|
||||
1999, 2000, 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU CC.
|
||||
|
||||
@ -81,7 +81,7 @@ Boston, MA 02111-1307, USA. */
|
||||
into the reload registers. */
|
||||
|
||||
#ifndef REGISTER_MOVE_COST
|
||||
#define REGISTER_MOVE_COST(x, y) 2
|
||||
#define REGISTER_MOVE_COST(m, x, y) 2
|
||||
#endif
|
||||
|
||||
#ifndef LOCAL_REGNO
|
||||
@ -5396,7 +5396,7 @@ choose_reload_regs (chain)
|
||||
register, we might use it for reload_override_in,
|
||||
if copying it to the desired class is cheap
|
||||
enough. */
|
||||
|| ((REGISTER_MOVE_COST (last_class, class)
|
||||
|| ((REGISTER_MOVE_COST (mode, last_class, class)
|
||||
< MEMORY_MOVE_COST (mode, class, 1))
|
||||
#ifdef SECONDARY_INPUT_RELOAD_CLASS
|
||||
&& (SECONDARY_INPUT_RELOAD_CLASS (class, mode,
|
||||
@ -6113,7 +6113,7 @@ emit_input_reload_insns (chain, rl, old, j)
|
||||
|
||||
if (oldequiv != 0
|
||||
&& ((REGNO_REG_CLASS (regno) != rl->class
|
||||
&& (REGISTER_MOVE_COST (REGNO_REG_CLASS (regno),
|
||||
&& (REGISTER_MOVE_COST (mode, REGNO_REG_CLASS (regno),
|
||||
rl->class)
|
||||
>= MEMORY_MOVE_COST (mode, rl->class, 1)))
|
||||
#ifdef SECONDARY_INPUT_RELOAD_CLASS
|
||||
@ -8106,7 +8106,8 @@ reload_cse_simplify_set (set, insn)
|
||||
else if (CONSTANT_P (src))
|
||||
old_cost = rtx_cost (src, SET);
|
||||
else if (GET_CODE (src) == REG)
|
||||
old_cost = REGISTER_MOVE_COST (REGNO_REG_CLASS (REGNO (src)), dclass);
|
||||
old_cost = REGISTER_MOVE_COST (GET_MODE (src),
|
||||
REGNO_REG_CLASS (REGNO (src)), dclass);
|
||||
else
|
||||
/* ??? */
|
||||
old_cost = rtx_cost (src, SET);
|
||||
@ -8120,7 +8121,8 @@ reload_cse_simplify_set (set, insn)
|
||||
if (CONSTANT_P (l->loc) && ! references_value_p (l->loc, 0))
|
||||
this_cost = rtx_cost (l->loc, SET);
|
||||
else if (GET_CODE (l->loc) == REG)
|
||||
this_cost = REGISTER_MOVE_COST (REGNO_REG_CLASS (REGNO (l->loc)),
|
||||
this_cost = REGISTER_MOVE_COST (GET_MODE (l->loc),
|
||||
REGNO_REG_CLASS (REGNO (l->loc)),
|
||||
dclass);
|
||||
else
|
||||
continue;
|
||||
|
13
gcc/tm.texi
13
gcc/tm.texi
@ -1,4 +1,4 @@
|
||||
@c Copyright (C) 1988,1989,1992,1993,1994,1995,1996,1997,1998,1999,2000
|
||||
@c Copyright (C) 1988,1989,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001
|
||||
@c Free Software Foundation, Inc.
|
||||
@c This is part of the GCC manual.
|
||||
@c For copying conditions, see the file gcc.texi.
|
||||
@ -4869,11 +4869,12 @@ This macro will normally either not be defined or be defined as a
|
||||
constant.
|
||||
|
||||
@findex REGISTER_MOVE_COST
|
||||
@item REGISTER_MOVE_COST (@var{from}, @var{to})
|
||||
A C expression for the cost of moving data from a register in class
|
||||
@var{from} to one in class @var{to}. The classes are expressed using
|
||||
the enumeration values such as @code{GENERAL_REGS}. A value of 2 is the
|
||||
default; other values are interpreted relative to that.
|
||||
@item REGISTER_MOVE_COST (@var{mode}, @var{from}, @var{to})
|
||||
A C expression for the cost of moving data of mode @var{mode} from a
|
||||
register in class @var{from} to one in class @var{to}. The classes are
|
||||
expressed using the enumeration values such as @code{GENERAL_REGS}. A
|
||||
value of 2 is the default; other values are interpreted relative to
|
||||
that.
|
||||
|
||||
It is not required that the cost always equal 2 when @var{from} is the
|
||||
same as @var{to}; on some machines it is expensive to move between
|
||||
|
Loading…
Reference in New Issue
Block a user