Xtensa-Immediate-Relaxation.html 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- This file documents the GNU Assembler "as".
  4. Copyright (C) 1991-2017 Free Software Foundation, Inc.
  5. Permission is granted to copy, distribute and/or modify this document
  6. under the terms of the GNU Free Documentation License, Version 1.3
  7. or any later version published by the Free Software Foundation;
  8. with no Invariant Sections, with no Front-Cover Texts, and with no
  9. Back-Cover Texts. A copy of the license is included in the
  10. section entitled "GNU Free Documentation License".
  11. -->
  12. <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
  13. <head>
  14. <title>Using as: Xtensa Immediate Relaxation</title>
  15. <meta name="description" content="Using as: Xtensa Immediate Relaxation">
  16. <meta name="keywords" content="Using as: Xtensa Immediate Relaxation">
  17. <meta name="resource-type" content="document">
  18. <meta name="distribution" content="global">
  19. <meta name="Generator" content="makeinfo">
  20. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  21. <link href="index.html#Top" rel="start" title="Top">
  22. <link href="AS-Index.html#AS-Index" rel="index" title="AS Index">
  23. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  24. <link href="Xtensa-Relaxation.html#Xtensa-Relaxation" rel="up" title="Xtensa Relaxation">
  25. <link href="Xtensa-Directives.html#Xtensa-Directives" rel="next" title="Xtensa Directives">
  26. <link href="Xtensa-Jump-Relaxation.html#Xtensa-Jump-Relaxation" rel="prev" title="Xtensa Jump Relaxation">
  27. <style type="text/css">
  28. <!--
  29. a.summary-letter {text-decoration: none}
  30. blockquote.smallquotation {font-size: smaller}
  31. div.display {margin-left: 3.2em}
  32. div.example {margin-left: 3.2em}
  33. div.indentedblock {margin-left: 3.2em}
  34. div.lisp {margin-left: 3.2em}
  35. div.smalldisplay {margin-left: 3.2em}
  36. div.smallexample {margin-left: 3.2em}
  37. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  38. div.smalllisp {margin-left: 3.2em}
  39. kbd {font-style:oblique}
  40. pre.display {font-family: inherit}
  41. pre.format {font-family: inherit}
  42. pre.menu-comment {font-family: serif}
  43. pre.menu-preformatted {font-family: serif}
  44. pre.smalldisplay {font-family: inherit; font-size: smaller}
  45. pre.smallexample {font-size: smaller}
  46. pre.smallformat {font-family: inherit; font-size: smaller}
  47. pre.smalllisp {font-size: smaller}
  48. span.nocodebreak {white-space:nowrap}
  49. span.nolinebreak {white-space:nowrap}
  50. span.roman {font-family:serif; font-weight:normal}
  51. span.sansserif {font-family:sans-serif; font-weight:normal}
  52. ul.no-bullet {list-style: none}
  53. -->
  54. </style>
  55. </head>
  56. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  57. <a name="Xtensa-Immediate-Relaxation"></a>
  58. <div class="header">
  59. <p>
  60. Previous: <a href="Xtensa-Jump-Relaxation.html#Xtensa-Jump-Relaxation" accesskey="p" rel="prev">Xtensa Jump Relaxation</a>, Up: <a href="Xtensa-Relaxation.html#Xtensa-Relaxation" accesskey="u" rel="up">Xtensa Relaxation</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="AS-Index.html#AS-Index" title="Index" rel="index">Index</a>]</p>
  61. </div>
  62. <hr>
  63. <a name="Other-Immediate-Field-Relaxation"></a>
  64. <h4 class="subsubsection">9.53.4.4 Other Immediate Field Relaxation</h4>
  65. <a name="index-immediate-fields_002c-relaxation"></a>
  66. <a name="index-relaxation-of-immediate-fields"></a>
  67. <p>The assembler normally performs the following other relaxations. They
  68. can be disabled by using underscore prefixes (see <a href="Xtensa-Opcodes.html#Xtensa-Opcodes">Opcode Names</a>), the &lsquo;<samp>--no-transform</samp>&rsquo; command-line option
  69. (see <a href="Xtensa-Options.html#Xtensa-Options">Command Line Options</a>), or the
  70. <code>no-transform</code> directive (see <a href="Transform-Directive.html#Transform-Directive">transform</a>).
  71. </p>
  72. <a name="index-MOVI-instructions_002c-relaxation"></a>
  73. <a name="index-relaxation-of-MOVI-instructions"></a>
  74. <p>The <code>MOVI</code> machine instruction can only materialize values in the
  75. range from -2048 to 2047. Values outside this range are best
  76. materialized with <code>L32R</code> instructions. Thus:
  77. </p>
  78. <div class="smallexample">
  79. <pre class="smallexample"> movi a0, 100000
  80. </pre></div>
  81. <p>is assembled into the following machine code:
  82. </p>
  83. <div class="smallexample">
  84. <pre class="smallexample"> .literal .L1, 100000
  85. l32r a0, .L1
  86. </pre></div>
  87. <a name="index-L8UI-instructions_002c-relaxation"></a>
  88. <a name="index-L16SI-instructions_002c-relaxation"></a>
  89. <a name="index-L16UI-instructions_002c-relaxation"></a>
  90. <a name="index-L32I-instructions_002c-relaxation"></a>
  91. <a name="index-relaxation-of-L8UI-instructions"></a>
  92. <a name="index-relaxation-of-L16SI-instructions"></a>
  93. <a name="index-relaxation-of-L16UI-instructions"></a>
  94. <a name="index-relaxation-of-L32I-instructions"></a>
  95. <p>The <code>L8UI</code> machine instruction can only be used with immediate
  96. offsets in the range from 0 to 255. The <code>L16SI</code> and <code>L16UI</code>
  97. machine instructions can only be used with offsets from 0 to 510. The
  98. <code>L32I</code> machine instruction can only be used with offsets from 0 to
  99. 1020. A load offset outside these ranges can be materialized with
  100. an <code>L32R</code> instruction if the destination register of the load
  101. is different than the source address register. For example:
  102. </p>
  103. <div class="smallexample">
  104. <pre class="smallexample"> l32i a1, a0, 2040
  105. </pre></div>
  106. <p>is translated to:
  107. </p>
  108. <div class="smallexample">
  109. <pre class="smallexample"> .literal .L1, 2040
  110. l32r a1, .L1
  111. </pre><pre class="smallexample"> add a1, a0, a1
  112. l32i a1, a1, 0
  113. </pre></div>
  114. <p>If the load destination and source address register are the same, an
  115. out-of-range offset causes an error.
  116. </p>
  117. <a name="index-ADDI-instructions_002c-relaxation"></a>
  118. <a name="index-relaxation-of-ADDI-instructions"></a>
  119. <p>The Xtensa <code>ADDI</code> instruction only allows immediate operands in the
  120. range from -128 to 127. There are a number of alternate instruction
  121. sequences for the <code>ADDI</code> operation. First, if the
  122. immediate is 0, the <code>ADDI</code> will be turned into a <code>MOV.N</code>
  123. instruction (or the equivalent <code>OR</code> instruction if the code density
  124. option is not available). If the <code>ADDI</code> immediate is outside of
  125. the range -128 to 127, but inside the range -32896 to 32639, an
  126. <code>ADDMI</code> instruction or <code>ADDMI</code>/<code>ADDI</code> sequence will be
  127. used. Finally, if the immediate is outside of this range and a free
  128. register is available, an <code>L32R</code>/<code>ADD</code> sequence will be used
  129. with a literal allocated from the literal pool.
  130. </p>
  131. <p>For example:
  132. </p>
  133. <div class="smallexample">
  134. <pre class="smallexample"> addi a5, a6, 0
  135. addi a5, a6, 512
  136. </pre><pre class="smallexample"> addi a5, a6, 513
  137. addi a5, a6, 50000
  138. </pre></div>
  139. <p>is assembled into the following:
  140. </p>
  141. <div class="smallexample">
  142. <pre class="smallexample"> .literal .L1, 50000
  143. mov.n a5, a6
  144. </pre><pre class="smallexample"> addmi a5, a6, 0x200
  145. addmi a5, a6, 0x200
  146. addi a5, a5, 1
  147. </pre><pre class="smallexample"> l32r a5, .L1
  148. add a5, a6, a5
  149. </pre></div>
  150. <hr>
  151. <div class="header">
  152. <p>
  153. Previous: <a href="Xtensa-Jump-Relaxation.html#Xtensa-Jump-Relaxation" accesskey="p" rel="prev">Xtensa Jump Relaxation</a>, Up: <a href="Xtensa-Relaxation.html#Xtensa-Relaxation" accesskey="u" rel="up">Xtensa Relaxation</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="AS-Index.html#AS-Index" title="Index" rel="index">Index</a>]</p>
  154. </div>
  155. </body>
  156. </html>