-
Notifications
You must be signed in to change notification settings - Fork 8
Description
While the input/output operands make it clear what general purpose registers inline asm code is allowed to modify/clobber, it is not clear what other registers are allowed to be modified.
The following examples are x86-specific, but the general principles should apply to all architectures. For the purposes of this discussion, "modified" means that a register is not restored to its original value at the end of the asm.
Case 1: Flags
Is asm code allowed to modify the condition flags? What about other flags in the EFLAGS register? What about floating-point status registers, such as FPCR, FPSR, MXCSR?
Which of these are/aren't covered by preserves_flags
?
Case 2: Segment registers
Is asm code allowed to modify the segment registers? For example, initialization code may need to change the fs
register to point to the thread-local storage area. Does this conflict with the compiler's use of fs
?
Case 3: Future registers
Suppose that some new registers are added in the future, such as xmm[32-63]
. How can current asm code be forward-compatible if they call a function which may clobber these registers?