So I think there is a basic decision to be made here. We can choose between:
- Try to do something nice, like D did.
- Try to do something compatible, basically copying what clang and gcc do (which I understand is roughly the same? feel free to correct me.)
- Try to do our own thing.
IIRC, D lets you basically just write x86 assembly inline, referencing variables and so forth, and everything Just Works. It’s pretty sweet. But it’s a lot of work, and it’s not portable across architectures.
OTOH, gcc/clang offer these bizarre templates that are basically cut-and-paste assembly into the output and they use a cryptic notation for communicating with the register allocator which essentially nobody understands (hyperbole, but not by much). However, it’s portable, and if we hew closely to what they’ve done, it’s plausible you can mostly copy-and-paste an existing solution from stackoverflow and get on with your life much of the time.
There is probably some middle ground, where we do something like gcc but try to improve on the opaque notation, making it easier to use, or making common cases more intuitive.
I think what I favor is adopting the gcc notation as closely as we can (which I think is what we’ve done…?) to start, and then considering unstable extensions that are essentially front-ends for this more cryptic variety. I feel like if we have the gcc stuff, people can write syntax extensions in cargo that translate to it from some more natural notation fairly easily and so forth, so this may never have to be part of the Rust compiler proper (that’d be ideal).