This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: divmodhi4
- To: jeff hammond <hammondjs at yahoo dot com>
- Subject: Re: divmodhi4
- From: Michael Meissner <meissner at cygnus dot com>
- Date: Thu, 18 May 2000 20:20:11 -0400
- Cc: gcc at gcc dot gnu dot org
- References: <20000518210008.28596.qmail@web4802.mail.yahoo.com>
On Thu, May 18, 2000 at 02:00:08PM -0700, jeff hammond wrote:
> I am creating a .md file for a processor we are
> developing and ran into a problem with divmodhi4.
>
> The instruction that our processor uses for a
> divmodhi4 always put the remainder in the
> register just after the quotient. If the
> quotient goes in register N, the remainder always
> goes in register N+1. I have no idea how to
> express this in rtx. Can anyone suggest a good
> example or point to where this is documented?
I usually express it using a temporary type that is big enough to hold two
registers (SI in this case):
[(set (match_operand:HI 0 "register_operand" "=r")
(div:HI (match_operand:HI 1 "register_operand" "r")
(match_operand:HI 2 "register_operand" "r")))
(set (match_operand:HI 3 "register_operand" "=r")
(mod:HI (match_dup 1)
(match_dup 2)))
(clobber (match_scratch:SI 4 "=&r"))]
""
"divmod %4,%1,%2\;move %4,%0\;move %L4,%1"
where print_operand code 'L' prints the second register in a 2 register type.
To get fancier, you can define just div/mod patterns to avoid a second useless
move where you only want a div or mod (and keeping divmodhi4 for cases where
you want both), and then split the pattern after reload into component
instructions.
--
Michael Meissner, Cygnus Solutions, a Red Hat company.
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work: meissner@redhat.com phone: +1 978-486-9304
Non-work: meissner@spectacle-pond.org fax: +1 978-692-4482