Commit faa832a7 by Anatoly Sokolov Committed by Anatoly Sokolov

reload.h (register_move_cost, [...]): Adjust prototype.

	* reload.h (register_move_cost, memory_move_secondary_cost,
	secondary_reload_class): Adjust prototype.
	* rtl.h (reg_class_subset_p): Adjust prototype.
	* reload.c (secondary_reload_class): Change arguments type from
	enum reg_class to reg_class_t. Change result type to reg_class_t.
	* reginfo.c (register_move_cost, reg_class_subset_p): Change
	arguments type from enum reg_class to reg_class_t.
	(memory_move_secondary_cost): Change arguments type from
	enum reg_class to reg_class_t. Change type of saved_flags to
	reg_class_t.

	* config/mips/mips.h (REGISTER_MOVE_COST, MEMORY_MOVE_COST): 
	Remove macros.
	(mips_cost): Remove.
	(struct mips_rtx_cost_data): Moved to mips.c.
	* config/mips/mips-protos.h (mips_register_move_cost): Remove.
	* config/mips/mips.c (struct mips_rtx_cost_data): Moved from mips.h.
	(mips_cost): Make static.
	(mips_canonicalize_move_class): Change argument type to reg_class_t.
	Change result type to reg_class_t.
	(mips_move_to_gpr_cost, mips_move_from_gpr_cost): Change arguments
	type from enum reg_class to reg_class_t.
	(mips_register_move_cost): Make static. Change arguments
	type from enum reg_class to reg_class_t.
	(mips_memory_move_cost): New function.
	(TARGET_REGISTER_MOVE_COST, TARGET_MEMORY_MOVE_COST): Define.

