sparc-protos.h (sparc_rtx_costs): New.
authorDavid S. Miller <davem@redhat.com>
Sat, 4 May 2002 05:36:40 +0000 (22:36 -0700)
committerDavid S. Miller <davem@gcc.gnu.org>
Sat, 4 May 2002 05:36:40 +0000 (22:36 -0700)
2002-05-03  David S. Miller  <davem@redhat.com>

* config/sparc/sparc-protos.h (sparc_rtx_costs): New.
* config/sparc/sparc.c (sparc_rtx_costs): New function
implementing RTX_COSTS and CONST_COSTS.
* config/sparc/sparc.h (CONST_COSTS): Delete.
(RTX_COSTS_CASES): Define.
(RTX_COSTS): Expand RTX_COSTS_CASES and use sparc_rtx_costs to do
the work.

From-SVN: r53147

gcc/ChangeLog
gcc/config/sparc/sparc-protos.h
gcc/config/sparc/sparc.c
gcc/config/sparc/sparc.h

index df9380a1f49f6c340ee5e6106f80bf81e18b0378..144f74499d5bc55587ebfa8ba46a1de13e5b3c63 100644 (file)
@@ -1,5 +1,13 @@
 2002-05-03  David S. Miller  <davem@redhat.com>
 
+       * config/sparc/sparc-protos.h (sparc_rtx_costs): New.
+       * config/sparc/sparc.c (sparc_rtx_costs): New function
+       implementing RTX_COSTS and CONST_COSTS.
+       * config/sparc/sparc.h (CONST_COSTS): Delete.
+       (RTX_COSTS_CASES): Define.
+       (RTX_COSTS): Expand RTX_COSTS_CASES and use sparc_rtx_costs to do
+       the work.
+
        * config/sparc/sparc.md (DFA schedulers): Split out...
        * config/sparc/cypress.md, config/sparc/hypersparc.md,
        config/sparc/sparclet.md, config/sparc/supersparc.md,
index fd372ded33cae4440b6068b7fee64d4987631bf6..427aaba18640bd4108df1e77c60549b57c480179 100644 (file)
@@ -121,6 +121,7 @@ extern char *sparc_v8plus_shift PARAMS ((rtx *, rtx, const char *));
 extern int sparc_check_64 PARAMS ((rtx, rtx));
 extern rtx gen_df_reg PARAMS ((rtx, int));
 extern int sparc_extra_constraint_check PARAMS ((rtx, int, int));
+extern int sparc_rtx_costs PARAMS ((rtx, enum rtx_code, enum rtx_code));
 #endif /* RTX_CODE */
 
 #endif /* __SPARC_PROTOS_H__ */
index 11e7ceca30f5cb13d0b236d8d6022c311f32a2e2..0405726969f1284eceaf958852261d7bf0091e3a 100644 (file)
@@ -8085,3 +8085,68 @@ sparc_extra_constraint_check (op, c, strict)
 
   return reload_ok_mem;
 }
