]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/risc-v-function-attributes.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / doc / gcc / extensions-to-the-c-language-family / declaring-attributes-of-functions / risc-v-function-attributes.rst
1 ..
2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
5
6 .. _risc-v-function-attributes:
7
8 RISC-V Function Attributes
9 ^^^^^^^^^^^^^^^^^^^^^^^^^^
10
11 These function attributes are supported by the RISC-V back end:
12
13 .. index:: naked function attribute, RISC-V
14
15 .. risc-v-fn-attr:: naked
16
17 This attribute allows the compiler to construct the
18 requisite function declaration, while allowing the body of the
19 function to be assembly code. The specified function will not have
20 prologue/epilogue sequences generated by the compiler. Only basic
21 ``asm`` statements can safely be included in naked functions
22 (see :ref:`basic-asm`). While using extended ``asm`` or a mixture of
23 basic ``asm`` and C code may appear to work, they cannot be
24 depended upon to work reliably and are not supported.
25
26 .. index:: interrupt function attribute, RISC-V
27
28 .. risc-v-fn-attr:: interrupt
29
30 Use this attribute to indicate that the specified function is an interrupt
31 handler. The compiler generates function entry and exit sequences suitable
32 for use in an interrupt handler when this attribute is present.
33
34 You can specify the kind of interrupt to be handled by adding an optional
35 parameter to the interrupt attribute like this:
36
37 .. code-block:: c++
38
39 void f (void) __attribute__ ((interrupt ("user")));
40
41 Permissible values for this parameter are ``user``, ``supervisor``,
42 and ``machine``. If there is no parameter, then it defaults to
43 ``machine``.