summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog12
-rw-r--r--gcc/config/m68hc11/m68hc11-protos.h5
-rw-r--r--gcc/config/m68hc11/m68hc11.c34
-rw-r--r--gcc/config/m68hc11/m68hc11.h2
4 files changed, 35 insertions, 18 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2f3e025caf7..c8167571fc5 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,15 @@
+2002-03-15 Stephane Carrez <Stephane.Carrez@worldnet.fr>
+
+ * config/m68hc11/m68hc11.c (m6812_cost): Make cost of add higher
+ than a shift to avoid adding a register with itself.
+ (m68hc11_memory_move_cost): Take into account NO_REGS.
+ (m68hc11_register_move_cost): Update and use memory move cost
+ for soft registers.
+ (m68hc11_address_cost): Make cost of valid offset not 0 so that
+ it gives more opportunities to cse to optimize.
+ * config/m68hc11/m68hc11.h (REGISTER_MOVE_COST): Pass the mode.
+ * config/m68hc11/m68hc11-protos.h (m68hc11_register_move_cost): Update.
+
2002-03-15 Mark Mitchell <mark@codesourcery.com>
* c-common.c (statement_code_p): Handle CLEANUP_STMT.
diff --git a/gcc/config/m68hc11/m68hc11-protos.h b/gcc/config/m68hc11/m68hc11-protos.h
index bbbb4525f4f..e974348a317 100644
--- a/gcc/config/m68hc11/m68hc11-protos.h
+++ b/gcc/config/m68hc11/m68hc11-protos.h
@@ -1,5 +1,5 @@
/* Prototypes for exported functions defined in m68hc11.c
- Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
Contributed by Stephane Carrez (stcarrez@worldnet.fr)
This file is part of GNU CC.
@@ -96,7 +96,8 @@ extern rtx m68hc11_gen_highpart PARAMS((enum machine_mode, rtx));
#ifdef HAVE_MACHINE_MODES
extern int m68hc11_memory_move_cost PARAMS((enum machine_mode, enum reg_class,
int));
-extern int m68hc11_register_move_cost PARAMS((enum reg_class, enum reg_class));
+extern int m68hc11_register_move_cost PARAMS((enum machine_mode,
+ enum reg_class, enum reg_class));
extern int m68hc11_rtx_costs PARAMS((rtx, enum rtx_code, enum rtx_code));
extern int m68hc11_address_cost PARAMS((rtx));
diff --git a/gcc/config/m68hc11/m68hc11.c b/gcc/config/m68hc11/m68hc11.c
index 4946c3bb78c..252b4e64cd8 100644
--- a/gcc/config/m68hc11/m68hc11.c
+++ b/gcc/config/m68hc11/m68hc11.c
@@ -1,5 +1,5 @@
/* Subroutines for code generation on Motorola 68HC11 and 68HC12.
- Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
Contributed by Stephane Carrez (stcarrez@worldnet.fr)
This file is part of GNU CC.
@@ -169,9 +169,9 @@ static const struct processor_costs m6811_cost = {
/* Costs for a 68HC12. */
static const struct processor_costs m6812_cost = {
/* add */
- COSTS_N_INSNS (1),
+ COSTS_N_INSNS (2),
/* logical */
- COSTS_N_INSNS (1),
+ COSTS_N_INSNS (2),
/* non-constant shift */
COSTS_N_INSNS (20),
/* shiftQI const */
@@ -1173,9 +1173,8 @@ m68hc11_handle_fntype_attribute (node, name, args, flags, no_add_attrs)
handle calls to traps in a special manner (by issuing the trap).
This information is stored in SYMBOL_REF_FLAG. */
void
-m68hc11_encode_section_info (decl, first)
+m68hc11_encode_section_info (decl)
tree decl;
- int first ATTRIBUTE_UNUSED;
{
tree func_attr;
int trap_handler;
@@ -4919,7 +4918,7 @@ m68hc11_memory_move_cost (mode, class, in)
enum reg_class class;
int in ATTRIBUTE_UNUSED;
{
- if (class <= H_REGS)
+ if (class <= H_REGS && class > NO_REGS)
{
if (GET_MODE_SIZE (mode) <= 2)
return COSTS_N_INSNS (1) + (reload_completed | reload_in_progress);
@@ -4941,19 +4940,24 @@ m68hc11_memory_move_cost (mode, class, in)
have a move cost of 2. Setting a higher cost will force reload to check
the constraints. */
int
-m68hc11_register_move_cost (from, to)
+m68hc11_register_move_cost (mode, from, to)
+ enum machine_mode mode;
enum reg_class from;
enum reg_class to;
{
- if (from >= S_REGS && to >= S_REGS)
+ /* All costs are symmetric, so reduce cases by putting the
+ lower number class as the destination. */
+ if (from < to)
{
- return COSTS_N_INSNS (3);
+ enum reg_class tmp = to;
+ to = from, from = tmp;
}
- if (from <= S_REGS && to <= S_REGS)
- {
- return COSTS_N_INSNS (1) + (reload_completed | reload_in_progress);
- }
- return COSTS_N_INSNS (2);
+ if (to >= S_REGS)
+ return m68hc11_memory_move_cost (mode, S_REGS, 0);
+ else if (from <= S_REGS)
+ return COSTS_N_INSNS (1) + (reload_completed | reload_in_progress);
+ else
+ return COSTS_N_INSNS (2);
}
@@ -5002,7 +5006,7 @@ m68hc11_address_cost (addr)
else if (INTVAL (plus1) >= m68hc11_max_offset)
cost = 2;
else
- cost = 0;
+ cost = 1;
if (REGNO (plus0) < FIRST_PSEUDO_REGISTER)
cost += 0;
else
diff --git a/gcc/config/m68hc11/m68hc11.h b/gcc/config/m68hc11/m68hc11.h
index b522c849814..53f38d79768 100644
--- a/gcc/config/m68hc11/m68hc11.h
+++ b/gcc/config/m68hc11/m68hc11.h
@@ -1422,7 +1422,7 @@ extern unsigned char m68hc11_reg_valid_for_index[FIRST_PSEUDO_REGISTER];
/* Move costs between classes of registers */
#define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2) \
- (m68hc11_register_move_cost (CLASS1, CLASS2))
+ (m68hc11_register_move_cost (MODE, CLASS1, CLASS2))
/* Move cost between register and memory.
- Move to a 16-bit register is reasonable,