Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

235 lines
10KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <title>Conversions (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Conversions (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Conversions (GNU Compiler Collection (GCC) Internals)">
  23. <meta name="resource-type" content="document">
  24. <meta name="distribution" content="global">
  25. <meta name="Generator" content="makeinfo">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="RTL.html#RTL" rel="up" title="RTL">
  30. <link href="RTL-Declarations.html#RTL-Declarations" rel="next" title="RTL Declarations">
  31. <link href="Vector-Operations.html#Vector-Operations" rel="prev" title="Vector Operations">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.indentedblock {margin-right: 0em}
  36. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  37. blockquote.smallquotation {font-size: smaller}
  38. div.display {margin-left: 3.2em}
  39. div.example {margin-left: 3.2em}
  40. div.lisp {margin-left: 3.2em}
  41. div.smalldisplay {margin-left: 3.2em}
  42. div.smallexample {margin-left: 3.2em}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style: oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nolinebreak {white-space: nowrap}
  54. span.roman {font-family: initial; font-weight: normal}
  55. span.sansserif {font-family: sans-serif; font-weight: normal}
  56. ul.no-bullet {list-style: none}
  57. -->
  58. </style>
  59. </head>
  60. <body lang="en">
  61. <a name="Conversions"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="RTL-Declarations.html#RTL-Declarations" accesskey="n" rel="next">RTL Declarations</a>, Previous: <a href="Vector-Operations.html#Vector-Operations" accesskey="p" rel="prev">Vector Operations</a>, Up: <a href="RTL.html#RTL" accesskey="u" rel="up">RTL</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  65. </div>
  66. <hr>
  67. <a name="Conversions-1"></a>
  68. <h3 class="section">14.13 Conversions</h3>
  69. <a name="index-conversions"></a>
  70. <a name="index-machine-mode-conversions"></a>
  71. <p>All conversions between machine modes must be represented by
  72. explicit conversion operations. For example, an expression
  73. which is the sum of a byte and a full word cannot be written as
  74. <code>(plus:SI (reg:QI 34) (reg:SI 80))</code> because the <code>plus</code>
  75. operation requires two operands of the same machine mode.
  76. Therefore, the byte-sized operand is enclosed in a conversion
  77. operation, as in
  78. </p>
  79. <div class="smallexample">
  80. <pre class="smallexample">(plus:SI (sign_extend:SI (reg:QI 34)) (reg:SI 80))
  81. </pre></div>
  82. <p>The conversion operation is not a mere placeholder, because there
  83. may be more than one way of converting from a given starting mode
  84. to the desired final mode. The conversion operation code says how
  85. to do it.
  86. </p>
  87. <p>For all conversion operations, <var>x</var> must not be <code>VOIDmode</code>
  88. because the mode in which to do the conversion would not be known.
  89. The conversion must either be done at compile-time or <var>x</var>
  90. must be placed into a register.
  91. </p>
  92. <dl compact="compact">
  93. <dd><a name="index-sign_005fextend"></a>
  94. </dd>
  95. <dt><code>(sign_extend:<var>m</var> <var>x</var>)</code></dt>
  96. <dd><p>Represents the result of sign-extending the value <var>x</var>
  97. to machine mode <var>m</var>. <var>m</var> must be a fixed-point mode
  98. and <var>x</var> a fixed-point value of a mode narrower than <var>m</var>.
  99. </p>
  100. <a name="index-zero_005fextend"></a>
  101. </dd>
  102. <dt><code>(zero_extend:<var>m</var> <var>x</var>)</code></dt>
  103. <dd><p>Represents the result of zero-extending the value <var>x</var>
  104. to machine mode <var>m</var>. <var>m</var> must be a fixed-point mode
  105. and <var>x</var> a fixed-point value of a mode narrower than <var>m</var>.
  106. </p>
  107. <a name="index-float_005fextend"></a>
  108. </dd>
  109. <dt><code>(float_extend:<var>m</var> <var>x</var>)</code></dt>
  110. <dd><p>Represents the result of extending the value <var>x</var>
  111. to machine mode <var>m</var>. <var>m</var> must be a floating point mode
  112. and <var>x</var> a floating point value of a mode narrower than <var>m</var>.
  113. </p>
  114. <a name="index-truncate"></a>
  115. </dd>
  116. <dt><code>(truncate:<var>m</var> <var>x</var>)</code></dt>
  117. <dd><p>Represents the result of truncating the value <var>x</var>
  118. to machine mode <var>m</var>. <var>m</var> must be a fixed-point mode
  119. and <var>x</var> a fixed-point value of a mode wider than <var>m</var>.
  120. </p>
  121. <a name="index-ss_005ftruncate"></a>
  122. </dd>
  123. <dt><code>(ss_truncate:<var>m</var> <var>x</var>)</code></dt>
  124. <dd><p>Represents the result of truncating the value <var>x</var>
  125. to machine mode <var>m</var>, using signed saturation in the case of
  126. overflow. Both <var>m</var> and the mode of <var>x</var> must be fixed-point
  127. modes.
  128. </p>
  129. <a name="index-us_005ftruncate"></a>
  130. </dd>
  131. <dt><code>(us_truncate:<var>m</var> <var>x</var>)</code></dt>
  132. <dd><p>Represents the result of truncating the value <var>x</var>
  133. to machine mode <var>m</var>, using unsigned saturation in the case of
  134. overflow. Both <var>m</var> and the mode of <var>x</var> must be fixed-point
  135. modes.
  136. </p>
  137. <a name="index-float_005ftruncate"></a>
  138. </dd>
  139. <dt><code>(float_truncate:<var>m</var> <var>x</var>)</code></dt>
  140. <dd><p>Represents the result of truncating the value <var>x</var>
  141. to machine mode <var>m</var>. <var>m</var> must be a floating point mode
  142. and <var>x</var> a floating point value of a mode wider than <var>m</var>.
  143. </p>
  144. <a name="index-float"></a>
  145. </dd>
  146. <dt><code>(float:<var>m</var> <var>x</var>)</code></dt>
  147. <dd><p>Represents the result of converting fixed point value <var>x</var>,
  148. regarded as signed, to floating point mode <var>m</var>.
  149. </p>
  150. <a name="index-unsigned_005ffloat"></a>
  151. </dd>
  152. <dt><code>(unsigned_float:<var>m</var> <var>x</var>)</code></dt>
  153. <dd><p>Represents the result of converting fixed point value <var>x</var>,
  154. regarded as unsigned, to floating point mode <var>m</var>.
  155. </p>
  156. <a name="index-fix"></a>
  157. </dd>
  158. <dt><code>(fix:<var>m</var> <var>x</var>)</code></dt>
  159. <dd><p>When <var>m</var> is a floating-point mode, represents the result of
  160. converting floating point value <var>x</var> (valid for mode <var>m</var>) to an
  161. integer, still represented in floating point mode <var>m</var>, by rounding
  162. towards zero.
  163. </p>
  164. <p>When <var>m</var> is a fixed-point mode, represents the result of
  165. converting floating point value <var>x</var> to mode <var>m</var>, regarded as
  166. signed. How rounding is done is not specified, so this operation may
  167. be used validly in compiling C code only for integer-valued operands.
  168. </p>
  169. <a name="index-unsigned_005ffix"></a>
  170. </dd>
  171. <dt><code>(unsigned_fix:<var>m</var> <var>x</var>)</code></dt>
  172. <dd><p>Represents the result of converting floating point value <var>x</var> to
  173. fixed point mode <var>m</var>, regarded as unsigned. How rounding is done
  174. is not specified.
  175. </p>
  176. <a name="index-fract_005fconvert"></a>
  177. </dd>
  178. <dt><code>(fract_convert:<var>m</var> <var>x</var>)</code></dt>
  179. <dd><p>Represents the result of converting fixed-point value <var>x</var> to
  180. fixed-point mode <var>m</var>, signed integer value <var>x</var> to
  181. fixed-point mode <var>m</var>, floating-point value <var>x</var> to
  182. fixed-point mode <var>m</var>, fixed-point value <var>x</var> to integer mode <var>m</var>
  183. regarded as signed, or fixed-point value <var>x</var> to floating-point mode <var>m</var>.
  184. When overflows or underflows happen, the results are undefined.
  185. </p>
  186. <a name="index-sat_005ffract"></a>
  187. </dd>
  188. <dt><code>(sat_fract:<var>m</var> <var>x</var>)</code></dt>
  189. <dd><p>Represents the result of converting fixed-point value <var>x</var> to
  190. fixed-point mode <var>m</var>, signed integer value <var>x</var> to
  191. fixed-point mode <var>m</var>, or floating-point value <var>x</var> to
  192. fixed-point mode <var>m</var>.
  193. When overflows or underflows happen, the results are saturated to the
  194. maximum or the minimum.
  195. </p>
  196. <a name="index-unsigned_005ffract_005fconvert"></a>
  197. </dd>
  198. <dt><code>(unsigned_fract_convert:<var>m</var> <var>x</var>)</code></dt>
  199. <dd><p>Represents the result of converting fixed-point value <var>x</var> to
  200. integer mode <var>m</var> regarded as unsigned, or unsigned integer value <var>x</var> to
  201. fixed-point mode <var>m</var>.
  202. When overflows or underflows happen, the results are undefined.
  203. </p>
  204. <a name="index-unsigned_005fsat_005ffract"></a>
  205. </dd>
  206. <dt><code>(unsigned_sat_fract:<var>m</var> <var>x</var>)</code></dt>
  207. <dd><p>Represents the result of converting unsigned integer value <var>x</var> to
  208. fixed-point mode <var>m</var>.
  209. When overflows or underflows happen, the results are saturated to the
  210. maximum or the minimum.
  211. </p></dd>
  212. </dl>
  213. <hr>
  214. <div class="header">
  215. <p>
  216. Next: <a href="RTL-Declarations.html#RTL-Declarations" accesskey="n" rel="next">RTL Declarations</a>, Previous: <a href="Vector-Operations.html#Vector-Operations" accesskey="p" rel="prev">Vector Operations</a>, Up: <a href="RTL.html#RTL" accesskey="u" rel="up">RTL</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  217. </div>
  218. </body>
  219. </html>