What interest is there in LLVM?

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
dsjove
Posts: 56
Joined: 22 Jan 2011, 23:22

Re: What interest is there in LLVM?

Post by dsjove »

The model...

Subset of C/C++...
This gives us all the C/C++ parsing for free - templates, struct/array initializers, full type system, etc. NXC struggles with even basic C constructs. It is fast, very fast.

Compiled down to LLVM bytecode...
This includes some of the most advanced optimizers and static analyzers available - far beyond what NBC/NXC can do. The LLVM byte code is language and platform agnostic. You can train the LLVM system to meet your hardware requirements.

LLVM to NBC or RXE
NBC compiler knows how to create RXEs and handle external resources. I'd just assume leverage that and convert one assembler to another.

If you see the above as useless, OK.
nxt-ai
Posts: 36
Joined: 10 Jan 2011, 05:02

Re: What interest is there in LLVM?

Post by nxt-ai »

Wouldn't optimizing the final code be even better though? Converting to a different language just to optimize sounds kind of backwards. Wouldn't you also want to then optimize the code generated by the LLVM language?
Why not optimize the end resulting code?
spillerrec
Posts: 358
Joined: 01 Oct 2010, 06:37
Location: Denmark
Contact:

Re: What interest is there in LLVM?

Post by spillerrec »

The idea with a middle step is apparent if you have multiple languages. Lets say you have the following languages you want to use with the NXT: C++, pascal, python and basic. You write a C++ parser, you optimize it and convert it into NXT bytecode. You write a Pascal parser, you optimize it and convert it into NXT bytecode. And the same with the other languages.
But if we had a middle step like LLWM:
You write a C++ parser and convert it into intermediate code. You write a Pascal parser and convert it into intermediate code. And so on.
With the intermediate code, you optimize it here (and here only) and convert it into NXT bytecode. In other words, all optimization is done on the intermediate code and you therefore only have to write it once for one type of code. Similarly you only have to worry about converting into NXT bytecode in one place and from one language.

The model might seem a bit weird, but it is widely used because it improves code reuse greatly and therefore lowers development costs.
My blog: http://spillerrec.dk/category/lego/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
tcwan
Posts: 186
Joined: 30 Sep 2010, 07:39

Re: What interest is there in LLVM?

Post by tcwan »

dsjove wrote:
Compiled down to LLVM bytecode...
This includes some of the most advanced optimizers and static analyzers available - far beyond what NBC/NXC can do. The LLVM byte code is language and platform agnostic. You can train the LLVM system to meet your hardware requirements.
Would LLVM be able to target bare-metal ARM as well? What about ARM Assembly? I haven't looked into the LLVM toolchain, since almost all the toolchains are still based on gcc. I know that Apple has LLVM to ARM target for iOS, but I'm not familiar with the details. (My main platform is Mac OSX).

Incidentally, I sent a Private Message to you but not sure if you've received it (the message board UI is not very intuitive).
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 3 guests