Jump-Patterns.html 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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: Jump Patterns</title>
  20. <meta name="description" content="GNU Compiler Collection (GCC) Internals: Jump Patterns">
  21. <meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Jump Patterns">
  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="Machine-Desc.html#Machine-Desc" rel="up" title="Machine Desc">
  30. <link href="Looping-Patterns.html#Looping-Patterns" rel="next" title="Looping Patterns">
  31. <link href="Dependent-Patterns.html#Dependent-Patterns" rel="prev" title="Dependent Patterns">
  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="Jump-Patterns"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="Looping-Patterns.html#Looping-Patterns" accesskey="n" rel="next">Looping Patterns</a>, Previous: <a href="Dependent-Patterns.html#Dependent-Patterns" accesskey="p" rel="prev">Dependent Patterns</a>, Up: <a href="Machine-Desc.html#Machine-Desc" accesskey="u" rel="up">Machine Desc</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="Defining-Jump-Instruction-Patterns"></a>
  69. <h3 class="section">16.12 Defining Jump Instruction Patterns</h3>
  70. <a name="index-jump-instruction-patterns"></a>
  71. <a name="index-defining-jump-instruction-patterns"></a>
  72. <p>GCC does not assume anything about how the machine realizes jumps.
  73. The machine description should define a single pattern, usually
  74. a <code>define_expand</code>, which expands to all the required insns.
  75. </p>
  76. <p>Usually, this would be a comparison insn to set the condition code
  77. and a separate branch insn testing the condition code and branching
  78. or not according to its value. For many machines, however,
  79. separating compares and branches is limiting, which is why the
  80. more flexible approach with one <code>define_expand</code> is used in GCC.
  81. The machine description becomes clearer for architectures that
  82. have compare-and-branch instructions but no condition code. It also
  83. works better when different sets of comparison operators are supported
  84. by different kinds of conditional branches (e.g. integer vs. floating-point),
  85. or by conditional branches with respect to conditional stores.
  86. </p>
  87. <p>Two separate insns are always used if the machine description represents
  88. a condition code register using the legacy RTL expression <code>(cc0)</code>,
  89. and on most machines that use a separate condition code register
  90. (see <a href="Condition-Code.html#Condition-Code">Condition Code</a>). For machines that use <code>(cc0)</code>, in
  91. fact, the set and use of the condition code must be separate and
  92. adjacent<a name="DOCF4" href="#FOOT4"><sup>4</sup></a>, thus
  93. allowing flags in <code>cc_status</code> to be used (see <a href="Condition-Code.html#Condition-Code">Condition Code</a>) and
  94. so that the comparison and branch insns could be located from each other
  95. by using the functions <code>prev_cc0_setter</code> and <code>next_cc0_user</code>.
  96. </p>
  97. <p>Even in this case having a single entry point for conditional branches
  98. is advantageous, because it handles equally well the case where a single
  99. comparison instruction records the results of both signed and unsigned
  100. comparison of the given operands (with the branch insns coming in distinct
  101. signed and unsigned flavors) as in the x86 or SPARC, and the case where
  102. there are distinct signed and unsigned compare instructions and only
  103. one set of conditional branch instructions as in the PowerPC.
  104. </p>
  105. <div class="footnote">
  106. <hr>
  107. <h4 class="footnotes-heading">Footnotes</h4>
  108. <h3><a name="FOOT4" href="#DOCF4">(4)</a></h3>
  109. <p><code>note</code> insns can separate them, though.</p>
  110. </div>
  111. <hr>
  112. <div class="header">
  113. <p>
  114. Next: <a href="Looping-Patterns.html#Looping-Patterns" accesskey="n" rel="next">Looping Patterns</a>, Previous: <a href="Dependent-Patterns.html#Dependent-Patterns" accesskey="p" rel="prev">Dependent Patterns</a>, Up: <a href="Machine-Desc.html#Machine-Desc" accesskey="u" rel="up">Machine Desc</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>
  115. </div>
  116. </body>
  117. </html>