Commit a6008bd8 by Richard Sandiford Committed by Richard Sandiford

mips-protos.h (mips_dangerous_for_la25_p): Declare.

	* config/mips/mips-protos.h (mips_dangerous_for_la25_p): Declare.
	(mips_preferred_reload_class): Declare.
	* config/mips/mips.h (DANGEROUS_FOR_LA25_P): Replace with function.
	(EXTRA_CONSTRAINT): Update accordingly.
	(PREFERRED_RELOAD_CLASS): Use mips_preferred_reload_class.
	* config/mips/mips.c (mips_dangerous_for_la25_p): New function.
	(mips_preferred_reload_class): New function.  Prefer LEA_REGS if
	mips_dangerous_for_la25_p.
	(mips_secondary_reload_class): Use LEA_REGS rather than GR_REGS
	if mips_dangerous_for_la25_p.

From-SVN: r75420
parent 543ebd4a
2004-01-05 Richard Sandiford <rsandifo@redhat.com>
* config/mips/mips-protos.h (mips_dangerous_for_la25_p): Declare.
(mips_preferred_reload_class): Declare.
* config/mips/mips.h (DANGEROUS_FOR_LA25_P): Replace with function.
(EXTRA_CONSTRAINT): Update accordingly.
(PREFERRED_RELOAD_CLASS): Use mips_preferred_reload_class.
* config/mips/mips.c (mips_dangerous_for_la25_p): New function.
(mips_preferred_reload_class): New function. Prefer LEA_REGS if
mips_dangerous_for_la25_p.
(mips_secondary_reload_class): Use LEA_REGS rather than GR_REGS
if mips_dangerous_for_la25_p.
2004-01-05 Bernardo Innocenti <bernie@develer.com> 2004-01-05 Bernardo Innocenti <bernie@develer.com>
* config/m68k/m68k.c (output_andsi3): Fix signed/unsigned comparison * config/m68k/m68k.c (output_andsi3): Fix signed/unsigned comparison
......
...@@ -124,6 +124,8 @@ extern int function_arg_pass_by_reference (const CUMULATIVE_ARGS *, ...@@ -124,6 +124,8 @@ extern int function_arg_pass_by_reference (const CUMULATIVE_ARGS *,
extern bool mips_cannot_change_mode_class (enum machine_mode, extern bool mips_cannot_change_mode_class (enum machine_mode,
enum machine_mode, enum reg_class); enum machine_mode, enum reg_class);
extern bool mips_dangerous_for_la25_p (rtx);
extern enum reg_class mips_preferred_reload_class (rtx, enum reg_class);
extern enum reg_class mips_secondary_reload_class (enum reg_class, extern enum reg_class mips_secondary_reload_class (enum reg_class,
enum machine_mode, enum machine_mode,
rtx, int); rtx, int);
......
...@@ -7350,6 +7350,44 @@ mips_cannot_change_mode_class (enum machine_mode from, ...@@ -7350,6 +7350,44 @@ mips_cannot_change_mode_class (enum machine_mode from,
return false; return false;
} }
/* Return true if X should not be moved directly into register $25.
We need this because many versions of GAS will treat "la $25,foo" as
part of a call sequence and so allow a global "foo" to be lazily bound. */
bool
mips_dangerous_for_la25_p (rtx x)
{
HOST_WIDE_INT offset;
if (TARGET_EXPLICIT_RELOCS)
return false;
mips_split_const (x, &x, &offset);
return global_got_operand (x, VOIDmode);
}
/* Implement PREFERRED_RELOAD_CLASS. */
enum reg_class
mips_preferred_reload_class (rtx x, enum reg_class class)
{
if (mips_dangerous_for_la25_p (x) && reg_class_subset_p (LEA_REGS, class))
return LEA_REGS;
if (TARGET_HARD_FLOAT
&& FLOAT_MODE_P (GET_MODE (x))
&& reg_class_subset_p (FP_REGS, class))
return FP_REGS;
if (reg_class_subset_p (GR_REGS, class))
class = GR_REGS;
if (TARGET_MIPS16 && reg_class_subset_p (M16_REGS, class))
class = M16_REGS;
return class;
}
/* This function returns the register class required for a secondary /* This function returns the register class required for a secondary
register when copying between one of the registers in CLASS, and X, register when copying between one of the registers in CLASS, and X,
using MODE. If IN_P is nonzero, the copy is going from X to the using MODE. If IN_P is nonzero, the copy is going from X to the
...@@ -7369,9 +7407,12 @@ mips_secondary_reload_class (enum reg_class class, ...@@ -7369,9 +7407,12 @@ mips_secondary_reload_class (enum reg_class class,
gp_reg_p = TARGET_MIPS16 ? M16_REG_P (regno) : GP_REG_P (regno); gp_reg_p = TARGET_MIPS16 ? M16_REG_P (regno) : GP_REG_P (regno);
if (TEST_HARD_REG_BIT (reg_class_contents[(int) class], 25) if (mips_dangerous_for_la25_p (x))
&& DANGEROUS_FOR_LA25_P (x)) {
return LEA_REGS; gr_regs = LEA_REGS;
if (TEST_HARD_REG_BIT (reg_class_contents[(int) class], 25))
return gr_regs;
}
/* Copying from HI or LO to anywhere other than a general register /* Copying from HI or LO to anywhere other than a general register
requires a general register. */ requires a general register. */
...@@ -7402,13 +7443,13 @@ mips_secondary_reload_class (enum reg_class class, ...@@ -7402,13 +7443,13 @@ mips_secondary_reload_class (enum reg_class class,
{ {
if (in_p) if (in_p)
return FP_REGS; return FP_REGS;
return GP_REG_P (regno) ? NO_REGS : GR_REGS; return gp_reg_p ? NO_REGS : gr_regs;
} }
if (ST_REG_P (regno)) if (ST_REG_P (regno))
{ {
if (! in_p) if (! in_p)
return FP_REGS; return FP_REGS;
return class == GR_REGS ? NO_REGS : GR_REGS; return class == gr_regs ? NO_REGS : gr_regs;
} }
if (class == FP_REGS) if (class == FP_REGS)
...@@ -7425,7 +7466,7 @@ mips_secondary_reload_class (enum reg_class class, ...@@ -7425,7 +7466,7 @@ mips_secondary_reload_class (enum reg_class class,
code by returning GR_REGS here. */ code by returning GR_REGS here. */
return NO_REGS; return NO_REGS;
} }
else if (GP_REG_P (regno) || x == CONST0_RTX (mode)) else if (gp_reg_p || x == CONST0_RTX (mode))
{ {
/* In this case we can use mtc1, mfc1, dmtc1 or dmfc1. */ /* In this case we can use mtc1, mfc1, dmtc1 or dmfc1. */
return NO_REGS; return NO_REGS;
...@@ -7438,7 +7479,7 @@ mips_secondary_reload_class (enum reg_class class, ...@@ -7438,7 +7479,7 @@ mips_secondary_reload_class (enum reg_class class,
else else
{ {
/* Otherwise, we need to reload through an integer register. */ /* Otherwise, we need to reload through an integer register. */
return GR_REGS; return gr_regs;
} }
} }
......
...@@ -2022,13 +2022,6 @@ extern enum reg_class mips_char_to_class[256]; ...@@ -2022,13 +2022,6 @@ extern enum reg_class mips_char_to_class[256];
((C) == 'G' \ ((C) == 'G' \
&& (VALUE) == CONST0_RTX (GET_MODE (VALUE))) && (VALUE) == CONST0_RTX (GET_MODE (VALUE)))
/* True if OP is a constant that should not be moved into $25.
We need this because many versions of gas treat 'la $25,foo' as
part of a call sequence and allow a global 'foo' to be lazily bound. */
#define DANGEROUS_FOR_LA25_P(OP) \
(!TARGET_EXPLICIT_RELOCS && global_got_operand (OP, VOIDmode))
/* Letters in the range `Q' through `U' may be defined in a /* Letters in the range `Q' through `U' may be defined in a
machine-dependent fashion to stand for arbitrary operand types. machine-dependent fashion to stand for arbitrary operand types.
The machine description macro `EXTRA_CONSTRAINT' is passed the The machine description macro `EXTRA_CONSTRAINT' is passed the
...@@ -2054,10 +2047,10 @@ extern enum reg_class mips_char_to_class[256]; ...@@ -2054,10 +2047,10 @@ extern enum reg_class mips_char_to_class[256];
&& call_insn_operand (OP, VOIDmode)) \ && call_insn_operand (OP, VOIDmode)) \
: ((CODE) == 'T') ? (CONSTANT_P (OP) \ : ((CODE) == 'T') ? (CONSTANT_P (OP) \
&& move_operand (OP, VOIDmode) \ && move_operand (OP, VOIDmode) \
&& DANGEROUS_FOR_LA25_P (OP)) \ && mips_dangerous_for_la25_p (OP)) \
: ((CODE) == 'U') ? (CONSTANT_P (OP) \ : ((CODE) == 'U') ? (CONSTANT_P (OP) \
&& move_operand (OP, VOIDmode) \ && move_operand (OP, VOIDmode) \
&& !DANGEROUS_FOR_LA25_P (OP)) \ && !mips_dangerous_for_la25_p (OP)) \
: ((CODE) == 'W') ? (GET_CODE (OP) == MEM \ : ((CODE) == 'W') ? (GET_CODE (OP) == MEM \
&& memory_operand (OP, VOIDmode) \ && memory_operand (OP, VOIDmode) \
&& (!TARGET_MIPS16 \ && (!TARGET_MIPS16 \
...@@ -2068,27 +2061,8 @@ extern enum reg_class mips_char_to_class[256]; ...@@ -2068,27 +2061,8 @@ extern enum reg_class mips_char_to_class[256];
/* Say which of the above are memory constraints. */ /* Say which of the above are memory constraints. */
#define EXTRA_MEMORY_CONSTRAINT(C, STR) ((C) == 'R' || (C) == 'W') #define EXTRA_MEMORY_CONSTRAINT(C, STR) ((C) == 'R' || (C) == 'W')
/* Given an rtx X being reloaded into a reg required to be
in class CLASS, return the class of reg to actually use.
In general this is just CLASS; but on some machines
in some cases it is preferable to use a more restrictive class. */
#define PREFERRED_RELOAD_CLASS(X,CLASS) \ #define PREFERRED_RELOAD_CLASS(X,CLASS) \
((CLASS) != ALL_REGS \ mips_preferred_reload_class (X, CLASS)
? (! TARGET_MIPS16 \
? (CLASS) \
: ((CLASS) != GR_REGS \
? (CLASS) \
: M16_REGS)) \
: ((GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \
|| GET_MODE_CLASS (GET_MODE (X)) == MODE_COMPLEX_FLOAT) \
? (TARGET_SOFT_FLOAT \
? (TARGET_MIPS16 ? M16_REGS : GR_REGS) \
: FP_REGS) \
: ((GET_MODE_CLASS (GET_MODE (X)) == MODE_INT \
|| GET_MODE (X) == VOIDmode) \
? (TARGET_MIPS16 ? M16_REGS : GR_REGS) \
: (CLASS))))
/* Certain machines have the property that some registers cannot be /* Certain machines have the property that some registers cannot be
copied to some other registers without using memory. Define this copied to some other registers without using memory. Define this
......
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