Delay-Slots.html 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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: Delay Slots</title>
  20. <meta name="description" content="GNU Compiler Collection (GCC) Internals: Delay Slots">
  21. <meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Delay Slots">
  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="Insn-Attributes.html#Insn-Attributes" rel="up" title="Insn Attributes">
  30. <link href="Processor-pipeline-description.html#Processor-pipeline-description" rel="next" title="Processor pipeline description">
  31. <link href="Mnemonic-Attribute.html#Mnemonic-Attribute" rel="prev" title="Mnemonic Attribute">
  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="Delay-Slots"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="Processor-pipeline-description.html#Processor-pipeline-description" accesskey="n" rel="next">Processor pipeline description</a>, Previous: <a href="Mnemonic-Attribute.html#Mnemonic-Attribute" accesskey="p" rel="prev">Mnemonic Attribute</a>, Up: <a href="Insn-Attributes.html#Insn-Attributes" accesskey="u" rel="up">Insn Attributes</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="Delay-Slot-Scheduling"></a>
  69. <h4 class="subsection">16.19.8 Delay Slot Scheduling</h4>
  70. <a name="index-delay-slots_002c-defining"></a>
  71. <p>The insn attribute mechanism can be used to specify the requirements for
  72. delay slots, if any, on a target machine. An instruction is said to
  73. require a <em>delay slot</em> if some instructions that are physically
  74. after the instruction are executed as if they were located before it.
  75. Classic examples are branch and call instructions, which often execute
  76. the following instruction before the branch or call is performed.
  77. </p>
  78. <p>On some machines, conditional branch instructions can optionally
  79. <em>annul</em> instructions in the delay slot. This means that the
  80. instruction will not be executed for certain branch outcomes. Both
  81. instructions that annul if the branch is true and instructions that
  82. annul if the branch is false are supported.
  83. </p>
  84. <p>Delay slot scheduling differs from instruction scheduling in that
  85. determining whether an instruction needs a delay slot is dependent only
  86. on the type of instruction being generated, not on data flow between the
  87. instructions. See the next section for a discussion of data-dependent
  88. instruction scheduling.
  89. </p>
  90. <a name="index-define_005fdelay"></a>
  91. <p>The requirement of an insn needing one or more delay slots is indicated
  92. via the <code>define_delay</code> expression. It has the following form:
  93. </p>
  94. <div class="smallexample">
  95. <pre class="smallexample">(define_delay <var>test</var>
  96. [<var>delay-1</var> <var>annul-true-1</var> <var>annul-false-1</var>
  97. <var>delay-2</var> <var>annul-true-2</var> <var>annul-false-2</var>
  98. &hellip;])
  99. </pre></div>
  100. <p><var>test</var> is an attribute test that indicates whether this
  101. <code>define_delay</code> applies to a particular insn. If so, the number of
  102. required delay slots is determined by the length of the vector specified
  103. as the second argument. An insn placed in delay slot <var>n</var> must
  104. satisfy attribute test <var>delay-n</var>. <var>annul-true-n</var> is an
  105. attribute test that specifies which insns may be annulled if the branch
  106. is true. Similarly, <var>annul-false-n</var> specifies which insns in the
  107. delay slot may be annulled if the branch is false. If annulling is not
  108. supported for that delay slot, <code>(nil)</code> should be coded.
  109. </p>
  110. <p>For example, in the common case where branch and call insns require
  111. a single delay slot, which may contain any insn other than a branch or
  112. call, the following would be placed in the <samp>md</samp> file:
  113. </p>
  114. <div class="smallexample">
  115. <pre class="smallexample">(define_delay (eq_attr &quot;type&quot; &quot;branch,call&quot;)
  116. [(eq_attr &quot;type&quot; &quot;!branch,call&quot;) (nil) (nil)])
  117. </pre></div>
  118. <p>Multiple <code>define_delay</code> expressions may be specified. In this
  119. case, each such expression specifies different delay slot requirements
  120. and there must be no insn for which tests in two <code>define_delay</code>
  121. expressions are both true.
  122. </p>
  123. <p>For example, if we have a machine that requires one delay slot for branches
  124. but two for calls, no delay slot can contain a branch or call insn,
  125. and any valid insn in the delay slot for the branch can be annulled if the
  126. branch is true, we might represent this as follows:
  127. </p>
  128. <div class="smallexample">
  129. <pre class="smallexample">(define_delay (eq_attr &quot;type&quot; &quot;branch&quot;)
  130. [(eq_attr &quot;type&quot; &quot;!branch,call&quot;)
  131. (eq_attr &quot;type&quot; &quot;!branch,call&quot;)
  132. (nil)])
  133. (define_delay (eq_attr &quot;type&quot; &quot;call&quot;)
  134. [(eq_attr &quot;type&quot; &quot;!branch,call&quot;) (nil) (nil)
  135. (eq_attr &quot;type&quot; &quot;!branch,call&quot;) (nil) (nil)])
  136. </pre></div>
  137. <hr>
  138. <div class="header">
  139. <p>
  140. Next: <a href="Processor-pipeline-description.html#Processor-pipeline-description" accesskey="n" rel="next">Processor pipeline description</a>, Previous: <a href="Mnemonic-Attribute.html#Mnemonic-Attribute" accesskey="p" rel="prev">Mnemonic Attribute</a>, Up: <a href="Insn-Attributes.html#Insn-Attributes" accesskey="u" rel="up">Insn Attributes</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>
  141. </div>
  142. </body>
  143. </html>