Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

211 rindas
11KB

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