-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
{crucible,crux}-llvm: Adapt to GaloisInc/llvm-pretty#118 (#1162)
This patch: * Bumps the `llvm-pretty` and `llvm-pretty-bc-parser` submodules to recent commits that include the changes from GaloisInc/llvm-pretty#118. * Introduces a `ppLLVMLatest` combinator to `Lang.Crucible.LLVM.PrettyPrint` that prints a `Fmt` value (from `Text.LLVM.PP`) using the latest version of LLVM that `llvm-pretty` supports. * Uses `ppLLVMLatest` in the appropriate places to fix compilation errors. Fixes #1145.
- Loading branch information
1 parent
0e097d5
commit c4e01c5
Showing
13 changed files
with
80 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,19 +6,38 @@ | |
-- License : BSD3 | ||
-- Maintainer : Rob Dockins <[email protected]> | ||
-- Stability : provisional | ||
-- | ||
-- This module defines several functions whose names clash with functions | ||
-- offered elsewhere in @llvm-pretty@ (e.g., "Text.LLVM.PP") and in | ||
-- @crucible-llvm@ (e.g., "Lang.Crucible.LLVM.MemModel.MemLog"). For this | ||
-- reason, it is recommended to import this module qualified. | ||
------------------------------------------------------------------------ | ||
|
||
{-# LANGUAGE ImplicitParams #-} | ||
{-# LANGUAGE RankNTypes #-} | ||
module Lang.Crucible.LLVM.PrettyPrint | ||
( commaSepList | ||
, ppIntType | ||
, ppPtrType | ||
, ppArrayType | ||
, ppVectorType | ||
, ppIntVector | ||
|
||
-- * @llvm-pretty@ printing with the latest LLVM version | ||
, ppLLVMLatest | ||
, ppDeclare | ||
, ppIdent | ||
, ppSymbol | ||
, ppType | ||
, ppValue | ||
) where | ||
|
||
import Numeric.Natural | ||
import Prettyprinter | ||
import qualified Text.PrettyPrint.HughesPJ as HPJ | ||
|
||
import qualified Text.LLVM.AST as L | ||
import qualified Text.LLVM.PP as L | ||
|
||
-- | Print list of documents separated by commas and spaces. | ||
commaSepList :: [Doc ann] -> Doc ann | ||
|
@@ -40,3 +59,39 @@ ppVectorType n e = angles (pretty (toInteger n) <+> pretty 'x' <+> e) | |
|
||
ppIntVector :: Integral a => Natural -> a -> Doc ann | ||
ppIntVector n w = ppVectorType n (ppIntType w) | ||
|
||
-- | Pretty-print an LLVM-related AST in accordance with the latest LLVM version | ||
-- that @llvm-pretty@ currently supports (i.e., the value of 'L.llvmVlatest'.) | ||
-- | ||
-- Note that we are mainly using the @llvm-pretty@ printer in @crucible-llvm@ | ||
-- for the sake of defining 'Show' instances and creating error messages, not | ||
-- for creating machine-readable LLVM code. As a result, it doesn't particularly | ||
-- matter which LLVM version we use, as any version-specific differences in | ||
-- pretty-printer output won't be that impactful. | ||
ppLLVMLatest :: ((?config :: L.Config) => a) -> a | ||
ppLLVMLatest = L.withConfig (L.Config { L.cfgVer = L.llvmVlatest }) | ||
|
||
-- | Invoke 'L.ppDeclare' in accordance with the latest LLVM version that | ||
-- @llvm-pretty@ supports. | ||
ppDeclare :: L.Declare -> HPJ.Doc | ||
ppDeclare = ppLLVMLatest L.ppDeclare | ||
|
||
-- | Invoke 'L.ppIdent' in accordance with the latest LLVM version that | ||
-- @llvm-pretty@ supports. | ||
ppIdent :: L.Ident -> HPJ.Doc | ||
ppIdent = ppLLVMLatest L.ppIdent | ||
|
||
-- | Invoke 'L.ppSymbol' in accordance with the latest LLVM version that | ||
-- @llvm-pretty@ supports. | ||
ppSymbol :: L.Symbol -> HPJ.Doc | ||
ppSymbol = ppLLVMLatest L.ppSymbol | ||
|
||
-- | Invoke 'L.ppType' in accordance with the latest LLVM version that | ||
-- @llvm-pretty@ supports. | ||
ppType :: L.Type -> HPJ.Doc | ||
ppType = ppLLVMLatest L.ppType | ||
|
||
-- | Invoke 'L.ppValue' in accordance with the latest LLVM version that | ||
-- @llvm-pretty@ supports. | ||
ppValue :: L.Value -> HPJ.Doc | ||
ppValue = ppLLVMLatest L.ppValue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule llvm-pretty
updated
from 94e384 to 8124fc
Submodule llvm-pretty-bc-parser
updated
31 files