Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial work on refactor to LLVM 9.0 #52

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update bounds
  • Loading branch information
sdiehl committed Feb 8, 2020
commit f5e3f6c0fc39d93bfcf9c94de10729c896383afd
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 102,4 @@ Text is adapted from the LLVM tutorial and is subsequently licensed under the
LLVM license.

The Haskell source files are released under the MIT license. Copyright (c)
2013-2016, Stephen Diehl
2013-2020, Stephen Diehl
215 changes: 96 additions & 119 deletions kaleidoscope.cabal
Original file line number Diff line number Diff line change
@@ -1,87 1,64 @@
name: kaleidoscope
version: 0.1.0.0
synopsis: Haskell port of LLVM Kaleidoscope tutorial
description: Port of the Kaleidoscope tutorial for Haskell and LLVM
homepage: https://github.com/sdiehl/kaleidoscope
license: MIT
license-file: LICENSE-MIT
author: Stephen Diehl
maintainer: [email protected]
copyright: 2012-2020 Stephen Diehl
Category: Compilers
build-type: Simple
cabal-version: >=1.10
Bug-Reports: https://github.com/sdiehl/kaleidoscope/issues

Source-Repository head
Type: git
Location: [email protected]:sdiehl/kaleidoscope.git

--library
--default-language: Haskell2010
--build-depends:
--base >= 4.7 && <5
--, haskeline >= 0.7.1.2
--, llvm-hs >= 9.0.0 && <10.0.0
--, llvm-hs-pure >= 9.0.0 && <10.0.0
--, mtl >= 2.1.3
--, transformers >= 0.3.0.0 && < 0.6

--executable preprocessor
-- default-language: Haskell2010
-- main-is: preprocessor.hs
-- hs-source-dirs: tools
-- build-depends:
-- base >= 4.7 && <5,
-- text >= 1.1,
-- mtl >= 2.1,
-- transformers >= 0.3,
-- pandoc >= 2.8 && <3.0,
-- pandoc-types >= 1.20 && <2.0


cabal-version: >=1.10
name: kaleidoscope
version: 0.1.0.0
license: MIT
license-file: LICENSE-MIT
copyright: 2012-2020 Stephen Diehl
maintainer: [email protected]
author: Stephen Diehl
homepage: https://github.com/sdiehl/kaleidoscope
bug-reports: https://github.com/sdiehl/kaleidoscope/issues
synopsis: Haskell port of LLVM Kaleidoscope tutorial
description: Port of the Kaleidoscope tutorial for Haskell and LLVM
category: Compilers
build-type: Simple

source-repository head
type: git
location: [email protected]:sdiehl/kaleidoscope.git

executable chapter2
default-language: Haskell2010
main-is: Main.hs
other-modules:
main-is: Main.hs
hs-source-dirs: src/chapter2
other-modules:
Lexer
Parser
Syntax
Lexer

default-language: Haskell2010
build-depends:
base >= 4.7 && <5
, haskeline >= 0.7.1.2
, llvm-hs >= 9.0.0 && <10.0.0
, llvm-hs-pure >= 9.0.0 && <10.0.0
, parsec >= 3.1
, mtl >= 2.1.3
, transformers >= 0.3.0.0 && < 0.6
hs-source-dirs: src/chapter2
base >=4.7 && <5
, haskeline >=0.7.1.2 && <0.8
, llvm-hs >=9.0.0 && <10.0.0
, llvm-hs-pure >=9.0.0 && <10.0.0
, mtl >=2.1.3 && <2.3
, parsec >=3.1 && <3.2
, transformers >=0.3.0.0 && <0.6

executable chapter3
default-language: Haskell2010
main-is: Main.hs
main-is: Main.hs
hs-source-dirs: src/chapter3
other-modules:
Codegen
Emit
Lexer
Parser
Syntax

default-language: Haskell2010
build-depends:
base >= 4.7 && <5
, haskeline >= 0.7.1.2
, llvm-hs >= 9.0.0 && <10.0.0
, llvm-hs-pure >= 9.0.0 && <10.0.0
, parsec >= 3.1
, mtl >= 2.1.3
, transformers >= 0.3.0.0 && < 0.6
, containers >= 0.4
hs-source-dirs: src/chapter3
base >=4.7 && <5
, containers >=0.4 && <0.7
, haskeline >=0.7.1.2 && <0.8
, llvm-hs >=9.0.0 && <10.0.0
, llvm-hs-pure >=9.0.0 && <10.0.0
, mtl >=2.1.3 && <2.3
, parsec >=3.1 && <3.2
, transformers >=0.3.0.0 && <0.6

executable chapter4
default-language: Haskell2010
main-is: Main.hs
main-is: Main.hs
hs-source-dirs: src/chapter4
other-modules:
Codegen
Emit
Expand All @@ -90,20 67,20 @@ executable chapter4
Parser
Syntax

