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

What interest is there in LLVM?

Post by dsjove »

I would love to start an LLVM compiler for the extended firmware. LLVM produces a language agnostic assembler and bytecode. It is a truly modern compiler system that is fast, has great error generation, and built in optimizers. This will enable the use of Ada, Fortran, C, C++, etc without having to write a parser/ optimizer for each one. We wouldn't have the associated runtimes (no new, delete, virtual, throw in C++) but we would get the enormous benefits of the languages, extensibility, and the optimizations provided by the LLVM system.

And it can be integrated with BrickCC, XCode, etc.

I am creating a sourceforge project this week for this effort. Please post a reply if interested, concerned, or even think if I fell of the rocker.

Cheers,
Dave
dsjove
Posts: 56
Joined: 22 Jan 2011, 23:22

Re: What interest is there in LLVM?

Post by dsjove »

I probably should have included the link...
http://llvm.org/
http://llvm.org/demo/
h-g-t
Posts: 552
Joined: 07 Jan 2011, 08:59
Location: Albania

Re: What interest is there in LLVM?

Post by h-g-t »

Sounds good but I can't see how you are going to integrate that to produce NXT-specific code.

Will follow your progress with great interest.

PS Did a quick google after reading this and it may already be possible - http://projects.cs.kent.ac.uk/projects/ ... c?rev=6960
A sophistical rhetorician, inebriated with the exuberance of his own verbosity, and gifted with an egotistical imagination that can at all times command an interminable and inconsistent series of arguments to malign an opponent and to glorify himself.
spillerrec
Posts: 358
Joined: 01 Oct 2010, 06:37
Location: Denmark
Contact:

Re: What interest is there in LLVM?

Post by spillerrec »

Sounds rather interesting. However I don't really know LLVM, is it really that flexible so we can take the whole C (or other) language, yet add limitations or change certain aspects so certain aspects of the firmware can be taken care of.

I was actually about to take a closer look on how classes with simple inheritance could work in NBC code the next few days. I have an idea, so I want to try it out. Is it something you are interested in hearing more about?
My blog: http://spillerrec.dk/category/lego/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
aswin0
Posts: 201
Joined: 29 Sep 2010, 06:58

Re: What interest is there in LLVM?

Post by aswin0 »

Hi,

This is a brave initiative. But what would be the benefit of this, what is the unique selling point of this that can't be found in the alternatives that are available already? You mentioned optimized code and the debugger. Are there others?

Aswin
My blog: nxttime.wordpress.com
dsjove
Posts: 56
Joined: 22 Jan 2011, 23:22

Re: What interest is there in LLVM?

Post by dsjove »

Very good questions and points! This makes me have to really think about what I proposing. :mrgreen:

@spillerrec
I big yes. LLVM has been designed ground up to be a modular system. It is what Apple is using to provide the flexibility for their large array of platforms, including JIT compilation for graphics hardware support.

It is a language agnostic bytecode. It currently has explicit support for C, C++, Obj-C, and Fortran. They all create the same bytecode.

Of course I would be interested. My initial thoughts for Clang (the C++ front-end) is to remove the virtual keyword and simply depend on compile-time polymorphism.

@h-g-t
I googled LLVM LEGO numerous times! Now I see I should have googled LLVM Nxt :roll: From the Wiki it appears to be another brick OS that uses LLVM for its compiler. I am not interested in a third party OS.

@aswin0
I am going to bullet the benefits I perceive.
- Use of John's extended LEGO endorsed firmware
- Leveraging some of the work of NXC
- Easily integrated with XCode
- Full C++ front-end is complete and actively updated by companies like Apple
--- I really like NXC but it is still missing some basic C constructs.
--- C++ is an extremely powerful language, and getting better.
--- We can concentrate on platform, not language parsing
- LLVM performs optimizations tin the various stages of compilation and link time that is beyond most of our pay-scales!
- Multi-language support
- LLVM's error repotting is better than any other C/C++ compiler I have seen.

@John
My gut tells me hat creating a back-end that translates bytecodes and modifying an already robust and modular C++ front-end is going to be simpler and have more payout than maintaining and independent C/C++ front-end.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: What interest is there in LLVM?

Post by HaWe »

a different firmware could be a big advantage for your LLVM/C/C++ project because both the Lego and the Enhanced firmware are currently too much limited:
no stack, no heap, no pointers, no recursion, no dynamic memory allocation, no re-entrant functions, no double, no full stdio.h implementation - and a quite slow runtime performance (slower than the Lejos and/or RobotC fw).

Using different C compilers on the same limited fw base would end up (CMIIW) in having just another NXC dialect implementation with exactly the same limitations like NXC already has.

On the other hand - just having NXC on a different stack/heap designed fw would be already a "big leap for (NeXT)mankind".
spillerrec
Posts: 358
Joined: 01 Oct 2010, 06:37
Location: Denmark
Contact:

Re: What interest is there in LLVM?

Post by spillerrec »

dsjove wrote:Of course I would be interested. My initial thoughts for Clang (the C++ front-end) is to remove the virtual keyword and simply depend on compile-time polymorphism.
I finished my first draft on an implementation, however testing it in full-scale required a lot of macro-functions and I ran out of patience so it isn't properly tested... Anyway, take a look: http://spillerrec.wordpress.com/2011/02 ... -firmware/
doc-helmut wrote:Using different C compilers on the same limited fw base would end up (CMIIW) in having just another NXC dialect implementation with exactly the same limitations like NXC already has.
Yeah, it will. However I would be grateful for a compiler that could actually compile well... And if it could optimize, I would be jumping in joy.
My blog: http://spillerrec.dk/category/lego/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: What interest is there in LLVM?

Post by HaWe »

so if your LLVM / C will be the same as EFW/NXC :
what would be the advantage of your project opposite to NXC?
spillerrec
Posts: 358
Joined: 01 Oct 2010, 06:37
Location: Denmark
Contact:

Re: What interest is there in LLVM?

Post by spillerrec »

If done properly, we would get faster programs (I would guess about 10% on average, but I have experienced over 30%) and smaller programs while using fewer RAM resources.
Using a proven parser will also be a big advantage as many of the issues we experience every now and then because incomplete or buggy support of C in NXC would be unlikely. (Two of my old NXC programs stopped working because the newer compiler parsed differently.)
Having proper error messages would be nice too, since some of them are rather cryptic. Warnings would also be a nice addition.
It would be much easier for others to implement another language for the standard firmware as they could simply take this project and add a new parser on top of it. What other text-based languages are there to program you NXT running standard firmware?

But even with something like LLVM, it will probably require a lot of work to get something like this done properly. Dave, how long are you intending to go with such a project? And are you still intending to try to do it?
My blog: http://spillerrec.dk/category/lego/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
Post Reply

Who is online

Users browsing this forum: No registered users and 29 guests