Skip to content

Commit

Permalink
Add DIGlobalVariableExpression, dicuSplitDebugInlining, digvAlignment
Browse files Browse the repository at this point in the history
These fields and type are new in LLVM 4.0
  • Loading branch information
glguy committed Feb 24, 2017
1 parent 9ff4eb4 commit e4c382e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 14 deletions.
11 changes: 11 additions & 0 deletions src/Text/LLVM/AST.hs
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,7 @@ data DebugInfo' lab
| DebugInfoExpression DIExpression
| DebugInfoFile DIFile
| DebugInfoGlobalVariable (DIGlobalVariable' lab)
| DebugInfoGlobalVariableExpression (DIGlobalVariableExpression' lab)
| DebugInfoLexicalBlock (DILexicalBlock' lab)
| DebugInfoLexicalBlockFile (DILexicalBlockFile' lab)
| DebugInfoLocalVariable (DILocalVariable' lab)
Expand Down Expand Up @@ -987,6 +988,7 @@ data DICompileUnit' lab = DICompileUnit
, dicuImports :: Maybe (ValMd' lab)
, dicuMacros :: Maybe (ValMd' lab)
, dicuDWOId :: Word64
, dicuSplitDebugInlining :: Bool
}
deriving (Show,Functor,Generic,Generic1)

Expand Down Expand Up @@ -1051,11 +1053,20 @@ data DIGlobalVariable' lab = DIGlobalVariable
, digvIsDefinition :: Bool
, digvVariable :: Maybe (ValMd' lab)
, digvDeclaration :: Maybe (ValMd' lab)
, digvAlignment :: Maybe Word32
}
deriving (Show,Functor,Generic,Generic1)

type DIGlobalVariable = DIGlobalVariable' BlockLabel

data DIGlobalVariableExpression' lab = DIGlobalVariableExpression
{ digveVariable :: Maybe (ValMd' lab)
, digveExpression :: Maybe (ValMd' lab)
}
deriving (Show,Functor,Generic,Generic1)

type DIGlobalVariableExpression = DIGlobalVariableExpression' BlockLabel

data DILexicalBlock' lab = DILexicalBlock
{ dilbScope :: Maybe (ValMd' lab)
, dilbFile :: Maybe (ValMd' lab)
Expand Down
29 changes: 15 additions & 14 deletions src/Text/LLVM/Labels.hs
Original file line number Diff line number Diff line change
Expand Up @@ -148,20 +148,21 @@ instance HasLabel Instr' where

relabel f (Resume tv) = Resume <$> traverse (relabel f) tv

instance HasLabel Clause' where relabel = genericRelabel
instance HasLabel Value' where relabel = genericRelabel
instance HasLabel ValMd' where relabel = genericRelabel
instance HasLabel DebugLoc' where relabel = genericRelabel
instance HasLabel DebugInfo' where relabel = genericRelabel
instance HasLabel DIDerivedType' where relabel = genericRelabel
instance HasLabel DISubroutineType' where relabel = genericRelabel
instance HasLabel DIGlobalVariable' where relabel = genericRelabel
instance HasLabel DILocalVariable' where relabel = genericRelabel
instance HasLabel DISubprogram' where relabel = genericRelabel
instance HasLabel DICompositeType' where relabel = genericRelabel
instance HasLabel DILexicalBlock' where relabel = genericRelabel
instance HasLabel DICompileUnit' where relabel = genericRelabel
instance HasLabel DILexicalBlockFile' where relabel = genericRelabel
instance HasLabel Clause' where relabel = genericRelabel
instance HasLabel Value' where relabel = genericRelabel
instance HasLabel ValMd' where relabel = genericRelabel
instance HasLabel DebugLoc' where relabel = genericRelabel
instance HasLabel DebugInfo' where relabel = genericRelabel
instance HasLabel DIDerivedType' where relabel = genericRelabel
instance HasLabel DISubroutineType' where relabel = genericRelabel
instance HasLabel DIGlobalVariable' where relabel = genericRelabel
instance HasLabel DIGlobalVariableExpression' where relabel = genericRelabel
instance HasLabel DILocalVariable' where relabel = genericRelabel
instance HasLabel DISubprogram' where relabel = genericRelabel
instance HasLabel DICompositeType' where relabel = genericRelabel
instance HasLabel DILexicalBlock' where relabel = genericRelabel
instance HasLabel DICompileUnit' where relabel = genericRelabel
instance HasLabel DILexicalBlockFile' where relabel = genericRelabel

-- | Clever instance that actually uses the block name
instance HasLabel ConstExpr' where
Expand Down
9 changes: 9 additions & 0 deletions src/Text/LLVM/PP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ ppDebugInfo di = case di of
DebugInfoExpression e -> ppDIExpression e
DebugInfoFile f -> ppDIFile f
DebugInfoGlobalVariable gv -> ppDIGlobalVariable gv
DebugInfoGlobalVariableExpression gv -> ppDIGlobalVariableExpression gv
DebugInfoLexicalBlock lb -> ppDILexicalBlock lb
DebugInfoLexicalBlockFile lbf -> ppDILexicalBlockFile lbf
DebugInfoLocalVariable lv -> ppDILocalVariable lv
Expand Down Expand Up @@ -746,6 +747,14 @@ ppDIGlobalVariable gv = "!DIGlobalVariable"
, pure ("isDefinition:" <+> ppBool (digvIsDefinition gv))
, (("variable:" <+>) . ppValMd) <$> (digvType gv)
, (("declaration:" <+>) . ppValMd) <$> (digvDeclaration gv)
, (("align:" <+>) . integral) <$> digvAlignment gv
])

ppDIGlobalVariableExpression :: DIGlobalVariableExpression -> Doc
ppDIGlobalVariableExpression gve = "!DIGlobalVariableExpression"
<> parens (mcommas
[ (("var:" <+>) . ppValMd) <$> (digveVariable gve)
, (("expr:" <+>) . ppValMd) <$> (digveExpression gve)
])

ppDILexicalBlock :: DILexicalBlock -> Doc
Expand Down

0 comments on commit e4c382e

Please sign in to comment.