diff options
Diffstat (limited to 'gcc/config')
74 files changed, 303 insertions, 569 deletions
diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c index d10396e6c0a..4e4de75b6ad 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 ae28dd2729d..0522ba6c080 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 cbb8ac2240b..717845eca0d 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 2048bd3e06e..bd2afc015f1 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 4d7b6338cb0..583398c643b 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 5bbe6acc909..427f68e7bf6 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 c2afa4dc211..fb82ebcf68b 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 b721b3e5a54..35ac2329514 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 037801243ba..017308bfb8d 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 126a6fdb7b8..6b3d6774ab9 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 ce3bde88e21..104d0e5c22d 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 2d83a8c9b66..77d3e8250ec 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 891ed4bf200..68c7db54fbc 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 b3b72cd21cd..1e79baa5309 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 db0e120de28..ba931130229 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 c2a2584682d..633b9b6925a 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 6d402bf6e3f..bf3f5861d22 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 d80213a7a68..6657fb82004 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 0f4137712b6..c5349a01d28 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 bb8091dfcb4..9abff89a052 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 6543ab018a4..1e38d10d36e 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 aa4d2ec6c15..983afb2c5a3 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 35b72e25811..7436104c3ff 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 534f5254dbd..f93f0159f10 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 9a671a9edee..f9fc8cadd5a 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 425d451b8ab..3e1f295d73e 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 48c2c4a750e..55f8ba66ab9 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 cb1a0952c5f..43d08ae9f9a 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 c656e4a4bec..34f901c2769 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 1a73aa014b4..3816dd5e843 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 6d4f2a30e1f..ff027949e5b 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 22bf095f72c..74431b6ca53 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 2d78bed2f00..ec43ca0ac15 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 0a50c4cc2e6..6dafb198818 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 8f3740cb27d..c51f1924254 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 5a8f26864e8..441b6f44ab6 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 4001927e655..7cf036bbd9a 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 cb24e937f3e..865cc30ebee 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 42d2d45f974..6d2078c966c 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 6d3d16783ee..902f1bef48b 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 4dcf5248ab5..a6ad4c0f7ab 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 696aff2be2f..24b668b70fe 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 e6c22f093f9..2e0571739ac 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 b8cc2fbd2b9..0eb36ae07d4 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 7549f590cdc..976ceb0b639 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 d5a1c4426c6..f51f3c95546 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 7f524ae134c..f040a899d9e 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 67dc1ebee3f..7ddd9d5291b 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 64b484b5f5a..6f2c6508c0f 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 58650c4c924..73b16df9058 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 36c23f2640f..9f2c0260fe8 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 8ea36f3a44e..243cc10dbf5 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 9b2f98ef041..21afcbb8466 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 8be8d88e3a0..595253c8926 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 36e8b54b160..0811ee81f46 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 16b543dfa80..f81d88ae14e 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 69fda814afb..31eb55e2ec7 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 71288817dc5..b3fa442c0cf 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 3e315dd369a..a1a3ba52d93 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 7149ae90f75..6dfb3d54118 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 066f2cf3670..1623666cb65 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 93e7978c020..dadc1c951b3 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 e5d0677ed60..cf8ac7fd910 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 a769ca9d2e7..50e81f0b8d8 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 95a97d240ca..c6d8aac5982 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 7a034626dd9..7a20df4993c 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 b8a90c49f47..505236484d9 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 f16114ec6c9..2295a552a00 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 447e247ea36..8e1d28bd4c2 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 0e8cfb1f484..d62b2ac8c8d 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 9bff82b15e8..1413882f4a6 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 e2a1d95e13d..d52f31d854e 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 645ad1adbfd..a05386cf4e5 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 3ae66f1240e..b11fa5e81a7 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 |