{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Llvm.MetaData where
import GhcPrelude
import Llvm.Types
import Outputable
newtype MetaId = MetaId Int
deriving (MetaId -> MetaId -> Bool
(MetaId -> MetaId -> Bool)
-> (MetaId -> MetaId -> Bool) -> Eq MetaId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetaId -> MetaId -> Bool
$c/= :: MetaId -> MetaId -> Bool
== :: MetaId -> MetaId -> Bool
$c== :: MetaId -> MetaId -> Bool
Eq, Eq MetaId
Eq MetaId
-> (MetaId -> MetaId -> Ordering)
-> (MetaId -> MetaId -> Bool)
-> (MetaId -> MetaId -> Bool)
-> (MetaId -> MetaId -> Bool)
-> (MetaId -> MetaId -> Bool)
-> (MetaId -> MetaId -> MetaId)
-> (MetaId -> MetaId -> MetaId)
-> Ord MetaId
MetaId -> MetaId -> Bool
MetaId -> MetaId -> Ordering
MetaId -> MetaId -> MetaId
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: MetaId -> MetaId -> MetaId
$cmin :: MetaId -> MetaId -> MetaId
max :: MetaId -> MetaId -> MetaId
$cmax :: MetaId -> MetaId -> MetaId
>= :: MetaId -> MetaId -> Bool
$c>= :: MetaId -> MetaId -> Bool
> :: MetaId -> MetaId -> Bool
$c> :: MetaId -> MetaId -> Bool
<= :: MetaId -> MetaId -> Bool
$c<= :: MetaId -> MetaId -> Bool
< :: MetaId -> MetaId -> Bool
$c< :: MetaId -> MetaId -> Bool
compare :: MetaId -> MetaId -> Ordering
$ccompare :: MetaId -> MetaId -> Ordering
$cp1Ord :: Eq MetaId
Ord, Int -> MetaId
MetaId -> Int
MetaId -> [MetaId]
MetaId -> MetaId
MetaId -> MetaId -> [MetaId]
MetaId -> MetaId -> MetaId -> [MetaId]
(MetaId -> MetaId)
-> (MetaId -> MetaId)
-> (Int -> MetaId)
-> (MetaId -> Int)
-> (MetaId -> [MetaId])
-> (MetaId -> MetaId -> [MetaId])
-> (MetaId -> MetaId -> [MetaId])
-> (MetaId -> MetaId -> MetaId -> [MetaId])
-> Enum MetaId
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: MetaId -> MetaId -> MetaId -> [MetaId]
$cenumFromThenTo :: MetaId -> MetaId -> MetaId -> [MetaId]
enumFromTo :: MetaId -> MetaId -> [MetaId]
$cenumFromTo :: MetaId -> MetaId -> [MetaId]
enumFromThen :: MetaId -> MetaId -> [MetaId]
$cenumFromThen :: MetaId -> MetaId -> [MetaId]
enumFrom :: MetaId -> [MetaId]
$cenumFrom :: MetaId -> [MetaId]
fromEnum :: MetaId -> Int
$cfromEnum :: MetaId -> Int
toEnum :: Int -> MetaId
$ctoEnum :: Int -> MetaId
pred :: MetaId -> MetaId
$cpred :: MetaId -> MetaId
succ :: MetaId -> MetaId
$csucc :: MetaId -> MetaId
Enum)
instance Outputable MetaId where
ppr :: MetaId -> SDoc
ppr (MetaId Int
n) = Char -> SDoc
char Char
'!' SDoc -> SDoc -> SDoc
<> Int -> SDoc
int Int
n
data MetaExpr = MetaStr !LMString
| MetaNode !MetaId
| MetaVar !LlvmVar
| MetaStruct [MetaExpr]
deriving (MetaExpr -> MetaExpr -> Bool
(MetaExpr -> MetaExpr -> Bool)
-> (MetaExpr -> MetaExpr -> Bool) -> Eq MetaExpr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetaExpr -> MetaExpr -> Bool
$c/= :: MetaExpr -> MetaExpr -> Bool
== :: MetaExpr -> MetaExpr -> Bool
$c== :: MetaExpr -> MetaExpr -> Bool
Eq)
instance Outputable MetaExpr where
ppr :: MetaExpr -> SDoc
ppr (MetaVar (LMLitVar (LMNullLit LlvmType
_))) = String -> SDoc
text String
"null"
ppr (MetaStr LMString
s ) = Char -> SDoc
char Char
'!' SDoc -> SDoc -> SDoc
<> SDoc -> SDoc
doubleQuotes (LMString -> SDoc
ftext LMString
s)
ppr (MetaNode MetaId
n ) = MetaId -> SDoc
forall a. Outputable a => a -> SDoc
ppr MetaId
n
ppr (MetaVar LlvmVar
v ) = LlvmVar -> SDoc
forall a. Outputable a => a -> SDoc
ppr LlvmVar
v
ppr (MetaStruct [MetaExpr]
es) = Char -> SDoc
char Char
'!' SDoc -> SDoc -> SDoc
<> SDoc -> SDoc
braces ([MetaExpr] -> SDoc
forall a. Outputable a => [a] -> SDoc
ppCommaJoin [MetaExpr]
es)
data MetaAnnot = MetaAnnot LMString MetaExpr
deriving (MetaAnnot -> MetaAnnot -> Bool
(MetaAnnot -> MetaAnnot -> Bool)
-> (MetaAnnot -> MetaAnnot -> Bool) -> Eq MetaAnnot
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetaAnnot -> MetaAnnot -> Bool
$c/= :: MetaAnnot -> MetaAnnot -> Bool
== :: MetaAnnot -> MetaAnnot -> Bool
$c== :: MetaAnnot -> MetaAnnot -> Bool
Eq)
data MetaDecl
= MetaNamed !LMString [MetaId]
| MetaUnnamed !MetaId !MetaExpr