Commit 169304de by Richard Sandiford Committed by Richard Sandiford

mips.c (mips_legitimize_move): Generate special patterns for mflo and mfhi instructions.

	* config/mips/mips.c (mips_legitimize_move): Generate special patterns
	for mflo and mfhi instructions.
	(mips_output_move): Remove mflo and mfhi handling.
	* config/mips/mips.md (UNSPEC_MFHILO): New unspec.
	(*mulsidi3_64bit): Update for new mfhi/mflo representation.
	Likewise various define_peephole2s.
	(*movdi_32bit, *movdi_64bit, *movsi_internal): Merge x<-J and x<-d
	alternatives.
	(*movdi_64bit, *movdi_64bit_mips16, *mov[shq]i_internal)
	(*mov[shq]i_mips16): Remove mflo and mfhi alternatives.
	(mfhilo_di, mfhilo_si): New patterns.

From-SVN: r80883
parent c6ca23fb
2004-04-20 Richard Sandiford <rsandifo@redhat.com>
* config/mips/mips.c (mips_legitimize_move): Generate special patterns
for mflo and mfhi instructions.
(mips_output_move): Remove mflo and mfhi handling.
* config/mips/mips.md (UNSPEC_MFHILO): New unspec.
(*mulsidi3_64bit): Update for new mfhi/mflo representation.
Likewise various define_peephole2s.
(*movdi_32bit, *movdi_64bit, *movsi_internal): Merge x<-J and x<-d
alternatives.
(*movdi_64bit, *movdi_64bit_mips16, *mov[shq]i_internal)
(*mov[shq]i_mips16): Remove mflo and mfhi alternatives.
(mfhilo_di, mfhilo_si): New patterns.
2004-04-20 Josef Zlomek <zlomekj@suse.cz> 2004-04-20 Josef Zlomek <zlomekj@suse.cz>
* function.c (assign_parms): Force * function.c (assign_parms): Force
......
...@@ -1990,6 +1990,23 @@ mips_legitimize_move (enum machine_mode mode, rtx dest, rtx src) ...@@ -1990,6 +1990,23 @@ mips_legitimize_move (enum machine_mode mode, rtx dest, rtx src)
return true; return true;
} }
/* Check for individual, fully-reloaded mflo and mfhi instructions. */
if (GET_MODE_SIZE (mode) <= UNITS_PER_WORD
&& REG_P (src) && MD_REG_P (REGNO (src))
&& REG_P (dest) && GP_REG_P (REGNO (dest)))
{
int other_regno = REGNO (src) == HI_REGNUM ? LO_REGNUM : HI_REGNUM;
if (GET_MODE_SIZE (mode) <= 4)
emit_insn (gen_mfhilo_si (gen_rtx_REG (SImode, REGNO (dest)),
gen_rtx_REG (SImode, REGNO (src)),
gen_rtx_REG (SImode, other_regno)));
else
emit_insn (gen_mfhilo_di (gen_rtx_REG (DImode, REGNO (dest)),
gen_rtx_REG (DImode, REGNO (src)),
gen_rtx_REG (DImode, other_regno)));
return true;
}
/* We need to deal with constants that would be legitimate /* We need to deal with constants that would be legitimate
immediate_operands but not legitimate move_operands. */ immediate_operands but not legitimate move_operands. */
if (CONSTANT_P (src) && !move_operand (src, mode)) if (CONSTANT_P (src) && !move_operand (src, mode))
...@@ -2600,9 +2617,6 @@ mips_output_move (rtx dest, rtx src) ...@@ -2600,9 +2617,6 @@ mips_output_move (rtx dest, rtx src)
{ {
if (src_code == REG) if (src_code == REG)
{ {
if (MD_REG_P (REGNO (src)))
return "mf%1\t%0";
if (ST_REG_P (REGNO (src)) && ISA_HAS_8CC) if (ST_REG_P (REGNO (src)) && ISA_HAS_8CC)
return "lui\t%0,0x3f80\n\tmovf\t%0,%.,%1"; return "lui\t%0,0x3f80\n\tmovf\t%0,%.,%1";
......
2004-04-20 Richard Sandiford <rsandifo@redhat.com>
* gcc.dg/torture/mips-hilo-1.c: New test.
2004-04-19 Andrew Pinski <pinskia@physics.uc.edu> 2004-04-19 Andrew Pinski <pinskia@physics.uc.edu>
* gcc.c-torture/compile/20040419-1.c: New test. * gcc.c-torture/compile/20040419-1.c: New test.
......
/* f1 checks that an mtlo is not moved before an mfhi. f2 does the same
for an mthi and an mflo. */
/* { dg-do run { target mips*-*-* } } */
/* { dg-options "-mtune=rm7000" } */
#if !defined(__mips16)
#define DECLARE(TYPE) \
TYPE __attribute__ ((noinline)) \
f1##TYPE (TYPE x1, TYPE x2, TYPE x3) \
{ \
TYPE t1, t2; \
\
asm ("mult\t%1,%2" : "=h" (t1) : "d" (x1), "d" (x2) : "lo"); \
asm ("mflo\t%0" : "=r" (t2) : "l" (x3) : "hi"); \
return t1 + t2; \
} \
\
TYPE __attribute__ ((noinline)) \
f2##TYPE (TYPE x1, TYPE x2, TYPE x3) \
{ \
TYPE t1, t2; \
\
asm ("mult\t%1,%2" : "=l" (t1) : "d" (x1), "d" (x2) : "hi"); \
asm ("mfhi\t%0" : "=r" (t2) : "h" (x3) : "lo"); \
return t1 + t2; \
}
#define TEST(TYPE) \
if (f1##TYPE (1, 2, 10) != 10) \
abort (); \
if (f2##TYPE (1, 2, 40) != 42) \
abort ()
typedef char c;
typedef signed char sc;
typedef unsigned char uc;
typedef short s;
typedef unsigned short us;
typedef int i;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
DECLARE (c)
DECLARE (sc)
DECLARE (uc)
DECLARE (s)
DECLARE (us)
DECLARE (i)
DECLARE (ui)
#if defined (__mips64)
DECLARE (ll)
DECLARE (ull)
#endif
int
main ()
{
TEST (c);
TEST (sc);
TEST (uc);
TEST (s);
TEST (us);
TEST (i);
TEST (ui);
#if defined (__mips64)
TEST (ll);
TEST (ull);
#endif
exit (0);
}
#else
int main () { exit (0); }
#endif
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