Use Pretty instances also for partial instructions

This commit is contained in:
Francesco Gazzetta
2022-07-03 11:06:51 +02:00
parent e6f660011e
commit 993319cf62

View File

@@ -420,22 +420,19 @@ data Comparison
| Uo -- ^ unordered (at least one operand is a NaN) (floating point only) | Uo -- ^ unordered (at least one operand is a NaN) (floating point only)
deriving (Show, Eq) deriving (Show, Eq)
-- | This is not a 'Pretty' instance because it only builds _part_ of the instance Pretty Comparison where
-- instruction (for example "ule" instead of "culew" pretty Eq = "eq"
prettyComparison :: Comparison -> Doc ann pretty Ne = "ne"
prettyComparison Eq = "eq" pretty (Le intRepr) = pretty intRepr <> "le"
prettyComparison Ne = "ne" pretty (Lt intRepr) = pretty intRepr <> "lt"
prettyComparison (Le intRepr) = prettyMaybeIntRepr intRepr <> "le" pretty (Ge intRepr) = pretty intRepr <> "ge"
prettyComparison (Lt intRepr) = prettyMaybeIntRepr intRepr <> "lt" pretty (Gt intRepr) = pretty intRepr <> "gt"
prettyComparison (Ge intRepr) = prettyMaybeIntRepr intRepr <> "ge" pretty O = "o"
prettyComparison (Gt intRepr) = prettyMaybeIntRepr intRepr <> "gt" pretty Uo = "uo"
prettyComparison O = "o"
prettyComparison Uo = "uo"
prettyMaybeIntRepr :: Maybe IntRepr -> Doc ann instance Pretty IntRepr where
prettyMaybeIntRepr Nothing = mempty pretty Signed = pretty 's'
prettyMaybeIntRepr (Just Signed) = pretty 's' pretty Unsigned = pretty 'u'
prettyMaybeIntRepr (Just Unsigned) = pretty 'u'
data Arg = Arg AbiTy Val data Arg = Arg AbiTy Val
deriving (Show, Eq) deriving (Show, Eq)