]>
Commit | Line | Data |
---|---|---|
c63539ff ML |
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 | .. index:: calling functions in RTL, RTL function-call insns, function-call insns | |
7 | ||
8 | .. _calls: | |
9 | ||
10 | RTL Representation of Function-Call Insns | |
11 | ***************************************** | |
12 | ||
13 | Insns that call subroutines have the RTL expression code ``call_insn``. | |
14 | These insns must satisfy special rules, and their bodies must use a special | |
15 | RTL expression code, ``call``. | |
16 | ||
17 | .. index:: call usage | |
18 | ||
19 | A ``call`` expression has two operands, as follows: | |
20 | ||
21 | .. code-block:: c++ | |
22 | ||
23 | (call (mem:fm addr) nbytes) | |
24 | ||
25 | Here :samp:`{nbytes}` is an operand that represents the number of bytes of | |
26 | argument data being passed to the subroutine, :samp:`{fm}` is a machine mode | |
27 | (which must equal as the definition of the ``FUNCTION_MODE`` macro in | |
28 | the machine description) and :samp:`{addr}` represents the address of the | |
29 | subroutine. | |
30 | ||
31 | For a subroutine that returns no value, the ``call`` expression as | |
32 | shown above is the entire body of the insn, except that the insn might | |
33 | also contain ``use`` or ``clobber`` expressions. | |
34 | ||
35 | .. index:: BLKmode, and function return values | |
36 | ||
37 | For a subroutine that returns a value whose mode is not ``BLKmode``, | |
38 | the value is returned in a hard register. If this register's number is | |
39 | :samp:`{r}`, then the body of the call insn looks like this: | |
40 | ||
41 | .. code-block:: c++ | |
42 | ||
43 | (set (reg:m r) | |
44 | (call (mem:fm addr) nbytes)) | |
45 | ||
46 | This RTL expression makes it clear (to the optimizer passes) that the | |
47 | appropriate register receives a useful value in this insn. | |
48 | ||
49 | When a subroutine returns a ``BLKmode`` value, it is handled by | |
50 | passing to the subroutine the address of a place to store the value. | |
51 | So the call insn itself does not 'return' any value, and it has the | |
52 | same RTL form as a call that returns nothing. | |
53 | ||
54 | On some machines, the call instruction itself clobbers some register, | |
55 | for example to contain the return address. ``call_insn`` insns | |
56 | on these machines should have a body which is a ``parallel`` | |
57 | that contains both the ``call`` expression and ``clobber`` | |
58 | expressions that indicate which registers are destroyed. Similarly, | |
59 | if the call instruction requires some register other than the stack | |
60 | pointer that is not explicitly mentioned in its RTL, a ``use`` | |
61 | subexpression should mention that register. | |
62 | ||
63 | Functions that are called are assumed to modify all registers listed in | |
64 | the configuration macro ``CALL_USED_REGISTERS`` (see :ref:`register-basics`) and, with the exception of ``const`` functions and library | |
65 | calls, to modify all of memory. | |
66 | ||
67 | Insns containing just ``use`` expressions directly precede the | |
68 | ``call_insn`` insn to indicate which registers contain inputs to the | |
69 | function. Similarly, if registers other than those in | |
70 | ``CALL_USED_REGISTERS`` are clobbered by the called function, insns | |
71 | containing a single ``clobber`` follow immediately after the call to | |
3ed1b4ce | 72 | indicate which registers. |