Sujet : Re: question about linker
De : thiago.adams (at) *nospam* gmail.com (Thiago Adams)
Groupes : comp.lang.cDate : 27. Nov 2024, 10:37:52
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vi6p9h$3un4t$1@dont-email.me>
References : 1 2 3 4 5 6
User-Agent : Mozilla Thunderbird
Em 11/26/2024 10:52 PM, Thiago Adams escreveu:
Em 11/26/2024 9:59 PM, Bart escreveu:
On 26/11/2024 20:00, Bart wrote:
On 26/11/2024 19:38, Thiago Adams wrote:
>
Do you have any idea what else can be simplified when creating a C compiler?
...
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.
...
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;
also one options is to extend the generated language with some macros. (the generated code still works in C compiler)
for instance macros to include the integer promotion that are ignored in real c compiler but used in this simple c compiler backend.
#define CHAR_TO_INT(X)
int r1 = b * CHAR_TO_INT(c);
then the backend also does not worry with this and just follows intructions.