Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

145 lines
6.6KB

  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>Target Structure (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Target Structure (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Target Structure (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="Driver.html#Driver" rel="next" title="Driver">
  31. <link href="Target-Macros.html#Target-Macros" rel="prev" title="Target Macros">
  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="Target-Structure"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Driver.html#Driver" accesskey="n" rel="next">Driver</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="The-Global-targetm-Variable"></a>
  68. <h3 class="section">18.1 The Global <code>targetm</code> Variable</h3>
  69. <a name="index-target-hooks"></a>
  70. <a name="index-target-functions"></a>
  71. <dl>
  72. <dt><a name="index-targetm"></a>Variable: <em>struct gcc_target</em> <strong>targetm</strong></dt>
  73. <dd><p>The target <samp>.c</samp> file must define the global <code>targetm</code> variable
  74. which contains pointers to functions and data relating to the target
  75. machine. The variable is declared in <samp>target.h</samp>;
  76. <samp>target-def.h</samp> defines the macro <code>TARGET_INITIALIZER</code> which is
  77. used to initialize the variable, and macros for the default initializers
  78. for elements of the structure. The <samp>.c</samp> file should override those
  79. macros for which the default definition is inappropriate. For example:
  80. </p><div class="smallexample">
  81. <pre class="smallexample">#include &quot;target.h&quot;
  82. #include &quot;target-def.h&quot;
  83. /* <span class="roman">Initialize the GCC target structure.</span> */
  84. #undef TARGET_COMP_TYPE_ATTRIBUTES
  85. #define TARGET_COMP_TYPE_ATTRIBUTES <var>machine</var>_comp_type_attributes
  86. struct gcc_target targetm = TARGET_INITIALIZER;
  87. </pre></div>
  88. </dd></dl>
  89. <p>Where a macro should be defined in the <samp>.c</samp> file in this manner to
  90. form part of the <code>targetm</code> structure, it is documented below as a
  91. &ldquo;Target Hook&rdquo; with a prototype. Many macros will change in future
  92. from being defined in the <samp>.h</samp> file to being part of the
  93. <code>targetm</code> structure.
  94. </p>
  95. <p>Similarly, there is a <code>targetcm</code> variable for hooks that are
  96. specific to front ends for C-family languages, documented as &ldquo;C
  97. Target Hook&rdquo;. This is declared in <samp>c-family/c-target.h</samp>, the
  98. initializer <code>TARGETCM_INITIALIZER</code> in
  99. <samp>c-family/c-target-def.h</samp>. If targets initialize <code>targetcm</code>
  100. themselves, they should set <code>target_has_targetcm=yes</code> in
  101. <samp>config.gcc</samp>; otherwise a default definition is used.
  102. </p>
  103. <p>Similarly, there is a <code>targetm_common</code> variable for hooks that
  104. are shared between the compiler driver and the compilers proper,
  105. documented as &ldquo;Common Target Hook&rdquo;. This is declared in
  106. <samp>common/common-target.h</samp>, the initializer
  107. <code>TARGETM_COMMON_INITIALIZER</code> in
  108. <samp>common/common-target-def.h</samp>. If targets initialize
  109. <code>targetm_common</code> themselves, they should set
  110. <code>target_has_targetm_common=yes</code> in <samp>config.gcc</samp>; otherwise a
  111. default definition is used.
  112. </p>
  113. <p>Similarly, there is a <code>targetdm</code> variable for hooks that are
  114. specific to the D language front end, documented as &ldquo;D Target Hook&rdquo;.
  115. This is declared in <samp>d/d-target.h</samp>, the initializer
  116. <code>TARGETDM_INITIALIZER</code> in <samp>d/d-target-def.h</samp>. If targets
  117. initialize <code>targetdm</code> themselves, they should set
  118. <code>target_has_targetdm=yes</code> in <samp>config.gcc</samp>; otherwise a default
  119. definition is used.
  120. </p>
  121. <hr>
  122. <div class="header">
  123. <p>
  124. Next: <a href="Driver.html#Driver" accesskey="n" rel="next">Driver</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>
  125. </div>
  126. </body>
  127. </html>