Liste des Groupes | Revenir à cl c |
On 27/11/2024 12:32, Thiago Adams wrote:Exactly.On 27/11/2024 08:57, Bart wrote:OK! Finally that is cleared up.On 27/11/2024 01:52, Thiago Adams wrote:>Em 11/26/2024 9:59 PM, Bart escreveu:>>Hard C Features
>
...
>I think K&R C is simpler than C89 that is simpler than C99 etc...>
>
My objective if to find the minimum code generator (backend) in C and leave the other complexities (like warnings, static analysis, constexpr, preprocessor) to the frond end.
>
This also facilitates to have more than on backend sharing the job done by the front end.
>
For instance, I may move all constant expressions from the generated code. So the backend does not have to compute constant expressions any more and it still C89 compatible. I removed enuns for instance.
>
So my question is not about how to create a simple C compiler but how to separate and move most of the job to the front end creating a very simple backend (code generator) which the input is code C89 compatible.>>
>
I believe that K&R C is simpler than C89, which in turn is simpler than C99, and so on.
>
My goal is to design a minimal code generator (backend) in C reading C89, while delegating other complexities—such as warnings, static analysis, constexpr, and preprocessing—to the front end.
>
This approach also facilitates using multiple backends that share the work handled by the front end.
>
For example, I might remove all constant expressions from the generated code, so the backend no longer needs to compute them and remains C89-compatible. I've already removed features like enums, typedefs for instance.
>
Therefore, my question isn't about how to create a simple C compiler.
>
Instead, it's about how to shift most of the workload to the front end, resulting in a very simple backend (code generator) that processes C89-compatible code as input.
>
Does it makes sense?
Not really. You're basically talking about using an IR or IL, which most compilers already do, including mine now. Clang for example uses LLVM IR.
>
I am talking about using a subset of C89 as IL.
>
>Some languages use C as intermediate language.C89 compilers that can deal with function
>
But you seem to be getting C, and lower level ILs, mixed up.
>
If you are transpiling to C, then just generate C code, C89 if you like. In that case you don't need to discard 90% of the language to make it simpler! Simpler for whom?prototypes etc already exist; you said you are not writing your own compiler.>
>
This shows your confusion:
>
> I was wondering if splitting expressions would make the backend simpler
>
> for instance
>
> int r = a + b * c;
>
> converted to
>
> int r1 = b * c;
> int r2 = a + r1;
> int r = r2;
>
You are still talking as though YOU are writing the backend! You will either use an existing C compiler or an existing IL backend, but there aren't that many of the latter.
>
But I want to write the backend!
I want to have a simple backend (C compiler that compiles a subset of C89) and complex front end (C99 C11 C23 ..C26)So the requirements now are different. You want to use the simplest possible subset of C, that is still valid C and can be processed and optimised etc by any compiler. But which at a later point you will try to implement it yourself.
At same time I can use existing C compilers.
Les messages affichés proviennent d'usenet.