+
+int
+sparc_rtx_costs (x, code, outer_code)
+     rtx x;
+     enum rtx_code code, outer_code;
+{
+  switch (code)
+    {
+    case MULT:
+      if (sparc_cpu == PROCESSOR_ULTRASPARC)
+       return (GET_MODE (x) == DImode ?
+               COSTS_N_INSNS (34) : COSTS_N_INSNS (19));
+
+      if (sparc_cpu == PROCESSOR_ULTRASPARC3)
+       return COSTS_N_INSNS (6);
+
+      return (TARGET_HARD_MUL
+             ? COSTS_N_INSNS (5)
+             : COSTS_N_INSNS (25));
+
+    case DIV:
+    case UDIV:
+    case MOD:
+    case UMOD:
+      if (sparc_cpu == PROCESSOR_ULTRASPARC)
+       return (GET_MODE (x) == DImode ?
+               COSTS_N_INSNS (68) : COSTS_N_INSNS (37));
+      if (sparc_cpu == PROCESSOR_ULTRASPARC3)
+       return (GET_MODE (x) == DImode ?
+               COSTS_N_INSNS (71) : COSTS_N_INSNS (40));
+      return COSTS_N_INSNS (25);
+
+      /* Make FLOAT and FIX more expensive than CONST_DOUBLE,
+        so that cse will favor the latter.  */
+    case FLOAT:
+    case FIX:
+      return 19;
+
+    case CONST_INT:
+      if (INTVAL (x) < 0x1000 && INTVAL (x) >= -0x1000)
+       return 0;
+
+    /* fallthru */
+    case HIGH:
+      return 2;
+
+    case CONST:
+    case LABEL_REF:
+    case SYMBOL_REF:
+      return 4;
+
+    case CONST_DOUBLE:
+      if (GET_MODE (x) == DImode)
+       if ((XINT (x, 3) == 0
+            && (unsigned) XINT (x, 2) < 0x1000)
+           || (XINT (x, 3) == -1
+               && XINT (x, 2) < 0
+               && XINT (x, 2) >= -0x1000))
+         return 0;
+      return 8;
+
+    default:
+      abort();
+    };
+}
index f807be89e54ce4b2691400d4a826508c612e95f0..fd6312a6b45f2e12f0ed05b0ddebcad795521e8b 100644 (file)
@@ -2645,33 +2645,6 @@ do {                                                                    \
    of the libgcc2 functions is used.  */
 #define FLOAT_LIB_COMPARE_RETURNS_BOOL(MODE, COMPARISON) ((MODE) == TFmode)
 
-/* 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.  */
-
-#define CONST_COSTS(RTX,CODE,OUTER_CODE) \
-  case CONST_INT:                                              \
-    if (INTVAL (RTX) < 0x1000 && INTVAL (RTX) >= -0x1000)      \
-      return 0;                                                        \
-  case HIGH:                                                   \
-    return 2;                                                  \
-  case CONST:                                                  \
-  case LABEL_REF:                                              \
-  case SYMBOL_REF:                                             \
-    return 4;                                                  \
-  case CONST_DOUBLE:                                           \
-    if (GET_MODE (RTX) == DImode)                              \
-      if ((XINT (RTX, 3) == 0                                  \
-          && (unsigned) XINT (RTX, 2) < 0x1000)                \
-         || (XINT (RTX, 3) == -1                               \
-             && XINT (RTX, 2) < 0                              \
-             && XINT (RTX, 2) >= -0x1000))                     \
-       return 0;                                               \
-    return 8;
-
-#define ADDRESS_COST(RTX)  1
-
 /* Compute extra cost of moving data between one register class
    and another.  */
 #define GENERAL_OR_I64(C) ((C) == GENERAL_REGS || (C) == I64_REGS)
@@ -2699,37 +2672,22 @@ do {                                                                    \
          : (sparc_cpu == PROCESSOR_ULTRASPARC3 \
             ? 9 : 3))
 
-/* Provide the costs of a rtl expression.  This is in the body of a
-   switch on CODE.  The purpose for the cost of MULT is to encourage
-   `synth_mult' to find a synthetic multiply when reasonable.
+/* The cases that RTX_COSTS handles.  */
 
-   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.  */
+#define RTX_COSTS_CASES        \
+case MULT: case DIV: case UDIV: case MOD: case UMOD: \
+case FLOAT: case FIX: \
+case CONST_INT: case HIGH: case CONST: \
+case LABEL_REF: case SYMBOL_REF: case CONST_DOUBLE:
+
+/* Provide the costs of a rtl expression.  This is in the body of a
+   switch on CODE.  */
 
 #define RTX_COSTS(X,CODE,OUTER_CODE)                   \
-  case MULT:                                           \
-    if (sparc_cpu == PROCESSOR_ULTRASPARC)             \
-      return (GET_MODE (X) == DImode ?                 \
-              COSTS_N_INSNS (34) : COSTS_N_INSNS (19));        \
-    if (sparc_cpu == PROCESSOR_ULTRASPARC3)            \
-      return COSTS_N_INSNS (6);                                \
-    return TARGET_HARD_MUL ? COSTS_N_INSNS (5) : COSTS_N_INSNS (25); \
-  case DIV:                                            \
-  case UDIV:                                           \
-  case MOD:                                            \
-  case UMOD:                                           \
-    if (sparc_cpu == PROCESSOR_ULTRASPARC)             \
-      return (GET_MODE (X) == DImode ?                 \
-              COSTS_N_INSNS (68) : COSTS_N_INSNS (37));        \
-    if (sparc_cpu == PROCESSOR_ULTRASPARC3)            \
-      return (GET_MODE (X) == DImode ?                 \
-              COSTS_N_INSNS (71) : COSTS_N_INSNS (40));        \
-    return COSTS_N_INSNS (25);                         \
-  /* Make FLOAT and FIX more expensive than CONST_DOUBLE,\
-     so that cse will favor the latter.  */            \
-  case FLOAT:                                          \
-  case FIX:                                            \
-    return 19;
+  RTX_COSTS_CASES                                      \
+    return sparc_rtx_costs(X,CODE,OUTER_CODE);
+
+#define ADDRESS_COST(RTX)  1
 
 #define PREFETCH_BLOCK \
        ((sparc_cpu == PROCESSOR_ULTRASPARC \