From 919776f50ae62b791e61c689ca487f82eabc4f82 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Wed, 19 Apr 2023 17:45:44 -0700 Subject: [PATCH] merge integer min/max instructions and correct section ordering --- openpower/sv/rfc/ls013.mdwn | 124 ++++++++---------------------------- 1 file changed, 26 insertions(+), 98 deletions(-) diff --git a/openpower/sv/rfc/ls013.mdwn b/openpower/sv/rfc/ls013.mdwn index d7c91064b..8145cd18c 100644 --- a/openpower/sv/rfc/ls013.mdwn +++ b/openpower/sv/rfc/ls013.mdwn @@ -220,116 +220,44 @@ semantics therefore Saturated variants of these instructions need not be propose | 101 | `maxuw RT,RA,RB` | `RT = (uint32_t)RA > (uint32_t)RB ? RA : RB` | | 110 | `minsw RT,RA,RB` | `RT = (int32_t)RA < (int32_t)RB ? RA : RB` | | 111 | `maxsw RT,RA,RB` | `RT = (int32_t)RA > (int32_t)RB ? RA : RB` | - -## Minimum Unsigned -X-Form +## Integer Min/Max MM-Form -``` - |0 |6 |11 |16 |21 |31 | - | PO | RT | RA | RB | XO | Rc | -``` - -* minu RT, RA, RB -* minu. RT, RA, RB - - -``` - if (RA) u (RB) then - RT <- (RA) - else - RT <- (RB) -``` - -Special Registers altered: - -``` - CR0 (if Rc=1) -``` - -Compute the unsigned maximum of RA and RB and store the result in RT. - -\newpage{} - -## Minimum - -X-Form - -``` - min RT, RA, RB - min. RT, RA, RB -``` - -``` - |0 |6 |11 |16 |21 |31 | - | PO | RT | RA | RB | XO | Rc | -``` - -``` - if (RA) < (RB) then - RT <- (RA) - else - RT <- (RB) -``` - -Special Registers altered: - -``` - CR0 (if Rc=1) -``` -Compute the signed minimum of RA and RB and store the result in RT. - -## Maximum - -X-Form - -``` - max RT, RA, RB - max. RT, RA, RB -``` +* minmax RT, RA, RB, MMM +* minmax. RT, RA, RB, MMM ``` - |0 |6 |11 |16 |21 |31 | - | PO | RT | RA | RB | XO | Rc | + |0 |6 |11 |16 |21 |24 |25 |31 | + | PO | RT | RA | RB | MMM | / | XO | Rc | ``` ``` - if (RA) > (RB) then + a <- (RA) + b <- (RB) + if MMM[0] then # word mode + # shift left by XLEN/2 to make the dword comparison + # do word comparison of the original inputs + a <- a[XLEN/2:XLEN-1] || [0] * XLEN/2 + b <- b[XLEN/2:XLEN-1] || [0] * XLEN/2 + if MMM[1] then # signed mode + # invert sign bits to make the unsigned comparison + # do signed comparison of the original inputs + a[0] <- !a[0] # convert + b[0] <- !b[0] + if MMM[2] then # max mode + # swap a and b to make the less than comparison do + # greater than comparison of the original inputs + t <- a + a <- b + b <- t + if a