mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 09:43:56 -06:00
host-utils: move checks out of divu128/divs128
In preparation for changing the divu128/divs128 implementations to allow for quotients larger than 64 bits, move the div-by-zero and overflow checks to the callers. Signed-off-by: Luis Pires <luis.pires@eldorado.org.br> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20211025191154.350831-2-luis.pires@eldorado.org.br> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
1c46937358
commit
9276a31c34
4 changed files with 42 additions and 51 deletions
|
@ -104,10 +104,11 @@ uint64_t helper_divdeu(CPUPPCState *env, uint64_t ra, uint64_t rb, uint32_t oe)
|
|||
uint64_t rt = 0;
|
||||
int overflow = 0;
|
||||
|
||||
overflow = divu128(&rt, &ra, rb);
|
||||
|
||||
if (unlikely(overflow)) {
|
||||
if (unlikely(rb == 0 || ra >= rb)) {
|
||||
overflow = 1;
|
||||
rt = 0; /* Undefined */
|
||||
} else {
|
||||
divu128(&rt, &ra, rb);
|
||||
}
|
||||
|
||||
if (oe) {
|
||||
|
@ -122,10 +123,13 @@ uint64_t helper_divde(CPUPPCState *env, uint64_t rau, uint64_t rbu, uint32_t oe)
|
|||
int64_t rt = 0;
|
||||
int64_t ra = (int64_t)rau;
|
||||
int64_t rb = (int64_t)rbu;
|
||||
int overflow = divs128(&rt, &ra, rb);
|
||||
int overflow = 0;
|
||||
|
||||
if (unlikely(overflow)) {
|
||||
if (unlikely(rb == 0 || uabs64(ra) >= uabs64(rb))) {
|
||||
overflow = 1;
|
||||
rt = 0; /* Undefined */
|
||||
} else {
|
||||
divs128(&rt, &ra, rb);
|
||||
}
|
||||
|
||||
if (oe) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue