Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

307 rindas
14KB

  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>Simple Constraints (Using the GNU Compiler Collection (GCC))</title>
  21. <meta name="description" content="Simple Constraints (Using the GNU Compiler Collection (GCC))">
  22. <meta name="keywords" content="Simple Constraints (Using the GNU Compiler Collection (GCC))">
  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="Constraints.html#Constraints" rel="up" title="Constraints">
  30. <link href="Multi_002dAlternative.html#Multi_002dAlternative" rel="next" title="Multi-Alternative">
  31. <link href="Constraints.html#Constraints" rel="prev" title="Constraints">
  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="Simple-Constraints"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Multi_002dAlternative.html#Multi_002dAlternative" accesskey="n" rel="next">Multi-Alternative</a>, Up: <a href="Constraints.html#Constraints" accesskey="u" rel="up">Constraints</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="Simple-Constraints-1"></a>
  68. <h4 class="subsubsection">6.47.3.1 Simple Constraints</h4>
  69. <a name="index-simple-constraints"></a>
  70. <p>The simplest kind of constraint is a string full of letters, each of
  71. which describes one kind of operand that is permitted. Here are
  72. the letters that are allowed:
  73. </p>
  74. <dl compact="compact">
  75. <dt>whitespace</dt>
  76. <dd><p>Whitespace characters are ignored and can be inserted at any position
  77. except the first. This enables each alternative for different operands to
  78. be visually aligned in the machine description even if they have different
  79. number of constraints and modifiers.
  80. </p>
  81. <a name="index-m-in-constraint"></a>
  82. <a name="index-memory-references-in-constraints"></a>
  83. </dd>
  84. <dt>&lsquo;<samp>m</samp>&rsquo;</dt>
  85. <dd><p>A memory operand is allowed, with any kind of address that the machine
  86. supports in general.
  87. Note that the letter used for the general memory constraint can be
  88. re-defined by a back end using the <code>TARGET_MEM_CONSTRAINT</code> macro.
  89. </p>
  90. <a name="index-offsettable-address"></a>
  91. <a name="index-o-in-constraint"></a>
  92. </dd>
  93. <dt>&lsquo;<samp>o</samp>&rsquo;</dt>
  94. <dd><p>A memory operand is allowed, but only if the address is
  95. <em>offsettable</em>. This means that adding a small integer (actually,
  96. the width in bytes of the operand, as determined by its machine mode)
  97. may be added to the address and the result is also a valid memory
  98. address.
  99. </p>
  100. <a name="index-autoincrement_002fdecrement-addressing"></a>
  101. <p>For example, an address which is constant is offsettable; so is an
  102. address that is the sum of a register and a constant (as long as a
  103. slightly larger constant is also within the range of address-offsets
  104. supported by the machine); but an autoincrement or autodecrement
  105. address is not offsettable. More complicated indirect/indexed
  106. addresses may or may not be offsettable depending on the other
  107. addressing modes that the machine supports.
  108. </p>
  109. <p>Note that in an output operand which can be matched by another
  110. operand, the constraint letter &lsquo;<samp>o</samp>&rsquo; is valid only when accompanied
  111. by both &lsquo;<samp>&lt;</samp>&rsquo; (if the target machine has predecrement addressing)
  112. and &lsquo;<samp>&gt;</samp>&rsquo; (if the target machine has preincrement addressing).
  113. </p>
  114. <a name="index-V-in-constraint"></a>
  115. </dd>
  116. <dt>&lsquo;<samp>V</samp>&rsquo;</dt>
  117. <dd><p>A memory operand that is not offsettable. In other words, anything that
  118. would fit the &lsquo;<samp>m</samp>&rsquo; constraint but not the &lsquo;<samp>o</samp>&rsquo; constraint.
  119. </p>
  120. <a name="index-_003c-in-constraint"></a>
  121. </dd>
  122. <dt>&lsquo;<samp>&lt;</samp>&rsquo;</dt>
  123. <dd><p>A memory operand with autodecrement addressing (either predecrement or
  124. postdecrement) is allowed. In inline <code>asm</code> this constraint is only
  125. allowed if the operand is used exactly once in an instruction that can
  126. handle the side effects. Not using an operand with &lsquo;<samp>&lt;</samp>&rsquo; in constraint
  127. string in the inline <code>asm</code> pattern at all or using it in multiple
  128. instructions isn&rsquo;t valid, because the side effects wouldn&rsquo;t be performed
  129. or would be performed more than once. Furthermore, on some targets
  130. the operand with &lsquo;<samp>&lt;</samp>&rsquo; in constraint string must be accompanied by
  131. special instruction suffixes like <code>%U0</code> instruction suffix on PowerPC
  132. or <code>%P0</code> on IA-64.
  133. </p>
  134. <a name="index-_003e-in-constraint"></a>
  135. </dd>
  136. <dt>&lsquo;<samp>&gt;</samp>&rsquo;</dt>
  137. <dd><p>A memory operand with autoincrement addressing (either preincrement or
  138. postincrement) is allowed. In inline <code>asm</code> the same restrictions
  139. as for &lsquo;<samp>&lt;</samp>&rsquo; apply.
  140. </p>
  141. <a name="index-r-in-constraint"></a>
  142. <a name="index-registers-in-constraints"></a>
  143. </dd>
  144. <dt>&lsquo;<samp>r</samp>&rsquo;</dt>
  145. <dd><p>A register operand is allowed provided that it is in a general
  146. register.
  147. </p>
  148. <a name="index-constants-in-constraints"></a>
  149. <a name="index-i-in-constraint"></a>
  150. </dd>
  151. <dt>&lsquo;<samp>i</samp>&rsquo;</dt>
  152. <dd><p>An immediate integer operand (one with constant value) is allowed.
  153. This includes symbolic constants whose values will be known only at
  154. assembly time or later.
  155. </p>
  156. <a name="index-n-in-constraint"></a>
  157. </dd>
  158. <dt>&lsquo;<samp>n</samp>&rsquo;</dt>
  159. <dd><p>An immediate integer operand with a known numeric value is allowed.
  160. Many systems cannot support assembly-time constants for operands less
  161. than a word wide. Constraints for these operands should use &lsquo;<samp>n</samp>&rsquo;
  162. rather than &lsquo;<samp>i</samp>&rsquo;.
  163. </p>
  164. <a name="index-I-in-constraint"></a>
  165. </dd>
  166. <dt>&lsquo;<samp>I</samp>&rsquo;, &lsquo;<samp>J</samp>&rsquo;, &lsquo;<samp>K</samp>&rsquo;, &hellip; &lsquo;<samp>P</samp>&rsquo;</dt>
  167. <dd><p>Other letters in the range &lsquo;<samp>I</samp>&rsquo; through &lsquo;<samp>P</samp>&rsquo; may be defined in
  168. a machine-dependent fashion to permit immediate integer operands with
  169. explicit integer values in specified ranges. For example, on the
  170. 68000, &lsquo;<samp>I</samp>&rsquo; is defined to stand for the range of values 1 to 8.
  171. This is the range permitted as a shift count in the shift
  172. instructions.
  173. </p>
  174. <a name="index-E-in-constraint"></a>
  175. </dd>
  176. <dt>&lsquo;<samp>E</samp>&rsquo;</dt>
  177. <dd><p>An immediate floating operand (expression code <code>const_double</code>) is
  178. allowed, but only if the target floating point format is the same as
  179. that of the host machine (on which the compiler is running).
  180. </p>
  181. <a name="index-F-in-constraint"></a>
  182. </dd>
  183. <dt>&lsquo;<samp>F</samp>&rsquo;</dt>
  184. <dd><p>An immediate floating operand (expression code <code>const_double</code> or
  185. <code>const_vector</code>) is allowed.
  186. </p>
  187. <a name="index-G-in-constraint"></a>
  188. <a name="index-H-in-constraint"></a>
  189. </dd>
  190. <dt>&lsquo;<samp>G</samp>&rsquo;, &lsquo;<samp>H</samp>&rsquo;</dt>
  191. <dd><p>&lsquo;<samp>G</samp>&rsquo; and &lsquo;<samp>H</samp>&rsquo; may be defined in a machine-dependent fashion to
  192. permit immediate floating operands in particular ranges of values.
  193. </p>
  194. <a name="index-s-in-constraint"></a>
  195. </dd>
  196. <dt>&lsquo;<samp>s</samp>&rsquo;</dt>
  197. <dd><p>An immediate integer operand whose value is not an explicit integer is
  198. allowed.
  199. </p>
  200. <p>This might appear strange; if an insn allows a constant operand with a
  201. value not known at compile time, it certainly must allow any known
  202. value. So why use &lsquo;<samp>s</samp>&rsquo; instead of &lsquo;<samp>i</samp>&rsquo;? Sometimes it allows
  203. better code to be generated.
  204. </p>
  205. <p>For example, on the 68000 in a fullword instruction it is possible to
  206. use an immediate operand; but if the immediate value is between -128
  207. and 127, better code results from loading the value into a register and
  208. using the register. This is because the load into the register can be
  209. done with a &lsquo;<samp>moveq</samp>&rsquo; instruction. We arrange for this to happen
  210. by defining the letter &lsquo;<samp>K</samp>&rsquo; to mean &ldquo;any integer outside the
  211. range -128 to 127&rdquo;, and then specifying &lsquo;<samp>Ks</samp>&rsquo; in the operand
  212. constraints.
  213. </p>
  214. <a name="index-g-in-constraint"></a>
  215. </dd>
  216. <dt>&lsquo;<samp>g</samp>&rsquo;</dt>
  217. <dd><p>Any register, memory or immediate integer operand is allowed, except for
  218. registers that are not general registers.
  219. </p>
  220. <a name="index-X-in-constraint"></a>
  221. </dd>
  222. <dt>&lsquo;<samp>X</samp>&rsquo;</dt>
  223. <dd><p>Any operand whatsoever is allowed.
  224. </p>
  225. <a name="index-0-in-constraint"></a>
  226. <a name="index-digits-in-constraint"></a>
  227. </dd>
  228. <dt>&lsquo;<samp>0</samp>&rsquo;, &lsquo;<samp>1</samp>&rsquo;, &lsquo;<samp>2</samp>&rsquo;, &hellip; &lsquo;<samp>9</samp>&rsquo;</dt>
  229. <dd><p>An operand that matches the specified operand number is allowed. If a
  230. digit is used together with letters within the same alternative, the
  231. digit should come last.
  232. </p>
  233. <p>This number is allowed to be more than a single digit. If multiple
  234. digits are encountered consecutively, they are interpreted as a single
  235. decimal integer. There is scant chance for ambiguity, since to-date
  236. it has never been desirable that &lsquo;<samp>10</samp>&rsquo; be interpreted as matching
  237. either operand 1 <em>or</em> operand 0. Should this be desired, one
  238. can use multiple alternatives instead.
  239. </p>
  240. <a name="index-matching-constraint"></a>
  241. <a name="index-constraint_002c-matching"></a>
  242. <p>This is called a <em>matching constraint</em> and what it really means is
  243. that the assembler has only a single operand that fills two roles
  244. which <code>asm</code> distinguishes. For example, an add instruction uses
  245. two input operands and an output operand, but on most CISC
  246. machines an add instruction really has only two operands, one of them an
  247. input-output operand:
  248. </p>
  249. <div class="smallexample">
  250. <pre class="smallexample">addl #35,r12
  251. </pre></div>
  252. <p>Matching constraints are used in these circumstances.
  253. More precisely, the two operands that match must include one input-only
  254. operand and one output-only operand. Moreover, the digit must be a
  255. smaller number than the number of the operand that uses it in the
  256. constraint.
  257. </p>
  258. <a name="index-load-address-instruction"></a>
  259. <a name="index-push-address-instruction"></a>
  260. <a name="index-address-constraints"></a>
  261. <a name="index-p-in-constraint"></a>
  262. </dd>
  263. <dt>&lsquo;<samp>p</samp>&rsquo;</dt>
  264. <dd><p>An operand that is a valid memory address is allowed. This is
  265. for &ldquo;load address&rdquo; and &ldquo;push address&rdquo; instructions.
  266. </p>
  267. <a name="index-address_005foperand"></a>
  268. <p>&lsquo;<samp>p</samp>&rsquo; in the constraint must be accompanied by <code>address_operand</code>
  269. as the predicate in the <code>match_operand</code>. This predicate interprets
  270. the mode specified in the <code>match_operand</code> as the mode of the memory
  271. reference for which the address would be valid.
  272. </p>
  273. <a name="index-other-register-constraints"></a>
  274. <a name="index-extensible-constraints"></a>
  275. </dd>
  276. <dt><var>other-letters</var></dt>
  277. <dd><p>Other letters can be defined in machine-dependent fashion to stand for
  278. particular classes of registers or other arbitrary operand types.
  279. &lsquo;<samp>d</samp>&rsquo;, &lsquo;<samp>a</samp>&rsquo; and &lsquo;<samp>f</samp>&rsquo; are defined on the 68000/68020 to stand
  280. for data, address and floating point registers.
  281. </p></dd>
  282. </dl>
  283. <hr>
  284. <div class="header">
  285. <p>
  286. Next: <a href="Multi_002dAlternative.html#Multi_002dAlternative" accesskey="n" rel="next">Multi-Alternative</a>, Up: <a href="Constraints.html#Constraints" accesskey="u" rel="up">Constraints</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>
  287. </div>
  288. </body>
  289. </html>