It would be useful to interface C functions with code written in raw assembly to have a function attribute to make a function save and restore every used registers, even flags register if possible.
This should not cause big problems because such special functions will still _respect_ the ABI, but would not _expect_ the code around to be so fair.
Why not just use -fcall-saved-reg for the relevant registers?
Using -fcall-saved-reg for every reg is a very heavy syntax, and would not work on flags register. I think that a per function attribute would be better. It seems that this feature is actually supported for a couple of architectures (for example blackfin) with the attribute 'saveall'
First the target needs support for saving those registers. Does it make sense to mark the TOC register as being saved? How about the thread local storage register being saved?
Why not used use ABI correctly? Because the raw assembly is just violating the ABI. There is a reason why ABIs exist in the first place :).
i'm afraid i'm only experienced with x86/x86_64 and, to a lesser extent, MIPS. so i'm marking this request as x86 specific.
For my purpose it would be enough to save all gp registers, excluding those that has a special meaning, for example the stack pointer. (%r[a-d]x, %r[ds]i, %r[9-15])