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.

160 lines
7.4KB

  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>Anchored Addresses (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Anchored Addresses (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Anchored Addresses (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="Target-Macros.html#Target-Macros" rel="up" title="Target Macros">
  30. <link href="Condition-Code.html#Condition-Code" rel="next" title="Condition Code">
  31. <link href="Addressing-Modes.html#Addressing-Modes" rel="prev" title="Addressing 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="Anchored-Addresses"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Condition-Code.html#Condition-Code" accesskey="n" rel="next">Condition Code</a>, Previous: <a href="Addressing-Modes.html#Addressing-Modes" accesskey="p" rel="prev">Addressing Modes</a>, Up: <a href="Target-Macros.html#Target-Macros" accesskey="u" rel="up">Target Macros</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="Anchored-Addresses-1"></a>
  68. <h3 class="section">18.14 Anchored Addresses</h3>
  69. <a name="index-anchored-addresses"></a>
  70. <a name="index-_002dfsection_002danchors-1"></a>
  71. <p>GCC usually addresses every static object as a separate entity.
  72. For example, if we have:
  73. </p>
  74. <div class="smallexample">
  75. <pre class="smallexample">static int a, b, c;
  76. int foo (void) { return a + b + c; }
  77. </pre></div>
  78. <p>the code for <code>foo</code> will usually calculate three separate symbolic
  79. addresses: those of <code>a</code>, <code>b</code> and <code>c</code>. On some targets,
  80. it would be better to calculate just one symbolic address and access
  81. the three variables relative to it. The equivalent pseudocode would
  82. be something like:
  83. </p>
  84. <div class="smallexample">
  85. <pre class="smallexample">int foo (void)
  86. {
  87. register int *xr = &amp;x;
  88. return xr[&amp;a - &amp;x] + xr[&amp;b - &amp;x] + xr[&amp;c - &amp;x];
  89. }
  90. </pre></div>
  91. <p>(which isn&rsquo;t valid C). We refer to shared addresses like <code>x</code> as
  92. &ldquo;section anchors&rdquo;. Their use is controlled by <samp>-fsection-anchors</samp>.
  93. </p>
  94. <p>The hooks below describe the target properties that GCC needs to know
  95. in order to make effective use of section anchors. It won&rsquo;t use
  96. section anchors at all unless either <code>TARGET_MIN_ANCHOR_OFFSET</code>
  97. or <code>TARGET_MAX_ANCHOR_OFFSET</code> is set to a nonzero value.
  98. </p>
  99. <dl>
  100. <dt><a name="index-TARGET_005fMIN_005fANCHOR_005fOFFSET"></a>Target Hook: <em>HOST_WIDE_INT</em> <strong>TARGET_MIN_ANCHOR_OFFSET</strong></dt>
  101. <dd><p>The minimum offset that should be applied to a section anchor.
  102. On most targets, it should be the smallest offset that can be
  103. applied to a base register while still giving a legitimate address
  104. for every mode. The default value is 0.
  105. </p></dd></dl>
  106. <dl>
  107. <dt><a name="index-TARGET_005fMAX_005fANCHOR_005fOFFSET"></a>Target Hook: <em>HOST_WIDE_INT</em> <strong>TARGET_MAX_ANCHOR_OFFSET</strong></dt>
  108. <dd><p>Like <code>TARGET_MIN_ANCHOR_OFFSET</code>, but the maximum (inclusive)
  109. offset that should be applied to section anchors. The default
  110. value is 0.
  111. </p></dd></dl>
  112. <dl>
  113. <dt><a name="index-TARGET_005fASM_005fOUTPUT_005fANCHOR"></a>Target Hook: <em>void</em> <strong>TARGET_ASM_OUTPUT_ANCHOR</strong> <em>(rtx <var>x</var>)</em></dt>
  114. <dd><p>Write the assembly code to define section anchor <var>x</var>, which is a
  115. <code>SYMBOL_REF</code> for which &lsquo;<samp>SYMBOL_REF_ANCHOR_P (<var>x</var>)</samp>&rsquo; is true.
  116. The hook is called with the assembly output position set to the beginning
  117. of <code>SYMBOL_REF_BLOCK (<var>x</var>)</code>.
  118. </p>
  119. <p>If <code>ASM_OUTPUT_DEF</code> is available, the hook&rsquo;s default definition uses
  120. it to define the symbol as &lsquo;<samp>. + SYMBOL_REF_BLOCK_OFFSET (<var>x</var>)</samp>&rsquo;.
  121. If <code>ASM_OUTPUT_DEF</code> is not available, the hook&rsquo;s default definition
  122. is <code>NULL</code>, which disables the use of section anchors altogether.
  123. </p></dd></dl>
  124. <dl>
  125. <dt><a name="index-TARGET_005fUSE_005fANCHORS_005fFOR_005fSYMBOL_005fP"></a>Target Hook: <em>bool</em> <strong>TARGET_USE_ANCHORS_FOR_SYMBOL_P</strong> <em>(const_rtx <var>x</var>)</em></dt>
  126. <dd><p>Return true if GCC should attempt to use anchors to access <code>SYMBOL_REF</code>
  127. <var>x</var>. You can assume &lsquo;<samp>SYMBOL_REF_HAS_BLOCK_INFO_P (<var>x</var>)</samp>&rsquo; and
  128. &lsquo;<samp>!SYMBOL_REF_ANCHOR_P (<var>x</var>)</samp>&rsquo;.
  129. </p>
  130. <p>The default version is correct for most targets, but you might need to
  131. intercept this hook to handle things like target-specific attributes
  132. or target-specific sections.
  133. </p></dd></dl>
  134. <hr>
  135. <div class="header">
  136. <p>
  137. Next: <a href="Condition-Code.html#Condition-Code" accesskey="n" rel="next">Condition Code</a>, Previous: <a href="Addressing-Modes.html#Addressing-Modes" accesskey="p" rel="prev">Addressing Modes</a>, Up: <a href="Target-Macros.html#Target-Macros" accesskey="u" rel="up">Target Macros</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>
  138. </div>
  139. </body>
  140. </html>