]> git.proxmox.com Git - mirror_qemu.git/commit - tcg/sparc/tcg-target.c
tcg-sparc: Implement division properly.
authorRichard Henderson <rth@twiddle.net>
Tue, 12 Jan 2010 19:59:33 +0000 (19:59 +0000)
committerBlue Swirl <blauwirbel@gmail.com>
Tue, 12 Jan 2010 19:59:33 +0000 (19:59 +0000)
commit583d121520a81d07bacee7ebe9366d107c8b18b6
treeedaa4e9824a7b3e99886da07c3fe1a6bb0c61b25
parent5e143c43a686d5563b3a8c9d46b338967cc8d09c
tcg-sparc: Implement division properly.

The {div,divu}2 opcodes are intended for systems for which the
division instruction produces both quotient and remainder.  Sparc
is not such a system.  Indeed, the remainder must be computed as

  quot = a / b
  rem = a - (quot * b)

Split out a tcg_out_div32 function that properly initializes Y
with the extension of the input to 64-bits.  Discard the code
that used the 64-bit DIVX on sparc9/sparcv8plus without extending
the inputs to 64-bits.  Implement remainders in terms of division
followed by multiplication.

Signed-off-by: Richard Henderson <rth@twiddle.net>
[blauwirbel@gmail.com: applied rth's typo fix in tcg_out_div32]
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
tcg/sparc/tcg-target.c
tcg/sparc/tcg-target.h