Define-Subst.html 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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: Define Subst</title>
  20. <meta name="description" content="GNU Compiler Collection (GCC) Internals: Define Subst">
  21. <meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Define Subst">
  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="Define-Subst-Example.html#Define-Subst-Example" rel="next" title="Define Subst Example">
  31. <link href="Conditional-Execution.html#Conditional-Execution" rel="prev" title="Conditional Execution">
  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="Define-Subst"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="Constant-Definitions.html#Constant-Definitions" accesskey="n" rel="next">Constant Definitions</a>, Previous: <a href="Conditional-Execution.html#Conditional-Execution" accesskey="p" rel="prev">Conditional Execution</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="RTL-Templates-Transformations"></a>
  69. <h3 class="section">16.21 RTL Templates Transformations</h3>
  70. <a name="index-define_005fsubst"></a>
  71. <p>For some hardware architectures there are common cases when the RTL
  72. templates for the instructions can be derived from the other RTL
  73. templates using simple transformations. E.g., <samp>i386.md</samp> contains
  74. an RTL template for the ordinary <code>sub</code> instruction&mdash;
  75. <code>*subsi_1</code>, and for the <code>sub</code> instruction with subsequent
  76. zero-extension&mdash;<code>*subsi_1_zext</code>. Such cases can be easily
  77. implemented by a single meta-template capable of generating a modified
  78. case based on the initial one:
  79. </p>
  80. <a name="index-define_005fsubst-4"></a>
  81. <div class="smallexample">
  82. <pre class="smallexample">(define_subst &quot;<var>name</var>&quot;
  83. [<var>input-template</var>]
  84. &quot;<var>condition</var>&quot;
  85. [<var>output-template</var>])
  86. </pre></div>
  87. <p><var>input-template</var> is a pattern describing the source RTL template,
  88. which will be transformed.
  89. </p>
  90. <p><var>condition</var> is a C expression that is conjunct with the condition
  91. from the input-template to generate a condition to be used in the
  92. output-template.
  93. </p>
  94. <p><var>output-template</var> is a pattern that will be used in the resulting
  95. template.
  96. </p>
  97. <p><code>define_subst</code> mechanism is tightly coupled with the notion of the
  98. subst attribute (see <a href="Subst-Iterators.html#Subst-Iterators">Subst Iterators</a>). The use of
  99. <code>define_subst</code> is triggered by a reference to a subst attribute in
  100. the transforming RTL template. This reference initiates duplication of
  101. the source RTL template and substitution of the attributes with their
  102. values. The source RTL template is left unchanged, while the copy is
  103. transformed by <code>define_subst</code>. This transformation can fail in the
  104. case when the source RTL template is not matched against the
  105. input-template of the <code>define_subst</code>. In such case the copy is
  106. deleted.
  107. </p>
  108. <p><code>define_subst</code> can be used only in <code>define_insn</code> and
  109. <code>define_expand</code>, it cannot be used in other expressions (e.g. in
  110. <code>define_insn_and_split</code>).
  111. </p>
  112. <table class="menu" border="0" cellspacing="0">
  113. <tr><td align="left" valign="top">&bull; <a href="Define-Subst-Example.html#Define-Subst-Example" accesskey="1">Define Subst Example</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Example of <code>define_subst</code> work.
  114. </td></tr>
  115. <tr><td align="left" valign="top">&bull; <a href="Define-Subst-Pattern-Matching.html#Define-Subst-Pattern-Matching" accesskey="2">Define Subst Pattern Matching</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Process of template comparison.
  116. </td></tr>
  117. <tr><td align="left" valign="top">&bull; <a href="Define-Subst-Output-Template.html#Define-Subst-Output-Template" accesskey="3">Define Subst Output Template</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Generation of output template.
  118. </td></tr>
  119. </table>
  120. <hr>
  121. <div class="header">
  122. <p>
  123. Next: <a href="Constant-Definitions.html#Constant-Definitions" accesskey="n" rel="next">Constant Definitions</a>, Previous: <a href="Conditional-Execution.html#Conditional-Execution" accesskey="p" rel="prev">Conditional Execution</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>
  124. </div>
  125. </body>
  126. </html>