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