@@ -4801,6 +4801,54 @@ Marking virtual functions as ``disable_tail_calls`` is legal.
4801
4801
}];
4802
4802
}
4803
4803
4804
+ def AnyX86InterruptDocs : Documentation {
4805
+ let Category = DocCatFunction;
4806
+ let Heading = "interrupt (X86)";
4807
+ let Content = [{
4808
+ Clang supports the GNU style ``__attribute__((interrupt))`` attribute on X86
4809
+ targets. This attribute may be attached to a function definition and instructs
4810
+ the backend to generate appropriate function entry/exit code so that it can be
4811
+ used directly as an interrupt service routine.
4812
+
4813
+ Interrupt handlers have access to the stack frame pushed onto the stack by the processor,
4814
+ and return using the ``IRET`` instruction. All registers in an interrupt handler are callee-saved.
4815
+ Exception handlers also have access to the error code pushed onto the stack by the processor,
4816
+ when applicable.
4817
+
4818
+ An interrupt handler must take the following arguments:
4819
+
4820
+ .. code-block:: c
4821
+
4822
+ __attribute__ ((interrupt))
4823
+ void f (struct stack_frame *frame) {
4824
+ ...
4825
+ }
4826
+
4827
+ Where ``struct stack_frame`` is a suitable struct matching the stack frame pushed by the
4828
+ processor.
4829
+
4830
+ An exception handler must take the following arguments:
4831
+
4832
+ .. code-block:: c
4833
+
4834
+ __attribute__ ((interrupt))
4835
+ void g (struct stack_frame *frame, unsigned long code) {
4836
+ ...
4837
+ }
4838
+
4839
+ On 32-bit targets, the ``code`` argument should be of type ``unsigned int``.
4840
+
4841
+ Exception handlers should only be used when an error code is pushed by the processor.
4842
+ Using the incorrect handler type will crash the system.
4843
+
4844
+ Interrupt and exception handlers cannot be called by other functions and must have return type ``void``.
4845
+
4846
+ Interrupt and exception handlers should only call functions with the 'no_caller_saved_registers'
4847
+ attribute, or should be compiled with the '-mgeneral-regs-only' flag to avoid saving unused
4848
+ non-GPR registers.
4849
+ }];
4850
+ }
4851
+
4804
4852
def AnyX86NoCallerSavedRegistersDocs : Documentation {
4805
4853
let Category = DocCatFunction;
4806
4854
let Content = [{
0 commit comments