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

Update to llvm-hs(-pure) 5.1 #4

Merged
merged 3 commits into from
Dec 26, 2017
Merged

Conversation

OndrejSlamecka
Copy link
Contributor

@OndrejSlamecka OndrejSlamecka commented Dec 25, 2017

  • 825c8fb prevents llvm-hs from stopping with an error about instructions returning void (e.g., store) having a name,
  • cc60b61 provides a function for easily getting pointers to inside-llvm-functions in the front end.

The following code (to be put in src/Main.hs) is an example where the commits help. If e.g., double was used instead of the function pointer then llvm-hs would stop with an error, see sdiehl/kaleidoscope#45.

logic :: LLVM ()
logic = do
  define double "foo" [(double, "a")] $ do
    ret (local double (AST.mkName "a"))

  fooPtr <- fnPtr (AST.mkName "foo")

  define double "main" [] $ do
    let a = cons $ C.Float (F.Double 10)
    let b = cons $ C.Float (F.Double 20)

    a' <- call (externf fooPtr (AST.mkName "foo")) [a]

    c <- alloca double
    store c b
    c' <- load c
    res <- fadd a' c'

    ret res

The corresponding PR for the tutorial is sdiehl/kaleidoscope#46.

@sdiehl sdiehl merged commit 73876ec into llvm-hs:master Dec 26, 2017
@sdiehl
Copy link
Member

sdiehl commented Dec 26, 2017

Looks great, thanks!

@sdiehl
Copy link
Member

sdiehl commented Dec 26, 2017

I think at some point I'm going to rewrite the tutorial to just the IRBuilder itself, rather than reimplementing it inside the tutorial.

@OndrejSlamecka
Copy link
Contributor Author

OndrejSlamecka commented Dec 26, 2017

Happy I could help. If I understand it correctly, there's not much of a point in porting this to the tutorial at the moment, so I have closed sdiehl/kaleidoscope#46 Maybe, for the time being, we could put a link to this repository to the beginning of the tutorial so that people with LLVM 5 can find a working code easily.

@sdiehl
Copy link
Member

sdiehl commented Dec 26, 2017

Indeed, I'll update the text to link here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants