On Sat, Sep 22, 2012 at 12:36:07AM +0100, Martin Bazley wrote:
> (It does remind me of an idea I've been playing with for a while, some
> form of automated translation of C library headers into RISC OS modules
> so they could both be used from other languages and shared between C
> programs without the need to faff about with !SOManager. I'm convinced
> it should be theoretically possible, given a set of fixed, sensible
> calling standards and nailing down the format of C's data types,
> particularly structs, but it's not happening any time soon. But hey, I
> see one of my modules for this year is entitled "Compilers", so you
> never know...)
Today I went to a workshop on LLVM, which looks very useful. LLVM is a
toolkit for writing compilers, which makes it easy to build a compiler by
assembling all the bits you want from the toolkit. You plugin in a parser
to convert a textual program into an abstract syntax tree (ie representation
of the program as a data structure not a textfile). Then you write the
language implementation using the parts of the LLVM toolkit. That makes an
intermediate representation - code for a machine with infinite registers
which can each only be written once. Then it can work on optimising that
representation, and finally it's converted to assembler. At each stage you
can mix and match the parts of the toolkit appropriate for your application.
In your specific case, clang is the C/C++ fronted to LLVM and libclang is a
library for manipulating C programs (for example, extracting all the
function definitions and their types). So should be very handy for your
idea. In that case you probably don't need LLVM to output code as such,
just the analysis parts.
I notice John did some work on LLVM two years ago:
http://www.riscos.info/websvn/listing.php?repname=gccsdk&path=%2Fbranches%2Fdevelopers%2Fjoty%2Fllvm
It's still quite a fast-moving target. The ARM support is there but it
keeps breaking due to changes in the core, and ARM are working on the
testsuites to pick this up when it happens. As they have customers
interested in all three, ARM plan to support the three available toolchains
(GCC, LLVM, their own compiler) as much as they have sufficient manpower to
do so. LLVM looks considerably easier to work with than GCC, and not
subject to the GPL conditions (awkward for some ARM customers).
As for the implications for RISC OS generally... I don't know how much
specifics we'd need for RISC OS, but I suspect it would be a lot easier than
the previous work on GCC. So if someone feels like having a go...
John, do you want to say how far you got with LLVM?
Theo
_______________________________________________
GCCSDK mailing list gcc@gccsdk.riscos.info
Bugzilla: http://www.riscos.info/bugzilla/index.cgi
List Info: http://www.riscos.info/mailman/listinfo/gcc
Main Page: http://www.riscos.info/index.php/GCCSDK
No comments:
Post a Comment