4
aggelalex
64d

LLVM AND BISON FIX YOUR FUCKING DOCUMENTATIONS
I've been trying the whole quarantine period to make some small Bison and LLVM snippets because I've been planning to make a compiler for my own language. But I haven't been able to make a SINGLE THING WORK because these projects have the WORST DOCUMENTATION I HAVE SEEN IN MY LIFE FOR AN OSS PROJECT. Seriously, no basic references, no tutorials, no nothing. It's as if they are trying to obscure it all! I'm looking for alternatives now.

Comments
  • 3
    We're using LLVM in compilers class and while combing the doxygen is a gigantic pain, there are reasons for it. LLVM moves really fast, it's near impossible to document properly, and besides, most of the userbase is advanced programmers who know the basics and read the code for the rest.

    It's not really a "hey, everyone's welcome here, it's super easy!" type of project. Or rather, LLVM's development resources are spent elsewhere.

    The kaleidoscope tutorial is usually updated, though. What are you having trouble with?
  • 0
  • 0
    @aggelalex what about it?
  • 0
    @RememberMe I'm having trouble with the C++ API. I was looking for some reference, something that would tell me what those functions and classes do, what's wrong with my code, etc.
  • 0
    @aggelalex did you do the Kaleidoscope tutorial? It introduces you to a lot of useful stuff like functions and modules and IRBuilder. It also shows you how to generate code from an AST, which is tbh all you need to make a new compiler frontend.

    https://llvm.org/docs/tutorial/...

    Also the Programmer's Manual

    http://llvm.org/docs/...

    especially the "helpful hints for common operations" bit. Also check out all the passes LLVM has, most of what you want to do will already be done by a pass (eg. your compiler can output loads and stores only for variables and the mem2reg pass will eliminate most of them)

    https://llvm.org/docs/Passes.html

    Looking through their code is very helpful. Also how to write a custom pass

    http://llvm.org/docs/...

    There are also books like the LLVM Cookbook. It's *not* a trivial thing to do use, if it seems difficult and full of weird terminology then well, it is.
  • 0
    @RememberMe Where did you find all that? Of all this all I could find was the programmer's manual...
  • 0
    @aggelalex haha, I've been bashing my head against LLVM since January. It really isn't all that bad, and the code is very clearly written so most of the times I just look up the code for a pass that kind of has something I want and copy that.

    You might also try targeting a specific LLVM version instead of latest.

    This is way nicer than rolling my own library because then I'd have to reimplement dominator trees, alias analysis, pointer analysis, code motion etc. which are just a massive pain to do. So I put up with it. Just keep at it, you'll get there eventually :)
  • 1
    @RememberMe Thanks! I'm grateful for your help.
Add Comment