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
17.4 KiB145 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>VCADD -- 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">VCADD</h2>
4      <p class="aml">Vector Complex Add.</p>
5      <p class="aml">This instruction operates on complex numbers that are represented in SIMD&amp;FP registers as pairs of elements, with the more significant element holding the imaginary part of the number and the less significant element holding the real part of the number. Each element holds a floating-point value. It performs the following computation on the corresponding complex number element pairs from the two source registers:</p>
6      <ul>
7        <li>Considering the complex number from the second source register on an Argand diagram, the number is rotated counterclockwise by 90 or 270 degrees.</li>
8        <li>The rotated complex number is added to the complex number from the first source register.</li>
9      </ul>
10      <p class="aml">Depending on settings in the <a class="armarm-xref" title="Reference to Armv8 ARM section" data-linkend="AArch32.cpacr">CPACR</a>, <a class="armarm-xref" title="Reference to Armv8 ARM section" data-linkend="AArch32.nsacr">NSACR</a>, and <a class="armarm-xref" title="Reference to Armv8 ARM section" data-linkend="AArch32.hcptr">HCPTR</a> registers, and the Security state and PE mode in which the instruction is executed, an attempt to execute the instruction might be <span class="arm-defined-word">undefined</span>, or trapped to Hyp mode. For more information see <a class="armarm-xref" title="Reference to Armv8 ARM section" data-linkend="CIHIDDFF">Enabling Advanced SIMD and floating-point support</a>.</p>
11    
12    <p class="desc">
13      It has encodings from the following instruction sets:
14       A32 (
15      <a href="#iclass_a1">A1</a>
16      )
17       and 
18       T32 (
19      <a href="#iclass_t1">T1</a>
20      )
21      .
22    </p>
23    <h3 class="classheading"><a id="iclass_a1"/>A1<span style="font-size:smaller;"><br/>(FEAT_FCMA)
24          </span></h3><p class="desc"/><div class="regdiagram-32"><table class="regdiagram"><thead><tr><td>31</td><td>30</td><td>29</td><td>28</td><td>27</td><td>26</td><td>25</td><td>24</td><td>23</td><td>22</td><td>21</td><td>20</td><td>19</td><td>18</td><td>17</td><td>16</td><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>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td class="r">0</td><td class="lr">rot</td><td class="lr">1</td><td class="lr">D</td><td class="lr">0</td><td class="lr">S</td><td colspan="4" class="lr">Vn</td><td colspan="4" class="lr">Vd</td><td class="lr">1</td><td class="lr">0</td><td class="lr">0</td><td class="lr">0</td><td class="lr">N</td><td class="lr">Q</td><td class="lr">M</td><td class="lr">0</td><td colspan="4" class="lr">Vm</td></tr></tbody></table></div><div class="encoding"><h4 class="encoding">64-bit SIMD vector<span class="bitdiff"> (Q == 0)</span></h4><a id="VCADD_A1_D"/><p class="asm-code">VCADD{<a href="#sa_q" title="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;q&gt;</a>}.<a href="#sa_dt" title="Data type for elements of vectors (field &quot;S&quot;) [F16,F32]">&lt;dt&gt;</a> <a href="#sa_dd" title="64-bit SIMD&amp;FP destination register (field &quot;D:Vd&quot;)">&lt;Dd&gt;</a>, <a href="#sa_dn" title="First 64-bit SIMD&amp;FP source register (field &quot;N:Vn&quot;)">&lt;Dn&gt;</a>, <a href="#sa_dm" title="Second 64-bit SIMD&amp;FP source register (field &quot;M:Vm&quot;)">&lt;Dm&gt;</a>, #<a href="#sa_rotate" title="Rotation applied to elements in the second SIMD&amp;FP source register (field &quot;rot&quot;) [90,270]">&lt;rotate&gt;</a></p></div><div class="encoding"><h4 class="encoding">128-bit SIMD vector<span class="bitdiff"> (Q == 1)</span></h4><a id="VCADD_A1_Q"/><p class="asm-code">VCADD{<a href="#sa_q" title="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;q&gt;</a>}.<a href="#sa_dt" title="Data type for elements of vectors (field &quot;S&quot;) [F16,F32]">&lt;dt&gt;</a> <a href="#sa_qd" title="128-bit SIMD&amp;FP destination register (field &quot;D:Vd&quot;)">&lt;Qd&gt;</a>, <a href="#sa_qn" title="First 128-bit SIMD&amp;FP source register (field &quot;N:Vn&quot;)">&lt;Qn&gt;</a>, <a href="#sa_qm" title="Second 128-bit SIMD&amp;FP source register (field &quot;M:Vm&quot;)">&lt;Qm&gt;</a>, #<a href="#sa_rotate" title="Rotation applied to elements in the second SIMD&amp;FP source register (field &quot;rot&quot;) [90,270]">&lt;rotate&gt;</a></p></div><p class="pseudocode">if !IsFeatureImplemented(FEAT_FCMA) then UNDEFINED;
25if Q == '1' &amp;&amp; (Vd&lt;0&gt; == '1' || Vn&lt;0&gt; == '1' || Vm&lt;0&gt; == '1') then UNDEFINED;
26if S == '0' &amp;&amp; !IsFeatureImplemented(FEAT_FP16) then UNDEFINED;
27constant d = <a href="shared_pseudocode.html#impl-shared.UInt.1" title="function: integer UInt(bits(N) x)">UInt</a>(D:Vd);  constant n = <a href="shared_pseudocode.html#impl-shared.UInt.1" title="function: integer UInt(bits(N) x)">UInt</a>(N:Vn);  constant m = <a href="shared_pseudocode.html#impl-shared.UInt.1" title="function: integer UInt(bits(N) x)">UInt</a>(M:Vm);
28constant integer esize = 16 &lt;&lt; <a href="shared_pseudocode.html#impl-shared.UInt.1" title="function: integer UInt(bits(N) x)">UInt</a>(S);
29constant elements = 64 DIV esize; constant regs = if Q == '0' then 1 else 2;</p>
30    <h3 class="classheading"><a id="iclass_t1"/>T1<span style="font-size:smaller;"><br/>(FEAT_FCMA)
31          </span></h3><p class="desc"/><div class="regdiagram-16x2"><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><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>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td class="r">0</td><td class="lr">rot</td><td class="lr">1</td><td class="lr">D</td><td class="lr">0</td><td class="lr">S</td><td colspan="4" class="lr">Vn</td><td colspan="4" class="lr">Vd</td><td class="lr">1</td><td class="lr">0</td><td class="lr">0</td><td class="lr">0</td><td class="lr">N</td><td class="lr">Q</td><td class="lr">M</td><td class="lr">0</td><td colspan="4" class="lr">Vm</td></tr></tbody></table></div><div class="encoding"><h4 class="encoding">64-bit SIMD vector<span class="bitdiff"> (Q == 0)</span></h4><a id="VCADD_T1_D"/><p class="asm-code">VCADD{<a href="#sa_q" title="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;q&gt;</a>}.<a href="#sa_dt" title="Data type for elements of vectors (field &quot;S&quot;) [F16,F32]">&lt;dt&gt;</a> <a href="#sa_dd" title="64-bit SIMD&amp;FP destination register (field &quot;D:Vd&quot;)">&lt;Dd&gt;</a>, <a href="#sa_dn" title="First 64-bit SIMD&amp;FP source register (field &quot;N:Vn&quot;)">&lt;Dn&gt;</a>, <a href="#sa_dm" title="Second 64-bit SIMD&amp;FP source register (field &quot;M:Vm&quot;)">&lt;Dm&gt;</a>, #<a href="#sa_rotate" title="Rotation applied to elements in the second SIMD&amp;FP source register (field &quot;rot&quot;) [90,270]">&lt;rotate&gt;</a></p></div><div class="encoding"><h4 class="encoding">128-bit SIMD vector<span class="bitdiff"> (Q == 1)</span></h4><a id="VCADD_T1_Q"/><p class="asm-code">VCADD{<a href="#sa_q" title="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;q&gt;</a>}.<a href="#sa_dt" title="Data type for elements of vectors (field &quot;S&quot;) [F16,F32]">&lt;dt&gt;</a> <a href="#sa_qd" title="128-bit SIMD&amp;FP destination register (field &quot;D:Vd&quot;)">&lt;Qd&gt;</a>, <a href="#sa_qn" title="First 128-bit SIMD&amp;FP source register (field &quot;N:Vn&quot;)">&lt;Qn&gt;</a>, <a href="#sa_qm" title="Second 128-bit SIMD&amp;FP source register (field &quot;M:Vm&quot;)">&lt;Qm&gt;</a>, #<a href="#sa_rotate" title="Rotation applied to elements in the second SIMD&amp;FP source register (field &quot;rot&quot;) [90,270]">&lt;rotate&gt;</a></p></div><p class="pseudocode">if <a href="shared_pseudocode.html#impl-aarch32.InITBlock.0" title="function: boolean InITBlock()">InITBlock</a>() then UNPREDICTABLE;
32if !IsFeatureImplemented(FEAT_FCMA) then UNDEFINED;
33if Q == '1' &amp;&amp; (Vd&lt;0&gt; == '1' || Vn&lt;0&gt; == '1' || Vm&lt;0&gt; == '1') then UNDEFINED;
34if S == '0' &amp;&amp; !IsFeatureImplemented(FEAT_FP16) then UNDEFINED;
35constant integer esize = 16 &lt;&lt; <a href="shared_pseudocode.html#impl-shared.UInt.1" title="function: integer UInt(bits(N) x)">UInt</a>(S);
36constant d = <a href="shared_pseudocode.html#impl-shared.UInt.1" title="function: integer UInt(bits(N) x)">UInt</a>(D:Vd);  constant n = <a href="shared_pseudocode.html#impl-shared.UInt.1" title="function: integer UInt(bits(N) x)">UInt</a>(N:Vn);  constant m = <a href="shared_pseudocode.html#impl-shared.UInt.1" title="function: integer UInt(bits(N) x)">UInt</a>(M:Vm);
37constant elements = 64 DIV esize; constant regs = if Q == '0' then 1 else 2;</p>
38  <div class="encoding-notes"/><h3 class="explanations">Assembler Symbols</h3><div class="explanations"><table><col class="asyn-l"/><col class="asyn-r"/><tr><td>&lt;q&gt;</td><td><a id="sa_q"/>
39        
40          <p class="aml">See <a class="armarm-xref" title="Reference to Armv8 ARM section" data-linkend="Babbefhf">Standard assembler syntax fields</a>.</p>
41        
42      </td></tr></table><table><col class="asyn-l"/><col class="asyn-r"/><tr><td>&lt;dt&gt;</td><td><a id="sa_dt"/>
43        <p>Is the data type for the elements of the vectors, 
44          encoded in
45          <q>S</q>:
46            </p>
47        <table class="valuetable">
48          
49            <thead>
50              <tr>
51                <th class="bitfield">S</th>
52                <th class="symbol">&lt;dt&gt;</th>
53              </tr>
54            </thead>
55            <tbody>
56              <tr>
57                <td class="bitfield">0</td>
58                <td class="symbol">F16</td>
59              </tr>
60              <tr>
61                <td class="bitfield">1</td>
62                <td class="symbol">F32</td>
63              </tr>
64            </tbody>
65          
66        </table>
67      </td></tr></table><table><col class="asyn-l"/><col class="asyn-r"/><tr><td>&lt;Qd&gt;</td><td><a id="sa_qd"/>
68        
69          <p class="aml">Is the 128-bit name of the SIMD&amp;FP destination register, encoded in the "D:Vd" field as &lt;Qd&gt;*2.</p>
70        
71      </td></tr></table><table><col class="asyn-l"/><col class="asyn-r"/><tr><td>&lt;Qn&gt;</td><td><a id="sa_qn"/>
72        
73          <p class="aml">Is the 128-bit name of the first SIMD&amp;FP source register, encoded in the "N:Vn" field as &lt;Qn&gt;*2.</p>
74        
75      </td></tr></table><table><col class="asyn-l"/><col class="asyn-r"/><tr><td>&lt;Qm&gt;</td><td><a id="sa_qm"/>
76        
77          <p class="aml">Is the 128-bit name of the second SIMD&amp;FP source register, encoded in the "M:Vm" field as &lt;Qm&gt;*2.</p>
78        
79      </td></tr></table><table><col class="asyn-l"/><col class="asyn-r"/><tr><td>&lt;Dd&gt;</td><td><a id="sa_dd"/>
80        
81          <p class="aml">Is the 64-bit name of the SIMD&amp;FP destination register, encoded in the "D:Vd" field.</p>
82        
83      </td></tr></table><table><col class="asyn-l"/><col class="asyn-r"/><tr><td>&lt;Dn&gt;</td><td><a id="sa_dn"/>
84        
85          <p class="aml">Is the 64-bit name of the first SIMD&amp;FP source register, encoded in the "N:Vn" field.</p>
86        
87      </td></tr></table><table><col class="asyn-l"/><col class="asyn-r"/><tr><td>&lt;Dm&gt;</td><td><a id="sa_dm"/>
88        
89          <p class="aml">Is the 64-bit name of the second SIMD&amp;FP source register, encoded in the "M:Vm" field.</p>
90        
91      </td></tr></table><table><col class="asyn-l"/><col class="asyn-r"/><tr><td>&lt;rotate&gt;</td><td><a id="sa_rotate"/>
92        <p>Is the rotation to be applied to elements in the second SIMD&amp;FP source register, 
93          encoded in
94          <q>rot</q>:
95            </p>
96        <table class="valuetable">
97          
98            <thead>
99              <tr>
100                <th class="bitfield">rot</th>
101                <th class="symbol">&lt;rotate&gt;</th>
102              </tr>
103            </thead>
104            <tbody>
105              <tr>
106                <td class="bitfield">0</td>
107                <td class="symbol">90</td>
108              </tr>
109              <tr>
110                <td class="bitfield">1</td>
111                <td class="symbol">270</td>
112              </tr>
113            </tbody>
114          
115        </table>
116      </td></tr></table></div><div class="syntax-notes"/>
117    <div class="ps"><a id="execute"/><h3 class="pseudocode">Operation</h3>
118      <p class="pseudocode">EncodingSpecificOperations();
119<a href="shared_pseudocode.html#impl-aarch32.CheckAdvSIMDEnabled.0" title="function: CheckAdvSIMDEnabled()">CheckAdvSIMDEnabled</a>();
120for r = 0 to regs-1
121    constant operand1 = <a href="shared_pseudocode.html#impl-aarch32.D.read.1" title="accessor: bits(64) D[integer n]">D</a>[n+r];
122    constant operand2 = <a href="shared_pseudocode.html#impl-aarch32.D.read.1" title="accessor: bits(64) D[integer n]">D</a>[m+r];
123    constant <a href="shared_pseudocode.html#FPCR_Type" title="type FPCR_Type">FPCR_Type</a> fpcr = <a href="shared_pseudocode.html#impl-aarch32.StandardFPCR.0" title="function: FPCR_Type StandardFPCR()">StandardFPCR</a>();
124    for e = 0 to (elements DIV 2)-1
125        bits(esize) element1;
126        bits(esize) element3;
127        case rot of
128            when '0'
129                element1 = <a href="shared_pseudocode.html#impl-shared.FPNeg.2" title="function: bits(N) FPNeg(bits(N) op, FPCR_Type fpcr)">FPNeg</a>(<a href="shared_pseudocode.html#impl-shared.Elem.read.3" title="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</a>[operand2,e*2+1,esize], fpcr);
130                element3 = <a href="shared_pseudocode.html#impl-shared.Elem.read.3" title="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</a>[operand2,e*2,esize];
131            when '1'
132                element1 = <a href="shared_pseudocode.html#impl-shared.Elem.read.3" title="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</a>[operand2,e*2+1,esize];
133                element3 = <a href="shared_pseudocode.html#impl-shared.FPNeg.2" title="function: bits(N) FPNeg(bits(N) op, FPCR_Type fpcr)">FPNeg</a>(<a href="shared_pseudocode.html#impl-shared.Elem.read.3" title="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</a>[operand2,e*2,esize], fpcr);
134        constant result1 = <a href="shared_pseudocode.html#impl-shared.FPAdd.3" title="function: bits(N) FPAdd(bits(N) op1, bits(N) op2, FPCR_Type fpcr)">FPAdd</a>(<a href="shared_pseudocode.html#impl-shared.Elem.read.3" title="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</a>[operand1,e*2,esize],element1,fpcr);
135        constant result2 = <a href="shared_pseudocode.html#impl-shared.FPAdd.3" title="function: bits(N) FPAdd(bits(N) op1, bits(N) op2, FPCR_Type fpcr)">FPAdd</a>(<a href="shared_pseudocode.html#impl-shared.Elem.read.3" title="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</a>[operand1,e*2+1,esize],element3,fpcr);
136        <a href="shared_pseudocode.html#impl-shared.Elem.write.3" title="accessor: Elem[bits(N) &amp;vector, integer e, integer size] = bits(size) value">Elem</a>[<a href="shared_pseudocode.html#impl-aarch32.D.write.1" title="accessor: D[integer n] = bits(64) value">D</a>[d+r],e*2,esize] = result1;
137        <a href="shared_pseudocode.html#impl-shared.Elem.write.3" title="accessor: Elem[bits(N) &amp;vector, integer e, integer size] = bits(size) value">Elem</a>[<a href="shared_pseudocode.html#impl-aarch32.D.write.1" title="accessor: D[integer n] = bits(64) value">D</a>[d+r],e*2+1,esize] = result2;</p>
138    </div>
139  <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">
140      Internal version only: isa v01_31, pseudocode v2024-09_rel
141      ; Build timestamp: 2024-09-26T13:26
142    </p><p class="copyconf">
143      Copyright © 2010-2024 Arm Limited or its affiliates. All rights reserved.
144      This document is Non-Confidential.
145    </p></body></html>