| 1 | [wiki:ClrxToc Back to Table of content] |
| 2 | {{{ |
| 3 | #!html |
| 4 | <h2>GCN ISA SOPK instructions</h2> |
| 5 | <p>The basic encoding of the SOP2 instructions needs 4 bytes (dword). List of fields:</p> |
| 6 | <table> |
| 7 | <thead> |
| 8 | <tr> |
| 9 | <th>Bits</th> |
| 10 | <th>Name</th> |
| 11 | <th>Description</th> |
| 12 | </tr> |
| 13 | </thead> |
| 14 | <tbody> |
| 15 | <tr> |
| 16 | <td>0-15</td> |
| 17 | <td>SIMM16</td> |
| 18 | <td>Signed 16-bit immediate value</td> |
| 19 | </tr> |
| 20 | <tr> |
| 21 | <td>16-22</td> |
| 22 | <td>SDST</td> |
| 23 | <td>Destination scalar operand. Refer to operand encoding</td> |
| 24 | </tr> |
| 25 | <tr> |
| 26 | <td>23-27</td> |
| 27 | <td>OPCODE</td> |
| 28 | <td>Operation code</td> |
| 29 | </tr> |
| 30 | <tr> |
| 31 | <td>28-31</td> |
| 32 | <td>ENCODING</td> |
| 33 | <td>Encoding type. Must be 0b1011</td> |
| 34 | </tr> |
| 35 | </tbody> |
| 36 | </table> |
| 37 | <p>Syntax for almost instructions: INSTRUCTION SDST, SIMM16</p> |
| 38 | <p>SIMM16 - signed 16-bit immediate. IMM16 - unsigned 16-bit immediate.</p> |
| 39 | <p>List of the instructions by opcode:</p> |
| 40 | <table> |
| 41 | <thead> |
| 42 | <tr> |
| 43 | <th>Opcode</th> |
| 44 | <th>Mnemonic (GCN1.0/1.1)</th> |
| 45 | <th>Mnemonic (GCN 1.2)</th> |
| 46 | </tr> |
| 47 | </thead> |
| 48 | <tbody> |
| 49 | <tr> |
| 50 | <td>0 (0x0)</td> |
| 51 | <td>S_MOVK_I32</td> |
| 52 | <td>S_MOVK_I32</td> |
| 53 | </tr> |
| 54 | <tr> |
| 55 | <td>1 (0x1)</td> |
| 56 | <td>--</td> |
| 57 | <td>S_CMOVK_I32</td> |
| 58 | </tr> |
| 59 | <tr> |
| 60 | <td>2 (0x2)</td> |
| 61 | <td>S_CMOVK_I32</td> |
| 62 | <td>S_CMPK_EQ_I32</td> |
| 63 | </tr> |
| 64 | <tr> |
| 65 | <td>3 (0x3)</td> |
| 66 | <td>S_CMPK_EQ_I32</td> |
| 67 | <td>S_CMPK_LG_I32</td> |
| 68 | </tr> |
| 69 | <tr> |
| 70 | <td>4 (0x4)</td> |
| 71 | <td>S_CMPK_LG_I32</td> |
| 72 | <td>S_CMPK_GT_I32</td> |
| 73 | </tr> |
| 74 | <tr> |
| 75 | <td>5 (0x5)</td> |
| 76 | <td>S_CMPK_GT_I32</td> |
| 77 | <td>S_CMPK_GE_I32</td> |
| 78 | </tr> |
| 79 | <tr> |
| 80 | <td>6 (0x6)</td> |
| 81 | <td>S_CMPK_GE_I32</td> |
| 82 | <td>S_CMPK_LT_I32</td> |
| 83 | </tr> |
| 84 | <tr> |
| 85 | <td>7 (0x7)</td> |
| 86 | <td>S_CMPK_LT_I32</td> |
| 87 | <td>S_CMPK_LE_I32</td> |
| 88 | </tr> |
| 89 | <tr> |
| 90 | <td>8 (0x8)</td> |
| 91 | <td>S_CMPK_LE_I32</td> |
| 92 | <td>S_CMPK_EQ_U32</td> |
| 93 | </tr> |
| 94 | <tr> |
| 95 | <td>9 (0x9)</td> |
| 96 | <td>S_CMPK_EQ_U32</td> |
| 97 | <td>S_CMPK_LG_U32</td> |
| 98 | </tr> |
| 99 | <tr> |
| 100 | <td>10 (0xa)</td> |
| 101 | <td>S_CMPK_LG_U32</td> |
| 102 | <td>S_CMPK_GT_U32</td> |
| 103 | </tr> |
| 104 | <tr> |
| 105 | <td>11 (0xb)</td> |
| 106 | <td>S_CMPK_GT_U32</td> |
| 107 | <td>S_CMPK_GE_U32</td> |
| 108 | </tr> |
| 109 | <tr> |
| 110 | <td>12 (0xc)</td> |
| 111 | <td>S_CMPK_GE_U32</td> |
| 112 | <td>S_CMPK_LT_U32</td> |
| 113 | </tr> |
| 114 | <tr> |
| 115 | <td>13 (0xd)</td> |
| 116 | <td>S_CMPK_LT_U32</td> |
| 117 | <td>S_CMPK_LE_U32</td> |
| 118 | </tr> |
| 119 | <tr> |
| 120 | <td>14 (0xe)</td> |
| 121 | <td>S_CMPK_LE_U32</td> |
| 122 | <td>S_ADDK_I32</td> |
| 123 | </tr> |
| 124 | <tr> |
| 125 | <td>15 (0xf)</td> |
| 126 | <td>S_ADDK_I32</td> |
| 127 | <td>S_MULK_I32</td> |
| 128 | </tr> |
| 129 | <tr> |
| 130 | <td>16 (0x10)</td> |
| 131 | <td>S_MULK_I32</td> |
| 132 | <td>S_CBRANCH_I_FORK</td> |
| 133 | </tr> |
| 134 | <tr> |
| 135 | <td>17 (0x11)</td> |
| 136 | <td>S_CBRANCH_I_FORK</td> |
| 137 | <td>S_GETREG_B32</td> |
| 138 | </tr> |
| 139 | <tr> |
| 140 | <td>18 (0x12)</td> |
| 141 | <td>S_GETREG_B32</td> |
| 142 | <td>S_SETREG_B32</td> |
| 143 | </tr> |
| 144 | <tr> |
| 145 | <td>19 (0x13)</td> |
| 146 | <td>S_SETREG_B32</td> |
| 147 | <td>S_GETREG_REGRD_B32</td> |
| 148 | </tr> |
| 149 | <tr> |
| 150 | <td>20 (0x14)</td> |
| 151 | <td>S_GETREG_REGRD_B32</td> |
| 152 | <td>S_SETREG_IMM32_B32</td> |
| 153 | </tr> |
| 154 | <tr> |
| 155 | <td>21 (0x15)</td> |
| 156 | <td>S_SETREG_IMM32_B32</td> |
| 157 | <td>--</td> |
| 158 | </tr> |
| 159 | </tbody> |
| 160 | </table> |
| 161 | <h3>Instruction set</h3> |
| 162 | <p>Alphabetically sorted instruction list:</p> |
| 163 | <h4>S_ADDK_I32</h4> |
| 164 | <p>Opcode: 15 (0xf) for GCN 1.0/1.1; 14 (0xe) for GCN 1.2<br /> |
| 165 | Syntax: S_ADDK_I32 SDST, SIMM16<br /> |
| 166 | Description: Add signed SDST to SIMM16 and store result into SDST and |
| 167 | store overflow flag into SCC.<br /> |
| 168 | Operation:<br /> |
| 169 | <code>SDST = SDST + SIMM16 |
| 170 | INT64 temp = SEXT64(SDST) + SEXT64(SIMM16) |
| 171 | SCC = temp > ((1LL<<31)-1) || temp < (-1LL<<31)</code></p> |
| 172 | <h4>S_CMOVK_I32</h4> |
| 173 | <p>Opcode: 2 (0x2) for GCN 1.0/1.1; 1 (0x1) for GCN 1.2<br /> |
| 174 | Syntax: S_MOVK_I32 SDST, SIMM16<br /> |
| 175 | Description: If SCC is 1 then move signed extended 16-bit immediate into SDST. |
| 176 | SCC has not been changed.<br /> |
| 177 | Operation:<br /> |
| 178 | <code>SDST = SCC ? SIMM16 : SDST</code></p> |
| 179 | <h4>S_CMPK_EQ_I32</h4> |
| 180 | <p>Opcode: 3 (0x3) for GCN1.0/1.1; 2 (0x2) for GCN 1.2<br /> |
| 181 | Syntax: S_CMPK_EQ_I32 SDST, SIMM16<br /> |
| 182 | Description: Compare signed value from SDST with SIMM16. If SDST equal, store 1 to SCC, |
| 183 | otherwise store 0 to SCC.<br /> |
| 184 | Operation:<br /> |
| 185 | <code>SCC = (INT32)SDST == SIMM16</code></p> |
| 186 | <h4>S_CMPK_EQ_U32</h4> |
| 187 | <p>Opcode: 9 (0x9) for GCN1.0/1.1; 8 (0x8) for GCN 1.2<br /> |
| 188 | Syntax: S_CMPK_EQ_U32 SDST, IMM16<br /> |
| 189 | Description: Compare unsigned value from SDST with IMM16. If SDST equal, store 1 to SCC, |
| 190 | otherwise store 0 to SCC.<br /> |
| 191 | Operation:<br /> |
| 192 | <code>SCC = SDST == IMM16</code></p> |
| 193 | <h4>S_CMPK_GE_I32</h4> |
| 194 | <p>Opcode: 6 (0x6) for GCN1.0/1.1; 5 (0x5) for GCN 1.2<br /> |
| 195 | Syntax: S_CMPK_GE_I32 SDST, SIMM16<br /> |
| 196 | Description: Compare signed value from SDST with SIMM16. If SDST greater or equal, |
| 197 | store 1 to SCC, otherwise store 0 to SCC.<br /> |
| 198 | Operation:<br /> |
| 199 | <code>SCC = (INT32)SDST >= SIMM16</code></p> |
| 200 | <h4>S_CMPK_GE_U32</h4> |
| 201 | <p>Opcode: 12 (0xc) for GCN1.0/1.1; 11 (0xb) for GCN 1.2<br /> |
| 202 | Syntax: S_CMPK_GE_U32 SDST, IMM16<br /> |
| 203 | Description: Compare unsigned value from SDST with IMM16. If SDST greater or equal, |
| 204 | store 1 to SCC, otherwise store 0 to SCC.<br /> |
| 205 | Operation:<br /> |
| 206 | <code>SCC = SDST >= IMM16</code></p> |
| 207 | <h4>S_CMPK_GT_I32</h4> |
| 208 | <p>Opcode: 5 (0x5) for GCN1.0/1.1; 4 (0x4) for GCN 1.2<br /> |
| 209 | Syntax: S_CMPK_GT_I32 SDST, SIMM16<br /> |
| 210 | Description: Compare signed value from SDST with SIMM16. If SDST greater, store 1 to SCC, |
| 211 | otherwise store 0 to SCC.<br /> |
| 212 | Operation:<br /> |
| 213 | <code>SCC = (INT32)SDST > SIMM16</code></p> |
| 214 | <h4>S_CMPK_GT_U32</h4> |
| 215 | <p>Opcode: 11 (0xb) for GCN1.0/1.1; 10 (0xa) for GCN 1.2<br /> |
| 216 | Syntax: S_CMPK_GT_U32 SDST, IMM16<br /> |
| 217 | Description: Compare unsigned value from SDST with IMM16. If SDST greater, store 1 to SCC, |
| 218 | otherwise store 0 to SCC.<br /> |
| 219 | Operation:<br /> |
| 220 | <code>SCC = SDST > IMM16</code></p> |
| 221 | <h4>S_CMPK_LE_I32</h4> |
| 222 | <p>Opcode: 8 (0x8) for GCN1.0/1.1; 7 (0x7) for GCN 1.2<br /> |
| 223 | Syntax: S_CMPK_LE_I32 SDST, SIMM16<br /> |
| 224 | Description: Compare signed value from SDST with SIMM16. If SDST less or equal, |
| 225 | store 1 to SCC, otherwise store 0 to SCC.<br /> |
| 226 | Operation:<br /> |
| 227 | <code>SCC = (INT32)SDST <= SIMM16</code></p> |
| 228 | <h4>S_CMPK_LE_U32</h4> |
| 229 | <p>Opcode: 14 (0xe) for GCN1.0/1.1; 13 (0xd) for GCN 1.2<br /> |
| 230 | Syntax: S_CMPK_LE_U32 SDST, IMM16<br /> |
| 231 | Description: Compare unsigned value from SDST with IMM16. If SDST less or equal, |
| 232 | store 1 to SCC, otherwise store 0 to SCC.<br /> |
| 233 | Operation:<br /> |
| 234 | <code>SCC = SDST <= IMM16</code></p> |
| 235 | <h4>S_CMPK_LG_I32</h4> |
| 236 | <p>Opcode: 4 (0x4) for GCN1.0/1.1; 3 (0x3) for GCN 1.2<br /> |
| 237 | Syntax: S_CMPK_LG_I32 SDST, SIMM16<br /> |
| 238 | Description: Compare signed value from SDST with SIMM16. If SDST not equal, store 1 to SCC, |
| 239 | otherwise store 0 to SCC.<br /> |
| 240 | Operation:<br /> |
| 241 | <code>SCC = (INT32)SDST != SIMM16</code></p> |
| 242 | <h4>S_CMPK_LG_U32</h4> |
| 243 | <p>Opcode: 10 (0xa) for GCN1.0/1.1; 9 (0x9) for GCN 1.2<br /> |
| 244 | Syntax: S_CMPK_LG_U32 SDST, IMM16<br /> |
| 245 | Description: Compare unsigned value from SDST with IMM16. If SDST not equal, store 1 to SCC, |
| 246 | otherwise store 0 to SCC.<br /> |
| 247 | Operation:<br /> |
| 248 | <code>SCC = SDST != IMM16</code></p> |
| 249 | <h4>S_CMPK_LT_I32</h4> |
| 250 | <p>Opcode: 7 (0x7) for GCN1.0/1.1; 6 (0x6) for GCN 1.2<br /> |
| 251 | Syntax: S_CMPK_LT_I32 SDST, SIMM16<br /> |
| 252 | Description: Compare signed value from SDST with SIMM16. If SDST less, store 1 to SCC, |
| 253 | otherwise store 0 to SCC.<br /> |
| 254 | Operation:<br /> |
| 255 | <code>SCC = (INT32)SDST < SIMM16</code></p> |
| 256 | <h4>S_CMPK_LT_U32</h4> |
| 257 | <p>Opcode: 13 (0xd) for GCN1.0/1.1; 12 (0xc) for GCN 1.2<br /> |
| 258 | Syntax: S_CMPK_LT_U32 SDST, IMM16<br /> |
| 259 | Description: Compare unsigned value from SDST with IMM16. If SDST less, store 1 to SCC, |
| 260 | otherwise store 0 to SCC.<br /> |
| 261 | Operation:<br /> |
| 262 | <code>SCC = SDST < IMM16</code></p> |
| 263 | <h4>S_MOVK_I32</h4> |
| 264 | <p>Opcode: 0 (0x0)<br /> |
| 265 | Syntax: S_MOVK_I32 SDST, SIMM16<br /> |
| 266 | Description: Move signed extended 16-bit immediate into SDST. SCC has not been changed.<br /> |
| 267 | Operation:<br /> |
| 268 | <code>SCC = SIMM16</code></p> |
| 269 | <h4>S_MUL_I32</h4> |
| 270 | <p>Opcode: 16 (0x10) for GCN 1.0/1.1; 15 (0xf) for GCN 1.2<br /> |
| 271 | Syntax: S_MULK_I32 SDST, SIMM16<br /> |
| 272 | Description: Multiply signed SDST with SIMM16 and store result into SDST. |
| 273 | SCC has not been changed.<br /> |
| 274 | <code>SDST = SDST * SIMM16</code></p> |
| 275 | }}} |