Liste des Groupes | Revenir à cl c |
On 2024-03-22, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:I have no answer here either.bart <bc@freeuk.com> writes:On 22/03/2024 17:14, James Kuyper wrote:[...]>If you want to tell a system not only what a program must do, but>
also how it must do it, you need to use a lower-level language than
C.
Which one?
Good question.
One of the stated motivations for creating C was to save people from writing code in assembly!>I don't think anyone seriously wants to switch to assembly for the
sort of tasks they want to use C for.
I think lack of demand combines with it actually being an extremely difficult task.>
Agreed. What some people seem to be looking for is a language that's
about as portable as C, but where every language construct is required
to result in generated code that performs the specified operation.
There's a lot of handwaving in that description. "C without
optimization", maybe?
>
I'm not aware that any such language exists, at least in the mainstream
(and I've looked at a *lot* of programming languages). I conclude that
there just isn't enough demand for that kind of thing.
I think you can more or less get something like that with the followingYou might like to try to formalise this. You won't be the first to attempt it. But you might be the first to succeed, because no one (AFAIK) has managed it so far.
strategy:
- all memory accesses through pointers are performed as written.
- local variables are aggressively optimized into registers.
- basic optimizations:
- constant folding, dead code elimination.
- basic control flow ones: jump threading and the like.
- basic data flow optimizations.
- peephole, good instruction selection.
In that environment, the way the programmer writes the code is the rest
of the optimization. Want loop unrolling? Write it yourself.
Les messages affichés proviennent d'usenet.