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.
6 .. index:: arguments in registers, registers arguments
8 .. _register-arguments:
10 Passing Arguments in Registers
11 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13 This section describes the macros which let you control how various
14 types of arguments are passed in registers or how they are arranged in
17 .. include:: ../tm.rst.in
18 :start-after: [TARGET_FUNCTION_ARG]
19 :end-before: [TARGET_FUNCTION_ARG]
22 .. include:: ../tm.rst.in
23 :start-after: [TARGET_MUST_PASS_IN_STACK]
24 :end-before: [TARGET_MUST_PASS_IN_STACK]
27 .. include:: ../tm.rst.in
28 :start-after: [TARGET_FUNCTION_INCOMING_ARG]
29 :end-before: [TARGET_FUNCTION_INCOMING_ARG]
32 .. include:: ../tm.rst.in
33 :start-after: [TARGET_USE_PSEUDO_PIC_REG]
34 :end-before: [TARGET_USE_PSEUDO_PIC_REG]
37 .. include:: ../tm.rst.in
38 :start-after: [TARGET_INIT_PIC_REG]
39 :end-before: [TARGET_INIT_PIC_REG]
42 .. include:: ../tm.rst.in
43 :start-after: [TARGET_ARG_PARTIAL_BYTES]
44 :end-before: [TARGET_ARG_PARTIAL_BYTES]
47 .. include:: ../tm.rst.in
48 :start-after: [TARGET_PASS_BY_REFERENCE]
49 :end-before: [TARGET_PASS_BY_REFERENCE]
52 .. include:: ../tm.rst.in
53 :start-after: [TARGET_CALLEE_COPIES]
54 :end-before: [TARGET_CALLEE_COPIES]
57 .. c:macro:: CUMULATIVE_ARGS
59 A C type for declaring a variable that is used as the first argument
60 of ``TARGET_FUNCTION_ARG`` and other related values. For some
61 target machines, the type ``int`` suffices and can hold the number
62 of bytes of argument so far.
64 There is no need to record in ``CUMULATIVE_ARGS`` anything about the
65 arguments that have been passed on the stack. The compiler has other
66 variables to keep track of that. For target machines on which all
67 arguments are passed on the stack, there is no need to store anything in
68 ``CUMULATIVE_ARGS`` ; however, the data structure must exist and
69 should not be empty, so use ``int``.
71 .. c:macro:: OVERRIDE_ABI_FORMAT (fndecl)
73 If defined, this macro is called before generating any code for a
74 function, but after the :samp:`{cfun}` descriptor for the function has been
75 created. The back end may use this macro to update :samp:`{cfun}` to
76 reflect an ABI other than that which would normally be used by default.
77 If the compiler is generating code for a compiler-generated function,
78 :samp:`{fndecl}` may be ``NULL``.
80 .. c:macro:: INIT_CUMULATIVE_ARGS (cum, fntype, libname, fndecl, n_named_args)
82 A C statement (sans semicolon) for initializing the variable
83 :samp:`{cum}` for the state at the beginning of the argument list. The
84 variable has type ``CUMULATIVE_ARGS``. The value of :samp:`{fntype}`
85 is the tree node for the data type of the function which will receive
86 the args, or 0 if the args are to a compiler support library function.
87 For direct calls that are not libcalls, :samp:`{fndecl}` contain the
88 declaration node of the function. :samp:`{fndecl}` is also set when
89 ``INIT_CUMULATIVE_ARGS`` is used to find arguments for the function
90 being compiled. :samp:`{n_named_args}` is set to the number of named
91 arguments, including a structure return address if it is passed as a
92 parameter, when making a call. When processing incoming arguments,
93 :samp:`{n_named_args}` is set to -1.
95 When processing a call to a compiler support library function,
96 :samp:`{libname}` identifies which one. It is a ``symbol_ref`` rtx which
97 contains the name of the function, as a string. :samp:`{libname}` is 0 when
98 an ordinary C function call is being processed. Thus, each time this
99 macro is called, either :samp:`{libname}` or :samp:`{fntype}` is nonzero, but
100 never both of them at once.
102 .. c:macro:: INIT_CUMULATIVE_LIBCALL_ARGS (cum, mode, libname)
104 Like ``INIT_CUMULATIVE_ARGS`` but only used for outgoing libcalls,
105 it gets a ``MODE`` argument instead of :samp:`{fntype}`, that would be
106 ``NULL``. :samp:`{indirect}` would always be zero, too. If this macro
107 is not defined, ``INIT_CUMULATIVE_ARGS (cum, NULL_RTX, libname,
108 0)`` is used instead.
110 .. c:macro:: INIT_CUMULATIVE_INCOMING_ARGS (cum, fntype, libname)
112 Like ``INIT_CUMULATIVE_ARGS`` but overrides it for the purposes of
113 finding the arguments for the function being compiled. If this macro is
114 undefined, ``INIT_CUMULATIVE_ARGS`` is used instead.
116 The value passed for :samp:`{libname}` is always 0, since library routines
117 with special calling conventions are never compiled with GCC. The
118 argument :samp:`{libname}` exists for symmetry with
119 ``INIT_CUMULATIVE_ARGS``.
121 .. could use "this macro" in place of @code{INIT_CUMULATIVE_ARGS}, maybe.
123 .. -mew 5feb93 i switched the order of the sentences. -mew 10feb93
125 .. include:: ../tm.rst.in
126 :start-after: [TARGET_FUNCTION_ARG_ADVANCE]
127 :end-before: [TARGET_FUNCTION_ARG_ADVANCE]
130 .. include:: ../tm.rst.in
131 :start-after: [TARGET_FUNCTION_ARG_OFFSET]
132 :end-before: [TARGET_FUNCTION_ARG_OFFSET]
135 .. include:: ../tm.rst.in
136 :start-after: [TARGET_FUNCTION_ARG_PADDING]
137 :end-before: [TARGET_FUNCTION_ARG_PADDING]
140 .. c:macro:: PAD_VARARGS_DOWN
142 If defined, a C expression which determines whether the default
143 implementation of va_arg will attempt to pad down before reading the
144 next argument, if that argument is smaller than its aligned space as
145 controlled by ``PARM_BOUNDARY``. If this macro is not defined, all such
146 arguments are padded down if ``BYTES_BIG_ENDIAN`` is true.
148 .. c:macro:: BLOCK_REG_PADDING (mode, type, first)
150 Specify padding for the last element of a block move between registers and
151 memory. :samp:`{first}` is nonzero if this is the only element. Defining this
152 macro allows better control of register function parameters on big-endian
153 machines, without using ``PARALLEL`` rtl. In particular,
154 ``MUST_PASS_IN_STACK`` need not test padding and mode of types in
155 registers, as there is no longer a "wrong" part of a register; For example,
156 a three byte aggregate may be passed in the high part of a register if so
159 .. include:: ../tm.rst.in
160 :start-after: [TARGET_FUNCTION_ARG_BOUNDARY]
161 :end-before: [TARGET_FUNCTION_ARG_BOUNDARY]
164 .. include:: ../tm.rst.in
165 :start-after: [TARGET_FUNCTION_ARG_ROUND_BOUNDARY]
166 :end-before: [TARGET_FUNCTION_ARG_ROUND_BOUNDARY]
169 .. c:macro:: FUNCTION_ARG_REGNO_P (regno)
171 A C expression that is nonzero if :samp:`{regno}` is the number of a hard
172 register in which function arguments are sometimes passed. This does
173 *not* include implicit arguments such as the static chain and
174 the structure-value address. On many machines, no registers can be
175 used for this purpose since all function arguments are pushed on the
178 .. include:: ../tm.rst.in
179 :start-after: [TARGET_SPLIT_COMPLEX_ARG]
180 :end-before: [TARGET_SPLIT_COMPLEX_ARG]
183 .. include:: ../tm.rst.in
184 :start-after: [TARGET_BUILD_BUILTIN_VA_LIST]
185 :end-before: [TARGET_BUILD_BUILTIN_VA_LIST]
188 .. include:: ../tm.rst.in
189 :start-after: [TARGET_ENUM_VA_LIST_P]
190 :end-before: [TARGET_ENUM_VA_LIST_P]
193 .. include:: ../tm.rst.in
194 :start-after: [TARGET_FN_ABI_VA_LIST]
195 :end-before: [TARGET_FN_ABI_VA_LIST]
198 .. include:: ../tm.rst.in
199 :start-after: [TARGET_CANONICAL_VA_LIST_TYPE]
200 :end-before: [TARGET_CANONICAL_VA_LIST_TYPE]
203 .. include:: ../tm.rst.in
204 :start-after: [TARGET_GIMPLIFY_VA_ARG_EXPR]
205 :end-before: [TARGET_GIMPLIFY_VA_ARG_EXPR]
208 .. include:: ../tm.rst.in
209 :start-after: [TARGET_VALID_POINTER_MODE]
210 :end-before: [TARGET_VALID_POINTER_MODE]
213 .. include:: ../tm.rst.in
214 :start-after: [TARGET_REF_MAY_ALIAS_ERRNO]
215 :end-before: [TARGET_REF_MAY_ALIAS_ERRNO]
218 .. include:: ../tm.rst.in
219 :start-after: [TARGET_TRANSLATE_MODE_ATTRIBUTE]
220 :end-before: [TARGET_TRANSLATE_MODE_ATTRIBUTE]
223 .. include:: ../tm.rst.in
224 :start-after: [TARGET_SCALAR_MODE_SUPPORTED_P]
225 :end-before: [TARGET_SCALAR_MODE_SUPPORTED_P]
228 .. include:: ../tm.rst.in
229 :start-after: [TARGET_VECTOR_MODE_SUPPORTED_P]
230 :end-before: [TARGET_VECTOR_MODE_SUPPORTED_P]
233 .. include:: ../tm.rst.in
234 :start-after: [TARGET_COMPATIBLE_VECTOR_TYPES_P]
235 :end-before: [TARGET_COMPATIBLE_VECTOR_TYPES_P]
238 .. include:: ../tm.rst.in
239 :start-after: [TARGET_ARRAY_MODE]
240 :end-before: [TARGET_ARRAY_MODE]
243 .. include:: ../tm.rst.in
244 :start-after: [TARGET_ARRAY_MODE_SUPPORTED_P]
245 :end-before: [TARGET_ARRAY_MODE_SUPPORTED_P]
248 .. include:: ../tm.rst.in
249 :start-after: [TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P]
250 :end-before: [TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P]
253 .. include:: ../tm.rst.in
254 :start-after: [TARGET_FLOATN_MODE]
255 :end-before: [TARGET_FLOATN_MODE]
258 .. include:: ../tm.rst.in
259 :start-after: [TARGET_FLOATN_BUILTIN_P]
260 :end-before: [TARGET_FLOATN_BUILTIN_P]
263 .. include:: ../tm.rst.in
264 :start-after: [TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P]
265 :end-before: [TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P]