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.

565 lines
30KB

  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>Costs (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Costs (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Costs (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="Scheduling.html#Scheduling" rel="next" title="Scheduling">
  31. <link href="MODE_005fCC-Condition-Codes.html#MODE_005fCC-Condition-Codes" rel="prev" title="MODE_CC Condition Codes">
  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="Costs"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Scheduling.html#Scheduling" accesskey="n" rel="next">Scheduling</a>, Previous: <a href="Condition-Code.html#Condition-Code" accesskey="p" rel="prev">Condition Code</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="Describing-Relative-Costs-of-Operations"></a>
  68. <h3 class="section">18.16 Describing Relative Costs of Operations</h3>
  69. <a name="index-costs-of-instructions"></a>
  70. <a name="index-relative-costs"></a>
  71. <a name="index-speed-of-instructions"></a>
  72. <p>These macros let you describe the relative speed of various operations
  73. on the target machine.
  74. </p>
  75. <dl>
  76. <dt><a name="index-REGISTER_005fMOVE_005fCOST"></a>Macro: <strong>REGISTER_MOVE_COST</strong> <em>(<var>mode</var>, <var>from</var>, <var>to</var>)</em></dt>
  77. <dd><p>A C expression for the cost of moving data of mode <var>mode</var> from a
  78. register in class <var>from</var> to one in class <var>to</var>. The classes are
  79. expressed using the enumeration values such as <code>GENERAL_REGS</code>. A
  80. value of 2 is the default; other values are interpreted relative to
  81. that.
  82. </p>
  83. <p>It is not required that the cost always equal 2 when <var>from</var> is the
  84. same as <var>to</var>; on some machines it is expensive to move between
  85. registers if they are not general registers.
  86. </p>
  87. <p>If reload sees an insn consisting of a single <code>set</code> between two
  88. hard registers, and if <code>REGISTER_MOVE_COST</code> applied to their
  89. classes returns a value of 2, reload does not check to ensure that the
  90. constraints of the insn are met. Setting a cost of other than 2 will
  91. allow reload to verify that the constraints are met. You should do this
  92. if the &lsquo;<samp>mov<var>m</var></samp>&rsquo; pattern&rsquo;s constraints do not allow such copying.
  93. </p>
  94. <p>These macros are obsolete, new ports should use the target hook
  95. <code>TARGET_REGISTER_MOVE_COST</code> instead.
  96. </p></dd></dl>
  97. <dl>
  98. <dt><a name="index-TARGET_005fREGISTER_005fMOVE_005fCOST"></a>Target Hook: <em>int</em> <strong>TARGET_REGISTER_MOVE_COST</strong> <em>(machine_mode <var>mode</var>, reg_class_t <var>from</var>, reg_class_t <var>to</var>)</em></dt>
  99. <dd><p>This target hook should return the cost of moving data of mode <var>mode</var>
  100. from a register in class <var>from</var> to one in class <var>to</var>. The classes
  101. are expressed using the enumeration values such as <code>GENERAL_REGS</code>.
  102. A value of 2 is the default; other values are interpreted relative to
  103. that.
  104. </p>
  105. <p>It is not required that the cost always equal 2 when <var>from</var> is the
  106. same as <var>to</var>; on some machines it is expensive to move between
  107. registers if they are not general registers.
  108. </p>
  109. <p>If reload sees an insn consisting of a single <code>set</code> between two
  110. hard registers, and if <code>TARGET_REGISTER_MOVE_COST</code> applied to their
  111. classes returns a value of 2, reload does not check to ensure that the
  112. constraints of the insn are met. Setting a cost of other than 2 will
  113. allow reload to verify that the constraints are met. You should do this
  114. if the &lsquo;<samp>mov<var>m</var></samp>&rsquo; pattern&rsquo;s constraints do not allow such copying.
  115. </p>
  116. <p>The default version of this function returns 2.
  117. </p></dd></dl>
  118. <dl>
  119. <dt><a name="index-MEMORY_005fMOVE_005fCOST"></a>Macro: <strong>MEMORY_MOVE_COST</strong> <em>(<var>mode</var>, <var>class</var>, <var>in</var>)</em></dt>
  120. <dd><p>A C expression for the cost of moving data of mode <var>mode</var> between a
  121. register of class <var>class</var> and memory; <var>in</var> is zero if the value
  122. is to be written to memory, nonzero if it is to be read in. This cost
  123. is relative to those in <code>REGISTER_MOVE_COST</code>. If moving between
  124. registers and memory is more expensive than between two registers, you
  125. should define this macro to express the relative cost.
  126. </p>
  127. <p>If you do not define this macro, GCC uses a default cost of 4 plus
  128. the cost of copying via a secondary reload register, if one is
  129. needed. If your machine requires a secondary reload register to copy
  130. between memory and a register of <var>class</var> but the reload mechanism is
  131. more complex than copying via an intermediate, define this macro to
  132. reflect the actual cost of the move.
  133. </p>
  134. <p>GCC defines the function <code>memory_move_secondary_cost</code> if
  135. secondary reloads are needed. It computes the costs due to copying via
  136. a secondary register. If your machine copies from memory using a
  137. secondary register in the conventional way but the default base value of
  138. 4 is not correct for your machine, define this macro to add some other
  139. value to the result of that function. The arguments to that function
  140. are the same as to this macro.
  141. </p>
  142. <p>These macros are obsolete, new ports should use the target hook
  143. <code>TARGET_MEMORY_MOVE_COST</code> instead.
  144. </p></dd></dl>
  145. <dl>
  146. <dt><a name="index-TARGET_005fMEMORY_005fMOVE_005fCOST"></a>Target Hook: <em>int</em> <strong>TARGET_MEMORY_MOVE_COST</strong> <em>(machine_mode <var>mode</var>, reg_class_t <var>rclass</var>, bool <var>in</var>)</em></dt>
  147. <dd><p>This target hook should return the cost of moving data of mode <var>mode</var>
  148. between a register of class <var>rclass</var> and memory; <var>in</var> is <code>false</code>
  149. if the value is to be written to memory, <code>true</code> if it is to be read in.
  150. This cost is relative to those in <code>TARGET_REGISTER_MOVE_COST</code>.
  151. If moving between registers and memory is more expensive than between two
  152. registers, you should add this target hook to express the relative cost.
  153. </p>
  154. <p>If you do not add this target hook, GCC uses a default cost of 4 plus
  155. the cost of copying via a secondary reload register, if one is
  156. needed. If your machine requires a secondary reload register to copy
  157. between memory and a register of <var>rclass</var> but the reload mechanism is
  158. more complex than copying via an intermediate, use this target hook to
  159. reflect the actual cost of the move.
  160. </p>
  161. <p>GCC defines the function <code>memory_move_secondary_cost</code> if
  162. secondary reloads are needed. It computes the costs due to copying via
  163. a secondary register. If your machine copies from memory using a
  164. secondary register in the conventional way but the default base value of
  165. 4 is not correct for your machine, use this target hook to add some other
  166. value to the result of that function. The arguments to that function
  167. are the same as to this target hook.
  168. </p></dd></dl>
  169. <dl>
  170. <dt><a name="index-BRANCH_005fCOST"></a>Macro: <strong>BRANCH_COST</strong> <em>(<var>speed_p</var>, <var>predictable_p</var>)</em></dt>
  171. <dd><p>A C expression for the cost of a branch instruction. A value of 1 is
  172. the default; other values are interpreted relative to that. Parameter
  173. <var>speed_p</var> is true when the branch in question should be optimized
  174. for speed. When it is false, <code>BRANCH_COST</code> should return a value
  175. optimal for code size rather than performance. <var>predictable_p</var> is
  176. true for well-predicted branches. On many architectures the
  177. <code>BRANCH_COST</code> can be reduced then.
  178. </p></dd></dl>
  179. <p>Here are additional macros which do not specify precise relative costs,
  180. but only that certain actions are more expensive than GCC would
  181. ordinarily expect.
  182. </p>
  183. <dl>
  184. <dt><a name="index-SLOW_005fBYTE_005fACCESS"></a>Macro: <strong>SLOW_BYTE_ACCESS</strong></dt>
  185. <dd><p>Define this macro as a C expression which is nonzero if accessing less
  186. than a word of memory (i.e. a <code>char</code> or a <code>short</code>) is no
  187. faster than accessing a word of memory, i.e., if such access
  188. require more than one instruction or if there is no difference in cost
  189. between byte and (aligned) word loads.
  190. </p>
  191. <p>When this macro is not defined, the compiler will access a field by
  192. finding the smallest containing object; when it is defined, a fullword
  193. load will be used if alignment permits. Unless bytes accesses are
  194. faster than word accesses, using word accesses is preferable since it
  195. may eliminate subsequent memory access if subsequent accesses occur to
  196. other fields in the same word of the structure, but to different bytes.
  197. </p></dd></dl>
  198. <dl>
  199. <dt><a name="index-TARGET_005fSLOW_005fUNALIGNED_005fACCESS"></a>Target Hook: <em>bool</em> <strong>TARGET_SLOW_UNALIGNED_ACCESS</strong> <em>(machine_mode <var>mode</var>, unsigned int <var>align</var>)</em></dt>
  200. <dd><p>This hook returns true if memory accesses described by the
  201. <var>mode</var> and <var>alignment</var> parameters have a cost many times greater
  202. than aligned accesses, for example if they are emulated in a trap handler.
  203. This hook is invoked only for unaligned accesses, i.e. when
  204. <code><var>alignment</var> &lt; GET_MODE_ALIGNMENT (<var>mode</var>)</code>.
  205. </p>
  206. <p>When this hook returns true, the compiler will act as if
  207. <code>STRICT_ALIGNMENT</code> were true when generating code for block
  208. moves. This can cause significantly more instructions to be produced.
  209. Therefore, do not make this hook return true if unaligned accesses only
  210. add a cycle or two to the time for a memory access.
  211. </p>
  212. <p>The hook must return true whenever <code>STRICT_ALIGNMENT</code> is true.
  213. The default implementation returns <code>STRICT_ALIGNMENT</code>.
  214. </p></dd></dl>
  215. <dl>
  216. <dt><a name="index-MOVE_005fRATIO"></a>Macro: <strong>MOVE_RATIO</strong> <em>(<var>speed</var>)</em></dt>
  217. <dd><p>The threshold of number of scalar memory-to-memory move insns, <em>below</em>
  218. which a sequence of insns should be generated instead of a
  219. string move insn or a library call. Increasing the value will always
  220. make code faster, but eventually incurs high cost in increased code size.
  221. </p>
  222. <p>Note that on machines where the corresponding move insn is a
  223. <code>define_expand</code> that emits a sequence of insns, this macro counts
  224. the number of such sequences.
  225. </p>
  226. <p>The parameter <var>speed</var> is true if the code is currently being
  227. optimized for speed rather than size.
  228. </p>
  229. <p>If you don&rsquo;t define this, a reasonable default is used.
  230. </p></dd></dl>
  231. <dl>
  232. <dt><a name="index-TARGET_005fUSE_005fBY_005fPIECES_005fINFRASTRUCTURE_005fP"></a>Target Hook: <em>bool</em> <strong>TARGET_USE_BY_PIECES_INFRASTRUCTURE_P</strong> <em>(unsigned HOST_WIDE_INT <var>size</var>, unsigned int <var>alignment</var>, enum by_pieces_operation <var>op</var>, bool <var>speed_p</var>)</em></dt>
  233. <dd><p>GCC will attempt several strategies when asked to copy between
  234. two areas of memory, or to set, clear or store to memory, for example
  235. when copying a <code>struct</code>. The <code>by_pieces</code> infrastructure
  236. implements such memory operations as a sequence of load, store or move
  237. insns. Alternate strategies are to expand the
  238. <code>cpymem</code> or <code>setmem</code> optabs, to emit a library call, or to emit
  239. unit-by-unit, loop-based operations.
  240. </p>
  241. <p>This target hook should return true if, for a memory operation with a
  242. given <var>size</var> and <var>alignment</var>, using the <code>by_pieces</code>
  243. infrastructure is expected to result in better code generation.
  244. Both <var>size</var> and <var>alignment</var> are measured in terms of storage
  245. units.
  246. </p>
  247. <p>The parameter <var>op</var> is one of: <code>CLEAR_BY_PIECES</code>,
  248. <code>MOVE_BY_PIECES</code>, <code>SET_BY_PIECES</code>, <code>STORE_BY_PIECES</code> or
  249. <code>COMPARE_BY_PIECES</code>. These describe the type of memory operation
  250. under consideration.
  251. </p>
  252. <p>The parameter <var>speed_p</var> is true if the code is currently being
  253. optimized for speed rather than size.
  254. </p>
  255. <p>Returning true for higher values of <var>size</var> can improve code generation
  256. for speed if the target does not provide an implementation of the
  257. <code>cpymem</code> or <code>setmem</code> standard names, if the <code>cpymem</code> or
  258. <code>setmem</code> implementation would be more expensive than a sequence of
  259. insns, or if the overhead of a library call would dominate that of
  260. the body of the memory operation.
  261. </p>
  262. <p>Returning true for higher values of <code>size</code> may also cause an increase
  263. in code size, for example where the number of insns emitted to perform a
  264. move would be greater than that of a library call.
  265. </p></dd></dl>
  266. <dl>
  267. <dt><a name="index-TARGET_005fCOMPARE_005fBY_005fPIECES_005fBRANCH_005fRATIO"></a>Target Hook: <em>int</em> <strong>TARGET_COMPARE_BY_PIECES_BRANCH_RATIO</strong> <em>(machine_mode <var>mode</var>)</em></dt>
  268. <dd><p>When expanding a block comparison in MODE, gcc can try to reduce the
  269. number of branches at the expense of more memory operations. This hook
  270. allows the target to override the default choice. It should return the
  271. factor by which branches should be reduced over the plain expansion with
  272. one comparison per <var>mode</var>-sized piece. A port can also prevent a
  273. particular mode from being used for block comparisons by returning a
  274. negative number from this hook.
  275. </p></dd></dl>
  276. <dl>
  277. <dt><a name="index-MOVE_005fMAX_005fPIECES"></a>Macro: <strong>MOVE_MAX_PIECES</strong></dt>
  278. <dd><p>A C expression used by <code>move_by_pieces</code> to determine the largest unit
  279. a load or store used to copy memory is. Defaults to <code>MOVE_MAX</code>.
  280. </p></dd></dl>
  281. <dl>
  282. <dt><a name="index-STORE_005fMAX_005fPIECES"></a>Macro: <strong>STORE_MAX_PIECES</strong></dt>
  283. <dd><p>A C expression used by <code>store_by_pieces</code> to determine the largest unit
  284. a store used to memory is. Defaults to <code>MOVE_MAX_PIECES</code>, or two times
  285. the size of <code>HOST_WIDE_INT</code>, whichever is smaller.
  286. </p></dd></dl>
  287. <dl>
  288. <dt><a name="index-COMPARE_005fMAX_005fPIECES"></a>Macro: <strong>COMPARE_MAX_PIECES</strong></dt>
  289. <dd><p>A C expression used by <code>compare_by_pieces</code> to determine the largest unit
  290. a load or store used to compare memory is. Defaults to
  291. <code>MOVE_MAX_PIECES</code>.
  292. </p></dd></dl>
  293. <dl>
  294. <dt><a name="index-CLEAR_005fRATIO"></a>Macro: <strong>CLEAR_RATIO</strong> <em>(<var>speed</var>)</em></dt>
  295. <dd><p>The threshold of number of scalar move insns, <em>below</em> which a sequence
  296. of insns should be generated to clear memory instead of a string clear insn
  297. or a library call. Increasing the value will always make code faster, but
  298. eventually incurs high cost in increased code size.
  299. </p>
  300. <p>The parameter <var>speed</var> is true if the code is currently being
  301. optimized for speed rather than size.
  302. </p>
  303. <p>If you don&rsquo;t define this, a reasonable default is used.
  304. </p></dd></dl>
  305. <dl>
  306. <dt><a name="index-SET_005fRATIO"></a>Macro: <strong>SET_RATIO</strong> <em>(<var>speed</var>)</em></dt>
  307. <dd><p>The threshold of number of scalar move insns, <em>below</em> which a sequence
  308. of insns should be generated to set memory to a constant value, instead of
  309. a block set insn or a library call.
  310. Increasing the value will always make code faster, but
  311. eventually incurs high cost in increased code size.
  312. </p>
  313. <p>The parameter <var>speed</var> is true if the code is currently being
  314. optimized for speed rather than size.
  315. </p>
  316. <p>If you don&rsquo;t define this, it defaults to the value of <code>MOVE_RATIO</code>.
  317. </p></dd></dl>
  318. <dl>
  319. <dt><a name="index-USE_005fLOAD_005fPOST_005fINCREMENT"></a>Macro: <strong>USE_LOAD_POST_INCREMENT</strong> <em>(<var>mode</var>)</em></dt>
  320. <dd><p>A C expression used to determine whether a load postincrement is a good
  321. thing to use for a given mode. Defaults to the value of
  322. <code>HAVE_POST_INCREMENT</code>.
  323. </p></dd></dl>
  324. <dl>
  325. <dt><a name="index-USE_005fLOAD_005fPOST_005fDECREMENT"></a>Macro: <strong>USE_LOAD_POST_DECREMENT</strong> <em>(<var>mode</var>)</em></dt>
  326. <dd><p>A C expression used to determine whether a load postdecrement is a good
  327. thing to use for a given mode. Defaults to the value of
  328. <code>HAVE_POST_DECREMENT</code>.
  329. </p></dd></dl>
  330. <dl>
  331. <dt><a name="index-USE_005fLOAD_005fPRE_005fINCREMENT"></a>Macro: <strong>USE_LOAD_PRE_INCREMENT</strong> <em>(<var>mode</var>)</em></dt>
  332. <dd><p>A C expression used to determine whether a load preincrement is a good
  333. thing to use for a given mode. Defaults to the value of
  334. <code>HAVE_PRE_INCREMENT</code>.
  335. </p></dd></dl>
  336. <dl>
  337. <dt><a name="index-USE_005fLOAD_005fPRE_005fDECREMENT"></a>Macro: <strong>USE_LOAD_PRE_DECREMENT</strong> <em>(<var>mode</var>)</em></dt>
  338. <dd><p>A C expression used to determine whether a load predecrement is a good
  339. thing to use for a given mode. Defaults to the value of
  340. <code>HAVE_PRE_DECREMENT</code>.
  341. </p></dd></dl>
  342. <dl>
  343. <dt><a name="index-USE_005fSTORE_005fPOST_005fINCREMENT"></a>Macro: <strong>USE_STORE_POST_INCREMENT</strong> <em>(<var>mode</var>)</em></dt>
  344. <dd><p>A C expression used to determine whether a store postincrement is a good
  345. thing to use for a given mode. Defaults to the value of
  346. <code>HAVE_POST_INCREMENT</code>.
  347. </p></dd></dl>
  348. <dl>
  349. <dt><a name="index-USE_005fSTORE_005fPOST_005fDECREMENT"></a>Macro: <strong>USE_STORE_POST_DECREMENT</strong> <em>(<var>mode</var>)</em></dt>
  350. <dd><p>A C expression used to determine whether a store postdecrement is a good
  351. thing to use for a given mode. Defaults to the value of
  352. <code>HAVE_POST_DECREMENT</code>.
  353. </p></dd></dl>
  354. <dl>
  355. <dt><a name="index-USE_005fSTORE_005fPRE_005fINCREMENT"></a>Macro: <strong>USE_STORE_PRE_INCREMENT</strong> <em>(<var>mode</var>)</em></dt>
  356. <dd><p>This macro is used to determine whether a store preincrement is a good
  357. thing to use for a given mode. Defaults to the value of
  358. <code>HAVE_PRE_INCREMENT</code>.
  359. </p></dd></dl>
  360. <dl>
  361. <dt><a name="index-USE_005fSTORE_005fPRE_005fDECREMENT"></a>Macro: <strong>USE_STORE_PRE_DECREMENT</strong> <em>(<var>mode</var>)</em></dt>
  362. <dd><p>This macro is used to determine whether a store predecrement is a good
  363. thing to use for a given mode. Defaults to the value of
  364. <code>HAVE_PRE_DECREMENT</code>.
  365. </p></dd></dl>
  366. <dl>
  367. <dt><a name="index-NO_005fFUNCTION_005fCSE"></a>Macro: <strong>NO_FUNCTION_CSE</strong></dt>
  368. <dd><p>Define this macro to be true if it is as good or better to call a constant
  369. function address than to call an address kept in a register.
  370. </p></dd></dl>
  371. <dl>
  372. <dt><a name="index-LOGICAL_005fOP_005fNON_005fSHORT_005fCIRCUIT"></a>Macro: <strong>LOGICAL_OP_NON_SHORT_CIRCUIT</strong></dt>
  373. <dd><p>Define this macro if a non-short-circuit operation produced by
  374. &lsquo;<samp>fold_range_test ()</samp>&rsquo; is optimal. This macro defaults to true if
  375. <code>BRANCH_COST</code> is greater than or equal to the value 2.
  376. </p></dd></dl>
  377. <dl>
  378. <dt><a name="index-TARGET_005fOPTAB_005fSUPPORTED_005fP"></a>Target Hook: <em>bool</em> <strong>TARGET_OPTAB_SUPPORTED_P</strong> <em>(int <var>op</var>, machine_mode <var>mode1</var>, machine_mode <var>mode2</var>, optimization_type <var>opt_type</var>)</em></dt>
  379. <dd><p>Return true if the optimizers should use optab <var>op</var> with
  380. modes <var>mode1</var> and <var>mode2</var> for optimization type <var>opt_type</var>.
  381. The optab is known to have an associated <samp>.md</samp> instruction
  382. whose C condition is true. <var>mode2</var> is only meaningful for conversion
  383. optabs; for direct optabs it is a copy of <var>mode1</var>.
  384. </p>
  385. <p>For example, when called with <var>op</var> equal to <code>rint_optab</code> and
  386. <var>mode1</var> equal to <code>DFmode</code>, the hook should say whether the
  387. optimizers should use optab <code>rintdf2</code>.
  388. </p>
  389. <p>The default hook returns true for all inputs.
  390. </p></dd></dl>
  391. <dl>
  392. <dt><a name="index-TARGET_005fRTX_005fCOSTS"></a>Target Hook: <em>bool</em> <strong>TARGET_RTX_COSTS</strong> <em>(rtx <var>x</var>, machine_mode <var>mode</var>, int <var>outer_code</var>, int <var>opno</var>, int *<var>total</var>, bool <var>speed</var>)</em></dt>
  393. <dd><p>This target hook describes the relative costs of RTL expressions.
  394. </p>
  395. <p>The cost may depend on the precise form of the expression, which is
  396. available for examination in <var>x</var>, and the fact that <var>x</var> appears
  397. as operand <var>opno</var> of an expression with rtx code <var>outer_code</var>.
  398. That is, the hook can assume that there is some rtx <var>y</var> such
  399. that &lsquo;<samp>GET_CODE (<var>y</var>) == <var>outer_code</var></samp>&rsquo; and such that
  400. either (a) &lsquo;<samp>XEXP (<var>y</var>, <var>opno</var>) == <var>x</var></samp>&rsquo; or
  401. (b) &lsquo;<samp>XVEC (<var>y</var>, <var>opno</var>)</samp>&rsquo; contains <var>x</var>.
  402. </p>
  403. <p><var>mode</var> is <var>x</var>&rsquo;s machine mode, or for cases like <code>const_int</code> that
  404. do not have a mode, the mode in which <var>x</var> is used.
  405. </p>
  406. <p>In implementing this hook, you can use the construct
  407. <code>COSTS_N_INSNS (<var>n</var>)</code> to specify a cost equal to <var>n</var> fast
  408. instructions.
  409. </p>
  410. <p>On entry to the hook, <code>*<var>total</var></code> contains a default estimate
  411. for the cost of the expression. The hook should modify this value as
  412. necessary. Traditionally, the default costs are <code>COSTS_N_INSNS (5)</code>
  413. for multiplications, <code>COSTS_N_INSNS (7)</code> for division and modulus
  414. operations, and <code>COSTS_N_INSNS (1)</code> for all other operations.
  415. </p>
  416. <p>When optimizing for code size, i.e. when <code>speed</code> is
  417. false, this target hook should be used to estimate the relative
  418. size cost of an expression, again relative to <code>COSTS_N_INSNS</code>.
  419. </p>
  420. <p>The hook returns true when all subexpressions of <var>x</var> have been
  421. processed, and false when <code>rtx_cost</code> should recurse.
  422. </p></dd></dl>
  423. <dl>
  424. <dt><a name="index-TARGET_005fADDRESS_005fCOST"></a>Target Hook: <em>int</em> <strong>TARGET_ADDRESS_COST</strong> <em>(rtx <var>address</var>, machine_mode <var>mode</var>, addr_space_t <var>as</var>, bool <var>speed</var>)</em></dt>
  425. <dd><p>This hook computes the cost of an addressing mode that contains
  426. <var>address</var>. If not defined, the cost is computed from
  427. the <var>address</var> expression and the <code>TARGET_RTX_COST</code> hook.
  428. </p>
  429. <p>For most CISC machines, the default cost is a good approximation of the
  430. true cost of the addressing mode. However, on RISC machines, all
  431. instructions normally have the same length and execution time. Hence
  432. all addresses will have equal costs.
  433. </p>
  434. <p>In cases where more than one form of an address is known, the form with
  435. the lowest cost will be used. If multiple forms have the same, lowest,
  436. cost, the one that is the most complex will be used.
  437. </p>
  438. <p>For example, suppose an address that is equal to the sum of a register
  439. and a constant is used twice in the same basic block. When this macro
  440. is not defined, the address will be computed in a register and memory
  441. references will be indirect through that register. On machines where
  442. the cost of the addressing mode containing the sum is no higher than
  443. that of a simple indirect reference, this will produce an additional
  444. instruction and possibly require an additional register. Proper
  445. specification of this macro eliminates this overhead for such machines.
  446. </p>
  447. <p>This hook is never called with an invalid address.
  448. </p>
  449. <p>On machines where an address involving more than one register is as
  450. cheap as an address computation involving only one register, defining
  451. <code>TARGET_ADDRESS_COST</code> to reflect this can cause two registers to
  452. be live over a region of code where only one would have been if
  453. <code>TARGET_ADDRESS_COST</code> were not defined in that manner. This effect
  454. should be considered in the definition of this macro. Equivalent costs
  455. should probably only be given to addresses with different numbers of
  456. registers on machines with lots of registers.
  457. </p></dd></dl>
  458. <dl>
  459. <dt><a name="index-TARGET_005fINSN_005fCOST"></a>Target Hook: <em>int</em> <strong>TARGET_INSN_COST</strong> <em>(rtx_insn *<var>insn</var>, bool <var>speed</var>)</em></dt>
  460. <dd><p>This target hook describes the relative costs of RTL instructions.
  461. </p>
  462. <p>In implementing this hook, you can use the construct
  463. <code>COSTS_N_INSNS (<var>n</var>)</code> to specify a cost equal to <var>n</var> fast
  464. instructions.
  465. </p>
  466. <p>When optimizing for code size, i.e. when <code>speed</code> is
  467. false, this target hook should be used to estimate the relative
  468. size cost of an expression, again relative to <code>COSTS_N_INSNS</code>.
  469. </p></dd></dl>
  470. <dl>
  471. <dt><a name="index-TARGET_005fMAX_005fNOCE_005fIFCVT_005fSEQ_005fCOST"></a>Target Hook: <em>unsigned int</em> <strong>TARGET_MAX_NOCE_IFCVT_SEQ_COST</strong> <em>(edge <var>e</var>)</em></dt>
  472. <dd><p>This hook returns a value in the same units as <code>TARGET_RTX_COSTS</code>,
  473. giving the maximum acceptable cost for a sequence generated by the RTL
  474. if-conversion pass when conditional execution is not available.
  475. The RTL if-conversion pass attempts to convert conditional operations
  476. that would require a branch to a series of unconditional operations and
  477. <code>mov<var>mode</var>cc</code> insns. This hook returns the maximum cost of the
  478. unconditional instructions and the <code>mov<var>mode</var>cc</code> insns.
  479. RTL if-conversion is cancelled if the cost of the converted sequence
  480. is greater than the value returned by this hook.
  481. </p>
  482. <p><code>e</code> is the edge between the basic block containing the conditional
  483. branch to the basic block which would be executed if the condition
  484. were true.
  485. </p>
  486. <p>The default implementation of this hook uses the
  487. <code>max-rtl-if-conversion-[un]predictable</code> parameters if they are set,
  488. and uses a multiple of <code>BRANCH_COST</code> otherwise.
  489. </p></dd></dl>
  490. <dl>
  491. <dt><a name="index-TARGET_005fNOCE_005fCONVERSION_005fPROFITABLE_005fP"></a>Target Hook: <em>bool</em> <strong>TARGET_NOCE_CONVERSION_PROFITABLE_P</strong> <em>(rtx_insn *<var>seq</var>, struct noce_if_info *<var>if_info</var>)</em></dt>
  492. <dd><p>This hook returns true if the instruction sequence <code>seq</code> is a good
  493. candidate as a replacement for the if-convertible sequence described in
  494. <code>if_info</code>.
  495. </p></dd></dl>
  496. <dl>
  497. <dt><a name="index-TARGET_005fNO_005fSPECULATION_005fIN_005fDELAY_005fSLOTS_005fP"></a>Target Hook: <em>bool</em> <strong>TARGET_NO_SPECULATION_IN_DELAY_SLOTS_P</strong> <em>(void)</em></dt>
  498. <dd><p>This predicate controls the use of the eager delay slot filler to disallow
  499. speculatively executed instructions being placed in delay slots. Targets
  500. such as certain MIPS architectures possess both branches with and without
  501. delay slots. As the eager delay slot filler can decrease performance,
  502. disabling it is beneficial when ordinary branches are available. Use of
  503. delay slot branches filled using the basic filler is often still desirable
  504. as the delay slot can hide a pipeline bubble.
  505. </p></dd></dl>
  506. <dl>
  507. <dt><a name="index-TARGET_005fESTIMATED_005fPOLY_005fVALUE"></a>Target Hook: <em>HOST_WIDE_INT</em> <strong>TARGET_ESTIMATED_POLY_VALUE</strong> <em>(poly_int64 <var>val</var>)</em></dt>
  508. <dd><p>Return an estimate of the runtime value of <var>val</var>, for use in
  509. things like cost calculations or profiling frequencies. The default
  510. implementation returns the lowest possible value of <var>val</var>.
  511. </p></dd></dl>
  512. <hr>
  513. <div class="header">
  514. <p>
  515. Next: <a href="Scheduling.html#Scheduling" accesskey="n" rel="next">Scheduling</a>, Previous: <a href="Condition-Code.html#Condition-Code" accesskey="p" rel="prev">Condition Code</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>
  516. </div>
  517. </body>
  518. </html>