-
Notifications
You must be signed in to change notification settings - Fork 84
Compiler for Carp #12
Comments
Hi firebolt55439, Excellent, though I would prefer C to C++. Is there not an API for C? Your note makes sense. tekknolagi On Mon, Aug 4, 2014 at 8:44 PM, firebolt55439 [email protected]
|
Hi tekknolagi, There is indeed an API for C, but there are drawbacks to using it - its intended purpose was to expose the API to other programming languages which have a hard time inter-oping with C++ (name mangling, namespace relocation, etc.), and find it easier to call C functions. Basically, it takes all of the C++ classes provided, and exposes to C a "reference" to them, or rather a data structure that is almost a serialization of the class, and can be converted to and from a C++ class (see below). It provides C++ functions called 'wrap' and 'unwrap' which take a C-compatible reference and return a class, and vica versa. For a compiler for CARP, my recommendation would be to write a wrapper in C++ and write the rest in C. The wrapper should "abstract away" some certain details (e.g. llvm::BasicBlock*'s for labels, "stack-based" evaluation, etc.). Another thing (or two): P.S. So the compilation process would look something like this (in pseudo-code): Input: Compiler: Output: |
Perhaps, then, LLVM is not the project for this. On Tue, Aug 5, 2014 at 11:27 AM, firebolt55439 [email protected]
|
I have taken a look at the CARP instruction set and the basic implementation.
I consider myself to be proficient in C and C++, and am volunteering to create a compiler fork/branch.
Suggestions:
A note:
When compiling to another language, for example LLVM IR or C, due to the inherent nature of a stack VM, constant folding is trivial. At compile-time. The compiler will have to make tradeoffs between how many operations (e.g. addition, bitwise, etc.) it will do at compile time or how many it will relegate to the backend for code generation.
The text was updated successfully, but these errors were encountered: