Deutsch English Français Italiano |
<vjp28q$13k4m$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Thiago Adams <thiago.adams@gmail.com> Newsgroups: comp.lang.c Subject: Re: transpiling to low level C Date: Mon, 16 Dec 2024 08:17:45 -0300 Organization: A noiseless patient Spider Lines: 64 Message-ID: <vjp28q$13k4m$1@dont-email.me> References: <vjlh19$8j4k$1@dont-email.me> <vjlm2b$dfpo$1@dont-email.me> <vjmbuh$hhg1$1@dont-email.me> <vjnkqh$op3c$2@dont-email.me> <vjnocf$pme5$1@dont-email.me> <vjojaj$11811$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Mon, 16 Dec 2024 12:17:46 +0100 (CET) Injection-Info: dont-email.me; posting-host="9df6c4f7516d4e1a3aa2c9bdac164fe4"; logging-data="1167510"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+RxuJTL3itKldKO5Gh3ERkHZ0CCpx6OHY=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:LRt120zwnixQ/3nFdc0bCJcjHSc= Content-Language: en-US In-Reply-To: <vjojaj$11811$1@dont-email.me> Bytes: 3413 On 16/12/2024 04:02, BGB wrote: > On 12/15/2024 5:22 PM, Thiago Adams wrote: >> Em 12/15/2024 7:22 PM, Lawrence D'Oliveiro escreveu: >>> 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 agree that both LLVM and GCC are too big. > > 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 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. > 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. > > 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%). > Yes, switch is something I can remove. C2Y is adding range in case. (https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3370.htm)