| 1 |
// Copyright 2015, VIXL authors |
| 2 |
// All rights reserved. |
| 3 |
// |
| 4 |
// Redistribution and use in source and binary forms, with or without |
| 5 |
// modification, are permitted provided that the following conditions are met: |
| 6 |
// |
| 7 |
// * Redistributions of source code must retain the above copyright notice, |
| 8 |
// this list of conditions and the following disclaimer. |
| 9 |
// * Redistributions in binary form must reproduce the above copyright notice, |
| 10 |
// this list of conditions and the following disclaimer in the documentation |
| 11 |
// and/or other materials provided with the distribution. |
| 12 |
// * Neither the name of ARM Limited nor the names of its contributors may be |
| 13 |
// used to endorse or promote products derived from this software without |
| 14 |
// specific prior written permission. |
| 15 |
// |
| 16 |
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS CONTRIBUTORS "AS IS" AND |
| 17 |
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 18 |
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 19 |
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE |
| 20 |
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 21 |
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 22 |
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 23 |
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 24 |
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 25 |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 |
|
| 27 |
#include "jit/arm64/vixl/Disasm-vixl.h" |
| 28 |
|
| 29 |
#include "mozilla/Sprintf.h" |
| 30 |
#include <cstdlib> |
| 31 |
|
| 32 |
namespace vixl { |
| 33 |
|
| 34 |
Disassembler::Disassembler() { |
| 35 |
buffer_size_ = 256; |
| 36 |
buffer_ = reinterpret_cast<char*>(malloc(buffer_size_)); |
| 37 |
buffer_pos_ = 0; |
| 38 |
own_buffer_ = true; |
| 39 |
code_address_offset_ = 0; |
| 40 |
} |
| 41 |
|
| 42 |
|
| 43 |
Disassembler::Disassembler(char* text_buffer, int buffer_size) { |
| 44 |
buffer_size_ = buffer_size; |
| 45 |
buffer_ = text_buffer; |
| 46 |
buffer_pos_ = 0; |
| 47 |
own_buffer_ = false; |
| 48 |
code_address_offset_ = 0; |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
Disassembler::~Disassembler() { |
| 53 |
if (own_buffer_) { |
| 54 |
free(buffer_); |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
char* Disassembler::GetOutput() { |
| 60 |
return buffer_; |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
void Disassembler::VisitAddSubImmediate(const Instruction* instr) { |
| 65 |
bool rd_is_zr = RdIsZROrSP(instr); |
| 66 |
bool stack_op = (rd_is_zr || RnIsZROrSP(instr)) && |
| 67 |
(instr->ImmAddSub() == 0) ? true : false; |
| 68 |
const char *mnemonic = ""; |
| 69 |
const char *form = "'Rds, 'Rns, 'IAddSub"; |
| 70 |
const char *form_cmp = "'Rns, 'IAddSub"; |
| 71 |
const char *form_mov = "'Rds, 'Rns"; |
| 72 |
|
| 73 |
switch (instr->Mask(AddSubImmediateMask)) { |
| 74 |
case ADD_w_imm: |
| 75 |
case ADD_x_imm: { |
| 76 |
mnemonic = "add"; |
| 77 |
if (stack_op) { |
| 78 |
mnemonic = "mov"; |
| 79 |
form = form_mov; |
| 80 |
} |
| 81 |
break; |
| 82 |
} |
| 83 |
case ADDS_w_imm: |
| 84 |
case ADDS_x_imm: { |
| 85 |
mnemonic = "adds"; |
| 86 |
if (rd_is_zr) { |
| 87 |
mnemonic = "cmn"; |
| 88 |
form = form_cmp; |
| 89 |
} |
| 90 |
break; |
| 91 |
} |
| 92 |
case SUB_w_imm: |
| 93 |
case SUB_x_imm: mnemonic = "sub"; break; |
| 94 |
case SUBS_w_imm: |
| 95 |
case SUBS_x_imm: { |
| 96 |
mnemonic = "subs"; |
| 97 |
if (rd_is_zr) { |
| 98 |
mnemonic = "cmp"; |
| 99 |
form = form_cmp; |
| 100 |
} |
| 101 |
break; |
| 102 |
} |
| 103 |
default: VIXL_UNREACHABLE(); |
| 104 |
} |
| 105 |
Format(instr, mnemonic, form); |
| 106 |
} |
| 107 |
|
| 108 |
|
| 109 |
void Disassembler::VisitAddSubShifted(const Instruction* instr) { |
| 110 |
bool rd_is_zr = RdIsZROrSP(instr); |
| 111 |
bool rn_is_zr = RnIsZROrSP(instr); |
| 112 |
const char *mnemonic = ""; |
| 113 |
const char *form = "'Rd, 'Rn, 'Rm'NDP"; |
| 114 |
const char *form_cmp = "'Rn, 'Rm'NDP"; |
| 115 |
const char *form_neg = "'Rd, 'Rm'NDP"; |
| 116 |
|
| 117 |
switch (instr->Mask(AddSubShiftedMask)) { |
| 118 |
case ADD_w_shift: |
| 119 |
case ADD_x_shift: mnemonic = "add"; break; |
| 120 |
case ADDS_w_shift: |
| 121 |
case ADDS_x_shift: { |
| 122 |
mnemonic = "adds"; |
| 123 |
if (rd_is_zr) { |
| 124 |
mnemonic = "cmn"; |
| 125 |
form = form_cmp; |
| 126 |
} |
| 127 |
break; |
| 128 |
} |
| 129 |
case SUB_w_shift: |
| 130 |
case SUB_x_shift: { |
| 131 |
mnemonic = "sub"; |
| 132 |
if (rn_is_zr) { |
| 133 |
mnemonic = "neg"; |
| 134 |
form = form_neg; |
| 135 |
} |
| 136 |
break; |
| 137 |
} |
| 138 |
case SUBS_w_shift: |
| 139 |
case SUBS_x_shift: { |
| 140 |
mnemonic = "subs"; |
| 141 |
if (rd_is_zr) { |
| 142 |
mnemonic = "cmp"; |
| 143 |
form = form_cmp; |
| 144 |
} else if (rn_is_zr) { |
| 145 |
mnemonic = "negs"; |
| 146 |
form = form_neg; |
| 147 |
} |
| 148 |
break; |
| 149 |
} |
| 150 |
default: VIXL_UNREACHABLE(); |
| 151 |
} |
| 152 |
Format(instr, mnemonic, form); |
| 153 |
} |
| 154 |
|
| 155 |
|
| 156 |
void Disassembler::VisitAddSubExtended(const Instruction* instr) { |
| 157 |
bool rd_is_zr = RdIsZROrSP(instr); |
| 158 |
const char *mnemonic = ""; |
| 159 |
Extend mode = static_cast<Extend>(instr->ExtendMode()); |
| 160 |
const char *form = ((mode == UXTX) || (mode == SXTX)) ? |
| 161 |
"'Rds, 'Rns, 'Xm'Ext" : "'Rds, 'Rns, 'Wm'Ext"; |
| 162 |
const char *form_cmp = ((mode == UXTX) || (mode == SXTX)) ? |
| 163 |
"'Rns, 'Xm'Ext" : "'Rns, 'Wm'Ext"; |
| 164 |
|
| 165 |
switch (instr->Mask(AddSubExtendedMask)) { |
| 166 |
case ADD_w_ext: |
| 167 |
case ADD_x_ext: mnemonic = "add"; break; |
| 168 |
case ADDS_w_ext: |
| 169 |
case ADDS_x_ext: { |
| 170 |
mnemonic = "adds"; |
| 171 |
if (rd_is_zr) { |
| 172 |
mnemonic = "cmn"; |
| 173 |
form = form_cmp; |
| 174 |
} |
| 175 |
break; |
| 176 |
} |
| 177 |
case SUB_w_ext: |
| 178 |
case SUB_x_ext: mnemonic = "sub"; break; |
| 179 |
case SUBS_w_ext: |
| 180 |
case SUBS_x_ext: { |
| 181 |
mnemonic = "subs"; |
| 182 |
if (rd_is_zr) { |
| 183 |
mnemonic = "cmp"; |
| 184 |
form = form_cmp; |
| 185 |
} |
| 186 |
break; |
| 187 |
} |
| 188 |
default: VIXL_UNREACHABLE(); |
| 189 |
} |
| 190 |
Format(instr, mnemonic, form); |
| 191 |
} |
| 192 |
|
| 193 |
|
| 194 |
void Disassembler::VisitAddSubWithCarry(const Instruction* instr) { |
| 195 |
bool rn_is_zr = RnIsZROrSP(instr); |
| 196 |
const char *mnemonic = ""; |
| 197 |
const char *form = "'Rd, 'Rn, 'Rm"; |
| 198 |
const char *form_neg = "'Rd, 'Rm"; |
| 199 |
|
| 200 |
switch (instr->Mask(AddSubWithCarryMask)) { |
| 201 |
case ADC_w: |
| 202 |
case ADC_x: mnemonic = "adc"; break; |
| 203 |
case ADCS_w: |
| 204 |
case ADCS_x: mnemonic = "adcs"; break; |
| 205 |
case SBC_w: |
| 206 |
case SBC_x: { |
| 207 |
mnemonic = "sbc"; |
| 208 |
if (rn_is_zr) { |
| 209 |
mnemonic = "ngc"; |
| 210 |
form = form_neg; |
| 211 |
} |
| 212 |
break; |
| 213 |
} |
| 214 |
case SBCS_w: |
| 215 |
case SBCS_x: { |
| 216 |
mnemonic = "sbcs"; |
| 217 |
if (rn_is_zr) { |
| 218 |
mnemonic = "ngcs"; |
| 219 |
form = form_neg; |
| 220 |
} |
| 221 |
break; |
| 222 |
} |
| 223 |
default: VIXL_UNREACHABLE(); |
| 224 |
} |
| 225 |
Format(instr, mnemonic, form); |
| 226 |
} |
| 227 |
|
| 228 |
|
| 229 |
void Disassembler::VisitLogicalImmediate(const Instruction* instr) { |
| 230 |
bool rd_is_zr = RdIsZROrSP(instr); |
| 231 |
bool rn_is_zr = RnIsZROrSP(instr); |
| 232 |
const char *mnemonic = ""; |
| 233 |
const char *form = "'Rds, 'Rn, 'ITri"; |
| 234 |
|
| 235 |
if (instr->ImmLogical() == 0) { |
| 236 |
// The immediate encoded in the instruction is not in the expected format. |
| 237 |
Format(instr, "unallocated", "(LogicalImmediate)"); |
| 238 |
return; |
| 239 |
} |
| 240 |
|
| 241 |
switch (instr->Mask(LogicalImmediateMask)) { |
| 242 |
case AND_w_imm: |
| 243 |
case AND_x_imm: mnemonic = "and"; break; |
| 244 |
case ORR_w_imm: |
| 245 |
case ORR_x_imm: { |
| 246 |
mnemonic = "orr"; |
| 247 |
unsigned reg_size = (instr->SixtyFourBits() == 1) ? kXRegSize |
| 248 |
: kWRegSize; |
| 249 |
if (rn_is_zr && !IsMovzMovnImm(reg_size, instr->ImmLogical())) { |
| 250 |
mnemonic = "mov"; |
| 251 |
form = "'Rds, 'ITri"; |
| 252 |
} |
| 253 |
break; |
| 254 |
} |
| 255 |
case EOR_w_imm: |
| 256 |
case EOR_x_imm: mnemonic = "eor"; break; |
| 257 |
case ANDS_w_imm: |
| 258 |
case ANDS_x_imm: { |
| 259 |
mnemonic = "ands"; |
| 260 |
if (rd_is_zr) { |
| 261 |
mnemonic = "tst"; |
| 262 |
form = "'Rn, 'ITri"; |
| 263 |
} |
| 264 |
break; |
| 265 |
} |
| 266 |
default: VIXL_UNREACHABLE(); |
| 267 |
} |
| 268 |
Format(instr, mnemonic, form); |
| 269 |
} |
| 270 |
|
| 271 |
|
| 272 |
bool Disassembler::IsMovzMovnImm(unsigned reg_size, uint64_t value) { |
| 273 |
VIXL_ASSERT((reg_size == kXRegSize) || |
| 274 |
((reg_size == kWRegSize) && (value <= 0xffffffff))); |
| 275 |
|
| 276 |
// Test for movz: 16 bits set at positions 0, 16, 32 or 48. |
| 277 |
if (((value & UINT64_C(0xffffffffffff0000)) == 0) || |
| 278 |
((value & UINT64_C(0xffffffff0000ffff)) == 0) || |
| 279 |
((value & UINT64_C(0xffff0000ffffffff)) == 0) || |
| 280 |
((value & UINT64_C(0x0000ffffffffffff)) == 0)) { |
| 281 |
return true; |
| 282 |
} |
| 283 |
|
| 284 |
// Test for movn: NOT(16 bits set at positions 0, 16, 32 or 48). |
| 285 |
if ((reg_size == kXRegSize) && |
| 286 |
(((~value & UINT64_C(0xffffffffffff0000)) == 0) || |
| 287 |
((~value & UINT64_C(0xffffffff0000ffff)) == 0) || |
| 288 |
((~value & UINT64_C(0xffff0000ffffffff)) == 0) || |
| 289 |
((~value & UINT64_C(0x0000ffffffffffff)) == 0))) { |
| 290 |
return true; |
| 291 |
} |
| 292 |
if ((reg_size == kWRegSize) && |
| 293 |
(((value & 0xffff0000) == 0xffff0000) || |
| 294 |
((value & 0x0000ffff) == 0x0000ffff))) { |
| 295 |
return true; |
| 296 |
} |
| 297 |
return false; |
| 298 |
} |
| 299 |
|
| 300 |
|
| 301 |
void Disassembler::VisitLogicalShifted(const Instruction* instr) { |
| 302 |
bool rd_is_zr = RdIsZROrSP(instr); |
| 303 |
bool rn_is_zr = RnIsZROrSP(instr); |
| 304 |
const char *mnemonic = ""; |
| 305 |
const char *form = "'Rd, 'Rn, 'Rm'NLo"; |
| 306 |
|
| 307 |
switch (instr->Mask(LogicalShiftedMask)) { |
| 308 |
case AND_w: |
| 309 |
case AND_x: mnemonic = "and"; break; |
| 310 |
case BIC_w: |
| 311 |
case BIC_x: mnemonic = "bic"; break; |
| 312 |
case EOR_w: |
| 313 |
case EOR_x: mnemonic = "eor"; break; |
| 314 |
case EON_w: |
| 315 |
case EON_x: mnemonic = "eon"; break; |
| 316 |
case BICS_w: |
| 317 |
case BICS_x: mnemonic = "bics"; break; |
| 318 |
case ANDS_w: |
| 319 |
case ANDS_x: { |
| 320 |
mnemonic = "ands"; |
| 321 |
if (rd_is_zr) { |
| 322 |
mnemonic = "tst"; |
| 323 |
form = "'Rn, 'Rm'NLo"; |
| 324 |
} |
| 325 |
break; |
| 326 |
} |
| 327 |
case ORR_w: |
| 328 |
case ORR_x: { |
| 329 |
mnemonic = "orr"; |
| 330 |
if (rn_is_zr && (instr->ImmDPShift() == 0) && (instr->ShiftDP() == LSL)) { |
| 331 |
mnemonic = "mov"; |
| 332 |
form = "'Rd, 'Rm"; |
| 333 |
} |
| 334 |
break; |
| 335 |
} |
| 336 |
case ORN_w: |
| 337 |
case ORN_x: { |
| 338 |
mnemonic = "orn"; |
| 339 |
if (rn_is_zr) { |
| 340 |
mnemonic = "mvn"; |
| 341 |
form = "'Rd, 'Rm'NLo"; |
| 342 |
} |
| 343 |
break; |
| 344 |
} |
| 345 |
default: VIXL_UNREACHABLE(); |
| 346 |
} |
| 347 |
|
| 348 |
Format(instr, mnemonic, form); |
| 349 |
} |
| 350 |
|
| 351 |
|
| 352 |
void Disassembler::VisitConditionalCompareRegister(const Instruction* instr) { |
| 353 |
const char *mnemonic = ""; |
| 354 |
const char *form = "'Rn, 'Rm, 'INzcv, 'Cond"; |
| 355 |
|
| 356 |
switch (instr->Mask(ConditionalCompareRegisterMask)) { |
| 357 |
case CCMN_w: |
| 358 |
case CCMN_x: mnemonic = "ccmn"; break; |
| 359 |
case CCMP_w: |
| 360 |
case CCMP_x: mnemonic = "ccmp"; break; |
| 361 |
default: VIXL_UNREACHABLE(); |
| 362 |
} |
| 363 |
Format(instr, mnemonic, form); |
| 364 |
} |
| 365 |
|
| 366 |
|
| 367 |
void Disassembler::VisitConditionalCompareImmediate(const Instruction* instr) { |
| 368 |
const char *mnemonic = ""; |
| 369 |
const char *form = "'Rn, 'IP, 'INzcv, 'Cond"; |
| 370 |
|
| 371 |
switch (instr->Mask(ConditionalCompareImmediateMask)) { |
| 372 |
case CCMN_w_imm: |
| 373 |
case CCMN_x_imm: mnemonic = "ccmn"; break; |
| 374 |
case CCMP_w_imm: |
| 375 |
case CCMP_x_imm: mnemonic = "ccmp"; break; |
| 376 |
default: VIXL_UNREACHABLE(); |
| 377 |
} |
| 378 |
Format(instr, mnemonic, form); |
| 379 |
} |
| 380 |
|
| 381 |
|
| 382 |
void Disassembler::VisitConditionalSelect(const Instruction* instr) { |
| 383 |
bool rnm_is_zr = (RnIsZROrSP(instr) && RmIsZROrSP(instr)); |
| 384 |
bool rn_is_rm = (instr->Rn() == instr->Rm()); |
| 385 |
const char *mnemonic = ""; |
| 386 |
const char *form = "'Rd, 'Rn, 'Rm, 'Cond"; |
| 387 |
const char *form_test = "'Rd, 'CInv"; |
| 388 |
const char *form_update = "'Rd, 'Rn, 'CInv"; |
| 389 |
|
| 390 |
Condition cond = static_cast<Condition>(instr->Condition()); |
| 391 |
bool invertible_cond = (cond != al) && (cond != nv); |
| 392 |
|
| 393 |
switch (instr->Mask(ConditionalSelectMask)) { |
| 394 |
case CSEL_w: |
| 395 |
case CSEL_x: mnemonic = "csel"; break; |
| 396 |
case CSINC_w: |
| 397 |
case CSINC_x: { |
| 398 |
mnemonic = "csinc"; |
| 399 |
if (rnm_is_zr && invertible_cond) { |
| 400 |
mnemonic = "cset"; |
| 401 |
form = form_test; |
| 402 |
} else if (rn_is_rm && invertible_cond) { |
| 403 |
mnemonic = "cinc"; |
| 404 |
form = form_update; |
| 405 |
} |
| 406 |
break; |
| 407 |
} |
| 408 |
case CSINV_w: |
| 409 |
case CSINV_x: { |
| 410 |
mnemonic = "csinv"; |
| 411 |
if (rnm_is_zr && invertible_cond) { |
| 412 |
mnemonic = "csetm"; |
| 413 |
form = form_test; |
| 414 |
} else if (rn_is_rm && invertible_cond) { |
| 415 |
mnemonic = "cinv"; |
| 416 |
form = form_update; |
| 417 |
} |
| 418 |
break; |
| 419 |
} |
| 420 |
case CSNEG_w: |
| 421 |
case CSNEG_x: { |
| 422 |
mnemonic = "csneg"; |
| 423 |
if (rn_is_rm && invertible_cond) { |
| 424 |
mnemonic = "cneg"; |
| 425 |
form = form_update; |
| 426 |
} |
| 427 |
break; |
| 428 |
} |
| 429 |
default: VIXL_UNREACHABLE(); |
| 430 |
} |
| 431 |
Format(instr, mnemonic, form); |
| 432 |
} |
| 433 |
|
| 434 |
|
| 435 |
void Disassembler::VisitBitfield(const Instruction* instr) { |
| 436 |
unsigned s = instr->ImmS(); |
| 437 |
unsigned r = instr->ImmR(); |
| 438 |
unsigned rd_size_minus_1 = |
| 439 |
((instr->SixtyFourBits() == 1) ? kXRegSize : kWRegSize) - 1; |
| 440 |
const char *mnemonic = ""; |
| 441 |
const char *form = ""; |
| 442 |
const char *form_shift_right = "'Rd, 'Rn, 'IBr"; |
| 443 |
const char *form_extend = "'Rd, 'Wn"; |
| 444 |
const char *form_bfiz = "'Rd, 'Rn, 'IBZ-r, 'IBs+1"; |
| 445 |
const char *form_bfx = "'Rd, 'Rn, 'IBr, 'IBs-r+1"; |
| 446 |
const char *form_lsl = "'Rd, 'Rn, 'IBZ-r"; |
| 447 |
|
| 448 |
switch (instr->Mask(BitfieldMask)) { |
| 449 |
case SBFM_w: |
| 450 |
case SBFM_x: { |
| 451 |
mnemonic = "sbfx"; |
| 452 |
form = form_bfx; |
| 453 |
if (r == 0) { |
| 454 |
form = form_extend; |
| 455 |
if (s == 7) { |
| 456 |
mnemonic = "sxtb"; |
| 457 |
} else if (s == 15) { |
| 458 |
mnemonic = "sxth"; |
| 459 |
} else if ((s == 31) && (instr->SixtyFourBits() == 1)) { |
| 460 |
mnemonic = "sxtw"; |
| 461 |
} else { |
| 462 |
form = form_bfx; |
| 463 |
} |
| 464 |
} else if (s == rd_size_minus_1) { |
| 465 |
mnemonic = "asr"; |
| 466 |
form = form_shift_right; |
| 467 |
} else if (s < r) { |
| 468 |
mnemonic = "sbfiz"; |
| 469 |
form = form_bfiz; |
| 470 |
} |
| 471 |
break; |
| 472 |
} |
| 473 |
case UBFM_w: |
| 474 |
case UBFM_x: { |
| 475 |
mnemonic = "ubfx"; |
| 476 |
form = form_bfx; |
| 477 |
if (r == 0) { |
| 478 |
form = form_extend; |
| 479 |
if (s == 7) { |
| 480 |
mnemonic = "uxtb"; |
| 481 |
} else if (s == 15) { |
| 482 |
mnemonic = "uxth"; |
| 483 |
} else { |
| 484 |
form = form_bfx; |
| 485 |
} |
| 486 |
} |
| 487 |
if (s == rd_size_minus_1) { |
| 488 |
mnemonic = "lsr"; |
| 489 |
form = form_shift_right; |
| 490 |
} else if (r == s + 1) { |
| 491 |
mnemonic = "lsl"; |
| 492 |
form = form_lsl; |
| 493 |
} else if (s < r) { |
| 494 |
mnemonic = "ubfiz"; |
| 495 |
form = form_bfiz; |
| 496 |
} |
| 497 |
break; |
| 498 |
} |
| 499 |
case BFM_w: |
| 500 |
case BFM_x: { |
| 501 |
mnemonic = "bfxil"; |
| 502 |
form = form_bfx; |
| 503 |
if (s < r) { |
| 504 |
mnemonic = "bfi"; |
| 505 |
form = form_bfiz; |
| 506 |
} |
| 507 |
} |
| 508 |
} |
| 509 |
Format(instr, mnemonic, form); |
| 510 |
} |
| 511 |
|
| 512 |
|
| 513 |
void Disassembler::VisitExtract(const Instruction* instr) { |
| 514 |
const char *mnemonic = ""; |
| 515 |
const char *form = "'Rd, 'Rn, 'Rm, 'IExtract"; |
| 516 |
|
| 517 |
switch (instr->Mask(ExtractMask)) { |
| 518 |
case EXTR_w: |
| 519 |
case EXTR_x: { |
| 520 |
if (instr->Rn() == instr->Rm()) { |
| 521 |
mnemonic = "ror"; |
| 522 |
form = "'Rd, 'Rn, 'IExtract"; |
| 523 |
} else { |
| 524 |
mnemonic = "extr"; |
| 525 |
} |
| 526 |
break; |
| 527 |
} |
| 528 |
default: VIXL_UNREACHABLE(); |
| 529 |
} |
| 530 |
Format(instr, mnemonic, form); |
| 531 |
} |
| 532 |
|
| 533 |
|
| 534 |
void Disassembler::VisitPCRelAddressing(const Instruction* instr) { |
| 535 |
switch (instr->Mask(PCRelAddressingMask)) { |
| 536 |
case ADR: Format(instr, "adr", "'Xd, 'AddrPCRelByte"); break; |
| 537 |
case ADRP: Format(instr, "adrp", "'Xd, 'AddrPCRelPage"); break; |
| 538 |
default: Format(instr, "unimplemented", "(PCRelAddressing)"); |
| 539 |
} |
| 540 |
} |
| 541 |
|
| 542 |
|
| 543 |
void Disassembler::VisitConditionalBranch(const Instruction* instr) { |
| 544 |
switch (instr->Mask(ConditionalBranchMask)) { |
| 545 |
case B_cond: Format(instr, "b.'CBrn", "'TImmCond"); break; |
| 546 |
default: VIXL_UNREACHABLE(); |
| 547 |
} |
| 548 |
} |
| 549 |
|
| 550 |
|
| 551 |
void Disassembler::VisitUnconditionalBranchToRegister( |
| 552 |
const Instruction* instr) { |
| 553 |
const char *mnemonic = "unimplemented"; |
| 554 |
const char *form = "'Xn"; |
| 555 |
|
| 556 |
switch (instr->Mask(UnconditionalBranchToRegisterMask)) { |
| 557 |
case BR: mnemonic = "br"; break; |
| 558 |
case BLR: mnemonic = "blr"; break; |
| 559 |
case RET: { |
| 560 |
mnemonic = "ret"; |
| 561 |
if (instr->Rn() == kLinkRegCode) { |
| 562 |
form = NULL; |
| 563 |
} |
| 564 |
break; |
| 565 |
} |
| 566 |
default: form = "(UnconditionalBranchToRegister)"; |
| 567 |
} |
| 568 |
Format(instr, mnemonic, form); |
| 569 |
} |
| 570 |
|
| 571 |
|
| 572 |
void Disassembler::VisitUnconditionalBranch(const Instruction* instr) { |
| 573 |
const char *mnemonic = ""; |
| 574 |
const char *form = "'TImmUncn"; |
| 575 |
|
| 576 |
switch (instr->Mask(UnconditionalBranchMask)) { |
| 577 |
case B: mnemonic = "b"; break; |
| 578 |
case BL: mnemonic = "bl"; break; |
| 579 |
default: VIXL_UNREACHABLE(); |
| 580 |
} |
| 581 |
Format(instr, mnemonic, form); |
| 582 |
} |
| 583 |
|
| 584 |
|
| 585 |
void Disassembler::VisitDataProcessing1Source(const Instruction* instr) { |
| 586 |
const char *mnemonic = ""; |
| 587 |
const char *form = "'Rd, 'Rn"; |
| 588 |
|
| 589 |
switch (instr->Mask(DataProcessing1SourceMask)) { |
| 590 |
#define FORMAT(A, B) \ |
| 591 |
case A##_w: \ |
| 592 |
case A##_x: mnemonic = B; break; |
| 593 |
FORMAT(RBIT, "rbit"); |
| 594 |
FORMAT(REV16, "rev16"); |
| 595 |
FORMAT(REV, "rev"); |
| 596 |
FORMAT(CLZ, "clz"); |
| 597 |
FORMAT(CLS, "cls"); |
| 598 |
#undef FORMAT |
| 599 |
case REV32_x: mnemonic = "rev32"; break; |
| 600 |
default: VIXL_UNREACHABLE(); |
| 601 |
} |
| 602 |
Format(instr, mnemonic, form); |
| 603 |
} |
| 604 |
|
| 605 |
|
| 606 |
void Disassembler::VisitDataProcessing2Source(const Instruction* instr) { |
| 607 |
const char *mnemonic = "unimplemented"; |
| 608 |
const char *form = "'Rd, 'Rn, 'Rm"; |
| 609 |
const char *form_wwx = "'Wd, 'Wn, 'Xm"; |
| 610 |
|
| 611 |
switch (instr->Mask(DataProcessing2SourceMask)) { |
| 612 |
#define FORMAT(A, B) \ |
| 613 |
case A##_w: \ |
| 614 |
case A##_x: mnemonic = B; break; |
| 615 |
FORMAT(UDIV, "udiv"); |
| 616 |
FORMAT(SDIV, "sdiv"); |
| 617 |
FORMAT(LSLV, "lsl"); |
| 618 |
FORMAT(LSRV, "lsr"); |
| 619 |
FORMAT(ASRV, "asr"); |
| 620 |
FORMAT(RORV, "ror"); |
| 621 |
#undef FORMAT |
| 622 |
case CRC32B: mnemonic = "crc32b"; break; |
| 623 |
case CRC32H: mnemonic = "crc32h"; break; |
| 624 |
case CRC32W: mnemonic = "crc32w"; break; |
| 625 |
case CRC32X: mnemonic = "crc32x"; form = form_wwx; break; |
| 626 |
case CRC32CB: mnemonic = "crc32cb"; break; |
| 627 |
case CRC32CH: mnemonic = "crc32ch"; break; |
| 628 |
case CRC32CW: mnemonic = "crc32cw"; break; |
| 629 |
case CRC32CX: mnemonic = "crc32cx"; form = form_wwx; break; |
| 630 |
default: form = "(DataProcessing2Source)"; |
| 631 |
} |
| 632 |
Format(instr, mnemonic, form); |
| 633 |
} |
| 634 |
|
| 635 |
|
| 636 |
void Disassembler::VisitDataProcessing3Source(const Instruction* instr) { |
| 637 |
bool ra_is_zr = RaIsZROrSP(instr); |
| 638 |
const char *mnemonic = ""; |
| 639 |
const char *form = "'Xd, 'Wn, 'Wm, 'Xa"; |
| 640 |
const char *form_rrr = "'Rd, 'Rn, 'Rm"; |
| 641 |
const char *form_rrrr = "'Rd, 'Rn, 'Rm, 'Ra"; |
| 642 |
const char *form_xww = "'Xd, 'Wn, 'Wm"; |
| 643 |
const char *form_xxx = "'Xd, 'Xn, 'Xm"; |
| 644 |
|
| 645 |
switch (instr->Mask(DataProcessing3SourceMask)) { |
| 646 |
case MADD_w: |
| 647 |
case MADD_x: { |
| 648 |
mnemonic = "madd"; |
| 649 |
form = form_rrrr; |
| 650 |
if (ra_is_zr) { |
| 651 |
mnemonic = "mul"; |
| 652 |
form = form_rrr; |
| 653 |
} |
| 654 |
break; |
| 655 |
} |
| 656 |
case MSUB_w: |
| 657 |
case MSUB_x: { |
| 658 |
mnemonic = "msub"; |
| 659 |
form = form_rrrr; |
| 660 |
if (ra_is_zr) { |
| 661 |
mnemonic = "mneg"; |
| 662 |
form = form_rrr; |
| 663 |
} |
| 664 |
break; |
| 665 |
} |
| 666 |
case SMADDL_x: { |
| 667 |
mnemonic = "smaddl"; |
| 668 |
if (ra_is_zr) { |
| 669 |
mnemonic = "smull"; |
| 670 |
form = form_xww; |
| 671 |
} |
| 672 |
break; |
| 673 |
} |
| 674 |
case SMSUBL_x: { |
| 675 |
mnemonic = "smsubl"; |
| 676 |
if (ra_is_zr) { |
| 677 |
mnemonic = "smnegl"; |
| 678 |
form = form_xww; |
| 679 |
} |
| 680 |
break; |
| 681 |
} |
| 682 |
case UMADDL_x: { |
| 683 |
mnemonic = "umaddl"; |
| 684 |
if (ra_is_zr) { |
| 685 |
mnemonic = "umull"; |
| 686 |
form = form_xww; |
| 687 |
} |
| 688 |
break; |
| 689 |
} |
| 690 |
case UMSUBL_x: { |
| 691 |
mnemonic = "umsubl"; |
| 692 |
if (ra_is_zr) { |
| 693 |
mnemonic = "umnegl"; |
| 694 |
form = form_xww; |
| 695 |
} |
| 696 |
break; |
| 697 |
} |
| 698 |
case SMULH_x: { |
| 699 |
mnemonic = "smulh"; |
| 700 |
form = form_xxx; |
| 701 |
break; |
| 702 |
} |
| 703 |
case UMULH_x: { |
| 704 |
mnemonic = "umulh"; |
| 705 |
form = form_xxx; |
| 706 |
break; |
| 707 |
} |
| 708 |
default: VIXL_UNREACHABLE(); |
| 709 |
} |
| 710 |
Format(instr, mnemonic, form); |
| 711 |
} |
| 712 |
|
| 713 |
|
| 714 |
void Disassembler::VisitCompareBranch(const Instruction* instr) { |
| 715 |
const char *mnemonic = ""; |
| 716 |
const char *form = "'Rt, 'TImmCmpa"; |
| 717 |
|
| 718 |
switch (instr->Mask(CompareBranchMask)) { |
| 719 |
case CBZ_w: |
| 720 |
case CBZ_x: mnemonic = "cbz"; break; |
| 721 |
case CBNZ_w: |
| 722 |
case CBNZ_x: mnemonic = "cbnz"; break; |
| 723 |
default: VIXL_UNREACHABLE(); |
| 724 |
} |
| 725 |
Format(instr, mnemonic, form); |
| 726 |
} |
| 727 |
|
| 728 |
|
| 729 |
void Disassembler::VisitTestBranch(const Instruction* instr) { |
| 730 |
const char *mnemonic = ""; |
| 731 |
// If the top bit of the immediate is clear, the tested register is |
| 732 |
// disassembled as Wt, otherwise Xt. As the top bit of the immediate is |
| 733 |
// encoded in bit 31 of the instruction, we can reuse the Rt form, which |
| 734 |
// uses bit 31 (normally "sf") to choose the register size. |
| 735 |
const char *form = "'Rt, 'IS, 'TImmTest"; |
| 736 |
|
| 737 |
switch (instr->Mask(TestBranchMask)) { |
| 738 |
case TBZ: mnemonic = "tbz"; break; |
| 739 |
case TBNZ: mnemonic = "tbnz"; break; |
| 740 |
default: VIXL_UNREACHABLE(); |
| 741 |
} |
| 742 |
Format(instr, mnemonic, form); |
| 743 |
} |
| 744 |
|
| 745 |
|
| 746 |
void Disassembler::VisitMoveWideImmediate(const Instruction* instr) { |
| 747 |
const char *mnemonic = ""; |
| 748 |
const char *form = "'Rd, 'IMoveImm"; |
| 749 |
|
| 750 |
// Print the shift separately for movk, to make it clear which half word will |
| 751 |
// be overwritten. Movn and movz print the computed immediate, which includes |
| 752 |
// shift calculation. |
| 753 |
switch (instr->Mask(MoveWideImmediateMask)) { |
| 754 |
case MOVN_w: |
| 755 |
case MOVN_x: |
| 756 |
if ((instr->ImmMoveWide()) || (instr->ShiftMoveWide() == 0)) { |
| 757 |
if ((instr->SixtyFourBits() == 0) && (instr->ImmMoveWide() == 0xffff)) { |
| 758 |
mnemonic = "movn"; |
| 759 |
} else { |
| 760 |
mnemonic = "mov"; |
| 761 |
form = "'Rd, 'IMoveNeg"; |
| 762 |
} |
| 763 |
} else { |
| 764 |
mnemonic = "movn"; |
| 765 |
} |
| 766 |
break; |
| 767 |
case MOVZ_w: |
| 768 |
case MOVZ_x: |
| 769 |
if ((instr->ImmMoveWide()) || (instr->ShiftMoveWide() == 0)) |
| 770 |
mnemonic = "mov"; |
| 771 |
else |
| 772 |
mnemonic = "movz"; |
| 773 |
break; |
| 774 |
case MOVK_w: |
| 775 |
case MOVK_x: mnemonic = "movk"; form = "'Rd, 'IMoveLSL"; break; |
| 776 |
default: VIXL_UNREACHABLE(); |
| 777 |
} |
| 778 |
Format(instr, mnemonic, form); |
| 779 |
} |
| 780 |
|
| 781 |
|
| 782 |
#define LOAD_STORE_LIST(V) \ |
| 783 |
V(STRB_w, "strb", "'Wt") \ |
| 784 |
V(STRH_w, "strh", "'Wt") \ |
| 785 |
V(STR_w, "str", "'Wt") \ |
| 786 |
V(STR_x, "str", "'Xt") \ |
| 787 |
V(LDRB_w, "ldrb", "'Wt") \ |
| 788 |
V(LDRH_w, "ldrh", "'Wt") \ |
| 789 |
V(LDR_w, "ldr", "'Wt") \ |
| 790 |
V(LDR_x, "ldr", "'Xt") \ |
| 791 |
V(LDRSB_x, "ldrsb", "'Xt") \ |
| 792 |
V(LDRSH_x, "ldrsh", "'Xt") \ |
| 793 |
V(LDRSW_x, "ldrsw", "'Xt") \ |
| 794 |
V(LDRSB_w, "ldrsb", "'Wt") \ |
| 795 |
V(LDRSH_w, "ldrsh", "'Wt") \ |
| 796 |
V(STR_b, "str", "'Bt") \ |
| 797 |
V(STR_h, "str", "'Ht") \ |
| 798 |
V(STR_s, "str", "'St") \ |
| 799 |
V(STR_d, "str", "'Dt") \ |
| 800 |
V(LDR_b, "ldr", "'Bt") \ |
| 801 |
V(LDR_h, "ldr", "'Ht") \ |
| 802 |
V(LDR_s, "ldr", "'St") \ |
| 803 |
V(LDR_d, "ldr", "'Dt") \ |
| 804 |
V(STR_q, "str", "'Qt") \ |
| 805 |
V(LDR_q, "ldr", "'Qt") |
| 806 |
|
| 807 |
void Disassembler::VisitLoadStorePreIndex(const Instruction* instr) { |
| 808 |
const char *mnemonic = "unimplemented"; |
| 809 |
const char *form = "(LoadStorePreIndex)"; |
| 810 |
|
| 811 |
switch (instr->Mask(LoadStorePreIndexMask)) { |
| 812 |
#define LS_PREINDEX(A, B, C) \ |
| 813 |
case A##_pre: mnemonic = B; form = C ", ['Xns'ILS]!"; break; |
| 814 |
LOAD_STORE_LIST(LS_PREINDEX) |
| 815 |
#undef LS_PREINDEX |
| 816 |
} |
| 817 |
Format(instr, mnemonic, form); |
| 818 |
} |
| 819 |
|
| 820 |
|
| 821 |
void Disassembler::VisitLoadStorePostIndex(const Instruction* instr) { |
| 822 |
const char *mnemonic = "unimplemented"; |
| 823 |
const char *form = "(LoadStorePostIndex)"; |
| 824 |
|
| 825 |
switch (instr->Mask(LoadStorePostIndexMask)) { |
| 826 |
#define LS_POSTINDEX(A, B, C) \ |
| 827 |
case A##_post: mnemonic = B; form = C ", ['Xns]'ILS"; break; |
| 828 |
LOAD_STORE_LIST(LS_POSTINDEX) |
| 829 |
#undef LS_POSTINDEX |
| 830 |
} |
| 831 |
Format(instr, mnemonic, form); |
| 832 |
} |
| 833 |
|
| 834 |
|
| 835 |
void Disassembler::VisitLoadStoreUnsignedOffset(const Instruction* instr) { |
| 836 |
const char *mnemonic = "unimplemented"; |
| 837 |
const char *form = "(LoadStoreUnsignedOffset)"; |
| 838 |
|
| 839 |
switch (instr->Mask(LoadStoreUnsignedOffsetMask)) { |
| 840 |
#define LS_UNSIGNEDOFFSET(A, B, C) \ |
| 841 |
case A##_unsigned: mnemonic = B; form = C ", ['Xns'ILU]"; break; |
| 842 |
LOAD_STORE_LIST(LS_UNSIGNEDOFFSET) |
| 843 |
#undef LS_UNSIGNEDOFFSET |
| 844 |
case PRFM_unsigned: mnemonic = "prfm"; form = "'PrefOp, ['Xns'ILU]"; |
| 845 |
} |
| 846 |
Format(instr, mnemonic, form); |
| 847 |
} |
| 848 |
|
| 849 |
|
| 850 |
void Disassembler::VisitLoadStoreRegisterOffset(const Instruction* instr) { |
| 851 |
const char *mnemonic = "unimplemented"; |
| 852 |
const char *form = "(LoadStoreRegisterOffset)"; |
| 853 |
|
| 854 |
switch (instr->Mask(LoadStoreRegisterOffsetMask)) { |
| 855 |
#define LS_REGISTEROFFSET(A, B, C) \ |
| 856 |
case A##_reg: mnemonic = B; form = C ", ['Xns, 'Offsetreg]"; break; |
| 857 |
LOAD_STORE_LIST(LS_REGISTEROFFSET) |
| 858 |
#undef LS_REGISTEROFFSET |
| 859 |
case PRFM_reg: mnemonic = "prfm"; form = "'PrefOp, ['Xns, 'Offsetreg]"; |
| 860 |
} |
| 861 |
Format(instr, mnemonic, form); |
| 862 |
} |
| 863 |
|
| 864 |
|
| 865 |
void Disassembler::VisitLoadStoreUnscaledOffset(const Instruction* instr) { |
| 866 |
const char *mnemonic = "unimplemented"; |
| 867 |
const char *form = "'Wt, ['Xns'ILS]"; |
| 868 |
const char *form_x = "'Xt, ['Xns'ILS]"; |
| 869 |
const char *form_b = "'Bt, ['Xns'ILS]"; |
| 870 |
const char *form_h = "'Ht, ['Xns'ILS]"; |
| 871 |
const char *form_s = "'St, ['Xns'ILS]"; |
| 872 |
const char *form_d = "'Dt, ['Xns'ILS]"; |
| 873 |
const char *form_q = "'Qt, ['Xns'ILS]"; |
| 874 |
const char *form_prefetch = "'PrefOp, ['Xns'ILS]"; |
| 875 |
|
| 876 |
switch (instr->Mask(LoadStoreUnscaledOffsetMask)) { |
| 877 |
case STURB_w: mnemonic = "sturb"; break; |
| 878 |
case STURH_w: mnemonic = "sturh"; break; |
| 879 |
case STUR_w: mnemonic = "stur"; break; |
| 880 |
case STUR_x: mnemonic = "stur"; form = form_x; break; |
| 881 |
case STUR_b: mnemonic = "stur"; form = form_b; break; |
| 882 |
case STUR_h: mnemonic = "stur"; form = form_h; break; |
| 883 |
case STUR_s: mnemonic = "stur"; form = form_s; break; |
| 884 |
case STUR_d: mnemonic = "stur"; form = form_d; break; |
| 885 |
case STUR_q: mnemonic = "stur"; form = form_q; break; |
| 886 |
case LDURB_w: mnemonic = "ldurb"; break; |
| 887 |
case LDURH_w: mnemonic = "ldurh"; break; |
| 888 |
case LDUR_w: mnemonic = "ldur"; break; |
| 889 |
case LDUR_x: mnemonic = "ldur"; form = form_x; break; |
| 890 |
case LDUR_b: mnemonic = "ldur"; form = form_b; break; |
| 891 |
case LDUR_h: mnemonic = "ldur"; form = form_h; break; |
| 892 |
case LDUR_s: mnemonic = "ldur"; form = form_s; break; |
| 893 |
case LDUR_d: mnemonic = "ldur"; form = form_d; break; |
| 894 |
case LDUR_q: mnemonic = "ldur"; form = form_q; break; |
| 895 |
case LDURSB_x: form = form_x; VIXL_FALLTHROUGH(); |
| 896 |
case LDURSB_w: mnemonic = "ldursb"; break; |
| 897 |
case LDURSH_x: form = form_x; VIXL_FALLTHROUGH(); |
| 898 |
case LDURSH_w: mnemonic = "ldursh"; break; |
| 899 |
case LDURSW_x: mnemonic = "ldursw"; form = form_x; break; |
| 900 |
case PRFUM: mnemonic = "prfum"; form = form_prefetch; break; |
| 901 |
default: form = "(LoadStoreUnscaledOffset)"; |
| 902 |
} |
| 903 |
Format(instr, mnemonic, form); |
| 904 |
} |
| 905 |
|
| 906 |
|
| 907 |
void Disassembler::VisitLoadLiteral(const Instruction* instr) { |
| 908 |
const char *mnemonic = "ldr"; |
| 909 |
const char *form = "(LoadLiteral)"; |
| 910 |
|
| 911 |
switch (instr->Mask(LoadLiteralMask)) { |
| 912 |
case LDR_w_lit: form = "'Wt, 'ILLiteral 'LValue"; break; |
| 913 |
case LDR_x_lit: form = "'Xt, 'ILLiteral 'LValue"; break; |
| 914 |
case LDR_s_lit: form = "'St, 'ILLiteral 'LValue"; break; |
| 915 |
case LDR_d_lit: form = "'Dt, 'ILLiteral 'LValue"; break; |
| 916 |
case LDR_q_lit: form = "'Qt, 'ILLiteral 'LValue"; break; |
| 917 |
case LDRSW_x_lit: { |
| 918 |
mnemonic = "ldrsw"; |
| 919 |
form = "'Xt, 'ILLiteral 'LValue"; |
| 920 |
break; |
| 921 |
} |
| 922 |
case PRFM_lit: { |
| 923 |
mnemonic = "prfm"; |
| 924 |
form = "'PrefOp, 'ILLiteral 'LValue"; |
| 925 |
break; |
| 926 |
} |
| 927 |
default: mnemonic = "unimplemented"; |
| 928 |
} |
| 929 |
Format(instr, mnemonic, form); |
| 930 |
} |
| 931 |
|
| 932 |
|
| 933 |
#define LOAD_STORE_PAIR_LIST(V) \ |
| 934 |
V(STP_w, "stp", "'Wt, 'Wt2", "2") \ |
| 935 |
V(LDP_w, "ldp", "'Wt, 'Wt2", "2") \ |
| 936 |
V(LDPSW_x, "ldpsw", "'Xt, 'Xt2", "2") \ |
| 937 |
V(STP_x, "stp", "'Xt, 'Xt2", "3") \ |
| 938 |
V(LDP_x, "ldp", "'Xt, 'Xt2", "3") \ |
| 939 |
V(STP_s, "stp", "'St, 'St2", "2") \ |
| 940 |
V(LDP_s, "ldp", "'St, 'St2", "2") \ |
| 941 |
V(STP_d, "stp", "'Dt, 'Dt2", "3") \ |
| 942 |
V(LDP_d, "ldp", "'Dt, 'Dt2", "3") \ |
| 943 |
V(LDP_q, "ldp", "'Qt, 'Qt2", "4") \ |
| 944 |
V(STP_q, "stp", "'Qt, 'Qt2", "4") |
| 945 |
|
| 946 |
void Disassembler::VisitLoadStorePairPostIndex(const Instruction* instr) { |
| 947 |
const char *mnemonic = "unimplemented"; |
| 948 |
const char *form = "(LoadStorePairPostIndex)"; |
| 949 |
|
| 950 |
switch (instr->Mask(LoadStorePairPostIndexMask)) { |
| 951 |
#define LSP_POSTINDEX(A, B, C, D) \ |
| 952 |
case A##_post: mnemonic = B; form = C ", ['Xns]'ILP" D; break; |
| 953 |
LOAD_STORE_PAIR_LIST(LSP_POSTINDEX) |
| 954 |
#undef LSP_POSTINDEX |
| 955 |
} |
| 956 |
Format(instr, mnemonic, form); |
| 957 |
} |
| 958 |
|
| 959 |
|
| 960 |
void Disassembler::VisitLoadStorePairPreIndex(const Instruction* instr) { |
| 961 |
const char *mnemonic = "unimplemented"; |
| 962 |
const char *form = "(LoadStorePairPreIndex)"; |
| 963 |
|
| 964 |
switch (instr->Mask(LoadStorePairPreIndexMask)) { |
| 965 |
#define LSP_PREINDEX(A, B, C, D) \ |
| 966 |
case A##_pre: mnemonic = B; form = C ", ['Xns'ILP" D "]!"; break; |
| 967 |
LOAD_STORE_PAIR_LIST(LSP_PREINDEX) |
| 968 |
#undef LSP_PREINDEX |
| 969 |
} |
| 970 |
Format(instr, mnemonic, form); |
| 971 |
} |
| 972 |
|
| 973 |
|
| 974 |
void Disassembler::VisitLoadStorePairOffset(const Instruction* instr) { |
| 975 |
const char *mnemonic = "unimplemented"; |
| 976 |
const char *form = "(LoadStorePairOffset)"; |
| 977 |
|
| 978 |
switch (instr->Mask(LoadStorePairOffsetMask)) { |
| 979 |
#define LSP_OFFSET(A, B, C, D) \ |
| 980 |
case A##_off: mnemonic = B; form = C ", ['Xns'ILP" D "]"; break; |
| 981 |
LOAD_STORE_PAIR_LIST(LSP_OFFSET) |
| 982 |
#undef LSP_OFFSET |
| 983 |
} |
| 984 |
Format(instr, mnemonic, form); |
| 985 |
} |
| 986 |
|
| 987 |
|
| 988 |
void Disassembler::VisitLoadStorePairNonTemporal(const Instruction* instr) { |
| 989 |
const char *mnemonic = "unimplemented"; |
| 990 |
const char *form; |
| 991 |
|
| 992 |
switch (instr->Mask(LoadStorePairNonTemporalMask)) { |
| 993 |
case STNP_w: mnemonic = "stnp"; form = "'Wt, 'Wt2, ['Xns'ILP2]"; break; |
| 994 |
case LDNP_w: mnemonic = "ldnp"; form = "'Wt, 'Wt2, ['Xns'ILP2]"; break; |
| 995 |
case STNP_x: mnemonic = "stnp"; form = "'Xt, 'Xt2, ['Xns'ILP3]"; break; |
| 996 |
case LDNP_x: mnemonic = "ldnp"; form = "'Xt, 'Xt2, ['Xns'ILP3]"; break; |
| 997 |
case STNP_s: mnemonic = "stnp"; form = "'St, 'St2, ['Xns'ILP2]"; break; |
| 998 |
case LDNP_s: mnemonic = "ldnp"; form = "'St, 'St2, ['Xns'ILP2]"; break; |
| 999 |
case STNP_d: mnemonic = "stnp"; form = "'Dt, 'Dt2, ['Xns'ILP3]"; break; |
| 1000 |
case LDNP_d: mnemonic = "ldnp"; form = "'Dt, 'Dt2, ['Xns'ILP3]"; break; |
| 1001 |
case STNP_q: mnemonic = "stnp"; form = "'Qt, 'Qt2, ['Xns'ILP4]"; break; |
| 1002 |
case LDNP_q: mnemonic = "ldnp"; form = "'Qt, 'Qt2, ['Xns'ILP4]"; break; |
| 1003 |
default: form = "(LoadStorePairNonTemporal)"; |
| 1004 |
} |
| 1005 |
Format(instr, mnemonic, form); |
| 1006 |
} |
| 1007 |
|
| 1008 |
// clang-format off |
| 1009 |
#define LOAD_STORE_EXCLUSIVE_LIST(V) \ |
| 1010 |
V(STXRB_w, "stxrb", "'Ws, 'Wt") \ |
| 1011 |
V(STXRH_w, "stxrh", "'Ws, 'Wt") \ |
| 1012 |
V(STXR_w, "stxr", "'Ws, 'Wt") \ |
| 1013 |
V(STXR_x, "stxr", "'Ws, 'Xt") \ |
| 1014 |
V(LDXRB_w, "ldxrb", "'Wt") \ |
| 1015 |
V(LDXRH_w, "ldxrh", "'Wt") \ |
| 1016 |
V(LDXR_w, "ldxr", "'Wt") \ |
| 1017 |
V(LDXR_x, "ldxr", "'Xt") \ |
| 1018 |
V(STXP_w, "stxp", "'Ws, 'Wt, 'Wt2") \ |
| 1019 |
V(STXP_x, "stxp", "'Ws, 'Xt, 'Xt2") \ |
| 1020 |
V(LDXP_w, "ldxp", "'Wt, 'Wt2") \ |
| 1021 |
V(LDXP_x, "ldxp", "'Xt, 'Xt2") \ |
| 1022 |
V(STLXRB_w, "stlxrb", "'Ws, 'Wt") \ |
| 1023 |
V(STLXRH_w, "stlxrh", "'Ws, 'Wt") \ |
| 1024 |
V(STLXR_w, "stlxr", "'Ws, 'Wt") \ |
| 1025 |
V(STLXR_x, "stlxr", "'Ws, 'Xt") \ |
| 1026 |
V(LDAXRB_w, "ldaxrb", "'Wt") \ |
| 1027 |
V(LDAXRH_w, "ldaxrh", "'Wt") \ |
| 1028 |
V(LDAXR_w, "ldaxr", "'Wt") \ |
| 1029 |
V(LDAXR_x, "ldaxr", "'Xt") \ |
| 1030 |
V(STLXP_w, "stlxp", "'Ws, 'Wt, 'Wt2") \ |
| 1031 |
V(STLXP_x, "stlxp", "'Ws, 'Xt, 'Xt2") \ |
| 1032 |
V(LDAXP_w, "ldaxp", "'Wt, 'Wt2") \ |
| 1033 |
V(LDAXP_x, "ldaxp", "'Xt, 'Xt2") \ |
| 1034 |
V(STLRB_w, "stlrb", "'Wt") \ |
| 1035 |
V(STLRH_w, "stlrh", "'Wt") \ |
| 1036 |
V(STLR_w, "stlr", "'Wt") \ |
| 1037 |
V(STLR_x, "stlr", "'Xt") \ |
| 1038 |
V(LDARB_w, "ldarb", "'Wt") \ |
| 1039 |
V(LDARH_w, "ldarh", "'Wt") \ |
| 1040 |
V(LDAR_w, "ldar", "'Wt") \ |
| 1041 |
V(LDAR_x, "ldar", "'Xt") \ |
| 1042 |
V(CAS_w, "cas", "'Ws, 'Wt") \ |
| 1043 |
V(CAS_x, "cas", "'Xs, 'Xt") \ |
| 1044 |
V(CASA_w, "casa", "'Ws, 'Wt") \ |
| 1045 |
V(CASA_x, "casa", "'Xs, 'Xt") \ |
| 1046 |
V(CASL_w, "casl", "'Ws, 'Wt") \ |
| 1047 |
V(CASL_x, "casl", "'Xs, 'Xt") \ |
| 1048 |
V(CASAL_w, "casal", "'Ws, 'Wt") \ |
| 1049 |
V(CASAL_x, "casal", "'Xs, 'Xt") \ |
| 1050 |
V(CASB, "casb", "'Ws, 'Wt") \ |
| 1051 |
V(CASAB, "casab", "'Ws, 'Wt") \ |
| 1052 |
V(CASLB, "caslb", "'Ws, 'Wt") \ |
| 1053 |
V(CASALB, "casalb", "'Ws, 'Wt") \ |
| 1054 |
V(CASH, "cash", "'Ws, 'Wt") \ |
| 1055 |
V(CASAH, "casah", "'Ws, 'Wt") \ |
| 1056 |
V(CASLH, "caslh", "'Ws, 'Wt") \ |
| 1057 |
V(CASALH, "casalh", "'Ws, 'Wt") \ |
| 1058 |
V(CASP_w, "casp", "'Ws, 'W(s+1), 'Wt, 'W(t+1)") \ |
| 1059 |
V(CASP_x, "casp", "'Xs, 'X(s+1), 'Xt, 'X(t+1)") \ |
| 1060 |
V(CASPA_w, "caspa", "'Ws, 'W(s+1), 'Wt, 'W(t+1)") \ |
| 1061 |
V(CASPA_x, "caspa", "'Xs, 'X(s+1), 'Xt, 'X(t+1)") \ |
| 1062 |
V(CASPL_w, "caspl", "'Ws, 'W(s+1), 'Wt, 'W(t+1)") \ |
| 1063 |
V(CASPL_x, "caspl", "'Xs, 'X(s+1), 'Xt, 'X(t+1)") \ |
| 1064 |
V(CASPAL_w, "caspal", "'Ws, 'W(s+1), 'Wt, 'W(t+1)") \ |
| 1065 |
V(CASPAL_x, "caspal", "'Xs, 'X(s+1), 'Xt, 'X(t+1)") |
| 1066 |
// clang-format on |
| 1067 |
|
| 1068 |
void Disassembler::VisitLoadStoreExclusive(const Instruction* instr) { |
| 1069 |
const char *mnemonic = "unimplemented"; |
| 1070 |
const char *form; |
| 1071 |
|
| 1072 |
switch (instr->Mask(LoadStoreExclusiveMask)) { |
| 1073 |
#define LSX(A, B, C) \ |
| 1074 |
case A: \ |
| 1075 |
mnemonic = B; \ |
| 1076 |
form = C ", ['Xns]"; \ |
| 1077 |
break; |
| 1078 |
LOAD_STORE_EXCLUSIVE_LIST(LSX) |
| 1079 |
#undef LSX |
| 1080 |
default: |
| 1081 |
form = "(LoadStoreExclusive)"; |
| 1082 |
} |
| 1083 |
|
| 1084 |
switch (instr->Mask(LoadStoreExclusiveMask)) { |
| 1085 |
case CASP_w: |
| 1086 |
case CASP_x: |
| 1087 |
case CASPA_w: |
| 1088 |
case CASPA_x: |
| 1089 |
case CASPL_w: |
| 1090 |
case CASPL_x: |
| 1091 |
case CASPAL_w: |
| 1092 |
case CASPAL_x: |
| 1093 |
if ((instr->Rs() % 2 == 1) || (instr->Rt() % 2 == 1)) { |
| 1094 |
mnemonic = "unallocated"; |
| 1095 |
form = "(LoadStoreExclusive)"; |
| 1096 |
} |
| 1097 |
break; |
| 1098 |
} |
| 1099 |
|
| 1100 |
Format(instr, mnemonic, form); |
| 1101 |
} |
| 1102 |
|
| 1103 |
#define ATOMIC_MEMORY_SIMPLE_LIST(V) \ |
| 1104 |
V(LDADD, "add") \ |
| 1105 |
V(LDCLR, "clr") \ |
| 1106 |
V(LDEOR, "eor") \ |
| 1107 |
V(LDSET, "set") \ |
| 1108 |
V(LDSMAX, "smax") \ |
| 1109 |
V(LDSMIN, "smin") \ |
| 1110 |
V(LDUMAX, "umax") \ |
| 1111 |
V(LDUMIN, "umin") |
| 1112 |
|
| 1113 |
void Disassembler::VisitAtomicMemory(const Instruction* instr) { |
| 1114 |
const int kMaxAtomicOpMnemonicLength = 16; |
| 1115 |
const char* mnemonic; |
| 1116 |
const char* form = "'Ws, 'Wt, ['Xns]"; |
| 1117 |
|
| 1118 |
switch (instr->Mask(AtomicMemoryMask)) { |
| 1119 |
#define AMS(A, MN) \ |
| 1120 |
case A##B: \ |
| 1121 |
mnemonic = MN "b"; \ |
| 1122 |
break; \ |
| 1123 |
case A##AB: \ |
| 1124 |
mnemonic = MN "ab"; \ |
| 1125 |
break; \ |
| 1126 |
case A##LB: \ |
| 1127 |
mnemonic = MN "lb"; \ |
| 1128 |
break; \ |
| 1129 |
case A##ALB: \ |
| 1130 |
mnemonic = MN "alb"; \ |
| 1131 |
break; \ |
| 1132 |
case A##H: \ |
| 1133 |
mnemonic = MN "h"; \ |
| 1134 |
break; \ |
| 1135 |
case A##AH: \ |
| 1136 |
mnemonic = MN "ah"; \ |
| 1137 |
break; \ |
| 1138 |
case A##LH: \ |
| 1139 |
mnemonic = MN "lh"; \ |
| 1140 |
break; \ |
| 1141 |
case A##ALH: \ |
| 1142 |
mnemonic = MN "alh"; \ |
| 1143 |
break; \ |
| 1144 |
case A##_w: \ |
| 1145 |
mnemonic = MN; \ |
| 1146 |
break; \ |
| 1147 |
case A##A_w: \ |
| 1148 |
mnemonic = MN "a"; \ |
| 1149 |
break; \ |
| 1150 |
case A##L_w: \ |
| 1151 |
mnemonic = MN "l"; \ |
| 1152 |
break; \ |
| 1153 |
case A##AL_w: \ |
| 1154 |
mnemonic = MN "al"; \ |
| 1155 |
break; \ |
| 1156 |
case A##_x: \ |
| 1157 |
mnemonic = MN; \ |
| 1158 |
form = "'Xs, 'Xt, ['Xns]"; \ |
| 1159 |
break; \ |
| 1160 |
case A##A_x: \ |
| 1161 |
mnemonic = MN "a"; \ |
| 1162 |
form = "'Xs, 'Xt, ['Xns]"; \ |
| 1163 |
break; \ |
| 1164 |
case A##L_x: \ |
| 1165 |
mnemonic = MN "l"; \ |
| 1166 |
form = "'Xs, 'Xt, ['Xns]"; \ |
| 1167 |
break; \ |
| 1168 |
case A##AL_x: \ |
| 1169 |
mnemonic = MN "al"; \ |
| 1170 |
form = "'Xs, 'Xt, ['Xns]"; \ |
| 1171 |
break; |
| 1172 |
ATOMIC_MEMORY_SIMPLE_LIST(AMS) |
| 1173 |
|
| 1174 |
// SWP has the same semantics as ldadd etc but without the store aliases. |
| 1175 |
AMS(SWP, "swp") |
| 1176 |
#undef AMS |
| 1177 |
|
| 1178 |
case LDAPRB: |
| 1179 |
mnemonic = "ldaprb"; |
| 1180 |
form = "'Wt, ['Xns]"; |
| 1181 |
break; |
| 1182 |
case LDAPRH: |
| 1183 |
mnemonic = "ldaprh"; |
| 1184 |
form = "'Wt, ['Xns]"; |
| 1185 |
break; |
| 1186 |
case LDAPR_w: |
| 1187 |
mnemonic = "ldapr"; |
| 1188 |
form = "'Wt, ['Xns]"; |
| 1189 |
break; |
| 1190 |
case LDAPR_x: |
| 1191 |
mnemonic = "ldapr"; |
| 1192 |
form = "'Xt, ['Xns]"; |
| 1193 |
break; |
| 1194 |
default: |
| 1195 |
mnemonic = "unimplemented"; |
| 1196 |
form = "(AtomicMemory)"; |
| 1197 |
} |
| 1198 |
|
| 1199 |
const char* prefix = ""; |
| 1200 |
switch (instr->Mask(AtomicMemoryMask)) { |
| 1201 |
#define AMS(A, MN) \ |
| 1202 |
case A##AB: \ |
| 1203 |
case A##ALB: \ |
| 1204 |
case A##AH: \ |
| 1205 |
case A##ALH: \ |
| 1206 |
case A##A_w: \ |
| 1207 |
case A##AL_w: \ |
| 1208 |
case A##A_x: \ |
| 1209 |
case A##AL_x: \ |
| 1210 |
prefix = "ld"; \ |
| 1211 |
break; \ |
| 1212 |
case A##B: \ |
| 1213 |
case A##LB: \ |
| 1214 |
case A##H: \ |
| 1215 |
case A##LH: \ |
| 1216 |
case A##_w: \ |
| 1217 |
case A##L_w: { \ |
| 1218 |
prefix = "ld"; \ |
| 1219 |
unsigned rt = instr->Rt(); \ |
| 1220 |
if (Register(rt, 32).IsZero()) { \ |
| 1221 |
prefix = "st"; \ |
| 1222 |
form = "'Ws, ['Xns]"; \ |
| 1223 |
} \ |
| 1224 |
break; \ |
| 1225 |
} \ |
| 1226 |
case A##_x: \ |
| 1227 |
case A##L_x: { \ |
| 1228 |
prefix = "ld"; \ |
| 1229 |
unsigned rt = instr->Rt(); \ |
| 1230 |
if (Register(rt, 64).IsZero()) { \ |
| 1231 |
prefix = "st"; \ |
| 1232 |
form = "'Xs, ['Xns]"; \ |
| 1233 |
} \ |
| 1234 |
break; \ |
| 1235 |
} |
| 1236 |
ATOMIC_MEMORY_SIMPLE_LIST(AMS) |
| 1237 |
#undef AMS |
| 1238 |
} |
| 1239 |
|
| 1240 |
char buffer[kMaxAtomicOpMnemonicLength]; |
| 1241 |
if (strlen(prefix) > 0) { |
| 1242 |
snprintf(buffer, kMaxAtomicOpMnemonicLength, "%s%s", prefix, mnemonic); |
| 1243 |
mnemonic = buffer; |
| 1244 |
} |
| 1245 |
|
| 1246 |
Format(instr, mnemonic, form); |
| 1247 |
} |
| 1248 |
|
| 1249 |
void Disassembler::VisitFPCompare(const Instruction* instr) { |
| 1250 |
const char *mnemonic = "unimplemented"; |
| 1251 |
const char *form = "'Fn, 'Fm"; |
| 1252 |
const char *form_zero = "'Fn, #0.0"; |
| 1253 |
|
| 1254 |
switch (instr->Mask(FPCompareMask)) { |
| 1255 |
case FCMP_s_zero: |
| 1256 |
case FCMP_d_zero: form = form_zero; VIXL_FALLTHROUGH(); |
| 1257 |
case FCMP_s: |
| 1258 |
case FCMP_d: mnemonic = "fcmp"; break; |
| 1259 |
case FCMPE_s_zero: |
| 1260 |
case FCMPE_d_zero: form = form_zero; VIXL_FALLTHROUGH(); |
| 1261 |
case FCMPE_s: |
| 1262 |
case FCMPE_d: mnemonic = "fcmpe"; break; |
| 1263 |
default: form = "(FPCompare)"; |
| 1264 |
} |
| 1265 |
Format(instr, mnemonic, form); |
| 1266 |
} |
| 1267 |
|
| 1268 |
|
| 1269 |
void Disassembler::VisitFPConditionalCompare(const Instruction* instr) { |
| 1270 |
const char *mnemonic = "unmplemented"; |
| 1271 |
const char *form = "'Fn, 'Fm, 'INzcv, 'Cond"; |
| 1272 |
|
| 1273 |
switch (instr->Mask(FPConditionalCompareMask)) { |
| 1274 |
case FCCMP_s: |
| 1275 |
case FCCMP_d: mnemonic = "fccmp"; break; |
| 1276 |
case FCCMPE_s: |
| 1277 |
case FCCMPE_d: mnemonic = "fccmpe"; break; |
| 1278 |
default: form = "(FPConditionalCompare)"; |
| 1279 |
} |
| 1280 |
Format(instr, mnemonic, form); |
| 1281 |
} |
| 1282 |
|
| 1283 |
|
| 1284 |
void Disassembler::VisitFPConditionalSelect(const Instruction* instr) { |
| 1285 |
const char *mnemonic = ""; |
| 1286 |
const char *form = "'Fd, 'Fn, 'Fm, 'Cond"; |
| 1287 |
|
| 1288 |
switch (instr->Mask(FPConditionalSelectMask)) { |
| 1289 |
case FCSEL_s: |
| 1290 |
case FCSEL_d: mnemonic = "fcsel"; break; |
| 1291 |
default: VIXL_UNREACHABLE(); |
| 1292 |
} |
| 1293 |
Format(instr, mnemonic, form); |
| 1294 |
} |
| 1295 |
|
| 1296 |
|
| 1297 |
void Disassembler::VisitFPDataProcessing1Source(const Instruction* instr) { |
| 1298 |
const char *mnemonic = "unimplemented"; |
| 1299 |
const char *form = "'Fd, 'Fn"; |
| 1300 |
|
| 1301 |
switch (instr->Mask(FPDataProcessing1SourceMask)) { |
| 1302 |
#define FORMAT(A, B) \ |
| 1303 |
case A##_s: \ |
| 1304 |
case A##_d: mnemonic = B; break; |
| 1305 |
FORMAT(FMOV, "fmov"); |
| 1306 |
FORMAT(FABS, "fabs"); |
| 1307 |
FORMAT(FNEG, "fneg"); |
| 1308 |
FORMAT(FSQRT, "fsqrt"); |
| 1309 |
FORMAT(FRINTN, "frintn"); |
| 1310 |
FORMAT(FRINTP, "frintp"); |
| 1311 |
FORMAT(FRINTM, "frintm"); |
| 1312 |
FORMAT(FRINTZ, "frintz"); |
| 1313 |
FORMAT(FRINTA, "frinta"); |
| 1314 |
FORMAT(FRINTX, "frintx"); |
| 1315 |
FORMAT(FRINTI, "frinti"); |
| 1316 |
#undef FORMAT |
| 1317 |
case FCVT_ds: mnemonic = "fcvt"; form = "'Dd, 'Sn"; break; |
| 1318 |
case FCVT_sd: mnemonic = "fcvt"; form = "'Sd, 'Dn"; break; |
| 1319 |
case FCVT_hs: mnemonic = "fcvt"; form = "'Hd, 'Sn"; break; |
| 1320 |
case FCVT_sh: mnemonic = "fcvt"; form = "'Sd, 'Hn"; break; |
| 1321 |
case FCVT_dh: mnemonic = "fcvt"; form = "'Dd, 'Hn"; break; |
| 1322 |
case FCVT_hd: mnemonic = "fcvt"; form = "'Hd, 'Dn"; break; |
| 1323 |
default: form = "(FPDataProcessing1Source)"; |
| 1324 |
} |
| 1325 |
Format(instr, mnemonic, form); |
| 1326 |
} |
| 1327 |
|
| 1328 |
|
| 1329 |
void Disassembler::VisitFPDataProcessing2Source(const Instruction* instr) { |
| 1330 |
const char *mnemonic = ""; |
| 1331 |
const char *form = "'Fd, 'Fn, 'Fm"; |
| 1332 |
|
| 1333 |
switch (instr->Mask(FPDataProcessing2SourceMask)) { |
| 1334 |
#define FORMAT(A, B) \ |
| 1335 |
case A##_s: \ |
| 1336 |
case A##_d: mnemonic = B; break; |
| 1337 |
FORMAT(FMUL, "fmul"); |
| 1338 |
FORMAT(FDIV, "fdiv"); |
| 1339 |
FORMAT(FADD, "fadd"); |
| 1340 |
FORMAT(FSUB, "fsub"); |
| 1341 |
FORMAT(FMAX, "fmax"); |
| 1342 |
FORMAT(FMIN, "fmin"); |
| 1343 |
FORMAT(FMAXNM, "fmaxnm"); |
| 1344 |
FORMAT(FMINNM, "fminnm"); |
| 1345 |
FORMAT(FNMUL, "fnmul"); |
| 1346 |
#undef FORMAT |
| 1347 |
default: VIXL_UNREACHABLE(); |
| 1348 |
} |
| 1349 |
Format(instr, mnemonic, form); |
| 1350 |
} |
| 1351 |
|
| 1352 |
|
| 1353 |
void Disassembler::VisitFPDataProcessing3Source(const Instruction* instr) { |
| 1354 |
const char *mnemonic = ""; |
| 1355 |
const char *form = "'Fd, 'Fn, 'Fm, 'Fa"; |
| 1356 |
|
| 1357 |
switch (instr->Mask(FPDataProcessing3SourceMask)) { |
| 1358 |
#define FORMAT(A, B) \ |
| 1359 |
case A##_s: \ |
| 1360 |
case A##_d: mnemonic = B; break; |
| 1361 |
FORMAT(FMADD, "fmadd"); |
| 1362 |
FORMAT(FMSUB, "fmsub"); |
| 1363 |
FORMAT(FNMADD, "fnmadd"); |
| 1364 |
FORMAT(FNMSUB, "fnmsub"); |
| 1365 |
#undef FORMAT |
| 1366 |
default: VIXL_UNREACHABLE(); |
| 1367 |
} |
| 1368 |
Format(instr, mnemonic, form); |
| 1369 |
} |
| 1370 |
|
| 1371 |
|
| 1372 |
void Disassembler::VisitFPImmediate(const Instruction* instr) { |
| 1373 |
const char *mnemonic = ""; |
| 1374 |
const char *form = "(FPImmediate)"; |
| 1375 |
|
| 1376 |
switch (instr->Mask(FPImmediateMask)) { |
| 1377 |
case FMOV_s_imm: mnemonic = "fmov"; form = "'Sd, 'IFPSingle"; break; |
| 1378 |
case FMOV_d_imm: mnemonic = "fmov"; form = "'Dd, 'IFPDouble"; break; |
| 1379 |
default: VIXL_UNREACHABLE(); |
| 1380 |
} |
| 1381 |
Format(instr, mnemonic, form); |
| 1382 |
} |
| 1383 |
|
| 1384 |
|
| 1385 |
void Disassembler::VisitFPIntegerConvert(const Instruction* instr) { |
| 1386 |
const char *mnemonic = "unimplemented"; |
| 1387 |
const char *form = "(FPIntegerConvert)"; |
| 1388 |
const char *form_rf = "'Rd, 'Fn"; |
| 1389 |
const char *form_fr = "'Fd, 'Rn"; |
| 1390 |
|
| 1391 |
switch (instr->Mask(FPIntegerConvertMask)) { |
| 1392 |
case FMOV_ws: |
| 1393 |
case FMOV_xd: mnemonic = "fmov"; form = form_rf; break; |
| 1394 |
case FMOV_sw: |
| 1395 |
case FMOV_dx: mnemonic = "fmov"; form = form_fr; break; |
| 1396 |
case FMOV_d1_x: mnemonic = "fmov"; form = "'Vd.D[1], 'Rn"; break; |
| 1397 |
case FMOV_x_d1: mnemonic = "fmov"; form = "'Rd, 'Vn.D[1]"; break; |
| 1398 |
case FCVTAS_ws: |
| 1399 |
case FCVTAS_xs: |
| 1400 |
case FCVTAS_wd: |
| 1401 |
case FCVTAS_xd: mnemonic = "fcvtas"; form = form_rf; break; |
| 1402 |
case FCVTAU_ws: |
| 1403 |
case FCVTAU_xs: |
| 1404 |
case FCVTAU_wd: |
| 1405 |
case FCVTAU_xd: mnemonic = "fcvtau"; form = form_rf; break; |
| 1406 |
case FCVTMS_ws: |
| 1407 |
case FCVTMS_xs: |
| 1408 |
case FCVTMS_wd: |
| 1409 |
case FCVTMS_xd: mnemonic = "fcvtms"; form = form_rf; break; |
| 1410 |
case FCVTMU_ws: |
| 1411 |
case FCVTMU_xs: |
| 1412 |
case FCVTMU_wd: |
| 1413 |
case FCVTMU_xd: mnemonic = "fcvtmu"; form = form_rf; break; |
| 1414 |
case FCVTNS_ws: |
| 1415 |
case FCVTNS_xs: |
| 1416 |
case FCVTNS_wd: |
| 1417 |
case FCVTNS_xd: mnemonic = "fcvtns"; form = form_rf; break; |
| 1418 |
case FCVTNU_ws: |
| 1419 |
case FCVTNU_xs: |
| 1420 |
case FCVTNU_wd: |
| 1421 |
case FCVTNU_xd: mnemonic = "fcvtnu"; form = form_rf; break; |
| 1422 |
case FCVTZU_xd: |
| 1423 |
case FCVTZU_ws: |
| 1424 |
case FCVTZU_wd: |
| 1425 |
case FCVTZU_xs: mnemonic = "fcvtzu"; form = form_rf; break; |
| 1426 |
case FCVTZS_xd: |
| 1427 |
case FCVTZS_wd: |
| 1428 |
case FCVTZS_xs: |
| 1429 |
case FCVTZS_ws: mnemonic = "fcvtzs"; form = form_rf; break; |
| 1430 |
case FCVTPU_xd: |
| 1431 |
case FCVTPU_ws: |
| 1432 |
case FCVTPU_wd: |
| 1433 |
case FCVTPU_xs: mnemonic = "fcvtpu"; form = form_rf; break; |
| 1434 |
case FCVTPS_xd: |
| 1435 |
case FCVTPS_wd: |
| 1436 |
case FCVTPS_xs: |
| 1437 |
case FCVTPS_ws: mnemonic = "fcvtps"; form = form_rf; break; |
| 1438 |
case SCVTF_sw: |
| 1439 |
case SCVTF_sx: |
| 1440 |
case SCVTF_dw: |
| 1441 |
case SCVTF_dx: mnemonic = "scvtf"; form = form_fr; break; |
| 1442 |
case UCVTF_sw: |
| 1443 |
case UCVTF_sx: |
| 1444 |
case UCVTF_dw: |
| 1445 |
case UCVTF_dx: mnemonic = "ucvtf"; form = form_fr; break; |
| 1446 |
case FJCVTZS: mnemonic = "fjcvtzs"; form = form_rf; break; |
| 1447 |
} |
| 1448 |
Format(instr, mnemonic, form); |
| 1449 |
} |
| 1450 |
|
| 1451 |
|
| 1452 |
void Disassembler::VisitFPFixedPointConvert(const Instruction* instr) { |
| 1453 |
const char *mnemonic = ""; |
| 1454 |
const char *form = "'Rd, 'Fn, 'IFPFBits"; |
| 1455 |
const char *form_fr = "'Fd, 'Rn, 'IFPFBits"; |
| 1456 |
|
| 1457 |
switch (instr->Mask(FPFixedPointConvertMask)) { |
| 1458 |
case FCVTZS_ws_fixed: |
| 1459 |
case FCVTZS_xs_fixed: |
| 1460 |
case FCVTZS_wd_fixed: |
| 1461 |
case FCVTZS_xd_fixed: mnemonic = "fcvtzs"; break; |
| 1462 |
case FCVTZU_ws_fixed: |
| 1463 |
case FCVTZU_xs_fixed: |
| 1464 |
case FCVTZU_wd_fixed: |
| 1465 |
case FCVTZU_xd_fixed: mnemonic = "fcvtzu"; break; |
| 1466 |
case SCVTF_sw_fixed: |
| 1467 |
case SCVTF_sx_fixed: |
| 1468 |
case SCVTF_dw_fixed: |
| 1469 |
case SCVTF_dx_fixed: mnemonic = "scvtf"; form = form_fr; break; |
| 1470 |
case UCVTF_sw_fixed: |
| 1471 |
case UCVTF_sx_fixed: |
| 1472 |
case UCVTF_dw_fixed: |
| 1473 |
case UCVTF_dx_fixed: mnemonic = "ucvtf"; form = form_fr; break; |
| 1474 |
default: VIXL_UNREACHABLE(); |
| 1475 |
} |
| 1476 |
Format(instr, mnemonic, form); |
| 1477 |
} |
| 1478 |
|
| 1479 |
|
| 1480 |
void Disassembler::VisitSystem(const Instruction* instr) { |
| 1481 |
// Some system instructions hijack their Op and Cp fields to represent a |
| 1482 |
// range of immediates instead of indicating a different instruction. This |
| 1483 |
// makes the decoding tricky. |
| 1484 |
const char *mnemonic = "unimplemented"; |
| 1485 |
const char *form = "(System)"; |
| 1486 |
|
| 1487 |
if (instr->Mask(SystemExclusiveMonitorFMask) == SystemExclusiveMonitorFixed) { |
| 1488 |
switch (instr->Mask(SystemExclusiveMonitorMask)) { |
| 1489 |
case CLREX: { |
| 1490 |
mnemonic = "clrex"; |
| 1491 |
form = (instr->CRm() == 0xf) ? NULL : "'IX"; |
| 1492 |
break; |
| 1493 |
} |
| 1494 |
} |
| 1495 |
} else if (instr->Mask(SystemSysRegFMask) == SystemSysRegFixed) { |
| 1496 |
switch (instr->Mask(SystemSysRegMask)) { |
| 1497 |
case MRS: { |
| 1498 |
mnemonic = "mrs"; |
| 1499 |
switch (instr->ImmSystemRegister()) { |
| 1500 |
case NZCV: form = "'Xt, nzcv"; break; |
| 1501 |
case FPCR: form = "'Xt, fpcr"; break; |
| 1502 |
default: form = "'Xt, (unknown)"; break; |
| 1503 |
} |
| 1504 |
break; |
| 1505 |
} |
| 1506 |
case MSR: { |
| 1507 |
mnemonic = "msr"; |
| 1508 |
switch (instr->ImmSystemRegister()) { |
| 1509 |
case NZCV: form = "nzcv, 'Xt"; break; |
| 1510 |
case FPCR: form = "fpcr, 'Xt"; break; |
| 1511 |
default: form = "(unknown), 'Xt"; break; |
| 1512 |
} |
| 1513 |
break; |
| 1514 |
} |
| 1515 |
} |
| 1516 |
} else if (instr->Mask(SystemHintFMask) == SystemHintFixed) { |
| 1517 |
switch (instr->ImmHint()) { |
| 1518 |
case NOP: { |
| 1519 |
mnemonic = "nop"; |
| 1520 |
form = NULL; |
| 1521 |
break; |
| 1522 |
} |
| 1523 |
case CSDB: { |
| 1524 |
mnemonic = "csdb"; |
| 1525 |
form = NULL; |
| 1526 |
break; |
| 1527 |
} |
| 1528 |
} |
| 1529 |
} else if (instr->Mask(MemBarrierFMask) == MemBarrierFixed) { |
| 1530 |
switch (instr->Mask(MemBarrierMask)) { |
| 1531 |
case DMB: { |
| 1532 |
mnemonic = "dmb"; |
| 1533 |
form = "'M"; |
| 1534 |
break; |
| 1535 |
} |
| 1536 |
case DSB: { |
| 1537 |
mnemonic = "dsb"; |
| 1538 |
form = "'M"; |
| 1539 |
break; |
| 1540 |
} |
| 1541 |
case ISB: { |
| 1542 |
mnemonic = "isb"; |
| 1543 |
form = NULL; |
| 1544 |
break; |
| 1545 |
} |
| 1546 |
} |
| 1547 |
} else if (instr->Mask(SystemSysFMask) == SystemSysFixed) { |
| 1548 |
switch (instr->SysOp()) { |
| 1549 |
case IVAU: |
| 1550 |
mnemonic = "ic"; |
| 1551 |
form = "ivau, 'Xt"; |
| 1552 |
break; |
| 1553 |
case CVAC: |
| 1554 |
mnemonic = "dc"; |
| 1555 |
form = "cvac, 'Xt"; |
| 1556 |
break; |
| 1557 |
case CVAU: |
| 1558 |
mnemonic = "dc"; |
| 1559 |
form = "cvau, 'Xt"; |
| 1560 |
break; |
| 1561 |
case CIVAC: |
| 1562 |
mnemonic = "dc"; |
| 1563 |
form = "civac, 'Xt"; |
| 1564 |
break; |
| 1565 |
case ZVA: |
| 1566 |
mnemonic = "dc"; |
| 1567 |
form = "zva, 'Xt"; |
| 1568 |
break; |
| 1569 |
default: |
| 1570 |
mnemonic = "sys"; |
| 1571 |
if (instr->Rt() == 31) { |
| 1572 |
form = "'G1, 'Kn, 'Km, 'G2"; |
| 1573 |
} else { |
| 1574 |
form = "'G1, 'Kn, 'Km, 'G2, 'Xt"; |
| 1575 |
} |
| 1576 |
break; |
| 1577 |
} |
| 1578 |
} |
| 1579 |
Format(instr, mnemonic, form); |
| 1580 |
} |
| 1581 |
|
| 1582 |
|
| 1583 |
void Disassembler::VisitException(const Instruction* instr) { |
| 1584 |
const char *mnemonic = "unimplemented"; |
| 1585 |
const char *form = "'IDebug"; |
| 1586 |
|
| 1587 |
switch (instr->Mask(ExceptionMask)) { |
| 1588 |
case HLT: mnemonic = "hlt"; break; |
| 1589 |
case BRK: mnemonic = "brk"; break; |
| 1590 |
case SVC: mnemonic = "svc"; break; |
| 1591 |
case HVC: mnemonic = "hvc"; break; |
| 1592 |
case SMC: mnemonic = "smc"; break; |
| 1593 |
case DCPS1: mnemonic = "dcps1"; form = "{'IDebug}"; break; |
| 1594 |
case DCPS2: mnemonic = "dcps2"; form = "{'IDebug}"; break; |
| 1595 |
case DCPS3: mnemonic = "dcps3"; form = "{'IDebug}"; break; |
| 1596 |
default: form = "(Exception)"; |
| 1597 |
} |
| 1598 |
Format(instr, mnemonic, form); |
| 1599 |
} |
| 1600 |
|
| 1601 |
|
| 1602 |
void Disassembler::VisitCrypto2RegSHA(const Instruction* instr) { |
| 1603 |
VisitUnimplemented(instr); |
| 1604 |
} |
| 1605 |
|
| 1606 |
|
| 1607 |
void Disassembler::VisitCrypto3RegSHA(const Instruction* instr) { |
| 1608 |
VisitUnimplemented(instr); |
| 1609 |
} |
| 1610 |
|
| 1611 |
|
| 1612 |
void Disassembler::VisitCryptoAES(const Instruction* instr) { |
| 1613 |
VisitUnimplemented(instr); |
| 1614 |
} |
| 1615 |
|
| 1616 |
|
| 1617 |
void Disassembler::VisitNEON2RegMisc(const Instruction* instr) { |
| 1618 |
const char *mnemonic = "unimplemented"; |
| 1619 |
const char *form = "'Vd.%s, 'Vn.%s"; |
| 1620 |
const char *form_cmp_zero = "'Vd.%s, 'Vn.%s, #0"; |
| 1621 |
const char *form_fcmp_zero = "'Vd.%s, 'Vn.%s, #0.0"; |
| 1622 |
NEONFormatDecoder nfd(instr); |
| 1623 |
|
| 1624 |
static const NEONFormatMap map_lp_ta = { |
| 1625 |
{23, 22, 30}, {NF_4H, NF_8H, NF_2S, NF_4S, NF_1D, NF_2D} |
| 1626 |
}; |
| 1627 |
|
| 1628 |
static const NEONFormatMap map_cvt_ta = { |
| 1629 |
{22}, {NF_4S, NF_2D} |
| 1630 |
}; |
| 1631 |
|
| 1632 |
static const NEONFormatMap map_cvt_tb = { |
| 1633 |
{22, 30}, {NF_4H, NF_8H, NF_2S, NF_4S} |
| 1634 |
}; |
| 1635 |
|
| 1636 |
if (instr->Mask(NEON2RegMiscOpcode) <= NEON_NEG_opcode) { |
| 1637 |
// These instructions all use a two bit size field, except NOT and RBIT, |
| 1638 |
// which use the field to encode the operation. |
| 1639 |
switch (instr->Mask(NEON2RegMiscMask)) { |
| 1640 |
case NEON_REV64: mnemonic = "rev64"; break; |
| 1641 |
case NEON_REV32: mnemonic = "rev32"; break; |
| 1642 |
case NEON_REV16: mnemonic = "rev16"; break; |
| 1643 |
case NEON_SADDLP: |
| 1644 |
mnemonic = "saddlp"; |
| 1645 |
nfd.SetFormatMap(0, &map_lp_ta); |
| 1646 |
break; |
| 1647 |
case NEON_UADDLP: |
| 1648 |
mnemonic = "uaddlp"; |
| 1649 |
nfd.SetFormatMap(0, &map_lp_ta); |
| 1650 |
break; |
| 1651 |
case NEON_SUQADD: mnemonic = "suqadd"; break; |
| 1652 |
case NEON_USQADD: mnemonic = "usqadd"; break; |
| 1653 |
case NEON_CLS: mnemonic = "cls"; break; |
| 1654 |
case NEON_CLZ: mnemonic = "clz"; break; |
| 1655 |
case NEON_CNT: mnemonic = "cnt"; break; |
| 1656 |
case NEON_SADALP: |
| 1657 |
mnemonic = "sadalp"; |
| 1658 |
nfd.SetFormatMap(0, &map_lp_ta); |
| 1659 |
break; |
| 1660 |
case NEON_UADALP: |
| 1661 |
mnemonic = "uadalp"; |
| 1662 |
nfd.SetFormatMap(0, &map_lp_ta); |
| 1663 |
break; |
| 1664 |
case NEON_SQABS: mnemonic = "sqabs"; break; |
| 1665 |
case NEON_SQNEG: mnemonic = "sqneg"; break; |
| 1666 |
case NEON_CMGT_zero: mnemonic = "cmgt"; form = form_cmp_zero; break; |
| 1667 |
case NEON_CMGE_zero: mnemonic = "cmge"; form = form_cmp_zero; break; |
| 1668 |
case NEON_CMEQ_zero: mnemonic = "cmeq"; form = form_cmp_zero; break; |
| 1669 |
case NEON_CMLE_zero: mnemonic = "cmle"; form = form_cmp_zero; break; |
| 1670 |
case NEON_CMLT_zero: mnemonic = "cmlt"; form = form_cmp_zero; break; |
| 1671 |
case NEON_ABS: mnemonic = "abs"; break; |
| 1672 |
case NEON_NEG: mnemonic = "neg"; break; |
| 1673 |
case NEON_RBIT_NOT: |
| 1674 |
switch (instr->FPType()) { |
| 1675 |
case 0: mnemonic = "mvn"; break; |
| 1676 |
case 1: mnemonic = "rbit"; break; |
| 1677 |
default: form = "(NEON2RegMisc)"; |
| 1678 |
} |
| 1679 |
nfd.SetFormatMaps(nfd.LogicalFormatMap()); |
| 1680 |
break; |
| 1681 |
} |
| 1682 |
} else { |
| 1683 |
// These instructions all use a one bit size field, except XTN, SQXTUN, |
| 1684 |
// SHLL, SQXTN and UQXTN, which use a two bit size field. |
| 1685 |
nfd.SetFormatMaps(nfd.FPFormatMap()); |
| 1686 |
switch (instr->Mask(NEON2RegMiscFPMask)) { |
| 1687 |
case NEON_FABS: mnemonic = "fabs"; break; |
| 1688 |
case NEON_FNEG: mnemonic = "fneg"; break; |
| 1689 |
case NEON_FCVTN: |
| 1690 |
mnemonic = instr->Mask(NEON_Q) ? "fcvtn2" : "fcvtn"; |
| 1691 |
nfd.SetFormatMap(0, &map_cvt_tb); |
| 1692 |
nfd.SetFormatMap(1, &map_cvt_ta); |
| 1693 |
break; |
| 1694 |
case NEON_FCVTXN: |
| 1695 |
mnemonic = instr->Mask(NEON_Q) ? "fcvtxn2" : "fcvtxn"; |
| 1696 |
nfd.SetFormatMap(0, &map_cvt_tb); |
| 1697 |
nfd.SetFormatMap(1, &map_cvt_ta); |
| 1698 |
break; |
| 1699 |
case NEON_FCVTL: |
| 1700 |
mnemonic = instr->Mask(NEON_Q) ? "fcvtl2" : "fcvtl"; |
| 1701 |
nfd.SetFormatMap(0, &map_cvt_ta); |
| 1702 |
nfd.SetFormatMap(1, &map_cvt_tb); |
| 1703 |
break; |
| 1704 |
case NEON_FRINTN: mnemonic = "frintn"; break; |
| 1705 |
case NEON_FRINTA: mnemonic = "frinta"; break; |
| 1706 |
case NEON_FRINTP: mnemonic = "frintp"; break; |
| 1707 |
case NEON_FRINTM: mnemonic = "frintm"; break; |
| 1708 |
case NEON_FRINTX: mnemonic = "frintx"; break; |
| 1709 |
case NEON_FRINTZ: mnemonic = "frintz"; break; |
| 1710 |
case NEON_FRINTI: mnemonic = "frinti"; break; |
| 1711 |
case NEON_FCVTNS: mnemonic = "fcvtns"; break; |
| 1712 |
case NEON_FCVTNU: mnemonic = "fcvtnu"; break; |
| 1713 |
case NEON_FCVTPS: mnemonic = "fcvtps"; break; |
| 1714 |
case NEON_FCVTPU: mnemonic = "fcvtpu"; break; |
| 1715 |
case NEON_FCVTMS: mnemonic = "fcvtms"; break; |
| 1716 |
case NEON_FCVTMU: mnemonic = "fcvtmu"; break; |
| 1717 |
case NEON_FCVTZS: mnemonic = "fcvtzs"; break; |
| 1718 |
case NEON_FCVTZU: mnemonic = "fcvtzu"; break; |
| 1719 |
case NEON_FCVTAS: mnemonic = "fcvtas"; break; |
| 1720 |
case NEON_FCVTAU: mnemonic = "fcvtau"; break; |
| 1721 |
case NEON_FSQRT: mnemonic = "fsqrt"; break; |
| 1722 |
case NEON_SCVTF: mnemonic = "scvtf"; break; |
| 1723 |
case NEON_UCVTF: mnemonic = "ucvtf"; break; |
| 1724 |
case NEON_URSQRTE: mnemonic = "ursqrte"; break; |
| 1725 |
case NEON_URECPE: mnemonic = "urecpe"; break; |
| 1726 |
case NEON_FRSQRTE: mnemonic = "frsqrte"; break; |
| 1727 |
case NEON_FRECPE: mnemonic = "frecpe"; break; |
| 1728 |
case NEON_FCMGT_zero: mnemonic = "fcmgt"; form = form_fcmp_zero; break; |
| 1729 |
case NEON_FCMGE_zero: mnemonic = "fcmge"; form = form_fcmp_zero; break; |
| 1730 |
case NEON_FCMEQ_zero: mnemonic = "fcmeq"; form = form_fcmp_zero; break; |
| 1731 |
case NEON_FCMLE_zero: mnemonic = "fcmle"; form = form_fcmp_zero; break; |
| 1732 |
case NEON_FCMLT_zero: mnemonic = "fcmlt"; form = form_fcmp_zero; break; |
| 1733 |
default: |
| 1734 |
if ((NEON_XTN_opcode <= instr->Mask(NEON2RegMiscOpcode)) && |
| 1735 |
(instr->Mask(NEON2RegMiscOpcode) <= NEON_UQXTN_opcode)) { |
| 1736 |
nfd.SetFormatMap(0, nfd.IntegerFormatMap()); |
| 1737 |
nfd.SetFormatMap(1, nfd.LongIntegerFormatMap()); |
| 1738 |
|
| 1739 |
switch (instr->Mask(NEON2RegMiscMask)) { |
| 1740 |
case NEON_XTN: mnemonic = "xtn"; break; |
| 1741 |
case NEON_SQXTN: mnemonic = "sqxtn"; break; |
| 1742 |
case NEON_UQXTN: mnemonic = "uqxtn"; break; |
| 1743 |
case NEON_SQXTUN: mnemonic = "sqxtun"; break; |
| 1744 |
case NEON_SHLL: |
| 1745 |
mnemonic = "shll"; |
| 1746 |
nfd.SetFormatMap(0, nfd.LongIntegerFormatMap()); |
| 1747 |
nfd.SetFormatMap(1, nfd.IntegerFormatMap()); |
| 1748 |
switch (instr->NEONSize()) { |
| 1749 |
case 0: form = "'Vd.%s, 'Vn.%s, #8"; break; |
| 1750 |
case 1: form = "'Vd.%s, 'Vn.%s, #16"; break; |
| 1751 |
case 2: form = "'Vd.%s, 'Vn.%s, #32"; break; |
| 1752 |
default: form = "(NEON2RegMisc)"; |
| 1753 |
} |
| 1754 |
} |
| 1755 |
Format(instr, nfd.Mnemonic(mnemonic), nfd.Substitute(form)); |
| 1756 |
return; |
| 1757 |
} else { |
| 1758 |
form = "(NEON2RegMisc)"; |
| 1759 |
} |
| 1760 |
} |
| 1761 |
} |
| 1762 |
Format(instr, mnemonic, nfd.Substitute(form)); |
| 1763 |
} |
| 1764 |
|
| 1765 |
|
| 1766 |
void Disassembler::VisitNEON3Same(const Instruction* instr) { |
| 1767 |
const char *mnemonic = "unimplemented"; |
| 1768 |
const char *form = "'Vd.%s, 'Vn.%s, 'Vm.%s"; |
| 1769 |
NEONFormatDecoder nfd(instr); |
| 1770 |
|
| 1771 |
if (instr->Mask(NEON3SameLogicalFMask) == NEON3SameLogicalFixed) { |
| 1772 |
switch (instr->Mask(NEON3SameLogicalMask)) { |
| 1773 |
case NEON_AND: mnemonic = "and"; break; |
| 1774 |
case NEON_ORR: |
| 1775 |
mnemonic = "orr"; |
| 1776 |
if (instr->Rm() == instr->Rn()) { |
| 1777 |
mnemonic = "mov"; |
| 1778 |
form = "'Vd.%s, 'Vn.%s"; |
| 1779 |
} |
| 1780 |
break; |
| 1781 |
case NEON_ORN: mnemonic = "orn"; break; |
| 1782 |
case NEON_EOR: mnemonic = "eor"; break; |
| 1783 |
case NEON_BIC: mnemonic = "bic"; break; |
| 1784 |
case NEON_BIF: mnemonic = "bif"; break; |
| 1785 |
case NEON_BIT: mnemonic = "bit"; break; |
| 1786 |
case NEON_BSL: mnemonic = "bsl"; break; |
| 1787 |
default: form = "(NEON3Same)"; |
| 1788 |
} |
| 1789 |
nfd.SetFormatMaps(nfd.LogicalFormatMap()); |
| 1790 |
} else { |
| 1791 |
static const char *mnemonics[] = { |
| 1792 |
"shadd", "uhadd", "shadd", "uhadd", |
| 1793 |
"sqadd", "uqadd", "sqadd", "uqadd", |
| 1794 |
"srhadd", "urhadd", "srhadd", "urhadd", |
| 1795 |
NULL, NULL, NULL, NULL, // Handled by logical cases above. |
| 1796 |
"shsub", "uhsub", "shsub", "uhsub", |
| 1797 |
"sqsub", "uqsub", "sqsub", "uqsub", |
| 1798 |
"cmgt", "cmhi", "cmgt", "cmhi", |
| 1799 |
"cmge", "cmhs", "cmge", "cmhs", |
| 1800 |
"sshl", "ushl", "sshl", "ushl", |
| 1801 |
"sqshl", "uqshl", "sqshl", "uqshl", |
| 1802 |
"srshl", "urshl", "srshl", "urshl", |
| 1803 |
"sqrshl", "uqrshl", "sqrshl", "uqrshl", |
| 1804 |
"smax", "umax", "smax", "umax", |
| 1805 |
"smin", "umin", "smin", "umin", |
| 1806 |
"sabd", "uabd", "sabd", "uabd", |
| 1807 |
"saba", "uaba", "saba", "uaba", |
| 1808 |
"add", "sub", "add", "sub", |
| 1809 |
"cmtst", "cmeq", "cmtst", "cmeq", |
| 1810 |
"mla", "mls", "mla", "mls", |
| 1811 |
"mul", "pmul", "mul", "pmul", |
| 1812 |
"smaxp", "umaxp", "smaxp", "umaxp", |
| 1813 |
"sminp", "uminp", "sminp", "uminp", |
| 1814 |
"sqdmulh", "sqrdmulh", "sqdmulh", "sqrdmulh", |
| 1815 |
"addp", "unallocated", "addp", "unallocated", |
| 1816 |
"fmaxnm", "fmaxnmp", "fminnm", "fminnmp", |
| 1817 |
"fmla", "unallocated", "fmls", "unallocated", |
| 1818 |
"fadd", "faddp", "fsub", "fabd", |
| 1819 |
"fmulx", "fmul", "unallocated", "unallocated", |
| 1820 |
"fcmeq", "fcmge", "unallocated", "fcmgt", |
| 1821 |
"unallocated", "facge", "unallocated", "facgt", |
| 1822 |
"fmax", "fmaxp", "fmin", "fminp", |
| 1823 |
"frecps", "fdiv", "frsqrts", "unallocated"}; |
| 1824 |
|
| 1825 |
// Operation is determined by the opcode bits (15-11), the top bit of |
| 1826 |
// size (23) and the U bit (29). |
| 1827 |
unsigned index = (instr->Bits(15, 11) << 2) | (instr->Bit(23) << 1) | |
| 1828 |
instr->Bit(29); |
| 1829 |
VIXL_ASSERT(index < (sizeof(mnemonics) / sizeof(mnemonics[0]))); |
| 1830 |
mnemonic = mnemonics[index]; |
| 1831 |
// Assert that index is not one of the previously handled logical |
| 1832 |
// instructions. |
| 1833 |
VIXL_ASSERT(mnemonic != NULL); |
| 1834 |
|
| 1835 |
if (instr->Mask(NEON3SameFPFMask) == NEON3SameFPFixed) { |
| 1836 |
nfd.SetFormatMaps(nfd.FPFormatMap()); |
| 1837 |
} |
| 1838 |
} |
| 1839 |
Format(instr, mnemonic, nfd.Substitute(form)); |
| 1840 |
} |
| 1841 |
|
| 1842 |
|
| 1843 |
void Disassembler::VisitNEON3Different(const Instruction* instr) { |
| 1844 |
const char *mnemonic = "unimplemented"; |
| 1845 |
const char *form = "'Vd.%s, 'Vn.%s, 'Vm.%s"; |
| 1846 |
|
| 1847 |
NEONFormatDecoder nfd(instr); |
| 1848 |
nfd.SetFormatMap(0, nfd.LongIntegerFormatMap()); |
| 1849 |
|
| 1850 |
// Ignore the Q bit. Appending a "2" suffix is handled later. |
| 1851 |
switch (instr->Mask(NEON3DifferentMask) & ~NEON_Q) { |
| 1852 |
case NEON_PMULL: mnemonic = "pmull"; break; |
| 1853 |
case NEON_SABAL: mnemonic = "sabal"; break; |
| 1854 |
case NEON_SABDL: mnemonic = "sabdl"; break; |
| 1855 |
case NEON_SADDL: mnemonic = "saddl"; break; |
| 1856 |
case NEON_SMLAL: mnemonic = "smlal"; break; |
| 1857 |
case NEON_SMLSL: mnemonic = "smlsl"; break; |
| 1858 |
case NEON_SMULL: mnemonic = "smull"; break; |
| 1859 |
case NEON_SSUBL: mnemonic = "ssubl"; break; |
| 1860 |
case NEON_SQDMLAL: mnemonic = "sqdmlal"; break; |
| 1861 |
case NEON_SQDMLSL: mnemonic = "sqdmlsl"; break; |
| 1862 |
case NEON_SQDMULL: mnemonic = "sqdmull"; break; |
| 1863 |
case NEON_UABAL: mnemonic = "uabal"; break; |
| 1864 |
case NEON_UABDL: mnemonic = "uabdl"; break; |
| 1865 |
case NEON_UADDL: mnemonic = "uaddl"; break; |
| 1866 |
case NEON_UMLAL: mnemonic = "umlal"; break; |
| 1867 |
case NEON_UMLSL: mnemonic = "umlsl"; break; |
| 1868 |
case NEON_UMULL: mnemonic = "umull"; break; |
| 1869 |
case NEON_USUBL: mnemonic = "usubl"; break; |
| 1870 |
case NEON_SADDW: |
| 1871 |
mnemonic = "saddw"; |
| 1872 |
nfd.SetFormatMap(1, nfd.LongIntegerFormatMap()); |
| 1873 |
break; |
| 1874 |
case NEON_SSUBW: |
| 1875 |
mnemonic = "ssubw"; |
| 1876 |
nfd.SetFormatMap(1, nfd.LongIntegerFormatMap()); |
| 1877 |
break; |
| 1878 |
case NEON_UADDW: |
| 1879 |
mnemonic = "uaddw"; |
| 1880 |
nfd.SetFormatMap(1, nfd.LongIntegerFormatMap()); |
| 1881 |
break; |
| 1882 |
case NEON_USUBW: |
| 1883 |
mnemonic = "usubw"; |
| 1884 |
nfd.SetFormatMap(1, nfd.LongIntegerFormatMap()); |
| 1885 |
break; |
| 1886 |
case NEON_ADDHN: |
| 1887 |
mnemonic = "addhn"; |
| 1888 |
nfd.SetFormatMaps(nfd.LongIntegerFormatMap()); |
| 1889 |
nfd.SetFormatMap(0, nfd.IntegerFormatMap()); |
| 1890 |
break; |
| 1891 |
case NEON_RADDHN: |
| 1892 |
mnemonic = "raddhn"; |
| 1893 |
nfd.SetFormatMaps(nfd.LongIntegerFormatMap()); |
| 1894 |
nfd.SetFormatMap(0, nfd.IntegerFormatMap()); |
| 1895 |
break; |
| 1896 |
case NEON_RSUBHN: |
| 1897 |
mnemonic = "rsubhn"; |
| 1898 |
nfd.SetFormatMaps(nfd.LongIntegerFormatMap()); |
| 1899 |
nfd.SetFormatMap(0, nfd.IntegerFormatMap()); |
| 1900 |
break; |
| 1901 |
case NEON_SUBHN: |
| 1902 |
mnemonic = "subhn"; |
| 1903 |
nfd.SetFormatMaps(nfd.LongIntegerFormatMap()); |
| 1904 |
nfd.SetFormatMap(0, nfd.IntegerFormatMap()); |
| 1905 |
break; |
| 1906 |
default: form = "(NEON3Different)"; |
| 1907 |
} |
| 1908 |
Format(instr, nfd.Mnemonic(mnemonic), nfd.Substitute(form)); |
| 1909 |
} |
| 1910 |
|
| 1911 |
|
| 1912 |
void Disassembler::VisitNEONAcrossLanes(const Instruction* instr) { |
| 1913 |
const char *mnemonic = "unimplemented"; |
| 1914 |
const char *form = "%sd, 'Vn.%s"; |
| 1915 |
|
| 1916 |
NEONFormatDecoder nfd(instr, NEONFormatDecoder::ScalarFormatMap(), |
| 1917 |
NEONFormatDecoder::IntegerFormatMap()); |
| 1918 |
|
| 1919 |
if (instr->Mask(NEONAcrossLanesFPFMask) == NEONAcrossLanesFPFixed) { |
| 1920 |
nfd.SetFormatMap(0, nfd.FPScalarFormatMap()); |
| 1921 |
nfd.SetFormatMap(1, nfd.FPFormatMap()); |
| 1922 |
switch (instr->Mask(NEONAcrossLanesFPMask)) { |
| 1923 |
case NEON_FMAXV: mnemonic = "fmaxv"; break; |
| 1924 |
case NEON_FMINV: mnemonic = "fminv"; break; |
| 1925 |
case NEON_FMAXNMV: mnemonic = "fmaxnmv"; break; |
| 1926 |
case NEON_FMINNMV: mnemonic = "fminnmv"; break; |
| 1927 |
default: form = "(NEONAcrossLanes)"; break; |
| 1928 |
} |
| 1929 |
} else if (instr->Mask(NEONAcrossLanesFMask) == NEONAcrossLanesFixed) { |
| 1930 |
switch (instr->Mask(NEONAcrossLanesMask)) { |
| 1931 |
case NEON_ADDV: mnemonic = "addv"; break; |
| 1932 |
case NEON_SMAXV: mnemonic = "smaxv"; break; |
| 1933 |
case NEON_SMINV: mnemonic = "sminv"; break; |
| 1934 |
case NEON_UMAXV: mnemonic = "umaxv"; break; |
| 1935 |
case NEON_UMINV: mnemonic = "uminv"; break; |
| 1936 |
case NEON_SADDLV: |
| 1937 |
mnemonic = "saddlv"; |
| 1938 |
nfd.SetFormatMap(0, nfd.LongScalarFormatMap()); |
| 1939 |
break; |
| 1940 |
case NEON_UADDLV: |
| 1941 |
mnemonic = "uaddlv"; |
| 1942 |
nfd.SetFormatMap(0, nfd.LongScalarFormatMap()); |
| 1943 |
break; |
| 1944 |
default: form = "(NEONAcrossLanes)"; break; |
| 1945 |
} |
| 1946 |
} |
| 1947 |
Format(instr, mnemonic, nfd.Substitute(form, |
| 1948 |
NEONFormatDecoder::kPlaceholder, NEONFormatDecoder::kFormat)); |
| 1949 |
} |
| 1950 |
|
| 1951 |
|
| 1952 |
void Disassembler::VisitNEONByIndexedElement(const Instruction* instr) { |
| 1953 |
const char *mnemonic = "unimplemented"; |
| 1954 |
bool l_instr = false; |
| 1955 |
bool fp_instr = false; |
| 1956 |
|
| 1957 |
const char *form = "'Vd.%s, 'Vn.%s, 'Ve.%s['IVByElemIndex]"; |
| 1958 |
|
| 1959 |
static const NEONFormatMap map_ta = { |
| 1960 |
{23, 22}, {NF_UNDEF, NF_4S, NF_2D} |
| 1961 |
}; |
| 1962 |
NEONFormatDecoder nfd(instr, &map_ta, |
| 1963 |
NEONFormatDecoder::IntegerFormatMap(), |
| 1964 |
NEONFormatDecoder::ScalarFormatMap()); |
| 1965 |
|
| 1966 |
switch (instr->Mask(NEONByIndexedElementMask)) { |
| 1967 |
case NEON_SMULL_byelement: mnemonic = "smull"; l_instr = true; break; |
| 1968 |
case NEON_UMULL_byelement: mnemonic = "umull"; l_instr = true; break; |
| 1969 |
case NEON_SMLAL_byelement: mnemonic = "smlal"; l_instr = true; break; |
| 1970 |
case NEON_UMLAL_byelement: mnemonic = "umlal"; l_instr = true; break; |
| 1971 |
case NEON_SMLSL_byelement: mnemonic = "smlsl"; l_instr = true; break; |
| 1972 |
case NEON_UMLSL_byelement: mnemonic = "umlsl"; l_instr = true; break; |
| 1973 |
case NEON_SQDMULL_byelement: mnemonic = "sqdmull"; l_instr = true; break; |
| 1974 |
case NEON_SQDMLAL_byelement: mnemonic = "sqdmlal"; l_instr = true; break; |
| 1975 |
case NEON_SQDMLSL_byelement: mnemonic = "sqdmlsl"; l_instr = true; break; |
| 1976 |
case NEON_MUL_byelement: mnemonic = "mul"; break; |
| 1977 |
case NEON_MLA_byelement: mnemonic = "mla"; break; |
| 1978 |
case NEON_MLS_byelement: mnemonic = "mls"; break; |
| 1979 |
case NEON_SQDMULH_byelement: mnemonic = "sqdmulh"; break; |
| 1980 |
case NEON_SQRDMULH_byelement: mnemonic = "sqrdmulh"; break; |
| 1981 |
default: |
| 1982 |
switch (instr->Mask(NEONByIndexedElementFPMask)) { |
| 1983 |
case NEON_FMUL_byelement: mnemonic = "fmul"; fp_instr = true; break; |
| 1984 |
case NEON_FMLA_byelement: mnemonic = "fmla"; fp_instr = true; break; |
| 1985 |
case NEON_FMLS_byelement: mnemonic = "fmls"; fp_instr = true; break; |
| 1986 |
case NEON_FMULX_byelement: mnemonic = "fmulx"; fp_instr = true; break; |
| 1987 |
} |
| 1988 |
} |
| 1989 |
|
| 1990 |
if (l_instr) { |
| 1991 |
Format(instr, nfd.Mnemonic(mnemonic), nfd.Substitute(form)); |
| 1992 |
} else if (fp_instr) { |
| 1993 |
nfd.SetFormatMap(0, nfd.FPFormatMap()); |
| 1994 |
Format(instr, mnemonic, nfd.Substitute(form)); |
| 1995 |
} else { |
| 1996 |
nfd.SetFormatMap(0, nfd.IntegerFormatMap()); |
| 1997 |
Format(instr, mnemonic, nfd.Substitute(form)); |
| 1998 |
} |
| 1999 |
} |
| 2000 |
|
| 2001 |
|
| 2002 |
void Disassembler::VisitNEONCopy(const Instruction* instr) { |
| 2003 |
const char *mnemonic = "unimplemented"; |
| 2004 |
const char *form = "(NEONCopy)"; |
| 2005 |
|
| 2006 |
NEONFormatDecoder nfd(instr, NEONFormatDecoder::TriangularFormatMap(), |
| 2007 |
NEONFormatDecoder::TriangularScalarFormatMap()); |
| 2008 |
|
| 2009 |
if (instr->Mask(NEONCopyInsElementMask) == NEON_INS_ELEMENT) { |
| 2010 |
mnemonic = "mov"; |
| 2011 |
nfd.SetFormatMap(0, nfd.TriangularScalarFormatMap()); |
| 2012 |
form = "'Vd.%s['IVInsIndex1], 'Vn.%s['IVInsIndex2]"; |
| 2013 |
} else if (instr->Mask(NEONCopyInsGeneralMask) == NEON_INS_GENERAL) { |
| 2014 |
mnemonic = "mov"; |
| 2015 |
nfd.SetFormatMap(0, nfd.TriangularScalarFormatMap()); |
| 2016 |
if (nfd.GetVectorFormat() == kFormatD) { |
| 2017 |
form = "'Vd.%s['IVInsIndex1], 'Xn"; |
| 2018 |
} else { |
| 2019 |
form = "'Vd.%s['IVInsIndex1], 'Wn"; |
| 2020 |
} |
| 2021 |
} else if (instr->Mask(NEONCopyUmovMask) == NEON_UMOV) { |
| 2022 |
if (instr->Mask(NEON_Q) || ((instr->ImmNEON5() & 7) == 4)) { |
| 2023 |
mnemonic = "mov"; |
| 2024 |
} else { |
| 2025 |
mnemonic = "umov"; |
| 2026 |
} |
| 2027 |
nfd.SetFormatMap(0, nfd.TriangularScalarFormatMap()); |
| 2028 |
if (nfd.GetVectorFormat() == kFormatD) { |
| 2029 |
form = "'Xd, 'Vn.%s['IVInsIndex1]"; |
| 2030 |
} else { |
| 2031 |
form = "'Wd, 'Vn.%s['IVInsIndex1]"; |
| 2032 |
} |
| 2033 |
} else if (instr->Mask(NEONCopySmovMask) == NEON_SMOV) { |
| 2034 |
mnemonic = "smov"; |
| 2035 |
nfd.SetFormatMap(0, nfd.TriangularScalarFormatMap()); |
| 2036 |
form = "'Rdq, 'Vn.%s['IVInsIndex1]"; |
| 2037 |
} else if (instr->Mask(NEONCopyDupElementMask) == NEON_DUP_ELEMENT) { |
| 2038 |
mnemonic = "dup"; |
| 2039 |
form = "'Vd.%s, 'Vn.%s['IVInsIndex1]"; |
| 2040 |
} else if (instr->Mask(NEONCopyDupGeneralMask) == NEON_DUP_GENERAL) { |
| 2041 |
mnemonic = "dup"; |
| 2042 |
if (nfd.GetVectorFormat() == kFormat2D) { |
| 2043 |
form = "'Vd.%s, 'Xn"; |
| 2044 |
} else { |
| 2045 |
form = "'Vd.%s, 'Wn"; |
| 2046 |
} |
| 2047 |
} |
| 2048 |
Format(instr, mnemonic, nfd.Substitute(form)); |
| 2049 |
} |
| 2050 |
|
| 2051 |
|
| 2052 |
void Disassembler::VisitNEONExtract(const Instruction* instr) { |
| 2053 |
const char *mnemonic = "unimplemented"; |
| 2054 |
const char *form = "(NEONExtract)"; |
| 2055 |
NEONFormatDecoder nfd(instr, NEONFormatDecoder::LogicalFormatMap()); |
| 2056 |
if (instr->Mask(NEONExtractMask) == NEON_EXT) { |
| 2057 |
mnemonic = "ext"; |
| 2058 |
form = "'Vd.%s, 'Vn.%s, 'Vm.%s, 'IVExtract"; |
| 2059 |
} |
| 2060 |
Format(instr, mnemonic, nfd.Substitute(form)); |
| 2061 |
} |
| 2062 |
|
| 2063 |
|
| 2064 |
void Disassembler::VisitNEONLoadStoreMultiStruct(const Instruction* instr) { |
| 2065 |
const char *mnemonic = "unimplemented"; |
| 2066 |
const char *form = "(NEONLoadStoreMultiStruct)"; |
| 2067 |
const char *form_1v = "{'Vt.%1$s}, ['Xns]"; |
| 2068 |
const char *form_2v = "{'Vt.%1$s, 'Vt2.%1$s}, ['Xns]"; |
| 2069 |
const char *form_3v = "{'Vt.%1$s, 'Vt2.%1$s, 'Vt3.%1$s}, ['Xns]"; |
| 2070 |
const char *form_4v = "{'Vt.%1$s, 'Vt2.%1$s, 'Vt3.%1$s, 'Vt4.%1$s}, ['Xns]"; |
| 2071 |
NEONFormatDecoder nfd(instr, NEONFormatDecoder::LoadStoreFormatMap()); |
| 2072 |
|
| 2073 |
switch (instr->Mask(NEONLoadStoreMultiStructMask)) { |
| 2074 |
case NEON_LD1_1v: mnemonic = "ld1"; form = form_1v; break; |
| 2075 |
case NEON_LD1_2v: mnemonic = "ld1"; form = form_2v; break; |
| 2076 |
case NEON_LD1_3v: mnemonic = "ld1"; form = form_3v; break; |
| 2077 |
case NEON_LD1_4v: mnemonic = "ld1"; form = form_4v; break; |
| 2078 |
case NEON_LD2: mnemonic = "ld2"; form = form_2v; break; |
| 2079 |
case NEON_LD3: mnemonic = "ld3"; form = form_3v; break; |
| 2080 |
case NEON_LD4: mnemonic = "ld4"; form = form_4v; break; |
| 2081 |
case NEON_ST1_1v: mnemonic = "st1"; form = form_1v; break; |
| 2082 |
case NEON_ST1_2v: mnemonic = "st1"; form = form_2v; break; |
| 2083 |
case NEON_ST1_3v: mnemonic = "st1"; form = form_3v; break; |
| 2084 |
case NEON_ST1_4v: mnemonic = "st1"; form = form_4v; break; |
| 2085 |
case NEON_ST2: mnemonic = "st2"; form = form_2v; break; |
| 2086 |
case NEON_ST3: mnemonic = "st3"; form = form_3v; break; |
| 2087 |
case NEON_ST4: mnemonic = "st4"; form = form_4v; break; |
| 2088 |
default: break; |
| 2089 |
} |
| 2090 |
|
| 2091 |
Format(instr, mnemonic, nfd.Substitute(form)); |
| 2092 |
} |
| 2093 |
|
| 2094 |
|
| 2095 |
void Disassembler::VisitNEONLoadStoreMultiStructPostIndex( |
| 2096 |
const Instruction* instr) { |
| 2097 |
const char *mnemonic = "unimplemented"; |
| 2098 |
const char *form = "(NEONLoadStoreMultiStructPostIndex)"; |
| 2099 |
const char *form_1v = "{'Vt.%1$s}, ['Xns], 'Xmr1"; |
| 2100 |
const char *form_2v = "{'Vt.%1$s, 'Vt2.%1$s}, ['Xns], 'Xmr2"; |
| 2101 |
const char *form_3v = "{'Vt.%1$s, 'Vt2.%1$s, 'Vt3.%1$s}, ['Xns], 'Xmr3"; |
| 2102 |
const char *form_4v = |
| 2103 |
"{'Vt.%1$s, 'Vt2.%1$s, 'Vt3.%1$s, 'Vt4.%1$s}, ['Xns], 'Xmr4"; |
| 2104 |
NEONFormatDecoder nfd(instr, NEONFormatDecoder::LoadStoreFormatMap()); |
| 2105 |
|
| 2106 |
switch (instr->Mask(NEONLoadStoreMultiStructPostIndexMask)) { |
| 2107 |
case NEON_LD1_1v_post: mnemonic = "ld1"; form = form_1v; break; |
| 2108 |
case NEON_LD1_2v_post: mnemonic = "ld1"; form = form_2v; break; |
| 2109 |
case NEON_LD1_3v_post: mnemonic = "ld1"; form = form_3v; break; |
| 2110 |
case NEON_LD1_4v_post: mnemonic = "ld1"; form = form_4v; break; |
| 2111 |
case NEON_LD2_post: mnemonic = "ld2"; form = form_2v; break; |
| 2112 |
case NEON_LD3_post: mnemonic = "ld3"; form = form_3v; break; |
| 2113 |
case NEON_LD4_post: mnemonic = "ld4"; form = form_4v; break; |
| 2114 |
case NEON_ST1_1v_post: mnemonic = "st1"; form = form_1v; break; |
| 2115 |
case NEON_ST1_2v_post: mnemonic = "st1"; form = form_2v; break; |
| 2116 |
case NEON_ST1_3v_post: mnemonic = "st1"; form = form_3v; break; |
| 2117 |
case NEON_ST1_4v_post: mnemonic = "st1"; form = form_4v; break; |
| 2118 |
case NEON_ST2_post: mnemonic = "st2"; form = form_2v; break; |
| 2119 |
case NEON_ST3_post: mnemonic = "st3"; form = form_3v; break; |
| 2120 |
case NEON_ST4_post: mnemonic = "st4"; form = form_4v; break; |
| 2121 |
default: break; |
| 2122 |
} |
| 2123 |
|
| 2124 |
Format(instr, mnemonic, nfd.Substitute(form)); |
| 2125 |
} |
| 2126 |
|
| 2127 |
|
| 2128 |
void Disassembler::VisitNEONLoadStoreSingleStruct(const Instruction* instr) { |
| 2129 |
const char *mnemonic = "unimplemented"; |
| 2130 |
const char *form = "(NEONLoadStoreSingleStruct)"; |
| 2131 |
|
| 2132 |
const char *form_1b = "{'Vt.b}['IVLSLane0], ['Xns]"; |
| 2133 |
const char *form_1h = "{'Vt.h}['IVLSLane1], ['Xns]"; |
| 2134 |
const char *form_1s = "{'Vt.s}['IVLSLane2], ['Xns]"; |
| 2135 |
const char *form_1d = "{'Vt.d}['IVLSLane3], ['Xns]"; |
| 2136 |
NEONFormatDecoder nfd(instr, NEONFormatDecoder::LoadStoreFormatMap()); |
| 2137 |
|
| 2138 |
switch (instr->Mask(NEONLoadStoreSingleStructMask)) { |
| 2139 |
case NEON_LD1_b: mnemonic = "ld1"; form = form_1b; break; |
| 2140 |
case NEON_LD1_h: mnemonic = "ld1"; form = form_1h; break; |
| 2141 |
case NEON_LD1_s: |
| 2142 |
mnemonic = "ld1"; |
| 2143 |
VIXL_STATIC_ASSERT((NEON_LD1_s | (1 << NEONLSSize_offset)) == NEON_LD1_d); |
| 2144 |
form = ((instr->NEONLSSize() & 1) == 0) ? form_1s : form_1d; |
| 2145 |
break; |
| 2146 |
case NEON_ST1_b: mnemonic = "st1"; form = form_1b; break; |
| 2147 |
case NEON_ST1_h: mnemonic = "st1"; form = form_1h; break; |
| 2148 |
case NEON_ST1_s: |
| 2149 |
mnemonic = "st1"; |
| 2150 |
VIXL_STATIC_ASSERT((NEON_ST1_s | (1 << NEONLSSize_offset)) == NEON_ST1_d); |
| 2151 |
form = ((instr->NEONLSSize() & 1) == 0) ? form_1s : form_1d; |
| 2152 |
break; |
| 2153 |
case NEON_LD1R: |
| 2154 |
mnemonic = "ld1r"; |
| 2155 |
form = "{'Vt.%s}, ['Xns]"; |
| 2156 |
break; |
| 2157 |
case NEON_LD2_b: |
| 2158 |
case NEON_ST2_b: |
| 2159 |
mnemonic = (instr->LdStXLoad() == 1) ? "ld2" : "st2"; |
| 2160 |
form = "{'Vt.b, 'Vt2.b}['IVLSLane0], ['Xns]"; |
| 2161 |
break; |
| 2162 |
case NEON_LD2_h: |
| 2163 |
case NEON_ST2_h: |
| 2164 |
mnemonic = (instr->LdStXLoad() == 1) ? "ld2" : "st2"; |
| 2165 |
form = "{'Vt.h, 'Vt2.h}['IVLSLane1], ['Xns]"; |
| 2166 |
break; |
| 2167 |
case NEON_LD2_s: |
| 2168 |
case NEON_ST2_s: |
| 2169 |
VIXL_STATIC_ASSERT((NEON_ST2_s | (1 << NEONLSSize_offset)) == NEON_ST2_d); |
| 2170 |
VIXL_STATIC_ASSERT((NEON_LD2_s | (1 << NEONLSSize_offset)) == NEON_LD2_d); |
| 2171 |
mnemonic = (instr->LdStXLoad() == 1) ? "ld2" : "st2"; |
| 2172 |
if ((instr->NEONLSSize() & 1) == 0) |
| 2173 |
form = "{'Vt.s, 'Vt2.s}['IVLSLane2], ['Xns]"; |
| 2174 |
else |
| 2175 |
form = "{'Vt.d, 'Vt2.d}['IVLSLane3], ['Xns]"; |
| 2176 |
break; |
| 2177 |
case NEON_LD2R: |
| 2178 |
mnemonic = "ld2r"; |
| 2179 |
form = "{'Vt.%s, 'Vt2.%s}, ['Xns]"; |
| 2180 |
break; |
| 2181 |
case NEON_LD3_b: |
| 2182 |
case NEON_ST3_b: |
| 2183 |
mnemonic = (instr->LdStXLoad() == 1) ? "ld3" : "st3"; |
| 2184 |
form = "{'Vt.b, 'Vt2.b, 'Vt3.b}['IVLSLane0], ['Xns]"; |
| 2185 |
break; |
| 2186 |
case NEON_LD3_h: |
| 2187 |
case NEON_ST3_h: |
| 2188 |
mnemonic = (instr->LdStXLoad() == 1) ? "ld3" : "st3"; |
| 2189 |
form = "{'Vt.h, 'Vt2.h, 'Vt3.h}['IVLSLane1], ['Xns]"; |
| 2190 |
break; |
| 2191 |
case NEON_LD3_s: |
| 2192 |
case NEON_ST3_s: |
| 2193 |
mnemonic = (instr->LdStXLoad() == 1) ? "ld3" : "st3"; |
| 2194 |
if ((instr->NEONLSSize() & 1) == 0) |
| 2195 |
form = "{'Vt.s, 'Vt2.s, 'Vt3.s}['IVLSLane2], ['Xns]"; |
| 2196 |
else |
| 2197 |
form = "{'Vt.d, 'Vt2.d, 'Vt3.d}['IVLSLane3], ['Xns]"; |
| 2198 |
break; |
| 2199 |
case NEON_LD3R: |
| 2200 |
mnemonic = "ld3r"; |
| 2201 |
form = "{'Vt.%s, 'Vt2.%s, 'Vt3.%s}, ['Xns]"; |
| 2202 |
break; |
| 2203 |
case NEON_LD4_b: |
| 2204 |
case NEON_ST4_b: |
| 2205 |
mnemonic = (instr->LdStXLoad() == 1) ? "ld4" : "st4"; |
| 2206 |
form = "{'Vt.b, 'Vt2.b, 'Vt3.b, 'Vt4.b}['IVLSLane0], ['Xns]"; |
| 2207 |
break; |
| 2208 |
case NEON_LD4_h: |
| 2209 |
case NEON_ST4_h: |
| 2210 |
mnemonic = (instr->LdStXLoad() == 1) ? "ld4" : "st4"; |
| 2211 |
form = "{'Vt.h, 'Vt2.h, 'Vt3.h, 'Vt4.h}['IVLSLane1], ['Xns]"; |
| 2212 |
break; |
| 2213 |
case NEON_LD4_s: |
| 2214 |
case NEON_ST4_s: |
| 2215 |
VIXL_STATIC_ASSERT((NEON_LD4_s | (1 << NEONLSSize_offset)) == NEON_LD4_d); |
| 2216 |
VIXL_STATIC_ASSERT((NEON_ST4_s | (1 << NEONLSSize_offset)) == NEON_ST4_d); |
| 2217 |
mnemonic = (instr->LdStXLoad() == 1) ? "ld4" : "st4"; |
| 2218 |
if ((instr->NEONLSSize() & 1) == 0) |
| 2219 |
form = "{'Vt.s, 'Vt2.s, 'Vt3.s, 'Vt4.s}['IVLSLane2], ['Xns]"; |
| 2220 |
else |
| 2221 |
form = "{'Vt.d, 'Vt2.d, 'Vt3.d, 'Vt4.d}['IVLSLane3], ['Xns]"; |
| 2222 |
break; |
| 2223 |
case NEON_LD4R: |
| 2224 |
mnemonic = "ld4r"; |
| 2225 |
form = "{'Vt.%1$s, 'Vt2.%1$s, 'Vt3.%1$s, 'Vt4.%1$s}, ['Xns]"; |
| 2226 |
break; |
| 2227 |
default: break; |
| 2228 |
} |
| 2229 |
|
| 2230 |
Format(instr, mnemonic, nfd.Substitute(form)); |
| 2231 |
} |
| 2232 |
|
| 2233 |
|
| 2234 |
void Disassembler::VisitNEONLoadStoreSingleStructPostIndex( |
| 2235 |
const Instruction* instr) { |
| 2236 |
const char *mnemonic = "unimplemented"; |
| 2237 |
const char *form = "(NEONLoadStoreSingleStructPostIndex)"; |
| 2238 |
|
| 2239 |
const char *form_1b = "{'Vt.b}['IVLSLane0], ['Xns], 'Xmb1"; |
| 2240 |
const char *form_1h = "{'Vt.h}['IVLSLane1], ['Xns], 'Xmb2"; |
| 2241 |
const char *form_1s = "{'Vt.s}['IVLSLane2], ['Xns], 'Xmb4"; |
| 2242 |
const char *form_1d = "{'Vt.d}['IVLSLane3], ['Xns], 'Xmb8"; |
| 2243 |
NEONFormatDecoder nfd(instr, NEONFormatDecoder::LoadStoreFormatMap()); |
| 2244 |
|
| 2245 |
switch (instr->Mask(NEONLoadStoreSingleStructPostIndexMask)) { |
| 2246 |
case NEON_LD1_b_post: mnemonic = "ld1"; form = form_1b; break; |
| 2247 |
case NEON_LD1_h_post: mnemonic = "ld1"; form = form_1h; break; |
| 2248 |
case NEON_LD1_s_post: |
| 2249 |
mnemonic = "ld1"; |
| 2250 |
VIXL_STATIC_ASSERT((NEON_LD1_s | (1 << NEONLSSize_offset)) == NEON_LD1_d); |
| 2251 |
form = ((instr->NEONLSSize() & 1) == 0) ? form_1s : form_1d; |
| 2252 |
break; |
| 2253 |
case NEON_ST1_b_post: mnemonic = "st1"; form = form_1b; break; |
| 2254 |
case NEON_ST1_h_post: mnemonic = "st1"; form = form_1h; break; |
| 2255 |
case NEON_ST1_s_post: |
| 2256 |
mnemonic = "st1"; |
| 2257 |
VIXL_STATIC_ASSERT((NEON_ST1_s | (1 << NEONLSSize_offset)) == NEON_ST1_d); |
| 2258 |
form = ((instr->NEONLSSize() & 1) == 0) ? form_1s : form_1d; |
| 2259 |
break; |
| 2260 |
case NEON_LD1R_post: |
| 2261 |
mnemonic = "ld1r"; |
| 2262 |
form = "{'Vt.%s}, ['Xns], 'Xmz1"; |
| 2263 |
break; |
| 2264 |
case NEON_LD2_b_post: |
| 2265 |
case NEON_ST2_b_post: |
| 2266 |
mnemonic = (instr->LdStXLoad() == 1) ? "ld2" : "st2"; |
| 2267 |
form = "{'Vt.b, 'Vt2.b}['IVLSLane0], ['Xns], 'Xmb2"; |
| 2268 |
break; |
| 2269 |
case NEON_ST2_h_post: |
| 2270 |
case NEON_LD2_h_post: |
| 2271 |
mnemonic = (instr->LdStXLoad() == 1) ? "ld2" : "st2"; |
| 2272 |
form = "{'Vt.h, 'Vt2.h}['IVLSLane1], ['Xns], 'Xmb4"; |
| 2273 |
break; |
| 2274 |
case NEON_LD2_s_post: |
| 2275 |
case NEON_ST2_s_post: |
| 2276 |
mnemonic = (instr->LdStXLoad() == 1) ? "ld2" : "st2"; |
| 2277 |
if ((instr->NEONLSSize() & 1) == 0) |
| 2278 |
form = "{'Vt.s, 'Vt2.s}['IVLSLane2], ['Xns], 'Xmb8"; |
| 2279 |
else |
| 2280 |
form = "{'Vt.d, 'Vt2.d}['IVLSLane3], ['Xns], 'Xmb16"; |
| 2281 |
break; |
| 2282 |
case NEON_LD2R_post: |
| 2283 |
mnemonic = "ld2r"; |
| 2284 |
form = "{'Vt.%s, 'Vt2.%s}, ['Xns], 'Xmz2"; |
| 2285 |
break; |
| 2286 |
case NEON_LD3_b_post: |
| 2287 |
case NEON_ST3_b_post: |
| 2288 |
mnemonic = (instr->LdStXLoad() == 1) ? "ld3" : "st3"; |
| 2289 |
form = "{'Vt.b, 'Vt2.b, 'Vt3.b}['IVLSLane0], ['Xns], 'Xmb3"; |
| 2290 |
break; |
| 2291 |
case NEON_LD3_h_post: |
| 2292 |
case NEON_ST3_h_post: |
| 2293 |
mnemonic = (instr->LdStXLoad() == 1) ? "ld3" : "st3"; |
| 2294 |
form = "{'Vt.h, 'Vt2.h, 'Vt3.h}['IVLSLane1], ['Xns], 'Xmb6"; |
| 2295 |
break; |
| 2296 |
case NEON_LD3_s_post: |
| 2297 |
case NEON_ST3_s_post: |
| 2298 |
mnemonic = (instr->LdStXLoad() == 1) ? "ld3" : "st3"; |
| 2299 |
if ((instr->NEONLSSize() & 1) == 0) |
| 2300 |
form = "{'Vt.s, 'Vt2.s, 'Vt3.s}['IVLSLane2], ['Xns], 'Xmb12"; |
| 2301 |
else |
| 2302 |
form = "{'Vt.d, 'Vt2.d, 'Vt3.d}['IVLSLane3], ['Xns], 'Xmr3"; |
| 2303 |
break; |
| 2304 |
case NEON_LD3R_post: |
| 2305 |
mnemonic = "ld3r"; |
| 2306 |
form = "{'Vt.%s, 'Vt2.%s, 'Vt3.%s}, ['Xns], 'Xmz3"; |
| 2307 |
break; |
| 2308 |
case NEON_LD4_b_post: |
| 2309 |
case NEON_ST4_b_post: |
| 2310 |
mnemonic = (instr->LdStXLoad() == 1) ? "ld4" : "st4"; |
| 2311 |
form = "{'Vt.b, 'Vt2.b, 'Vt3.b, 'Vt4.b}['IVLSLane0], ['Xns], 'Xmb4"; |
| 2312 |
break; |
| 2313 |
case NEON_LD4_h_post: |
| 2314 |
case NEON_ST4_h_post: |
| 2315 |
mnemonic = (instr->LdStXLoad()) == 1 ? "ld4" : "st4"; |
| 2316 |
form = "{'Vt.h, 'Vt2.h, 'Vt3.h, 'Vt4.h}['IVLSLane1], ['Xns], 'Xmb8"; |
| 2317 |
break; |
| 2318 |
case NEON_LD4_s_post: |
| 2319 |
case NEON_ST4_s_post: |
| 2320 |
mnemonic = (instr->LdStXLoad() == 1) ? "ld4" : "st4"; |
| 2321 |
if ((instr->NEONLSSize() & 1) == 0) |
| 2322 |
form = "{'Vt.s, 'Vt2.s, 'Vt3.s, 'Vt4.s}['IVLSLane2], ['Xns], 'Xmb16"; |
| 2323 |
else |
| 2324 |
form = "{'Vt.d, 'Vt2.d, 'Vt3.d, 'Vt4.d}['IVLSLane3], ['Xns], 'Xmb32"; |
| 2325 |
break; |
| 2326 |
case NEON_LD4R_post: |
| 2327 |
mnemonic = "ld4r"; |
| 2328 |
form = "{'Vt.%1$s, 'Vt2.%1$s, 'Vt3.%1$s, 'Vt4.%1$s}, ['Xns], 'Xmz4"; |
| 2329 |
break; |
| 2330 |
default: break; |
| 2331 |
} |
| 2332 |
|
| 2333 |
Format(instr, mnemonic, nfd.Substitute(form)); |
| 2334 |
} |
| 2335 |
|
| 2336 |
|
| 2337 |
void Disassembler::VisitNEONModifiedImmediate(const Instruction* instr) { |
| 2338 |
const char *mnemonic = "unimplemented"; |
| 2339 |
const char *form = "'Vt.%s, 'IVMIImm8, lsl 'IVMIShiftAmt1"; |
| 2340 |
|
| 2341 |
int cmode = instr->NEONCmode(); |
| 2342 |
int cmode_3 = (cmode >> 3) & 1; |
| 2343 |
int cmode_2 = (cmode >> 2) & 1; |
| 2344 |
int cmode_1 = (cmode >> 1) & 1; |
| 2345 |
int cmode_0 = cmode & 1; |
| 2346 |
int q = instr->NEONQ(); |
| 2347 |
int op = instr->NEONModImmOp(); |
| 2348 |
|
| 2349 |
static const NEONFormatMap map_b = { {30}, {NF_8B, NF_16B} }; |
| 2350 |
static const NEONFormatMap map_h = { {30}, {NF_4H, NF_8H} }; |
| 2351 |
static const NEONFormatMap map_s = { {30}, {NF_2S, NF_4S} }; |
| 2352 |
NEONFormatDecoder nfd(instr, &map_b); |
| 2353 |
|
| 2354 |
if (cmode_3 == 0) { |
| 2355 |
if (cmode_0 == 0) { |
| 2356 |
mnemonic = (op == 1) ? "mvni" : "movi"; |
| 2357 |
} else { // cmode<0> == '1'. |
| 2358 |
mnemonic = (op == 1) ? "bic" : "orr"; |
| 2359 |
} |
| 2360 |
nfd.SetFormatMap(0, &map_s); |
| 2361 |
} else { // cmode<3> == '1'. |
| 2362 |
if (cmode_2 == 0) { |
| 2363 |
if (cmode_0 == 0) { |
| 2364 |
mnemonic = (op == 1) ? "mvni" : "movi"; |
| 2365 |
} else { // cmode<0> == '1'. |
| 2366 |
mnemonic = (op == 1) ? "bic" : "orr"; |
| 2367 |
} |
| 2368 |
nfd.SetFormatMap(0, &map_h); |
| 2369 |
} else { // cmode<2> == '1'. |
| 2370 |
if (cmode_1 == 0) { |
| 2371 |
mnemonic = (op == 1) ? "mvni" : "movi"; |
| 2372 |
form = "'Vt.%s, 'IVMIImm8, msl 'IVMIShiftAmt2"; |
| 2373 |
nfd.SetFormatMap(0, &map_s); |
| 2374 |
} else { // cmode<1> == '1'. |
| 2375 |
if (cmode_0 == 0) { |
| 2376 |
mnemonic = "movi"; |
| 2377 |
if (op == 0) { |
| 2378 |
form = "'Vt.%s, 'IVMIImm8"; |
| 2379 |
} else { |
| 2380 |
form = (q == 0) ? "'Dd, 'IVMIImm" : "'Vt.2d, 'IVMIImm"; |
| 2381 |
} |
| 2382 |
} else { // cmode<0> == '1' |
| 2383 |
mnemonic = "fmov"; |
| 2384 |
if (op == 0) { |
| 2385 |
form = "'Vt.%s, 'IVMIImmFPSingle"; |
| 2386 |
nfd.SetFormatMap(0, &map_s); |
| 2387 |
} else { |
| 2388 |
if (q == 1) { |
| 2389 |
form = "'Vt.2d, 'IVMIImmFPDouble"; |
| 2390 |
} |
| 2391 |
} |
| 2392 |
} |
| 2393 |
} |
| 2394 |
} |
| 2395 |
} |
| 2396 |
Format(instr, mnemonic, nfd.Substitute(form)); |
| 2397 |
} |
| 2398 |
|
| 2399 |
|
| 2400 |
void Disassembler::VisitNEONScalar2RegMisc(const Instruction* instr) { |
| 2401 |
const char *mnemonic = "unimplemented"; |
| 2402 |
const char *form = "%sd, %sn"; |
| 2403 |
const char *form_0 = "%sd, %sn, #0"; |
| 2404 |
const char *form_fp0 = "%sd, %sn, #0.0"; |
| 2405 |
|
| 2406 |
NEONFormatDecoder nfd(instr, NEONFormatDecoder::ScalarFormatMap()); |
| 2407 |
|
| 2408 |
if (instr->Mask(NEON2RegMiscOpcode) <= NEON_NEG_scalar_opcode) { |
| 2409 |
// These instructions all use a two bit size field, except NOT and RBIT, |
| 2410 |
// which use the field to encode the operation. |
| 2411 |
switch (instr->Mask(NEONScalar2RegMiscMask)) { |
| 2412 |
case NEON_CMGT_zero_scalar: mnemonic = "cmgt"; form = form_0; break; |
| 2413 |
case NEON_CMGE_zero_scalar: mnemonic = "cmge"; form = form_0; break; |
| 2414 |
case NEON_CMLE_zero_scalar: mnemonic = "cmle"; form = form_0; break; |
| 2415 |
case NEON_CMLT_zero_scalar: mnemonic = "cmlt"; form = form_0; break; |
| 2416 |
case NEON_CMEQ_zero_scalar: mnemonic = "cmeq"; form = form_0; break; |
| 2417 |
case NEON_NEG_scalar: mnemonic = "neg"; break; |
| 2418 |
case NEON_SQNEG_scalar: mnemonic = "sqneg"; break; |
| 2419 |
case NEON_ABS_scalar: mnemonic = "abs"; break; |
| 2420 |
case NEON_SQABS_scalar: mnemonic = "sqabs"; break; |
| 2421 |
case NEON_SUQADD_scalar: mnemonic = "suqadd"; break; |
| 2422 |
case NEON_USQADD_scalar: mnemonic = "usqadd"; break; |
| 2423 |
default: form = "(NEONScalar2RegMisc)"; |
| 2424 |
} |
| 2425 |
} else { |
| 2426 |
// These instructions all use a one bit size field, except SQXTUN, SQXTN |
| 2427 |
// and UQXTN, which use a two bit size field. |
| 2428 |
nfd.SetFormatMaps(nfd.FPScalarFormatMap()); |
| 2429 |
switch (instr->Mask(NEONScalar2RegMiscFPMask)) { |
| 2430 |
case NEON_FRSQRTE_scalar: mnemonic = "frsqrte"; break; |
| 2431 |
case NEON_FRECPE_scalar: mnemonic = "frecpe"; break; |
| 2432 |
case NEON_SCVTF_scalar: mnemonic = "scvtf"; break; |
| 2433 |
case NEON_UCVTF_scalar: mnemonic = "ucvtf"; break; |
| 2434 |
case NEON_FCMGT_zero_scalar: mnemonic = "fcmgt"; form = form_fp0; break; |
| 2435 |
case NEON_FCMGE_zero_scalar: mnemonic = "fcmge"; form = form_fp0; break; |
| 2436 |
case NEON_FCMLE_zero_scalar: mnemonic = "fcmle"; form = form_fp0; break; |
| 2437 |
case NEON_FCMLT_zero_scalar: mnemonic = "fcmlt"; form = form_fp0; break; |
| 2438 |
case NEON_FCMEQ_zero_scalar: mnemonic = "fcmeq"; form = form_fp0; break; |
| 2439 |
case NEON_FRECPX_scalar: mnemonic = "frecpx"; break; |
| 2440 |
case NEON_FCVTNS_scalar: mnemonic = "fcvtns"; break; |
| 2441 |
case NEON_FCVTNU_scalar: mnemonic = "fcvtnu"; break; |
| 2442 |
case NEON_FCVTPS_scalar: mnemonic = "fcvtps"; break; |
| 2443 |
case NEON_FCVTPU_scalar: mnemonic = "fcvtpu"; break; |
| 2444 |
case NEON_FCVTMS_scalar: mnemonic = "fcvtms"; break; |
| 2445 |
case NEON_FCVTMU_scalar: mnemonic = "fcvtmu"; break; |
| 2446 |
case NEON_FCVTZS_scalar: mnemonic = "fcvtzs"; break; |
| 2447 |
case NEON_FCVTZU_scalar: mnemonic = "fcvtzu"; break; |
| 2448 |
case NEON_FCVTAS_scalar: mnemonic = "fcvtas"; break; |
| 2449 |
case NEON_FCVTAU_scalar: mnemonic = "fcvtau"; break; |
| 2450 |
case NEON_FCVTXN_scalar: |
| 2451 |
nfd.SetFormatMap(0, nfd.LongScalarFormatMap()); |
| 2452 |
mnemonic = "fcvtxn"; |
| 2453 |
break; |
| 2454 |
default: |
| 2455 |
nfd.SetFormatMap(0, nfd.ScalarFormatMap()); |
| 2456 |
nfd.SetFormatMap(1, nfd.LongScalarFormatMap()); |
| 2457 |
switch (instr->Mask(NEONScalar2RegMiscMask)) { |
| 2458 |
case NEON_SQXTN_scalar: mnemonic = "sqxtn"; break; |
| 2459 |
case NEON_UQXTN_scalar: mnemonic = "uqxtn"; break; |
| 2460 |
case NEON_SQXTUN_scalar: mnemonic = "sqxtun"; break; |
| 2461 |
default: form = "(NEONScalar2RegMisc)"; |
| 2462 |
} |
| 2463 |
} |
| 2464 |
} |
| 2465 |
Format(instr, mnemonic, nfd.SubstitutePlaceholders(form)); |
| 2466 |
} |
| 2467 |
|
| 2468 |
|
| 2469 |
void Disassembler::VisitNEONScalar3Diff(const Instruction* instr) { |
| 2470 |
const char *mnemonic = "unimplemented"; |
| 2471 |
const char *form = "%sd, %sn, %sm"; |
| 2472 |
NEONFormatDecoder nfd(instr, NEONFormatDecoder::LongScalarFormatMap(), |
| 2473 |
NEONFormatDecoder::ScalarFormatMap()); |
| 2474 |
|
| 2475 |
switch (instr->Mask(NEONScalar3DiffMask)) { |
| 2476 |
case NEON_SQDMLAL_scalar : mnemonic = "sqdmlal"; break; |
| 2477 |
case NEON_SQDMLSL_scalar : mnemonic = "sqdmlsl"; break; |
| 2478 |
case NEON_SQDMULL_scalar : mnemonic = "sqdmull"; break; |
| 2479 |
default: form = "(NEONScalar3Diff)"; |
| 2480 |
} |
| 2481 |
Format(instr, mnemonic, nfd.SubstitutePlaceholders(form)); |
| 2482 |
} |
| 2483 |
|
| 2484 |
|
| 2485 |
void Disassembler::VisitNEONScalar3Same(const Instruction* instr) { |
| 2486 |
const char *mnemonic = "unimplemented"; |
| 2487 |
const char *form = "%sd, %sn, %sm"; |
| 2488 |
NEONFormatDecoder nfd(instr, NEONFormatDecoder::ScalarFormatMap()); |
| 2489 |
|
| 2490 |
if (instr->Mask(NEONScalar3SameFPFMask) == NEONScalar3SameFPFixed) { |
| 2491 |
nfd.SetFormatMaps(nfd.FPScalarFormatMap()); |
| 2492 |
switch (instr->Mask(NEONScalar3SameFPMask)) { |
| 2493 |
case NEON_FACGE_scalar: mnemonic = "facge"; break; |
| 2494 |
case NEON_FACGT_scalar: mnemonic = "facgt"; break; |
| 2495 |
case NEON_FCMEQ_scalar: mnemonic = "fcmeq"; break; |
| 2496 |
case NEON_FCMGE_scalar: mnemonic = "fcmge"; break; |
| 2497 |
case NEON_FCMGT_scalar: mnemonic = "fcmgt"; break; |
| 2498 |
case NEON_FMULX_scalar: mnemonic = "fmulx"; break; |
| 2499 |
case NEON_FRECPS_scalar: mnemonic = "frecps"; break; |
| 2500 |
case NEON_FRSQRTS_scalar: mnemonic = "frsqrts"; break; |
| 2501 |
case NEON_FABD_scalar: mnemonic = "fabd"; break; |
| 2502 |
default: form = "(NEONScalar3Same)"; |
| 2503 |
} |
| 2504 |
} else { |
| 2505 |
switch (instr->Mask(NEONScalar3SameMask)) { |
| 2506 |
case NEON_ADD_scalar: mnemonic = "add"; break; |
| 2507 |
case NEON_SUB_scalar: mnemonic = "sub"; break; |
| 2508 |
case NEON_CMEQ_scalar: mnemonic = "cmeq"; break; |
| 2509 |
case NEON_CMGE_scalar: mnemonic = "cmge"; break; |
| 2510 |
case NEON_CMGT_scalar: mnemonic = "cmgt"; break; |
| 2511 |
case NEON_CMHI_scalar: mnemonic = "cmhi"; break; |
| 2512 |
case NEON_CMHS_scalar: mnemonic = "cmhs"; break; |
| 2513 |
case NEON_CMTST_scalar: mnemonic = "cmtst"; break; |
| 2514 |
case NEON_UQADD_scalar: mnemonic = "uqadd"; break; |
| 2515 |
case NEON_SQADD_scalar: mnemonic = "sqadd"; break; |
| 2516 |
case NEON_UQSUB_scalar: mnemonic = "uqsub"; break; |
| 2517 |
case NEON_SQSUB_scalar: mnemonic = "sqsub"; break; |
| 2518 |
case NEON_USHL_scalar: mnemonic = "ushl"; break; |
| 2519 |
case NEON_SSHL_scalar: mnemonic = "sshl"; break; |
| 2520 |
case NEON_UQSHL_scalar: mnemonic = "uqshl"; break; |
| 2521 |
case NEON_SQSHL_scalar: mnemonic = "sqshl"; break; |
| 2522 |
case NEON_URSHL_scalar: mnemonic = "urshl"; break; |
| 2523 |
case NEON_SRSHL_scalar: mnemonic = "srshl"; break; |
| 2524 |
case NEON_UQRSHL_scalar: mnemonic = "uqrshl"; break; |
| 2525 |
case NEON_SQRSHL_scalar: mnemonic = "sqrshl"; break; |
| 2526 |
case NEON_SQDMULH_scalar: mnemonic = "sqdmulh"; break; |
| 2527 |
case NEON_SQRDMULH_scalar: mnemonic = "sqrdmulh"; break; |
| 2528 |
default: form = "(NEONScalar3Same)"; |
| 2529 |
} |
| 2530 |
} |
| 2531 |
Format(instr, mnemonic, nfd.SubstitutePlaceholders(form)); |
| 2532 |
} |
| 2533 |
|
| 2534 |
|
| 2535 |
void Disassembler::VisitNEONScalarByIndexedElement(const Instruction* instr) { |
| 2536 |
const char *mnemonic = "unimplemented"; |
| 2537 |
const char *form = "%sd, %sn, 'Ve.%s['IVByElemIndex]"; |
| 2538 |
NEONFormatDecoder nfd(instr, NEONFormatDecoder::ScalarFormatMap()); |
| 2539 |
bool long_instr = false; |
| 2540 |
|
| 2541 |
switch (instr->Mask(NEONScalarByIndexedElementMask)) { |
| 2542 |
case NEON_SQDMULL_byelement_scalar: |
| 2543 |
mnemonic = "sqdmull"; |
| 2544 |
long_instr = true; |
| 2545 |
break; |
| 2546 |
case NEON_SQDMLAL_byelement_scalar: |
| 2547 |
mnemonic = "sqdmlal"; |
| 2548 |
long_instr = true; |
| 2549 |
break; |
| 2550 |
case NEON_SQDMLSL_byelement_scalar: |
| 2551 |
mnemonic = "sqdmlsl"; |
| 2552 |
long_instr = true; |
| 2553 |
break; |
| 2554 |
case NEON_SQDMULH_byelement_scalar: |
| 2555 |
mnemonic = "sqdmulh"; |
| 2556 |
break; |
| 2557 |
case NEON_SQRDMULH_byelement_scalar: |
| 2558 |
mnemonic = "sqrdmulh"; |
| 2559 |
break; |
| 2560 |
default: |
| 2561 |
nfd.SetFormatMap(0, nfd.FPScalarFormatMap()); |
| 2562 |
switch (instr->Mask(NEONScalarByIndexedElementFPMask)) { |
| 2563 |
case NEON_FMUL_byelement_scalar: mnemonic = "fmul"; break; |
| 2564 |
case NEON_FMLA_byelement_scalar: mnemonic = "fmla"; break; |
| 2565 |
case NEON_FMLS_byelement_scalar: mnemonic = "fmls"; break; |
| 2566 |
case NEON_FMULX_byelement_scalar: mnemonic = "fmulx"; break; |
| 2567 |
default: form = "(NEONScalarByIndexedElement)"; |
| 2568 |
} |
| 2569 |
} |
| 2570 |
|
| 2571 |
if (long_instr) { |
| 2572 |
nfd.SetFormatMap(0, nfd.LongScalarFormatMap()); |
| 2573 |
} |
| 2574 |
|
| 2575 |
Format(instr, mnemonic, nfd.Substitute( |
| 2576 |
form, nfd.kPlaceholder, nfd.kPlaceholder, nfd.kFormat)); |
| 2577 |
} |
| 2578 |
|
| 2579 |
|
| 2580 |
void Disassembler::VisitNEONScalarCopy(const Instruction* instr) { |
| 2581 |
const char *mnemonic = "unimplemented"; |
| 2582 |
const char *form = "(NEONScalarCopy)"; |
| 2583 |
|
| 2584 |
NEONFormatDecoder nfd(instr, NEONFormatDecoder::TriangularScalarFormatMap()); |
| 2585 |
|
| 2586 |
if (instr->Mask(NEONScalarCopyMask) == NEON_DUP_ELEMENT_scalar) { |
| 2587 |
mnemonic = "mov"; |
| 2588 |
form = "%sd, 'Vn.%s['IVInsIndex1]"; |
| 2589 |
} |
| 2590 |
|
| 2591 |
Format(instr, mnemonic, nfd.Substitute(form, nfd.kPlaceholder, nfd.kFormat)); |
| 2592 |
} |
| 2593 |
|
| 2594 |
|
| 2595 |
void Disassembler::VisitNEONScalarPairwise(const Instruction* instr) { |
| 2596 |
const char *mnemonic = "unimplemented"; |
| 2597 |
const char *form = "%sd, 'Vn.%s"; |
| 2598 |
NEONFormatMap map = { {22}, {NF_2S, NF_2D} }; |
| 2599 |
NEONFormatDecoder nfd(instr, NEONFormatDecoder::FPScalarFormatMap(), &map); |
| 2600 |
|
| 2601 |
switch (instr->Mask(NEONScalarPairwiseMask)) { |
| 2602 |
case NEON_ADDP_scalar: mnemonic = "addp"; break; |
| 2603 |
case NEON_FADDP_scalar: mnemonic = "faddp"; break; |
| 2604 |
case NEON_FMAXP_scalar: mnemonic = "fmaxp"; break; |
| 2605 |
case NEON_FMAXNMP_scalar: mnemonic = "fmaxnmp"; break; |
| 2606 |
case NEON_FMINP_scalar: mnemonic = "fminp"; break; |
| 2607 |
case NEON_FMINNMP_scalar: mnemonic = "fminnmp"; break; |
| 2608 |
default: form = "(NEONScalarPairwise)"; |
| 2609 |
} |
| 2610 |
Format(instr, mnemonic, nfd.Substitute(form, |
| 2611 |
NEONFormatDecoder::kPlaceholder, NEONFormatDecoder::kFormat)); |
| 2612 |
} |
| 2613 |
|
| 2614 |
|
| 2615 |
void Disassembler::VisitNEONScalarShiftImmediate(const Instruction* instr) { |
| 2616 |
const char *mnemonic = "unimplemented"; |
| 2617 |
const char *form = "%sd, %sn, 'Is1"; |
| 2618 |
const char *form_2 = "%sd, %sn, 'Is2"; |
| 2619 |
|
| 2620 |
static const NEONFormatMap map_shift = { |
| 2621 |
{22, 21, 20, 19}, |
| 2622 |
{NF_UNDEF, NF_B, NF_H, NF_H, NF_S, NF_S, NF_S, NF_S, |
| 2623 |
NF_D, NF_D, NF_D, NF_D, NF_D, NF_D, NF_D, NF_D} |
| 2624 |
}; |
| 2625 |
static const NEONFormatMap map_shift_narrow = { |
| 2626 |
{21, 20, 19}, |
| 2627 |
{NF_UNDEF, NF_H, NF_S, NF_S, NF_D, NF_D, NF_D, NF_D} |
| 2628 |
}; |
| 2629 |
NEONFormatDecoder nfd(instr, &map_shift); |
| 2630 |
|
| 2631 |
if (instr->ImmNEONImmh()) { // immh has to be non-zero. |
| 2632 |
switch (instr->Mask(NEONScalarShiftImmediateMask)) { |
| 2633 |
case NEON_FCVTZU_imm_scalar: mnemonic = "fcvtzu"; break; |
| 2634 |
case NEON_FCVTZS_imm_scalar: mnemonic = "fcvtzs"; break; |
| 2635 |
case NEON_SCVTF_imm_scalar: mnemonic = "scvtf"; break; |
| 2636 |
case NEON_UCVTF_imm_scalar: mnemonic = "ucvtf"; break; |
| 2637 |
case NEON_SRI_scalar: mnemonic = "sri"; break; |
| 2638 |
case NEON_SSHR_scalar: mnemonic = "sshr"; break; |
| 2639 |
case NEON_USHR_scalar: mnemonic = "ushr"; break; |
| 2640 |
case NEON_SRSHR_scalar: mnemonic = "srshr"; break; |
| 2641 |
case NEON_URSHR_scalar: mnemonic = "urshr"; break; |
| 2642 |
case NEON_SSRA_scalar: mnemonic = "ssra"; break; |
| 2643 |
case NEON_USRA_scalar: mnemonic = "usra"; break; |
| 2644 |
case NEON_SRSRA_scalar: mnemonic = "srsra"; break; |
| 2645 |
case NEON_URSRA_scalar: mnemonic = "ursra"; break; |
| 2646 |
case NEON_SHL_scalar: mnemonic = "shl"; form = form_2; break; |
| 2647 |
case NEON_SLI_scalar: mnemonic = "sli"; form = form_2; break; |
| 2648 |
case NEON_SQSHLU_scalar: mnemonic = "sqshlu"; form = form_2; break; |
| 2649 |
case NEON_SQSHL_imm_scalar: mnemonic = "sqshl"; form = form_2; break; |
| 2650 |
case NEON_UQSHL_imm_scalar: mnemonic = "uqshl"; form = form_2; break; |
| 2651 |
case NEON_UQSHRN_scalar: |
| 2652 |
mnemonic = "uqshrn"; |
| 2653 |
nfd.SetFormatMap(1, &map_shift_narrow); |
| 2654 |
break; |
| 2655 |
case NEON_UQRSHRN_scalar: |
| 2656 |
mnemonic = "uqrshrn"; |
| 2657 |
nfd.SetFormatMap(1, &map_shift_narrow); |
| 2658 |
break; |
| 2659 |
case NEON_SQSHRN_scalar: |
| 2660 |
mnemonic = "sqshrn"; |
| 2661 |
nfd.SetFormatMap(1, &map_shift_narrow); |
| 2662 |
break; |
| 2663 |
case NEON_SQRSHRN_scalar: |
| 2664 |
mnemonic = "sqrshrn"; |
| 2665 |
nfd.SetFormatMap(1, &map_shift_narrow); |
| 2666 |
break; |
| 2667 |
case NEON_SQSHRUN_scalar: |
| 2668 |
mnemonic = "sqshrun"; |
| 2669 |
nfd.SetFormatMap(1, &map_shift_narrow); |
| 2670 |
break; |
| 2671 |
case NEON_SQRSHRUN_scalar: |
| 2672 |
mnemonic = "sqrshrun"; |
| 2673 |
nfd.SetFormatMap(1, &map_shift_narrow); |
| 2674 |
break; |
| 2675 |
default: |
| 2676 |
form = "(NEONScalarShiftImmediate)"; |
| 2677 |
} |
| 2678 |
} else { |
| 2679 |
form = "(NEONScalarShiftImmediate)"; |
| 2680 |
} |
| 2681 |
Format(instr, mnemonic, nfd.SubstitutePlaceholders(form)); |
| 2682 |
} |
| 2683 |
|
| 2684 |
|
| 2685 |
void Disassembler::VisitNEONShiftImmediate(const Instruction* instr) { |
| 2686 |
const char *mnemonic = "unimplemented"; |
| 2687 |
const char *form = "'Vd.%s, 'Vn.%s, 'Is1"; |
| 2688 |
const char *form_shift_2 = "'Vd.%s, 'Vn.%s, 'Is2"; |
| 2689 |
const char *form_xtl = "'Vd.%s, 'Vn.%s"; |
| 2690 |
|
| 2691 |
// 0001->8H, 001x->4S, 01xx->2D, all others undefined. |
| 2692 |
static const NEONFormatMap map_shift_ta = { |
| 2693 |
{22, 21, 20, 19}, |
| 2694 |
{NF_UNDEF, NF_8H, NF_4S, NF_4S, NF_2D, NF_2D, NF_2D, NF_2D} |
| 2695 |
}; |
| 2696 |
|
| 2697 |
// 00010->8B, 00011->16B, 001x0->4H, 001x1->8H, |
| 2698 |
// 01xx0->2S, 01xx1->4S, 1xxx1->2D, all others undefined. |
| 2699 |
static const NEONFormatMap map_shift_tb = { |
| 2700 |
{22, 21, 20, 19, 30}, |
| 2701 |
{NF_UNDEF, NF_UNDEF, NF_8B, NF_16B, NF_4H, NF_8H, NF_4H, NF_8H, |
| 2702 |
NF_2S, NF_4S, NF_2S, NF_4S, NF_2S, NF_4S, NF_2S, NF_4S, |
| 2703 |
NF_UNDEF, NF_2D, NF_UNDEF, NF_2D, NF_UNDEF, NF_2D, NF_UNDEF, NF_2D, |
| 2704 |
NF_UNDEF, NF_2D, NF_UNDEF, NF_2D, NF_UNDEF, NF_2D, NF_UNDEF, NF_2D} |
| 2705 |
}; |
| 2706 |
|
| 2707 |
NEONFormatDecoder nfd(instr, &map_shift_tb); |
| 2708 |
|
| 2709 |
if (instr->ImmNEONImmh()) { // immh has to be non-zero. |
| 2710 |
switch (instr->Mask(NEONShiftImmediateMask)) { |
| 2711 |
case NEON_SQSHLU: mnemonic = "sqshlu"; form = form_shift_2; break; |
| 2712 |
case NEON_SQSHL_imm: mnemonic = "sqshl"; form = form_shift_2; break; |
| 2713 |
case NEON_UQSHL_imm: mnemonic = "uqshl"; form = form_shift_2; break; |
| 2714 |
case NEON_SHL: mnemonic = "shl"; form = form_shift_2; break; |
| 2715 |
case NEON_SLI: mnemonic = "sli"; form = form_shift_2; break; |
| 2716 |
case NEON_SCVTF_imm: mnemonic = "scvtf"; break; |
| 2717 |
case NEON_UCVTF_imm: mnemonic = "ucvtf"; break; |
| 2718 |
case NEON_FCVTZU_imm: mnemonic = "fcvtzu"; break; |
| 2719 |
case NEON_FCVTZS_imm: mnemonic = "fcvtzs"; break; |
| 2720 |
case NEON_SRI: mnemonic = "sri"; break; |
| 2721 |
case NEON_SSHR: mnemonic = "sshr"; break; |
| 2722 |
case NEON_USHR: mnemonic = "ushr"; break; |
| 2723 |
case NEON_SRSHR: mnemonic = "srshr"; break; |
| 2724 |
case NEON_URSHR: mnemonic = "urshr"; break; |
| 2725 |
case NEON_SSRA: mnemonic = "ssra"; break; |
| 2726 |
case NEON_USRA: mnemonic = "usra"; break; |
| 2727 |
case NEON_SRSRA: mnemonic = "srsra"; break; |
| 2728 |
case NEON_URSRA: mnemonic = "ursra"; break; |
| 2729 |
case NEON_SHRN: |
| 2730 |
mnemonic = instr->Mask(NEON_Q) ? "shrn2" : "shrn"; |
| 2731 |
nfd.SetFormatMap(1, &map_shift_ta); |
| 2732 |
break; |
| 2733 |
case NEON_RSHRN: |
| 2734 |
mnemonic = instr->Mask(NEON_Q) ? "rshrn2" : "rshrn"; |
| 2735 |
nfd.SetFormatMap(1, &map_shift_ta); |
| 2736 |
break; |
| 2737 |
case NEON_UQSHRN: |
| 2738 |
mnemonic = instr->Mask(NEON_Q) ? "uqshrn2" : "uqshrn"; |
| 2739 |
nfd.SetFormatMap(1, &map_shift_ta); |
| 2740 |
break; |
| 2741 |
case NEON_UQRSHRN: |
| 2742 |
mnemonic = instr->Mask(NEON_Q) ? "uqrshrn2" : "uqrshrn"; |
| 2743 |
nfd.SetFormatMap(1, &map_shift_ta); |
| 2744 |
break; |
| 2745 |
case NEON_SQSHRN: |
| 2746 |
mnemonic = instr->Mask(NEON_Q) ? "sqshrn2" : "sqshrn"; |
| 2747 |
nfd.SetFormatMap(1, &map_shift_ta); |
| 2748 |
break; |
| 2749 |
case NEON_SQRSHRN: |
| 2750 |
mnemonic = instr->Mask(NEON_Q) ? "sqrshrn2" : "sqrshrn"; |
| 2751 |
nfd.SetFormatMap(1, &map_shift_ta); |
| 2752 |
break; |
| 2753 |
case NEON_SQSHRUN: |
| 2754 |
mnemonic = instr->Mask(NEON_Q) ? "sqshrun2" : "sqshrun"; |
| 2755 |
nfd.SetFormatMap(1, &map_shift_ta); |
| 2756 |
break; |
| 2757 |
case NEON_SQRSHRUN: |
| 2758 |
mnemonic = instr->Mask(NEON_Q) ? "sqrshrun2" : "sqrshrun"; |
| 2759 |
nfd.SetFormatMap(1, &map_shift_ta); |
| 2760 |
break; |
| 2761 |
case NEON_SSHLL: |
| 2762 |
nfd.SetFormatMap(0, &map_shift_ta); |
| 2763 |
if (instr->ImmNEONImmb() == 0 && |
| 2764 |
CountSetBits(instr->ImmNEONImmh(), 32) == 1) { // sxtl variant. |
| 2765 |
form = form_xtl; |
| 2766 |
mnemonic = instr->Mask(NEON_Q) ? "sxtl2" : "sxtl"; |
| 2767 |
} else { // sshll variant. |
| 2768 |
form = form_shift_2; |
| 2769 |
mnemonic = instr->Mask(NEON_Q) ? "sshll2" : "sshll"; |
| 2770 |
} |
| 2771 |
break; |
| 2772 |
case NEON_USHLL: |
| 2773 |
nfd.SetFormatMap(0, &map_shift_ta); |
| 2774 |
if (instr->ImmNEONImmb() == 0 && |
| 2775 |
CountSetBits(instr->ImmNEONImmh(), 32) == 1) { // uxtl variant. |
| 2776 |
form = form_xtl; |
| 2777 |
mnemonic = instr->Mask(NEON_Q) ? "uxtl2" : "uxtl"; |
| 2778 |
} else { // ushll variant. |
| 2779 |
form = form_shift_2; |
| 2780 |
mnemonic = instr->Mask(NEON_Q) ? "ushll2" : "ushll"; |
| 2781 |
} |
| 2782 |
break; |
| 2783 |
default: form = "(NEONShiftImmediate)"; |
| 2784 |
} |
| 2785 |
} else { |
| 2786 |
form = "(NEONShiftImmediate)"; |
| 2787 |
} |
| 2788 |
Format(instr, mnemonic, nfd.Substitute(form)); |
| 2789 |
} |
| 2790 |
|
| 2791 |
|
| 2792 |
void Disassembler::VisitNEONTable(const Instruction* instr) { |
| 2793 |
const char *mnemonic = "unimplemented"; |
| 2794 |
const char *form = "(NEONTable)"; |
| 2795 |
const char form_1v[] = "'Vd.%%s, {'Vn.16b}, 'Vm.%%s"; |
| 2796 |
const char form_2v[] = "'Vd.%%s, {'Vn.16b, v%d.16b}, 'Vm.%%s"; |
| 2797 |
const char form_3v[] = "'Vd.%%s, {'Vn.16b, v%d.16b, v%d.16b}, 'Vm.%%s"; |
| 2798 |
const char form_4v[] = |
| 2799 |
"'Vd.%%s, {'Vn.16b, v%d.16b, v%d.16b, v%d.16b}, 'Vm.%%s"; |
| 2800 |
static const NEONFormatMap map_b = { {30}, {NF_8B, NF_16B} }; |
| 2801 |
NEONFormatDecoder nfd(instr, &map_b); |
| 2802 |
|
| 2803 |
switch (instr->Mask(NEONTableMask)) { |
| 2804 |
case NEON_TBL_1v: mnemonic = "tbl"; form = form_1v; break; |
| 2805 |
case NEON_TBL_2v: mnemonic = "tbl"; form = form_2v; break; |
| 2806 |
case NEON_TBL_3v: mnemonic = "tbl"; form = form_3v; break; |
| 2807 |
case NEON_TBL_4v: mnemonic = "tbl"; form = form_4v; break; |
| 2808 |
case NEON_TBX_1v: mnemonic = "tbx"; form = form_1v; break; |
| 2809 |
case NEON_TBX_2v: mnemonic = "tbx"; form = form_2v; break; |
| 2810 |
case NEON_TBX_3v: mnemonic = "tbx"; form = form_3v; break; |
| 2811 |
case NEON_TBX_4v: mnemonic = "tbx"; form = form_4v; break; |
| 2812 |
default: break; |
| 2813 |
} |
| 2814 |
|
| 2815 |
char re_form[sizeof(form_4v) + 6]; |
| 2816 |
int reg_num = instr->Rn(); |
| 2817 |
SprintfLiteral(re_form, form, |
| 2818 |
(reg_num + 1) % kNumberOfVRegisters, |
| 2819 |
(reg_num + 2) % kNumberOfVRegisters, |
| 2820 |
(reg_num + 3) % kNumberOfVRegisters); |
| 2821 |
|
| 2822 |
Format(instr, mnemonic, nfd.Substitute(re_form)); |
| 2823 |
} |
| 2824 |
|
| 2825 |
|
| 2826 |
void Disassembler::VisitNEONPerm(const Instruction* instr) { |
| 2827 |
const char *mnemonic = "unimplemented"; |
| 2828 |
const char *form = "'Vd.%s, 'Vn.%s, 'Vm.%s"; |
| 2829 |
NEONFormatDecoder nfd(instr); |
| 2830 |
|
| 2831 |
switch (instr->Mask(NEONPermMask)) { |
| 2832 |
case NEON_TRN1: mnemonic = "trn1"; break; |
| 2833 |
case NEON_TRN2: mnemonic = "trn2"; break; |
| 2834 |
case NEON_UZP1: mnemonic = "uzp1"; break; |
| 2835 |
case NEON_UZP2: mnemonic = "uzp2"; break; |
| 2836 |
case NEON_ZIP1: mnemonic = "zip1"; break; |
| 2837 |
case NEON_ZIP2: mnemonic = "zip2"; break; |
| 2838 |
default: form = "(NEONPerm)"; |
| 2839 |
} |
| 2840 |
Format(instr, mnemonic, nfd.Substitute(form)); |
| 2841 |
} |
| 2842 |
|
| 2843 |
|
| 2844 |
void Disassembler::VisitUnimplemented(const Instruction* instr) { |
| 2845 |
Format(instr, "unimplemented", "(Unimplemented)"); |
| 2846 |
} |
| 2847 |
|
| 2848 |
|
| 2849 |
void Disassembler::VisitUnallocated(const Instruction* instr) { |
| 2850 |
Format(instr, "unallocated", "(Unallocated)"); |
| 2851 |
} |
| 2852 |
|
| 2853 |
|
| 2854 |
void Disassembler::ProcessOutput(const Instruction* /*instr*/) { |
| 2855 |
// The base disasm does nothing more than disassembling into a buffer. |
| 2856 |
} |
| 2857 |
|
| 2858 |
|
| 2859 |
void Disassembler::AppendRegisterNameToOutput(const Instruction* instr, |
| 2860 |
const CPURegister& reg) { |
| 2861 |
USE(instr); |
| 2862 |
VIXL_ASSERT(reg.IsValid()); |
| 2863 |
char reg_char; |
| 2864 |
|
| 2865 |
if (reg.IsRegister()) { |
| 2866 |
reg_char = reg.Is64Bits() ? 'x' : 'w'; |
| 2867 |
} else { |
| 2868 |
VIXL_ASSERT(reg.IsVRegister()); |
| 2869 |
switch (reg.SizeInBits()) { |
| 2870 |
case kBRegSize: reg_char = 'b'; break; |
| 2871 |
case kHRegSize: reg_char = 'h'; break; |
| 2872 |
case kSRegSize: reg_char = 's'; break; |
| 2873 |
case kDRegSize: reg_char = 'd'; break; |
| 2874 |
default: |
| 2875 |
VIXL_ASSERT(reg.Is128Bits()); |
| 2876 |
reg_char = 'q'; |
| 2877 |
} |
| 2878 |
} |
| 2879 |
|
| 2880 |
if (reg.IsVRegister() || !(reg.Aliases(sp) || reg.Aliases(xzr))) { |
| 2881 |
// A core or scalar/vector register: [wx]0 - 30, [bhsdq]0 - 31. |
| 2882 |
AppendToOutput("%c%d", reg_char, reg.code()); |
| 2883 |
} else if (reg.Aliases(sp)) { |
| 2884 |
// Disassemble w31/x31 as stack pointer wsp/sp. |
| 2885 |
AppendToOutput("%s", reg.Is64Bits() ? "sp" : "wsp"); |
| 2886 |
} else { |
| 2887 |
// Disassemble w31/x31 as zero register wzr/xzr. |
| 2888 |
AppendToOutput("%czr", reg_char); |
| 2889 |
} |
| 2890 |
} |
| 2891 |
|
| 2892 |
|
| 2893 |
void Disassembler::AppendPCRelativeOffsetToOutput(const Instruction* instr, |
| 2894 |
int64_t offset) { |
| 2895 |
USE(instr); |
| 2896 |
char sign = (offset < 0) ? '-' : '+'; |
| 2897 |
AppendToOutput("#%c0x%" PRIx64, sign, std::abs(offset)); |
| 2898 |
} |
| 2899 |
|
| 2900 |
|
| 2901 |
void Disassembler::AppendAddressToOutput(const Instruction* instr, |
| 2902 |
const void* addr) { |
| 2903 |
USE(instr); |
| 2904 |
AppendToOutput("(addr 0x%" PRIxPTR ")", reinterpret_cast<uintptr_t>(addr)); |
| 2905 |
} |
| 2906 |
|
| 2907 |
|
| 2908 |
void Disassembler::AppendCodeAddressToOutput(const Instruction* instr, |
| 2909 |
const void* addr) { |
| 2910 |
AppendAddressToOutput(instr, addr); |
| 2911 |
} |
| 2912 |
|
| 2913 |
|
| 2914 |
void Disassembler::AppendDataAddressToOutput(const Instruction* instr, |
| 2915 |
const void* addr) { |
| 2916 |
AppendAddressToOutput(instr, addr); |
| 2917 |
} |
| 2918 |
|
| 2919 |
|
| 2920 |
void Disassembler::AppendCodeRelativeAddressToOutput(const Instruction* instr, |
| 2921 |
const void* addr) { |
| 2922 |
USE(instr); |
| 2923 |
int64_t rel_addr = CodeRelativeAddress(addr); |
| 2924 |
if (rel_addr >= 0) { |
| 2925 |
AppendToOutput("(addr 0x%" PRIx64 ")", rel_addr); |
| 2926 |
} else { |
| 2927 |
AppendToOutput("(addr -0x%" PRIx64 ")", -rel_addr); |
| 2928 |
} |
| 2929 |
} |
| 2930 |
|
| 2931 |
|
| 2932 |
void Disassembler::AppendCodeRelativeCodeAddressToOutput( |
| 2933 |
const Instruction* instr, const void* addr) { |
| 2934 |
AppendCodeRelativeAddressToOutput(instr, addr); |
| 2935 |
} |
| 2936 |
|
| 2937 |
|
| 2938 |
void Disassembler::AppendCodeRelativeDataAddressToOutput( |
| 2939 |
const Instruction* instr, const void* addr) { |
| 2940 |
AppendCodeRelativeAddressToOutput(instr, addr); |
| 2941 |
} |
| 2942 |
|
| 2943 |
|
| 2944 |
void Disassembler::MapCodeAddress(int64_t base_address, |
| 2945 |
const Instruction* instr_address) { |
| 2946 |
set_code_address_offset( |
| 2947 |
base_address - reinterpret_cast<intptr_t>(instr_address)); |
| 2948 |
} |
| 2949 |
int64_t Disassembler::CodeRelativeAddress(const void* addr) { |
| 2950 |
return reinterpret_cast<intptr_t>(addr) + code_address_offset(); |
| 2951 |
} |
| 2952 |
|
| 2953 |
|
| 2954 |
void Disassembler::Format(const Instruction* instr, const char* mnemonic, |
| 2955 |
const char* format) { |
| 2956 |
VIXL_ASSERT(mnemonic != NULL); |
| 2957 |
ResetOutput(); |
| 2958 |
uint32_t pos = buffer_pos_; |
| 2959 |
Substitute(instr, mnemonic); |
| 2960 |
if (format != NULL) { |
| 2961 |
uint32_t spaces = buffer_pos_ - pos < 8 ? 8 - (buffer_pos_ - pos) : 1; |
| 2962 |
while (spaces--) { |
| 2963 |
VIXL_ASSERT(buffer_pos_ < buffer_size_); |
| 2964 |
buffer_[buffer_pos_++] = ' '; |
| 2965 |
} |
| 2966 |
Substitute(instr, format); |
| 2967 |
} |
| 2968 |
VIXL_ASSERT(buffer_pos_ < buffer_size_); |
| 2969 |
buffer_[buffer_pos_] = 0; |
| 2970 |
ProcessOutput(instr); |
| 2971 |
} |
| 2972 |
|
| 2973 |
|
| 2974 |
void Disassembler::Substitute(const Instruction* instr, const char* string) { |
| 2975 |
char chr = *string++; |
| 2976 |
while (chr != '\0') { |
| 2977 |
if (chr == '\'') { |
| 2978 |
string += SubstituteField(instr, string); |
| 2979 |
} else { |
| 2980 |
VIXL_ASSERT(buffer_pos_ < buffer_size_); |
| 2981 |
buffer_[buffer_pos_++] = chr; |
| 2982 |
} |
| 2983 |
chr = *string++; |
| 2984 |
} |
| 2985 |
} |
| 2986 |
|
| 2987 |
|
| 2988 |
int Disassembler::SubstituteField(const Instruction* instr, |
| 2989 |
const char* format) { |
| 2990 |
switch (format[0]) { |
| 2991 |
// NB. The remaining substitution prefix characters are: GJKUZ. |
| 2992 |
case 'R': // Register. X or W, selected by sf bit. |
| 2993 |
case 'F': // FP register. S or D, selected by type field. |
| 2994 |
case 'V': // Vector register, V, vector format. |
| 2995 |
case 'W': |
| 2996 |
case 'X': |
| 2997 |
case 'B': |
| 2998 |
case 'H': |
| 2999 |
case 'S': |
| 3000 |
case 'D': |
| 3001 |
case 'Q': return SubstituteRegisterField(instr, format); |
| 3002 |
case 'I': return SubstituteImmediateField(instr, format); |
| 3003 |
case 'L': return SubstituteLiteralField(instr, format); |
| 3004 |
case 'N': return SubstituteShiftField(instr, format); |
| 3005 |
case 'P': return SubstitutePrefetchField(instr, format); |
| 3006 |
case 'C': return SubstituteConditionField(instr, format); |
| 3007 |
case 'E': return SubstituteExtendField(instr, format); |
| 3008 |
case 'A': return SubstitutePCRelAddressField(instr, format); |
| 3009 |
case 'T': return SubstituteBranchTargetField(instr, format); |
| 3010 |
case 'O': return SubstituteLSRegOffsetField(instr, format); |
| 3011 |
case 'M': return SubstituteBarrierField(instr, format); |
| 3012 |
case 'K': return SubstituteCrField(instr, format); |
| 3013 |
case 'G': return SubstituteSysOpField(instr, format); |
| 3014 |
default: { |
| 3015 |
VIXL_UNREACHABLE(); |
| 3016 |
return 1; |
| 3017 |
} |
| 3018 |
} |
| 3019 |
} |
| 3020 |
|
| 3021 |
|
| 3022 |
int Disassembler::SubstituteRegisterField(const Instruction* instr, |
| 3023 |
const char* format) { |
| 3024 |
char reg_prefix = format[0]; |
| 3025 |
unsigned reg_num = 0; |
| 3026 |
unsigned field_len = 2; |
| 3027 |
|
| 3028 |
switch (format[1]) { |
| 3029 |
case 'd': |
| 3030 |
reg_num = instr->Rd(); |
| 3031 |
if (format[2] == 'q') { |
| 3032 |
reg_prefix = instr->NEONQ() ? 'X' : 'W'; |
| 3033 |
field_len = 3; |
| 3034 |
} |
| 3035 |
break; |
| 3036 |
case 'n': reg_num = instr->Rn(); break; |
| 3037 |
case 'm': |
| 3038 |
reg_num = instr->Rm(); |
| 3039 |
switch (format[2]) { |
| 3040 |
// Handle registers tagged with b (bytes), z (instruction), or |
| 3041 |
// r (registers), used for address updates in |
| 3042 |
// NEON load/store instructions. |
| 3043 |
case 'r': |
| 3044 |
case 'b': |
| 3045 |
case 'z': { |
| 3046 |
field_len = 3; |
| 3047 |
char* eimm; |
| 3048 |
int imm = static_cast<int>(strtol(&format[3], &eimm, 10)); |
| 3049 |
field_len += eimm - &format[3]; |
| 3050 |
if (reg_num == 31) { |
| 3051 |
switch (format[2]) { |
| 3052 |
case 'z': |
| 3053 |
imm *= (1 << instr->NEONLSSize()); |
| 3054 |
break; |
| 3055 |
case 'r': |
| 3056 |
imm *= (instr->NEONQ() == 0) ? kDRegSizeInBytes |
| 3057 |
: kQRegSizeInBytes; |
| 3058 |
break; |
| 3059 |
case 'b': |
| 3060 |
break; |
| 3061 |
} |
| 3062 |
AppendToOutput("#%d", imm); |
| 3063 |
return field_len; |
| 3064 |
} |
| 3065 |
break; |
| 3066 |
} |
| 3067 |
} |
| 3068 |
break; |
| 3069 |
case 'e': |
| 3070 |
// This is register Rm, but using a 4-bit specifier. Used in NEON |
| 3071 |
// by-element instructions. |
| 3072 |
reg_num = (instr->Rm() & 0xf); |
| 3073 |
break; |
| 3074 |
case 'a': reg_num = instr->Ra(); break; |
| 3075 |
case 's': reg_num = instr->Rs(); break; |
| 3076 |
case 't': |
| 3077 |
reg_num = instr->Rt(); |
| 3078 |
if (format[0] == 'V') { |
| 3079 |
if ((format[2] >= '2') && (format[2] <= '4')) { |
| 3080 |
// Handle consecutive vector register specifiers Vt2, Vt3 and Vt4. |
| 3081 |
reg_num = (reg_num + format[2] - '1') % 32; |
| 3082 |
field_len = 3; |
| 3083 |
} |
| 3084 |
} else { |
| 3085 |
if (format[2] == '2') { |
| 3086 |
// Handle register specifier Rt2. |
| 3087 |
reg_num = instr->Rt2(); |
| 3088 |
field_len = 3; |
| 3089 |
} |
| 3090 |
} |
| 3091 |
break; |
| 3092 |
case '(': { |
| 3093 |
switch (format[2]) { |
| 3094 |
case 's': |
| 3095 |
reg_num = instr->Rs(); |
| 3096 |
break; |
| 3097 |
case 't': |
| 3098 |
reg_num = instr->Rt(); |
| 3099 |
break; |
| 3100 |
default: |
| 3101 |
VIXL_UNREACHABLE(); |
| 3102 |
} |
| 3103 |
|
| 3104 |
VIXL_ASSERT(format[3] == '+'); |
| 3105 |
int i = 4; |
| 3106 |
int addition = 0; |
| 3107 |
while (format[i] != ')') { |
| 3108 |
VIXL_ASSERT((format[i] >= '0') && (format[i] <= '9')); |
| 3109 |
addition *= 10; |
| 3110 |
addition += format[i] - '0'; |
| 3111 |
++i; |
| 3112 |
} |
| 3113 |
reg_num += addition; |
| 3114 |
field_len = i + 1; |
| 3115 |
break; |
| 3116 |
} |
| 3117 |
default: VIXL_UNREACHABLE(); |
| 3118 |
} |
| 3119 |
|
| 3120 |
// Increase field length for registers tagged as stack. |
| 3121 |
if (format[1] != '(' && format[2] == 's') { |
| 3122 |
field_len = 3; |
| 3123 |
} |
| 3124 |
|
| 3125 |
CPURegister::RegisterType reg_type = CPURegister::kRegister; |
| 3126 |
unsigned reg_size = kXRegSize; |
| 3127 |
|
| 3128 |
if (reg_prefix == 'R') { |
| 3129 |
reg_prefix = instr->SixtyFourBits() ? 'X' : 'W'; |
| 3130 |
} else if (reg_prefix == 'F') { |
| 3131 |
reg_prefix = ((instr->FPType() & 1) == 0) ? 'S' : 'D'; |
| 3132 |
} |
| 3133 |
|
| 3134 |
switch (reg_prefix) { |
| 3135 |
case 'W': |
| 3136 |
reg_type = CPURegister::kRegister; reg_size = kWRegSize; break; |
| 3137 |
case 'X': |
| 3138 |
reg_type = CPURegister::kRegister; reg_size = kXRegSize; break; |
| 3139 |
case 'B': |
| 3140 |
reg_type = CPURegister::kVRegister; reg_size = kBRegSize; break; |
| 3141 |
case 'H': |
| 3142 |
reg_type = CPURegister::kVRegister; reg_size = kHRegSize; break; |
| 3143 |
case 'S': |
| 3144 |
reg_type = CPURegister::kVRegister; reg_size = kSRegSize; break; |
| 3145 |
case 'D': |
| 3146 |
reg_type = CPURegister::kVRegister; reg_size = kDRegSize; break; |
| 3147 |
case 'Q': |
| 3148 |
reg_type = CPURegister::kVRegister; reg_size = kQRegSize; break; |
| 3149 |
case 'V': |
| 3150 |
AppendToOutput("v%d", reg_num); |
| 3151 |
return field_len; |
| 3152 |
default: |
| 3153 |
VIXL_UNREACHABLE(); |
| 3154 |
} |
| 3155 |
|
| 3156 |
if ((reg_type == CPURegister::kRegister) && |
| 3157 |
(reg_num == kZeroRegCode) && (format[2] == 's')) { |
| 3158 |
reg_num = kSPRegInternalCode; |
| 3159 |
} |
| 3160 |
|
| 3161 |
AppendRegisterNameToOutput(instr, CPURegister(reg_num, reg_size, reg_type)); |
| 3162 |
|
| 3163 |
return field_len; |
| 3164 |
} |
| 3165 |
|
| 3166 |
|
| 3167 |
int Disassembler::SubstituteImmediateField(const Instruction* instr, |
| 3168 |
const char* format) { |
| 3169 |
VIXL_ASSERT(format[0] == 'I'); |
| 3170 |
|
| 3171 |
switch (format[1]) { |
| 3172 |
case 'M': { // IMoveImm, IMoveNeg or IMoveLSL. |
| 3173 |
if (format[5] == 'L') { |
| 3174 |
AppendToOutput("#0x%" PRIx32, instr->ImmMoveWide()); |
| 3175 |
if (instr->ShiftMoveWide() > 0) { |
| 3176 |
AppendToOutput(", lsl #%" PRId32, 16 * instr->ShiftMoveWide()); |
| 3177 |
} |
| 3178 |
} else { |
| 3179 |
VIXL_ASSERT((format[5] == 'I') || (format[5] == 'N')); |
| 3180 |
uint64_t imm = static_cast<uint64_t>(instr->ImmMoveWide()) << |
| 3181 |
(16 * instr->ShiftMoveWide()); |
| 3182 |
if (format[5] == 'N') |
| 3183 |
imm = ~imm; |
| 3184 |
if (!instr->SixtyFourBits()) |
| 3185 |
imm &= UINT64_C(0xffffffff); |
| 3186 |
AppendToOutput("#0x%" PRIx64, imm); |
| 3187 |
} |
| 3188 |
return 8; |
| 3189 |
} |
| 3190 |
case 'L': { |
| 3191 |
switch (format[2]) { |
| 3192 |
case 'L': { // ILLiteral - Immediate Load Literal. |
| 3193 |
AppendToOutput("pc%+" PRId32, |
| 3194 |
instr->ImmLLiteral() << kLiteralEntrySizeLog2); |
| 3195 |
return 9; |
| 3196 |
} |
| 3197 |
case 'S': { // ILS - Immediate Load/Store. |
| 3198 |
if (instr->ImmLS() != 0) { |
| 3199 |
AppendToOutput(", #%" PRId32, instr->ImmLS()); |
| 3200 |
} |
| 3201 |
return 3; |
| 3202 |
} |
| 3203 |
case 'P': { // ILPx - Immediate Load/Store Pair, x = access size. |
| 3204 |
if (instr->ImmLSPair() != 0) { |
| 3205 |
// format[3] is the scale value. Convert to a number. |
| 3206 |
int scale = 1 << (format[3] - '0'); |
| 3207 |
AppendToOutput(", #%" PRId32, instr->ImmLSPair() * scale); |
| 3208 |
} |
| 3209 |
return 4; |
| 3210 |
} |
| 3211 |
case 'U': { // ILU - Immediate Load/Store Unsigned. |
| 3212 |
if (instr->ImmLSUnsigned() != 0) { |
| 3213 |
int shift = instr->SizeLS(); |
| 3214 |
AppendToOutput(", #%" PRId32, instr->ImmLSUnsigned() << shift); |
| 3215 |
} |
| 3216 |
return 3; |
| 3217 |
} |
| 3218 |
default: { |
| 3219 |
VIXL_UNIMPLEMENTED(); |
| 3220 |
return 0; |
| 3221 |
} |
| 3222 |
} |
| 3223 |
} |
| 3224 |
case 'C': { // ICondB - Immediate Conditional Branch. |
| 3225 |
int64_t offset = instr->ImmCondBranch() << 2; |
| 3226 |
AppendPCRelativeOffsetToOutput(instr, offset); |
| 3227 |
return 6; |
| 3228 |
} |
| 3229 |
case 'A': { // IAddSub. |
| 3230 |
VIXL_ASSERT(instr->ShiftAddSub() <= 1); |
| 3231 |
int64_t imm = instr->ImmAddSub() << (12 * instr->ShiftAddSub()); |
| 3232 |
AppendToOutput("#0x%" PRIx64 " (%" PRId64 ")", imm, imm); |
| 3233 |
return 7; |
| 3234 |
} |
| 3235 |
case 'F': { // IFPSingle, IFPDouble or IFPFBits. |
| 3236 |
if (format[3] == 'F') { // IFPFbits. |
| 3237 |
AppendToOutput("#%" PRId32, 64 - instr->FPScale()); |
| 3238 |
return 8; |
| 3239 |
} else { |
| 3240 |
AppendToOutput("#0x%" PRIx32 " (%.4f)", instr->ImmFP(), |
| 3241 |
format[3] == 'S' ? instr->ImmFP32() : instr->ImmFP64()); |
| 3242 |
return 9; |
| 3243 |
} |
| 3244 |
} |
| 3245 |
case 'T': { // ITri - Immediate Triangular Encoded. |
| 3246 |
AppendToOutput("#0x%" PRIx64, instr->ImmLogical()); |
| 3247 |
return 4; |
| 3248 |
} |
| 3249 |
case 'N': { // INzcv. |
| 3250 |
int nzcv = (instr->Nzcv() << Flags_offset); |
| 3251 |
AppendToOutput("#%c%c%c%c", ((nzcv & NFlag) == 0) ? 'n' : 'N', |
| 3252 |
((nzcv & ZFlag) == 0) ? 'z' : 'Z', |
| 3253 |
((nzcv & CFlag) == 0) ? 'c' : 'C', |
| 3254 |
((nzcv & VFlag) == 0) ? 'v' : 'V'); |
| 3255 |
return 5; |
| 3256 |
} |
| 3257 |
case 'P': { // IP - Conditional compare. |
| 3258 |
AppendToOutput("#%" PRId32, instr->ImmCondCmp()); |
| 3259 |
return 2; |
| 3260 |
} |
| 3261 |
case 'B': { // Bitfields. |
| 3262 |
return SubstituteBitfieldImmediateField(instr, format); |
| 3263 |
} |
| 3264 |
case 'E': { // IExtract. |
| 3265 |
AppendToOutput("#%" PRId32, instr->ImmS()); |
| 3266 |
return 8; |
| 3267 |
} |
| 3268 |
case 'S': { // IS - Test and branch bit. |
| 3269 |
AppendToOutput("#%" PRId32, (instr->ImmTestBranchBit5() << 5) | |
| 3270 |
instr->ImmTestBranchBit40()); |
| 3271 |
return 2; |
| 3272 |
} |
| 3273 |
case 's': { // Is - Shift (immediate). |
| 3274 |
switch (format[2]) { |
| 3275 |
case '1': { // Is1 - SSHR. |
| 3276 |
int shift = 16 << HighestSetBitPosition(instr->ImmNEONImmh()); |
| 3277 |
shift -= instr->ImmNEONImmhImmb(); |
| 3278 |
AppendToOutput("#%d", shift); |
| 3279 |
return 3; |
| 3280 |
} |
| 3281 |
case '2': { // Is2 - SLI. |
| 3282 |
int shift = instr->ImmNEONImmhImmb(); |
| 3283 |
shift -= 8 << HighestSetBitPosition(instr->ImmNEONImmh()); |
| 3284 |
AppendToOutput("#%d", shift); |
| 3285 |
return 3; |
| 3286 |
} |
| 3287 |
default: { |
| 3288 |
VIXL_UNIMPLEMENTED(); |
| 3289 |
return 0; |
| 3290 |
} |
| 3291 |
} |
| 3292 |
} |
| 3293 |
case 'D': { // IDebug - HLT and BRK instructions. |
| 3294 |
AppendToOutput("#0x%" PRIx32, instr->ImmException()); |
| 3295 |
return 6; |
| 3296 |
} |
| 3297 |
case 'V': { // Immediate Vector. |
| 3298 |
switch (format[2]) { |
| 3299 |
case 'E': { // IVExtract. |
| 3300 |
AppendToOutput("#%" PRId32, instr->ImmNEONExt()); |
| 3301 |
return 9; |
| 3302 |
} |
| 3303 |
case 'B': { // IVByElemIndex. |
| 3304 |
int vm_index = (instr->NEONH() << 1) | instr->NEONL(); |
| 3305 |
if (instr->NEONSize() == 1) { |
| 3306 |
vm_index = (vm_index << 1) | instr->NEONM(); |
| 3307 |
} |
| 3308 |
AppendToOutput("%d", vm_index); |
| 3309 |
return strlen("IVByElemIndex"); |
| 3310 |
} |
| 3311 |
case 'I': { // INS element. |
| 3312 |
if (strncmp(format, "IVInsIndex", strlen("IVInsIndex")) == 0) { |
| 3313 |
int rd_index, rn_index; |
| 3314 |
int imm5 = instr->ImmNEON5(); |
| 3315 |
int imm4 = instr->ImmNEON4(); |
| 3316 |
int tz = CountTrailingZeros(imm5, 32); |
| 3317 |
rd_index = imm5 >> (tz + 1); |
| 3318 |
rn_index = imm4 >> tz; |
| 3319 |
if (strncmp(format, "IVInsIndex1", strlen("IVInsIndex1")) == 0) { |
| 3320 |
AppendToOutput("%d", rd_index); |
| 3321 |
return strlen("IVInsIndex1"); |
| 3322 |
} else if (strncmp(format, "IVInsIndex2", |
| 3323 |
strlen("IVInsIndex2")) == 0) { |
| 3324 |
AppendToOutput("%d", rn_index); |
| 3325 |
return strlen("IVInsIndex2"); |
| 3326 |
} else { |
| 3327 |
VIXL_UNIMPLEMENTED(); |
| 3328 |
return 0; |
| 3329 |
} |
| 3330 |
} |
| 3331 |
VIXL_FALLTHROUGH(); |
| 3332 |
} |
| 3333 |
case 'L': { // IVLSLane[0123] - suffix indicates access size shift. |
| 3334 |
AppendToOutput("%d", instr->NEONLSIndex(format[8] - '0')); |
| 3335 |
return 9; |
| 3336 |
} |
| 3337 |
case 'M': { // Modified Immediate cases. |
| 3338 |
if (strncmp(format, |
| 3339 |
"IVMIImmFPSingle", |
| 3340 |
strlen("IVMIImmFPSingle")) == 0) { |
| 3341 |
AppendToOutput("#0x%" PRIx32 " (%.4f)", instr->ImmNEONabcdefgh(), |
| 3342 |
instr->ImmNEONFP32()); |
| 3343 |
return strlen("IVMIImmFPSingle"); |
| 3344 |
} else if (strncmp(format, |
| 3345 |
"IVMIImmFPDouble", |
| 3346 |
strlen("IVMIImmFPDouble")) == 0) { |
| 3347 |
AppendToOutput("#0x%" PRIx32 " (%.4f)", instr->ImmNEONabcdefgh(), |
| 3348 |
instr->ImmNEONFP64()); |
| 3349 |
return strlen("IVMIImmFPDouble"); |
| 3350 |
} else if (strncmp(format, "IVMIImm8", strlen("IVMIImm8")) == 0) { |
| 3351 |
uint64_t imm8 = instr->ImmNEONabcdefgh(); |
| 3352 |
AppendToOutput("#0x%" PRIx64, imm8); |
| 3353 |
return strlen("IVMIImm8"); |
| 3354 |
} else if (strncmp(format, "IVMIImm", strlen("IVMIImm")) == 0) { |
| 3355 |
uint64_t imm8 = instr->ImmNEONabcdefgh(); |
| 3356 |
uint64_t imm = 0; |
| 3357 |
for (int i = 0; i < 8; ++i) { |
| 3358 |
if (imm8 & (1ULL << i)) { |
| 3359 |
imm |= (UINT64_C(0xff) << (8 * i)); |
| 3360 |
} |
| 3361 |
} |
| 3362 |
AppendToOutput("#0x%" PRIx64, imm); |
| 3363 |
return strlen("IVMIImm"); |
| 3364 |
} else if (strncmp(format, "IVMIShiftAmt1", |
| 3365 |
strlen("IVMIShiftAmt1")) == 0) { |
| 3366 |
int cmode = instr->NEONCmode(); |
| 3367 |
int shift_amount = 8 * ((cmode >> 1) & 3); |
| 3368 |
AppendToOutput("#%d", shift_amount); |
| 3369 |
return strlen("IVMIShiftAmt1"); |
| 3370 |
} else if (strncmp(format, "IVMIShiftAmt2", |
| 3371 |
strlen("IVMIShiftAmt2")) == 0) { |
| 3372 |
int cmode = instr->NEONCmode(); |
| 3373 |
int shift_amount = 8 << (cmode & 1); |
| 3374 |
AppendToOutput("#%d", shift_amount); |
| 3375 |
return strlen("IVMIShiftAmt2"); |
| 3376 |
} else { |
| 3377 |
VIXL_UNIMPLEMENTED(); |
| 3378 |
return 0; |
| 3379 |
} |
| 3380 |
} |
| 3381 |
default: { |
| 3382 |
VIXL_UNIMPLEMENTED(); |
| 3383 |
return 0; |
| 3384 |
} |
| 3385 |
} |
| 3386 |
} |
| 3387 |
case 'X': { // IX - CLREX instruction. |
| 3388 |
AppendToOutput("#0x%" PRIx32, instr->CRm()); |
| 3389 |
return 2; |
| 3390 |
} |
| 3391 |
default: { |
| 3392 |
VIXL_UNIMPLEMENTED(); |
| 3393 |
return 0; |
| 3394 |
} |
| 3395 |
} |
| 3396 |
} |
| 3397 |
|
| 3398 |
|
| 3399 |
int Disassembler::SubstituteBitfieldImmediateField(const Instruction* instr, |
| 3400 |
const char* format) { |
| 3401 |
VIXL_ASSERT((format[0] == 'I') && (format[1] == 'B')); |
| 3402 |
unsigned r = instr->ImmR(); |
| 3403 |
unsigned s = instr->ImmS(); |
| 3404 |
|
| 3405 |
switch (format[2]) { |
| 3406 |
case 'r': { // IBr. |
| 3407 |
AppendToOutput("#%d", r); |
| 3408 |
return 3; |
| 3409 |
} |
| 3410 |
case 's': { // IBs+1 or IBs-r+1. |
| 3411 |
if (format[3] == '+') { |
| 3412 |
AppendToOutput("#%d", s + 1); |
| 3413 |
return 5; |
| 3414 |
} else { |
| 3415 |
VIXL_ASSERT(format[3] == '-'); |
| 3416 |
AppendToOutput("#%d", s - r + 1); |
| 3417 |
return 7; |
| 3418 |
} |
| 3419 |
} |
| 3420 |
case 'Z': { // IBZ-r. |
| 3421 |
VIXL_ASSERT((format[3] == '-') && (format[4] == 'r')); |
| 3422 |
unsigned reg_size = (instr->SixtyFourBits() == 1) ? kXRegSize : kWRegSize; |
| 3423 |
AppendToOutput("#%d", reg_size - r); |
| 3424 |
return 5; |
| 3425 |
} |
| 3426 |
default: { |
| 3427 |
VIXL_UNREACHABLE(); |
| 3428 |
return 0; |
| 3429 |
} |
| 3430 |
} |
| 3431 |
} |
| 3432 |
|
| 3433 |
|
| 3434 |
int Disassembler::SubstituteLiteralField(const Instruction* instr, |
| 3435 |
const char* format) { |
| 3436 |
VIXL_ASSERT(strncmp(format, "LValue", 6) == 0); |
| 3437 |
USE(format); |
| 3438 |
|
| 3439 |
const void * address = instr->LiteralAddress<const void *>(); |
| 3440 |
switch (instr->Mask(LoadLiteralMask)) { |
| 3441 |
case LDR_w_lit: |
| 3442 |
case LDR_x_lit: |
| 3443 |
case LDRSW_x_lit: |
| 3444 |
case LDR_s_lit: |
| 3445 |
case LDR_d_lit: |
| 3446 |
case LDR_q_lit: |
| 3447 |
AppendCodeRelativeDataAddressToOutput(instr, address); |
| 3448 |
break; |
| 3449 |
case PRFM_lit: { |
| 3450 |
// Use the prefetch hint to decide how to print the address. |
| 3451 |
switch (instr->PrefetchHint()) { |
| 3452 |
case 0x0: // PLD: prefetch for load. |
| 3453 |
case 0x2: // PST: prepare for store. |
| 3454 |
AppendCodeRelativeDataAddressToOutput(instr, address); |
| 3455 |
break; |
| 3456 |
case 0x1: // PLI: preload instructions. |
| 3457 |
AppendCodeRelativeCodeAddressToOutput(instr, address); |
| 3458 |
break; |
| 3459 |
case 0x3: // Unallocated hint. |
| 3460 |
AppendCodeRelativeAddressToOutput(instr, address); |
| 3461 |
break; |
| 3462 |
} |
| 3463 |
break; |
| 3464 |
} |
| 3465 |
default: |
| 3466 |
VIXL_UNREACHABLE(); |
| 3467 |
} |
| 3468 |
|
| 3469 |
return 6; |
| 3470 |
} |
| 3471 |
|
| 3472 |
|
| 3473 |
int Disassembler::SubstituteShiftField(const Instruction* instr, |
| 3474 |
const char* format) { |
| 3475 |
VIXL_ASSERT(format[0] == 'N'); |
| 3476 |
VIXL_ASSERT(instr->ShiftDP() <= 0x3); |
| 3477 |
|
| 3478 |
switch (format[1]) { |
| 3479 |
case 'D': { // HDP. |
| 3480 |
VIXL_ASSERT(instr->ShiftDP() != ROR); |
| 3481 |
VIXL_FALLTHROUGH(); |
| 3482 |
} |
| 3483 |
case 'L': { // HLo. |
| 3484 |
if (instr->ImmDPShift() != 0) { |
| 3485 |
const char* shift_type[] = {"lsl", "lsr", "asr", "ror"}; |
| 3486 |
AppendToOutput(", %s #%" PRId32, shift_type[instr->ShiftDP()], |
| 3487 |
instr->ImmDPShift()); |
| 3488 |
} |
| 3489 |
return 3; |
| 3490 |
} |
| 3491 |
default: |
| 3492 |
VIXL_UNIMPLEMENTED(); |
| 3493 |
return 0; |
| 3494 |
} |
| 3495 |
} |
| 3496 |
|
| 3497 |
|
| 3498 |
int Disassembler::SubstituteConditionField(const Instruction* instr, |
| 3499 |
const char* format) { |
| 3500 |
VIXL_ASSERT(format[0] == 'C'); |
| 3501 |
const char* condition_code[] = { "eq", "ne", "hs", "lo", |
| 3502 |
"mi", "pl", "vs", "vc", |
| 3503 |
"hi", "ls", "ge", "lt", |
| 3504 |
"gt", "le", "al", "nv" }; |
| 3505 |
int cond; |
| 3506 |
switch (format[1]) { |
| 3507 |
case 'B': cond = instr->ConditionBranch(); break; |
| 3508 |
case 'I': { |
| 3509 |
cond = InvertCondition(static_cast<Condition>(instr->Condition())); |
| 3510 |
break; |
| 3511 |
} |
| 3512 |
default: cond = instr->Condition(); |
| 3513 |
} |
| 3514 |
AppendToOutput("%s", condition_code[cond]); |
| 3515 |
return 4; |
| 3516 |
} |
| 3517 |
|
| 3518 |
|
| 3519 |
int Disassembler::SubstitutePCRelAddressField(const Instruction* instr, |
| 3520 |
const char* format) { |
| 3521 |
VIXL_ASSERT((strcmp(format, "AddrPCRelByte") == 0) || // Used by `adr`. |
| 3522 |
(strcmp(format, "AddrPCRelPage") == 0)); // Used by `adrp`. |
| 3523 |
|
| 3524 |
int64_t offset = instr->ImmPCRel(); |
| 3525 |
|
| 3526 |
// Compute the target address based on the effective address (after applying |
| 3527 |
// code_address_offset). This is required for correct behaviour of adrp. |
| 3528 |
const Instruction* base = instr + code_address_offset(); |
| 3529 |
if (format[9] == 'P') { |
| 3530 |
offset *= kPageSize; |
| 3531 |
base = AlignDown(base, kPageSize); |
| 3532 |
} |
| 3533 |
// Strip code_address_offset before printing, so we can use the |
| 3534 |
// semantically-correct AppendCodeRelativeAddressToOutput. |
| 3535 |
const void* target = |
| 3536 |
reinterpret_cast<const void*>(base + offset - code_address_offset()); |
| 3537 |
|
| 3538 |
AppendPCRelativeOffsetToOutput(instr, offset); |
| 3539 |
AppendToOutput(" "); |
| 3540 |
AppendCodeRelativeAddressToOutput(instr, target); |
| 3541 |
return 13; |
| 3542 |
} |
| 3543 |
|
| 3544 |
|
| 3545 |
int Disassembler::SubstituteBranchTargetField(const Instruction* instr, |
| 3546 |
const char* format) { |
| 3547 |
VIXL_ASSERT(strncmp(format, "TImm", 4) == 0); |
| 3548 |
|
| 3549 |
int64_t offset = 0; |
| 3550 |
switch (format[5]) { |
| 3551 |
// BImmUncn - unconditional branch immediate. |
| 3552 |
case 'n': offset = instr->ImmUncondBranch(); break; |
| 3553 |
// BImmCond - conditional branch immediate. |
| 3554 |
case 'o': offset = instr->ImmCondBranch(); break; |
| 3555 |
// BImmCmpa - compare and branch immediate. |
| 3556 |
case 'm': offset = instr->ImmCmpBranch(); break; |
| 3557 |
// BImmTest - test and branch immediate. |
| 3558 |
case 'e': offset = instr->ImmTestBranch(); break; |
| 3559 |
default: VIXL_UNIMPLEMENTED(); |
| 3560 |
} |
| 3561 |
offset <<= kInstructionSizeLog2; |
| 3562 |
const void* target_address = reinterpret_cast<const void*>(instr + offset); |
| 3563 |
VIXL_STATIC_ASSERT(sizeof(*instr) == 1); |
| 3564 |
|
| 3565 |
AppendPCRelativeOffsetToOutput(instr, offset); |
| 3566 |
AppendToOutput(" "); |
| 3567 |
AppendCodeRelativeCodeAddressToOutput(instr, target_address); |
| 3568 |
|
| 3569 |
return 8; |
| 3570 |
} |
| 3571 |
|
| 3572 |
|
| 3573 |
int Disassembler::SubstituteExtendField(const Instruction* instr, |
| 3574 |
const char* format) { |
| 3575 |
VIXL_ASSERT(strncmp(format, "Ext", 3) == 0); |
| 3576 |
VIXL_ASSERT(instr->ExtendMode() <= 7); |
| 3577 |
USE(format); |
| 3578 |
|
| 3579 |
const char* extend_mode[] = { "uxtb", "uxth", "uxtw", "uxtx", |
| 3580 |
"sxtb", "sxth", "sxtw", "sxtx" }; |
| 3581 |
|
| 3582 |
// If rd or rn is SP, uxtw on 32-bit registers and uxtx on 64-bit |
| 3583 |
// registers becomes lsl. |
| 3584 |
if (((instr->Rd() == kZeroRegCode) || (instr->Rn() == kZeroRegCode)) && |
| 3585 |
(((instr->ExtendMode() == UXTW) && (instr->SixtyFourBits() == 0)) || |
| 3586 |
(instr->ExtendMode() == UXTX))) { |
| 3587 |
if (instr->ImmExtendShift() > 0) { |
| 3588 |
AppendToOutput(", lsl #%" PRId32, instr->ImmExtendShift()); |
| 3589 |
} |
| 3590 |
} else { |
| 3591 |
AppendToOutput(", %s", extend_mode[instr->ExtendMode()]); |
| 3592 |
if (instr->ImmExtendShift() > 0) { |
| 3593 |
AppendToOutput(" #%" PRId32, instr->ImmExtendShift()); |
| 3594 |
} |
| 3595 |
} |
| 3596 |
return 3; |
| 3597 |
} |
| 3598 |
|
| 3599 |
|
| 3600 |
int Disassembler::SubstituteLSRegOffsetField(const Instruction* instr, |
| 3601 |
const char* format) { |
| 3602 |
VIXL_ASSERT(strncmp(format, "Offsetreg", 9) == 0); |
| 3603 |
const char* extend_mode[] = { "undefined", "undefined", "uxtw", "lsl", |
| 3604 |
"undefined", "undefined", "sxtw", "sxtx" }; |
| 3605 |
USE(format); |
| 3606 |
|
| 3607 |
unsigned shift = instr->ImmShiftLS(); |
| 3608 |
Extend ext = static_cast<Extend>(instr->ExtendMode()); |
| 3609 |
char reg_type = ((ext == UXTW) || (ext == SXTW)) ? 'w' : 'x'; |
| 3610 |
|
| 3611 |
unsigned rm = instr->Rm(); |
| 3612 |
if (rm == kZeroRegCode) { |
| 3613 |
AppendToOutput("%czr", reg_type); |
| 3614 |
} else { |
| 3615 |
AppendToOutput("%c%d", reg_type, rm); |
| 3616 |
} |
| 3617 |
|
| 3618 |
// Extend mode UXTX is an alias for shift mode LSL here. |
| 3619 |
if (!((ext == UXTX) && (shift == 0))) { |
| 3620 |
AppendToOutput(", %s", extend_mode[ext]); |
| 3621 |
if (shift != 0) { |
| 3622 |
AppendToOutput(" #%d", instr->SizeLS()); |
| 3623 |
} |
| 3624 |
} |
| 3625 |
return 9; |
| 3626 |
} |
| 3627 |
|
| 3628 |
|
| 3629 |
int Disassembler::SubstitutePrefetchField(const Instruction* instr, |
| 3630 |
const char* format) { |
| 3631 |
VIXL_ASSERT(format[0] == 'P'); |
| 3632 |
USE(format); |
| 3633 |
|
| 3634 |
static const char* hints[] = {"ld", "li", "st"}; |
| 3635 |
static const char* stream_options[] = {"keep", "strm"}; |
| 3636 |
|
| 3637 |
unsigned hint = instr->PrefetchHint(); |
| 3638 |
unsigned target = instr->PrefetchTarget() + 1; |
| 3639 |
unsigned stream = instr->PrefetchStream(); |
| 3640 |
|
| 3641 |
if ((hint >= (sizeof(hints) / sizeof(hints[0]))) || (target > 3)) { |
| 3642 |
// Unallocated prefetch operations. |
| 3643 |
int prefetch_mode = instr->ImmPrefetchOperation(); |
| 3644 |
AppendToOutput("#0b%c%c%c%c%c", |
| 3645 |
(prefetch_mode & (1 << 4)) ? '1' : '0', |
| 3646 |
(prefetch_mode & (1 << 3)) ? '1' : '0', |
| 3647 |
(prefetch_mode & (1 << 2)) ? '1' : '0', |
| 3648 |
(prefetch_mode & (1 << 1)) ? '1' : '0', |
| 3649 |
(prefetch_mode & (1 << 0)) ? '1' : '0'); |
| 3650 |
} else { |
| 3651 |
VIXL_ASSERT(stream < (sizeof(stream_options) / sizeof(stream_options[0]))); |
| 3652 |
AppendToOutput("p%sl%d%s", hints[hint], target, stream_options[stream]); |
| 3653 |
} |
| 3654 |
return 6; |
| 3655 |
} |
| 3656 |
|
| 3657 |
int Disassembler::SubstituteBarrierField(const Instruction* instr, |
| 3658 |
const char* format) { |
| 3659 |
VIXL_ASSERT(format[0] == 'M'); |
| 3660 |
USE(format); |
| 3661 |
|
| 3662 |
static const char* options[4][4] = { |
| 3663 |
{ "sy (0b0000)", "oshld", "oshst", "osh" }, |
| 3664 |
{ "sy (0b0100)", "nshld", "nshst", "nsh" }, |
| 3665 |
{ "sy (0b1000)", "ishld", "ishst", "ish" }, |
| 3666 |
{ "sy (0b1100)", "ld", "st", "sy" } |
| 3667 |
}; |
| 3668 |
int domain = instr->ImmBarrierDomain(); |
| 3669 |
int type = instr->ImmBarrierType(); |
| 3670 |
|
| 3671 |
AppendToOutput("%s", options[domain][type]); |
| 3672 |
return 1; |
| 3673 |
} |
| 3674 |
|
| 3675 |
int Disassembler::SubstituteSysOpField(const Instruction* instr, |
| 3676 |
const char* format) { |
| 3677 |
VIXL_ASSERT(format[0] == 'G'); |
| 3678 |
int op = -1; |
| 3679 |
switch (format[1]) { |
| 3680 |
case '1': op = instr->SysOp1(); break; |
| 3681 |
case '2': op = instr->SysOp2(); break; |
| 3682 |
default: |
| 3683 |
VIXL_UNREACHABLE(); |
| 3684 |
} |
| 3685 |
AppendToOutput("#%d", op); |
| 3686 |
return 2; |
| 3687 |
} |
| 3688 |
|
| 3689 |
int Disassembler::SubstituteCrField(const Instruction* instr, |
| 3690 |
const char* format) { |
| 3691 |
VIXL_ASSERT(format[0] == 'K'); |
| 3692 |
int cr = -1; |
| 3693 |
switch (format[1]) { |
| 3694 |
case 'n': cr = instr->CRn(); break; |
| 3695 |
case 'm': cr = instr->CRm(); break; |
| 3696 |
default: |
| 3697 |
VIXL_UNREACHABLE(); |
| 3698 |
} |
| 3699 |
AppendToOutput("C%d", cr); |
| 3700 |
return 2; |
| 3701 |
} |
| 3702 |
|
| 3703 |
void Disassembler::ResetOutput() { |
| 3704 |
buffer_pos_ = 0; |
| 3705 |
buffer_[buffer_pos_] = 0; |
| 3706 |
} |
| 3707 |
|
| 3708 |
|
| 3709 |
void Disassembler::AppendToOutput(const char* format, ...) { |
| 3710 |
va_list args; |
| 3711 |
va_start(args, format); |
| 3712 |
buffer_pos_ += vsnprintf(&buffer_[buffer_pos_], buffer_size_ - buffer_pos_, |
| 3713 |
format, args); |
| 3714 |
va_end(args); |
| 3715 |
} |
| 3716 |
|
| 3717 |
|
| 3718 |
void PrintDisassembler::ProcessOutput(const Instruction* instr) { |
| 3719 |
fprintf(stream_, "0x%016" PRIx64 " %08" PRIx32 "\t\t%s\n", |
| 3720 |
reinterpret_cast<uint64_t>(instr), |
| 3721 |
instr->InstructionBits(), |
| 3722 |
GetOutput()); |
| 3723 |
} |
| 3724 |
|
| 3725 |
void DisassembleInstruction(char* buffer, size_t bufsize, const Instruction* instr) |
| 3726 |
{ |
| 3727 |
vixl::Disassembler disasm(buffer, bufsize-1); |
| 3728 |
vixl::Decoder decoder; |
| 3729 |
decoder.AppendVisitor(&disasm); |
| 3730 |
decoder.Decode(instr); |
| 3731 |
buffer[bufsize-1] = 0; // Just to be safe |
| 3732 |
} |
| 3733 |
|
| 3734 |
char* GdbDisassembleInstruction(const Instruction* instr) |
| 3735 |
{ |
| 3736 |
static char buffer[1024]; |
| 3737 |
DisassembleInstruction(buffer, sizeof(buffer), instr); |
| 3738 |
return buffer; |
| 3739 |
} |
| 3740 |
|
| 3741 |
} // namespace vixl |