packages feed

llvm-hs-pretty 0.6.2.0 → 0.9.0.0

raw patch · 5 files changed

+29/−20 lines, 5 filesdep ~llvm-hsdep ~llvm-hs-purePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: llvm-hs, llvm-hs-pure

API changes (from Hackage documentation)

Files

LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2014-2017 Stephen Diehl+Copyright (c) 2014-2020 Stephen Diehl Copyright (c) 2015 Cedric Shock  Permission is hereby granted, free of charge, to any person obtaining
README.md view
@@ -8,6 +8,11 @@ sufficiently large subset of the LLVM AST from pure Haskell without having to go through the C++ API. +> **Note**: It is possible to construct llvm-hs-pure ASTs that are invalid ASTs+> and as such there is no meaningful way to print them. Always run the LLVM+> verifier on your AST to test it is sound. If you encounter incomplete pattern+> matches using this library you likely have constructed invalid IR.+ Usage ----- @@ -29,12 +34,12 @@  ```bash # This is only necessary for running the test suite-sudo apt-get install llvm-dev-5.0+sudo apt-get install llvm-9-dev ```  The test suite currently consists of round tripping a LLVM IR from correct IR-outputted by the llc toolchain, parsing into llvm-general AST and then printing-it back out and comparing it with the original textual form to see if the pretty+outputted by the llc toolchain, parsing into llvm-hs AST and then printing it+back out and comparing it with the original textual form to see if the pretty printer faithfully preserves the structure. The sample modules are in ``tests/``. @@ -148,5 +153,5 @@  Released under the MIT License. -Copyright (c) 2014-2018, Stephen Diehl+Copyright (c) 2014-2020, Stephen Diehl Copyright (c) 2015 Cedric Shock
llvm-hs-pretty.cabal view
@@ -1,5 +1,5 @@ name:                llvm-hs-pretty-version:             0.6.2.0+version:             0.9.0.0 license:             MIT synopsis:            A pretty printer for LLVM IR.  description:         A pretty printer for the LLVM AST types provided by llvm-hs.@@ -20,8 +20,6 @@   hs-source-dirs:      src   exposed-modules:          LLVM.Pretty-  other-modules:-    LLVM.Token   ghc-options:     -fwarn-incomplete-patterns   default-language:    Haskell2010@@ -29,7 +27,7 @@     array                >= 0.5,     base                 >= 4.6   && < 5.0,     bytestring           >= 0.10,-    llvm-hs-pure         >= 8.0,+    llvm-hs-pure         >= 9.0  && < 10.0,     text                 >= 0.1,     prettyprinter        >= 1.2 @@ -50,5 +48,5 @@     tasty-hunit          -any,     tasty-golden         >= 1.1,     llvm-hs-pretty       -any,-    llvm-hs              >= 8.0,-    llvm-hs-pure         >= 8.0+    llvm-hs              >= 9.0  && < 10.0,+    llvm-hs-pure         >= 9.0  && < 10.0
src/LLVM/Pretty.hs view
@@ -372,6 +372,7 @@     Returned                   -> "returned"     SwiftSelf                  -> "swiftself"     SwiftError                 -> "swifterror"+    ImmArg                     -> "imgarg"     PA.StringAttribute k v -> dquotes (short k) <> "=" <> dquotes (short v)  instance Pretty CC.CallingConvention where@@ -527,7 +528,10 @@                                         Just o -> "," <+> ppTyped o     Store {..}  -> "store" <+> ppVolatile volatile <+> ppTyped value `cma` ppTyped address <> ppAlign alignment <+> ppInstrMeta metadata     Load {..}   -> "load" <+> ppVolatile volatile <+> pretty argTy `cma` ppTyped address <> ppAlign alignment <+> ppInstrMeta metadata-      where PointerType argTy _ = typeOf address+      where+        argTy = case typeOf address of+          PointerType argTy_ _ -> argTy_+          _ -> error "invalid load of non-pointer type. (Malformed AST)"     Phi {..}    -> "phi" <+> pretty type' <+> commas (fmap phiIncoming incomingValues) <+> ppInstrMeta metadata      ICmp {..}   -> "icmp" <+> pretty iPredicate <+> ppTyped operand0 `cma` pretty operand1 <+> ppInstrMeta metadata@@ -575,7 +579,7 @@       bounds True = "inbounds"       bounds False = mempty -      ppInstrWithNuwNsw :: Doc ann -> Bool -> Bool -> Operand -> Operand -> InstructionMetadata -> Doc ann +      ppInstrWithNuwNsw :: Doc ann -> Bool -> Bool -> Operand -> Operand -> InstructionMetadata -> Doc ann       ppInstrWithNuwNsw name nuw nsw op0 op1 metadata =         name         <+> ppBool "nuw" nuw@@ -1120,7 +1124,9 @@    pretty C.GetElementPtr {..} = "getelementptr" <+> bounds inBounds <+> parens (commas (pretty argTy : fmap ppTyped (address:indices)))     where-      PointerType argTy _ = typeOf address+      argTy = case typeOf address of+        PointerType argTy_ _ -> argTy_+        _ -> error "invalid load of non-pointer type. (Malformed AST)"       bounds True = "inbounds"       bounds False = mempty @@ -1283,7 +1289,7 @@     where       (functionType@FunctionType {..}) = case (referencedType (typeOf f)) of                                            fty@FunctionType {..} -> fty-                                           _ -> error "Calling non function type"+                                           _ -> error "Calling non function type. (Malformed AST)"       ftype = if isVarArg               then ppFunctionArgumentTypes functionType               else mempty@@ -1323,7 +1329,10 @@   = "invoke" <+> pretty callingConvention' <+> pretty resultType <+> ftype     <+> pretty f <> parens (commas $ fmap ppArguments arguments') <+> ppFunctionAttributes functionAttributes'     where-      (functionType@FunctionType {..}) = referencedType (typeOf f)+      (functionType@FunctionType {..}) =+        case referencedType (typeOf f) of+          fty@FunctionType{..} -> fty+          _ -> error "Invoking non-function type. (Malformed AST)"       ftype = if isVarArg               then ppFunctionArgumentTypes functionType               else mempty@@ -1363,7 +1372,7 @@  -- | Pretty print a LLVM module ppllvm :: Module -> Text-ppllvm = renderLazy . layoutPretty ppLayoutOptions . pretty +ppllvm = renderLazy . layoutPretty ppLayoutOptions . pretty  -- | Pretty print a printable LLVM expression ppll :: Pretty a => a -> Text
− src/LLVM/Token.hs
@@ -1,3 +0,0 @@-module LLVM.Token where--import Data.Text