[LLVMdev] Couple newbie questions :|

Eli Friedman eli.friedman at gmail.com
Sun Aug 2 00:25:10 PDT 2009


On Sat, Aug 1, 2009 at 11:43 PM, Tres Walsh<tres.walsh at gmail.com> wrote:
> Hello there!
> I'm an absolute newb at LLVM,and I was hoping someone could answer a few of
> my questions.
> I'm currently working on a game engine. As part of it's design, I need a
> virtual machine for scripts. Is LLVM suited for this at all? Such as
> registering external functions that can be called from the scripts?

Possibly... but you're sort of making the decision at the wrong level;
LLVM is really a low-level solution intended for implementing a
language.  If you need scripts, you probably want a scripting language
of some sort, and if you're working on a game engine, you probably
don't want to write your own scripting language, since it's a lot of
work with no obvious benefit.  There are numerous existing open-source
solutions for this; I think Python and Lua are popular choices for
that sort of thing.

> And if
> this did work, it wouldn't really matter what language the original scripts
> were written in, since they all get compiled down to the LLVM bytecode
> correct?

You can't really just compile a scripting language down to LLVM
bitcode and expect good performance; you really need some glue code to
mix interpretation, compilation, and possibly recompilation at runtime
to get good performance.  And if the scripts in question aren't
performance-sensitive, there's not really much point to using LLVM.
It strongly depends on what you're doing.

> As of now what platforms does LLVM not compile on? Is it good for embedded
> work?

In terms of platforms, it'll probably work for everything you might
care about; see http://llvm.org/docs/ReleaseNotes-2.6.html#portability
(although note that only some of those platforms have working JIT
support).  As for embedded work, it depends on what you mean by
embedded; if 10MB code footprint sounds way too large, LLVM is
probably not the way to go.

You might want to take a look at http://llvm.org/docs/tutorial/ to get
a better idea of what LLVM can do.

-Eli



More information about the llvm-dev mailing list