Liste des Groupes | Revenir à cl c |
On 15/12/2024 03:05, Thiago Adams wrote:It will have to be configured to x86 or x64. It has to match the target/platform compiler settings. The online versions is emulating something. I think x86 gcc on linux.>If I try:
I am working on a C backend that generates simple C code.
>
You can test it here:
http://thradams.com/cake/playground.html
>
Objective
- Shift all the complexity of the C compiler to the frontend.
Why? This approach simplifies having one frontend and multiple backends.
- Use C as an intermediate language to feed a backend (any C compiler can act as the backend).
The backend can then focus solely on code generation.
- Code is not portable
>
Removed C89 Features
- Preprocessor
- sizeof
printf("%zu\n", sizeof(void*));
it turns into:
printf("%zu\n", 4U);
Presumably this translator will only target 32-bit systems even if run on a 64-bit one?
(My own C transpiler goes the other way and generates 'C64', requiring a 64-bit compiler. Earlier versions made it optional, but the output was then either C32 or C64; if someone else compiled it, they'd have to choose the right compiler option.)It has to generate code as the target compiler wants to see. I am removing sizeof for instance, then sizeof computed must match the target compiler.
I don't know if that "%zu" format will be an issue.
I want to move this to the front end.- typedefYou can do that. But it can also slow down certain programs. (TCC 0.9.26 generated seqential tests for switch, but on one benchmark that relied on it heavily, its code was slower than my dynamic interpreter.)
- enum
- Constant expressions (the final result is precomputed during earlier stages)
- const
- I may also remove switch.
If you think this might be too hard to compile later, you can choose to do the same. (As for parsing switch, you'd need to do that anyway, either in the transpiler, or the backend compiler.)Initialization also needs a strategy. I want to move these to front end.
>
>
Les messages affichés proviennent d'usenet.