aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2003-01-28 10:08:56 -0800
committerRichard Henderson <rth@gcc.gnu.org>2003-01-28 10:08:56 -0800
commitdcefdf6717c42e30b0058fe26780188ff5978821 (patch)
tree2f6fbc07999c9923c492e499429bdd22d90f295a
parentf2ce60b88d09c376e9862b78e5d37045b2e92351 (diff)
downloadgcc-dcefdf6717c42e30b0058fe26780188ff5978821.zip
gcc-dcefdf6717c42e30b0058fe26780188ff5978821.tar.gz
gcc-dcefdf6717c42e30b0058fe26780188ff5978821.tar.bz2
target.h (targetm.address_cost): New.
* target.h (targetm.address_cost): New. * target-def.h (TARGET_ADDRESS_COST): New. (TARGET_RTX_COSTS): Uncomment. Oops. * cse.c (address_cost): Use new target hook. (default_address_cost): New. * output.h (default_address_cost): Declare. * hooks.c (hook_int_rtx_0): New. * hooks.h (hook_int_rtx_0): Declare. * loop.c (combine_givs_p): Remove if 0 code. * system.h (ADDRESS_COST): Poison. * config/alpha/alpha.c, config/alpha/alpha.h, config/d30v/d30v.c, config/d30v/d30v.h, config/ia64/ia64.c, config/ia64/ia64.h, config/m32r/m32r.c, config/m32r/m32r.h, config/mcore/mcore.c, config/mcore/mcore.h, config/mmix/mmix.c, config/mmix/mmix.h, config/rs6000/rs6000.c, config/rs6000/rs6000.h, config/sparc/sparc.c, config/sparc/sparc.h, config/v850/v850.c, config/v850/v850.h, config/xtensa/xtensa.c, config/xtensa/xtensa.h (TARGET_ADDRESS_COST): Define as hook_int_rtx_0. (ADDRESS_COST): Remove. * config/arc/arc-protos.h, config/arc/arc.c, config/arc/arc.h, config/avr/avr-protos.h, config/avr/avr.c, config/avr/avr.h, config/c4x/c4x-protos.h, config/c4x/c4x.c, config/c4x/c4x.h, config/dsp16xx/dsp16xx-protos.h, config/dsp16xx/dsp16xx.c, config/dsp16xx/dsp16xx.h, config/i386/i386-protos.h, config/i386/i386.c, config/i386/i386.h, config/i960/i960-protos.h, config/i960/i960.c, config/i960/i960.h, config/ip2k/ip2k-protos.h, config/ip2k/ip2k.c, config/ip2k/ip2k.h, config/mips/mips-protos.h, config/mips/mips.c, config/mips/mips.h, config/m68hc11/m68hc11-protos.h, config/m68hc11/m68hc11.c, config/m68hc11/m68hc11.h, config/ns32k/ns32k-protos.h, config/ns32k/ns32k.c, config/ns32k/ns32k.h, config/pa/pa-protos.h, config/pa/pa.c, config/pa/pa.h, config/s390/s390-protos.h, config/s390/s390.c, config/s390/s390.h, config/vax/vax-protos.h, config/vax/vax.c, config/vax/vax.h (foo_address_cost): Make static. (TARGET_ADDRESS_COST): New. (ADDRESS_COST): Remove. * config/arm/arm.h, config/arm/arm.c, config/m88k/m88k.h, config/m88k/m88k.c, config/romp/romp.h, config/romp/romp.c, config/sh/sh.c, config/sh/sh.h, config/stormy16/stormy16.c, config/stormy16/stormy16.h (ADDRESS_COST): Move code ... (foo_address_cost): ... here. (TARGET_ADDRESS_COST): New. * config/m32r/m32r.c (m32r_address_cost): Remove. * config/m32r/m32r-protos.h: Update. * config/mmix/mmix.c (mmix_address_cost): Remove. * config/mmix/mmix-protos.h: Update. * config/mn10300/mn10300.c (mn10300_address_cost_1): Rename from mn10300_address_cost; move unsig allocation ... (mn10300_address_cost): ... here. (TARGET_ADDRESS_COST): New. * config/mn10300/mn10300-protos.h: Update. * config/mn10300/mn10300.h (ADDRESS_COST): Remove. From-SVN: r61988
-rw-r--r--gcc/ChangeLog63
-rw-r--r--gcc/config/alpha/alpha.c2
-rw-r--r--gcc/config/alpha/alpha.h5
-rw-r--r--gcc/config/arc/arc-protos.h1
-rw-r--r--gcc/config/arc/arc.c124
-rw-r--r--gcc/config/arc/arc.h3
-rw-r--r--gcc/config/arm/arm.c37
-rw-r--r--gcc/config/arm/arm.h29
-rw-r--r--gcc/config/avr/avr-protos.h1
-rw-r--r--gcc/config/avr/avr.c5
-rw-r--r--gcc/config/avr/avr.h43
-rw-r--r--gcc/config/c4x/c4x-protos.h2
-rw-r--r--gcc/config/c4x/c4x.c5
-rw-r--r--gcc/config/c4x/c4x.h7
-rw-r--r--gcc/config/d30v/d30v.c2
-rw-r--r--gcc/config/d30v/d30v.h39
-rw-r--r--gcc/config/dsp16xx/dsp16xx-protos.h1
-rw-r--r--gcc/config/dsp16xx/dsp16xx.c5
-rw-r--r--gcc/config/dsp16xx/dsp16xx.h4
-rw-r--r--gcc/config/i386/i386-protos.h1
-rw-r--r--gcc/config/i386/i386.c5
-rw-r--r--gcc/config/i386/i386.h49
-rw-r--r--gcc/config/i960/i960-protos.h1
-rw-r--r--gcc/config/i960/i960.c9
-rw-r--r--gcc/config/i960/i960.h6
-rw-r--r--gcc/config/ia64/ia64.c2
-rw-r--r--gcc/config/ia64/ia64.h6
-rw-r--r--gcc/config/ip2k/ip2k-protos.h1
-rw-r--r--gcc/config/ip2k/ip2k.c5
-rw-r--r--gcc/config/ip2k/ip2k.h43
-rw-r--r--gcc/config/m32r/m32r-protos.h1
-rw-r--r--gcc/config/m32r/m32r.c15
-rw-r--r--gcc/config/m32r/m32r.h3
-rw-r--r--gcc/config/m68hc11/m68hc11-protos.h2
-rw-r--r--gcc/config/m68hc11/m68hc11.c5
-rw-r--r--gcc/config/m68hc11/m68hc11.h5
-rw-r--r--gcc/config/m88k/m88k.c26
-rw-r--r--gcc/config/m88k/m88k.h12
-rw-r--r--gcc/config/mcore/mcore.c2
-rw-r--r--gcc/config/mcore/mcore.h4
-rw-r--r--gcc/config/mips/mips-protos.h1
-rw-r--r--gcc/config/mips/mips.c8
-rw-r--r--gcc/config/mips/mips.h44
-rw-r--r--gcc/config/mmix/mmix-protos.h1
-rw-r--r--gcc/config/mmix/mmix.c14
-rw-r--r--gcc/config/mmix/mmix.h2
-rw-r--r--gcc/config/mn10300/mn10300-protos.h2
-rw-r--r--gcc/config/mn10300/mn10300.c30
-rw-r--r--gcc/config/mn10300/mn10300.h2
-rw-r--r--gcc/config/ns32k/ns32k-protos.h1
-rw-r--r--gcc/config/ns32k/ns32k.c32
-rw-r--r--gcc/config/ns32k/ns32k.h5
-rw-r--r--gcc/config/pa/pa-protos.h1
-rw-r--r--gcc/config/pa/pa.c22
-rw-r--r--gcc/config/pa/pa.h3
-rw-r--r--gcc/config/romp/romp.c23
-rw-r--r--gcc/config/romp/romp.h23
-rw-r--r--gcc/config/rs6000/rs6000.c2
-rw-r--r--gcc/config/rs6000/rs6000.h12
-rw-r--r--gcc/config/s390/s390-protos.h1
-rw-r--r--gcc/config/s390/s390.c5
-rw-r--r--gcc/config/s390/s390.h5
-rw-r--r--gcc/config/sh/sh.c15
-rw-r--r--gcc/config/sh/sh.h8
-rw-r--r--gcc/config/sparc/sparc.c2
-rw-r--r--gcc/config/sparc/sparc.h2
-rw-r--r--gcc/config/stormy16/stormy16.c11
-rw-r--r--gcc/config/stormy16/stormy16.h43
-rw-r--r--gcc/config/v850/v850.c2
-rw-r--r--gcc/config/v850/v850.h3
-rw-r--r--gcc/config/vax/vax-protos.h2
-rw-r--r--gcc/config/vax/vax.c19
-rw-r--r--gcc/config/vax/vax.h2
-rw-r--r--gcc/config/xtensa/xtensa.c2
-rw-r--r--gcc/config/xtensa/xtensa.h4
-rw-r--r--gcc/cse.c19
-rw-r--r--gcc/hooks.c7
-rw-r--r--gcc/hooks.h1
-rw-r--r--gcc/loop.c17
-rw-r--r--gcc/output.h2
-rw-r--r--gcc/system.h3
-rw-r--r--gcc/target-def.h8
-rw-r--r--gcc/target.h4
83 files changed, 402 insertions, 594 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d2673bb..808a3af 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,66 @@
+2003-01-28 Richard Henderson <rth@redhat.com>
+
+ * target.h (targetm.address_cost): New.
+ * target-def.h (TARGET_ADDRESS_COST): New.
+ (TARGET_RTX_COSTS): Uncomment. Oops.
+ * cse.c (address_cost): Use new target hook.
+ (default_address_cost): New.
+ * output.h (default_address_cost): Declare.
+ * hooks.c (hook_int_rtx_0): New.
+ * hooks.h (hook_int_rtx_0): Declare.
+ * loop.c (combine_givs_p): Remove if 0 code.
+ * system.h (ADDRESS_COST): Poison.
+
+ * config/alpha/alpha.c, config/alpha/alpha.h, config/d30v/d30v.c,
+ config/d30v/d30v.h, config/ia64/ia64.c, config/ia64/ia64.h,
+ config/m32r/m32r.c, config/m32r/m32r.h, config/mcore/mcore.c,
+ config/mcore/mcore.h, config/mmix/mmix.c, config/mmix/mmix.h,
+ config/rs6000/rs6000.c, config/rs6000/rs6000.h, config/sparc/sparc.c,
+ config/sparc/sparc.h, config/v850/v850.c, config/v850/v850.h,
+ config/xtensa/xtensa.c, config/xtensa/xtensa.h
+ (TARGET_ADDRESS_COST): Define as hook_int_rtx_0.
+ (ADDRESS_COST): Remove.
+
+ * config/arc/arc-protos.h, config/arc/arc.c, config/arc/arc.h,
+ config/avr/avr-protos.h, config/avr/avr.c, config/avr/avr.h,
+ config/c4x/c4x-protos.h, config/c4x/c4x.c, config/c4x/c4x.h,
+ config/dsp16xx/dsp16xx-protos.h, config/dsp16xx/dsp16xx.c,
+ config/dsp16xx/dsp16xx.h, config/i386/i386-protos.h,
+ config/i386/i386.c, config/i386/i386.h, config/i960/i960-protos.h,
+ config/i960/i960.c, config/i960/i960.h, config/ip2k/ip2k-protos.h,
+ config/ip2k/ip2k.c, config/ip2k/ip2k.h, config/mips/mips-protos.h,
+ config/mips/mips.c, config/mips/mips.h,
+ config/m68hc11/m68hc11-protos.h, config/m68hc11/m68hc11.c,
+ config/m68hc11/m68hc11.h, config/ns32k/ns32k-protos.h,
+ config/ns32k/ns32k.c, config/ns32k/ns32k.h, config/pa/pa-protos.h,
+ config/pa/pa.c, config/pa/pa.h, config/s390/s390-protos.h,
+ config/s390/s390.c, config/s390/s390.h, config/vax/vax-protos.h,
+ config/vax/vax.c, config/vax/vax.h
+ (foo_address_cost): Make static.
+ (TARGET_ADDRESS_COST): New.
+ (ADDRESS_COST): Remove.
+
+ * config/arm/arm.h, config/arm/arm.c, config/m88k/m88k.h,
+ config/m88k/m88k.c, config/romp/romp.h, config/romp/romp.c,
+ config/sh/sh.c, config/sh/sh.h, config/stormy16/stormy16.c,
+ config/stormy16/stormy16.h
+ (ADDRESS_COST): Move code ...
+ (foo_address_cost): ... here.
+ (TARGET_ADDRESS_COST): New.
+
+ * config/m32r/m32r.c (m32r_address_cost): Remove.
+ * config/m32r/m32r-protos.h: Update.
+
+ * config/mmix/mmix.c (mmix_address_cost): Remove.
+ * config/mmix/mmix-protos.h: Update.
+
+ * config/mn10300/mn10300.c (mn10300_address_cost_1): Rename from
+ mn10300_address_cost; move unsig allocation ...
+ (mn10300_address_cost): ... here.
+ (TARGET_ADDRESS_COST): New.
+ * config/mn10300/mn10300-protos.h: Update.
+ * config/mn10300/mn10300.h (ADDRESS_COST): Remove.
+
2003-01-28 Vladimir Makarov <vmakarov@redhat.com>
* haifa-sched.c (schedule_insn): Return necessary cycle advance
diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c
index d10396e..4e4de75 100644
--- a/gcc/config/alpha/alpha.c
+++ b/gcc/config/alpha/alpha.c
@@ -371,6 +371,8 @@ static void unicosmk_unique_section PARAMS ((tree, int));
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS alpha_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST hook_int_rtx_0
struct gcc_target targetm = TARGET_INITIALIZER;
diff --git a/gcc/config/alpha/alpha.h b/gcc/config/alpha/alpha.h
index ae28dd2..0522ba6 100644
--- a/gcc/config/alpha/alpha.h
+++ b/gcc/config/alpha/alpha.h
@@ -1416,11 +1416,6 @@ do { \
#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \
{ if (GET_CODE (ADDR) == AND) goto LABEL; }
-/* Compute the cost of an address. For the Alpha, all valid addresses are
- the same cost. */
-
-#define ADDRESS_COST(X) 0
-
/* Machine-dependent reorg pass. */
#define MACHINE_DEPENDENT_REORG(X) alpha_reorg(X)
diff --git a/gcc/config/arc/arc-protos.h b/gcc/config/arc/arc-protos.h
index cbb8ac2..717845e 100644
--- a/gcc/config/arc/arc-protos.h
+++ b/gcc/config/arc/arc-protos.h
@@ -34,7 +34,6 @@ extern const char *output_shift PARAMS ((rtx *));
extern int symbolic_operand PARAMS ((rtx, enum machine_mode));
extern int arc_double_limm_p PARAMS ((rtx));
-extern int arc_address_cost PARAMS ((rtx));
extern int arc_eligible_for_epilogue_delay PARAMS ((rtx, int));
extern void arc_initialize_trampoline PARAMS ((rtx, rtx, rtx));
extern void arc_print_operand PARAMS ((FILE *, rtx, int));
diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
index 2048bd3..bd2afc0 100644
--- a/gcc/config/arc/arc.c
+++ b/gcc/config/arc/arc.c
@@ -97,6 +97,7 @@ static void arc_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT));
static void arc_encode_section_info PARAMS ((tree, int));
static void arc_internal_label PARAMS ((FILE *, const char *, unsigned long));
static bool arc_rtx_costs PARAMS ((rtx, int, int, int *));
+static int arc_address_cost PARAMS ((rtx));
/* Initialize the GCC target structure. */
#undef TARGET_ASM_ALIGNED_HI_OP
@@ -119,6 +120,8 @@ static bool arc_rtx_costs PARAMS ((rtx, int, int, int *));
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS arc_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST arc_address_cost
struct gcc_target targetm = TARGET_INITIALIZER;
@@ -842,18 +845,75 @@ arc_setup_incoming_varargs (cum, mode, type, pretend_size, no_rtl)
/* Cost functions. */
+/* Compute a (partial) cost for rtx X. Return true if the complete
+ cost has been computed, and false if subexpressions should be
+ scanned. In either case, *TOTAL contains the cost result. */
+
+static bool
+arc_rtx_costs (x, code, outer_code, total)
+ rtx x;
+ int code;
+ int outer_code ATTRIBUTE_UNUSED;
+ int *total;
+{
+ switch (code)
+ {
+ /* Small integers are as cheap as registers. 4 byte values can
+ be fetched as immediate constants - let's give that the cost
+ of an extra insn. */
+ case CONST_INT:
+ if (SMALL_INT (INTVAL (x)))
+ {
+ *total = 0;
+ return true;
+ }
+ /* FALLTHRU */
+
+ case CONST:
+ case LABEL_REF:
+ case SYMBOL_REF:
+ *total = COSTS_N_INSNS (1);
+ return true;
+
+ case CONST_DOUBLE:
+ {
+ rtx high, low;
+ split_double (x, &high, &low);
+ *total = COSTS_N_INSNS (!SMALL_INT (INTVAL (high))
+ + !SMALL_INT (INTVAL (low)));
+ return true;
+ }
+
+ /* Encourage synth_mult to find a synthetic multiply when reasonable.
+ If we need more than 12 insns to do a multiply, then go out-of-line,
+ since the call overhead will be < 10% of the cost of the multiply. */
+ case ASHIFT:
+ case ASHIFTRT:
+ case LSHIFTRT:
+ if (TARGET_SHIFTER)
+ *total = COSTS_N_INSNS (1);
+ else if (GET_CODE (XEXP (x, 1)) != CONST_INT)
+ *total = COSTS_N_INSNS (16);
+ else
+ *total = COSTS_N_INSNS (INTVAL (XEXP ((x), 1)));
+ return false;
+
+ default:
+ return false;
+ }
+}
+
+
/* Provide the costs of an addressing mode that contains ADDR.
If ADDR is not a valid address, its cost is irrelevant. */
-int
+static int
arc_address_cost (addr)
rtx addr;
{
switch (GET_CODE (addr))
{
case REG :
- /* This is handled in the macro that calls us.
- It's here for documentation. */
return 1;
case LABEL_REF :
@@ -2380,61 +2440,3 @@ arc_internal_label (stream, prefix, labelno)
arc_ccfsm_at_label (prefix, labelno);
default_internal_label (stream, prefix, labelno);
}
-
-/* Compute a (partial) cost for rtx X. Return true if the complete
- cost has been computed, and false if subexpressions should be
- scanned. In either case, *TOTAL contains the cost result. */
-
-static bool
-arc_rtx_costs (x, code, outer_code, total)
- rtx x;
- int code;
- int outer_code ATTRIBUTE_UNUSED;
- int *total;
-{
- switch (code)
- {
- /* Small integers are as cheap as registers. 4 byte values can
- be fetched as immediate constants - let's give that the cost
- of an extra insn. */
- case CONST_INT:
- if (SMALL_INT (INTVAL (x)))
- {
- *total = 0;
- return true;
- }
- /* FALLTHRU */
-
- case CONST:
- case LABEL_REF:
- case SYMBOL_REF:
- *total = COSTS_N_INSNS (1);
- return true;
-
- case CONST_DOUBLE:
- {
- rtx high, low;
- split_double (x, &high, &low);
- *total = COSTS_N_INSNS (!SMALL_INT (INTVAL (high))
- + !SMALL_INT (INTVAL (low)));
- return true;
- }
-
- /* Encourage synth_mult to find a synthetic multiply when reasonable.
- If we need more than 12 insns to do a multiply, then go out-of-line,
- since the call overhead will be < 10% of the cost of the multiply. */
- case ASHIFT:
- case ASHIFTRT:
- case LSHIFTRT:
- if (TARGET_SHIFTER)
- *total = COSTS_N_INSNS (1);
- else if (GET_CODE (XEXP (x, 1)) != CONST_INT)
- *total = COSTS_N_INSNS (16);
- else
- *total = COSTS_N_INSNS (INTVAL (XEXP ((x), 1)));
- return false;
-
- default:
- return false;
- }
-}
diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h
index 4d7b633..583398c 100644
--- a/gcc/config/arc/arc.h
+++ b/gcc/config/arc/arc.h
@@ -995,9 +995,6 @@ arc_select_cc_mode (OP, X, Y)
/* Costs. */
-/* Compute the cost of an address. */
-#define ADDRESS_COST(ADDR) (REG_P (ADDR) ? 1 : arc_address_cost (ADDR))
-
/* Compute extra cost of moving data between one register class
and another. */
#define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2) 2
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 5bbe6ac..427f68e 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -143,6 +143,7 @@ static void arm_output_mi_thunk PARAMS ((FILE *, tree,
static int arm_rtx_costs_1 PARAMS ((rtx, enum rtx_code,
enum rtx_code));
static bool arm_rtx_costs PARAMS ((rtx, int, int, int*));
+static int arm_address_cost PARAMS ((rtx));
#undef Hint
#undef Mmode
@@ -218,6 +219,8 @@ static bool arm_rtx_costs PARAMS ((rtx, int, int, int*));
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS arm_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST arm_address_cost
struct gcc_target targetm = TARGET_INITIALIZER;
@@ -3310,6 +3313,40 @@ arm_rtx_costs (x, code, outer_code, total)
return true;
}
+/* All address computations that can be done are free, but rtx cost returns
+ the same for practically all of them. So we weight the different types
+ of address here in the order (most pref first):
+ PRE/POST_INC/DEC, SHIFT or NON-INT sum, INT sum, REG, MEM or LABEL. */
+
+static int
+arm_address_cost (X)
+ rtx X;
+{
+#define ARM_ADDRESS_COST(X) \
+ (10 - ((GET_CODE (X) == MEM || GET_CODE (X) == LABEL_REF \
+ || GET_CODE (X) == SYMBOL_REF) \
+ ? 0 \
+ : ((GET_CODE (X) == PRE_INC || GET_CODE (X) == PRE_DEC \
+ || GET_CODE (X) == POST_INC || GET_CODE (X) == POST_DEC) \
+ ? 10 \
+ : (((GET_CODE (X) == PLUS || GET_CODE (X) == MINUS) \
+ ? 6 + (GET_CODE (XEXP (X, 1)) == CONST_INT ? 2 \
+ : ((GET_RTX_CLASS (GET_CODE (XEXP (X, 0))) == '2' \
+ || GET_RTX_CLASS (GET_CODE (XEXP (X, 0))) == 'c' \
+ || GET_RTX_CLASS (GET_CODE (XEXP (X, 1))) == '2' \
+ || GET_RTX_CLASS (GET_CODE (XEXP (X, 1))) == 'c') \
+ ? 1 : 0)) \
+ : 4)))))
+
+#define THUMB_ADDRESS_COST(X) \
+ ((GET_CODE (X) == REG \
+ || (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == REG \
+ && GET_CODE (XEXP (X, 1)) == CONST_INT)) \
+ ? 1 : 2)
+
+ return (TARGET_ARM ? ARM_ADDRESS_COST (X) : THUMB_ADDRESS_COST (X));
+}
+
static int
arm_adjust_cost (insn, link, dep, cost)
rtx insn;
diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index c2afa4d..fb82ebc 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -2144,35 +2144,6 @@ typedef struct
((GET_MODE_SIZE (M) < 4 ? 8 : 2 * GET_MODE_SIZE (M)) \
* (CLASS == LO_REGS ? 1 : 2)))
-/* All address computations that can be done are free, but rtx cost returns
- the same for practically all of them. So we weight the different types
- of address here in the order (most pref first):
- PRE/POST_INC/DEC, SHIFT or NON-INT sum, INT sum, REG, MEM or LABEL. */
-#define ARM_ADDRESS_COST(X) \
- (10 - ((GET_CODE (X) == MEM || GET_CODE (X) == LABEL_REF \
- || GET_CODE (X) == SYMBOL_REF) \
- ? 0 \
- : ((GET_CODE (X) == PRE_INC || GET_CODE (X) == PRE_DEC \
- || GET_CODE (X) == POST_INC || GET_CODE (X) == POST_DEC) \
- ? 10 \
- : (((GET_CODE (X) == PLUS || GET_CODE (X) == MINUS) \
- ? 6 + (GET_CODE (XEXP (X, 1)) == CONST_INT ? 2 \
- : ((GET_RTX_CLASS (GET_CODE (XEXP (X, 0))) == '2' \
- || GET_RTX_CLASS (GET_CODE (XEXP (X, 0))) == 'c' \
- || GET_RTX_CLASS (GET_CODE (XEXP (X, 1))) == '2' \
- || GET_RTX_CLASS (GET_CODE (XEXP (X, 1))) == 'c') \
- ? 1 : 0)) \
- : 4)))))
-
-#define THUMB_ADDRESS_COST(X) \
- ((GET_CODE (X) == REG \
- || (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == REG \
- && GET_CODE (XEXP (X, 1)) == CONST_INT)) \
- ? 1 : 2)
-
-#define ADDRESS_COST(X) \
- (TARGET_ARM ? ARM_ADDRESS_COST (X) : THUMB_ADDRESS_COST (X))
-
/* Try to generate sequences that don't involve branches, we can then use
conditional instructions */
#define BRANCH_COST \
diff --git a/gcc/config/avr/avr-protos.h b/gcc/config/avr/avr-protos.h
index b721b3e..35ac232 100644
--- a/gcc/config/avr/avr-protos.h
+++ b/gcc/config/avr/avr-protos.h
@@ -104,7 +104,6 @@ extern const char *avr_out_sbxx_branch PARAMS ((rtx insn, rtx operands[]));
extern enum reg_class preferred_reload_class PARAMS ((rtx x,
enum reg_class class));
-extern int avr_address_cost PARAMS ((rtx x));
extern int extra_constraint PARAMS ((rtx x, int c));
extern rtx legitimize_address PARAMS ((rtx x, rtx oldx,
enum machine_mode mode));
diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c
index 0378012..017308b 100644
--- a/gcc/config/avr/avr.c
+++ b/gcc/config/avr/avr.c
@@ -73,6 +73,7 @@ static void avr_asm_out_ctor PARAMS ((rtx, int));
static void avr_asm_out_dtor PARAMS ((rtx, int));
static int default_rtx_costs PARAMS ((rtx, enum rtx_code, enum rtx_code));
static bool avr_rtx_costs PARAMS ((rtx, int, int, int *));
+static int avr_address_cost PARAMS ((rtx));
/* Allocate registers from r25 to r8 for parameters for function calls */
#define FIRST_CUM_REG 26
@@ -231,6 +232,8 @@ int avr_case_values_threshold = 30000;
#define TARGET_SECTION_TYPE_FLAGS avr_section_type_flags
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS avr_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST avr_address_cost
struct gcc_target targetm = TARGET_INITIALIZER;
@@ -5093,7 +5096,7 @@ avr_rtx_costs (x, code, outer_code, total)
/* Calculate the cost of a memory address */
-int
+static int
avr_address_cost (x)
rtx x;
{
diff --git a/gcc/config/avr/avr.h b/gcc/config/avr/avr.h
index 126a6fd..6b3d677 100644
--- a/gcc/config/avr/avr.h
+++ b/gcc/config/avr/avr.h
@@ -1521,49 +1521,6 @@ do { \
is a suitable definition for this macro on machines where anything
`CONSTANT_P' is valid. */
-#define ADDRESS_COST(ADDRESS) avr_address_cost (ADDRESS)
-
-/* An expression giving the cost of an addressing mode that contains
- ADDRESS. If not defined, the cost is computed from the ADDRESS
- expression and the `CONST_COSTS' values.
-
- For most CISC machines, the default cost is a good approximation
- of the true cost of the addressing mode. However, on RISC
- machines, all instructions normally have the same length and
- execution time. Hence all addresses will have equal costs.
-
- In cases where more than one form of an address is known, the form
- with the lowest cost will be used. If multiple forms have the
- same, lowest, cost, the one that is the most complex will be used.
-
- For example, suppose an address that is equal to the sum of a
- register and a constant is used twice in the same basic block.
- When this macro is not defined, the address will be computed in a
- register and memory references will be indirect through that
- register. On machines where the cost of the addressing mode
- containing the sum is no higher than that of a simple indirect
- reference, this will produce an additional instruction and
- possibly require an additional register. Proper specification of
- this macro eliminates this overhead for such machines.
-
- Similar use of this macro is made in strength reduction of loops.
-
- ADDRESS need not be valid as an address. In such a case, the cost
- is not relevant and can be any value; invalid addresses need not be
- assigned a different cost.
-
- On machines where an address involving more than one register is as
- cheap as an address computation involving only one register,
- defining `ADDRESS_COST' to reflect this can cause two registers to
- be live over a region of code where only one would have been if
- `ADDRESS_COST' were not defined in that manner. This effect should
- be considered in the definition of this macro. Equivalent costs
- should probably only be given to addresses with different numbers
- of registers on machines with lots of registers.
-
- This macro will normally either not be defined or be defined as a
- constant. */
-
#define REGISTER_MOVE_COST(MODE, FROM, TO) ((FROM) == STACK_REG ? 6 \
: (TO) == STACK_REG ? 12 \
: 2)
diff --git a/gcc/config/c4x/c4x-protos.h b/gcc/config/c4x/c4x-protos.h
index ce3bde8..104d0e5 100644
--- a/gcc/config/c4x/c4x-protos.h
+++ b/gcc/config/c4x/c4x-protos.h
@@ -81,8 +81,6 @@ extern int c4x_hard_regno_rename_ok PARAMS ((unsigned int, unsigned int));
extern struct rtx_def *c4x_legitimize_address PARAMS ((rtx,
enum machine_mode));
-extern int c4x_address_cost PARAMS ((rtx));
-
extern void c4x_print_operand PARAMS ((FILE *, rtx, int));
extern void c4x_print_operand_address PARAMS ((FILE *, rtx));
diff --git a/gcc/config/c4x/c4x.c b/gcc/config/c4x/c4x.c
index 2d83a8c..77d3e82 100644
--- a/gcc/config/c4x/c4x.c
+++ b/gcc/config/c4x/c4x.c
@@ -198,6 +198,7 @@ static int c4x_adjust_cost PARAMS ((rtx, rtx, rtx, int));
static void c4x_encode_section_info PARAMS ((tree, int));
static void c4x_globalize_label PARAMS ((FILE *, const char *));
static bool c4x_rtx_costs PARAMS ((rtx, int, int, int *));
+static int c4x_address_cost PARAMS ((rtx));
/* Initialize the GCC target structure. */
#undef TARGET_ASM_BYTE_OP
@@ -230,6 +231,8 @@ static bool c4x_rtx_costs PARAMS ((rtx, int, int, int *));
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS c4x_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST c4x_address_cost
struct gcc_target targetm = TARGET_INITIALIZER;
@@ -1699,7 +1702,7 @@ c4x_legitimize_address (orig, mode)
if it is worthwhile storing a common address into a register.
Unfortunately, the C4x address cost depends on other operands. */
-int
+static int
c4x_address_cost (addr)
rtx addr;
{
diff --git a/gcc/config/c4x/c4x.h b/gcc/config/c4x/c4x.h
index 891ed4b..68c7db5 100644
--- a/gcc/config/c4x/c4x.h
+++ b/gcc/config/c4x/c4x.h
@@ -1461,13 +1461,6 @@ CUMULATIVE_ARGS;
/* Descripting Relative Cost of Operations. */
-/* Compute the cost of an address. This is meant to approximate the size
- and/or execution delay of an insn using that address. The value of this
- macro only matters for valid addresses. We handle the most common address
- without a call to c4x_address_cost. */
-
-#define ADDRESS_COST(ADDR) (REG_P (ADDR) ? 1 : c4x_address_cost (ADDR))
-
#define CANONICALIZE_COMPARISON(CODE, OP0, OP1) \
if (REG_P (OP1) && ! REG_P (OP0)) \
{ \
diff --git a/gcc/config/d30v/d30v.c b/gcc/config/d30v/d30v.c
index b3b72cd..1e79baa 100644
--- a/gcc/config/d30v/d30v.c
+++ b/gcc/config/d30v/d30v.c
@@ -102,6 +102,8 @@ enum reg_class reg_class_from_letter[256];
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS d30v_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST hook_int_rtx_0
struct gcc_target targetm = TARGET_INITIALIZER;
diff --git a/gcc/config/d30v/d30v.h b/gcc/config/d30v/d30v.h
index db0e120..ba93113 100644
--- a/gcc/config/d30v/d30v.h
+++ b/gcc/config/d30v/d30v.h
@@ -2426,45 +2426,6 @@ do { \
/* Describing Relative Costs of Operations */
-/* An expression giving the cost of an addressing mode that contains ADDRESS.
- If not defined, the cost is computed from the ADDRESS expression and the
- `CONST_COSTS' values.
-
- For most CISC machines, the default cost is a good approximation of the true
- cost of the addressing mode. However, on RISC machines, all instructions
- normally have the same length and execution time. Hence all addresses will
- have equal costs.
-
- In cases where more than one form of an address is known, the form with the
- lowest cost will be used. If multiple forms have the same, lowest, cost,
- the one that is the most complex will be used.
-
- For example, suppose an address that is equal to the sum of a register and a
- constant is used twice in the same basic block. When this macro is not
- defined, the address will be computed in a register and memory references
- will be indirect through that register. On machines where the cost of the
- addressing mode containing the sum is no higher than that of a simple
- indirect reference, this will produce an additional instruction and possibly
- require an additional register. Proper specification of this macro
- eliminates this overhead for such machines.
-
- Similar use of this macro is made in strength reduction of loops.
-
- ADDRESS need not be valid as an address. In such a case, the cost is not
- relevant and can be any value; invalid addresses need not be assigned a
- different cost.
-
- On machines where an address involving more than one register is as cheap as
- an address computation involving only one register, defining `ADDRESS_COST'
- to reflect this can cause two registers to be live over a region of code
- where only one would have been if `ADDRESS_COST' were not defined in that
- manner. This effect should be considered in the definition of this macro.
- Equivalent costs should probably only be given to addresses with different
- numbers of registers on machines with lots of registers.
-
- This macro will normally either not be defined or be defined as a constant. */
-#define ADDRESS_COST(ADDRESS) 0
-
/* A C expression for the cost of moving data from a register in class FROM to
one in class TO. The classes are expressed using the enumeration values
such as `GENERAL_REGS'. A value of 4 is the default; other values are
diff --git a/gcc/config/dsp16xx/dsp16xx-protos.h b/gcc/config/dsp16xx/dsp16xx-protos.h
index c2a2584..633b9b6 100644
--- a/gcc/config/dsp16xx/dsp16xx-protos.h
+++ b/gcc/config/dsp16xx/dsp16xx-protos.h
@@ -47,7 +47,6 @@ extern void print_operand PARAMS ((FILE *, rtx, int));
extern void print_operand_address PARAMS ((FILE *, rtx));
extern void output_dsp16xx_float_const PARAMS ((rtx *));
extern void emit_1600_core_shift PARAMS ((enum rtx_code, rtx *, int));
-extern int dsp16xx_address_cost PARAMS ((rtx));
extern int symbolic_address_p PARAMS ((rtx));
extern int uns_comparison_operator PARAMS ((rtx, enum machine_mode));
#endif /* RTX_CODE */
diff --git a/gcc/config/dsp16xx/dsp16xx.c b/gcc/config/dsp16xx/dsp16xx.c
index 6d402bf..bf3f586 100644
--- a/gcc/config/dsp16xx/dsp16xx.c
+++ b/gcc/config/dsp16xx/dsp16xx.c
@@ -152,6 +152,7 @@ static int reg_save_size PARAMS ((void));
static void dsp16xx_output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT));
static void dsp16xx_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT));
static bool dsp16xx_rtx_costs PARAMS ((rtx, int, int, int *));
+static int dsp16xx_address_cost PARAMS ((rtx));
/* Initialize the GCC target structure. */
@@ -169,6 +170,8 @@ static bool dsp16xx_rtx_costs PARAMS ((rtx, int, int, int *));
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS dsp16xx_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST dsp16xx_address_cost
struct gcc_target targetm = TARGET_INITIALIZER;
@@ -2230,7 +2233,7 @@ asm_output_local(file, name, size, rounded)
fprintf (file, "int\n");
}
-int
+static int
dsp16xx_address_cost (addr)
rtx addr;
{
diff --git a/gcc/config/dsp16xx/dsp16xx.h b/gcc/config/dsp16xx/dsp16xx.h
index d80213a..6657fb8 100644
--- a/gcc/config/dsp16xx/dsp16xx.h
+++ b/gcc/config/dsp16xx/dsp16xx.h
@@ -1431,10 +1431,6 @@ extern struct dsp16xx_frame_info current_frame_info;
/* DESCRIBING RELATIVE COSTS OF OPERATIONS */
-/* An expression giving the cost of an addressing mode that contains
- address. */
-#define ADDRESS_COST(ADDR) dsp16xx_address_cost (ADDR)
-
/* A c expression for the cost of moving data from a register in
class FROM to one in class TO. The classes are expressed using
the enumeration values such as GENERAL_REGS. A value of 2 is
diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h
index 0f41377..c5349a0 100644
--- a/gcc/config/i386/i386-protos.h
+++ b/gcc/config/i386/i386-protos.h
@@ -149,7 +149,6 @@ extern void ix86_split_long_move PARAMS ((rtx[]));
extern void ix86_split_ashldi PARAMS ((rtx *, rtx));
extern void ix86_split_ashrdi PARAMS ((rtx *, rtx));
extern void ix86_split_lshrdi PARAMS ((rtx *, rtx));
-extern int ix86_address_cost PARAMS ((rtx));
extern rtx ix86_find_base_term PARAMS ((rtx));
extern rtx assign_386_stack_local PARAMS ((enum machine_mode, int));
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index bb8091d..9abff89 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -840,6 +840,7 @@ struct ix86_address
};
static int ix86_decompose_address PARAMS ((rtx, struct ix86_address *));
+static int ix86_address_cost PARAMS ((rtx));
static bool ix86_cannot_force_const_mem PARAMS ((rtx));
static void ix86_encode_section_info PARAMS ((tree, int)) ATTRIBUTE_UNUSED;
@@ -999,6 +1000,8 @@ static enum x86_64_reg_class merge_classes PARAMS ((enum x86_64_reg_class,
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS ix86_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST ix86_address_cost
struct gcc_target targetm = TARGET_INITIALIZER;
@@ -5275,7 +5278,7 @@ ix86_decompose_address (addr, out)
the address into a reg and make a new pseudo. But not if the address
requires to two regs - that would mean more pseudos with longer
lifetimes. */
-int
+static int
ix86_address_cost (x)
rtx x;
{
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index 6543ab0..1e38d10 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -2585,55 +2585,6 @@ do { \
so give the MEM rtx a byte's mode. */
#define FUNCTION_MODE QImode
-/* An expression giving the cost of an addressing mode that contains
- ADDRESS. If not defined, the cost is computed from the ADDRESS
- expression and the `CONST_COSTS' values.
-
- For most CISC machines, the default cost is a good approximation
- of the true cost of the addressing mode. However, on RISC
- machines, all instructions normally have the same length and
- execution time. Hence all addresses will have equal costs.
-
- In cases where more than one form of an address is known, the form
- with the lowest cost will be used. If multiple forms have the
- same, lowest, cost, the one that is the most complex will be used.
-
- For example, suppose an address that is equal to the sum of a
- register and a constant is used twice in the same basic block.
- When this macro is not defined, the address will be computed in a
- register and memory references will be indirect through that
- register. On machines where the cost of the addressing mode
- containing the sum is no higher than that of a simple indirect
- reference, this will produce an additional instruction and
- possibly require an additional register. Proper specification of
- this macro eliminates this overhead for such machines.
-
- Similar use of this macro is made in strength reduction of loops.
-
- ADDRESS need not be valid as an address. In such a case, the cost
- is not relevant and can be any value; invalid addresses need not be
- assigned a different cost.
-
- On machines where an address involving more than one register is as
- cheap as an address computation involving only one register,
- defining `ADDRESS_COST' to reflect this can cause two registers to
- be live over a region of code where only one would have been if
- `ADDRESS_COST' were not defined in that manner. This effect should
- be considered in the definition of this macro. Equivalent costs
- should probably only be given to addresses with different numbers
- of registers on machines with lots of registers.
-
- This macro will normally either not be defined or be defined as a
- constant.
-
- For i386, it is better to use a complex address than let gcc copy
- the address into a reg and make a new pseudo. But not if the address
- requires to two regs - that would mean more pseudos with longer
- lifetimes. */
-
-#define ADDRESS_COST(RTX) \
- ix86_address_cost (RTX)
-
/* A C expression for the cost of moving data from a register in class FROM to
one in class TO. The classes are expressed using the enumeration values
such as `GENERAL_REGS'. A value of 2 is the default; other values are
diff --git a/gcc/config/i960/i960-protos.h b/gcc/config/i960/i960-protos.h
index aa4d2ec..983afb2 100644
--- a/gcc/config/i960/i960-protos.h
+++ b/gcc/config/i960/i960-protos.h
@@ -60,7 +60,6 @@ extern int arith32_operand PARAMS ((rtx, enum machine_mode));
extern int power2_operand PARAMS ((rtx, enum machine_mode));
extern int cmplpower2_operand PARAMS ((rtx, enum machine_mode));
extern enum machine_mode select_cc_mode PARAMS ((RTX_CODE, rtx));
-extern int i960_address_cost PARAMS ((rtx));
extern int emit_move_sequence PARAMS ((rtx *, enum machine_mode));
extern int i960_bypass PARAMS ((rtx, rtx, rtx, int));
extern void i960_print_operand_addr PARAMS ((FILE *, rtx));
diff --git a/gcc/config/i960/i960.c b/gcc/config/i960/i960.c
index 35b72e2..7436104 100644
--- a/gcc/config/i960/i960.c
+++ b/gcc/config/i960/i960.c
@@ -51,6 +51,7 @@ static void i960_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT));
static void i960_output_mi_thunk PARAMS ((FILE *, tree, HOST_WIDE_INT,
HOST_WIDE_INT, tree));
static bool i960_rtx_costs PARAMS ((rtx, int, int, int *));
+static int i960_address_cost PARAMS ((rtx));
/* Save the operands last given to a compare for use when we
generate a scc or bcc insn. */
@@ -110,6 +111,8 @@ static int ret_label = 0;
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS i960_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST i960_address_cost
struct gcc_target targetm = TARGET_INITIALIZER;
@@ -503,15 +506,13 @@ gen_compare_reg (code, x, y)
/* ??? Try using just RTX_COST, i.e. not defining ADDRESS_COST. */
-int
+static int
i960_address_cost (x)
rtx x;
{
-#if 0
- /* Handled before calling here. */
if (GET_CODE (x) == REG)
return 1;
-#endif
+
/* This is a MEMA operand -- it's free. */
if (GET_CODE (x) == CONST_INT
&& INTVAL (x) >= 0
diff --git a/gcc/config/i960/i960.h b/gcc/config/i960/i960.h
index 534f525..f93f015 100644
--- a/gcc/config/i960/i960.h
+++ b/gcc/config/i960/i960.h
@@ -1153,12 +1153,6 @@ extern struct rtx_def *i960_compare_op0, *i960_compare_op1;
#ifndef WIND_RIVER
#define TARGET_MEM_FUNCTIONS 1
#endif
-
-/* The i960 offers addressing modes which are "as cheap as a register".
- See i960.c (or gcc.texinfo) for details. */
-
-#define ADDRESS_COST(RTX) \
- (GET_CODE (RTX) == REG ? 1 : i960_address_cost (RTX))
/* Control the assembler format that we output. */
diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
index 9a671a9..f9fc8ca 100644
--- a/gcc/config/ia64/ia64.c
+++ b/gcc/config/ia64/ia64.c
@@ -317,6 +317,8 @@ static const struct attribute_spec ia64_attribute_table[] =
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS ia64_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST hook_int_rtx_0
struct gcc_target targetm = TARGET_INITIALIZER;
diff --git a/gcc/config/ia64/ia64.h b/gcc/config/ia64/ia64.h
index 425d451..3e1f295 100644
--- a/gcc/config/ia64/ia64.h
+++ b/gcc/config/ia64/ia64.h
@@ -1673,12 +1673,6 @@ do { \
/* Describing Relative Costs of Operations */
-/* An expression giving the cost of an addressing mode that contains ADDRESS.
- If not defined, the cost is computed from the ADDRESS expression and the
- `CONST_COSTS' values. */
-
-#define ADDRESS_COST(ADDRESS) 0
-
/* A C expression for the cost of moving data from a register in class FROM to
one in class TO, using MODE. */
diff --git a/gcc/config/ip2k/ip2k-protos.h b/gcc/config/ip2k/ip2k-protos.h
index 48c2c4a..55f8ba6 100644
--- a/gcc/config/ip2k/ip2k-protos.h
+++ b/gcc/config/ip2k/ip2k-protos.h
@@ -39,7 +39,6 @@ extern int ip2k_return_pops_args PARAMS ((tree, tree, int));
#ifdef RTX_CODE
extern int legitimate_address_p PARAMS ((enum machine_mode, rtx, int));
extern void machine_dependent_reorg PARAMS ((rtx));
-extern int ip2k_address_cost PARAMS ((rtx));
extern int ip2k_extra_constraint PARAMS ((rtx, int));
extern rtx legitimize_address PARAMS ((rtx, rtx, enum machine_mode, rtx));
extern int adjust_insn_length PARAMS ((rtx insn, int len));
diff --git a/gcc/config/ip2k/ip2k.c b/gcc/config/ip2k/ip2k.c
index cb1a095..43d08ae 100644
--- a/gcc/config/ip2k/ip2k.c
+++ b/gcc/config/ip2k/ip2k.c
@@ -79,6 +79,7 @@ static tree ip2k_handle_progmem_attribute PARAMS ((tree *, tree, tree, int,
static tree ip2k_handle_fndecl_attribute PARAMS ((tree *, tree, tree, int,
bool *));
static bool ip2k_rtx_costs PARAMS ((rtx, int, int, int *));
+static int ip2k_address_cost PARAMS ((rtx));
const struct attribute_spec ip2k_attribute_table[];
@@ -104,6 +105,8 @@ const struct attribute_spec ip2k_attribute_table[];
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS ip2k_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST ip2k_address_cost
struct gcc_target targetm = TARGET_INITIALIZER;
@@ -3418,7 +3421,7 @@ ip2k_rtx_costs (x, code, outer_code, total)
/* Calculate the cost of a memory address. */
-int
+static int
ip2k_address_cost (x)
rtx x;
{
diff --git a/gcc/config/ip2k/ip2k.h b/gcc/config/ip2k/ip2k.h
index c656e4a..34f901c 100644
--- a/gcc/config/ip2k/ip2k.h
+++ b/gcc/config/ip2k/ip2k.h
@@ -1765,49 +1765,6 @@ do { \
is a suitable definition for this macro on machines where anything
`CONSTANT_P' is valid. */
-#define ADDRESS_COST(ADDRESS) ip2k_address_cost (ADDRESS)
-
-/* An expression giving the cost of an addressing mode that contains
- ADDRESS. If not defined, the cost is computed from the ADDRESS
- expression and the `CONST_COSTS' values.
-
- For most CISC machines, the default cost is a good approximation
- of the true cost of the addressing mode. However, on RISC
- machines, all instructions normally have the same length and
- execution time. Hence all addresses will have equal costs.
-
- In cases where more than one form of an address is known, the form
- with the lowest cost will be used. If multiple forms have the
- same, lowest, cost, the one that is the most complex will be used.
-
- For example, suppose an address that is equal to the sum of a
- register and a constant is used twice in the same basic block.
- When this macro is not defined, the address will be computed in a
- register and memory references will be indirect through that
- register. On machines where the cost of the addressing mode
- containing the sum is no higher than that of a simple indirect
- reference, this will produce an additional instruction and
- possibly require an additional register. Proper specification of
- this macro eliminates this overhead for such machines.
-
- Similar use of this macro is made in strength reduction of loops.
-
- ADDRESS need not be valid as an address. In such a case, the cost
- is not relevant and can be any value; invalid addresses need not be
- assigned a different cost.
-
- On machines where an address involving more than one register is as
- cheap as an address computation involving only one register,
- defining `ADDRESS_COST' to reflect this can cause two registers to
- be live over a region of code where only one would have been if
- `ADDRESS_COST' were not defined in that manner. This effect should
- be considered in the definition of this macro. Equivalent costs
- should probably only be given to addresses with different numbers
- of registers on machines with lots of registers.
-
- This macro will normally either not be defined or be defined as a
- constant. */
-
#define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2) 7
/* A C expression for the cost of moving data from a register in class
FROM to one in class TO. The classes are expressed using the
diff --git a/gcc/config/m32r/m32r-protos.h b/gcc/config/m32r/m32r-protos.h
index 1a73aa0..3816dd5 100644
--- a/gcc/config/m32r/m32r-protos.h
+++ b/gcc/config/m32r/m32r-protos.h
@@ -54,7 +54,6 @@ extern void m32r_output_block_move PARAMS ((rtx, rtx *));
extern void m32r_expand_block_move PARAMS ((rtx *));
extern void m32r_print_operand PARAMS ((FILE *, rtx, int));
extern void m32r_print_operand_address PARAMS ((FILE *, rtx));
-extern int m32r_address_cost PARAMS ((rtx));
extern int m32r_not_same_reg PARAMS ((rtx, rtx));
#ifdef HAVE_MACHINE_MODES
diff --git a/gcc/config/m32r/m32r.c b/gcc/config/m32r/m32r.c
index 6d4f2a3..ff02794 100644
--- a/gcc/config/m32r/m32r.c
+++ b/gcc/config/m32r/m32r.c
@@ -116,6 +116,8 @@ static bool m32r_rtx_costs PARAMS ((rtx, int, int, int *));
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS m32r_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST hook_int_rtx_0
struct gcc_target targetm = TARGET_INITIALIZER;
@@ -1804,19 +1806,6 @@ m32r_rtx_costs (x, code, outer_code, total)
return false;
}
}
-
-/* Provide the costs of an addressing mode that contains ADDR.
- If ADDR is not a valid address, its cost is irrelevant.
-
- This function is trivial at the moment. This code doesn't live
- in m32r.h so it's easy to experiment. */
-
-int
-m32r_address_cost (addr)
- rtx addr ATTRIBUTE_UNUSED;
-{
- return 1;
-}
/* Type of function DECL.
diff --git a/gcc/config/m32r/m32r.h b/gcc/config/m32r/m32r.h
index 22bf095..74431b6 100644
--- a/gcc/config/m32r/m32r.h
+++ b/gcc/config/m32r/m32r.h
@@ -1420,9 +1420,6 @@ do { \
/* Costs. */
-/* Compute the cost of an address. */
-#define ADDRESS_COST(ADDR) m32r_address_cost (ADDR)
-
/* Compute extra cost of moving data between one register class
and another. */
#define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2) 2
diff --git a/gcc/config/m68hc11/m68hc11-protos.h b/gcc/config/m68hc11/m68hc11-protos.h
index 2d78bed..ec43ca0 100644
--- a/gcc/config/m68hc11/m68hc11-protos.h
+++ b/gcc/config/m68hc11/m68hc11-protos.h
@@ -89,8 +89,6 @@ extern int m68hc11_memory_move_cost PARAMS((enum machine_mode, enum reg_class,
int));
extern int m68hc11_register_move_cost PARAMS((enum machine_mode,
enum reg_class, enum reg_class));
-extern int m68hc11_address_cost PARAMS((rtx));
-
extern void m68hc11_emit_libcall PARAMS((const char*, enum rtx_code,
enum machine_mode, enum machine_mode,
diff --git a/gcc/config/m68hc11/m68hc11.c b/gcc/config/m68hc11/m68hc11.c
index 0a50c4c..6dafb19 100644
--- a/gcc/config/m68hc11/m68hc11.c
+++ b/gcc/config/m68hc11/m68hc11.c
@@ -67,6 +67,7 @@ static int go_if_legitimate_address_internal PARAMS((rtx, enum machine_mode,
static int register_indirect_p PARAMS((rtx, enum machine_mode, int));
static rtx m68hc11_expand_compare PARAMS((enum rtx_code, rtx, rtx));
static int must_parenthesize PARAMS ((rtx));
+static int m68hc11_address_cost PARAMS ((rtx));
static int m68hc11_shift_cost PARAMS ((enum machine_mode, rtx, int));
static int m68hc11_rtx_costs_1 PARAMS ((rtx, enum rtx_code, enum rtx_code));
static bool m68hc11_rtx_costs PARAMS ((rtx, int, int, int *));
@@ -233,6 +234,8 @@ static int nb_soft_regs;
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS m68hc11_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST m68hc11_address_cost
struct gcc_target targetm = TARGET_INITIALIZER;
@@ -5226,7 +5229,7 @@ m68hc11_register_move_cost (mode, from, to)
/* Provide the costs of an addressing mode that contains ADDR.
If ADDR is not a valid address, its cost is irrelevant. */
-int
+static int
m68hc11_address_cost (addr)
rtx addr;
{
diff --git a/gcc/config/m68hc11/m68hc11.h b/gcc/config/m68hc11/m68hc11.h
index 8f3740c..c51f192 100644
--- a/gcc/config/m68hc11/m68hc11.h
+++ b/gcc/config/m68hc11/m68hc11.h
@@ -1391,11 +1391,6 @@ extern unsigned char m68hc11_reg_valid_for_index[FIRST_PSEUDO_REGISTER];
#define NOTICE_UPDATE_CC(EXP, INSN) \
m68hc11_notice_update_cc ((EXP), (INSN))
-/* An expression giving the cost of an addressing mode that contains
- ADDRESS. */
-
-#define ADDRESS_COST(RTX) m68hc11_address_cost (RTX)
-
/* Move costs between classes of registers */
#define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2) \
(m68hc11_register_move_cost (MODE, CLASS1, CLASS2))
diff --git a/gcc/config/m88k/m88k.c b/gcc/config/m88k/m88k.c
index 5a8f268..441b6f4 100644
--- a/gcc/config/m88k/m88k.c
+++ b/gcc/config/m88k/m88k.c
@@ -80,6 +80,7 @@ static void m88k_encode_section_info PARAMS ((tree, int));
static void m88k_internal_label PARAMS ((FILE *, const char *, unsigned long));
#endif
static bool m88k_rtx_costs PARAMS ((rtx, int, int, int *));
+static int m88k_address_cost PARAMS ((rtx));
/* Initialize the GCC target structure. */
#undef TARGET_ASM_BYTE_OP
@@ -114,6 +115,8 @@ static bool m88k_rtx_costs PARAMS ((rtx, int, int, int *));
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS m88k_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST m88k_address_cost
struct gcc_target targetm = TARGET_INITIALIZER;
@@ -3429,3 +3432,26 @@ m88k_rtx_costs (x, code, outer_code, total)
return false;
}
}
+
+/* Provide the costs of an addressing mode that contains ADDR.
+ If ADDR is not a valid address, its cost is irrelevant.
+ REG+REG is made slightly more expensive because it might keep
+ a register live for longer than we might like. */
+static int
+m88k_address_cost (x)
+ rtx x;
+{
+ switch (GET_CODE (x))
+ {
+ case REG:
+ case LO_SUM:
+ case MULT:
+ return 1;
+ case HIGH:
+ return 2;
+ case PLUS:
+ return (REG_P (XEXP (x, 0)) && REG_P (XEXP (x, 1))) ? 2 : 1;
+ default:
+ return 4;
+ }
+}
diff --git a/gcc/config/m88k/m88k.h b/gcc/config/m88k/m88k.h
index 4001927..7cf036b 100644
--- a/gcc/config/m88k/m88k.h
+++ b/gcc/config/m88k/m88k.h
@@ -1504,18 +1504,6 @@ enum reg_class { NO_REGS, AP_REG, XRF_REGS, GENERAL_REGS, AGRF_REGS,
state with CC_STATUS_INIT for now. */
#define CC_STATUS_INIT m88k_volatile_code = '\0'
-/* Provide the costs of an addressing mode that contains ADDR.
- If ADDR is not a valid address, its cost is irrelevant.
- REG+REG is made slightly more expensive because it might keep
- a register live for longer than we might like. */
-#define ADDRESS_COST(ADDR) \
- (GET_CODE (ADDR) == REG ? 1 : \
- GET_CODE (ADDR) == LO_SUM ? 1 : \
- GET_CODE (ADDR) == HIGH ? 2 : \
- GET_CODE (ADDR) == MULT ? 1 : \
- GET_CODE (ADDR) != PLUS ? 4 : \
- (REG_P (XEXP (ADDR, 0)) && REG_P (XEXP (ADDR, 1))) ? 2 : 1)
-
/* A C expressions returning the cost of moving data of MODE from a register
to or from memory. This is more costly than between registers. */
#define MEMORY_MOVE_COST(MODE,CLASS,IN) 4
diff --git a/gcc/config/mcore/mcore.c b/gcc/config/mcore/mcore.c
index cb24e93..865cc30 100644
--- a/gcc/config/mcore/mcore.c
+++ b/gcc/config/mcore/mcore.c
@@ -170,6 +170,8 @@ static bool mcore_rtx_costs PARAMS ((rtx, int, int, int *));
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS mcore_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST hook_int_rtx_0
struct gcc_target targetm = TARGET_INITIALIZER;
diff --git a/gcc/config/mcore/mcore.h b/gcc/config/mcore/mcore.h
index 42d2d45..6d2078c 100644
--- a/gcc/config/mcore/mcore.h
+++ b/gcc/config/mcore/mcore.h
@@ -1004,10 +1004,6 @@ extern const enum reg_class reg_class_from_letter[];
#define Pmode SImode
#define FUNCTION_MODE Pmode
-/* provide the cost for an address calculation.
- All addressing modes cost the same on the MCore. */
-#define ADDRESS_COST(RTX) 1
-
/* Compute extra cost of moving data between one register class
and another. All register moves are cheap. */
#define REGISTER_MOVE_COST(MODE, SRCCLASS, DSTCLASS) 2
diff --git a/gcc/config/mips/mips-protos.h b/gcc/config/mips/mips-protos.h
index 6d3d167..902f1be 100644
--- a/gcc/config/mips/mips-protos.h
+++ b/gcc/config/mips/mips-protos.h
@@ -90,7 +90,6 @@ extern void mips_gen_conditional_trap PARAMS ((rtx *));
extern void mips_emit_fcc_reload PARAMS ((rtx, rtx, rtx));
extern void mips_set_return_address PARAMS ((rtx, rtx));
extern void machine_dependent_reorg PARAMS ((rtx));
-extern int mips_address_cost PARAMS ((rtx));
extern void mips_count_memory_refs PARAMS ((rtx, int));
extern HOST_WIDE_INT mips_debugger_offset PARAMS ((rtx, HOST_WIDE_INT));
extern int mips_check_split PARAMS ((rtx, enum machine_mode));
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index 4dcf524..a6ad4c0 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -156,6 +156,7 @@ static void mips_select_rtx_section PARAMS ((enum machine_mode, rtx,
static int mips_use_dfa_pipeline_interface PARAMS ((void));
static void mips_encode_section_info PARAMS ((tree, int));
static bool mips_rtx_costs PARAMS ((rtx, int, int, int *));
+static int mips_address_cost PARAMS ((rtx));
/* Structure to be filled in by compute_frame_size with register
@@ -674,6 +675,8 @@ const struct mips_cpu_info mips_cpu_info_table[] = {
#define TARGET_VALID_POINTER_MODE mips_valid_pointer_mode
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS mips_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST mips_address_cost
struct gcc_target targetm = TARGET_INITIALIZER;
@@ -3324,12 +3327,15 @@ mips_rtx_costs (x, code, outer_code, total)
/* Provide the costs of an addressing mode that contains ADDR.
If ADDR is not a valid address, its cost is irrelevant. */
-int
+static int
mips_address_cost (addr)
rtx addr;
{
switch (GET_CODE (addr))
{
+ case REG:
+ return 1;
+
case LO_SUM:
return 1;
diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h
index 696aff2..24b668b 100644
--- a/gcc/config/mips/mips.h
+++ b/gcc/config/mips/mips.h
@@ -3385,50 +3385,6 @@ typedef struct mips_args {
#define FUNCTION_MODE (Pmode == DImode ? DImode : SImode)
-/* An expression giving the cost of an addressing mode that
- contains ADDRESS. If not defined, the cost is computed from the
- form of the ADDRESS expression and the `CONST_COSTS' values.
-
- For most CISC machines, the default cost is a good approximation
- of the true cost of the addressing mode. However, on RISC
- machines, all instructions normally have the same length and
- execution time. Hence all addresses will have equal costs.
-
- In cases where more than one form of an address is known, the
- form with the lowest cost will be used. If multiple forms have
- the same, lowest, cost, the one that is the most complex will be
- used.
-
- For example, suppose an address that is equal to the sum of a
- register and a constant is used twice in the same basic block.
- When this macro is not defined, the address will be computed in
- a register and memory references will be indirect through that
- register. On machines where the cost of the addressing mode
- containing the sum is no higher than that of a simple indirect
- reference, this will produce an additional instruction and
- possibly require an additional register. Proper specification
- of this macro eliminates this overhead for such machines.
-
- Similar use of this macro is made in strength reduction of loops.
-
- ADDRESS need not be valid as an address. In such a case, the
- cost is not relevant and can be any value; invalid addresses
- need not be assigned a different cost.
-
- On machines where an address involving more than one register is
- as cheap as an address computation involving only one register,
- defining `ADDRESS_COST' to reflect this can cause two registers
- to be live over a region of code where only one would have been
- if `ADDRESS_COST' were not defined in that manner. This effect
- should be considered in the definition of this macro.
- Equivalent costs should probably only be given to addresses with
- different numbers of registers on machines with lots of registers.
-
- This macro will normally either not be defined or be defined as
- a constant. */
-
-#define ADDRESS_COST(ADDR) (REG_P (ADDR) ? 1 : mips_address_cost (ADDR))
-
/* A C expression for the cost of moving data from a register in
class FROM to one in class TO. The classes are expressed using
the enumeration values such as `GENERAL_REGS'. A value of 2 is
diff --git a/gcc/config/mmix/mmix-protos.h b/gcc/config/mmix/mmix-protos.h
index e6c22f0..2e05717 100644
--- a/gcc/config/mmix/mmix-protos.h
+++ b/gcc/config/mmix/mmix-protos.h
@@ -95,7 +95,6 @@ extern void mmix_initialize_trampoline PARAMS ((rtx, rtx, rtx));
extern int mmix_constant_address_p PARAMS ((rtx));
extern int mmix_legitimate_address PARAMS ((enum machine_mode, rtx, int));
extern int mmix_legitimate_constant_p PARAMS ((rtx));
-extern int mmix_address_cost PARAMS ((rtx));
extern void mmix_print_operand PARAMS ((FILE *, rtx, int));
extern void mmix_print_operand_address PARAMS ((FILE *, rtx));
extern void mmix_machine_dependent_reorg PARAMS ((rtx));
diff --git a/gcc/config/mmix/mmix.c b/gcc/config/mmix/mmix.c
index b8cc2fb..0eb36ae 100644
--- a/gcc/config/mmix/mmix.c
+++ b/gcc/config/mmix/mmix.c
@@ -175,6 +175,8 @@ static bool mmix_rtx_costs
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS mmix_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST hook_int_rtx_0
struct gcc_target targetm = TARGET_INITIALIZER;
@@ -1209,18 +1211,6 @@ mmix_rtx_costs (x, code, outer_code, total)
return false;
}
-/* ADDRESS_COST. */
-
-int
-mmix_address_cost (addr)
- rtx addr ATTRIBUTE_UNUSED;
-{
- /* There's no difference in the address costs and we have lots of
- registers. Some targets use constant 0, many others use 1 to say
- this. Let's start with 1. */
- return 1;
-}
-
/* REGISTER_MOVE_COST. */
int
diff --git a/gcc/config/mmix/mmix.h b/gcc/config/mmix/mmix.h
index 7549f59..976ceb0 100644
--- a/gcc/config/mmix/mmix.h
+++ b/gcc/config/mmix/mmix.h
@@ -881,8 +881,6 @@ typedef struct { int regs; int lib; } CUMULATIVE_ARGS;
/* Node: Costs */
-#define ADDRESS_COST(ADDRESS) mmix_address_cost (ADDRESS)
-
/* The special registers can only move to and from general regs, and we
need to check that their constraints match, so say 3 for them. */
/* WARNING: gcc-2.7.2.2 i686-pc-linux-gnulibc1 (as shipped with RH 4.2)
diff --git a/gcc/config/mn10300/mn10300-protos.h b/gcc/config/mn10300/mn10300-protos.h
index d5a1c44..f51f3c9 100644
--- a/gcc/config/mn10300/mn10300-protos.h
+++ b/gcc/config/mn10300/mn10300-protos.h
@@ -40,8 +40,6 @@ extern int symbolic_operand PARAMS ((rtx, enum machine_mode));
extern int call_address_operand PARAMS ((rtx, enum machine_mode));
extern int impossible_plus_operand PARAMS ((rtx, enum machine_mode));
extern int const_8bit_operand PARAMS ((rtx, enum machine_mode));
-
-extern int mn10300_address_cost PARAMS ((rtx, int *));
#endif /* RTX_CODE */
#ifdef TREE_CODE
diff --git a/gcc/config/mn10300/mn10300.c b/gcc/config/mn10300/mn10300.c
index 7f524ae..f040a899 100644
--- a/gcc/config/mn10300/mn10300.c
+++ b/gcc/config/mn10300/mn10300.c
@@ -55,6 +55,8 @@ Boston, MA 02111-1307, USA. */
|| regs_ever_live[16] || regs_ever_live[17]))
+static int mn10300_address_cost_1 PARAMS ((rtx, int *));
+static int mn10300_address_cost PARAMS ((rtx));
static bool mn10300_rtx_costs PARAMS ((rtx, int, int, int *));
@@ -64,6 +66,8 @@ static bool mn10300_rtx_costs PARAMS ((rtx, int, int, int *));
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS mn10300_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST mn10300_address_cost
struct gcc_target targetm = TARGET_INITIALIZER;
@@ -1248,15 +1252,11 @@ legitimize_address (x, oldx, mode)
return x;
}
-int
-mn10300_address_cost (x, unsig)
+static int
+mn10300_address_cost_1 (x, unsig)
rtx x;
int *unsig;
{
- int _s = 0;
- if (unsig == 0)
- unsig = &_s;
-
switch (GET_CODE (x))
{
case REG:
@@ -1285,17 +1285,17 @@ mn10300_address_cost (x, unsig)
case ASHIFT:
case AND:
case IOR:
- return (mn10300_address_cost (XEXP (x, 0), unsig)
- + mn10300_address_cost (XEXP (x, 1), unsig));
+ return (mn10300_address_cost_1 (XEXP (x, 0), unsig)
+ + mn10300_address_cost_1 (XEXP (x, 1), unsig));
case EXPR_LIST:
case SUBREG:
case MEM:
- return ADDRESS_COST (XEXP (x, 0));
+ return mn10300_address_cost (XEXP (x, 0));
case ZERO_EXTEND:
*unsig = 1;
- return mn10300_address_cost (XEXP (x, 0), unsig);
+ return mn10300_address_cost_1 (XEXP (x, 0), unsig);
case CONST_INT:
if (INTVAL (x) == 0)
@@ -1317,7 +1317,7 @@ mn10300_address_cost (x, unsig)
switch (GET_CODE (XEXP (x, 0)))
{
case MEM:
- return ADDRESS_COST (XEXP (x, 0));
+ return mn10300_address_cost (XEXP (x, 0));
case REG:
return 1;
@@ -1332,6 +1332,14 @@ mn10300_address_cost (x, unsig)
}
}
+static int
+mn10300_address_cost (x)
+ rtx x;
+{
+ int s = 0;
+ return mn10300_address_cost_1 (x, &s);
+}
+
static bool
mn10300_rtx_costs (x, code, outer_code, total)
rtx x;
diff --git a/gcc/config/mn10300/mn10300.h b/gcc/config/mn10300/mn10300.h
index 67dc1eb..7ddd9d5 100644
--- a/gcc/config/mn10300/mn10300.h
+++ b/gcc/config/mn10300/mn10300.h
@@ -812,8 +812,6 @@ struct cum_arg {int nbytes; };
(CLASS1 == EXTENDED_REGS || CLASS2 == EXTENDED_REGS) ? 4 : \
4)
-#define ADDRESS_COST(X) mn10300_address_cost((X), 0)
-
/* Nonzero if access to memory by bytes or half words is no faster
than accessing full words. */
#define SLOW_BYTE_ACCESS 1
diff --git a/gcc/config/ns32k/ns32k-protos.h b/gcc/config/ns32k/ns32k-protos.h
index 64b484b..6f2c650 100644
--- a/gcc/config/ns32k/ns32k-protos.h
+++ b/gcc/config/ns32k/ns32k-protos.h
@@ -22,7 +22,6 @@ Boston, MA 02111-1307, USA. */
/* Prototypes for functions in ns32k.c */
#ifdef RTX_CODE
-extern int calc_address_cost PARAMS ((rtx));
extern enum reg_class secondary_reload_class PARAMS ((enum reg_class,
enum machine_mode, rtx));
extern int reg_or_mem_operand PARAMS ((rtx, enum machine_mode));
diff --git a/gcc/config/ns32k/ns32k.c b/gcc/config/ns32k/ns32k.c
index 58650c4..73b16df 100644
--- a/gcc/config/ns32k/ns32k.c
+++ b/gcc/config/ns32k/ns32k.c
@@ -73,6 +73,7 @@ static void ns32k_output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT));
static void ns32k_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT));
static void ns32k_encode_section_info PARAMS ((tree, int));
static bool ns32k_rtx_costs PARAMS ((rtx, int, int, int *));
+static int ns32k_address_cost PARAMS ((rtx));
/* Initialize the GCC target structure. */
#undef TARGET_ATTRIBUTE_TABLE
@@ -95,6 +96,8 @@ static bool ns32k_rtx_costs PARAMS ((rtx, int, int, int *));
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS ns32k_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST ns32k_address_cost
struct gcc_target targetm = TARGET_INITIALIZER;
@@ -559,28 +562,26 @@ int secondary_memory_needed (CLASS1, CLASS2, M)
#endif
-/* ADDRESS_COST calls this. This function is not optimal
+/* TARGET_ADDRESS_COST calls this. This function is not optimal
for the 32032 & 32332, but it probably is better than
the default. */
-int
-calc_address_cost (operand)
+static int
+ns32k_address_cost (operand)
rtx operand;
{
- int i;
int cost = 0;
- if (GET_CODE (operand) == MEM)
- cost += 3;
- if (GET_CODE (operand) == MULT)
- cost += 2;
+
switch (GET_CODE (operand))
{
case REG:
cost += 1;
break;
+
case POST_DEC:
case PRE_DEC:
break;
+
case CONST_INT:
if (INTVAL (operand) <= 7 && INTVAL (operand) >= -8)
break;
@@ -597,18 +598,23 @@ calc_address_cost (operand)
case CONST_DOUBLE:
cost += 5;
break;
+
case MEM:
- cost += calc_address_cost (XEXP (operand, 0));
+ cost += ns32k_address_cost (XEXP (operand, 0)) + 3;
break;
+
case MULT:
+ cost += 2;
+ /* FALLTHRU */
case PLUS:
- for (i = 0; i < GET_RTX_LENGTH (GET_CODE (operand)); i++)
- {
- cost += calc_address_cost (XEXP (operand, i));
- }
+ cost += ns32k_address_cost (XEXP (operand, 0));
+ cost += ns32k_address_cost (XEXP (operand, 1));
+ break;
+
default:
break;
}
+
return cost;
}
diff --git a/gcc/config/ns32k/ns32k.h b/gcc/config/ns32k/ns32k.h
index 36c23f2..9f2c026 100644
--- a/gcc/config/ns32k/ns32k.h
+++ b/gcc/config/ns32k/ns32k.h
@@ -1161,11 +1161,6 @@ __transfer_from_trampoline () \
is a byte address (for indexing purposes)
so give the MEM rtx a byte's mode. */
#define FUNCTION_MODE QImode
-
-/* Compute the cost of address ADDRESS. */
-
-#define ADDRESS_COST(RTX) calc_address_cost (RTX)
-
/* Tell final.c how to eliminate redundant test instructions. */
diff --git a/gcc/config/pa/pa-protos.h b/gcc/config/pa/pa-protos.h
index 8ea36f3..243cc10 100644
--- a/gcc/config/pa/pa-protos.h
+++ b/gcc/config/pa/pa-protos.h
@@ -65,7 +65,6 @@ extern void hppa_encode_label PARAMS ((rtx));
extern int arith11_operand PARAMS ((rtx, enum machine_mode));
extern int adddi3_operand PARAMS ((rtx, enum machine_mode));
extern int symbolic_expression_p PARAMS ((rtx));
-extern int hppa_address_cost PARAMS ((rtx));
extern int symbolic_memory_operand PARAMS ((rtx, enum machine_mode));
extern int pa_adjust_insn_length PARAMS ((rtx, int));
extern int int11_operand PARAMS ((rtx, enum machine_mode));
diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c
index 9b2f98e..21afcbb 100644
--- a/gcc/config/pa/pa.c
+++ b/gcc/config/pa/pa.c
@@ -97,6 +97,7 @@ hppa_fpstore_bypass_p (out_insn, in_insn)
#endif
#endif
+static int hppa_address_cost PARAMS ((rtx));
static bool hppa_rtx_costs PARAMS ((rtx, int, int, int *));
static inline rtx force_mode PARAMS ((enum machine_mode, rtx));
static void pa_combine_instructions PARAMS ((rtx));
@@ -223,6 +224,8 @@ static size_t n_deferred_plabels = 0;
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS hppa_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST hppa_address_cost
struct gcc_target targetm = TARGET_INITIALIZER;
@@ -1306,17 +1309,22 @@ hppa_legitimize_address (x, oldx, mode)
It is no coincidence that this has the same structure
as GO_IF_LEGITIMATE_ADDRESS. */
-int
+
+static int
hppa_address_cost (X)
rtx X;
{
- if (GET_CODE (X) == PLUS)
+ switch (GET_CODE (X))
+ {
+ case REG:
+ case PLUS:
+ case LO_SUM:
return 1;
- else if (GET_CODE (X) == LO_SUM)
- return 1;
- else if (GET_CODE (X) == HIGH)
- return 2;
- return 4;
+ case HIGH:
+ return 2;
+ default:
+ return 4;
+ }
}
/* Compute a (partial) cost for rtx X. Return true if the complete
diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h
index 8be8d88..595253c 100644
--- a/gcc/config/pa/pa.h
+++ b/gcc/config/pa/pa.h
@@ -1595,9 +1595,6 @@ do { \
few bits. */
#define SHIFT_COUNT_TRUNCATED 1
-#define ADDRESS_COST(RTX) \
- (GET_CODE (RTX) == REG ? 1 : hppa_address_cost (RTX))
-
/* Compute extra cost of moving data between one register class
and another.
diff --git a/gcc/config/romp/romp.c b/gcc/config/romp/romp.c
index 36e8b54..0811ee8 100644
--- a/gcc/config/romp/romp.c
+++ b/gcc/config/romp/romp.c
@@ -60,6 +60,7 @@ static void romp_select_rtx_section PARAMS ((enum machine_mode, rtx,
unsigned HOST_WIDE_INT));
static void romp_encode_section_info PARAMS ((tree, int));
static bool romp_rtx_costs PARAMS ((rtx, int, int, int *));
+static int romp_address_cost PARAMS ((rtx));
/* Initialize the GCC target structure. */
#undef TARGET_ASM_FUNCTION_PROLOGUE
@@ -72,6 +73,8 @@ static bool romp_rtx_costs PARAMS ((rtx, int, int, int *));
#define TARGET_ENCODE_SECTION_INFO romp_encode_section_info
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS romp_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST romp_address_cost
struct gcc_target targetm = TARGET_INITIALIZER;
@@ -2165,3 +2168,23 @@ romp_rtx_costs (x, code, outer_code, total)
return false;
}
}
+
+/* For the ROMP, everything is cost 0 except for addresses involving
+ symbolic constants, which are cost 1. */
+
+static int
+romp_address_cost (x)
+ rtx x;
+{
+ return
+ ((GET_CODE (x) == SYMBOL_REF
+ && ! CONSTANT_POOL_ADDRESS_P (x))
+ || GET_CODE (x) == LABEL_REF
+ || (GET_CODE (x) == CONST
+ && ! constant_pool_address_operand (x, Pmode))
+ || (GET_CODE (x) == PLUS
+ && ((GET_CODE (XEXP (x, 1)) == SYMBOL_REF
+ && ! CONSTANT_POOL_ADDRESS_P (XEXP (x, 0)))
+ || GET_CODE (XEXP (x, 1)) == LABEL_REF
+ || GET_CODE (XEXP (x, 1)) == CONST)));
+}
diff --git a/gcc/config/romp/romp.h b/gcc/config/romp/romp.h
index 16b543d..f81d88a 100644
--- a/gcc/config/romp/romp.h
+++ b/gcc/config/romp/romp.h
@@ -1162,29 +1162,6 @@ struct rt_cargs {int gregs, fregs; };
/* #define SHIFT_COUNT_TRUNCATED */
-/* Compute the cost of an address. This is meant to approximate the size
- and/or execution delay of an insn using that address. If the cost is
- approximated by the RTL complexity, including CONST_COSTS above, as
- is usually the case for CISC machines, this macro should not be defined.
- For aggressively RISCy machines, only one insn format is allowed, so
- this macro should be a constant. The value of this macro only matters
- for valid addresses.
-
- For the ROMP, everything is cost 0 except for addresses involving
- symbolic constants, which are cost 1. */
-
-#define ADDRESS_COST(RTX) \
- ((GET_CODE (RTX) == SYMBOL_REF \
- && ! CONSTANT_POOL_ADDRESS_P (RTX)) \
- || GET_CODE (RTX) == LABEL_REF \
- || (GET_CODE (RTX) == CONST \
- && ! constant_pool_address_operand (RTX, Pmode)) \
- || (GET_CODE (RTX) == PLUS \
- && ((GET_CODE (XEXP (RTX, 1)) == SYMBOL_REF \
- && ! CONSTANT_POOL_ADDRESS_P (XEXP (RTX, 0))) \
- || GET_CODE (XEXP (RTX, 1)) == LABEL_REF \
- || GET_CODE (XEXP (RTX, 1)) == CONST)))
-
/* Adjust the length of an INSN. LENGTH is the currently-computed length and
should be adjusted to reflect any required changes. This macro is used when
there is some systematic length adjustment required that would be difficult
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 69fda81..31eb55e 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -407,6 +407,8 @@ static const char alt_reg_names[][8] =
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS rs6000_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST hook_int_rtx_0
struct gcc_target targetm = TARGET_INITIALIZER;
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index 7128881..b3fa442 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -2291,18 +2291,6 @@ do { \
#define SHIFT_COUNT_TRUNCATED (TARGET_POWER ? 1 : 0)
-/* Compute the cost of an address. This is meant to approximate the size
- and/or execution delay of an insn using that address. If the cost is
- approximated by the RTL complexity, including CONST_COSTS above, as
- is usually the case for CISC machines, this macro should not be defined.
- For aggressively RISCy machines, only one insn format is allowed, so
- this macro should be a constant. The value of this macro only matters
- for valid addresses.
-
- For the RS/6000, everything is cost 0. */
-
-#define ADDRESS_COST(RTX) 0
-
/* Adjust the length of an INSN. LENGTH is the currently-computed length and
should be adjusted to reflect any required changes. This macro is used when
there is some systematic length adjustment required that would be difficult
diff --git a/gcc/config/s390/s390-protos.h b/gcc/config/s390/s390-protos.h
index 3e315dd..a1a3ba5 100644
--- a/gcc/config/s390/s390-protos.h
+++ b/gcc/config/s390/s390-protos.h
@@ -29,7 +29,6 @@ extern void s390_emit_epilogue PARAMS ((void));
extern void s390_function_profiler PARAMS ((FILE *, int));
#ifdef RTX_CODE
-extern int s390_address_cost PARAMS ((rtx));
extern int q_constraint PARAMS ((rtx));
extern int const0_operand PARAMS ((rtx, enum machine_mode));
extern int consttable_operand PARAMS ((rtx, enum machine_mode));
diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index 7149ae9..6dfb3d5 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -67,6 +67,7 @@ static int s390_adjust_cost PARAMS ((rtx, rtx, rtx, int));
static int s390_issue_rate PARAMS ((void));
static int s390_use_dfa_pipeline_interface PARAMS ((void));
static bool s390_rtx_costs PARAMS ((rtx, int, int, int *));
+static int s390_address_cost PARAMS ((rtx));
#undef TARGET_ASM_ALIGNED_HI_OP
@@ -116,6 +117,8 @@ static bool s390_rtx_costs PARAMS ((rtx, int, int, int *));
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS s390_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST s390_address_cost
struct gcc_target targetm = TARGET_INITIALIZER;
@@ -1270,7 +1273,7 @@ s390_rtx_costs (x, code, outer_code, total)
/* Return the cost of an address rtx ADDR. */
-int
+static int
s390_address_cost (addr)
rtx addr;
{
diff --git a/gcc/config/s390/s390.h b/gcc/config/s390/s390.h
index 066f2cf..1623666 100644
--- a/gcc/config/s390/s390.h
+++ b/gcc/config/s390/s390.h
@@ -812,11 +812,6 @@ extern struct rtx_def *s390_compare_op0, *s390_compare_op1;
/* Relative costs of operations. */
-/* An expression giving the cost of an addressing mode that contains
- ADDRESS. If not defined, the cost is computed from the ADDRESS
- expression and the `CONST_COSTS' values. */
-#define ADDRESS_COST(RTX) s390_address_cost ((RTX))
-
/* On s390, copy between fprs and gprs is expensive. */
#define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2) \
(( ( reg_classes_intersect_p ((CLASS1), GENERAL_REGS) \
diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c
index 93e7978..dadc1c9 100644
--- a/gcc/config/sh/sh.c
+++ b/gcc/config/sh/sh.c
@@ -219,6 +219,7 @@ static int andcosts PARAMS ((rtx));
static int addsubcosts PARAMS ((rtx));
static int multcosts PARAMS ((rtx));
static bool sh_rtx_costs PARAMS ((rtx, int, int, int *));
+static int sh_address_cost PARAMS ((rtx));
/* Initialize the GCC target structure. */
#undef TARGET_ATTRIBUTE_TABLE
@@ -272,6 +273,8 @@ static bool sh_rtx_costs PARAMS ((rtx, int, int, int *));
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS sh_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST sh_address_cost
struct gcc_target targetm = TARGET_INITIALIZER;
@@ -1522,6 +1525,18 @@ sh_rtx_costs (x, code, outer_code, total)
}
}
+/* Compute the cost of an address. For the SH, all valid addresses are
+ the same cost. Use a slightly higher cost for reg + reg addressing,
+ since it increases pressure on r0. */
+
+static int
+sh_address_cost (X)
+ rtx X;
+{
+ return (GET_CODE (X) == PLUS
+ && ! CONSTANT_P (XEXP (X, 1))
+ && ! TARGET_SHMEDIA ? 1 : 0);
+}
/* Code to expand a shift. */
diff --git a/gcc/config/sh/sh.h b/gcc/config/sh/sh.h
index e5d0677..cf8ac7f 100644
--- a/gcc/config/sh/sh.h
+++ b/gcc/config/sh/sh.h
@@ -2752,14 +2752,6 @@ while (0)
((GET_CODE (X) == SYMBOL_REF || GET_CODE (X) == LABEL_REF) \
&& nonpic_symbol_mentioned_p (X))
-/* Compute the cost of an address. For the SH, all valid addresses are
- the same cost. Use a slightly higher cost for reg + reg addressing,
- since it increases pressure on r0. */
-
-#define ADDRESS_COST(X) (GET_CODE (X) == PLUS && ! CONSTANT_P (XEXP (X, 1)) \
- && ! TARGET_SHMEDIA \
- ? 1 : 0)
-
/* Compute extra cost of moving data between one register class
and another. */
diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index a769ca9..50e81f0 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -255,6 +255,8 @@ enum processor_type sparc_cpu;
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS sparc_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST hook_int_rtx_0
struct gcc_target targetm = TARGET_INITIALIZER;
diff --git a/gcc/config/sparc/sparc.h b/gcc/config/sparc/sparc.h
index 95a97d2..c6d8aac 100644
--- a/gcc/config/sparc/sparc.h
+++ b/gcc/config/sparc/sparc.h
@@ -2608,8 +2608,6 @@ do { \
: (sparc_cpu == PROCESSOR_ULTRASPARC3 \
? 9 : 3))
-#define ADDRESS_COST(RTX) 1
-
#define PREFETCH_BLOCK \
((sparc_cpu == PROCESSOR_ULTRASPARC \
|| sparc_cpu == PROCESSOR_ULTRASPARC3) \
diff --git a/gcc/config/stormy16/stormy16.c b/gcc/config/stormy16/stormy16.c
index 7a03462..7a20df4 100644
--- a/gcc/config/stormy16/stormy16.c
+++ b/gcc/config/stormy16/stormy16.c
@@ -58,6 +58,7 @@ static void xstormy16_asm_output_mi_thunk PARAMS ((FILE *, tree, HOST_WIDE_INT,
static void xstormy16_init_builtins PARAMS ((void));
static rtx xstormy16_expand_builtin PARAMS ((tree, rtx, rtx, enum machine_mode, int));
static bool xstormy16_rtx_costs PARAMS ((rtx, int, int, int *));
+static int xstormy16_address_cost PARAMS ((rtx));
/* Define the information needed to generate branch and scc insns. This is
stored from the compare operation. */
@@ -138,6 +139,14 @@ xstormy16_rtx_costs (x, code, outer_code, total)
}
}
+static int
+xstormy16_address_cost (x)
+ rtx x;
+{
+ return (GET_CODE (x) == CONST_INT ? 2
+ : GET_CODE (x) == PLUS ? 7
+ : 5);
+}
/* Branches are handled as follows:
@@ -2209,5 +2218,7 @@ xstormy16_expand_builtin(exp, target, subtarget, mode, ignore)
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS xstormy16_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST xstormy16_address_cost
struct gcc_target targetm = TARGET_INITIALIZER;
diff --git a/gcc/config/stormy16/stormy16.h b/gcc/config/stormy16/stormy16.h
index b8a90c4..5052364 100644
--- a/gcc/config/stormy16/stormy16.h
+++ b/gcc/config/stormy16/stormy16.h
@@ -2197,49 +2197,6 @@ do { \
/* Describing Relative Costs of Operations */
-/* An expression giving the cost of an addressing mode that contains ADDRESS.
- If not defined, the cost is computed from the ADDRESS expression and the
- `CONST_COSTS' values.
-
- For most CISC machines, the default cost is a good approximation of the true
- cost of the addressing mode. However, on RISC machines, all instructions
- normally have the same length and execution time. Hence all addresses will
- have equal costs.
-
- In cases where more than one form of an address is known, the form with the
- lowest cost will be used. If multiple forms have the same, lowest, cost,
- the one that is the most complex will be used.
-
- For example, suppose an address that is equal to the sum of a register and a
- constant is used twice in the same basic block. When this macro is not
- defined, the address will be computed in a register and memory references
- will be indirect through that register. On machines where the cost of the
- addressing mode containing the sum is no higher than that of a simple
- indirect reference, this will produce an additional instruction and possibly
- require an additional register. Proper specification of this macro
- eliminates this overhead for such machines.
-
- Similar use of this macro is made in strength reduction of loops.
-
- ADDRESS need not be valid as an address. In such a case, the cost is not
- relevant and can be any value; invalid addresses need not be assigned a
- different cost.
-
- On machines where an address involving more than one register is as cheap as
- an address computation involving only one register, defining `ADDRESS_COST'
- to reflect this can cause two registers to be live over a region of code
- where only one would have been if `ADDRESS_COST' were not defined in that
- manner. This effect should be considered in the definition of this macro.
- Equivalent costs should probably only be given to addresses with different
- numbers of registers on machines with lots of registers.
-
- This macro will normally either not be defined or be defined as a
- constant. */
-#define ADDRESS_COST(ADDRESS) \
- (GET_CODE (ADDRESS) == CONST_INT ? 2 \
- : GET_CODE (ADDRESS) == PLUS ? 7 \
- : 5)
-
/* A C expression for the cost of moving data of mode MODE from a
register in class FROM to one in class TO. The classes are
expressed using the enumeration values such as `GENERAL_REGS'. A
diff --git a/gcc/config/v850/v850.c b/gcc/config/v850/v850.c
index f16114e..2295a55 100644
--- a/gcc/config/v850/v850.c
+++ b/gcc/config/v850/v850.c
@@ -109,6 +109,8 @@ static int v850_interrupt_p = FALSE;
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS v850_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST hook_int_rtx_0
struct gcc_target targetm = TARGET_INITIALIZER;
diff --git a/gcc/config/v850/v850.h b/gcc/config/v850/v850.h
index 447e247..8e1d28b 100644
--- a/gcc/config/v850/v850.h
+++ b/gcc/config/v850/v850.h
@@ -1025,9 +1025,6 @@ do { \
#define CC_NO_CARRY CC_NO_OVERFLOW
#define NOTICE_UPDATE_CC(EXP, INSN) notice_update_cc(EXP, INSN)
-/* All addressing modes have the same cost on the V850 series. */
-#define ADDRESS_COST(ADDR) 1
-
/* Nonzero if access to memory by bytes or half words is no faster
than accessing full words. */
#define SLOW_BYTE_ACCESS 1
diff --git a/gcc/config/vax/vax-protos.h b/gcc/config/vax/vax-protos.h
index 0e8cfb1..d62b2ac 100644
--- a/gcc/config/vax/vax-protos.h
+++ b/gcc/config/vax/vax-protos.h
@@ -25,8 +25,6 @@ extern const char *rev_cond_name PARAMS ((rtx));
extern void split_quadword_operands PARAMS ((rtx *, rtx *, int));
extern void print_operand_address PARAMS ((FILE *, rtx));
extern int vax_float_literal PARAMS ((rtx));
-extern int vax_address_cost PARAMS ((rtx));
-extern int vax_rtx_cost PARAMS ((rtx));
extern int reg_was_0_p PARAMS ((rtx, rtx));
#endif /* RTX_CODE */
diff --git a/gcc/config/vax/vax.c b/gcc/config/vax/vax.c
index 9bff82b..1413882 100644
--- a/gcc/config/vax/vax.c
+++ b/gcc/config/vax/vax.c
@@ -45,6 +45,8 @@ static int follows_p PARAMS ((rtx, rtx));
static void vax_output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT));
static void vax_output_mi_thunk PARAMS ((FILE *, tree, HOST_WIDE_INT,
HOST_WIDE_INT, tree));
+static int vax_address_cost_1 PARAMS ((rtx));
+static int vax_address_cost PARAMS ((rtx));
static int vax_rtx_costs_1 PARAMS ((rtx, enum rtx_code, enum rtx_code));
static bool vax_rtx_costs PARAMS ((rtx, int, int, int *));
@@ -62,6 +64,8 @@ static bool vax_rtx_costs PARAMS ((rtx, int, int, int *));
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS vax_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST vax_address_cost
struct gcc_target targetm = TARGET_INITIALIZER;
@@ -418,8 +422,8 @@ vax_float_literal(c)
2 - indirect */
-int
-vax_address_cost (addr)
+static int
+vax_address_cost_1 (addr)
register rtx addr;
{
int reg = 0, indexed = 0, indir = 0, offset = 0, predec = 0;
@@ -487,6 +491,13 @@ vax_address_cost (addr)
return reg + indexed + indir + offset + predec;
}
+static int
+vax_address_cost (x)
+ rtx x;
+{
+ return (1 + (GET_CODE (x) == REG ? 0 : vax_address_cost_1 (x)));
+}
+
/* Cost of an expression on a VAX. This version has costs tuned for the
CVAX chip (found in the VAX 3 series) with comments for variations on
other models. */
@@ -649,7 +660,7 @@ vax_rtx_costs_1 (x, code, outer_code)
x = XEXP (x, 0);
if (GET_CODE (x) == REG || GET_CODE (x) == POST_INC)
return c;
- return c + vax_address_cost (x);
+ return c + vax_address_cost_1 (x);
default:
c = 3;
break;
@@ -703,7 +714,7 @@ vax_rtx_costs_1 (x, code, outer_code)
case MEM:
c += 1; /* 2 on VAX 2 */
if (GET_CODE (XEXP (op, 0)) != REG)
- c += vax_address_cost (XEXP (op, 0));
+ c += vax_address_cost_1 (XEXP (op, 0));
break;
case REG:
case SUBREG:
diff --git a/gcc/config/vax/vax.h b/gcc/config/vax/vax.h
index e2a1d95..d52f31d 100644
--- a/gcc/config/vax/vax.h
+++ b/gcc/config/vax/vax.h
@@ -848,8 +848,6 @@ enum reg_class { NO_REGS, ALL_REGS, LIM_REG_CLASSES };
#define TARGET_FLOAT_FORMAT VAX_FLOAT_FORMAT
-#define ADDRESS_COST(RTX) (1 + (GET_CODE (RTX) == REG ? 0 : vax_address_cost(RTX)))
-
/* Specify the cost of a branch insn; roughly the number of extra insns that
should be added to avoid a branch.
diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c
index 645ad1a..a05386c 100644
--- a/gcc/config/xtensa/xtensa.c
+++ b/gcc/config/xtensa/xtensa.c
@@ -243,6 +243,8 @@ static const int reg_nonleaf_alloc_order[FIRST_PSEUDO_REGISTER] =
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS xtensa_rtx_costs
+#undef TARGET_ADDRESS_COST
+#define TARGET_ADDRESS_COST hook_int_rtx_0
struct gcc_target targetm = TARGET_INITIALIZER;
diff --git a/gcc/config/xtensa/xtensa.h b/gcc/config/xtensa/xtensa.h
index 3ae66f1..b11fa5e 100644
--- a/gcc/config/xtensa/xtensa.h
+++ b/gcc/config/xtensa/xtensa.h
@@ -1281,10 +1281,6 @@ typedef struct xtensa_args {
indexing purposes) so give the MEM rtx a words's mode. */
#define FUNCTION_MODE SImode
-/* An expression giving the cost of an addressing mode that
- contains ADDRESS. */
-#define ADDRESS_COST(ADDR) 1
-
/* A C expression for the cost of moving data from a register in
class FROM to one in class TO. The classes are expressed using
the enumeration values such as 'GENERAL_REGS'. A value of 2 is
diff --git a/gcc/cse.c b/gcc/cse.c
index e396042..59253a9 100644
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -896,7 +896,7 @@ address_cost (x, mode)
rtx x;
enum machine_mode mode;
{
- /* The ADDRESS_COST macro does not deal with ADDRESSOF nodes. But,
+ /* The address_cost target hook does not deal with ADDRESSOF nodes. But,
during CSE, such nodes are present. Using an ADDRESSOF node which
refers to the address of a REG is a good thing because we can then
turn (MEM (ADDRESSSOF (REG))) into just plain REG. */
@@ -906,17 +906,22 @@ address_cost (x, mode)
/* We may be asked for cost of various unusual addresses, such as operands
of push instruction. It is not worthwhile to complicate writing
- of ADDRESS_COST macro by such cases. */
+ of the target hook by such cases. */
if (!memory_address_p (mode, x))
return 1000;
-#ifdef ADDRESS_COST
- return ADDRESS_COST (x);
-#else
- return rtx_cost (x, MEM);
-#endif
+
+ return (*targetm.address_cost) (x);
}
+/* If the target doesn't override, compute the cost as with arithmetic. */
+
+int
+default_address_cost (x)
+ rtx x;
+{
+ return rtx_cost (x, MEM);
+}
static struct cse_reg_info *
get_cse_reg_info (regno)
diff --git a/gcc/hooks.c b/gcc/hooks.c
index 5911716..0954bde 100644
--- a/gcc/hooks.c
+++ b/gcc/hooks.c
@@ -97,6 +97,13 @@ hook_int_tree_tree_1 (a, b)
return 1;
}
+int
+hook_int_rtx_0 (a)
+ rtx a ATTRIBUTE_UNUSED;
+{
+ return 0;
+}
+
void
hook_void_tree (a)
tree a ATTRIBUTE_UNUSED;
diff --git a/gcc/hooks.h b/gcc/hooks.h
index 954f218..d36e3fc 100644
--- a/gcc/hooks.h
+++ b/gcc/hooks.h
@@ -38,6 +38,7 @@ void hook_void_tree PARAMS ((tree));
void hook_void_tree_treeptr PARAMS ((tree, tree *));
int hook_int_tree_tree_1 PARAMS ((tree, tree));
+int hook_int_rtx_0 PARAMS ((rtx));
bool default_can_output_mi_thunk_no_vcall
PARAMS ((tree, HOST_WIDE_INT, HOST_WIDE_INT, tree));
diff --git a/gcc/loop.c b/gcc/loop.c
index c7165e5..50c1692 100644
--- a/gcc/loop.c
+++ b/gcc/loop.c
@@ -7333,21 +7333,8 @@ combine_givs_p (g1, g2)
the expression of G2 in terms of G1 can be used. */
if (ret != NULL_RTX
&& g2->giv_type == DEST_ADDR
- && memory_address_p (GET_MODE (g2->mem), ret)
- /* ??? Looses, especially with -fforce-addr, where *g2->location
- will always be a register, and so anything more complicated
- gets discarded. */
-#if 0
-#ifdef ADDRESS_COST
- && ADDRESS_COST (tem) <= ADDRESS_COST (*g2->location)
-#else
- && rtx_cost (tem, MEM) <= rtx_cost (*g2->location, MEM)
-#endif
-#endif
- )
- {
- return ret;
- }
+ && memory_address_p (GET_MODE (g2->mem), ret))
+ return ret;
return NULL_RTX;
}
diff --git a/gcc/output.h b/gcc/output.h
index 3f6c0cd..18e0b23 100644
--- a/gcc/output.h
+++ b/gcc/output.h
@@ -530,3 +530,5 @@ extern bool default_valid_pointer_mode PARAMS ((enum machine_mode));
extern void assemble_vtable_entry PARAMS ((struct rtx_def *, HOST_WIDE_INT));
extern void assemble_vtable_inherit PARAMS ((struct rtx_def *,
struct rtx_def *));
+
+extern int default_address_cost PARAMS ((rtx));
diff --git a/gcc/system.h b/gcc/system.h
index 6858d30..81988c5 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -613,7 +613,8 @@ typedef char _Bool;
ASM_OUTPUT_DESTRUCTOR SIGNED_CHAR_SPEC MAX_CHAR_TYPE_SIZE \
WCHAR_UNSIGNED UNIQUE_SECTION SELECT_SECTION SELECT_RTX_SECTION \
ENCODE_SECTION_INFO STRIP_NAME_ENCODING ASM_GLOBALIZE_LABEL \
- ASM_OUTPUT_MI_THUNK CONST_COSTS RTX_COSTS DEFAULT_RTX_COSTS
+ ASM_OUTPUT_MI_THUNK CONST_COSTS RTX_COSTS DEFAULT_RTX_COSTS \
+ ADDRESS_COST
/* Other obsolete target macros, or macros that used to be in target
headers and were not used, and may be obsolete or may never have
diff --git a/gcc/target-def.h b/gcc/target-def.h
index a6f1357..18929d1 100644
--- a/gcc/target-def.h
+++ b/gcc/target-def.h
@@ -227,11 +227,14 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
TARGET_SCHED_INIT_DFA_BUBBLES, \
TARGET_SCHED_DFA_BUBBLE}
-/* All in tree.c. */
+/* In tree.c. */
#define TARGET_MERGE_DECL_ATTRIBUTES merge_decl_attributes
#define TARGET_MERGE_TYPE_ATTRIBUTES merge_type_attributes
#define TARGET_ATTRIBUTE_TABLE NULL
+/* In cse.c. */
+#define TARGET_ADDRESS_COST default_address_cost
+
/* In builtins.c. */
#define TARGET_INIT_BUILTINS default_init_builtins
#define TARGET_EXPAND_BUILTIN default_expand_builtin
@@ -262,7 +265,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define TARGET_INSERT_ATTRIBUTES hook_void_tree_treeptr
#define TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P hook_bool_tree_false
#define TARGET_MS_BITFIELD_LAYOUT_P hook_bool_tree_false
-/* #define TARGET_RTX_COSTS hook_bool_rtx_int_int_intp_false */
+#define TARGET_RTX_COSTS hook_bool_rtx_int_int_intp_false
#ifndef TARGET_IN_SMALL_DATA_P
#define TARGET_IN_SMALL_DATA_P hook_bool_tree_false
@@ -297,6 +300,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
TARGET_STRIP_NAME_ENCODING, \
TARGET_VALID_POINTER_MODE, \
TARGET_RTX_COSTS, \
+ TARGET_ADDRESS_COST, \
TARGET_HAVE_NAMED_SECTIONS, \
TARGET_HAVE_CTORS_DTORS, \
TARGET_HAVE_TLS, \
diff --git a/gcc/target.h b/gcc/target.h
index 933da66..b6d7f8d 100644
--- a/gcc/target.h
+++ b/gcc/target.h
@@ -321,6 +321,10 @@ struct gcc_target
not necessarily defined at this point. */
bool (* rtx_costs) PARAMS ((rtx x, int code, int outer_code, int *total));
+ /* Compute the cost of X, used as an address. Never called with
+ invalid addresses. */
+ int (* address_cost) PARAMS ((rtx x));
+
/* Leave the boolean fields at the end. */
/* True if arbitrary sections are supported. */