Run_002dtime-Target.html 16 KB

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