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.

165 lines
7.5KB

  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>Overview of poly_int (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Overview of poly_int (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Overview of poly_int (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="poly_005fint.html#poly_005fint" rel="up" title="poly_int">
  30. <link href="Consequences-of-using-poly_005fint.html#Consequences-of-using-poly_005fint" rel="next" title="Consequences of using poly_int">
  31. <link href="poly_005fint.html#poly_005fint" rel="prev" title="poly_int">
  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="Overview-of-poly_005fint"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Consequences-of-using-poly_005fint.html#Consequences-of-using-poly_005fint" accesskey="n" rel="next">Consequences of using <code>poly_int</code></a>, Up: <a href="poly_005fint.html#poly_005fint" accesskey="u" rel="up">poly_int</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="Overview-of-poly_005fint-1"></a>
  68. <h3 class="section">10.1 Overview of <code>poly_int</code></h3>
  69. <a name="index-poly_005fint_002c-runtime-value"></a>
  70. <p>We define indeterminates <var>x1</var>, &hellip;, <var>xn</var> whose values are
  71. only known at runtime and use polynomials of the form:
  72. </p>
  73. <div class="smallexample">
  74. <pre class="smallexample"><var>c0</var> + <var>c1</var> * <var>x1</var> + &hellip; + <var>cn</var> * <var>xn</var>
  75. </pre></div>
  76. <p>to represent a size or offset whose value might depend on some
  77. of these indeterminates. The coefficients <var>c0</var>, &hellip;, <var>cn</var>
  78. are always known at compile time, with the <var>c0</var> term being the
  79. &ldquo;constant&rdquo; part that does not depend on any runtime value.
  80. </p>
  81. <p>GCC uses the <code>poly_int</code> class to represent these coefficients.
  82. The class has two template parameters: the first specifies the number of
  83. coefficients (<var>n</var> + 1) and the second specifies the type of the
  84. coefficients. For example, &lsquo;<samp>poly_int&lt;2, unsigned short&gt;</samp>&rsquo; represents
  85. a polynomial with two coefficients (and thus one indeterminate), with each
  86. coefficient having type <code>unsigned short</code>. When <var>n</var> is 0,
  87. the class degenerates to a single compile-time constant <var>c0</var>.
  88. </p>
  89. <a name="index-poly_005fint_002c-template-parameters"></a>
  90. <a name="index-NUM_005fPOLY_005fINT_005fCOEFFS"></a>
  91. <p>The number of coefficients needed for compilation is a fixed
  92. property of each target and is specified by the configuration macro
  93. <code>NUM_POLY_INT_COEFFS</code>. The default value is 1, since most targets
  94. do not have such runtime invariants. Targets that need a different
  95. value should <code>#define</code> the macro in their <samp><var>cpu</var>-modes.def</samp>
  96. file. See <a href="Back-End.html#Back-End">Back End</a>.
  97. </p>
  98. <a name="index-poly_005fint_002c-invariant-range"></a>
  99. <p><code>poly_int</code> makes the simplifying requirement that each indeterminate
  100. must be a nonnegative integer. An indeterminate value of 0 should usually
  101. represent the minimum possible runtime value, with <var>c0</var> specifying
  102. the value in that case.
  103. </p>
  104. <p>For example, when targetting the Arm SVE ISA, the single indeterminate
  105. represents the number of 128-bit blocks in a vector <em>beyond the minimum
  106. length of 128 bits</em>. Thus the number of 64-bit doublewords in a vector
  107. is 2 + 2 * <var>x1</var>. If an aggregate has a single SVE vector and 16
  108. additional bytes, its total size is 32 + 16 * <var>x1</var> bytes.
  109. </p>
  110. <p>The header file <samp>poly-int-types.h</samp> provides typedefs for the
  111. most common forms of <code>poly_int</code>, all having
  112. <code>NUM_POLY_INT_COEFFS</code> coefficients:
  113. </p>
  114. <a name="index-poly_005fint_002c-main-typedefs"></a>
  115. <dl compact="compact">
  116. <dt><code>poly_uint16</code></dt>
  117. <dd><p>a &lsquo;<samp>poly_int</samp>&rsquo; with <code>unsigned short</code> coefficients.
  118. </p>
  119. </dd>
  120. <dt><code>poly_int64</code></dt>
  121. <dd><p>a &lsquo;<samp>poly_int</samp>&rsquo; with <code>HOST_WIDE_INT</code> coefficients.
  122. </p>
  123. </dd>
  124. <dt><code>poly_uint64</code></dt>
  125. <dd><p>a &lsquo;<samp>poly_int</samp>&rsquo; with <code>unsigned HOST_WIDE_INT</code> coefficients.
  126. </p>
  127. </dd>
  128. <dt><code>poly_offset_int</code></dt>
  129. <dd><p>a &lsquo;<samp>poly_int</samp>&rsquo; with <code>offset_int</code> coefficients.
  130. </p>
  131. </dd>
  132. <dt><code>poly_wide_int</code></dt>
  133. <dd><p>a &lsquo;<samp>poly_int</samp>&rsquo; with <code>wide_int</code> coefficients.
  134. </p>
  135. </dd>
  136. <dt><code>poly_widest_int</code></dt>
  137. <dd><p>a &lsquo;<samp>poly_int</samp>&rsquo; with <code>widest_int</code> coefficients.
  138. </p></dd>
  139. </dl>
  140. <p>Since the main purpose of <code>poly_int</code> is to represent sizes and
  141. offsets, the last two typedefs are only rarely used.
  142. </p>
  143. <hr>
  144. <div class="header">
  145. <p>
  146. Next: <a href="Consequences-of-using-poly_005fint.html#Consequences-of-using-poly_005fint" accesskey="n" rel="next">Consequences of using <code>poly_int</code></a>, Up: <a href="poly_005fint.html#poly_005fint" accesskey="u" rel="up">poly_int</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>
  147. </div>
  148. </body>
  149. </html>