collab/polyglot-riscv-arm

what if the same machine code was valid riscv and arm asm

git clone https://git.julia.blue/collab/polyglot-riscv-arm

Jonathan Dönszelmannwebsite start885cc4e

main
9.8 KiB64 linesraw
1<?xml version="1.0" encoding="utf-8"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="insn.css"/><meta name="generator" content="iform.xsl"/><title>IT -- AArch32</title></head><body><table style="margin: 0 auto;"><tr><td><div class="topbar"><a href="index.html">Base Instructions</a></div></td><td><div class="topbar"><a href="fpsimdindex.html">SIMD&amp;FP Instructions</a></div></td><td><div class="topbar"><a href="a32_encindex.html">A32 Instructions by Encoding</a></div></td><td><div class="topbar"><a href="t32_encindex.html">T32 Instructions by Encoding</a></div></td><td><div class="topbar"><a href="shared_pseudocode.html">Shared Pseudocode</a></div></td><td><div class="topbar"><a href="notice.html">Proprietary Notice</a></div></td></tr></table><hr/><h2 class="instruction-section">IT</h2>
4      <p class="aml">If-Then makes up to four following instructions (the IT block) conditional. The conditions for the instructions in the IT block are the same as, or the inverse of, the condition the <span class="asm-code">IT</span> instruction specifies for the first instruction in the block.</p>
5      <p class="aml">The <span class="asm-code">IT</span> instruction itself does not affect the condition flags, but the execution of the instructions in the IT block can change the condition flags.</p>
6      <p class="aml">16-bit instructions in the IT block, other than <span class="asm-code">CMP</span>, <span class="asm-code">CMN</span> and <span class="asm-code">TST</span>, do not set the condition flags. An <span class="asm-code">IT</span> instruction with the AL condition can change the behavior without conditional execution.</p>
7      <p class="aml">The architecture permits exception return to an instruction in the IT block only if the restoration of the <a class="armarm-xref" title="Reference to Armv8 ARM section" data-linkend="CIHJBHJA">CPSR</a> restores <a class="armarm-xref" title="Reference to Armv8 ARM section" data-linkend="BEIDIGBH">PSTATE</a>.IT to a state consistent with the conditions specified by the <span class="asm-code">IT</span> instruction.  Any other exception return to an instruction in an IT block is <span class="arm-defined-word">unpredictable</span>. Any branch to a target instruction in an IT block is not permitted, and if such a branch is made it is <span class="arm-defined-word">unpredictable</span> what condition is used when executing that target instruction and any subsequent instruction in the IT block.</p>
8      <p class="aml">Many uses of the IT instruction are deprecated for performance reasons, and an implementation might include ITD controls that can disable those uses of IT, making them <span class="arm-defined-word">undefined</span>.</p>
9      <p class="aml">For more information see <a class="armarm-xref" title="Reference to Armv8 ARM section" data-linkend="BABGABFG">Conditional execution</a> and <a class="armarm-xref" title="Reference to Armv8 ARM section" data-linkend="BABHIJHI">Conditional instructions</a>. The first of these sections includes more information about the ITD controls.</p>
10    
11    <h3 class="classheading"><a id="iclass_t1"/>T1</h3><p class="desc"/><div class="regdiagram-16"><table class="regdiagram"><thead><tr><td>15</td><td>14</td><td>13</td><td>12</td><td>11</td><td>10</td><td>9</td><td>8</td><td>7</td><td>6</td><td>5</td><td>4</td><td>3</td><td>2</td><td>1</td><td>0</td></tr></thead><tbody><tr class="firstrow"><td class="l">1</td><td>0</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td class="r">1</td><td colspan="4" class="lr">firstcond</td><td colspan="4" class="lr">!= 0000</td></tr><tr class="secondrow"><td colspan="8"/><td colspan="4"/><td colspan="4" class="droppedname">mask</td></tr></tbody></table></div><div class="encoding"><h4 class="encoding">T1</h4><a id="IT_T1"/><p class="asm-code">IT{<a href="#sa_x" title="The condition for second instruction in the IT block (field &quot;mask[3]&quot;)">&lt;x&gt;</a>{<a href="#sa_y" title="The condition for third instruction in the IT block (field &quot;mask[2]&quot;)">&lt;y&gt;</a>{<a href="#sa_z" title="The condition for fourth instruction in the IT block (field &quot;mask[1]&quot;)">&lt;z&gt;</a>}}}{<a href="#sa_q" title="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;q&gt;</a>} <a href="#sa_cond" title="The condition for first instruction in the IT block (field &quot;firstcond&quot;)">&lt;cond&gt;</a></p></div><p class="pseudocode">if mask == '0000' then SEE "Related encodings";
12if firstcond == '1111' || (firstcond == '1110' &amp;&amp; <a href="shared_pseudocode.html#impl-shared.BitCount.1" title="function: integer BitCount(bits(N) x)">BitCount</a>(mask) != 1) then UNPREDICTABLE;
13if <a href="shared_pseudocode.html#impl-aarch32.InITBlock.0" title="function: boolean InITBlock()">InITBlock</a>() then UNPREDICTABLE;</p><h3>CONSTRAINED UNPREDICTABLE behavior</h3><p>If <span class="pseudocode">firstcond == '1111' || (firstcond == '1110' &amp;&amp; BitCount(mask) != 1)</span>, then one of the following behaviors must occur:</p><ul><li>The instruction is <span class="arm-defined-word">undefined</span>.</li><li>The instruction executes as <span class="asm-code">NOP</span>.</li><li>The '1111' condition is treated as being the same as the '1110' condition, meaning always, and the ITSTATE state machine is progressed in the same way as for any other cond_base value.</li></ul>
14  <div class="encoding-notes">
15      <p class="aml">For more information about the <span class="arm-defined-word">constrained unpredictable</span> behavior of this instruction, see <a class="armarm-xref" title="Reference to Armv8 ARM section" data-linkend="CJAEGDJC">Architectural Constraints on UNPREDICTABLE behaviors</a>.</p>
16      <p class="aml">Related encodings: <a class="armarm-xref" title="Reference to Armv8 ARM section" data-linkend="T32.encoding_index.misc16">Miscellaneous 16-bit instructions</a>.</p>
17    </div><h3 class="explanations">Assembler Symbols</h3><div class="explanations"><table><col class="asyn-l"/><col class="asyn-r"/><tr><td>&lt;x&gt;</td><td><a id="sa_x"/>
18        
19          <p class="aml">The condition for the second instruction in the IT block. If omitted, the "mask" field is set to 0b1000. If present it is encoded in the "mask[3]" field:</p>
20          <dl>
21            <dt>T</dt><dd>firstcond[0]</dd>
22            <dt>E</dt><dd>NOT firstcond[0]</dd>
23          </dl>
24        
25      </td></tr></table><table><col class="asyn-l"/><col class="asyn-r"/><tr><td>&lt;y&gt;</td><td><a id="sa_y"/>
26        
27          <p class="aml">The condition for the third instruction in the IT block. If omitted and &lt;x&gt; is present, the "mask[2:0]" field is set to 0b100. If &lt;y&gt; is present it is encoded in the "mask[2]" field:</p>
28          <dl>
29            <dt>T</dt><dd>firstcond[0]</dd>
30            <dt>E</dt><dd>NOT firstcond[0]</dd>
31          </dl>
32        
33      </td></tr></table><table><col class="asyn-l"/><col class="asyn-r"/><tr><td>&lt;z&gt;</td><td><a id="sa_z"/>
34        
35          <p class="aml">The condition for the fourth instruction in the IT block. If omitted and &lt;y&gt; is present, the "mask[1:0]" field is set to 0b10. If &lt;z&gt; is present, the "mask[0]" field is set to 1, and it is encoded in the "mask[1]" field:</p>
36          <dl>
37            <dt>T</dt><dd>firstcond[0]</dd>
38            <dt>E</dt><dd>NOT firstcond[0]</dd>
39          </dl>
40        
41      </td></tr></table><table><col class="asyn-l"/><col class="asyn-r"/><tr><td>&lt;q&gt;</td><td><a id="sa_q"/>
42        
43          <p class="aml">See <a class="armarm-xref" title="Reference to Armv8 ARM section" data-linkend="Babbefhf">Standard assembler syntax fields</a>.</p>
44        
45      </td></tr></table><table><col class="asyn-l"/><col class="asyn-r"/><tr><td>&lt;cond&gt;</td><td><a id="sa_cond"/>
46        
47          <p class="aml">The condition for the first instruction in the IT block, encoded in the "firstcond" field. See <a class="armarm-xref" title="Reference to Armv8 ARM section" data-linkend="Chdcgdjb">Condition codes</a> for the range of conditions available, and the encodings.</p>
48        
49      </td></tr></table></div><div class="syntax-notes">
50      <p class="aml">The conditions specified in an <span class="asm-code">IT</span> instruction must match those specified in the syntax of the instructions in its IT block. When assembling to A32 code, assemblers check <span class="asm-code">IT</span> instruction syntax for validity but do not generate assembled instructions for them. See <a class="armarm-xref" title="Reference to Armv8 ARM section" data-linkend="BABHIJHI">Conditional instructions</a>.</p>
51    </div>
52    <div class="ps"><a id="execute"/><h3 class="pseudocode">Operation</h3>
53      <p class="pseudocode">EncodingSpecificOperations();
54<a href="shared_pseudocode.html#AArch32.CheckITEnabled.1" title="function: AArch32.CheckITEnabled(bits(4) mask)">AArch32.CheckITEnabled</a>(mask);
55PSTATE.IT&lt;7:0&gt; = firstcond:mask;
56ShouldAdvanceIT = FALSE;</p>
57    </div>
58  <hr/><table style="margin: 0 auto;"><tr><td><div class="topbar"><a href="index.html">Base Instructions</a></div></td><td><div class="topbar"><a href="fpsimdindex.html">SIMD&amp;FP Instructions</a></div></td><td><div class="topbar"><a href="a32_encindex.html">A32 Instructions by Encoding</a></div></td><td><div class="topbar"><a href="t32_encindex.html">T32 Instructions by Encoding</a></div></td><td><div class="topbar"><a href="shared_pseudocode.html">Shared Pseudocode</a></div></td><td><div class="topbar"><a href="notice.html">Proprietary Notice</a></div></td></tr></table><p class="versions">
59      Internal version only: isa v01_31, pseudocode v2024-09_rel
60      ; Build timestamp: 2024-09-26T13:26
61    </p><p class="copyconf">
62      Copyright © 2010-2024 Arm Limited or its affiliates. All rights reserved.
63      This document is Non-Confidential.
64    </p></body></html>