From-SVN: r163252
parent 0c21b3ca
2010-08-14 Anatoly Sokolov <aesok@post.ru>
* reload.h (register_move_cost, memory_move_secondary_cost,
secondary_reload_class): Adjust prototype.
* rtl.h (reg_class_subset_p): Adjust prototype.
* reload.c (secondary_reload_class): Change arguments type from
enum reg_class to reg_class_t. Change result type to reg_class_t.
* reginfo.c (register_move_cost, reg_class_subset_p): Change
arguments type from enum reg_class to reg_class_t.
(memory_move_secondary_cost): Change arguments type from
enum reg_class to reg_class_t. Change type of saved_flags to
reg_class_t.
* config/mips/mips.h (REGISTER_MOVE_COST, MEMORY_MOVE_COST):
Remove macros.
(mips_cost): Remove.
(struct mips_rtx_cost_data): Moved to mips.c.
* config/mips/mips-protos.h (mips_register_move_cost): Remove.
* config/mips/mips.c (struct mips_rtx_cost_data): Moved from mips.h.
(mips_cost): Make static.
(mips_canonicalize_move_class): Change argument type to reg_class_t.
Change result type to reg_class_t.
(mips_move_to_gpr_cost, mips_move_from_gpr_cost): Change arguments
type from enum reg_class to reg_class_t.
(mips_register_move_cost): Make static. Change arguments
type from enum reg_class to reg_class_t.
(mips_memory_move_cost): New function.
(TARGET_REGISTER_MOVE_COST, TARGET_MEMORY_MOVE_COST): Define.
2010-08-14 Richard Sandiford <rdsandiford@googlemail.com> 2010-08-14 Richard Sandiford <rdsandiford@googlemail.com>
PR rtl-optimization/43358 PR rtl-optimization/43358
......
...@@ -295,8 +295,6 @@ extern enum reg_class mips_secondary_reload_class (enum reg_class, ...@@ -295,8 +295,6 @@ extern enum reg_class mips_secondary_reload_class (enum reg_class,
enum machine_mode, enum machine_mode,
rtx, bool); rtx, bool);
extern int mips_class_max_nregs (enum reg_class, enum machine_mode); extern int mips_class_max_nregs (enum reg_class, enum machine_mode);
extern int mips_register_move_cost (enum machine_mode, enum reg_class,
enum reg_class);
extern int mips_adjust_insn_length (rtx, int); extern int mips_adjust_insn_length (rtx, int);
extern void mips_output_load_label (rtx); extern void mips_output_load_label (rtx);
......
...@@ -474,6 +474,23 @@ struct mips16e_save_restore_info { ...@@ -474,6 +474,23 @@ struct mips16e_save_restore_info {
HOST_WIDE_INT size; HOST_WIDE_INT size;
}; };
/* Costs of various operations on the different architectures. */
struct mips_rtx_cost_data
{
unsigned short fp_add;
unsigned short fp_mult_sf;
unsigned short fp_mult_df;
unsigned short fp_div_sf;
unsigned short fp_div_df;
unsigned short int_mult_si;
unsigned short int_mult_di;
unsigned short int_div_si;
unsigned short int_div_di;
unsigned short branch_cost;
unsigned short memory_latency;
};
/* Global variables for machine-dependent things. */ /* Global variables for machine-dependent things. */
/* The -G setting, or the configuration's default small-data limit if /* The -G setting, or the configuration's default small-data limit if
...@@ -522,7 +539,7 @@ static const struct mips_cpu_info *mips_isa_option_info; ...@@ -522,7 +539,7 @@ static const struct mips_cpu_info *mips_isa_option_info;
int mips_abi = MIPS_ABI_DEFAULT; int mips_abi = MIPS_ABI_DEFAULT;
/* Which cost information to use. */ /* Which cost information to use. */
const struct mips_rtx_cost_data *mips_cost; static const struct mips_rtx_cost_data *mips_cost;
/* The ambient target flags, excluding MASK_MIPS16. */ /* The ambient target flags, excluding MASK_MIPS16. */
static int mips_base_target_flags; static int mips_base_target_flags;
...@@ -1167,6 +1184,8 @@ static const struct mips_rtx_cost_data ...@@ -1167,6 +1184,8 @@ static const struct mips_rtx_cost_data
}; };
static rtx mips_find_pic_call_symbol (rtx, rtx); static rtx mips_find_pic_call_symbol (rtx, rtx);
static int mips_register_move_cost (enum machine_mode, reg_class_t,
reg_class_t);
/* This hash table keeps track of implicit "mips16" and "nomips16" attributes /* This hash table keeps track of implicit "mips16" and "nomips16" attributes
for -mflip_mips16. It maps decl names onto a boolean mode setting. */ for -mflip_mips16. It maps decl names onto a boolean mode setting. */
...@@ -10809,8 +10828,8 @@ mips_preferred_reload_class (rtx x, enum reg_class rclass) ...@@ -10809,8 +10828,8 @@ mips_preferred_reload_class (rtx x, enum reg_class rclass)
/* RCLASS is a class involved in a REGISTER_MOVE_COST calculation. /* RCLASS is a class involved in a REGISTER_MOVE_COST calculation.
Return a "canonical" class to represent it in later calculations. */ Return a "canonical" class to represent it in later calculations. */
static enum reg_class static reg_class_t
mips_canonicalize_move_class (enum reg_class rclass) mips_canonicalize_move_class (reg_class_t rclass)
{ {
/* All moves involving accumulator registers have the same cost. */ /* All moves involving accumulator registers have the same cost. */
if (reg_class_subset_p (rclass, ACC_REGS)) if (reg_class_subset_p (rclass, ACC_REGS))
...@@ -10832,7 +10851,7 @@ mips_canonicalize_move_class (enum reg_class rclass) ...@@ -10832,7 +10851,7 @@ mips_canonicalize_move_class (enum reg_class rclass)
static int static int
mips_move_to_gpr_cost (enum machine_mode mode ATTRIBUTE_UNUSED, mips_move_to_gpr_cost (enum machine_mode mode ATTRIBUTE_UNUSED,
enum reg_class from) reg_class_t from)
{ {
switch (from) switch (from)
{ {
...@@ -10868,7 +10887,7 @@ mips_move_to_gpr_cost (enum machine_mode mode ATTRIBUTE_UNUSED, ...@@ -10868,7 +10887,7 @@ mips_move_to_gpr_cost (enum machine_mode mode ATTRIBUTE_UNUSED,
other classes handled by this function. */ other classes handled by this function. */
static int static int
mips_move_from_gpr_cost (enum machine_mode mode, enum reg_class to) mips_move_from_gpr_cost (enum machine_mode mode, reg_class_t to)
{ {
switch (to) switch (to)
{ {
...@@ -10900,15 +10919,15 @@ mips_move_from_gpr_cost (enum machine_mode mode, enum reg_class to) ...@@ -10900,15 +10919,15 @@ mips_move_from_gpr_cost (enum machine_mode mode, enum reg_class to)
} }
} }
/* Implement REGISTER_MOVE_COST. Return 0 for classes that are the /* Implement TARGET_REGISTER_MOVE_COST. Return 0 for classes that are the
maximum of the move costs for subclasses; regclass will work out maximum of the move costs for subclasses; regclass will work out
the maximum for us. */ the maximum for us. */
int static int
mips_register_move_cost (enum machine_mode mode, mips_register_move_cost (enum machine_mode mode,
enum reg_class from, enum reg_class to) reg_class_t from, reg_class_t to)
{ {
enum reg_class dregs; reg_class_t dregs;
int cost1, cost2; int cost1, cost2;
from = mips_canonicalize_move_class (from); from = mips_canonicalize_move_class (from);
...@@ -10944,6 +10963,15 @@ mips_register_move_cost (enum machine_mode mode, ...@@ -10944,6 +10963,15 @@ mips_register_move_cost (enum machine_mode mode,
return 0; return 0;
} }
/* Implement TARGET_MEMORY_MOVE_COST. */
static int
mips_memory_move_cost (enum machine_mode mode, reg_class_t rclass, bool in)
{
return (mips_cost->memory_latency
+ memory_move_secondary_cost (mode, rclass, in));
}
/* Implement TARGET_IRA_COVER_CLASSES. */ /* Implement TARGET_IRA_COVER_CLASSES. */
static const reg_class_t * static const reg_class_t *
...@@ -16376,6 +16404,10 @@ void mips_function_profiler (FILE *file) ...@@ -16376,6 +16404,10 @@ void mips_function_profiler (FILE *file)
#undef TARGET_VALID_POINTER_MODE #undef TARGET_VALID_POINTER_MODE
#define TARGET_VALID_POINTER_MODE mips_valid_pointer_mode #define TARGET_VALID_POINTER_MODE mips_valid_pointer_mode
#undef TARGET_REGISTER_MOVE_COST
#define TARGET_REGISTER_MOVE_COST mips_register_move_cost
#undef TARGET_MEMORY_MOVE_COST
#define TARGET_MEMORY_MOVE_COST mips_memory_move_cost
#undef TARGET_RTX_COSTS #undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS mips_rtx_costs #define TARGET_RTX_COSTS mips_rtx_costs
#undef TARGET_ADDRESS_COST #undef TARGET_ADDRESS_COST
......
...@@ -28,23 +28,6 @@ along with GCC; see the file COPYING3. If not see ...@@ -28,23 +28,6 @@ along with GCC; see the file COPYING3. If not see
/* MIPS external variables defined in mips.c. */ /* MIPS external variables defined in mips.c. */
/* Costs of various operations on the different architectures. */
struct mips_rtx_cost_data
{
unsigned short fp_add;
unsigned short fp_mult_sf;
unsigned short fp_mult_df;
unsigned short fp_div_sf;
unsigned short fp_div_df;
unsigned short int_mult_si;
unsigned short int_mult_di;
unsigned short int_div_si;
unsigned short int_div_di;
unsigned short branch_cost;
unsigned short memory_latency;
};
/* Which ABI to use. ABI_32 (original 32, or o32), ABI_N32 (n32), /* Which ABI to use. ABI_32 (original 32, or o32), ABI_N32 (n32),
ABI_64 (n64) are all defined by SGI. ABI_O64 is o32 extended ABI_64 (n64) are all defined by SGI. ABI_O64 is o32 extended
to work on a 64-bit machine. */ to work on a 64-bit machine. */
...@@ -2487,29 +2470,6 @@ typedef struct mips_args { ...@@ -2487,29 +2470,6 @@ typedef struct mips_args {
#define FUNCTION_MODE SImode #define FUNCTION_MODE SImode
/* A C expression for the cost of moving data from a register in
class FROM to one in class TO. The classes are expressed using
the enumeration values such as `GENERAL_REGS'. A value of 2 is
the default; other values are interpreted relative to that.
It is not required that the cost always equal 2 when FROM is the
same as TO; on some machines it is expensive to move between
registers if they are not general registers.
If reload sees an insn consisting of a single `set' between two
hard registers, and if `REGISTER_MOVE_COST' applied to their
classes returns a value of 2, reload does not check to ensure
that the constraints of the insn are met. Setting a cost of
other than 2 will allow reload to verify that the constraints are
met. You should do this if the `movM' pattern's constraints do
not allow such copying. */
#define REGISTER_MOVE_COST(MODE, FROM, TO) \
mips_register_move_cost (MODE, FROM, TO)
#define MEMORY_MOVE_COST(MODE,CLASS,TO_P) \
(mips_cost->memory_latency \
+ memory_move_secondary_cost ((MODE), (CLASS), (TO_P)))
/* Define if copies to/from condition code registers should be avoided. /* Define if copies to/from condition code registers should be avoided.
...@@ -3019,7 +2979,6 @@ extern int mips_isa; /* architectural level */ ...@@ -3019,7 +2979,6 @@ extern int mips_isa; /* architectural level */
extern int mips_abi; /* which ABI to use */ extern int mips_abi; /* which ABI to use */
extern const struct mips_cpu_info *mips_arch_info; extern const struct mips_cpu_info *mips_arch_info;
extern const struct mips_cpu_info *mips_tune_info; extern const struct mips_cpu_info *mips_tune_info;
extern const struct mips_rtx_cost_data *mips_cost;
extern bool mips_base_mips16; extern bool mips_base_mips16;
extern enum mips_code_readable_setting mips_code_readable; extern enum mips_code_readable_setting mips_code_readable;
extern GTY(()) struct target_globals *mips16_globals; extern GTY(()) struct target_globals *mips16_globals;
......
...@@ -628,8 +628,7 @@ init_fake_stack_mems (void) ...@@ -628,8 +628,7 @@ init_fake_stack_mems (void)
TO, using MODE. */ TO, using MODE. */
int int
register_move_cost (enum machine_mode mode, enum reg_class from, register_move_cost (enum machine_mode mode, reg_class_t from, reg_class_t to)
enum reg_class to)
{ {
return targetm.register_move_cost (mode, from, to); return targetm.register_move_cost (mode, from, to);
} }
...@@ -644,10 +643,10 @@ memory_move_cost (enum machine_mode mode, enum reg_class rclass, bool in) ...@@ -644,10 +643,10 @@ memory_move_cost (enum machine_mode mode, enum reg_class rclass, bool in)
/* Compute extra cost of moving registers to/from memory due to reloads. /* Compute extra cost of moving registers to/from memory due to reloads.
Only needed if secondary reloads are required for memory moves. */ Only needed if secondary reloads are required for memory moves. */
int int
memory_move_secondary_cost (enum machine_mode mode, enum reg_class rclass, memory_move_secondary_cost (enum machine_mode mode, reg_class_t rclass,
bool in) bool in)
{ {
enum reg_class altclass; reg_class_t altclass;
int partial_cost = 0; int partial_cost = 0;
/* We need a memory reference to feed to SECONDARY... macros. */ /* We need a memory reference to feed to SECONDARY... macros. */
/* mem may be unused even if the SECONDARY_ macros are defined. */ /* mem may be unused even if the SECONDARY_ macros are defined. */
...@@ -1174,7 +1173,7 @@ reg_scan_mark_refs (rtx x, rtx insn) ...@@ -1174,7 +1173,7 @@ reg_scan_mark_refs (rtx x, rtx insn)
/* Return nonzero if C1 is a subset of C2, i.e., if every register in C1 /* Return nonzero if C1 is a subset of C2, i.e., if every register in C1
is also in C2. */ is also in C2. */
int int
reg_class_subset_p (enum reg_class c1, enum reg_class c2) reg_class_subset_p (reg_class_t c1, reg_class_t c2)
{ {
return (c1 == c2 return (c1 == c2
|| c2 == ALL_REGS || c2 == ALL_REGS
......
...@@ -518,9 +518,9 @@ push_secondary_reload (int in_p, rtx x, int opnum, int optional, ...@@ -518,9 +518,9 @@ push_secondary_reload (int in_p, rtx x, int opnum, int optional,
/* If a secondary reload is needed, return its class. If both an intermediate /* If a secondary reload is needed, return its class. If both an intermediate
register and a scratch register is needed, we return the class of the register and a scratch register is needed, we return the class of the
intermediate register. */ intermediate register. */
enum reg_class reg_class_t
secondary_reload_class (bool in_p, enum reg_class rclass, secondary_reload_class (bool in_p, reg_class_t rclass, enum machine_mode mode,
enum machine_mode mode, rtx x) rtx x)
{ {
enum insn_code icode; enum insn_code icode;
secondary_reload_info sri; secondary_reload_info sri;
......
...@@ -30,11 +30,9 @@ along with GCC; see the file COPYING3. If not see ...@@ -30,11 +30,9 @@ along with GCC; see the file COPYING3. If not see
SECONDARY_RELOAD_CLASS (CLASS, MODE, X) SECONDARY_RELOAD_CLASS (CLASS, MODE, X)
#endif #endif
extern int register_move_cost (enum machine_mode, enum reg_class, extern int register_move_cost (enum machine_mode, reg_class_t, reg_class_t);
enum reg_class);
extern int memory_move_cost (enum machine_mode, enum reg_class, bool); extern int memory_move_cost (enum machine_mode, enum reg_class, bool);
extern int memory_move_secondary_cost (enum machine_mode, enum reg_class, extern int memory_move_secondary_cost (enum machine_mode, reg_class_t, bool);
bool);
/* Maximum number of reloads we can need. */ /* Maximum number of reloads we can need. */
#define MAX_RELOADS (2 * MAX_RECOG_OPERANDS * (MAX_REGS_PER_ADDRESS + 1)) #define MAX_RELOADS (2 * MAX_RECOG_OPERANDS * (MAX_REGS_PER_ADDRESS + 1))
...@@ -292,8 +290,8 @@ extern void compute_use_by_pseudos (HARD_REG_SET *, bitmap); ...@@ -292,8 +290,8 @@ extern void compute_use_by_pseudos (HARD_REG_SET *, bitmap);
/* Functions from reload.c: */ /* Functions from reload.c: */
extern enum reg_class secondary_reload_class (bool, enum reg_class, extern reg_class_t secondary_reload_class (bool, reg_class_t,
enum machine_mode, rtx); enum machine_mode, rtx);
#ifdef GCC_INSN_CODES_H #ifdef GCC_INSN_CODES_H
extern enum reg_class scratch_reload_class (enum insn_code); extern enum reg_class scratch_reload_class (enum insn_code);
......
...@@ -2371,7 +2371,7 @@ extern void mark_elimination (int, int); ...@@ -2371,7 +2371,7 @@ extern void mark_elimination (int, int);
/* In reginfo.c */ /* In reginfo.c */
extern int reg_classes_intersect_p (reg_class_t, reg_class_t); extern int reg_classes_intersect_p (reg_class_t, reg_class_t);
extern int reg_class_subset_p (enum reg_class, enum reg_class); extern int reg_class_subset_p (reg_class_t, reg_class_t);
extern void globalize_reg (int); extern void globalize_reg (int);
extern void init_reg_modes_target (void); extern void init_reg_modes_target (void);
extern void init_regs (void); extern void init_regs (void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment