Named-Address-Spaces.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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: Named Address Spaces</title>
  20. <meta name="description" content="GNU Compiler Collection (GCC) Internals: Named Address Spaces">
  21. <meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Named Address Spaces">
  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="Target-Macros.html#Target-Macros" rel="up" title="Target Macros">
  30. <link href="Misc.html#Misc" rel="next" title="Misc">
  31. <link href="C_002b_002b-ABI.html#C_002b_002b-ABI" rel="prev" title="C++ ABI">
  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="Named-Address-Spaces"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="Misc.html#Misc" accesskey="n" rel="next">Misc</a>, Previous: <a href="C_002b_002b-ABI.html#C_002b_002b-ABI" accesskey="p" rel="prev">C++ ABI</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>
  66. </div>
  67. <hr>
  68. <a name="Adding-support-for-named-address-spaces"></a>
  69. <h3 class="section">17.29 Adding support for named address spaces</h3>
  70. <a name="index-named-address-spaces"></a>
  71. <p>The draft technical report of the ISO/IEC JTC1 S22 WG14 N1275
  72. standards committee, <cite>Programming Languages - C - Extensions to
  73. support embedded processors</cite>, specifies a syntax for embedded
  74. processors to specify alternate address spaces. You can configure a
  75. GCC port to support section 5.1 of the draft report to add support for
  76. address spaces other than the default address space. These address
  77. spaces are new keywords that are similar to the <code>volatile</code> and
  78. <code>const</code> type attributes.
  79. </p>
  80. <p>Pointers to named address spaces can have a different size than
  81. pointers to the generic address space.
  82. </p>
  83. <p>For example, the SPU port uses the <code>__ea</code> address space to refer
  84. to memory in the host processor, rather than memory local to the SPU
  85. processor. Access to memory in the <code>__ea</code> address space involves
  86. issuing DMA operations to move data between the host processor and the
  87. local processor memory address space. Pointers in the <code>__ea</code>
  88. address space are either 32 bits or 64 bits based on the
  89. <samp>-mea32</samp> or <samp>-mea64</samp> switches (native SPU pointers are
  90. always 32 bits).
  91. </p>
  92. <p>Internally, address spaces are represented as a small integer in the
  93. range 0 to 15 with address space 0 being reserved for the generic
  94. address space.
  95. </p>
  96. <p>To register a named address space qualifier keyword with the C front end,
  97. the target may call the <code>c_register_addr_space</code> routine. For example,
  98. the SPU port uses the following to declare <code>__ea</code> as the keyword for
  99. named address space #1:
  100. </p><div class="smallexample">
  101. <pre class="smallexample">#define ADDR_SPACE_EA 1
  102. c_register_addr_space (&quot;__ea&quot;, ADDR_SPACE_EA);
  103. </pre></div>
  104. <dl>
  105. <dt><a name="index-TARGET_005fADDR_005fSPACE_005fPOINTER_005fMODE"></a>Target Hook: <em>machine_mode</em> <strong>TARGET_ADDR_SPACE_POINTER_MODE</strong> <em>(addr_space_t <var>address_space</var>)</em></dt>
  106. <dd><p>Define this to return the machine mode to use for pointers to
  107. <var>address_space</var> if the target supports named address spaces.
  108. The default version of this hook returns <code>ptr_mode</code>.
  109. </p></dd></dl>
  110. <dl>
  111. <dt><a name="index-TARGET_005fADDR_005fSPACE_005fADDRESS_005fMODE"></a>Target Hook: <em>machine_mode</em> <strong>TARGET_ADDR_SPACE_ADDRESS_MODE</strong> <em>(addr_space_t <var>address_space</var>)</em></dt>
  112. <dd><p>Define this to return the machine mode to use for addresses in
  113. <var>address_space</var> if the target supports named address spaces.
  114. The default version of this hook returns <code>Pmode</code>.
  115. </p></dd></dl>
  116. <dl>
  117. <dt><a name="index-TARGET_005fADDR_005fSPACE_005fVALID_005fPOINTER_005fMODE"></a>Target Hook: <em>bool</em> <strong>TARGET_ADDR_SPACE_VALID_POINTER_MODE</strong> <em>(machine_mode <var>mode</var>, addr_space_t <var>as</var>)</em></dt>
  118. <dd><p>Define this to return nonzero if the port can handle pointers
  119. with machine mode <var>mode</var> to address space <var>as</var>. This target
  120. hook is the same as the <code>TARGET_VALID_POINTER_MODE</code> target hook,
  121. except that it includes explicit named address space support. The default
  122. version of this hook returns true for the modes returned by either the
  123. <code>TARGET_ADDR_SPACE_POINTER_MODE</code> or <code>TARGET_ADDR_SPACE_ADDRESS_MODE</code>
  124. target hooks for the given address space.
  125. </p></dd></dl>
  126. <dl>
  127. <dt><a name="index-TARGET_005fADDR_005fSPACE_005fLEGITIMATE_005fADDRESS_005fP"></a>Target Hook: <em>bool</em> <strong>TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P</strong> <em>(machine_mode <var>mode</var>, rtx <var>exp</var>, bool <var>strict</var>, addr_space_t <var>as</var>)</em></dt>
  128. <dd><p>Define this to return true if <var>exp</var> is a valid address for mode
  129. <var>mode</var> in the named address space <var>as</var>. The <var>strict</var>
  130. parameter says whether strict addressing is in effect after reload has
  131. finished. This target hook is the same as the
  132. <code>TARGET_LEGITIMATE_ADDRESS_P</code> target hook, except that it includes
  133. explicit named address space support.
  134. </p></dd></dl>
  135. <dl>
  136. <dt><a name="index-TARGET_005fADDR_005fSPACE_005fLEGITIMIZE_005fADDRESS"></a>Target Hook: <em>rtx</em> <strong>TARGET_ADDR_SPACE_LEGITIMIZE_ADDRESS</strong> <em>(rtx <var>x</var>, rtx <var>oldx</var>, machine_mode <var>mode</var>, addr_space_t <var>as</var>)</em></dt>
  137. <dd><p>Define this to modify an invalid address <var>x</var> to be a valid address
  138. with mode <var>mode</var> in the named address space <var>as</var>. This target
  139. hook is the same as the <code>TARGET_LEGITIMIZE_ADDRESS</code> target hook,
  140. except that it includes explicit named address space support.
  141. </p></dd></dl>
  142. <dl>
  143. <dt><a name="index-TARGET_005fADDR_005fSPACE_005fSUBSET_005fP"></a>Target Hook: <em>bool</em> <strong>TARGET_ADDR_SPACE_SUBSET_P</strong> <em>(addr_space_t <var>subset</var>, addr_space_t <var>superset</var>)</em></dt>
  144. <dd><p>Define this to return whether the <var>subset</var> named address space is
  145. contained within the <var>superset</var> named address space. Pointers to
  146. a named address space that is a subset of another named address space
  147. will be converted automatically without a cast if used together in
  148. arithmetic operations. Pointers to a superset address space can be
  149. converted to pointers to a subset address space via explicit casts.
  150. </p></dd></dl>
  151. <dl>
  152. <dt><a name="index-TARGET_005fADDR_005fSPACE_005fZERO_005fADDRESS_005fVALID"></a>Target Hook: <em>bool</em> <strong>TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID</strong> <em>(addr_space_t <var>as</var>)</em></dt>
  153. <dd><p>Define this to modify the default handling of address 0 for the
  154. address space. Return true if 0 should be considered a valid address.
  155. </p></dd></dl>
  156. <dl>
  157. <dt><a name="index-TARGET_005fADDR_005fSPACE_005fCONVERT"></a>Target Hook: <em>rtx</em> <strong>TARGET_ADDR_SPACE_CONVERT</strong> <em>(rtx <var>op</var>, tree <var>from_type</var>, tree <var>to_type</var>)</em></dt>
  158. <dd><p>Define this to convert the pointer expression represented by the RTL
  159. <var>op</var> with type <var>from_type</var> that points to a named address
  160. space to a new pointer expression with type <var>to_type</var> that points
  161. to a different named address space. When this hook it called, it is
  162. guaranteed that one of the two address spaces is a subset of the other,
  163. as determined by the <code>TARGET_ADDR_SPACE_SUBSET_P</code> target hook.
  164. </p></dd></dl>
  165. <dl>
  166. <dt><a name="index-TARGET_005fADDR_005fSPACE_005fDEBUG"></a>Target Hook: <em>int</em> <strong>TARGET_ADDR_SPACE_DEBUG</strong> <em>(addr_space_t <var>as</var>)</em></dt>
  167. <dd><p>Define this to define how the address space is encoded in dwarf.
  168. The result is the value to be used with <code>DW_AT_address_class</code>.
  169. </p></dd></dl>
  170. <dl>
  171. <dt><a name="index-TARGET_005fADDR_005fSPACE_005fDIAGNOSE_005fUSAGE"></a>Target Hook: <em>void</em> <strong>TARGET_ADDR_SPACE_DIAGNOSE_USAGE</strong> <em>(addr_space_t <var>as</var>, location_t <var>loc</var>)</em></dt>
  172. <dd><p>Define this hook if the availability of an address space depends on
  173. command line options and some diagnostics should be printed when the
  174. address space is used. This hook is called during parsing and allows
  175. to emit a better diagnostic compared to the case where the address space
  176. was not registered with <code>c_register_addr_space</code>. <var>as</var> is
  177. the address space as registered with <code>c_register_addr_space</code>.
  178. <var>loc</var> is the location of the address space qualifier token.
  179. The default implementation does nothing.
  180. </p></dd></dl>
  181. <hr>
  182. <div class="header">
  183. <p>
  184. Next: <a href="Misc.html#Misc" accesskey="n" rel="next">Misc</a>, Previous: <a href="C_002b_002b-ABI.html#C_002b_002b-ABI" accesskey="p" rel="prev">C++ ABI</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>
  185. </div>
  186. </body>
  187. </html>