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.

180 lines
8.7KB

  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>Alignment of poly_ints (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Alignment of poly_ints (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Alignment of poly_ints (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="Computing-bounds-on-poly_005fints.html#Computing-bounds-on-poly_005fints" rel="next" title="Computing bounds on poly_ints">
  31. <link href="Other-poly_005fint-arithmetic.html#Other-poly_005fint-arithmetic" rel="prev" title="Other poly_int arithmetic">
  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="Alignment-of-poly_005fints"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Computing-bounds-on-poly_005fints.html#Computing-bounds-on-poly_005fints" accesskey="n" rel="next">Computing bounds on <code>poly_int</code>s</a>, Previous: <a href="Arithmetic-on-poly_005fints.html#Arithmetic-on-poly_005fints" accesskey="p" rel="prev">Arithmetic on <code>poly_int</code>s</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="Alignment-of-poly_005fints-1"></a>
  68. <h3 class="section">10.5 Alignment of <code>poly_int</code>s</h3>
  69. <p><code>poly_int</code> provides various routines for aligning values and for querying
  70. misalignments. In each case the alignment must be a power of 2.
  71. </p>
  72. <dl compact="compact">
  73. <dt>&lsquo;<samp>can_align_p (<var>value</var>, <var>align</var>)</samp>&rsquo;</dt>
  74. <dd><p>Return true if we can align <var>value</var> up or down to the nearest multiple
  75. of <var>align</var> at compile time. The answer is the same for both directions.
  76. </p>
  77. </dd>
  78. <dt>&lsquo;<samp>can_align_down (<var>value</var>, <var>align</var>, &amp;<var>aligned</var>)</samp>&rsquo;</dt>
  79. <dd><p>Return true if <code>can_align_p</code>; if so, set <var>aligned</var> to the greatest
  80. aligned value that is less than or equal to <var>value</var>.
  81. </p>
  82. </dd>
  83. <dt>&lsquo;<samp>can_align_up (<var>value</var>, <var>align</var>, &amp;<var>aligned</var>)</samp>&rsquo;</dt>
  84. <dd><p>Return true if <code>can_align_p</code>; if so, set <var>aligned</var> to the lowest
  85. aligned value that is greater than or equal to <var>value</var>.
  86. </p>
  87. </dd>
  88. <dt>&lsquo;<samp>known_equal_after_align_down (<var>a</var>, <var>b</var>, <var>align</var>)</samp>&rsquo;</dt>
  89. <dd><p>Return true if we can align <var>a</var> and <var>b</var> down to the nearest
  90. <var>align</var> boundary at compile time and if the two results are equal.
  91. </p>
  92. </dd>
  93. <dt>&lsquo;<samp>known_equal_after_align_up (<var>a</var>, <var>b</var>, <var>align</var>)</samp>&rsquo;</dt>
  94. <dd><p>Return true if we can align <var>a</var> and <var>b</var> up to the nearest
  95. <var>align</var> boundary at compile time and if the two results are equal.
  96. </p>
  97. </dd>
  98. <dt>&lsquo;<samp>aligned_lower_bound (<var>value</var>, <var>align</var>)</samp>&rsquo;</dt>
  99. <dd><p>Return a result that is no greater than <var>value</var> and that is aligned
  100. to <var>align</var>. The result will the closest aligned value for some
  101. indeterminate values but not necessarily for all.
  102. </p>
  103. <p>For example, suppose we are allocating an object of <var>size</var> bytes
  104. in a downward-growing stack whose current limit is given by <var>limit</var>.
  105. If the object requires <var>align</var> bytes of alignment, the new stack
  106. limit is given by:
  107. </p>
  108. <div class="smallexample">
  109. <pre class="smallexample">aligned_lower_bound (<var>limit</var> - <var>size</var>, <var>align</var>)
  110. </pre></div>
  111. </dd>
  112. <dt>&lsquo;<samp>aligned_upper_bound (<var>value</var>, <var>align</var>)</samp>&rsquo;</dt>
  113. <dd><p>Likewise return a result that is no less than <var>value</var> and that is
  114. aligned to <var>align</var>. This is the routine that would be used for
  115. upward-growing stacks in the scenario just described.
  116. </p>
  117. </dd>
  118. <dt>&lsquo;<samp>known_misalignment (<var>value</var>, <var>align</var>, &amp;<var>misalign</var>)</samp>&rsquo;</dt>
  119. <dd><p>Return true if we can calculate the misalignment of <var>value</var>
  120. with respect to <var>align</var> at compile time, storing the result in
  121. <var>misalign</var> if so.
  122. </p>
  123. </dd>
  124. <dt>&lsquo;<samp>known_alignment (<var>value</var>)</samp>&rsquo;</dt>
  125. <dd><p>Return the minimum alignment that <var>value</var> is known to have
  126. (in other words, the largest alignment that can be guaranteed
  127. whatever the values of the indeterminates turn out to be).
  128. Return 0 if <var>value</var> is known to be 0.
  129. </p>
  130. </dd>
  131. <dt>&lsquo;<samp>force_align_down (<var>value</var>, <var>align</var>)</samp>&rsquo;</dt>
  132. <dd><p>Assert that <var>value</var> can be aligned down to <var>align</var> at compile
  133. time and return the result. When using this routine, please add a
  134. comment explaining why the assertion is known to hold.
  135. </p>
  136. </dd>
  137. <dt>&lsquo;<samp>force_align_up (<var>value</var>, <var>align</var>)</samp>&rsquo;</dt>
  138. <dd><p>Likewise, but aligning up.
  139. </p>
  140. </dd>
  141. <dt>&lsquo;<samp>force_align_down_and_div (<var>value</var>, <var>align</var>)</samp>&rsquo;</dt>
  142. <dd><p>Divide the result of <code>force_align_down</code> by <var>align</var>. Again,
  143. please add a comment explaining why the assertion in <code>force_align_down</code>
  144. is known to hold.
  145. </p>
  146. </dd>
  147. <dt>&lsquo;<samp>force_align_up_and_div (<var>value</var>, <var>align</var>)</samp>&rsquo;</dt>
  148. <dd><p>Likewise for <code>force_align_up</code>.
  149. </p>
  150. </dd>
  151. <dt>&lsquo;<samp>force_get_misalignment (<var>value</var>, <var>align</var>)</samp>&rsquo;</dt>
  152. <dd><p>Assert that we can calculate the misalignment of <var>value</var> with
  153. respect to <var>align</var> at compile time and return the misalignment.
  154. When using this function, please add a comment explaining why
  155. the assertion is known to hold.
  156. </p></dd>
  157. </dl>
  158. <hr>
  159. <div class="header">
  160. <p>
  161. Next: <a href="Computing-bounds-on-poly_005fints.html#Computing-bounds-on-poly_005fints" accesskey="n" rel="next">Computing bounds on <code>poly_int</code>s</a>, Previous: <a href="Arithmetic-on-poly_005fints.html#Arithmetic-on-poly_005fints" accesskey="p" rel="prev">Arithmetic on <code>poly_int</code>s</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>
  162. </div>
  163. </body>
  164. </html>