Mode-Switching.html 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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: Mode Switching</title>
  20. <meta name="description" content="GNU Compiler Collection (GCC) Internals: Mode Switching">
  21. <meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Mode Switching">
  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="Target-Attributes.html#Target-Attributes" rel="next" title="Target Attributes">
  31. <link href="Floating-Point.html#Floating-Point" rel="prev" title="Floating Point">
  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="Mode-Switching"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="Target-Attributes.html#Target-Attributes" accesskey="n" rel="next">Target Attributes</a>, Previous: <a href="Floating-Point.html#Floating-Point" accesskey="p" rel="prev">Floating Point</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="Mode-Switching-Instructions"></a>
  69. <h3 class="section">17.23 Mode Switching Instructions</h3>
  70. <a name="index-mode-switching"></a>
  71. <p>The following macros control mode switching optimizations:
  72. </p>
  73. <dl>
  74. <dt><a name="index-OPTIMIZE_005fMODE_005fSWITCHING"></a>Macro: <strong>OPTIMIZE_MODE_SWITCHING</strong> <em>(<var>entity</var>)</em></dt>
  75. <dd><p>Define this macro if the port needs extra instructions inserted for mode
  76. switching in an optimizing compilation.
  77. </p>
  78. <p>For an example, the SH4 can perform both single and double precision
  79. floating point operations, but to perform a single precision operation,
  80. the FPSCR PR bit has to be cleared, while for a double precision
  81. operation, this bit has to be set. Changing the PR bit requires a general
  82. purpose register as a scratch register, hence these FPSCR sets have to
  83. be inserted before reload, i.e. you cannot put this into instruction emitting
  84. or <code>TARGET_MACHINE_DEPENDENT_REORG</code>.
  85. </p>
  86. <p>You can have multiple entities that are mode-switched, and select at run time
  87. which entities actually need it. <code>OPTIMIZE_MODE_SWITCHING</code> should
  88. return nonzero for any <var>entity</var> that needs mode-switching.
  89. If you define this macro, you also have to define
  90. <code>NUM_MODES_FOR_MODE_SWITCHING</code>, <code>TARGET_MODE_NEEDED</code>,
  91. <code>TARGET_MODE_PRIORITY</code> and <code>TARGET_MODE_EMIT</code>.
  92. <code>TARGET_MODE_AFTER</code>, <code>TARGET_MODE_ENTRY</code>, and <code>TARGET_MODE_EXIT</code>
  93. are optional.
  94. </p></dd></dl>
  95. <dl>
  96. <dt><a name="index-NUM_005fMODES_005fFOR_005fMODE_005fSWITCHING"></a>Macro: <strong>NUM_MODES_FOR_MODE_SWITCHING</strong></dt>
  97. <dd><p>If you define <code>OPTIMIZE_MODE_SWITCHING</code>, you have to define this as
  98. initializer for an array of integers. Each initializer element
  99. N refers to an entity that needs mode switching, and specifies the number
  100. of different modes that might need to be set for this entity.
  101. The position of the initializer in the initializer&mdash;starting counting at
  102. zero&mdash;determines the integer that is used to refer to the mode-switched
  103. entity in question.
  104. In macros that take mode arguments / yield a mode result, modes are
  105. represented as numbers 0 &hellip; N - 1. N is used to specify that no mode
  106. switch is needed / supplied.
  107. </p></dd></dl>
  108. <dl>
  109. <dt><a name="index-TARGET_005fMODE_005fEMIT"></a>Target Hook: <em>void</em> <strong>TARGET_MODE_EMIT</strong> <em>(int <var>entity</var>, int <var>mode</var>, int <var>prev_mode</var>, HARD_REG_SET <var>regs_live</var>)</em></dt>
  110. <dd><p>Generate one or more insns to set <var>entity</var> to <var>mode</var>. <var>hard_reg_live</var> is the set of hard registers live at the point where the insn(s) are to be inserted. <var>prev_moxde</var> indicates the mode to switch from. Sets of a lower numbered entity will be emitted before sets of a higher numbered entity to a mode of the same or lower priority.
  111. </p></dd></dl>
  112. <dl>
  113. <dt><a name="index-TARGET_005fMODE_005fNEEDED"></a>Target Hook: <em>int</em> <strong>TARGET_MODE_NEEDED</strong> <em>(int <var>entity</var>, rtx_insn *<var>insn</var>)</em></dt>
  114. <dd><p><var>entity</var> is an integer specifying a mode-switched entity. If <code>OPTIMIZE_MODE_SWITCHING</code> is defined, you must define this macro to return an integer value not larger than the corresponding element in <code>NUM_MODES_FOR_MODE_SWITCHING</code>, to denote the mode that <var>entity</var> must be switched into prior to the execution of <var>insn</var>.
  115. </p></dd></dl>
  116. <dl>
  117. <dt><a name="index-TARGET_005fMODE_005fAFTER"></a>Target Hook: <em>int</em> <strong>TARGET_MODE_AFTER</strong> <em>(int <var>entity</var>, int <var>mode</var>, rtx_insn *<var>insn</var>)</em></dt>
  118. <dd><p><var>entity</var> is an integer specifying a mode-switched entity. If this macro is defined, it is evaluated for every <var>insn</var> during mode switching. It determines the mode that an insn results in (if different from the incoming mode).
  119. </p></dd></dl>
  120. <dl>
  121. <dt><a name="index-TARGET_005fMODE_005fENTRY"></a>Target Hook: <em>int</em> <strong>TARGET_MODE_ENTRY</strong> <em>(int <var>entity</var>)</em></dt>
  122. <dd><p>If this macro is defined, it is evaluated for every <var>entity</var> that needs mode switching. It should evaluate to an integer, which is a mode that <var>entity</var> is assumed to be switched to at function entry. If <code>TARGET_MODE_ENTRY</code> is defined then <code>TARGET_MODE_EXIT</code> must be defined.
  123. </p></dd></dl>
  124. <dl>
  125. <dt><a name="index-TARGET_005fMODE_005fEXIT"></a>Target Hook: <em>int</em> <strong>TARGET_MODE_EXIT</strong> <em>(int <var>entity</var>)</em></dt>
  126. <dd><p>If this macro is defined, it is evaluated for every <var>entity</var> that needs mode switching. It should evaluate to an integer, which is a mode that <var>entity</var> is assumed to be switched to at function exit. If <code>TARGET_MODE_EXIT</code> is defined then <code>TARGET_MODE_ENTRY</code> must be defined.
  127. </p></dd></dl>
  128. <dl>
  129. <dt><a name="index-TARGET_005fMODE_005fPRIORITY"></a>Target Hook: <em>int</em> <strong>TARGET_MODE_PRIORITY</strong> <em>(int <var>entity</var>, int <var>n</var>)</em></dt>
  130. <dd><p>This macro specifies the order in which modes for <var>entity</var> are processed. 0 is the highest priority, <code>NUM_MODES_FOR_MODE_SWITCHING[<var>entity</var>] - 1</code> the lowest. The value of the macro should be an integer designating a mode for <var>entity</var>. For any fixed <var>entity</var>, <code>mode_priority</code> (<var>entity</var>, <var>n</var>) shall be a bijection in 0 &hellip; <code>num_modes_for_mode_switching[<var>entity</var>] - 1</code>.
  131. </p></dd></dl>
  132. <hr>
  133. <div class="header">
  134. <p>
  135. Next: <a href="Target-Attributes.html#Target-Attributes" accesskey="n" rel="next">Target Attributes</a>, Previous: <a href="Floating-Point.html#Floating-Point" accesskey="p" rel="prev">Floating Point</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>
  136. </div>
  137. </body>
  138. </html>