From d099d5d0feab8066bc682f11c8a46c82fb7166b5 Mon Sep 17 00:00:00 2001 From: Ryan Scott Date: Sun, 15 May 2022 09:58:49 -0400 Subject: [PATCH] Add support for `btf_tag` annotations This paves the way for an eventual fix for https://github.com/GaloisInc/llvm-pretty-bc-parser/issues/188. --- src/Text/LLVM/AST.hs | 10 ++++++++++ src/Text/LLVM/PP.hs | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/src/Text/LLVM/AST.hs b/src/Text/LLVM/AST.hs index 525bee5..456e591 100644 --- a/src/Text/LLVM/AST.hs +++ b/src/Text/LLVM/AST.hs @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/src/Text/LLVM/PP.hs b/src/Text/LLVM/PP.hs index d46f48d..6bd97e3 100644 --- a/src/Text/LLVM/PP.hs +++ b/src/Text/LLVM/PP.hs @@ -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 @@ -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 @@ -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 @@ -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 @@ -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