Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

Back-End.html 9.5KB

před 3 roky
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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>Back End (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Back End (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Back End (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="gcc-Directory.html#gcc-Directory" rel="up" title="gcc Directory">
  30. <link href="Testsuites.html#Testsuites" rel="next" title="Testsuites">
  31. <link href="Front-End-Makefile.html#Front-End-Makefile" rel="prev" title="Front End Makefile">
  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="Back-End"></a>
  62. <div class="header">
  63. <p>
  64. Previous: <a href="Front-End.html#Front-End" accesskey="p" rel="prev">Front End</a>, Up: <a href="gcc-Directory.html#gcc-Directory" accesskey="u" rel="up">gcc Directory</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="Anatomy-of-a-Target-Back-End"></a>
  68. <h4 class="subsection">6.3.9 Anatomy of a Target Back End</h4>
  69. <p>A back end for a target architecture in GCC has the following parts:
  70. </p>
  71. <ul>
  72. <li> A directory <samp><var>machine</var></samp> under <samp>gcc/config</samp>, containing a
  73. machine description <samp><var>machine</var>.md</samp> file (see <a href="Machine-Desc.html#Machine-Desc">Machine Descriptions</a>), header files <samp><var>machine</var>.h</samp> and
  74. <samp><var>machine</var>-protos.h</samp> and a source file <samp><var>machine</var>.c</samp>
  75. (see <a href="Target-Macros.html#Target-Macros">Target Description Macros and Functions</a>),
  76. possibly a target Makefile fragment <samp>t-<var>machine</var></samp>
  77. (see <a href="Target-Fragment.html#Target-Fragment">The Target Makefile Fragment</a>), and maybe
  78. some other files. The names of these files may be changed from the
  79. defaults given by explicit specifications in <samp>config.gcc</samp>.
  80. </li><li> If necessary, a file <samp><var>machine</var>-modes.def</samp> in the
  81. <samp><var>machine</var></samp> directory, containing additional machine modes to
  82. represent condition codes. See <a href="Condition-Code.html#Condition-Code">Condition Code</a>, for further details.
  83. </li><li> An optional <samp><var>machine</var>.opt</samp> file in the <samp><var>machine</var></samp>
  84. directory, containing a list of target-specific options. You can also
  85. add other option files using the <code>extra_options</code> variable in
  86. <samp>config.gcc</samp>. See <a href="Options.html#Options">Options</a>.
  87. </li><li> Entries in <samp>config.gcc</samp> (see <a href="System-Config.html#System-Config">The
  88. <samp>config.gcc</samp> File</a>) for the systems with this target
  89. architecture.
  90. </li><li> Documentation in <samp>gcc/doc/invoke.texi</samp> for any command-line
  91. options supported by this target (see <a href="Run_002dtime-Target.html#Run_002dtime-Target">Run-time
  92. Target Specification</a>). This means both entries in the summary table
  93. of options and details of the individual options.
  94. </li><li> Documentation in <samp>gcc/doc/extend.texi</samp> for any target-specific
  95. attributes supported (see <a href="Target-Attributes.html#Target-Attributes">Defining
  96. target-specific uses of <code>__attribute__</code></a>), including where the
  97. same attribute is already supported on some targets, which are
  98. enumerated in the manual.
  99. </li><li> Documentation in <samp>gcc/doc/extend.texi</samp> for any target-specific
  100. pragmas supported.
  101. </li><li> Documentation in <samp>gcc/doc/extend.texi</samp> of any target-specific
  102. built-in functions supported.
  103. </li><li> Documentation in <samp>gcc/doc/extend.texi</samp> of any target-specific
  104. format checking styles supported.
  105. </li><li> Documentation in <samp>gcc/doc/md.texi</samp> of any target-specific
  106. constraint letters (see <a href="Machine-Constraints.html#Machine-Constraints">Constraints for
  107. Particular Machines</a>).
  108. </li><li> A note in <samp>gcc/doc/contrib.texi</samp> under the person or people who
  109. contributed the target support.
  110. </li><li> Entries in <samp>gcc/doc/install.texi</samp> for all target triplets
  111. supported with this target architecture, giving details of any special
  112. notes about installation for this target, or saying that there are no
  113. special notes if there are none.
  114. </li><li> Possibly other support outside the <samp>gcc</samp> directory for runtime
  115. libraries. FIXME: reference docs for this. The <code>libstdc++</code> porting
  116. manual needs to be installed as info for this to work, or to be a
  117. chapter of this manual.
  118. </li></ul>
  119. <p>The <samp><var>machine</var>.h</samp> header is included very early in GCC&rsquo;s
  120. standard sequence of header files, while <samp><var>machine</var>-protos.h</samp>
  121. is included late in the sequence. Thus <samp><var>machine</var>-protos.h</samp>
  122. can include declarations referencing types that are not defined when
  123. <samp><var>machine</var>.h</samp> is included, specifically including those from
  124. <samp>rtl.h</samp> and <samp>tree.h</samp>. Since both RTL and tree types may not
  125. be available in every context where <samp><var>machine</var>-protos.h</samp> is
  126. included, in this file you should guard declarations using these types
  127. inside appropriate <code>#ifdef RTX_CODE</code> or <code>#ifdef TREE_CODE</code>
  128. conditional code segments.
  129. </p>
  130. <p>If the backend uses shared data structures that require <code>GTY</code> markers
  131. for garbage collection (see <a href="Type-Information.html#Type-Information">Type Information</a>), you must declare those
  132. in <samp><var>machine</var>.h</samp> rather than <samp><var>machine</var>-protos.h</samp>.
  133. Any definitions required for building libgcc must also go in
  134. <samp><var>machine</var>.h</samp>.
  135. </p>
  136. <p>GCC uses the macro <code>IN_TARGET_CODE</code> to distinguish between
  137. machine-specific <samp>.c</samp> and <samp>.cc</samp> files and
  138. machine-independent <samp>.c</samp> and <samp>.cc</samp> files. Machine-specific
  139. files should use the directive:
  140. </p>
  141. <div class="example">
  142. <pre class="example">#define IN_TARGET_CODE 1
  143. </pre></div>
  144. <p>before including <code>config.h</code>.
  145. </p>
  146. <p>If the back end is added to the official GCC source repository, the
  147. following are also necessary:
  148. </p>
  149. <ul>
  150. <li> An entry for the target architecture in <samp>readings.html</samp> on the
  151. GCC web site, with any relevant links.
  152. </li><li> Details of the properties of the back end and target architecture in
  153. <samp>backends.html</samp> on the GCC web site.
  154. </li><li> A news item about the contribution of support for that target
  155. architecture, in <samp>index.html</samp> on the GCC web site.
  156. </li><li> Normally, one or more maintainers of that target listed in
  157. <samp>MAINTAINERS</samp>. Some existing architectures may be unmaintained,
  158. but it would be unusual to add support for a target that does not have
  159. a maintainer when support is added.
  160. </li><li> Target triplets covering all <samp>config.gcc</samp> stanzas for the target,
  161. in the list in <samp>contrib/config-list.mk</samp>.
  162. </li></ul>
  163. <hr>
  164. <div class="header">
  165. <p>
  166. Previous: <a href="Front-End.html#Front-End" accesskey="p" rel="prev">Front End</a>, Up: <a href="gcc-Directory.html#gcc-Directory" accesskey="u" rel="up">gcc Directory</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>
  167. </div>
  168. </body>
  169. </html>