Skip to content

Commit

Permalink
Support DIArgLists (added in LLVM 13) (GaloisInc#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanGlScott authored Mar 21, 2023
1 parent a272e38 commit 4318862
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Text/LLVM/AST.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,7 @@ data DebugInfo' lab
| DebugInfoTemplateValueParameter (DITemplateValueParameter' lab)
| DebugInfoImportedEntity (DIImportedEntity' lab)
| DebugInfoLabel (DILabel' lab)
| DebugInfoArgList (DIArgList' lab)
deriving (Data, Eq, Functor, Generic, Generic1, Ord, Show, Typeable)

type DebugInfo = DebugInfo' BlockLabel
Expand Down Expand Up @@ -1363,6 +1364,13 @@ data DISubroutineType' lab = DISubroutineType

type DISubroutineType = DISubroutineType' BlockLabel

-- | See <https://releases.llvm.org/13.0.0/docs/LangRef.html#diarglist>.
newtype DIArgList' lab = DIArgList
{ dialArgs :: [ValMd' lab]
} deriving (Data, Eq, Functor, Generic, Generic1, Ord, Show, Typeable)

type DIArgList = DIArgList' BlockLabel

-- Aggregate Utilities ---------------------------------------------------------

data IndexResult
Expand Down
1 change: 1 addition & 0 deletions src/Text/LLVM/Labels.hs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ instance HasLabel DINameSpace' where relabel = $(generateRelabel
instance HasLabel DITemplateTypeParameter' where relabel = $(generateRelabel 'relabel ''DITemplateTypeParameter')
instance HasLabel DITemplateValueParameter' where relabel = $(generateRelabel 'relabel ''DITemplateValueParameter')
instance HasLabel DIImportedEntity' where relabel = $(generateRelabel 'relabel ''DIImportedEntity')
instance HasLabel DIArgList' where relabel = $(generateRelabel 'relabel ''DIArgList')

-- | Clever instance that actually uses the block name
instance HasLabel ConstExpr' where
Expand Down
1 change: 1 addition & 0 deletions src/Text/LLVM/Lens.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ concat <$> mapM (makeLensesWith (lensRules & lensField .~ (\_ _ n -> [TopName $
, ''DIDerivedType'
, ''DILexicalBlock'
, ''DILexicalBlockFile'
, ''DIArgList'
, ''Instr'
, ''ValMd'
, ''ConvOp
Expand Down
8 changes: 8 additions & 0 deletions src/Text/LLVM/PP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,7 @@ ppDebugInfo' pp di = case di of
DebugInfoTemplateValueParameter dtvp -> ppDITemplateValueParameter' pp dtvp
DebugInfoImportedEntity diip -> ppDIImportedEntity' pp diip
DebugInfoLabel dil -> ppDILabel' pp dil
DebugInfoArgList args -> ppDIArgList' pp args

ppDebugInfo :: LLVM => DebugInfo -> Doc
ppDebugInfo = ppDebugInfo' ppLabel
Expand Down Expand Up @@ -1174,6 +1175,13 @@ ppDISubroutineType' pp st = "!DISubroutineType"
ppDISubroutineType :: LLVM => DISubroutineType -> Doc
ppDISubroutineType = ppDISubroutineType' ppLabel

ppDIArgList' :: LLVM => (i -> Doc) -> DIArgList' i -> Doc
ppDIArgList' pp args = "!DIArgList"
<> parens (commas (map (ppValMd' pp) (dialArgs args)))

ppDIArgList :: LLVM => DIArgList -> Doc
ppDIArgList = ppDIArgList' ppLabel

-- Utilities -------------------------------------------------------------------

ppBool :: Bool -> Doc
Expand Down

0 comments on commit 4318862

Please sign in to comment.