module GHC.CmmToAsm.X86.Cond (
Cond(..),
condToUnsigned,
maybeFlipCond,
maybeInvertCond
)
where
import GHC.Prelude
data Cond
= ALWAYS
| EQQ
| GE
| GEU
| GTT
| GU
| LE
| LEU
| LTT
| LU
| NE
| NEG
| POS
| CARRY
| OFLO
| PARITY
| NOTPARITY
deriving Eq
condToUnsigned :: Cond -> Cond
condToUnsigned GTT = GU
condToUnsigned LTT = LU
condToUnsigned GE = GEU
condToUnsigned LE = LEU
condToUnsigned x = x
maybeFlipCond :: Cond -> Maybe Cond
maybeFlipCond cond = case cond of
EQQ -> Just EQQ
NE -> Just NE
LU -> Just GU
GU -> Just LU
LEU -> Just GEU
GEU -> Just LEU
LTT -> Just GTT
GTT -> Just LTT
LE -> Just GE
GE -> Just LE
_other -> Nothing
maybeInvertCond :: Cond -> Maybe Cond
maybeInvertCond cond = case cond of
ALWAYS -> Nothing
EQQ -> Just NE
NE -> Just EQQ
NEG -> Just POS
POS -> Just NEG
GEU -> Just LU
LU -> Just GEU
GE -> Just LTT
LTT -> Just GE
GTT -> Just LE
LE -> Just GTT
GU -> Just LEU
LEU -> Just GU
CARRY -> Just GEU
OFLO -> Nothing
PARITY -> Just NOTPARITY
NOTPARITY -> Just PARITY