[LLVMdev] seeking advice
Renato Golin
renato.golin at linaro.org
Mon Aug 3 10:07:21 PDT 2015
On 3 August 2015 at 16:29, Arno Bastenhof <arnobastenhof at gmail.com> wrote:
> Based on these
> readings, as a matter of exercise I can take what I learnt from LCC to write
> a small compiler in C targeting the LLVM IR for, say, a subset of Prolog.
Hi Arno,
This is not a monumental task. There are many tutorials in the LLVM
tree, and producing IR from a simple AST is actually simple and
straight-forward.
So many languages can target LLVM IR, that it's very hard that you'll
find something that cannot be represented in IR. At least something
that other implementations haven't found already, and worked around.
With your broad knowledge in CS, I wouldn't expect you to take more
than a month or two to get a front-end working with the JIT compiler
on a reasonable subset of Prolog. Of course, the deeper you go, the
more time it takes to progress the same 1%, but you can always stop
when productivity drops as fast as enjoyment. :)
But you won't need to understand the back-end at all, modulo some
quirks on your platform of choice. The hint is to write the same logic
in Prolog and C, compile the C with Clang and see what they do. If you
spot hackery, the least resistance path is to replicate the hackery.
Asking on the list is also a good way to understand why the hackery,
and maybe even give you an entry point into changing the middle/back
end to support a proper construct in IR for better codegen.
>From there, I'd recommend you to try different targets. Get some
board, device, phone you have at your disposal (RaspberryPi2 is a
great inexpensive kit), and make it work. You'll take a lot less
effort than you're imagining...
cheers,
--renato
More information about the llvm-dev
mailing list