whitespace only
[ghc.git] / compiler / nativeGen / X86 / Cond.hs
1 module X86.Cond (
2 Cond(..),
3 condUnsigned,
4 condToSigned,
5 condToUnsigned,
6 maybeFlipCond
7 )
8
9 where
10
11 data Cond
12 = ALWAYS -- What's really used? ToDo
13 | EQQ
14 | GE
15 | GEU
16 | GTT
17 | GU
18 | LE
19 | LEU
20 | LTT
21 | LU
22 | NE
23 | NEG
24 | POS
25 | CARRY
26 | OFLO
27 | PARITY
28 | NOTPARITY
29 deriving Eq
30
31 condUnsigned :: Cond -> Bool
32 condUnsigned GU = True
33 condUnsigned LU = True
34 condUnsigned GEU = True
35 condUnsigned LEU = True
36 condUnsigned _ = False
37
38
39 condToSigned :: Cond -> Cond
40 condToSigned GU = GTT
41 condToSigned LU = LTT
42 condToSigned GEU = GE
43 condToSigned LEU = LE
44 condToSigned x = x
45
46
47 condToUnsigned :: Cond -> Cond
48 condToUnsigned GTT = GU
49 condToUnsigned LTT = LU
50 condToUnsigned GE = GEU
51 condToUnsigned LE = LEU
52 condToUnsigned x = x
53
54 -- | @maybeFlipCond c@ returns @Just c'@ if it is possible to flip the
55 -- arguments to the conditional @c@, and the new condition should be @c'@.
56 maybeFlipCond :: Cond -> Maybe Cond
57 maybeFlipCond cond = case cond of
58 EQQ -> Just EQQ
59 NE -> Just NE
60 LU -> Just GU
61 GU -> Just LU
62 LEU -> Just GEU
63 GEU -> Just LEU
64 LTT -> Just GTT
65 GTT -> Just LTT
66 LE -> Just GE
67 GE -> Just LE
68 _other -> Nothing