From fab7adbfb5b8861f87531f939ad03f891bba055a Mon Sep 17 00:00:00 2001 From: rth Date: Tue, 28 Jan 2003 04:46:33 +0000 Subject: * Makefile.in (cse.o): Depend on TARGET_H. * cse.c (rtx_cost): Use targetm.rtx_costs. * system.h (CONST_COSTS RTX_COSTS DEFAULT_RTX_COSTS): Poison. * doc/tm.texi: Update. * target.h (targetm.rtx_costs): New. * target-def.h (TARGET_RTX_COSTS): New. * hooks.c (hook_bool_rtx_int_int_intp_false): New. * hooks.h: Update. * config/alpha/alpha.c (alpha_rtx_cost_data): New. (alpha_rtx_costs, TARGET_RTX_COSTS): New. * config/alpha/alpha.h (PROCESSOR_MAX): New. (CONST_COSTS, RTX_COSTS): Remove. * config/arc/arc.c, config/arc/arc.h, config/c4x/c4x.c, config/c4x/c4x.h, config/cris/cris.c, config/cris/cris.h, config/d30v/d30v.c, config/d30v/d30v.h, config/dsp16xx/dsp16xx.c, config/dsp16xx/dsp16xx.h, config/frv/frv.c, config/frv/frv.h, config/h8300/h8300.c, config/h8300/h8300.h, config/i370/i370.c, config/i370/i370.h, config/i386/i386.c, config/i386/i386.h, config/i960/i960.c, config/i960/i960.h, config/ia64/ia64.c, config/ia64/ia64.h, config/m32r/m32r.c, config/m32r/m32r.h, config/m68k/m68k.c, config/m68k/m68k.h, config/m88k/m88k.c, config/m88k/m88k.h, config/mcore/mcore.c, config/mcore/mcore.h, config/mips/mips.c, config/mips/mips.h, config/mn10200/mn10200.c, config/mn10200/mn10200.h, config/mn10300/mn10300.c, config/mn10300/mn10300.h, config/ns32k/ns32k.c, config/ns32k/ns32k.h, config/pa/pa.c, config/pa/pa.h, config/pdp11/pdp11.c, config/pdp11/pdp11.h, config/romp/romp.c, config/romp/romp.h, config/rs6000/rs6000.c, config/rs6000/rs6000.h, config/s390/s390.c, config/s390/s390.h, config/sh/sh.c, config/sh/sh.h, config/stormy16/stormy16.c, config/stormy16/stormy16.h, config/v850/v850.c, config/v850/v850.h, config/xtensa/xtensa.c, config/xtensa/xtensa.h (CONST_COSTS, RTX_COSTS): Move code ... (foo_rtx_costs, TARGET_RTX_COSTS): ... here. * config/arm/arm.c (arm_rtx_costs_1): Rename from arm_rtx_costs. (arm_rtx_costs, TARGET_RTX_COSTS): New. * config/arm/arm-protos.h: Update. * config/arm/arm.h (DEFAULT_RTX_COSTS): Remove. * config/avr/avr.h (CONST_COSTS): Move code ... * config/avr/avr.c (avr_rtx_costs): ... here. (default_rtx_costs): Make static. * config/avr/avr-protos.h: Update. * config/h8300/h8300.c (const_costs): Make static. (h8300_and_costs, h8300_shift_costs): Likewise. * config/h8300/h8300-protos.h: Update. * config/ip2k/ip2k.h (DEFAULT_RTX_COSTS): Remove. (CONST_COSTS): Move code ... * config/ip2k/ip2k.c (ip2k_rtx_costs): ... here. Rename from default_rtx_costs; update for signature change. * config/ip2k/ip2k-protos.h: Update. * config/m68hc11/m68hc11.h (RTX_COSTS): Remove. (CONST_COSTS): Move code ... * config/m68hc11/m68hc11.c (m68hc11_rtx_costs): ... here. (TARGET_RTX_COSTS): New. (m68hc11_rtx_costs_1): Rename from m68hc11_rtx_costs; make static. * config/m68hc11/m68hc11-protos.h: Update. * config/m68k/m68k.c (const_int_cost): Make static. * config/m68k/m68k-protos.h: Update. * config/mcore/mcore.c (mcore_const_costs): Make static. (mcore_and_cost, mcore_ior_cost): Likewise. * config/mcore/mcore-protos.h: Update. * config/mmix/mmix.c (mmix_rtx_costs, TARGET_RTX_COSTS): New. (mmix_rtx_cost_recalculated): Remove. * config/mmix/mmix.h (DEFAULT_RTX_COSTS): Remove. * config/mmix/mmix-protos.h: Update. * config/sh/sh.c (shiftcosts): Make static. (addsubcosts, andcosts, multcosts): Likewise. * config/sh/sh-protos.h: Update. * config/sparc/sparc.c (TARGET_RTX_COSTS): New. (sparc_rtx_costs): Make static; update for change in signature. * config/sparc/sparc.h (RTX_COSTS_CASES, RTX_COSTS): Remove. * config/sparc/sparc-protos.h: Update. * config/v850/v850.c (const_costs): Make static. * config/v850/v850-protos.h: Update. * config/vax/vax.h (RTX_COSTS): Remove. (CONST_COSTS): Move code ... * config/vax/vax.c (vax_rtx_costs_1): ... here; rename from vax_rtx_cost. (vax_rtx_costs, TARGET_RTX_COSTS): New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@61954 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/config/xtensa/xtensa.c | 216 +++++++++++++++++++++++++++++++++++++++++++++ gcc/config/xtensa/xtensa.h | 147 ------------------------------ 2 files changed, 216 insertions(+), 147 deletions(-) (limited to 'gcc/config/xtensa') diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c index c0d0ab0780d..645ad1adbfd 100644 --- a/gcc/config/xtensa/xtensa.c +++ b/gcc/config/xtensa/xtensa.c @@ -204,6 +204,7 @@ static unsigned int xtensa_multibss_section_type_flags static void xtensa_select_rtx_section PARAMS ((enum machine_mode, rtx, unsigned HOST_WIDE_INT)); static void xtensa_encode_section_info PARAMS ((tree, int)); +static bool xtensa_rtx_costs PARAMS ((rtx, int, int, int *)); static rtx frame_size_const; static int current_function_arg_words; @@ -240,6 +241,9 @@ static const int reg_nonleaf_alloc_order[FIRST_PSEUDO_REGISTER] = #undef TARGET_ENCODE_SECTION_INFO #define TARGET_ENCODE_SECTION_INFO xtensa_encode_section_info +#undef TARGET_RTX_COSTS +#define TARGET_RTX_COSTS xtensa_rtx_costs + struct gcc_target targetm = TARGET_INITIALIZER; @@ -2838,4 +2842,216 @@ xtensa_encode_section_info (decl, first) SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)) = 1; } +/* 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 +xtensa_rtx_costs (x, code, outer_code, total) + rtx x; + int code, outer_code; + int *total; +{ + switch (code) + { + case CONST_INT: + switch (outer_code) + { + case SET: + if (xtensa_simm12b (INTVAL (x))) + { + *total = 4; + return true; + } + break; + case PLUS: + if (xtensa_simm8 (INTVAL (x)) + || xtensa_simm8x256 (INTVAL (x))) + { + *total = 0; + return true; + } + break; + case AND: + if (xtensa_mask_immediate (INTVAL (x))) + { + *total = 0; + return true; + } + break; + case COMPARE: + if ((INTVAL (x) == 0) || xtensa_b4const (INTVAL (x))) + { + *total = 0; + return true; + } + break; + case ASHIFT: + case ASHIFTRT: + case LSHIFTRT: + case ROTATE: + case ROTATERT: + /* no way to tell if X is the 2nd operand so be conservative */ + default: break; + } + if (xtensa_simm12b (INTVAL (x))) + *total = 5; + else + *total = 6; + return true; + + case CONST: + case LABEL_REF: + case SYMBOL_REF: + *total = 5; + return true; + + case CONST_DOUBLE: + *total = 7; + return true; + + case MEM: + { + int num_words = + (GET_MODE_SIZE (GET_MODE (x)) > UNITS_PER_WORD) ? 2 : 1; + + if (memory_address_p (GET_MODE (x), XEXP ((x), 0))) + *total = COSTS_N_INSNS (num_words); + else + *total = COSTS_N_INSNS (2*num_words); + return true; + } + + case FFS: + *total = COSTS_N_INSNS (TARGET_NSA ? 5 : 50); + return true; + + case NOT: + *total = COSTS_N_INSNS ((GET_MODE (x) == DImode) ? 3 : 2); + return true; + + case AND: + case IOR: + case XOR: + if (GET_MODE (x) == DImode) + *total = COSTS_N_INSNS (2); + else + *total = COSTS_N_INSNS (1); + return true; + + case ASHIFT: + case ASHIFTRT: + case LSHIFTRT: + if (GET_MODE (x) == DImode) + *total = COSTS_N_INSNS (50); + else + *total = COSTS_N_INSNS (1); + return true; + + case ABS: + { + enum machine_mode xmode = GET_MODE (x); + if (xmode == SFmode) + *total = COSTS_N_INSNS (TARGET_HARD_FLOAT ? 1 : 50); + else if (xmode == DFmode) + *total = COSTS_N_INSNS (50); + else + *total = COSTS_N_INSNS (4); + return true; + } + + case PLUS: + case MINUS: + { + enum machine_mode xmode = GET_MODE (x); + if (xmode == SFmode) + *total = COSTS_N_INSNS (TARGET_HARD_FLOAT ? 1 : 50); + else if (xmode == DFmode || xmode == DImode) + *total = COSTS_N_INSNS (50); + else + *total = COSTS_N_INSNS (1); + return true; + } + + case NEG: + *total = COSTS_N_INSNS ((GET_MODE (x) == DImode) ? 4 : 2); + return true; + + case MULT: + { + enum machine_mode xmode = GET_MODE (x); + if (xmode == SFmode) + *total = COSTS_N_INSNS (TARGET_HARD_FLOAT ? 4 : 50); + else if (xmode == DFmode || xmode == DImode) + *total = COSTS_N_INSNS (50); + else if (TARGET_MUL32) + *total = COSTS_N_INSNS (4); + else if (TARGET_MAC16) + *total = COSTS_N_INSNS (16); + else if (TARGET_MUL16) + *total = COSTS_N_INSNS (12); + else + *total = COSTS_N_INSNS (50); + return true; + } + + case DIV: + case MOD: + { + enum machine_mode xmode = GET_MODE (x); + if (xmode == SFmode) + { + *total = COSTS_N_INSNS (TARGET_HARD_FLOAT_DIV ? 8 : 50); + return true; + } + else if (xmode == DFmode) + { + *total = COSTS_N_INSNS (50); + return true; + } + } + /* fall through */ + + case UDIV: + case UMOD: + { + enum machine_mode xmode = GET_MODE (x); + if (xmode == DImode) + *total = COSTS_N_INSNS (50); + else if (TARGET_DIV32) + *total = COSTS_N_INSNS (32); + else + *total = COSTS_N_INSNS (50); + return true; + } + + case SQRT: + if (GET_MODE (x) == SFmode) + *total = COSTS_N_INSNS (TARGET_HARD_FLOAT_SQRT ? 8 : 50); + else + *total = COSTS_N_INSNS (50); + return true; + + case SMIN: + case UMIN: + case SMAX: + case UMAX: + *total = COSTS_N_INSNS (TARGET_MINMAX ? 1 : 50); + return true; + + case SIGN_EXTRACT: + case SIGN_EXTEND: + *total = COSTS_N_INSNS (TARGET_SEXT ? 1 : 2); + return true; + + case ZERO_EXTRACT: + case ZERO_EXTEND: + *total = COSTS_N_INSNS (1); + return true; + + default: + return false; + } +} + #include "gt-xtensa.h" diff --git a/gcc/config/xtensa/xtensa.h b/gcc/config/xtensa/xtensa.h index d51b6795a34..3ae66f1240e 100644 --- a/gcc/config/xtensa/xtensa.h +++ b/gcc/config/xtensa/xtensa.h @@ -1281,153 +1281,6 @@ typedef struct xtensa_args { indexing purposes) so give the MEM rtx a words's mode. */ #define FUNCTION_MODE SImode -/* Xtensa constant costs. */ -#define CONST_COSTS(X, CODE, OUTER_CODE) \ - case CONST_INT: \ - switch (OUTER_CODE) \ - { \ - case SET: \ - if (xtensa_simm12b (INTVAL (X))) return 4; \ - break; \ - case PLUS: \ - if (xtensa_simm8 (INTVAL (X))) return 0; \ - if (xtensa_simm8x256 (INTVAL (X))) return 0; \ - break; \ - case AND: \ - if (xtensa_mask_immediate (INTVAL (X))) return 0; \ - break; \ - case COMPARE: \ - if ((INTVAL (X) == 0) || xtensa_b4const (INTVAL (X))) return 0; \ - break; \ - case ASHIFT: \ - case ASHIFTRT: \ - case LSHIFTRT: \ - case ROTATE: \ - case ROTATERT: \ - /* no way to tell if X is the 2nd operand so be conservative */ \ - default: break; \ - } \ - if (xtensa_simm12b (INTVAL (X))) return 5; \ - return 6; \ - case CONST: \ - case LABEL_REF: \ - case SYMBOL_REF: \ - return 5; \ - case CONST_DOUBLE: \ - return 7; - -/* Costs of various Xtensa operations. */ -#define RTX_COSTS(X, CODE, OUTER_CODE) \ - case MEM: \ - { \ - int num_words = \ - (GET_MODE_SIZE (GET_MODE (X)) > UNITS_PER_WORD) ? 2 : 1; \ - if (memory_address_p (GET_MODE (X), XEXP ((X), 0))) \ - return COSTS_N_INSNS (num_words); \ - \ - return COSTS_N_INSNS (2*num_words); \ - } \ - \ - case FFS: \ - return COSTS_N_INSNS (TARGET_NSA ? 5 : 50); \ - \ - case NOT: \ - return COSTS_N_INSNS ((GET_MODE (X) == DImode) ? 3 : 2); \ - \ - case AND: \ - case IOR: \ - case XOR: \ - if (GET_MODE (X) == DImode) return COSTS_N_INSNS (2); \ - return COSTS_N_INSNS (1); \ - \ - case ASHIFT: \ - case ASHIFTRT: \ - case LSHIFTRT: \ - if (GET_MODE (X) == DImode) return COSTS_N_INSNS (50); \ - return COSTS_N_INSNS (1); \ - \ - case ABS: \ - { \ - enum machine_mode xmode = GET_MODE (X); \ - if (xmode == SFmode) \ - return COSTS_N_INSNS (TARGET_HARD_FLOAT ? 1 : 50); \ - if (xmode == DFmode) \ - return COSTS_N_INSNS (50); \ - return COSTS_N_INSNS (4); \ - } \ - \ - case PLUS: \ - case MINUS: \ - { \ - enum machine_mode xmode = GET_MODE (X); \ - if (xmode == SFmode) \ - return COSTS_N_INSNS (TARGET_HARD_FLOAT ? 1 : 50); \ - if (xmode == DFmode || xmode == DImode) \ - return COSTS_N_INSNS (50); \ - return COSTS_N_INSNS (1); \ - } \ - \ - case NEG: \ - return COSTS_N_INSNS ((GET_MODE (X) == DImode) ? 4 : 2); \ - \ - case MULT: \ - { \ - enum machine_mode xmode = GET_MODE (X); \ - if (xmode == SFmode) \ - return COSTS_N_INSNS (TARGET_HARD_FLOAT ? 4 : 50); \ - if (xmode == DFmode || xmode == DImode) \ - return COSTS_N_INSNS (50); \ - if (TARGET_MUL32) \ - return COSTS_N_INSNS (4); \ - if (TARGET_MAC16) \ - return COSTS_N_INSNS (16); \ - if (TARGET_MUL16) \ - return COSTS_N_INSNS (12); \ - return COSTS_N_INSNS (50); \ - } \ - \ - case DIV: \ - case MOD: \ - { \ - enum machine_mode xmode = GET_MODE (X); \ - if (xmode == SFmode) \ - return COSTS_N_INSNS (TARGET_HARD_FLOAT_DIV ? 8 : 50); \ - if (xmode == DFmode) \ - return COSTS_N_INSNS (50); \ - } \ - /* fall through */ \ - \ - case UDIV: \ - case UMOD: \ - { \ - enum machine_mode xmode = GET_MODE (X); \ - if (xmode == DImode) \ - return COSTS_N_INSNS (50); \ - if (TARGET_DIV32) \ - return COSTS_N_INSNS (32); \ - return COSTS_N_INSNS (50); \ - } \ - \ - case SQRT: \ - if (GET_MODE (X) == SFmode) \ - return COSTS_N_INSNS (TARGET_HARD_FLOAT_SQRT ? 8 : 50); \ - return COSTS_N_INSNS (50); \ - \ - case SMIN: \ - case UMIN: \ - case SMAX: \ - case UMAX: \ - return COSTS_N_INSNS (TARGET_MINMAX ? 1 : 50); \ - \ - case SIGN_EXTRACT: \ - case SIGN_EXTEND: \ - return COSTS_N_INSNS (TARGET_SEXT ? 1 : 2); \ - \ - case ZERO_EXTRACT: \ - case ZERO_EXTEND: \ - return COSTS_N_INSNS (1); - - /* An expression giving the cost of an addressing mode that contains ADDRESS. */ #define ADDRESS_COST(ADDR) 1 -- cgit v1.2.1