4 ms·
It's certainly possible to do a lot better than GCC's inline assembly setup, which has proven time and again to be a usability disaster that positively encourag
by msbarnett 11y ago
It's certainly possible to do a lot better than GCC's inline assembly setup, which has proven time and again to be a usability disaster that positively encourages writing subtly buggy code.
Microsoft's C compilers do a much better job with inline asm by being more conservative in how they allocate registers around the asm (https://msdn.microsoft.com/en-us/library/k1a8ss06.aspx https://msdn.microsoft.com/en-us/library/k1a8ss06.aspx).
CodeWarrior's PPC compilers remain the ne plus ultra of inline assembly ergonomics, and it's a goddamn shame that LLVM has chosen (for pragmatic reasons) to follow GCC's mediocre lead rather than pursue something akin to it.
- userbinator 11y agoI think this stems from the same "lazy design" that made (G)AS' x86 syntax so very unpleasant to work with --- they just decided to make inline Asm literally dump strings out into the compiler's own Asm output, with some printf-like placeholders to be replaced with variable names/register assignments. There's a belief of "strict modularity" (i.e. compiler doesn't know at all about the inline Asm other than what the programmer tells it explicitly) which probably had some influences too, whereas MSVC et.al decided to spend a bit more effort on making things work in a more integrated fashion.
- cokernel_hacker 11y agoClang provides both GCC and MSVC style inline assembly.
- msbarnett 11y agoHoly crap, I was not aware of that. edit: this doesn't seem well-documented, if true. The Clang site mostly just talks about GCC compatibility, eg) http://clang.llvm.org/compatibility.html#inline-asm http://clang.llvm.org/compatibility.html#inline-asm