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.

280 lines
16KB

  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>Run-time Target (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Run-time Target (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Run-time Target (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="Per_002dFunction-Data.html#Per_002dFunction-Data" rel="next" title="Per-Function Data">
  31. <link href="Driver.html#Driver" rel="prev" title="Driver">
  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="Run_002dtime-Target"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Per_002dFunction-Data.html#Per_002dFunction-Data" accesskey="n" rel="next">Per-Function Data</a>, Previous: <a href="Driver.html#Driver" accesskey="p" rel="prev">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="Run_002dtime-Target-Specification"></a>
  68. <h3 class="section">18.3 Run-time Target Specification</h3>
  69. <a name="index-run_002dtime-target-specification"></a>
  70. <a name="index-predefined-macros"></a>
  71. <a name="index-target-specifications"></a>
  72. <p>Here are run-time target specifications.
  73. </p>
  74. <dl>
  75. <dt><a name="index-TARGET_005fCPU_005fCPP_005fBUILTINS"></a>Macro: <strong>TARGET_CPU_CPP_BUILTINS</strong> <em>()</em></dt>
  76. <dd><p>This function-like macro expands to a block of code that defines
  77. built-in preprocessor macros and assertions for the target CPU, using
  78. the functions <code>builtin_define</code>, <code>builtin_define_std</code> and
  79. <code>builtin_assert</code>. When the front end
  80. calls this macro it provides a trailing semicolon, and since it has
  81. finished command line option processing your code can use those
  82. results freely.
  83. </p>
  84. <p><code>builtin_assert</code> takes a string in the form you pass to the
  85. command-line option <samp>-A</samp>, such as <code>cpu=mips</code>, and creates
  86. the assertion. <code>builtin_define</code> takes a string in the form
  87. accepted by option <samp>-D</samp> and unconditionally defines the macro.
  88. </p>
  89. <p><code>builtin_define_std</code> takes a string representing the name of an
  90. object-like macro. If it doesn&rsquo;t lie in the user&rsquo;s namespace,
  91. <code>builtin_define_std</code> defines it unconditionally. Otherwise, it
  92. defines a version with two leading underscores, and another version
  93. with two leading and trailing underscores, and defines the original
  94. only if an ISO standard was not requested on the command line. For
  95. example, passing <code>unix</code> defines <code>__unix</code>, <code>__unix__</code>
  96. and possibly <code>unix</code>; passing <code>_mips</code> defines <code>__mips</code>,
  97. <code>__mips__</code> and possibly <code>_mips</code>, and passing <code>_ABI64</code>
  98. defines only <code>_ABI64</code>.
  99. </p>
  100. <p>You can also test for the C dialect being compiled. The variable
  101. <code>c_language</code> is set to one of <code>clk_c</code>, <code>clk_cplusplus</code>
  102. or <code>clk_objective_c</code>. Note that if we are preprocessing
  103. assembler, this variable will be <code>clk_c</code> but the function-like
  104. macro <code>preprocessing_asm_p()</code> will return true, so you might want
  105. to check for that first. If you need to check for strict ANSI, the
  106. variable <code>flag_iso</code> can be used. The function-like macro
  107. <code>preprocessing_trad_p()</code> can be used to check for traditional
  108. preprocessing.
  109. </p></dd></dl>
  110. <dl>
  111. <dt><a name="index-TARGET_005fOS_005fCPP_005fBUILTINS"></a>Macro: <strong>TARGET_OS_CPP_BUILTINS</strong> <em>()</em></dt>
  112. <dd><p>Similarly to <code>TARGET_CPU_CPP_BUILTINS</code> but this macro is optional
  113. and is used for the target operating system instead.
  114. </p></dd></dl>
  115. <dl>
  116. <dt><a name="index-TARGET_005fOBJFMT_005fCPP_005fBUILTINS"></a>Macro: <strong>TARGET_OBJFMT_CPP_BUILTINS</strong> <em>()</em></dt>
  117. <dd><p>Similarly to <code>TARGET_CPU_CPP_BUILTINS</code> but this macro is optional
  118. and is used for the target object format. <samp>elfos.h</samp> uses this
  119. macro to define <code>__ELF__</code>, so you probably do not need to define
  120. it yourself.
  121. </p></dd></dl>
  122. <dl>
  123. <dt><a name="index-target_005fflags"></a>Variable: <em>extern int</em> <strong>target_flags</strong></dt>
  124. <dd><p>This variable is declared in <samp>options.h</samp>, which is included before
  125. any target-specific headers.
  126. </p></dd></dl>
  127. <dl>
  128. <dt><a name="index-TARGET_005fDEFAULT_005fTARGET_005fFLAGS"></a>Common Target Hook: <em>int</em> <strong>TARGET_DEFAULT_TARGET_FLAGS</strong></dt>
  129. <dd><p>This variable specifies the initial value of <code>target_flags</code>.
  130. Its default setting is 0.
  131. </p></dd></dl>
  132. <a name="index-optional-hardware-or-system-features"></a>
  133. <a name="index-features_002c-optional_002c-in-system-conventions"></a>
  134. <dl>
  135. <dt><a name="index-TARGET_005fHANDLE_005fOPTION"></a>Common Target Hook: <em>bool</em> <strong>TARGET_HANDLE_OPTION</strong> <em>(struct gcc_options *<var>opts</var>, struct gcc_options *<var>opts_set</var>, const struct cl_decoded_option *<var>decoded</var>, location_t <var>loc</var>)</em></dt>
  136. <dd><p>This hook is called whenever the user specifies one of the
  137. target-specific options described by the <samp>.opt</samp> definition files
  138. (see <a href="Options.html#Options">Options</a>). It has the opportunity to do some option-specific
  139. processing and should return true if the option is valid. The default
  140. definition does nothing but return true.
  141. </p>
  142. <p><var>decoded</var> specifies the option and its arguments. <var>opts</var> and
  143. <var>opts_set</var> are the <code>gcc_options</code> structures to be used for
  144. storing option state, and <var>loc</var> is the location at which the
  145. option was passed (<code>UNKNOWN_LOCATION</code> except for options passed
  146. via attributes).
  147. </p></dd></dl>
  148. <dl>
  149. <dt><a name="index-TARGET_005fHANDLE_005fC_005fOPTION"></a>C Target Hook: <em>bool</em> <strong>TARGET_HANDLE_C_OPTION</strong> <em>(size_t <var>code</var>, const char *<var>arg</var>, int <var>value</var>)</em></dt>
  150. <dd><p>This target hook is called whenever the user specifies one of the
  151. target-specific C language family options described by the <samp>.opt</samp>
  152. definition files(see <a href="Options.html#Options">Options</a>). It has the opportunity to do some
  153. option-specific processing and should return true if the option is
  154. valid. The arguments are like for <code>TARGET_HANDLE_OPTION</code>. The
  155. default definition does nothing but return false.
  156. </p>
  157. <p>In general, you should use <code>TARGET_HANDLE_OPTION</code> to handle
  158. options. However, if processing an option requires routines that are
  159. only available in the C (and related language) front ends, then you
  160. should use <code>TARGET_HANDLE_C_OPTION</code> instead.
  161. </p></dd></dl>
  162. <dl>
  163. <dt><a name="index-TARGET_005fOBJC_005fCONSTRUCT_005fSTRING_005fOBJECT"></a>C Target Hook: <em>tree</em> <strong>TARGET_OBJC_CONSTRUCT_STRING_OBJECT</strong> <em>(tree <var>string</var>)</em></dt>
  164. <dd><p>Targets may provide a string object type that can be used within and between C, C++ and their respective Objective-C dialects. A string object might, for example, embed encoding and length information. These objects are considered opaque to the compiler and handled as references. An ideal implementation makes the composition of the string object match that of the Objective-C <code>NSString</code> (<code>NXString</code> for GNUStep), allowing efficient interworking between C-only and Objective-C code. If a target implements string objects then this hook should return a reference to such an object constructed from the normal &lsquo;C&rsquo; string representation provided in <var>string</var>. At present, the hook is used by Objective-C only, to obtain a common-format string object when the target provides one.
  165. </p></dd></dl>
  166. <dl>
  167. <dt><a name="index-TARGET_005fOBJC_005fDECLARE_005fUNRESOLVED_005fCLASS_005fREFERENCE"></a>C Target Hook: <em>void</em> <strong>TARGET_OBJC_DECLARE_UNRESOLVED_CLASS_REFERENCE</strong> <em>(const char *<var>classname</var>)</em></dt>
  168. <dd><p>Declare that Objective C class <var>classname</var> is referenced by the current TU.
  169. </p></dd></dl>
  170. <dl>
  171. <dt><a name="index-TARGET_005fOBJC_005fDECLARE_005fCLASS_005fDEFINITION"></a>C Target Hook: <em>void</em> <strong>TARGET_OBJC_DECLARE_CLASS_DEFINITION</strong> <em>(const char *<var>classname</var>)</em></dt>
  172. <dd><p>Declare that Objective C class <var>classname</var> is defined by the current TU.
  173. </p></dd></dl>
  174. <dl>
  175. <dt><a name="index-TARGET_005fSTRING_005fOBJECT_005fREF_005fTYPE_005fP"></a>C Target Hook: <em>bool</em> <strong>TARGET_STRING_OBJECT_REF_TYPE_P</strong> <em>(const_tree <var>stringref</var>)</em></dt>
  176. <dd><p>If a target implements string objects then this hook should return <code>true</code> if <var>stringref</var> is a valid reference to such an object.
  177. </p></dd></dl>
  178. <dl>
  179. <dt><a name="index-TARGET_005fCHECK_005fSTRING_005fOBJECT_005fFORMAT_005fARG"></a>C Target Hook: <em>void</em> <strong>TARGET_CHECK_STRING_OBJECT_FORMAT_ARG</strong> <em>(tree <var>format_arg</var>, tree <var>args_list</var>)</em></dt>
  180. <dd><p>If a target implements string objects then this hook should should provide a facility to check the function arguments in <var>args_list</var> against the format specifiers in <var>format_arg</var> where the type of <var>format_arg</var> is one recognized as a valid string reference type.
  181. </p></dd></dl>
  182. <dl>
  183. <dt><a name="index-TARGET_005fOVERRIDE_005fOPTIONS_005fAFTER_005fCHANGE"></a>Target Hook: <em>void</em> <strong>TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE</strong> <em>(void)</em></dt>
  184. <dd><p>This target function is similar to the hook <code>TARGET_OPTION_OVERRIDE</code>
  185. but is called when the optimize level is changed via an attribute or
  186. pragma or when it is reset at the end of the code affected by the
  187. attribute or pragma. It is not called at the beginning of compilation
  188. when <code>TARGET_OPTION_OVERRIDE</code> is called so if you want to perform these
  189. actions then, you should have <code>TARGET_OPTION_OVERRIDE</code> call
  190. <code>TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE</code>.
  191. </p></dd></dl>
  192. <dl>
  193. <dt><a name="index-C_005fCOMMON_005fOVERRIDE_005fOPTIONS"></a>Macro: <strong>C_COMMON_OVERRIDE_OPTIONS</strong></dt>
  194. <dd><p>This is similar to the <code>TARGET_OPTION_OVERRIDE</code> hook
  195. but is only used in the C
  196. language frontends (C, Objective-C, C++, Objective-C++) and so can be
  197. used to alter option flag variables which only exist in those
  198. frontends.
  199. </p></dd></dl>
  200. <dl>
  201. <dt><a name="index-TARGET_005fOPTION_005fOPTIMIZATION_005fTABLE"></a>Common Target Hook: <em>const struct default_options *</em> <strong>TARGET_OPTION_OPTIMIZATION_TABLE</strong></dt>
  202. <dd><p>Some machines may desire to change what optimizations are performed for
  203. various optimization levels. This variable, if defined, describes
  204. options to enable at particular sets of optimization levels. These
  205. options are processed once
  206. just after the optimization level is determined and before the remainder
  207. of the command options have been parsed, so may be overridden by other
  208. options passed explicitly.
  209. </p>
  210. <p>This processing is run once at program startup and when the optimization
  211. options are changed via <code>#pragma GCC optimize</code> or by using the
  212. <code>optimize</code> attribute.
  213. </p></dd></dl>
  214. <dl>
  215. <dt><a name="index-TARGET_005fOPTION_005fINIT_005fSTRUCT"></a>Common Target Hook: <em>void</em> <strong>TARGET_OPTION_INIT_STRUCT</strong> <em>(struct gcc_options *<var>opts</var>)</em></dt>
  216. <dd><p>Set target-dependent initial values of fields in <var>opts</var>.
  217. </p></dd></dl>
  218. <dl>
  219. <dt><a name="index-SWITCHABLE_005fTARGET"></a>Macro: <strong>SWITCHABLE_TARGET</strong></dt>
  220. <dd><p>Some targets need to switch between substantially different subtargets
  221. during compilation. For example, the MIPS target has one subtarget for
  222. the traditional MIPS architecture and another for MIPS16. Source code
  223. can switch between these two subarchitectures using the <code>mips16</code>
  224. and <code>nomips16</code> attributes.
  225. </p>
  226. <p>Such subtargets can differ in things like the set of available
  227. registers, the set of available instructions, the costs of various
  228. operations, and so on. GCC caches a lot of this type of information
  229. in global variables, and recomputing them for each subtarget takes a
  230. significant amount of time. The compiler therefore provides a facility
  231. for maintaining several versions of the global variables and quickly
  232. switching between them; see <samp>target-globals.h</samp> for details.
  233. </p>
  234. <p>Define this macro to 1 if your target needs this facility. The default
  235. is 0.
  236. </p></dd></dl>
  237. <dl>
  238. <dt><a name="index-TARGET_005fFLOAT_005fEXCEPTIONS_005fROUNDING_005fSUPPORTED_005fP"></a>Target Hook: <em>bool</em> <strong>TARGET_FLOAT_EXCEPTIONS_ROUNDING_SUPPORTED_P</strong> <em>(void)</em></dt>
  239. <dd><p>Returns true if the target supports IEEE 754 floating-point exceptions and rounding modes, false otherwise. This is intended to relate to the <code>float</code> and <code>double</code> types, but not necessarily <code>long double</code>. By default, returns true if the <code>adddf3</code> instruction pattern is available and false otherwise, on the assumption that hardware floating point supports exceptions and rounding modes but software floating point does not.
  240. </p></dd></dl>
  241. <hr>
  242. <div class="header">
  243. <p>
  244. Next: <a href="Per_002dFunction-Data.html#Per_002dFunction-Data" accesskey="n" rel="next">Per-Function Data</a>, Previous: <a href="Driver.html#Driver" accesskey="p" rel="prev">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>
  245. </div>
  246. </body>
  247. </html>