Skip to content

Commit

Permalink
Add support for btf_tag annotations
Browse files Browse the repository at this point in the history
This paves the way for an eventual fix for
GaloisInc/llvm-pretty-bc-parser#188.
  • Loading branch information
RyanGlScott committed Apr 10, 2023
1 parent 22a2c22 commit f06ba63
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Text/LLVM/AST.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,8 @@ data DICompositeType' lab = DICompositeType
, dictAssociated :: Maybe (ValMd' lab)
, dictAllocated :: Maybe (ValMd' lab)
, dictRank :: Maybe (ValMd' lab)
, dictAnnotations :: Maybe (ValMd' lab)
-- ^ Introduced in LLVM 14.
} deriving (Data, Eq, Functor, Generic, Generic1, Ord, Show, Typeable)

type DICompositeType = DICompositeType' BlockLabel
Expand All @@ -1292,6 +1294,8 @@ data DIDerivedType' lab = DIDerivedType
--
-- The 'Maybe' encodes the possibility that there is no associated address
-- space (in LLVM, the sentinel value @0@ is used for this).
, didtAnnotations :: Maybe (ValMd' lab)
-- ^ Introduced in LLVM 14
} deriving (Data, Eq, Functor, Generic, Generic1, Ord, Show, Typeable)

type DIDerivedType = DIDerivedType' BlockLabel
Expand All @@ -1317,6 +1321,8 @@ data DIGlobalVariable' lab = DIGlobalVariable
, digvVariable :: Maybe (ValMd' lab)
, digvDeclaration :: Maybe (ValMd' lab)
, digvAlignment :: Maybe Word32
, digvAnnotations :: Maybe (ValMd' lab)
-- ^ Introduced in LLVM 14.
} deriving (Data, Eq, Functor, Generic, Generic1, Ord, Show, Typeable)

type DIGlobalVariable = DIGlobalVariable' BlockLabel
Expand Down Expand Up @@ -1355,6 +1361,8 @@ data DILocalVariable' lab = DILocalVariable
, dilvFlags :: DIFlags
, dilvAlignment :: Maybe Word32
-- ^ Introduced in LLVM 4.
, dilvAnnotations :: Maybe (ValMd' lab)
-- ^ Introduced in LLVM 14.
} deriving (Data, Eq, Functor, Generic, Generic1, Ord, Show, Typeable)

type DILocalVariable = DILocalVariable' BlockLabel
Expand All @@ -1380,6 +1388,8 @@ data DISubprogram' lab = DISubprogram
, dispDeclaration :: Maybe (ValMd' lab)
, dispRetainedNodes :: Maybe (ValMd' lab)
, dispThrownTypes :: Maybe (ValMd' lab)
, dispAnnotations :: Maybe (ValMd' lab)
-- ^ Introduced in LLVM 14.
} deriving (Data, Eq, Functor, Generic, Generic1, Ord, Show, Typeable)

type DISubprogram = DISubprogram' BlockLabel
Expand Down
5 changes: 5 additions & 0 deletions src/Text/LLVM/PP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,7 @@ ppDICompositeType' pp ct = "!DICompositeType"
, (("associated:" <+>) . ppValMd' pp) <$> (dictAssociated ct)
, (("allocated:" <+>) . ppValMd' pp) <$> (dictAllocated ct)
, (("rank:" <+>) . ppValMd' pp) <$> (dictRank ct)
, (("annotations:" <+>) . ppValMd' pp) <$> (dictAnnotations ct)
])

ppDICompositeType :: LLVM => DICompositeType -> Doc
Expand All @@ -1071,6 +1072,7 @@ ppDIDerivedType' pp dt = "!DIDerivedType"
, pure ("flags:" <+> integral (didtFlags dt))
, (("extraData:" <+>) . ppValMd' pp) <$> (didtExtraData dt)
, (("dwarfAddressSpace:" <+>) . integral) <$> didtDwarfAddressSpace dt
, (("annotations:" <+>) . ppValMd' pp) <$> (didtAnnotations dt)
])

ppDIDerivedType :: LLVM => DIDerivedType -> Doc
Expand Down Expand Up @@ -1108,6 +1110,7 @@ ppDIGlobalVariable' pp gv = "!DIGlobalVariable"
, (("variable:" <+>) . ppValMd' pp) <$> (digvVariable gv)
, (("declaration:" <+>) . ppValMd' pp) <$> (digvDeclaration gv)
, (("align:" <+>) . integral) <$> digvAlignment gv
, (("annotations:" <+>) . ppValMd' pp) <$> (digvAnnotations gv)
])

ppDIGlobalVariable :: LLVM => DIGlobalVariable -> Doc
Expand Down Expand Up @@ -1157,6 +1160,7 @@ ppDILocalVariable' pp lv = "!DILocalVariable"
, pure ("arg:" <+> integral (dilvArg lv))
, pure ("flags:" <+> integral (dilvFlags lv))
, (("align:" <+>) . integral) <$> dilvAlignment lv
, (("annotations:" <+>) . ppValMd' pp) <$> (dilvAnnotations lv)
])

ppDILocalVariable :: LLVM => DILocalVariable -> Doc
Expand Down Expand Up @@ -1189,6 +1193,7 @@ ppDISubprogram' pp sp = "!DISubprogram"
, (("declaration:" <+>) . ppValMd' pp) <$> (dispDeclaration sp)
, (("retainedNodes:" <+>) . ppValMd' pp) <$> (dispRetainedNodes sp)
, (("thrownTypes:" <+>) . ppValMd' pp) <$> (dispThrownTypes sp)
, (("annotations:" <+>) . ppValMd' pp) <$> (dispAnnotations sp)
])

ppDISubprogram :: LLVM => DISubprogram -> Doc
Expand Down

0 comments on commit f06ba63

Please sign in to comment.