module PPC.Cond (
        Cond(..),
        condNegate,
        condUnsigned,
        condToSigned,
        condToUnsigned,
)

where

import GhcPrelude

import Panic

data Cond
        = ALWAYS
        | EQQ
        | GE
        | GEU
        | GTT
        | GU
        | LE
        | LEU
        | LTT
        | LU
        | NE
        deriving Cond -> Cond -> Bool
(Cond -> Cond -> Bool) -> (Cond -> Cond -> Bool) -> Eq Cond
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Cond -> Cond -> Bool
$c/= :: Cond -> Cond -> Bool
== :: Cond -> Cond -> Bool
$c== :: Cond -> Cond -> Bool
Eq


condNegate :: Cond -> Cond
condNegate :: Cond -> Cond
condNegate ALWAYS  = String -> Cond
forall a. String -> a
panic "condNegate: ALWAYS"
condNegate EQQ     = Cond
NE
condNegate GE      = Cond
LTT
condNegate GEU     = Cond
LU
condNegate GTT     = Cond
LE
condNegate GU      = Cond
LEU
condNegate LE      = Cond
GTT
condNegate LEU     = Cond
GU
condNegate LTT     = Cond
GE
condNegate LU      = Cond
GEU
condNegate NE      = Cond
EQQ

-- Condition utils
condUnsigned :: Cond -> Bool
condUnsigned :: Cond -> Bool
condUnsigned GU  = Bool
True
condUnsigned LU  = Bool
True
condUnsigned GEU = Bool
True
condUnsigned LEU = Bool
True
condUnsigned _   = Bool
False

condToSigned :: Cond -> Cond
condToSigned :: Cond -> Cond
condToSigned GU  = Cond
GTT
condToSigned LU  = Cond
LTT
condToSigned GEU = Cond
GE
condToSigned LEU = Cond
LE
condToSigned x :: Cond
x   = Cond
x

condToUnsigned :: Cond -> Cond
condToUnsigned :: Cond -> Cond
condToUnsigned GTT = Cond
GU
condToUnsigned LTT = Cond
LU
condToUnsigned GE  = Cond
GEU
condToUnsigned LE  = Cond
LEU
condToUnsigned x :: Cond
x   = Cond
x