From 4b6c0e31385f5f27a151088c0a2b614495c4e589 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Thu, 14 Oct 2021 12:47:50 -0400 Subject: initial commit, including theme --- .../posts/2007-10-15-llvm-is-a-baby-killer.html | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 content/posts/2007-10-15-llvm-is-a-baby-killer.html (limited to 'content/posts/2007-10-15-llvm-is-a-baby-killer.html') diff --git a/content/posts/2007-10-15-llvm-is-a-baby-killer.html b/content/posts/2007-10-15-llvm-is-a-baby-killer.html new file mode 100644 index 0000000..0bd1623 --- /dev/null +++ b/content/posts/2007-10-15-llvm-is-a-baby-killer.html @@ -0,0 +1,57 @@ +--- +date: "2007-10-15T05:38:29Z" +title: LLVM is a Baby Killer +--- + + +

+I've spent some time sifting through the documentation for LLVM, and +I'm both impressed and horrified. I'm not sure I've ever seen so much +documentation about something that looks really cool that I'm not +interested in. I've been reading the dragon book and Advanced Compiler Design and Implementation, and I wanted to use LLVM to generate a simple +runtime JIT compiler, but I can't seem to find the necessary +documentation.

+ +

I see plenty of documentation on the IR, the various command-line tools, +and just about everything else LLVM-related except for a straightforward +tutorial that explains how to

+ +
    +
  1. blast either opcodes or IR at the LLVM API, and
  2. +
  3. have LLVM either emit an ELF/blob/whatever or execute the result.
  4. +
+ +

I did manage to find a couple of examples that give me half of what I +want. The source code ships with a sample Brainfuck compiler which +reads an input bf file and emits LLVM IR. There are a couple more +examples that show how to construct a basic JIT, then create some +functions that do frustratingly simple things like calculate Fibonacci +numbers or add two integers together, but nothing that's too much more +detailed than that.

+ +

Oh, did I mention that the online API documentation is broken?

+ +

A bit of googling turned up libjit, which is almost exactly what I want. +It's got a simple C API (instead of the nightmarishly bloated C++ +monstrosity that is the LLVM API), a simple build and link system, and +simple, straightforward and complete documentation. In +short, it's everything that I want.

+ +

It's also GPL-licensed, which makes it almost completely unusable. I +found this 2006 email exchange comparing libgit and LLVM. The +author, who apparently works on libgcj, mentions all of my problems with +LLVM (sans the anti-C++ bias).

+ +

My other crazy idea was to generate C as an IR and blast it at +libtcc, but with my limited fiddling I couldn't get to do anything +other than segfault on me. Incidentally, the documentation for libtcc +is a single file and it's still better than what's available for LLVM.

+ +

So here's my question: Is there a decent book or tutorial that walks +through the LLVM API? I've Googled to the end of the earth and back, +I've seen the Stacker documentation, and I've read through +everything in the LLVM documentation section, and none of it was +what I'm looking for. I'm open to suggestions...

+ + -- cgit v1.2.3