diff options
Diffstat (limited to 'gcc/config/pdp11')
-rw-r--r-- | gcc/config/pdp11/pdp11.c | 114 | ||||
-rw-r--r-- | gcc/config/pdp11/pdp11.h | 105 |
2 files changed, 114 insertions, 105 deletions
diff --git a/gcc/config/pdp11/pdp11.c b/gcc/config/pdp11/pdp11.c index d2f25ca6a29..23150965151 100644 --- a/gcc/config/pdp11/pdp11.c +++ b/gcc/config/pdp11/pdp11.c @@ -59,6 +59,7 @@ static const char *singlemove_string PARAMS ((rtx *)); static bool pdp11_assemble_integer PARAMS ((rtx, unsigned int, int)); static void pdp11_output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT)); static void pdp11_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT)); +static bool pdp11_rtx_costs PARAMS ((rtx, int, int, int *)); /* Initialize the GCC target structure. */ #undef TARGET_ASM_BYTE_OP @@ -80,6 +81,9 @@ static void pdp11_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT)); #undef TARGET_ASM_CLOSE_PAREN #define TARGET_ASM_CLOSE_PAREN "]" +#undef TARGET_RTX_COSTS +#define TARGET_RTX_COSTS pdp11_rtx_costs + struct gcc_target targetm = TARGET_INITIALIZER; /* Nonzero if OP is a valid second operand for an arithmetic insn. */ @@ -1015,6 +1019,116 @@ register_move_cost(c1, c2) return move_costs[(int)c1][(int)c2]; } +static bool +pdp11_rtx_costs (x, code, outer_code, total) + rtx x; + int code, outer_code ATTRIBUTE_UNUSED; + int *total; +{ + switch (code) + { + case CONST_INT: + if (INTVAL (x) == 0 || INTVAL (x) == -1 || INTVAL (x) == 1) + { + *total = 0; + return true; + } + /* FALLTHRU */ + + case CONST: + case LABEL_REF: + case SYMBOL_REF: + /* Twice as expensive as REG. */ + *total = 2; + return true; + + case CONST_DOUBLE: + /* Twice (or 4 times) as expensive as 16 bit. */ + *total = 4; + return true; + + case MULT: + /* ??? There is something wrong in MULT because MULT is not + as cheap as total = 2 even if we can shift! */ + /* If optimizing for size make mult etc cheap, but not 1, so when + in doubt the faster insn is chosen. */ + if (optimize_size) + *total = COSTS_N_INSNS (2); + else + *total = COSTS_N_INSNS (11); + return false; + + case DIV: + if (optimize_size) + *total = COSTS_N_INSNS (2); + else + *total = COSTS_N_INSNS (25); + return false; + + case MOD: + if (optimize_size) + *total = COSTS_N_INSNS (2); + else + *total = COSTS_N_INSNS (26); + return false; + + case ABS: + /* Equivalent to length, so same for optimize_size. */ + *total = COSTS_N_INSNS (3); + return false; + + case ZERO_EXTEND: + /* Only used for qi->hi. */ + *total = COSTS_N_INSNS (1); + return false; + + case SIGN_EXTEND: + if (GET_MODE (x) == HImode) + *total = COSTS_N_INSNS (1); + else if (GET_MODE (x) == SImode) + *total = COSTS_N_INSNS (6); + else + *total = COSTS_N_INSNS (2); + return false; + + case ASHIFT: + case LSHIFTRT: + case ASHIFTRT: + if (optimize_size) + *total = COSTS_N_INSNS (1); + else if (GET_MODE (x) == QImode) + { + if (GET_CODE (XEXP (x, 1)) != CONST_INT) + *total = COSTS_N_INSNS (8); /* worst case */ + else + *total = COSTS_N_INSNS (INTVAL (XEXP (x, 1))); + } + else if (GET_MODE (x) == HImode) + { + if (GET_CODE (XEXP (x, 1)) == CONST_INT) + { + if (abs (INTVAL (XEXP (x, 1))) == 1) + *total = COSTS_N_INSNS (1); + else + *total = COSTS_N_INSNS (2.5 + 0.5 * INTVAL (XEXP (x, 1))); + } + else + *total = COSTS_N_INSNS (10); /* worst case */ + } + else if (GET_MODE (x) == SImode) + { + if (GET_CODE (XEXP (x, 1)) == CONST_INT) + *total = COSTS_N_INSNS (2.5 + 0.5 * INTVAL (XEXP (x, 1))); + else /* worst case */ + *total = COSTS_N_INSNS (18); + } + return false; + + default: + return false; + } +} + const char * output_jump(pos, neg, length) const char *pos, *neg; diff --git a/gcc/config/pdp11/pdp11.h b/gcc/config/pdp11/pdp11.h index f9eb3f0e96a..147b6ba67ce 100644 --- a/gcc/config/pdp11/pdp11.h +++ b/gcc/config/pdp11/pdp11.h @@ -934,28 +934,6 @@ extern int may_call_alloca; but a CALL with constant address is cheap. */ /* #define NO_FUNCTION_CSE */ -/* Compute the cost of computing a constant rtl expression RTX - whose rtx-code is CODE. The body of this macro is a portion - of a switch statement. If the code is computed here, - return it with a return statement. Otherwise, break from the switch. - - -1, 0, 1 are cheaper for add, sub ... -*/ - -#define CONST_COSTS(RTX,CODE,OUTER_CODE) \ - case CONST_INT: \ - if (INTVAL(RTX) == 0 \ - || INTVAL(RTX) == -1 \ - || INTVAL(RTX) == 1) \ - return 0; \ - case CONST: \ - case LABEL_REF: \ - case SYMBOL_REF: \ - /* twice as expensive as REG */ \ - return 2; \ - case CONST_DOUBLE: \ - /* twice (or 4 times) as expensive as 16 bit */ \ - return 4; /* cost of moving one register class to another */ #define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2) \ @@ -1212,89 +1190,6 @@ JMP FUNCTION 0x0058 0x0000 <- FUNCTION } \ } - -/* Provide the costs of a rtl expression. This is in the body of a - switch on CODE. - - we don't say how expensive SImode is - pretty expensive!!! - - there is something wrong in MULT because MULT is not - as cheap as total = 2 even if we can shift! - - if optimizing for size make mult etc cheap, but not 1, so when - in doubt the faster insn is chosen. -*/ - -#define RTX_COSTS(X,CODE,OUTER_CODE) \ - case MULT: \ - if (optimize_size) \ - total = COSTS_N_INSNS(2); \ - else \ - total = COSTS_N_INSNS (11); \ - break; \ - case DIV: \ - if (optimize_size) \ - total = COSTS_N_INSNS(2); \ - else \ - total = COSTS_N_INSNS (25); \ - break; \ - case MOD: \ - if (optimize_size) \ - total = COSTS_N_INSNS(2); \ - else \ - total = COSTS_N_INSNS (26); \ - break; \ - case ABS: \ - /* equivalent to length, so same for optimize_size */ \ - total = COSTS_N_INSNS (3); \ - break; \ - case ZERO_EXTEND: \ - /* only used for: qi->hi */ \ - total = COSTS_N_INSNS(1); \ - break; \ - case SIGN_EXTEND: \ - if (GET_MODE(X) == HImode) \ - total = COSTS_N_INSNS(1); \ - else if (GET_MODE(X) == SImode) \ - total = COSTS_N_INSNS(6); \ - else \ - total = COSTS_N_INSNS(2); \ - break; \ - /* case LSHIFT: */ \ - case ASHIFT: \ - case LSHIFTRT: \ - case ASHIFTRT: \ - if (optimize_size) \ - total = COSTS_N_INSNS(1); \ - else if (GET_MODE(X) == QImode) \ - { \ - if (GET_CODE(XEXP (X,1)) != CONST_INT) \ - total = COSTS_N_INSNS(8); /* worst case */ \ - else \ - total = COSTS_N_INSNS(INTVAL(XEXP (X,1))); \ - } \ - else if (GET_MODE(X) == HImode) \ - { \ - if (GET_CODE(XEXP (X,1)) == CONST_INT) \ - { \ - if (abs (INTVAL (XEXP (X, 1))) == 1) \ - total = COSTS_N_INSNS(1); \ - else \ - total = COSTS_N_INSNS(2.5 + 0.5 *INTVAL(XEXP(X,1))); \ - } \ - else /* worst case */ \ - total = COSTS_N_INSNS (10); \ - } \ - else if (GET_MODE(X) == SImode) \ - { \ - if (GET_CODE(XEXP (X,1)) == CONST_INT) \ - total = COSTS_N_INSNS(2.5 + 0.5 *INTVAL(XEXP(X,1))); \ - else /* worst case */ \ - total = COSTS_N_INSNS(18); \ - } \ - break; - - /* there is no point in avoiding branches on a pdp, since branches are really cheap - I just want to find out how much difference the BRANCH_COST macro makes in code */ |