diff options
-rw-r--r-- | gcc/regclass.c | 92 | ||||
-rw-r--r-- | gcc/reload.c | 7 | ||||
-rw-r--r-- | gcc/reload1.c | 14 | ||||
-rw-r--r-- | gcc/tm.texi | 13 |
4 files changed, 67 insertions, 59 deletions
diff --git a/gcc/regclass.c b/gcc/regclass.c index 078bf9e..ca4cbd6 100644 --- a/gcc/regclass.c +++ b/gcc/regclass.c @@ -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; diff --git a/gcc/reload.c b/gcc/reload.c index 833ff50..7b9b669 100644 --- a/gcc/reload.c +++ b/gcc/reload.c @@ -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; diff --git a/gcc/reload1.c b/gcc/reload1.c index ee252a6..3a3dab0 100644 --- a/gcc/reload1.c +++ b/gcc/reload1.c @@ -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; diff --git a/gcc/tm.texi b/gcc/tm.texi index 511f8f0..893835d 100644 --- a/gcc/tm.texi +++ b/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 |