I'm an undergraduate student, and I'd like to implement a compiler as a
project for my university. The compiler would compile an experimental
language I made that attempts to make all operations memory-safe with
minimal runtime overhead (no GC)... All operations except those in some
critical sections where unsafe code is allowed (typically, standard
collection and algorithm classes).
You can find a presentation here: http://bit.ly/UiVF8z (by the way, I would
appreciate if some of you could tell me what you think of it and if I am
fundamentally wrong somewhere)
First I though of using LLVM, and make my compiler directly generate LLVM
But I have the feeling that this would mean redoing a lot of things that
have already been done (and probably much better than I could ever do).
These things include:
- High level exceptions handling with RAII (freeing resources transparently
when exceptions are thrown)
- Inheritance and multiple inheritance
- Virtual methods
- High-level optimizations (out of the grasp of LLVM)
- Concurrency (thread-local storage, etc.)
- Enhanced compatibility with C/C++
- ... ?
So I thought that it would probably be better to generate an AST that Clang
can understand, and let Clang compile it into LLVM IR. Indeed, under the
thin layer of abstraction, my language's structure is very similar to C++.
I know that Clang allows people to reuse its C/C++-parsing capabilities for
various needs, but what I'm looking for is precisely not this part of Clang,
but the other one: translating the AST into LLVM IR...
However, I'm wondering if the Clang API I'm looking for is stable enough, or
if it may change too quickly or too radically...
So my question is: Would it be worth the trouble to learn and use the Clang
AST library so that my font-end can use it, and would it be a good option
for the future?
Or (this is ugly), should I rather generate plain C++ code and compile it
with any C++ compiler (at least until I find something better to do)?
Thank you for your interest,