3 ms·
C programmers say things like "C is close to the machine"(+) and then have to write a huge elaborate macro in order to fool the compiler into generating a singl
by pjc50 2y ago
C programmers say things like "C is close to the machine"(+) and then have to write a huge elaborate macro in order to fool the compiler into generating a single machine instruction which is the one they actually want.
One of these days I'll write my "actually typesafe portable macro assembler" project. It will be .. opinionated.
(+) which machine, though
- Akronymus 2y ago> (+) which machine, though A PDP11. Tbf, for most lower level languages it's fairly close to a pdp 11.
- JackSlateur 2y agoCannot you just __asm__() things ?
- pjc50 2y agoNot portably! People want to have their cake (not having to think about instruction names, code generation for arithmetic expressions, or register allocation, because those differ per platform) and eat it (generate reasonably predictable machine code for multiple different platforms). Things like LLVM IR are pretty close, but understandably nobody wants to write IR by hand.
- o11c 2y agoAs I mentioned, asm is often a pessimization. GCC has a lot of useful builtins though.
- CyberDildonics 2y agoYou should give an example of that here: godbolt.org I have never had to do what you're talking about.