/* 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.
#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));
/* 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
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. */
/* 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
{
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
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
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])
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
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 ((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)
#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 */
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. */
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;
/* 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.
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
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,
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
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);
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;
-@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.
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