Liste des Groupes | Revenir à cl c |
On 12/15/2024 5:22 PM, Thiago Adams wrote:I've just been working on a new backend which can be shared between different projects. It can be built into a standalone library, which has a size from 70KB to 180KB (x64 target), depending on output options. (30K of that is my language's std library.)Em 12/15/2024 7:22 PM, Lawrence D'Oliveiro escreveu:I agree that both LLVM and GCC are too big.On Sun, 15 Dec 2024 07:44:34 -0300, Thiago Adams wrote:>
>I also think LLVM is too big.>
How about QBE, then <https://c9x.me/compile/>.
QBE is just for linux and it does not generate code directly. C is everywhere.
But I am reading QBE docs to see what is necessary in a IL.
>
I am not sure the minimum size of a usable C compiler, my current estimate is probably somewhere in the area of 50-100 kLOC.Mine, for quite a large subset (that can compile Lua and sqlite3 for example), is between 180KB and 290KB. That's roughly 20 to 30Kloc, assuming that one line of code maps to approx 10 bytes of x64 code.
My current compiler is a bit bigger than this, and my own past attempt to implement a C compiler in under 30k lines had failed.
If I were to estimate a feature set for a 3AC IL:The IL I mentioned above isn't that small. There are about 150 instructions. Probably half could be dispensed with (eg. 'MIN/MAX' ops, or in-place MUL), but then the functionality needs to be provided by other means. And as I showed, the resulting backend isn't that huge.
Basic UNARY and BINARY operators;
Also COMPARE and similar;
Load and Store Index operators;
With support for an immediate index;
GOTO
IF-GOTO
CALL (with a list of argument variables and a target variable).
Les messages affichés proviennent d'usenet.