Constants.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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-2017 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 5.2, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <title>GNU Compiler Collection (GCC) Internals: Constants</title>
  20. <meta name="description" content="GNU Compiler Collection (GCC) Internals: Constants">
  21. <meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Constants">
  22. <meta name="resource-type" content="document">
  23. <meta name="distribution" content="global">
  24. <meta name="Generator" content="makeinfo">
  25. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  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="Regs-and-Memory.html#Regs-and-Memory" rel="next" title="Regs and Memory">
  31. <link href="Machine-Modes.html#Machine-Modes" rel="prev" title="Machine Modes">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.smallquotation {font-size: smaller}
  36. div.display {margin-left: 3.2em}
  37. div.example {margin-left: 3.2em}
  38. div.indentedblock {margin-left: 3.2em}
  39. div.lisp {margin-left: 3.2em}
  40. div.smalldisplay {margin-left: 3.2em}
  41. div.smallexample {margin-left: 3.2em}
  42. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  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.nocodebreak {white-space:nowrap}
  54. span.nolinebreak {white-space:nowrap}
  55. span.roman {font-family:serif; font-weight:normal}
  56. span.sansserif {font-family:sans-serif; font-weight:normal}
  57. ul.no-bullet {list-style: none}
  58. -->
  59. </style>
  60. </head>
  61. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  62. <a name="Constants"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="Regs-and-Memory.html#Regs-and-Memory" accesskey="n" rel="next">Regs and Memory</a>, Previous: <a href="Machine-Modes.html#Machine-Modes" accesskey="p" rel="prev">Machine Modes</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>
  66. </div>
  67. <hr>
  68. <a name="Constant-Expression-Types"></a>
  69. <h3 class="section">13.7 Constant Expression Types</h3>
  70. <a name="index-RTL-constants"></a>
  71. <a name="index-RTL-constant-expression-types"></a>
  72. <p>The simplest RTL expressions are those that represent constant values.
  73. </p>
  74. <dl compact="compact">
  75. <dd><a name="index-const_005fint"></a>
  76. </dd>
  77. <dt><code>(const_int <var>i</var>)</code></dt>
  78. <dd><p>This type of expression represents the integer value <var>i</var>. <var>i</var>
  79. is customarily accessed with the macro <code>INTVAL</code> as in
  80. <code>INTVAL (<var>exp</var>)</code>, which is equivalent to <code>XWINT (<var>exp</var>, 0)</code>.
  81. </p>
  82. <p>Constants generated for modes with fewer bits than in
  83. <code>HOST_WIDE_INT</code> must be sign extended to full width (e.g., with
  84. <code>gen_int_mode</code>). For constants for modes with more bits than in
  85. <code>HOST_WIDE_INT</code> the implied high order bits of that constant are
  86. copies of the top bit. Note however that values are neither
  87. inherently signed nor inherently unsigned; where necessary, signedness
  88. is determined by the rtl operation instead.
  89. </p>
  90. <a name="index-const0_005frtx"></a>
  91. <a name="index-const1_005frtx"></a>
  92. <a name="index-const2_005frtx"></a>
  93. <a name="index-constm1_005frtx"></a>
  94. <p>There is only one expression object for the integer value zero; it is
  95. the value of the variable <code>const0_rtx</code>. Likewise, the only
  96. expression for integer value one is found in <code>const1_rtx</code>, the only
  97. expression for integer value two is found in <code>const2_rtx</code>, and the
  98. only expression for integer value negative one is found in
  99. <code>constm1_rtx</code>. Any attempt to create an expression of code
  100. <code>const_int</code> and value zero, one, two or negative one will return
  101. <code>const0_rtx</code>, <code>const1_rtx</code>, <code>const2_rtx</code> or
  102. <code>constm1_rtx</code> as appropriate.
  103. </p>
  104. <a name="index-const_005ftrue_005frtx"></a>
  105. <p>Similarly, there is only one object for the integer whose value is
  106. <code>STORE_FLAG_VALUE</code>. It is found in <code>const_true_rtx</code>. If
  107. <code>STORE_FLAG_VALUE</code> is one, <code>const_true_rtx</code> and
  108. <code>const1_rtx</code> will point to the same object. If
  109. <code>STORE_FLAG_VALUE</code> is -1, <code>const_true_rtx</code> and
  110. <code>constm1_rtx</code> will point to the same object.
  111. </p>
  112. <a name="index-const_005fdouble"></a>
  113. </dd>
  114. <dt><code>(const_double:<var>m</var> <var>i0</var> <var>i1</var> &hellip;)</code></dt>
  115. <dd><p>This represents either a floating-point constant of mode <var>m</var> or
  116. (on older ports that do not define
  117. <code>TARGET_SUPPORTS_WIDE_INT</code>) an integer constant too large to fit
  118. into <code>HOST_BITS_PER_WIDE_INT</code> bits but small enough to fit within
  119. twice that number of bits. In the latter case, <var>m</var> will be
  120. <code>VOIDmode</code>. For integral values constants for modes with more
  121. bits than twice the number in <code>HOST_WIDE_INT</code> the implied high
  122. order bits of that constant are copies of the top bit of
  123. <code>CONST_DOUBLE_HIGH</code>. Note however that integral values are
  124. neither inherently signed nor inherently unsigned; where necessary,
  125. signedness is determined by the rtl operation instead.
  126. </p>
  127. <p>On more modern ports, <code>CONST_DOUBLE</code> only represents floating
  128. point values. New ports define <code>TARGET_SUPPORTS_WIDE_INT</code> to
  129. make this designation.
  130. </p>
  131. <a name="index-CONST_005fDOUBLE_005fLOW"></a>
  132. <p>If <var>m</var> is <code>VOIDmode</code>, the bits of the value are stored in
  133. <var>i0</var> and <var>i1</var>. <var>i0</var> is customarily accessed with the macro
  134. <code>CONST_DOUBLE_LOW</code> and <var>i1</var> with <code>CONST_DOUBLE_HIGH</code>.
  135. </p>
  136. <p>If the constant is floating point (regardless of its precision), then
  137. the number of integers used to store the value depends on the size of
  138. <code>REAL_VALUE_TYPE</code> (see <a href="Floating-Point.html#Floating-Point">Floating Point</a>). The integers
  139. represent a floating point number, but not precisely in the target
  140. machine&rsquo;s or host machine&rsquo;s floating point format. To convert them to
  141. the precise bit pattern used by the target machine, use the macro
  142. <code>REAL_VALUE_TO_TARGET_DOUBLE</code> and friends (see <a href="Data-Output.html#Data-Output">Data Output</a>).
  143. </p>
  144. <a name="index-CONST_005fWIDE_005fINT"></a>
  145. </dd>
  146. <dt><code>(const_wide_int:<var>m</var> <var>nunits</var> <var>elt0</var> &hellip;)</code></dt>
  147. <dd><p>This contains an array of <code>HOST_WIDE_INT</code>s that is large enough
  148. to hold any constant that can be represented on the target. This form
  149. of rtl is only used on targets that define
  150. <code>TARGET_SUPPORTS_WIDE_INT</code> to be nonzero and then
  151. <code>CONST_DOUBLE</code>s are only used to hold floating-point values. If
  152. the target leaves <code>TARGET_SUPPORTS_WIDE_INT</code> defined as 0,
  153. <code>CONST_WIDE_INT</code>s are not used and <code>CONST_DOUBLE</code>s are as
  154. they were before.
  155. </p>
  156. <p>The values are stored in a compressed format. The higher-order
  157. 0s or -1s are not represented if they are just the logical sign
  158. extension of the number that is represented.
  159. </p>
  160. <a name="index-CONST_005fWIDE_005fINT_005fVEC"></a>
  161. </dd>
  162. <dt><code>CONST_WIDE_INT_VEC (<var>code</var>)</code></dt>
  163. <dd><p>Returns the entire array of <code>HOST_WIDE_INT</code>s that are used to
  164. store the value. This macro should be rarely used.
  165. </p>
  166. <a name="index-CONST_005fWIDE_005fINT_005fNUNITS"></a>
  167. </dd>
  168. <dt><code>CONST_WIDE_INT_NUNITS (<var>code</var>)</code></dt>
  169. <dd><p>The number of <code>HOST_WIDE_INT</code>s used to represent the number.
  170. Note that this generally is smaller than the number of
  171. <code>HOST_WIDE_INT</code>s implied by the mode size.
  172. </p>
  173. <a name="index-CONST_005fWIDE_005fINT_005fELT"></a>
  174. </dd>
  175. <dt><code>CONST_WIDE_INT_NUNITS (<var>code</var>,<var>i</var>)</code></dt>
  176. <dd><p>Returns the <code>i</code>th element of the array. Element 0 is contains
  177. the low order bits of the constant.
  178. </p>
  179. <a name="index-const_005ffixed"></a>
  180. </dd>
  181. <dt><code>(const_fixed:<var>m</var> &hellip;)</code></dt>
  182. <dd><p>Represents a fixed-point constant of mode <var>m</var>.
  183. The operand is a data structure of type <code>struct fixed_value</code> and
  184. is accessed with the macro <code>CONST_FIXED_VALUE</code>. The high part of
  185. data is accessed with <code>CONST_FIXED_VALUE_HIGH</code>; the low part is
  186. accessed with <code>CONST_FIXED_VALUE_LOW</code>.
  187. </p>
  188. <a name="index-const_005fvector"></a>
  189. </dd>
  190. <dt><code>(const_vector:<var>m</var> [<var>x0</var> <var>x1</var> &hellip;])</code></dt>
  191. <dd><p>Represents a vector constant. The square brackets stand for the vector
  192. containing the constant elements. <var>x0</var>, <var>x1</var> and so on are
  193. the <code>const_int</code>, <code>const_double</code> or <code>const_fixed</code> elements.
  194. </p>
  195. <p>The number of units in a <code>const_vector</code> is obtained with the macro
  196. <code>CONST_VECTOR_NUNITS</code> as in <code>CONST_VECTOR_NUNITS (<var>v</var>)</code>.
  197. </p>
  198. <p>Individual elements in a vector constant are accessed with the macro
  199. <code>CONST_VECTOR_ELT</code> as in <code>CONST_VECTOR_ELT (<var>v</var>, <var>n</var>)</code>
  200. where <var>v</var> is the vector constant and <var>n</var> is the element
  201. desired.
  202. </p>
  203. <a name="index-const_005fstring"></a>
  204. </dd>
  205. <dt><code>(const_string <var>str</var>)</code></dt>
  206. <dd><p>Represents a constant string with value <var>str</var>. Currently this is
  207. used only for insn attributes (see <a href="Insn-Attributes.html#Insn-Attributes">Insn Attributes</a>) since constant
  208. strings in C are placed in memory.
  209. </p>
  210. <a name="index-symbol_005fref"></a>
  211. </dd>
  212. <dt><code>(symbol_ref:<var>mode</var> <var>symbol</var>)</code></dt>
  213. <dd><p>Represents the value of an assembler label for data. <var>symbol</var> is
  214. a string that describes the name of the assembler label. If it starts
  215. with a &lsquo;<samp>*</samp>&rsquo;, the label is the rest of <var>symbol</var> not including
  216. the &lsquo;<samp>*</samp>&rsquo;. Otherwise, the label is <var>symbol</var>, usually prefixed
  217. with &lsquo;<samp>_</samp>&rsquo;.
  218. </p>
  219. <p>The <code>symbol_ref</code> contains a mode, which is usually <code>Pmode</code>.
  220. Usually that is the only mode for which a symbol is directly valid.
  221. </p>
  222. <a name="index-label_005fref"></a>
  223. </dd>
  224. <dt><code>(label_ref:<var>mode</var> <var>label</var>)</code></dt>
  225. <dd><p>Represents the value of an assembler label for code. It contains one
  226. operand, an expression, which must be a <code>code_label</code> or a <code>note</code>
  227. of type <code>NOTE_INSN_DELETED_LABEL</code> that appears in the instruction
  228. sequence to identify the place where the label should go.
  229. </p>
  230. <p>The reason for using a distinct expression type for code label
  231. references is so that jump optimization can distinguish them.
  232. </p>
  233. <p>The <code>label_ref</code> contains a mode, which is usually <code>Pmode</code>.
  234. Usually that is the only mode for which a label is directly valid.
  235. </p>
  236. <a name="index-const"></a>
  237. </dd>
  238. <dt><code>(const:<var>m</var> <var>exp</var>)</code></dt>
  239. <dd><p>Represents a constant that is the result of an assembly-time
  240. arithmetic computation. The operand, <var>exp</var>, is an expression that
  241. contains only constants (<code>const_int</code>, <code>symbol_ref</code> and
  242. <code>label_ref</code> expressions) combined with <code>plus</code> and
  243. <code>minus</code>. However, not all combinations are valid, since the
  244. assembler cannot do arbitrary arithmetic on relocatable symbols.
  245. </p>
  246. <p><var>m</var> should be <code>Pmode</code>.
  247. </p>
  248. <a name="index-high"></a>
  249. </dd>
  250. <dt><code>(high:<var>m</var> <var>exp</var>)</code></dt>
  251. <dd><p>Represents the high-order bits of <var>exp</var>, usually a
  252. <code>symbol_ref</code>. The number of bits is machine-dependent and is
  253. normally the number of bits specified in an instruction that initializes
  254. the high order bits of a register. It is used with <code>lo_sum</code> to
  255. represent the typical two-instruction sequence used in RISC machines to
  256. reference a global memory location.
  257. </p>
  258. <p><var>m</var> should be <code>Pmode</code>.
  259. </p></dd>
  260. </dl>
  261. <a name="index-CONST0_005fRTX"></a>
  262. <a name="index-CONST1_005fRTX"></a>
  263. <a name="index-CONST2_005fRTX"></a>
  264. <p>The macro <code>CONST0_RTX (<var>mode</var>)</code> refers to an expression with
  265. value 0 in mode <var>mode</var>. If mode <var>mode</var> is of mode class
  266. <code>MODE_INT</code>, it returns <code>const0_rtx</code>. If mode <var>mode</var> is of
  267. mode class <code>MODE_FLOAT</code>, it returns a <code>CONST_DOUBLE</code>
  268. expression in mode <var>mode</var>. Otherwise, it returns a
  269. <code>CONST_VECTOR</code> expression in mode <var>mode</var>. Similarly, the macro
  270. <code>CONST1_RTX (<var>mode</var>)</code> refers to an expression with value 1 in
  271. mode <var>mode</var> and similarly for <code>CONST2_RTX</code>. The
  272. <code>CONST1_RTX</code> and <code>CONST2_RTX</code> macros are undefined
  273. for vector modes.
  274. </p>
  275. <hr>
  276. <div class="header">
  277. <p>
  278. Next: <a href="Regs-and-Memory.html#Regs-and-Memory" accesskey="n" rel="next">Regs and Memory</a>, Previous: <a href="Machine-Modes.html#Machine-Modes" accesskey="p" rel="prev">Machine Modes</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>
  279. </div>
  280. </body>
  281. </html>