diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/gcc~13/multi-alternative.html | |
new repository
Diffstat (limited to 'devdocs/gcc~13/multi-alternative.html')
| -rw-r--r-- | devdocs/gcc~13/multi-alternative.html | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/devdocs/gcc~13/multi-alternative.html b/devdocs/gcc~13/multi-alternative.html new file mode 100644 index 00000000..77a7f39d --- /dev/null +++ b/devdocs/gcc~13/multi-alternative.html @@ -0,0 +1,8 @@ +<div class="subsubsection-level-extent" id="Multi-Alternative"> <div class="nav-panel"> <p> Next: <a href="modifiers" accesskey="n" rel="next">Constraint Modifier Characters</a>, Previous: <a href="simple-constraints" accesskey="p" rel="prev">Simple Constraints</a>, Up: <a href="constraints" accesskey="u" rel="up">Constraints for <code class="code">asm</code> Operands</a> [<a href="index#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="indices" title="Index" rel="index">Index</a>]</p> </div> <h1 class="subsubsection subsection-level-set-subsubsection" id="Multiple-Alternative-Constraints"><span>6.47.3.2 Multiple Alternative Constraints<a class="copiable-link" href="#Multiple-Alternative-Constraints"> ¶</a></span></h1> <p>Sometimes a single instruction has multiple alternative sets of possible operands. For example, on the 68000, a logical-or instruction can combine register or an immediate value into memory, or it can combine any kind of operand into a register; but it cannot combine one memory location into another. </p> <p>These constraints are represented as multiple alternatives. An alternative can be described by a series of letters for each operand. The overall constraint for an operand is made from the letters for this operand from the first alternative, a comma, the letters for this operand from the second alternative, a comma, and so on until the last alternative. All operands for a single instruction must have the same number of alternatives. </p> <p>So the first alternative for the 68000’s logical-or could be written as <code class="code">"+m" (output) : "ir" (input)</code>. The second could be <code class="code">"+r" +(output): "irm" (input)</code>. However, the fact that two memory locations cannot be used in a single instruction prevents simply using <code class="code">"+rm" +(output) : "irm" (input)</code>. Using multi-alternatives, this might be written as <code class="code">"+m,r" (output) : "ir,irm" (input)</code>. This describes all the available alternatives to the compiler, allowing it to choose the most efficient one for the current conditions. </p> <p>There is no way within the template to determine which alternative was chosen. However you may be able to wrap your <code class="code">asm</code> statements with builtins such as <code class="code">__builtin_constant_p</code> to achieve the desired results. </p> </div><div class="_attribution"> + <p class="_attribution-p"> + © Free Software Foundation<br>Licensed under the GNU Free Documentation License, Version 1.3.<br> + <a href="https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Multi-Alternative.html" class="_attribution-link">https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Multi-Alternative.html</a> + </p> +</div> |
