Liste des Groupes | Revenir à cl c |
On 12/15/2024 5:22 PM, Thiago Adams wrote:My hope is 10-30K lines. But remember this is a simpler version of C. This is the objective. It also may work in one pass, without building a lot of data structures for the AST.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.
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.Yes, switch is something I can remove.
My current compiler use to be smaller, but multiple backends and similar did make it bigger:
SH-2, SH-4, BJX1 (older)
BJX2, RISC-V (current)
If I were to estimate a feature set for a 3AC IL:
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).
One doesn't need any higher-level control flow constructs.
Any built-in support for "switch()" can be optional (the main reason to have so is that it can make switch a little faster, but isn't required).
Earlier on, my compiler didn't have any backend support for this, and would instead decompose the switch into "if/else/goto" logic. You can then use recursive binary subdivision to implement the list of case labels (or linear probes if N is small).
BGBCC still uses binary subdivide if the case-labels don't satisfy the constraints for a branch-table (Say, needs to be 16..256 case labels with a density over 75%).
Les messages affichés proviennent d'usenet.