You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RISC_002dV_002dDirectives.html 8.7KB

пре 3 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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-2020 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 6.5, http://www.gnu.org/software/texinfo/ -->
  13. <head>
  14. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  15. <title>RISC-V-Directives (Using as)</title>
  16. <meta name="description" content="RISC-V-Directives (Using as)">
  17. <meta name="keywords" content="RISC-V-Directives (Using as)">
  18. <meta name="resource-type" content="document">
  19. <meta name="distribution" content="global">
  20. <meta name="Generator" content="makeinfo">
  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="RISC_002dV_002dDependent.html#RISC_002dV_002dDependent" rel="up" title="RISC-V-Dependent">
  25. <link href="RISC_002dV_002dModifiers.html#RISC_002dV_002dModifiers" rel="next" title="RISC-V-Modifiers">
  26. <link href="RISC_002dV_002dOptions.html#RISC_002dV_002dOptions" rel="prev" title="RISC-V-Options">
  27. <style type="text/css">
  28. <!--
  29. a.summary-letter {text-decoration: none}
  30. blockquote.indentedblock {margin-right: 0em}
  31. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  32. blockquote.smallquotation {font-size: smaller}
  33. div.display {margin-left: 3.2em}
  34. div.example {margin-left: 3.2em}
  35. div.lisp {margin-left: 3.2em}
  36. div.smalldisplay {margin-left: 3.2em}
  37. div.smallexample {margin-left: 3.2em}
  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.nolinebreak {white-space: nowrap}
  49. span.roman {font-family: initial; font-weight: normal}
  50. span.sansserif {font-family: sans-serif; font-weight: normal}
  51. ul.no-bullet {list-style: none}
  52. -->
  53. </style>
  54. </head>
  55. <body lang="en">
  56. <a name="RISC_002dV_002dDirectives"></a>
  57. <div class="header">
  58. <p>
  59. Next: <a href="RISC_002dV_002dModifiers.html#RISC_002dV_002dModifiers" accesskey="n" rel="next">RISC-V-Modifiers</a>, Previous: <a href="RISC_002dV_002dOptions.html#RISC_002dV_002dOptions" accesskey="p" rel="prev">RISC-V-Options</a>, Up: <a href="RISC_002dV_002dDependent.html#RISC_002dV_002dDependent" accesskey="u" rel="up">RISC-V-Dependent</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>
  60. </div>
  61. <hr>
  62. <a name="RISC_002dV-Directives"></a>
  63. <h4 class="subsection">9.38.2 RISC-V Directives</h4>
  64. <a name="index-machine-directives_002c-RISC_002dV"></a>
  65. <a name="index-RISC_002dV-machine-directives"></a>
  66. <p>The following table lists all available RISC-V specific directives.
  67. </p>
  68. <dl compact="compact">
  69. <dd>
  70. <a name="index-align-directive-1"></a>
  71. </dd>
  72. <dt><code>.align <var>size-log-2</var></code></dt>
  73. <dd><p>Align to the given boundary, with the size given as log2 the number of bytes to
  74. align to.
  75. </p>
  76. <a name="index-Data-directives"></a>
  77. </dd>
  78. <dt><code>.half <var>value</var></code></dt>
  79. <dt><code>.word <var>value</var></code></dt>
  80. <dt><code>.dword <var>value</var></code></dt>
  81. <dd><p>Emits a half-word, word, or double-word value at the current position.
  82. </p>
  83. <a name="index-DTP_002drelative-data-directives"></a>
  84. </dd>
  85. <dt><code>.dtprelword <var>value</var></code></dt>
  86. <dt><code>.dtpreldword <var>value</var></code></dt>
  87. <dd><p>Emits a DTP-relative word (or double-word) at the current position. This is
  88. meant to be used by the compiler in shared libraries for DWARF debug info for
  89. thread local variables.
  90. </p>
  91. <a name="index-BSS-directive"></a>
  92. </dd>
  93. <dt><code>.bss</code></dt>
  94. <dd><p>Sets the current section to the BSS section.
  95. </p>
  96. <a name="index-LEB128-directives"></a>
  97. </dd>
  98. <dt><code>.uleb128 <var>value</var></code></dt>
  99. <dt><code>.sleb128 <var>value</var></code></dt>
  100. <dd><p>Emits a signed or unsigned LEB128 value at the current position. This only
  101. accepts constant expressions, because symbol addresses can change with
  102. relaxation, and we don&rsquo;t support relocations to modify LEB128 values at link
  103. time.
  104. </p>
  105. <a name="index-Option-directive"></a>
  106. <a name="index-option-directive"></a>
  107. </dd>
  108. <dt><code>.option <var>argument</var></code></dt>
  109. <dd><p>Modifies RISC-V specific assembler options inline with the assembly code.
  110. This is used when particular instruction sequences must be assembled with a
  111. specific set of options. For example, since we relax addressing sequences to
  112. shorter GP-relative sequences when possible the initial load of GP must not be
  113. relaxed and should be emitted as something like
  114. </p>
  115. <div class="smallexample">
  116. <pre class="smallexample"> .option push
  117. .option norelax
  118. la gp, __global_pointer$
  119. .option pop
  120. </pre></div>
  121. <p>in order to produce after linker relaxation the expected
  122. </p>
  123. <div class="smallexample">
  124. <pre class="smallexample"> auipc gp, %pcrel_hi(__global_pointer$)
  125. addi gp, gp, %pcrel_lo(__global_pointer$)
  126. </pre></div>
  127. <p>instead of just
  128. </p>
  129. <div class="smallexample">
  130. <pre class="smallexample"> addi gp, gp, 0
  131. </pre></div>
  132. <p>It&rsquo;s not expected that options are changed in this manner during regular use,
  133. but there are a handful of esoteric cases like the one above where users need
  134. to disable particular features of the assembler for particular code sequences.
  135. The complete list of option arguments is shown below:
  136. </p>
  137. <dl compact="compact">
  138. <dt><code>push</code></dt>
  139. <dt><code>pop</code></dt>
  140. <dd><p>Pushes or pops the current option stack. These should be used whenever
  141. changing an option in line with assembly code in order to ensure the user&rsquo;s
  142. command-line options are respected for the bulk of the file being assembled.
  143. </p>
  144. </dd>
  145. <dt><code>rvc</code></dt>
  146. <dt><code>norvc</code></dt>
  147. <dd><p>Enables or disables the generation of compressed instructions. Instructions
  148. are opportunistically compressed by the RISC-V assembler when possible, but
  149. sometimes this behavior is not desirable.
  150. </p>
  151. </dd>
  152. <dt><code>pic</code></dt>
  153. <dt><code>nopic</code></dt>
  154. <dd><p>Enables or disables position-independent code generation. Unless you really
  155. know what you&rsquo;re doing, this should only be at the top of a file.
  156. </p>
  157. </dd>
  158. <dt><code>relax</code></dt>
  159. <dt><code>norelax</code></dt>
  160. <dd><p>Enables or disables relaxation. The RISC-V assembler and linker
  161. opportunistically relax some code sequences, but sometimes this behavior is not
  162. desirable.
  163. </p></dd>
  164. </dl>
  165. </dd>
  166. <dt><code>csr-check</code></dt>
  167. <dt><code>no-csr-check</code></dt>
  168. <dd><p>Enables or disables the CSR checking.
  169. </p>
  170. <a name="index-INSN-directives"></a>
  171. </dd>
  172. <dt><code>.insn <var>value</var></code></dt>
  173. <dt><code>.insn <var>value</var></code></dt>
  174. <dd><p>This directive permits the numeric representation of an instructions
  175. and makes the assembler insert the operands according to one of the
  176. instruction formats for &lsquo;<samp>.insn</samp>&rsquo; (<a href="RISC_002dV_002dFormats.html#RISC_002dV_002dFormats">RISC-V-Formats</a>).
  177. For example, the instruction &lsquo;<samp>add a0, a1, a2</samp>&rsquo; could be written as
  178. &lsquo;<samp>.insn r 0x33, 0, 0, a0, a1, a2</samp>&rsquo;.
  179. </p>
  180. <a name="index-_002eattribute-directive_002c-RISC_002dV"></a>
  181. </dd>
  182. <dt><code>.attribute <var>tag</var>, <var>value</var></code></dt>
  183. <dd><p>Set the object attribute <var>tag</var> to <var>value</var>.
  184. </p>
  185. <p>The <var>tag</var> is either an attribute number, or one of the following:
  186. <code>Tag_RISCV_arch</code>, <code>Tag_RISCV_stack_align</code>,
  187. <code>Tag_RISCV_unaligned_access</code>, <code>Tag_RISCV_priv_spec</code>,
  188. <code>Tag_RISCV_priv_spec_minor</code>, <code>Tag_RISCV_priv_spec_revision</code>.
  189. </p>
  190. </dd>
  191. </dl>
  192. <hr>
  193. <div class="header">
  194. <p>
  195. Next: <a href="RISC_002dV_002dModifiers.html#RISC_002dV_002dModifiers" accesskey="n" rel="next">RISC-V-Modifiers</a>, Previous: <a href="RISC_002dV_002dOptions.html#RISC_002dV_002dOptions" accesskey="p" rel="prev">RISC-V-Options</a>, Up: <a href="RISC_002dV_002dDependent.html#RISC_002dV_002dDependent" accesskey="u" rel="up">RISC-V-Dependent</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>
  196. </div>
  197. </body>
  198. </html>