選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

Constants.html 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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>Constants (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Constants (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Constants (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="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.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="Constants"></a>
  62. <div class="header">
  63. <p>
  64. 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>
  65. </div>
  66. <hr>
  67. <a name="Constant-Expression-Types"></a>
  68. <h3 class="section">14.7 Constant Expression Types</h3>
  69. <a name="index-RTL-constants"></a>
  70. <a name="index-RTL-constant-expression-types"></a>
  71. <p>The simplest RTL expressions are those that represent constant values.
  72. </p>
  73. <dl compact="compact">
  74. <dd><a name="index-const_005fint"></a>
  75. </dd>
  76. <dt><code>(const_int <var>i</var>)</code></dt>
  77. <dd><p>This type of expression represents the integer value <var>i</var>. <var>i</var>
  78. is customarily accessed with the macro <code>INTVAL</code> as in
  79. <code>INTVAL (<var>exp</var>)</code>, which is equivalent to <code>XWINT (<var>exp</var>, 0)</code>.
  80. </p>
  81. <p>Constants generated for modes with fewer bits than in
  82. <code>HOST_WIDE_INT</code> must be sign extended to full width (e.g., with
  83. <code>gen_int_mode</code>). For constants for modes with more bits than in
  84. <code>HOST_WIDE_INT</code> the implied high order bits of that constant are
  85. copies of the top bit. Note however that values are neither
  86. inherently signed nor inherently unsigned; where necessary, signedness
  87. is determined by the rtl operation instead.
  88. </p>
  89. <a name="index-const0_005frtx"></a>
  90. <a name="index-const1_005frtx"></a>
  91. <a name="index-const2_005frtx"></a>
  92. <a name="index-constm1_005frtx"></a>
  93. <p>There is only one expression object for the integer value zero; it is
  94. the value of the variable <code>const0_rtx</code>. Likewise, the only
  95. expression for integer value one is found in <code>const1_rtx</code>, the only
  96. expression for integer value two is found in <code>const2_rtx</code>, and the
  97. only expression for integer value negative one is found in
  98. <code>constm1_rtx</code>. Any attempt to create an expression of code
  99. <code>const_int</code> and value zero, one, two or negative one will return
  100. <code>const0_rtx</code>, <code>const1_rtx</code>, <code>const2_rtx</code> or
  101. <code>constm1_rtx</code> as appropriate.
  102. </p>
  103. <a name="index-const_005ftrue_005frtx"></a>
  104. <p>Similarly, there is only one object for the integer whose value is
  105. <code>STORE_FLAG_VALUE</code>. It is found in <code>const_true_rtx</code>. If
  106. <code>STORE_FLAG_VALUE</code> is one, <code>const_true_rtx</code> and
  107. <code>const1_rtx</code> will point to the same object. If
  108. <code>STORE_FLAG_VALUE</code> is -1, <code>const_true_rtx</code> and
  109. <code>constm1_rtx</code> will point to the same object.
  110. </p>
  111. <a name="index-const_005fdouble"></a>
  112. </dd>
  113. <dt><code>(const_double:<var>m</var> <var>i0</var> <var>i1</var> &hellip;)</code></dt>
  114. <dd><p>This represents either a floating-point constant of mode <var>m</var> or
  115. (on older ports that do not define
  116. <code>TARGET_SUPPORTS_WIDE_INT</code>) an integer constant too large to fit
  117. into <code>HOST_BITS_PER_WIDE_INT</code> bits but small enough to fit within
  118. twice that number of bits. In the latter case, <var>m</var> will be
  119. <code>VOIDmode</code>. For integral values constants for modes with more
  120. bits than twice the number in <code>HOST_WIDE_INT</code> the implied high
  121. order bits of that constant are copies of the top bit of
  122. <code>CONST_DOUBLE_HIGH</code>. Note however that integral values are
  123. neither inherently signed nor inherently unsigned; where necessary,
  124. signedness is determined by the rtl operation instead.
  125. </p>
  126. <p>On more modern ports, <code>CONST_DOUBLE</code> only represents floating
  127. point values. New ports define <code>TARGET_SUPPORTS_WIDE_INT</code> to
  128. make this designation.
  129. </p>
  130. <a name="index-CONST_005fDOUBLE_005fLOW"></a>
  131. <p>If <var>m</var> is <code>VOIDmode</code>, the bits of the value are stored in
  132. <var>i0</var> and <var>i1</var>. <var>i0</var> is customarily accessed with the macro
  133. <code>CONST_DOUBLE_LOW</code> and <var>i1</var> with <code>CONST_DOUBLE_HIGH</code>.
  134. </p>
  135. <p>If the constant is floating point (regardless of its precision), then
  136. the number of integers used to store the value depends on the size of
  137. <code>REAL_VALUE_TYPE</code> (see <a href="Floating-Point.html#Floating-Point">Floating Point</a>). The integers
  138. represent a floating point number, but not precisely in the target
  139. machine&rsquo;s or host machine&rsquo;s floating point format. To convert them to
  140. the precise bit pattern used by the target machine, use the macro
  141. <code>REAL_VALUE_TO_TARGET_DOUBLE</code> and friends (see <a href="Data-Output.html#Data-Output">Data Output</a>).
  142. </p>
  143. <a name="index-CONST_005fWIDE_005fINT"></a>
  144. </dd>
  145. <dt><code>(const_wide_int:<var>m</var> <var>nunits</var> <var>elt0</var> &hellip;)</code></dt>
  146. <dd><p>This contains an array of <code>HOST_WIDE_INT</code>s that is large enough
  147. to hold any constant that can be represented on the target. This form
  148. of rtl is only used on targets that define
  149. <code>TARGET_SUPPORTS_WIDE_INT</code> to be nonzero and then
  150. <code>CONST_DOUBLE</code>s are only used to hold floating-point values. If
  151. the target leaves <code>TARGET_SUPPORTS_WIDE_INT</code> defined as 0,
  152. <code>CONST_WIDE_INT</code>s are not used and <code>CONST_DOUBLE</code>s are as
  153. they were before.
  154. </p>
  155. <p>The values are stored in a compressed format. The higher-order
  156. 0s or -1s are not represented if they are just the logical sign
  157. extension of the number that is represented.
  158. </p>
  159. <a name="index-CONST_005fWIDE_005fINT_005fVEC"></a>
  160. </dd>
  161. <dt><code>CONST_WIDE_INT_VEC (<var>code</var>)</code></dt>
  162. <dd><p>Returns the entire array of <code>HOST_WIDE_INT</code>s that are used to
  163. store the value. This macro should be rarely used.
  164. </p>
  165. <a name="index-CONST_005fWIDE_005fINT_005fNUNITS"></a>
  166. </dd>
  167. <dt><code>CONST_WIDE_INT_NUNITS (<var>code</var>)</code></dt>
  168. <dd><p>The number of <code>HOST_WIDE_INT</code>s used to represent the number.
  169. Note that this generally is smaller than the number of
  170. <code>HOST_WIDE_INT</code>s implied by the mode size.
  171. </p>
  172. <a name="index-CONST_005fWIDE_005fINT_005fELT"></a>
  173. </dd>
  174. <dt><code>CONST_WIDE_INT_ELT (<var>code</var>,<var>i</var>)</code></dt>
  175. <dd><p>Returns the <code>i</code>th element of the array. Element 0 is contains
  176. the low order bits of the constant.
  177. </p>
  178. <a name="index-const_005ffixed"></a>
  179. </dd>
  180. <dt><code>(const_fixed:<var>m</var> &hellip;)</code></dt>
  181. <dd><p>Represents a fixed-point constant of mode <var>m</var>.
  182. The operand is a data structure of type <code>struct fixed_value</code> and
  183. is accessed with the macro <code>CONST_FIXED_VALUE</code>. The high part of
  184. data is accessed with <code>CONST_FIXED_VALUE_HIGH</code>; the low part is
  185. accessed with <code>CONST_FIXED_VALUE_LOW</code>.
  186. </p>
  187. <a name="index-const_005fpoly_005fint"></a>
  188. </dd>
  189. <dt><code>(const_poly_int:<var>m</var> [<var>c0</var> <var>c1</var> &hellip;])</code></dt>
  190. <dd><p>Represents a <code>poly_int</code>-style polynomial integer with coefficients
  191. <var>c0</var>, <var>c1</var>, &hellip;. The coefficients are <code>wide_int</code>-based
  192. integers rather than rtxes. <code>CONST_POLY_INT_COEFFS</code> gives the
  193. values of individual coefficients (which is mostly only useful in
  194. low-level routines) and <code>const_poly_int_value</code> gives the full
  195. <code>poly_int</code> value.
  196. </p>
  197. <a name="index-const_005fvector"></a>
  198. </dd>
  199. <dt><code>(const_vector:<var>m</var> [<var>x0</var> <var>x1</var> &hellip;])</code></dt>
  200. <dd><p>Represents a vector constant. The values in square brackets are
  201. elements of the vector, which are always <code>const_int</code>,
  202. <code>const_wide_int</code>, <code>const_double</code> or <code>const_fixed</code>
  203. expressions.
  204. </p>
  205. <p>Each vector constant <var>v</var> is treated as a specific instance of an
  206. arbitrary-length sequence that itself contains
  207. &lsquo;<samp>CONST_VECTOR_NPATTERNS (<var>v</var>)</samp>&rsquo; interleaved patterns. Each
  208. pattern has the form:
  209. </p>
  210. <div class="smallexample">
  211. <pre class="smallexample">{ <var>base0</var>, <var>base1</var>, <var>base1</var> + <var>step</var>, <var>base1</var> + <var>step</var> * 2, &hellip; }
  212. </pre></div>
  213. <p>The first three elements in each pattern are enough to determine the
  214. values of the other elements. However, if all <var>step</var>s are zero,
  215. only the first two elements are needed. If in addition each <var>base1</var>
  216. is equal to the corresponding <var>base0</var>, only the first element in
  217. each pattern is needed. The number of determining elements per pattern
  218. is given by &lsquo;<samp>CONST_VECTOR_NELTS_PER_PATTERN (<var>v</var>)</samp>&rsquo;.
  219. </p>
  220. <p>For example, the constant:
  221. </p>
  222. <div class="smallexample">
  223. <pre class="smallexample">{ 0, 1, 2, 6, 3, 8, 4, 10, 5, 12, 6, 14, 7, 16, 8, 18 }
  224. </pre></div>
  225. <p>is interpreted as an interleaving of the sequences:
  226. </p>
  227. <div class="smallexample">
  228. <pre class="smallexample">{ 0, 2, 3, 4, 5, 6, 7, 8 }
  229. { 1, 6, 8, 10, 12, 14, 16, 18 }
  230. </pre></div>
  231. <p>where the sequences are represented by the following patterns:
  232. </p>
  233. <div class="smallexample">
  234. <pre class="smallexample"><var>base0</var> == 0, <var>base1</var> == 2, <var>step</var> == 1
  235. <var>base0</var> == 1, <var>base1</var> == 6, <var>step</var> == 2
  236. </pre></div>
  237. <p>In this case:
  238. </p>
  239. <div class="smallexample">
  240. <pre class="smallexample">CONST_VECTOR_NPATTERNS (<var>v</var>) == 2
  241. CONST_VECTOR_NELTS_PER_PATTERN (<var>v</var>) == 3
  242. </pre></div>
  243. <p>Thus the first 6 elements (&lsquo;<samp>{ 0, 1, 2, 6, 3, 8 }</samp>&rsquo;) are enough
  244. to determine the whole sequence; we refer to them as the &ldquo;encoded&rdquo;
  245. elements. They are the only elements present in the square brackets
  246. for variable-length <code>const_vector</code>s (i.e. for
  247. <code>const_vector</code>s whose mode <var>m</var> has a variable number of
  248. elements). However, as a convenience to code that needs to handle
  249. both <code>const_vector</code>s and <code>parallel</code>s, all elements are
  250. present in the square brackets for fixed-length <code>const_vector</code>s;
  251. the encoding scheme simply reduces the amount of work involved in
  252. processing constants that follow a regular pattern.
  253. </p>
  254. <p>Sometimes this scheme can create two possible encodings of the same
  255. vector. For example { 0, 1 } could be seen as two patterns with
  256. one element each or one pattern with two elements (<var>base0</var> and
  257. <var>base1</var>). The canonical encoding is always the one with the
  258. fewest patterns or (if both encodings have the same number of
  259. petterns) the one with the fewest encoded elements.
  260. </p>
  261. <p>&lsquo;<samp>const_vector_encoding_nelts (<var>v</var>)</samp>&rsquo; gives the total number of
  262. encoded elements in <var>v</var>, which is 6 in the example above.
  263. <code>CONST_VECTOR_ENCODED_ELT (<var>v</var>, <var>i</var>)</code> accesses the value
  264. of encoded element <var>i</var>.
  265. </p>
  266. <p>&lsquo;<samp>CONST_VECTOR_DUPLICATE_P (<var>v</var>)</samp>&rsquo; is true if <var>v</var> simply contains
  267. repeated instances of &lsquo;<samp>CONST_VECTOR_NPATTERNS (<var>v</var>)</samp>&rsquo; values. This is
  268. a shorthand for testing &lsquo;<samp>CONST_VECTOR_NELTS_PER_PATTERN (<var>v</var>) == 1</samp>&rsquo;.
  269. </p>
  270. <p>&lsquo;<samp>CONST_VECTOR_STEPPED_P (<var>v</var>)</samp>&rsquo; is true if at least one
  271. pattern in <var>v</var> has a nonzero step. This is a shorthand for
  272. testing &lsquo;<samp>CONST_VECTOR_NELTS_PER_PATTERN (<var>v</var>) == 3</samp>&rsquo;.
  273. </p>
  274. <p><code>CONST_VECTOR_NUNITS (<var>v</var>)</code> gives the total number of elements
  275. in <var>v</var>; it is a shorthand for getting the number of units in
  276. &lsquo;<samp>GET_MODE (<var>v</var>)</samp>&rsquo;.
  277. </p>
  278. <p>The utility function <code>const_vector_elt</code> gives the value of an
  279. arbitrary element as an <code>rtx</code>. <code>const_vector_int_elt</code> gives
  280. the same value as a <code>wide_int</code>.
  281. </p>
  282. <a name="index-const_005fstring"></a>
  283. </dd>
  284. <dt><code>(const_string <var>str</var>)</code></dt>
  285. <dd><p>Represents a constant string with value <var>str</var>. Currently this is
  286. used only for insn attributes (see <a href="Insn-Attributes.html#Insn-Attributes">Insn Attributes</a>) since constant
  287. strings in C are placed in memory.
  288. </p>
  289. <a name="index-symbol_005fref"></a>
  290. </dd>
  291. <dt><code>(symbol_ref:<var>mode</var> <var>symbol</var>)</code></dt>
  292. <dd><p>Represents the value of an assembler label for data. <var>symbol</var> is
  293. a string that describes the name of the assembler label. If it starts
  294. with a &lsquo;<samp>*</samp>&rsquo;, the label is the rest of <var>symbol</var> not including
  295. the &lsquo;<samp>*</samp>&rsquo;. Otherwise, the label is <var>symbol</var>, usually prefixed
  296. with &lsquo;<samp>_</samp>&rsquo;.
  297. </p>
  298. <p>The <code>symbol_ref</code> contains a mode, which is usually <code>Pmode</code>.
  299. Usually that is the only mode for which a symbol is directly valid.
  300. </p>
  301. <a name="index-label_005fref"></a>
  302. </dd>
  303. <dt><code>(label_ref:<var>mode</var> <var>label</var>)</code></dt>
  304. <dd><p>Represents the value of an assembler label for code. It contains one
  305. operand, an expression, which must be a <code>code_label</code> or a <code>note</code>
  306. of type <code>NOTE_INSN_DELETED_LABEL</code> that appears in the instruction
  307. sequence to identify the place where the label should go.
  308. </p>
  309. <p>The reason for using a distinct expression type for code label
  310. references is so that jump optimization can distinguish them.
  311. </p>
  312. <p>The <code>label_ref</code> contains a mode, which is usually <code>Pmode</code>.
  313. Usually that is the only mode for which a label is directly valid.
  314. </p>
  315. <a name="index-const"></a>
  316. </dd>
  317. <dt><code>(const:<var>m</var> <var>exp</var>)</code></dt>
  318. <dd><p>Represents a constant that is the result of an assembly-time
  319. arithmetic computation. The operand, <var>exp</var>, contains only
  320. <code>const_int</code>, <code>symbol_ref</code>, <code>label_ref</code> or <code>unspec</code>
  321. expressions, combined with <code>plus</code> and <code>minus</code>. Any such
  322. <code>unspec</code>s are target-specific and typically represent some form
  323. of relocation operator. <var>m</var> should be a valid address mode.
  324. </p>
  325. <a name="index-high"></a>
  326. </dd>
  327. <dt><code>(high:<var>m</var> <var>exp</var>)</code></dt>
  328. <dd><p>Represents the high-order bits of <var>exp</var>.
  329. The number of bits is machine-dependent and is
  330. normally the number of bits specified in an instruction that initializes
  331. the high order bits of a register. It is used with <code>lo_sum</code> to
  332. represent the typical two-instruction sequence used in RISC machines to
  333. reference large immediate values and/or link-time constants such
  334. as global memory addresses. In the latter case, <var>m</var> is <code>Pmode</code>
  335. and <var>exp</var> is usually a constant expression involving <code>symbol_ref</code>.
  336. </p></dd>
  337. </dl>
  338. <a name="index-CONST0_005fRTX"></a>
  339. <a name="index-CONST1_005fRTX"></a>
  340. <a name="index-CONST2_005fRTX"></a>
  341. <p>The macro <code>CONST0_RTX (<var>mode</var>)</code> refers to an expression with
  342. value 0 in mode <var>mode</var>. If mode <var>mode</var> is of mode class
  343. <code>MODE_INT</code>, it returns <code>const0_rtx</code>. If mode <var>mode</var> is of
  344. mode class <code>MODE_FLOAT</code>, it returns a <code>CONST_DOUBLE</code>
  345. expression in mode <var>mode</var>. Otherwise, it returns a
  346. <code>CONST_VECTOR</code> expression in mode <var>mode</var>. Similarly, the macro
  347. <code>CONST1_RTX (<var>mode</var>)</code> refers to an expression with value 1 in
  348. mode <var>mode</var> and similarly for <code>CONST2_RTX</code>. The
  349. <code>CONST1_RTX</code> and <code>CONST2_RTX</code> macros are undefined
  350. for vector modes.
  351. </p>
  352. <hr>
  353. <div class="header">
  354. <p>
  355. 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>
  356. </div>
  357. </body>
  358. </html>