diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-01-28 04:46:33 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-01-28 04:46:33 +0000 |
commit | fab7adbfb5b8861f87531f939ad03f891bba055a (patch) | |
tree | 1eaff917ba37b6f409082db1a76c42c218320c5e /gcc/config/cris | |
parent | bb5d2966d86c25ca14d0d12cb96249b8069e0ab1 (diff) | |
download | gcc-fab7adbfb5b8861f87531f939ad03f891bba055a.tar.gz |
* 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
Diffstat (limited to 'gcc/config/cris')
-rw-r--r-- | gcc/config/cris/cris.c | 109 | ||||
-rw-r--r-- | gcc/config/cris/cris.h | 67 |
2 files changed, 109 insertions, 67 deletions
diff --git a/gcc/config/cris/cris.c b/gcc/config/cris/cris.c index 0aeccc01636..6842dfebda0 100644 --- a/gcc/config/cris/cris.c +++ b/gcc/config/cris/cris.c @@ -2082,6 +2082,115 @@ cris_simple_epilogue () return 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 +cris_rtx_costs (x, code, outer_code, total) + rtx x; + int code, outer_code; + int *total; +{ + switch (code) + { + case CONST_INT: + { + HOST_WIDE_INT val = INTVAL (x); + if (val == 0) + *total = 0; + else if (val < 32 && val >= -32) + *total = 1; + /* Eight or 16 bits are a word and cycle more expensive. */ + else if (val <= 32767 && val >= -32768) + *total = 2; + /* A 32 bit constant (or very seldom, unsigned 16 bits) costs + another word. FIXME: This isn't linear to 16 bits. */ + else + *total = 4; + return true; + } + + case LABEL_REF: + *total = 6; + return true; + + case CONST: + case SYMBOL_REF: + /* For PIC, we need a prefix (if it isn't already there), + and the PIC register. For a global PIC symbol, we also + need a read of the GOT. */ + if (flag_pic) + if (cris_got_symbol (x)) + *total = 2 + 4 + 6; + else + *total = 2 + 6; + else + *total = 6; + return true; + + case CONST_DOUBLE: + if (x != CONST0_RTX (GET_MODE (x) == VOIDmode ? DImode : GET_MODE (x))) + *total = 12; + else + /* Make 0.0 cheap, else test-insns will not be used. */ + *total = 0; + return true; + + case MULT: + /* Identify values that are no powers of two. Powers of 2 are + taken care of already and those values should not be changed. */ + if (GET_CODE (XEXP (x, 1)) != CONST_INT + || exact_log2 (INTVAL (XEXP (x, 1)) < 0)) + { + /* If we have a multiply insn, then the cost is between + 1 and 2 "fast" instructions. */ + if (TARGET_HAS_MUL_INSNS) + { + *total = COSTS_N_INSNS (1) + COSTS_N_INSNS (1) / 2; + return true; + } + + /* Estimate as 4 + 4 * #ofbits. */ + *total = COSTS_N_INSNS (132); + return true; + } + return false; + + case UDIV: + case MOD: + case UMOD: + case DIV: + if (GET_CODE (XEXP (x, 1)) != CONST_INT + || exact_log2 (INTVAL (XEXP (X, 1)) < 0)) + { + /* Estimate this as 4 + 8 * #of bits. */ + *total = COSTS_N_INSNS (260); + return true; + } + return false; + + case AND: + if (GET_CODE (XEXP (x, 1)) == CONST_INT + /* Two constants may actually happen before optimization. */ + && GET_CODE (XEXP (x, 0)) != CONST_INT + && !CONST_OK_FOR_LETTER_P (INTVAL (XEXP (x, 1)), 'I')) + { + *total = (rtx_cost (XEXP (x, 0), outer_code) + 2 + + 2 * GET_MODE_NUNITS (GET_MODE (XEXP (x, 0)))); + return true; + } + return false; + + case ZERO_EXTEND: case SIGN_EXTEND: + *total = rtx_cost (XEXP (x, 0), outer_code); + return true; + + default: + return false; + } +} + /* The ADDRESS_COST worker. */ int diff --git a/gcc/config/cris/cris.h b/gcc/config/cris/cris.h index bd044f3a51a..38449c7bc81 100644 --- a/gcc/config/cris/cris.h +++ b/gcc/config/cris/cris.h @@ -1336,73 +1336,6 @@ struct cum_args {int regs;}; /* Node: Costs */ -#define CONST_COSTS(RTX, CODE, OUTER_CODE) \ - case CONST_INT: \ - if (INTVAL (RTX) == 0) \ - return 0; \ - if (INTVAL (RTX) < 32 && INTVAL (RTX) >= -32) \ - return 1; \ - /* Eight or 16 bits are a word and cycle more expensive. */ \ - if (INTVAL (RTX) <= 32767 && INTVAL (RTX) >= -32768) \ - return 2; \ - /* A 32 bit constant (or very seldom, unsigned 16 bits) costs \ - another word. FIXME: This isn't linear to 16 bits. */ \ - return 4; \ - case LABEL_REF: \ - return 6; \ - case CONST: \ - case SYMBOL_REF: \ - /* For PIC, we need a prefix (if it isn't already there), \ - and the PIC register. For a global PIC symbol, we also need a \ - read of the GOT. */ \ - return \ - flag_pic ? (cris_got_symbol (RTX) ? (2 + 4 + 6) : (2 + 6)) : 6; \ - case CONST_DOUBLE: \ - if (RTX != CONST0_RTX (GET_MODE (RTX) == VOIDmode ? DImode \ - : GET_MODE (RTX))) \ - return 12; \ - /* Make 0.0 cheap, else test-insns will not be used. */ \ - return 0; - -#define RTX_COSTS(X, CODE, OUTER_CODE) \ - case MULT: \ - /* Identify values that are no powers of two. Powers of 2 are \ - taken care of already and those values should not be \ - changed. */ \ - if (GET_CODE (XEXP (X, 1)) != CONST_INT \ - || exact_log2 (INTVAL (XEXP (X, 1)) < 0)) \ - { \ - /* If we have a multiply insn, then the cost is between \ - 1 and 2 "fast" instructions. */ \ - if (TARGET_HAS_MUL_INSNS) \ - return COSTS_N_INSNS (1) + COSTS_N_INSNS (1) /2; \ - \ - /* Estimate as 4 + 4 * #ofbits. */ \ - return COSTS_N_INSNS (132); \ - } \ - break; \ - case UDIV: \ - case MOD: \ - case UMOD: \ - case DIV: \ - if (GET_CODE (XEXP (X, 1)) != CONST_INT \ - || exact_log2 (INTVAL (XEXP (X, 1)) < 0)) \ - /* Estimate this as 4 + 8 * #of bits. */ \ - return COSTS_N_INSNS (260); \ - \ - case AND: \ - if (GET_CODE (XEXP (X, 1)) == CONST_INT \ - /* Two constants may actually happen before optimization. */ \ - && GET_CODE (XEXP (X, 0)) != CONST_INT \ - && !CONST_OK_FOR_LETTER_P (INTVAL (XEXP (X, 1)), 'I')) \ - return \ - rtx_cost (XEXP (X, 0), OUTER_CODE) + 2 \ - + 2 * GET_MODE_NUNITS (GET_MODE (XEXP (X, 0))); \ - \ - case ZERO_EXTEND: case SIGN_EXTEND: \ - /* Same as move. If embedded in other insn, cost is 0. */ \ - return rtx_cost (XEXP (X, 0), OUTER_CODE); - #define ADDRESS_COST(X) cris_address_cost (X) /* FIXME: Need to define REGISTER_MOVE_COST when more register classes are |