This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] h8300.c: Integrate const_costs() into h8300_rtx_costs().
- From: Kazu Hirata <kazu at cs dot umass dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 16 Jun 2003 09:06:00 -0400 (EDT)
- Subject: [patch] h8300.c: Integrate const_costs() into h8300_rtx_costs().
Hi,
Attached is a patch to integrate const_costs() into h8300_rtx_costs().
Both const_costs() and h8300_rtx_costs() do dispatching based on code,
which is ugly. The patch makes no functional change.
Tested on h8300 port. Committed.
Kazu Hirata
2003-06-16 Kazu Hirata <kazu@cs.umass.edu>
* config/h8300/h8300.c (const_costs): Move this to ...
(h8300_rtx_costs): ... here.
Index: h8300.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.c,v
retrieving revision 1.234
diff -u -r1.234 h8300.c
--- h8300.c 11 Jun 2003 11:58:39 -0000 1.234
+++ h8300.c 16 Jun 2003 03:13:31 -0000
@@ -68,7 +68,6 @@
static void h8300_asm_named_section PARAMS ((const char *, unsigned int));
#endif
static void h8300_encode_section_info PARAMS ((tree, rtx, int));
-static int const_costs PARAMS ((rtx, enum rtx_code, enum rtx_code));
static int h8300_and_costs PARAMS ((rtx));
static int h8300_shift_costs PARAMS ((rtx));
static bool h8300_rtx_costs PARAMS ((rtx, int, int, int *));
@@ -1090,55 +1089,6 @@
return result;
}
-/* Return the cost of the rtx R with code CODE. */
-
-static int
-const_costs (r, c, outer_code)
- rtx r;
- enum rtx_code c;
- enum rtx_code outer_code;
-{
- switch (c)
- {
- case CONST_INT:
- {
- HOST_WIDE_INT n = INTVAL (r);
-
- if (-4 <= n || n <= 4)
- {
- switch ((int) n)
- {
- case 0:
- return 0;
- case 1:
- case 2:
- case -1:
- case -2:
- return 0 + (outer_code == SET);
- case 4:
- case -4:
- if (TARGET_H8300H || TARGET_H8300S)
- return 0 + (outer_code == SET);
- else
- return 1;
- }
- }
- return 1;
- }
-
- case CONST:
- case LABEL_REF:
- case SYMBOL_REF:
- return 3;
-
- case CONST_DOUBLE:
- return 20;
-
- default:
- return 4;
- }
-}
-
static int
h8300_and_costs (x)
rtx x;
@@ -1185,6 +1135,46 @@
{
switch (code)
{
+ case CONST_INT:
+ {
+ HOST_WIDE_INT n = INTVAL (x);
+
+ if (-4 <= n || n <= 4)
+ {
+ switch ((int) n)
+ {
+ case 0:
+ *total = 0;
+ return true;
+ case 1:
+ case 2:
+ case -1:
+ case -2:
+ *total = 0 + (outer_code == SET);
+ return true;
+ case 4:
+ case -4:
+ if (TARGET_H8300H || TARGET_H8300S)
+ *total = 0 + (outer_code == SET);
+ else
+ *total = 1;
+ return true;
+ }
+ }
+ *total = 1;
+ return true;
+ }
+
+ case CONST:
+ case LABEL_REF:
+ case SYMBOL_REF:
+ *total = 3;
+ return true;
+
+ case CONST_DOUBLE:
+ *total = 20;
+ return true;
+
case AND:
*total = COSTS_N_INSNS (h8300_and_costs (x));
return true;
@@ -1215,7 +1205,7 @@
return true;
default:
- *total = const_costs (x, code, outer_code);
+ *total = 4;
return true;
}
}