[Bug target/81709] __attribute__((interrupt)) should handle SSE registers
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81709 --- Comment #7 from H.J. Lu --- (In reply to Anatol from comment #6) > > I don't believe compiler needs to do all that. > > I might miss something, could you please share why? > > The check for FXSAVE can be a compile time: if compiled for Pentium II tune > or later then use FXSAVE otherwise use FSAVE. > > if (tune >= 'pentium II') It should check ISA for SSE, AVX, AVX512, MPX, ... > FXSAVE > else > FSAVE > ... save whatever FSAVE did not save ... > end On newer processors, XSAVE is needed which uses EAX/EDX.
[Bug target/81709] __attribute__((interrupt)) should handle SSE registers
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81709 --- Comment #6 from Anatol --- > I don't believe compiler needs to do all that. I might miss something, could you please share why? The check for FXSAVE can be a compile time: if compiled for Pentium II tune or later then use FXSAVE otherwise use FSAVE. if (tune >= 'pentium II') FXSAVE else FSAVE ... save whatever FSAVE did not save ... end
[Bug target/81709] __attribute__((interrupt)) should handle SSE registers
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81709 --- Comment #5 from H.J. Lu --- (In reply to Anatol from comment #4) > > you need to save the complete vector state > > It is a good point. Would it make sense for compiler to do it? Instead of > forcing users to track if SSE registers are used and doing xsave/xrstor > manually? To save and restore the complete vector state, you need to do Check if CPU supports xsave/restore if yes Query CPU for the complete vector state size Allocate space on stack for the complete vector state xsave else Allocate space on stack for the fxsave area. fxsave endif ... if CPU supports xsave/restore xrstor else fxrstor endif I don't believe compiler needs to do all that.
[Bug target/81709] __attribute__((interrupt)) should handle SSE registers
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81709 --- Comment #4 from Anatol --- > you need to save the complete vector state It is a good point. Would it make sense for compiler to do it? Instead of forcing users to track if SSE registers are used and doing xsave/xrstor manually?
[Bug target/81709] __attribute__((interrupt)) should handle SSE registers
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81709 --- Comment #3 from H.J. Lu --- (In reply to Anatol from comment #2) > Theoretically it is possible to do things like this manually. Track > functions x86 extensions usage and save registers accordingly. But I would > love to see a more automated and less error-prone way to do it. Similar to > what CLANG compiler already does. CLANG tracks registers use and reduces a > lot of burden for me. > > That is the reason why we switched to CLANG in our project for now but I > would love to see GCC first-class support as well. > > What is the reason that GCC does not track SSE register usage? Is it a GGC > architecture restriction or something else? To use SSE registers in interrupt handler, you need to save the complete vector state, %xmm0-%xmm15 isn't sufficient. You need to preserve the whole set of vector registers plus MXCSR register. One way to do it is to use xsave/xrstor.
[Bug target/81709] __attribute__((interrupt)) should handle SSE registers
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81709 --- Comment #2 from Anatol --- Theoretically it is possible to do things like this manually. Track functions x86 extensions usage and save registers accordingly. But I would love to see a more automated and less error-prone way to do it. Similar to what CLANG compiler already does. CLANG tracks registers use and reduces a lot of burden for me. That is the reason why we switched to CLANG in our project for now but I would love to see GCC first-class support as well. What is the reason that GCC does not track SSE register usage? Is it a GGC architecture restriction or something else?
[Bug target/81709] __attribute__((interrupt)) should handle SSE registers
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81709 H.J. Lu changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|--- |WONTFIX --- Comment #1 from H.J. Lu --- If you want to use SSE registers, you can write the interrupt handler with the new naked attribute in GCC 8.