default-language: Haskell2010
build-depends:
base >= 4.7 && <5
, haskeline >= 0.7.1.2
, llvm-hs >= 9.0.0 && <10.0.0
, llvm-hs-pure >= 9.0.0 && <10.0.0
, parsec >= 3.1
, containers >= 0.4
, mtl >= 2.1.3
, transformers >= 0.3.0.0 && < 0.6
hs-source-dirs: src/chapter4
base >=4.7 && <5
, containers >=0.4 && <0.7
, haskeline >=0.7.1.2 && <0.8
, llvm-hs >=9.0.0 && <10.0.0
, llvm-hs-pure >=9.0.0 && <10.0.0
, mtl >=2.1.3 && <2.3
, parsec >=3.1 && <3.2
, transformers >=0.3.0.0 && <0.6

executable chapter5
default-language: Haskell2010
main-is: Main.hs
main-is: Main.hs
hs-source-dirs: src/chapter5
other-modules:
Codegen
Emit
Expand All @@ -112,46 89,46 @@ executable chapter5
Parser
Syntax

default-language: Haskell2010
build-depends:
base >= 4.7 && <5
, haskeline >= 0.7.1.2
, llvm-hs >= 9.0.0 && <10.0.0
, llvm-hs-pure >= 9.0.0 && <10.0.0
, parsec >= 3.1
, containers >= 0.4
, mtl >= 2.1.3
, transformers >= 0.3.0.0 && < 0.6
hs-source-dirs: src/chapter5
base >=4.7 && <5
, containers >=0.4 && <0.7
, haskeline >=0.7.1.2 && <0.8
, llvm-hs >=9.0.0 && <10.0.0
, llvm-hs-pure >=9.0.0 && <10.0.0
, mtl >=2.1.3 && <2.3
, parsec >=3.1 && <3.2
, transformers >=0.3.0.0 && <0.6

executable chapter6
default-language: Haskell2010
main-is: Main.hs
main-is: Main.hs
hs-source-dirs: src/chapter6
other-modules:
Codegen
JIT
Lexer
Parser
Syntax
Codegen
JIT
Lexer
Parser
Syntax

default-language: Haskell2010
build-depends:
base >= 4.7 && <5
, haskeline >= 0.7.1.2
, llvm-hs >= 9.0.0 && <10.0.0
, llvm-hs-pure >= 9.0.0 && <10.0.0
, llvm-hs-pretty >= 0.9 && <0.10
, parsec >= 3.1
, containers >= 0.4
, mtl >= 2.1.3
, transformers >= 0.3.0.0 && < 0.6
, directory >= 1.3 && <1.4
, bytestring >= 0.10
, text >= 1.2
, pretty-simple -any
hs-source-dirs: src/chapter6
base >=4.7 && <5
, bytestring >=0.10 && <0.11
, containers >=0.4 && <0.7
, directory >=1.3 && <1.4
, haskeline >=0.7.1.2 && <0.8
, llvm-hs >=9.0.0 && <10.0.0
, llvm-hs-pretty >=0.9 && <0.10
, llvm-hs-pure >=9.0.0 && <10.0.0
, mtl >=2.1.3 && <2.3
, parsec >=3.1 && <3.2
, pretty-simple >=3.2.0.0 && <3.3
, text >=1.2 && <1.3
, transformers >=0.3.0.0 && <0.6

executable chapter7
default-language: Haskell2010
main-is: Main.hs
main-is: Main.hs
hs-source-dirs: src/chapter7
other-modules:
Codegen
Emit
Expand All @@ -160,13 137,13 @@ executable chapter7
Parser
Syntax

default-language: Haskell2010
build-depends:
base >= 4.7 && <5
, haskeline >= 0.7.1.2
, llvm-hs >= 9.0.0 && <10.0.0
, llvm-hs-pure >= 9.0.0 && <10.0.0
, parsec >= 3.1
, containers >= 0.4
, mtl >= 2.1.3
, transformers >= 0.3.0.0 && < 0.6
hs-source-dirs: src/chapter7
base >=4.7 && <5
, containers >=0.4 && <0.7
, haskeline >=0.7.1.2 && <0.8
, llvm-hs >=9.0.0 && <10.0.0
, llvm-hs-pure >=9.0.0 && <10.0.0
, mtl >=2.1.3 && <2.3
, parsec >=3.1 && <3.2
, transformers >=0.3.0.0 && <0.6
5 changes: 2 additions & 3 deletions src/chapter6/JIT.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 13,6 @@ import Data.Word
import Foreign.Ptr (FunPtr, castFunPtr)
import qualified LLVM.AST as AST
import LLVM.Analysis
import qualified LLVM.Analysis as L
import LLVM.CodeModel
import LLVM.Context
import qualified LLVM.ExecutionEngine as EE
Expand All @@ -37,7 36,7 @@ jit c = EE.withMCJIT c optlevel model ptrelim fastins

verifyAndRecover :: Mod.Module -> IO String
verifyAndRecover m =
(L.verify m >> return "")
(verify m >> return "")
`catch` (\e -> return ("\nVerification error:\n" show (e :: SomeException) "\n"))

passes :: PassSetSpec
Expand All @@ -51,7 50,7 @@ runJIT mod = do
withPassManager passes $ \pm -> do
-- Optimization Pass
{-runPassManager pm m-}
L.verify m
verify m
verifyErr <- verifyAndRecover m
optmod <- moduleAST m
s <- moduleLLVMAssembly m
Expand Down