toolchain/share/doc/as.html/Xtensa-Call-Relaxation.html

86 lines
4.1 KiB
HTML

<html lang="en">
<head>
<title>Xtensa Call Relaxation - Using as</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Using as">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Xtensa-Relaxation.html#Xtensa-Relaxation" title="Xtensa Relaxation">
<link rel="prev" href="Xtensa-Branch-Relaxation.html#Xtensa-Branch-Relaxation" title="Xtensa Branch Relaxation">
<link rel="next" href="Xtensa-Jump-Relaxation.html#Xtensa-Jump-Relaxation" title="Xtensa Jump Relaxation">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
This file documents the GNU Assembler "as".
Copyright (C) 1991-2019 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, with no Front-Cover Texts, and with no
Back-Cover Texts. A copy of the license is included in the
section entitled ``GNU Free Documentation License''.
-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<a name="Xtensa-Call-Relaxation"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Xtensa-Jump-Relaxation.html#Xtensa-Jump-Relaxation">Xtensa Jump Relaxation</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Xtensa-Branch-Relaxation.html#Xtensa-Branch-Relaxation">Xtensa Branch Relaxation</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Xtensa-Relaxation.html#Xtensa-Relaxation">Xtensa Relaxation</a>
<hr>
</div>
<h5 class="subsubsection">9.55.4.2 Function Call Relaxation</h5>
<p><a name="index-relaxation-of-call-instructions-2636"></a><a name="index-call-instructions_002c-relaxation-2637"></a>
Function calls may require relaxation because the Xtensa immediate call
instructions (<code>CALL0</code>, <code>CALL4</code>, <code>CALL8</code> and
<code>CALL12</code>) provide a PC-relative offset of only 512 Kbytes in either
direction. For larger programs, it may be necessary to use indirect
calls (<code>CALLX0</code>, <code>CALLX4</code>, <code>CALLX8</code> and <code>CALLX12</code>)
where the target address is specified in a register. The Xtensa
assembler can automatically relax immediate call instructions into
indirect call instructions. This relaxation is done by loading the
address of the called function into the callee's return address register
and then using a <code>CALLX</code> instruction. So, for example:
<pre class="smallexample"> call8 func
</pre>
<p>might be relaxed to:
<pre class="smallexample"> .literal .L1, func
l32r a8, .L1
callx8 a8
</pre>
<p>Because the addresses of targets of function calls are not generally
known until link-time, the assembler must assume the worst and relax all
the calls to functions in other source files, not just those that really
will be out of range. The linker can recognize calls that were
unnecessarily relaxed, and it will remove the overhead introduced by the
assembler for those cases where direct calls are sufficient.
<p>Call relaxation is disabled by default because it can have a negative
effect on both code size and performance, although the linker can
usually eliminate the unnecessary overhead. If a program is too large
and some of the calls are out of range, function call relaxation can be
enabled using the &lsquo;<samp><span class="samp">--longcalls</span></samp>&rsquo; command-line option or the
<code>longcalls</code> directive (see <a href="Longcalls-Directive.html#Longcalls-Directive">longcalls</a>).
</body></html>