<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.7"> <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-Immediate-Relaxation.html#Xtensa-Immediate-Relaxation" title="Xtensa Immediate 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, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001, 2002, 2006, 2007 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.1 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''. man end--> <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; } --></style> </head> <body> <div class="node"> <p> <a name="Xtensa-Call-Relaxation"></a>Next: <a rel="next" accesskey="n" href="Xtensa-Immediate-Relaxation.html#Xtensa-Immediate-Relaxation">Xtensa Immediate Relaxation</a>, Previous: <a rel="previous" accesskey="p" href="Xtensa-Branch-Relaxation.html#Xtensa-Branch-Relaxation">Xtensa Branch Relaxation</a>, Up: <a rel="up" accesskey="u" href="Xtensa-Relaxation.html#Xtensa-Relaxation">Xtensa Relaxation</a> <hr><br> </div> <h5 class="subsubsection">9.36.4.2 Function Call Relaxation</h5> <p><a name="index-relaxation-of-call-instructions-1866"></a><a name="index-call-instructions_002c-relaxation-1867"></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 <span class="samp">--longcalls</span> command-line option or the <code>longcalls</code> directive (see <a href="Longcalls-Directive.html#Longcalls-Directive">longcalls</a>). </body></html>