Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

600 lines
34KB

  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>Scheduling (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Scheduling (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Scheduling (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="Sections.html#Sections" rel="next" title="Sections">
  31. <link href="Costs.html#Costs" rel="prev" title="Costs">
  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="Scheduling"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Sections.html#Sections" accesskey="n" rel="next">Sections</a>, Previous: <a href="Costs.html#Costs" accesskey="p" rel="prev">Costs</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="Adjusting-the-Instruction-Scheduler"></a>
  68. <h3 class="section">18.17 Adjusting the Instruction Scheduler</h3>
  69. <p>The instruction scheduler may need a fair amount of machine-specific
  70. adjustment in order to produce good code. GCC provides several target
  71. hooks for this purpose. It is usually enough to define just a few of
  72. them: try the first ones in this list first.
  73. </p>
  74. <dl>
  75. <dt><a name="index-TARGET_005fSCHED_005fISSUE_005fRATE"></a>Target Hook: <em>int</em> <strong>TARGET_SCHED_ISSUE_RATE</strong> <em>(void)</em></dt>
  76. <dd><p>This hook returns the maximum number of instructions that can ever
  77. issue at the same time on the target machine. The default is one.
  78. Although the insn scheduler can define itself the possibility of issue
  79. an insn on the same cycle, the value can serve as an additional
  80. constraint to issue insns on the same simulated processor cycle (see
  81. hooks &lsquo;<samp>TARGET_SCHED_REORDER</samp>&rsquo; and &lsquo;<samp>TARGET_SCHED_REORDER2</samp>&rsquo;).
  82. This value must be constant over the entire compilation. If you need
  83. it to vary depending on what the instructions are, you must use
  84. &lsquo;<samp>TARGET_SCHED_VARIABLE_ISSUE</samp>&rsquo;.
  85. </p></dd></dl>
  86. <dl>
  87. <dt><a name="index-TARGET_005fSCHED_005fVARIABLE_005fISSUE"></a>Target Hook: <em>int</em> <strong>TARGET_SCHED_VARIABLE_ISSUE</strong> <em>(FILE *<var>file</var>, int <var>verbose</var>, rtx_insn *<var>insn</var>, int <var>more</var>)</em></dt>
  88. <dd><p>This hook is executed by the scheduler after it has scheduled an insn
  89. from the ready list. It should return the number of insns which can
  90. still be issued in the current cycle. The default is
  91. &lsquo;<samp><var>more</var>&nbsp;<span class="nolinebreak">-</span>&nbsp;1<!-- /@w --></samp>&rsquo; for insns other than <code>CLOBBER</code> and
  92. <code>USE</code>, which normally are not counted against the issue rate.
  93. You should define this hook if some insns take more machine resources
  94. than others, so that fewer insns can follow them in the same cycle.
  95. <var>file</var> is either a null pointer, or a stdio stream to write any
  96. debug output to. <var>verbose</var> is the verbose level provided by
  97. <samp>-fsched-verbose-<var>n</var></samp>. <var>insn</var> is the instruction that
  98. was scheduled.
  99. </p></dd></dl>
  100. <dl>
  101. <dt><a name="index-TARGET_005fSCHED_005fADJUST_005fCOST"></a>Target Hook: <em>int</em> <strong>TARGET_SCHED_ADJUST_COST</strong> <em>(rtx_insn *<var>insn</var>, int <var>dep_type1</var>, rtx_insn *<var>dep_insn</var>, int <var>cost</var>, unsigned int <var>dw</var>)</em></dt>
  102. <dd><p>This function corrects the value of <var>cost</var> based on the
  103. relationship between <var>insn</var> and <var>dep_insn</var> through a
  104. dependence of type dep_type, and strength <var>dw</var>. It should return the new
  105. value. The default is to make no adjustment to <var>cost</var>. This can be
  106. used for example to specify to the scheduler using the traditional pipeline
  107. description that an output- or anti-dependence does not incur the same cost
  108. as a data-dependence. If the scheduler using the automaton based pipeline
  109. description, the cost of anti-dependence is zero and the cost of
  110. output-dependence is maximum of one and the difference of latency
  111. times of the first and the second insns. If these values are not
  112. acceptable, you could use the hook to modify them too. See also
  113. see <a href="Processor-pipeline-description.html#Processor-pipeline-description">Processor pipeline description</a>.
  114. </p></dd></dl>
  115. <dl>
  116. <dt><a name="index-TARGET_005fSCHED_005fADJUST_005fPRIORITY"></a>Target Hook: <em>int</em> <strong>TARGET_SCHED_ADJUST_PRIORITY</strong> <em>(rtx_insn *<var>insn</var>, int <var>priority</var>)</em></dt>
  117. <dd><p>This hook adjusts the integer scheduling priority <var>priority</var> of
  118. <var>insn</var>. It should return the new priority. Increase the priority to
  119. execute <var>insn</var> earlier, reduce the priority to execute <var>insn</var>
  120. later. Do not define this hook if you do not need to adjust the
  121. scheduling priorities of insns.
  122. </p></dd></dl>
  123. <dl>
  124. <dt><a name="index-TARGET_005fSCHED_005fREORDER"></a>Target Hook: <em>int</em> <strong>TARGET_SCHED_REORDER</strong> <em>(FILE *<var>file</var>, int <var>verbose</var>, rtx_insn **<var>ready</var>, int *<var>n_readyp</var>, int <var>clock</var>)</em></dt>
  125. <dd><p>This hook is executed by the scheduler after it has scheduled the ready
  126. list, to allow the machine description to reorder it (for example to
  127. combine two small instructions together on &lsquo;<samp>VLIW</samp>&rsquo; machines).
  128. <var>file</var> is either a null pointer, or a stdio stream to write any
  129. debug output to. <var>verbose</var> is the verbose level provided by
  130. <samp>-fsched-verbose-<var>n</var></samp>. <var>ready</var> is a pointer to the ready
  131. list of instructions that are ready to be scheduled. <var>n_readyp</var> is
  132. a pointer to the number of elements in the ready list. The scheduler
  133. reads the ready list in reverse order, starting with
  134. <var>ready</var>[<var>*n_readyp</var> - 1] and going to <var>ready</var>[0]. <var>clock</var>
  135. is the timer tick of the scheduler. You may modify the ready list and
  136. the number of ready insns. The return value is the number of insns that
  137. can issue this cycle; normally this is just <code>issue_rate</code>. See also
  138. &lsquo;<samp>TARGET_SCHED_REORDER2</samp>&rsquo;.
  139. </p></dd></dl>
  140. <dl>
  141. <dt><a name="index-TARGET_005fSCHED_005fREORDER2"></a>Target Hook: <em>int</em> <strong>TARGET_SCHED_REORDER2</strong> <em>(FILE *<var>file</var>, int <var>verbose</var>, rtx_insn **<var>ready</var>, int *<var>n_readyp</var>, int <var>clock</var>)</em></dt>
  142. <dd><p>Like &lsquo;<samp>TARGET_SCHED_REORDER</samp>&rsquo;, but called at a different time. That
  143. function is called whenever the scheduler starts a new cycle. This one
  144. is called once per iteration over a cycle, immediately after
  145. &lsquo;<samp>TARGET_SCHED_VARIABLE_ISSUE</samp>&rsquo;; it can reorder the ready list and
  146. return the number of insns to be scheduled in the same cycle. Defining
  147. this hook can be useful if there are frequent situations where
  148. scheduling one insn causes other insns to become ready in the same
  149. cycle. These other insns can then be taken into account properly.
  150. </p></dd></dl>
  151. <dl>
  152. <dt><a name="index-TARGET_005fSCHED_005fMACRO_005fFUSION_005fP"></a>Target Hook: <em>bool</em> <strong>TARGET_SCHED_MACRO_FUSION_P</strong> <em>(void)</em></dt>
  153. <dd><p>This hook is used to check whether target platform supports macro fusion.
  154. </p></dd></dl>
  155. <dl>
  156. <dt><a name="index-TARGET_005fSCHED_005fMACRO_005fFUSION_005fPAIR_005fP"></a>Target Hook: <em>bool</em> <strong>TARGET_SCHED_MACRO_FUSION_PAIR_P</strong> <em>(rtx_insn *<var>prev</var>, rtx_insn *<var>curr</var>)</em></dt>
  157. <dd><p>This hook is used to check whether two insns should be macro fused for
  158. a target microarchitecture. If this hook returns true for the given insn pair
  159. (<var>prev</var> and <var>curr</var>), the scheduler will put them into a sched
  160. group, and they will not be scheduled apart. The two insns will be either
  161. two SET insns or a compare and a conditional jump and this hook should
  162. validate any dependencies needed to fuse the two insns together.
  163. </p></dd></dl>
  164. <dl>
  165. <dt><a name="index-TARGET_005fSCHED_005fDEPENDENCIES_005fEVALUATION_005fHOOK"></a>Target Hook: <em>void</em> <strong>TARGET_SCHED_DEPENDENCIES_EVALUATION_HOOK</strong> <em>(rtx_insn *<var>head</var>, rtx_insn *<var>tail</var>)</em></dt>
  166. <dd><p>This hook is called after evaluation forward dependencies of insns in
  167. chain given by two parameter values (<var>head</var> and <var>tail</var>
  168. correspondingly) but before insns scheduling of the insn chain. For
  169. example, it can be used for better insn classification if it requires
  170. analysis of dependencies. This hook can use backward and forward
  171. dependencies of the insn scheduler because they are already
  172. calculated.
  173. </p></dd></dl>
  174. <dl>
  175. <dt><a name="index-TARGET_005fSCHED_005fINIT"></a>Target Hook: <em>void</em> <strong>TARGET_SCHED_INIT</strong> <em>(FILE *<var>file</var>, int <var>verbose</var>, int <var>max_ready</var>)</em></dt>
  176. <dd><p>This hook is executed by the scheduler at the beginning of each block of
  177. instructions that are to be scheduled. <var>file</var> is either a null
  178. pointer, or a stdio stream to write any debug output to. <var>verbose</var>
  179. is the verbose level provided by <samp>-fsched-verbose-<var>n</var></samp>.
  180. <var>max_ready</var> is the maximum number of insns in the current scheduling
  181. region that can be live at the same time. This can be used to allocate
  182. scratch space if it is needed, e.g. by &lsquo;<samp>TARGET_SCHED_REORDER</samp>&rsquo;.
  183. </p></dd></dl>
  184. <dl>
  185. <dt><a name="index-TARGET_005fSCHED_005fFINISH"></a>Target Hook: <em>void</em> <strong>TARGET_SCHED_FINISH</strong> <em>(FILE *<var>file</var>, int <var>verbose</var>)</em></dt>
  186. <dd><p>This hook is executed by the scheduler at the end of each block of
  187. instructions that are to be scheduled. It can be used to perform
  188. cleanup of any actions done by the other scheduling hooks. <var>file</var>
  189. is either a null pointer, or a stdio stream to write any debug output
  190. to. <var>verbose</var> is the verbose level provided by
  191. <samp>-fsched-verbose-<var>n</var></samp>.
  192. </p></dd></dl>
  193. <dl>
  194. <dt><a name="index-TARGET_005fSCHED_005fINIT_005fGLOBAL"></a>Target Hook: <em>void</em> <strong>TARGET_SCHED_INIT_GLOBAL</strong> <em>(FILE *<var>file</var>, int <var>verbose</var>, int <var>old_max_uid</var>)</em></dt>
  195. <dd><p>This hook is executed by the scheduler after function level initializations.
  196. <var>file</var> is either a null pointer, or a stdio stream to write any debug output to.
  197. <var>verbose</var> is the verbose level provided by <samp>-fsched-verbose-<var>n</var></samp>.
  198. <var>old_max_uid</var> is the maximum insn uid when scheduling begins.
  199. </p></dd></dl>
  200. <dl>
  201. <dt><a name="index-TARGET_005fSCHED_005fFINISH_005fGLOBAL"></a>Target Hook: <em>void</em> <strong>TARGET_SCHED_FINISH_GLOBAL</strong> <em>(FILE *<var>file</var>, int <var>verbose</var>)</em></dt>
  202. <dd><p>This is the cleanup hook corresponding to <code>TARGET_SCHED_INIT_GLOBAL</code>.
  203. <var>file</var> is either a null pointer, or a stdio stream to write any debug output to.
  204. <var>verbose</var> is the verbose level provided by <samp>-fsched-verbose-<var>n</var></samp>.
  205. </p></dd></dl>
  206. <dl>
  207. <dt><a name="index-TARGET_005fSCHED_005fDFA_005fPRE_005fCYCLE_005fINSN"></a>Target Hook: <em>rtx</em> <strong>TARGET_SCHED_DFA_PRE_CYCLE_INSN</strong> <em>(void)</em></dt>
  208. <dd><p>The hook returns an RTL insn. The automaton state used in the
  209. pipeline hazard recognizer is changed as if the insn were scheduled
  210. when the new simulated processor cycle starts. Usage of the hook may
  211. simplify the automaton pipeline description for some <acronym>VLIW</acronym>
  212. processors. If the hook is defined, it is used only for the automaton
  213. based pipeline description. The default is not to change the state
  214. when the new simulated processor cycle starts.
  215. </p></dd></dl>
  216. <dl>
  217. <dt><a name="index-TARGET_005fSCHED_005fINIT_005fDFA_005fPRE_005fCYCLE_005fINSN"></a>Target Hook: <em>void</em> <strong>TARGET_SCHED_INIT_DFA_PRE_CYCLE_INSN</strong> <em>(void)</em></dt>
  218. <dd><p>The hook can be used to initialize data used by the previous hook.
  219. </p></dd></dl>
  220. <dl>
  221. <dt><a name="index-TARGET_005fSCHED_005fDFA_005fPOST_005fCYCLE_005fINSN"></a>Target Hook: <em>rtx_insn *</em> <strong>TARGET_SCHED_DFA_POST_CYCLE_INSN</strong> <em>(void)</em></dt>
  222. <dd><p>The hook is analogous to &lsquo;<samp>TARGET_SCHED_DFA_PRE_CYCLE_INSN</samp>&rsquo; but used
  223. to changed the state as if the insn were scheduled when the new
  224. simulated processor cycle finishes.
  225. </p></dd></dl>
  226. <dl>
  227. <dt><a name="index-TARGET_005fSCHED_005fINIT_005fDFA_005fPOST_005fCYCLE_005fINSN"></a>Target Hook: <em>void</em> <strong>TARGET_SCHED_INIT_DFA_POST_CYCLE_INSN</strong> <em>(void)</em></dt>
  228. <dd><p>The hook is analogous to &lsquo;<samp>TARGET_SCHED_INIT_DFA_PRE_CYCLE_INSN</samp>&rsquo; but
  229. used to initialize data used by the previous hook.
  230. </p></dd></dl>
  231. <dl>
  232. <dt><a name="index-TARGET_005fSCHED_005fDFA_005fPRE_005fADVANCE_005fCYCLE"></a>Target Hook: <em>void</em> <strong>TARGET_SCHED_DFA_PRE_ADVANCE_CYCLE</strong> <em>(void)</em></dt>
  233. <dd><p>The hook to notify target that the current simulated cycle is about to finish.
  234. The hook is analogous to &lsquo;<samp>TARGET_SCHED_DFA_PRE_CYCLE_INSN</samp>&rsquo; but used
  235. to change the state in more complicated situations - e.g., when advancing
  236. state on a single insn is not enough.
  237. </p></dd></dl>
  238. <dl>
  239. <dt><a name="index-TARGET_005fSCHED_005fDFA_005fPOST_005fADVANCE_005fCYCLE"></a>Target Hook: <em>void</em> <strong>TARGET_SCHED_DFA_POST_ADVANCE_CYCLE</strong> <em>(void)</em></dt>
  240. <dd><p>The hook to notify target that new simulated cycle has just started.
  241. The hook is analogous to &lsquo;<samp>TARGET_SCHED_DFA_POST_CYCLE_INSN</samp>&rsquo; but used
  242. to change the state in more complicated situations - e.g., when advancing
  243. state on a single insn is not enough.
  244. </p></dd></dl>
  245. <dl>
  246. <dt><a name="index-TARGET_005fSCHED_005fFIRST_005fCYCLE_005fMULTIPASS_005fDFA_005fLOOKAHEAD"></a>Target Hook: <em>int</em> <strong>TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD</strong> <em>(void)</em></dt>
  247. <dd><p>This hook controls better choosing an insn from the ready insn queue
  248. for the <acronym>DFA</acronym>-based insn scheduler. Usually the scheduler
  249. chooses the first insn from the queue. If the hook returns a positive
  250. value, an additional scheduler code tries all permutations of
  251. &lsquo;<samp>TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD ()</samp>&rsquo;
  252. subsequent ready insns to choose an insn whose issue will result in
  253. maximal number of issued insns on the same cycle. For the
  254. <acronym>VLIW</acronym> processor, the code could actually solve the problem of
  255. packing simple insns into the <acronym>VLIW</acronym> insn. Of course, if the
  256. rules of <acronym>VLIW</acronym> packing are described in the automaton.
  257. </p>
  258. <p>This code also could be used for superscalar <acronym>RISC</acronym>
  259. processors. Let us consider a superscalar <acronym>RISC</acronym> processor
  260. with 3 pipelines. Some insns can be executed in pipelines <var>A</var> or
  261. <var>B</var>, some insns can be executed only in pipelines <var>B</var> or
  262. <var>C</var>, and one insn can be executed in pipeline <var>B</var>. The
  263. processor may issue the 1st insn into <var>A</var> and the 2nd one into
  264. <var>B</var>. In this case, the 3rd insn will wait for freeing <var>B</var>
  265. until the next cycle. If the scheduler issues the 3rd insn the first,
  266. the processor could issue all 3 insns per cycle.
  267. </p>
  268. <p>Actually this code demonstrates advantages of the automaton based
  269. pipeline hazard recognizer. We try quickly and easy many insn
  270. schedules to choose the best one.
  271. </p>
  272. <p>The default is no multipass scheduling.
  273. </p></dd></dl>
  274. <dl>
  275. <dt><a name="index-TARGET_005fSCHED_005fFIRST_005fCYCLE_005fMULTIPASS_005fDFA_005fLOOKAHEAD_005fGUARD"></a>Target Hook: <em>int</em> <strong>TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD</strong> <em>(rtx_insn *<var>insn</var>, int <var>ready_index</var>)</em></dt>
  276. <dd>
  277. <p>This hook controls what insns from the ready insn queue will be
  278. considered for the multipass insn scheduling. If the hook returns
  279. zero for <var>insn</var>, the insn will be considered in multipass scheduling.
  280. Positive return values will remove <var>insn</var> from consideration on
  281. the current round of multipass scheduling.
  282. Negative return values will remove <var>insn</var> from consideration for given
  283. number of cycles.
  284. Backends should be careful about returning non-zero for highest priority
  285. instruction at position 0 in the ready list. <var>ready_index</var> is passed
  286. to allow backends make correct judgements.
  287. </p>
  288. <p>The default is that any ready insns can be chosen to be issued.
  289. </p></dd></dl>
  290. <dl>
  291. <dt><a name="index-TARGET_005fSCHED_005fFIRST_005fCYCLE_005fMULTIPASS_005fBEGIN"></a>Target Hook: <em>void</em> <strong>TARGET_SCHED_FIRST_CYCLE_MULTIPASS_BEGIN</strong> <em>(void *<var>data</var>, signed char *<var>ready_try</var>, int <var>n_ready</var>, bool <var>first_cycle_insn_p</var>)</em></dt>
  292. <dd><p>This hook prepares the target backend for a new round of multipass
  293. scheduling.
  294. </p></dd></dl>
  295. <dl>
  296. <dt><a name="index-TARGET_005fSCHED_005fFIRST_005fCYCLE_005fMULTIPASS_005fISSUE"></a>Target Hook: <em>void</em> <strong>TARGET_SCHED_FIRST_CYCLE_MULTIPASS_ISSUE</strong> <em>(void *<var>data</var>, signed char *<var>ready_try</var>, int <var>n_ready</var>, rtx_insn *<var>insn</var>, const void *<var>prev_data</var>)</em></dt>
  297. <dd><p>This hook is called when multipass scheduling evaluates instruction INSN.
  298. </p></dd></dl>
  299. <dl>
  300. <dt><a name="index-TARGET_005fSCHED_005fFIRST_005fCYCLE_005fMULTIPASS_005fBACKTRACK"></a>Target Hook: <em>void</em> <strong>TARGET_SCHED_FIRST_CYCLE_MULTIPASS_BACKTRACK</strong> <em>(const void *<var>data</var>, signed char *<var>ready_try</var>, int <var>n_ready</var>)</em></dt>
  301. <dd><p>This is called when multipass scheduling backtracks from evaluation of
  302. an instruction.
  303. </p></dd></dl>
  304. <dl>
  305. <dt><a name="index-TARGET_005fSCHED_005fFIRST_005fCYCLE_005fMULTIPASS_005fEND"></a>Target Hook: <em>void</em> <strong>TARGET_SCHED_FIRST_CYCLE_MULTIPASS_END</strong> <em>(const void *<var>data</var>)</em></dt>
  306. <dd><p>This hook notifies the target about the result of the concluded current
  307. round of multipass scheduling.
  308. </p></dd></dl>
  309. <dl>
  310. <dt><a name="index-TARGET_005fSCHED_005fFIRST_005fCYCLE_005fMULTIPASS_005fINIT"></a>Target Hook: <em>void</em> <strong>TARGET_SCHED_FIRST_CYCLE_MULTIPASS_INIT</strong> <em>(void *<var>data</var>)</em></dt>
  311. <dd><p>This hook initializes target-specific data used in multipass scheduling.
  312. </p></dd></dl>
  313. <dl>
  314. <dt><a name="index-TARGET_005fSCHED_005fFIRST_005fCYCLE_005fMULTIPASS_005fFINI"></a>Target Hook: <em>void</em> <strong>TARGET_SCHED_FIRST_CYCLE_MULTIPASS_FINI</strong> <em>(void *<var>data</var>)</em></dt>
  315. <dd><p>This hook finalizes target-specific data used in multipass scheduling.
  316. </p></dd></dl>
  317. <dl>
  318. <dt><a name="index-TARGET_005fSCHED_005fDFA_005fNEW_005fCYCLE"></a>Target Hook: <em>int</em> <strong>TARGET_SCHED_DFA_NEW_CYCLE</strong> <em>(FILE *<var>dump</var>, int <var>verbose</var>, rtx_insn *<var>insn</var>, int <var>last_clock</var>, int <var>clock</var>, int *<var>sort_p</var>)</em></dt>
  319. <dd><p>This hook is called by the insn scheduler before issuing <var>insn</var>
  320. on cycle <var>clock</var>. If the hook returns nonzero,
  321. <var>insn</var> is not issued on this processor cycle. Instead,
  322. the processor cycle is advanced. If *<var>sort_p</var>
  323. is zero, the insn ready queue is not sorted on the new cycle
  324. start as usually. <var>dump</var> and <var>verbose</var> specify the file and
  325. verbosity level to use for debugging output.
  326. <var>last_clock</var> and <var>clock</var> are, respectively, the
  327. processor cycle on which the previous insn has been issued,
  328. and the current processor cycle.
  329. </p></dd></dl>
  330. <dl>
  331. <dt><a name="index-TARGET_005fSCHED_005fIS_005fCOSTLY_005fDEPENDENCE"></a>Target Hook: <em>bool</em> <strong>TARGET_SCHED_IS_COSTLY_DEPENDENCE</strong> <em>(struct _dep *<var>_dep</var>, int <var>cost</var>, int <var>distance</var>)</em></dt>
  332. <dd><p>This hook is used to define which dependences are considered costly by
  333. the target, so costly that it is not advisable to schedule the insns that
  334. are involved in the dependence too close to one another. The parameters
  335. to this hook are as follows: The first parameter <var>_dep</var> is the dependence
  336. being evaluated. The second parameter <var>cost</var> is the cost of the
  337. dependence as estimated by the scheduler, and the third
  338. parameter <var>distance</var> is the distance in cycles between the two insns.
  339. The hook returns <code>true</code> if considering the distance between the two
  340. insns the dependence between them is considered costly by the target,
  341. and <code>false</code> otherwise.
  342. </p>
  343. <p>Defining this hook can be useful in multiple-issue out-of-order machines,
  344. where (a) it&rsquo;s practically hopeless to predict the actual data/resource
  345. delays, however: (b) there&rsquo;s a better chance to predict the actual grouping
  346. that will be formed, and (c) correctly emulating the grouping can be very
  347. important. In such targets one may want to allow issuing dependent insns
  348. closer to one another&mdash;i.e., closer than the dependence distance; however,
  349. not in cases of &ldquo;costly dependences&rdquo;, which this hooks allows to define.
  350. </p></dd></dl>
  351. <dl>
  352. <dt><a name="index-TARGET_005fSCHED_005fH_005fI_005fD_005fEXTENDED"></a>Target Hook: <em>void</em> <strong>TARGET_SCHED_H_I_D_EXTENDED</strong> <em>(void)</em></dt>
  353. <dd><p>This hook is called by the insn scheduler after emitting a new instruction to
  354. the instruction stream. The hook notifies a target backend to extend its
  355. per instruction data structures.
  356. </p></dd></dl>
  357. <dl>
  358. <dt><a name="index-TARGET_005fSCHED_005fALLOC_005fSCHED_005fCONTEXT"></a>Target Hook: <em>void *</em> <strong>TARGET_SCHED_ALLOC_SCHED_CONTEXT</strong> <em>(void)</em></dt>
  359. <dd><p>Return a pointer to a store large enough to hold target scheduling context.
  360. </p></dd></dl>
  361. <dl>
  362. <dt><a name="index-TARGET_005fSCHED_005fINIT_005fSCHED_005fCONTEXT"></a>Target Hook: <em>void</em> <strong>TARGET_SCHED_INIT_SCHED_CONTEXT</strong> <em>(void *<var>tc</var>, bool <var>clean_p</var>)</em></dt>
  363. <dd><p>Initialize store pointed to by <var>tc</var> to hold target scheduling context.
  364. It <var>clean_p</var> is true then initialize <var>tc</var> as if scheduler is at the
  365. beginning of the block. Otherwise, copy the current context into <var>tc</var>.
  366. </p></dd></dl>
  367. <dl>
  368. <dt><a name="index-TARGET_005fSCHED_005fSET_005fSCHED_005fCONTEXT"></a>Target Hook: <em>void</em> <strong>TARGET_SCHED_SET_SCHED_CONTEXT</strong> <em>(void *<var>tc</var>)</em></dt>
  369. <dd><p>Copy target scheduling context pointed to by <var>tc</var> to the current context.
  370. </p></dd></dl>
  371. <dl>
  372. <dt><a name="index-TARGET_005fSCHED_005fCLEAR_005fSCHED_005fCONTEXT"></a>Target Hook: <em>void</em> <strong>TARGET_SCHED_CLEAR_SCHED_CONTEXT</strong> <em>(void *<var>tc</var>)</em></dt>
  373. <dd><p>Deallocate internal data in target scheduling context pointed to by <var>tc</var>.
  374. </p></dd></dl>
  375. <dl>
  376. <dt><a name="index-TARGET_005fSCHED_005fFREE_005fSCHED_005fCONTEXT"></a>Target Hook: <em>void</em> <strong>TARGET_SCHED_FREE_SCHED_CONTEXT</strong> <em>(void *<var>tc</var>)</em></dt>
  377. <dd><p>Deallocate a store for target scheduling context pointed to by <var>tc</var>.
  378. </p></dd></dl>
  379. <dl>
  380. <dt><a name="index-TARGET_005fSCHED_005fSPECULATE_005fINSN"></a>Target Hook: <em>int</em> <strong>TARGET_SCHED_SPECULATE_INSN</strong> <em>(rtx_insn *<var>insn</var>, unsigned int <var>dep_status</var>, rtx *<var>new_pat</var>)</em></dt>
  381. <dd><p>This hook is called by the insn scheduler when <var>insn</var> has only
  382. speculative dependencies and therefore can be scheduled speculatively.
  383. The hook is used to check if the pattern of <var>insn</var> has a speculative
  384. version and, in case of successful check, to generate that speculative
  385. pattern. The hook should return 1, if the instruction has a speculative form,
  386. or -1, if it doesn&rsquo;t. <var>request</var> describes the type of requested
  387. speculation. If the return value equals 1 then <var>new_pat</var> is assigned
  388. the generated speculative pattern.
  389. </p></dd></dl>
  390. <dl>
  391. <dt><a name="index-TARGET_005fSCHED_005fNEEDS_005fBLOCK_005fP"></a>Target Hook: <em>bool</em> <strong>TARGET_SCHED_NEEDS_BLOCK_P</strong> <em>(unsigned int <var>dep_status</var>)</em></dt>
  392. <dd><p>This hook is called by the insn scheduler during generation of recovery code
  393. for <var>insn</var>. It should return <code>true</code>, if the corresponding check
  394. instruction should branch to recovery code, or <code>false</code> otherwise.
  395. </p></dd></dl>
  396. <dl>
  397. <dt><a name="index-TARGET_005fSCHED_005fGEN_005fSPEC_005fCHECK"></a>Target Hook: <em>rtx</em> <strong>TARGET_SCHED_GEN_SPEC_CHECK</strong> <em>(rtx_insn *<var>insn</var>, rtx_insn *<var>label</var>, unsigned int <var>ds</var>)</em></dt>
  398. <dd><p>This hook is called by the insn scheduler to generate a pattern for recovery
  399. check instruction. If <var>mutate_p</var> is zero, then <var>insn</var> is a
  400. speculative instruction for which the check should be generated.
  401. <var>label</var> is either a label of a basic block, where recovery code should
  402. be emitted, or a null pointer, when requested check doesn&rsquo;t branch to
  403. recovery code (a simple check). If <var>mutate_p</var> is nonzero, then
  404. a pattern for a branchy check corresponding to a simple check denoted by
  405. <var>insn</var> should be generated. In this case <var>label</var> can&rsquo;t be null.
  406. </p></dd></dl>
  407. <dl>
  408. <dt><a name="index-TARGET_005fSCHED_005fSET_005fSCHED_005fFLAGS"></a>Target Hook: <em>void</em> <strong>TARGET_SCHED_SET_SCHED_FLAGS</strong> <em>(struct spec_info_def *<var>spec_info</var>)</em></dt>
  409. <dd><p>This hook is used by the insn scheduler to find out what features should be
  410. enabled/used.
  411. The structure *<var>spec_info</var> should be filled in by the target.
  412. The structure describes speculation types that can be used in the scheduler.
  413. </p></dd></dl>
  414. <dl>
  415. <dt><a name="index-TARGET_005fSCHED_005fCAN_005fSPECULATE_005fINSN"></a>Target Hook: <em>bool</em> <strong>TARGET_SCHED_CAN_SPECULATE_INSN</strong> <em>(rtx_insn *<var>insn</var>)</em></dt>
  416. <dd><p>Some instructions should never be speculated by the schedulers, usually
  417. because the instruction is too expensive to get this wrong. Often such
  418. instructions have long latency, and often they are not fully modeled in the
  419. pipeline descriptions. This hook should return <code>false</code> if <var>insn</var>
  420. should not be speculated.
  421. </p></dd></dl>
  422. <dl>
  423. <dt><a name="index-TARGET_005fSCHED_005fSMS_005fRES_005fMII"></a>Target Hook: <em>int</em> <strong>TARGET_SCHED_SMS_RES_MII</strong> <em>(struct ddg *<var>g</var>)</em></dt>
  424. <dd><p>This hook is called by the swing modulo scheduler to calculate a
  425. resource-based lower bound which is based on the resources available in
  426. the machine and the resources required by each instruction. The target
  427. backend can use <var>g</var> to calculate such bound. A very simple lower
  428. bound will be used in case this hook is not implemented: the total number
  429. of instructions divided by the issue rate.
  430. </p></dd></dl>
  431. <dl>
  432. <dt><a name="index-TARGET_005fSCHED_005fDISPATCH"></a>Target Hook: <em>bool</em> <strong>TARGET_SCHED_DISPATCH</strong> <em>(rtx_insn *<var>insn</var>, int <var>x</var>)</em></dt>
  433. <dd><p>This hook is called by Haifa Scheduler. It returns true if dispatch scheduling
  434. is supported in hardware and the condition specified in the parameter is true.
  435. </p></dd></dl>
  436. <dl>
  437. <dt><a name="index-TARGET_005fSCHED_005fDISPATCH_005fDO"></a>Target Hook: <em>void</em> <strong>TARGET_SCHED_DISPATCH_DO</strong> <em>(rtx_insn *<var>insn</var>, int <var>x</var>)</em></dt>
  438. <dd><p>This hook is called by Haifa Scheduler. It performs the operation specified
  439. in its second parameter.
  440. </p></dd></dl>
  441. <dl>
  442. <dt><a name="index-TARGET_005fSCHED_005fEXPOSED_005fPIPELINE"></a>Target Hook: <em>bool</em> <strong>TARGET_SCHED_EXPOSED_PIPELINE</strong></dt>
  443. <dd><p>True if the processor has an exposed pipeline, which means that not just
  444. the order of instructions is important for correctness when scheduling, but
  445. also the latencies of operations.
  446. </p></dd></dl>
  447. <dl>
  448. <dt><a name="index-TARGET_005fSCHED_005fREASSOCIATION_005fWIDTH"></a>Target Hook: <em>int</em> <strong>TARGET_SCHED_REASSOCIATION_WIDTH</strong> <em>(unsigned int <var>opc</var>, machine_mode <var>mode</var>)</em></dt>
  449. <dd><p>This hook is called by tree reassociator to determine a level of
  450. parallelism required in output calculations chain.
  451. </p></dd></dl>
  452. <dl>
  453. <dt><a name="index-TARGET_005fSCHED_005fFUSION_005fPRIORITY"></a>Target Hook: <em>void</em> <strong>TARGET_SCHED_FUSION_PRIORITY</strong> <em>(rtx_insn *<var>insn</var>, int <var>max_pri</var>, int *<var>fusion_pri</var>, int *<var>pri</var>)</em></dt>
  454. <dd><p>This hook is called by scheduling fusion pass. It calculates fusion
  455. priorities for each instruction passed in by parameter. The priorities
  456. are returned via pointer parameters.
  457. </p>
  458. <p><var>insn</var> is the instruction whose priorities need to be calculated.
  459. <var>max_pri</var> is the maximum priority can be returned in any cases.
  460. <var>fusion_pri</var> is the pointer parameter through which <var>insn</var>&rsquo;s
  461. fusion priority should be calculated and returned.
  462. <var>pri</var> is the pointer parameter through which <var>insn</var>&rsquo;s priority
  463. should be calculated and returned.
  464. </p>
  465. <p>Same <var>fusion_pri</var> should be returned for instructions which should
  466. be scheduled together. Different <var>pri</var> should be returned for
  467. instructions with same <var>fusion_pri</var>. <var>fusion_pri</var> is the major
  468. sort key, <var>pri</var> is the minor sort key. All instructions will be
  469. scheduled according to the two priorities. All priorities calculated
  470. should be between 0 (exclusive) and <var>max_pri</var> (inclusive). To avoid
  471. false dependencies, <var>fusion_pri</var> of instructions which need to be
  472. scheduled together should be smaller than <var>fusion_pri</var> of irrelevant
  473. instructions.
  474. </p>
  475. <p>Given below example:
  476. </p>
  477. <div class="smallexample">
  478. <pre class="smallexample"> ldr r10, [r1, 4]
  479. add r4, r4, r10
  480. ldr r15, [r2, 8]
  481. sub r5, r5, r15
  482. ldr r11, [r1, 0]
  483. add r4, r4, r11
  484. ldr r16, [r2, 12]
  485. sub r5, r5, r16
  486. </pre></div>
  487. <p>On targets like ARM/AArch64, the two pairs of consecutive loads should be
  488. merged. Since peephole2 pass can&rsquo;t help in this case unless consecutive
  489. loads are actually next to each other in instruction flow. That&rsquo;s where
  490. this scheduling fusion pass works. This hook calculates priority for each
  491. instruction based on its fustion type, like:
  492. </p>
  493. <div class="smallexample">
  494. <pre class="smallexample"> ldr r10, [r1, 4] ; fusion_pri=99, pri=96
  495. add r4, r4, r10 ; fusion_pri=100, pri=100
  496. ldr r15, [r2, 8] ; fusion_pri=98, pri=92
  497. sub r5, r5, r15 ; fusion_pri=100, pri=100
  498. ldr r11, [r1, 0] ; fusion_pri=99, pri=100
  499. add r4, r4, r11 ; fusion_pri=100, pri=100
  500. ldr r16, [r2, 12] ; fusion_pri=98, pri=88
  501. sub r5, r5, r16 ; fusion_pri=100, pri=100
  502. </pre></div>
  503. <p>Scheduling fusion pass then sorts all ready to issue instructions according
  504. to the priorities. As a result, instructions of same fusion type will be
  505. pushed together in instruction flow, like:
  506. </p>
  507. <div class="smallexample">
  508. <pre class="smallexample"> ldr r11, [r1, 0]
  509. ldr r10, [r1, 4]
  510. ldr r15, [r2, 8]
  511. ldr r16, [r2, 12]
  512. add r4, r4, r10
  513. sub r5, r5, r15
  514. add r4, r4, r11
  515. sub r5, r5, r16
  516. </pre></div>
  517. <p>Now peephole2 pass can simply merge the two pairs of loads.
  518. </p>
  519. <p>Since scheduling fusion pass relies on peephole2 to do real fusion
  520. work, it is only enabled by default when peephole2 is in effect.
  521. </p>
  522. <p>This is firstly introduced on ARM/AArch64 targets, please refer to
  523. the hook implementation for how different fusion types are supported.
  524. </p></dd></dl>
  525. <dl>
  526. <dt><a name="index-TARGET_005fEXPAND_005fDIVMOD_005fLIBFUNC"></a>Target Hook: <em>void</em> <strong>TARGET_EXPAND_DIVMOD_LIBFUNC</strong> <em>(rtx <var>libfunc</var>, machine_mode <var>mode</var>, rtx <var>op0</var>, rtx <var>op1</var>, rtx *<var>quot</var>, rtx *<var>rem</var>)</em></dt>
  527. <dd><p>Define this hook for enabling divmod transform if the port does not have
  528. hardware divmod insn but defines target-specific divmod libfuncs.
  529. </p></dd></dl>
  530. <hr>
  531. <div class="header">
  532. <p>
  533. Next: <a href="Sections.html#Sections" accesskey="n" rel="next">Sections</a>, Previous: <a href="Costs.html#Costs" accesskey="p" rel="prev">Costs</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>
  534. </div>
  535. </body>
  536. </html>