Methods of minimizing function parameter
passing overhead
There are a number of ways in which you can minimize the overhead
of passing parameters to functions. For example:
Ensure that functions take four or
fewer arguments if each argument is a word or less in size. In C++,
ensure that nonstatic member functions take three or fewer arguments because
of the implicit this pointer argument that is
usually passed in R0.
Ensure that a function does a significant amount
of work if it requires more than four arguments, so that the cost
of passing the stacked arguments is outweighed.
Put related arguments in a structure, and pass a
pointer to the structure in any function call. This reduces the
number of parameters and increases readability.
Minimize the number of long long parameters,
because these take two argument words that have to be aligned on
an even register index.
Minimize the number of double parameters
when using software floating-point.
Avoid functions with a variable number of parameters.
Functions taking a variable number of arguments effectively pass
all their arguments on the stack.
This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.
ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.