OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 Format(instr, "unallocated", "(LogicalImmediate)"); | 248 Format(instr, "unallocated", "(LogicalImmediate)"); |
249 return; | 249 return; |
250 } | 250 } |
251 | 251 |
252 switch (instr->Mask(LogicalImmediateMask)) { | 252 switch (instr->Mask(LogicalImmediateMask)) { |
253 case AND_w_imm: | 253 case AND_w_imm: |
254 case AND_x_imm: mnemonic = "and"; break; | 254 case AND_x_imm: mnemonic = "and"; break; |
255 case ORR_w_imm: | 255 case ORR_w_imm: |
256 case ORR_x_imm: { | 256 case ORR_x_imm: { |
257 mnemonic = "orr"; | 257 mnemonic = "orr"; |
258 unsigned reg_size = (instr->SixtyFourBits() == 1) ? kXRegSize | 258 unsigned reg_size = (instr->SixtyFourBits() == 1) ? kXRegSizeInBits |
259 : kWRegSize; | 259 : kWRegSizeInBits; |
260 if (rn_is_zr && !IsMovzMovnImm(reg_size, instr->ImmLogical())) { | 260 if (rn_is_zr && !IsMovzMovnImm(reg_size, instr->ImmLogical())) { |
261 mnemonic = "mov"; | 261 mnemonic = "mov"; |
262 form = "'Rds, 'ITri"; | 262 form = "'Rds, 'ITri"; |
263 } | 263 } |
264 break; | 264 break; |
265 } | 265 } |
266 case EOR_w_imm: | 266 case EOR_w_imm: |
267 case EOR_x_imm: mnemonic = "eor"; break; | 267 case EOR_x_imm: mnemonic = "eor"; break; |
268 case ANDS_w_imm: | 268 case ANDS_w_imm: |
269 case ANDS_x_imm: { | 269 case ANDS_x_imm: { |
270 mnemonic = "ands"; | 270 mnemonic = "ands"; |
271 if (rd_is_zr) { | 271 if (rd_is_zr) { |
272 mnemonic = "tst"; | 272 mnemonic = "tst"; |
273 form = "'Rn, 'ITri"; | 273 form = "'Rn, 'ITri"; |
274 } | 274 } |
275 break; | 275 break; |
276 } | 276 } |
277 default: UNREACHABLE(); | 277 default: UNREACHABLE(); |
278 } | 278 } |
279 Format(instr, mnemonic, form); | 279 Format(instr, mnemonic, form); |
280 } | 280 } |
281 | 281 |
282 | 282 |
283 bool Disassembler::IsMovzMovnImm(unsigned reg_size, uint64_t value) { | 283 bool Disassembler::IsMovzMovnImm(unsigned reg_size, uint64_t value) { |
284 ASSERT((reg_size == kXRegSize) || | 284 ASSERT((reg_size == kXRegSizeInBits) || |
285 ((reg_size == kWRegSize) && (value <= 0xffffffff))); | 285 ((reg_size == kWRegSizeInBits) && (value <= 0xffffffff))); |
286 | 286 |
287 // Test for movz: 16-bits set at positions 0, 16, 32 or 48. | 287 // Test for movz: 16-bits set at positions 0, 16, 32 or 48. |
288 if (((value & 0xffffffffffff0000UL) == 0UL) || | 288 if (((value & 0xffffffffffff0000UL) == 0UL) || |
289 ((value & 0xffffffff0000ffffUL) == 0UL) || | 289 ((value & 0xffffffff0000ffffUL) == 0UL) || |
290 ((value & 0xffff0000ffffffffUL) == 0UL) || | 290 ((value & 0xffff0000ffffffffUL) == 0UL) || |
291 ((value & 0x0000ffffffffffffUL) == 0UL)) { | 291 ((value & 0x0000ffffffffffffUL) == 0UL)) { |
292 return true; | 292 return true; |
293 } | 293 } |
294 | 294 |
295 // Test for movn: NOT(16-bits set at positions 0, 16, 32 or 48). | 295 // Test for movn: NOT(16-bits set at positions 0, 16, 32 or 48). |
296 if ((reg_size == kXRegSize) && | 296 if ((reg_size == kXRegSizeInBits) && |
297 (((value & 0xffffffffffff0000UL) == 0xffffffffffff0000UL) || | 297 (((value & 0xffffffffffff0000UL) == 0xffffffffffff0000UL) || |
298 ((value & 0xffffffff0000ffffUL) == 0xffffffff0000ffffUL) || | 298 ((value & 0xffffffff0000ffffUL) == 0xffffffff0000ffffUL) || |
299 ((value & 0xffff0000ffffffffUL) == 0xffff0000ffffffffUL) || | 299 ((value & 0xffff0000ffffffffUL) == 0xffff0000ffffffffUL) || |
300 ((value & 0x0000ffffffffffffUL) == 0x0000ffffffffffffUL))) { | 300 ((value & 0x0000ffffffffffffUL) == 0x0000ffffffffffffUL))) { |
301 return true; | 301 return true; |
302 } | 302 } |
303 if ((reg_size == kWRegSize) && | 303 if ((reg_size == kWRegSizeInBits) && |
304 (((value & 0xffff0000) == 0xffff0000) || | 304 (((value & 0xffff0000) == 0xffff0000) || |
305 ((value & 0x0000ffff) == 0x0000ffff))) { | 305 ((value & 0x0000ffff) == 0x0000ffff))) { |
306 return true; | 306 return true; |
307 } | 307 } |
308 return false; | 308 return false; |
309 } | 309 } |
310 | 310 |
311 | 311 |
312 void Disassembler::VisitLogicalShifted(Instruction* instr) { | 312 void Disassembler::VisitLogicalShifted(Instruction* instr) { |
313 bool rd_is_zr = RdIsZROrSP(instr); | 313 bool rd_is_zr = RdIsZROrSP(instr); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 default: UNREACHABLE(); | 440 default: UNREACHABLE(); |
441 } | 441 } |
442 Format(instr, mnemonic, form); | 442 Format(instr, mnemonic, form); |
443 } | 443 } |
444 | 444 |
445 | 445 |
446 void Disassembler::VisitBitfield(Instruction* instr) { | 446 void Disassembler::VisitBitfield(Instruction* instr) { |
447 unsigned s = instr->ImmS(); | 447 unsigned s = instr->ImmS(); |
448 unsigned r = instr->ImmR(); | 448 unsigned r = instr->ImmR(); |
449 unsigned rd_size_minus_1 = | 449 unsigned rd_size_minus_1 = |
450 ((instr->SixtyFourBits() == 1) ? kXRegSize : kWRegSize) - 1; | 450 ((instr->SixtyFourBits() == 1) ? kXRegSizeInBits : kWRegSizeInBits) - 1; |
451 const char *mnemonic = ""; | 451 const char *mnemonic = ""; |
452 const char *form = ""; | 452 const char *form = ""; |
453 const char *form_shift_right = "'Rd, 'Rn, 'IBr"; | 453 const char *form_shift_right = "'Rd, 'Rn, 'IBr"; |
454 const char *form_extend = "'Rd, 'Wn"; | 454 const char *form_extend = "'Rd, 'Wn"; |
455 const char *form_bfiz = "'Rd, 'Rn, 'IBZ-r, 'IBs+1"; | 455 const char *form_bfiz = "'Rd, 'Rn, 'IBZ-r, 'IBs+1"; |
456 const char *form_bfx = "'Rd, 'Rn, 'IBr, 'IBs-r+1"; | 456 const char *form_bfx = "'Rd, 'Rn, 'IBr, 'IBs-r+1"; |
457 const char *form_lsl = "'Rd, 'Rn, 'IBZ-r"; | 457 const char *form_lsl = "'Rd, 'Rn, 'IBZ-r"; |
458 | 458 |
459 switch (instr->Mask(BitfieldMask)) { | 459 switch (instr->Mask(BitfieldMask)) { |
460 case SBFM_w: | 460 case SBFM_w: |
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1511 AppendToOutput("#%d", s + 1); | 1511 AppendToOutput("#%d", s + 1); |
1512 return 5; | 1512 return 5; |
1513 } else { | 1513 } else { |
1514 ASSERT(format[3] == '-'); | 1514 ASSERT(format[3] == '-'); |
1515 AppendToOutput("#%d", s - r + 1); | 1515 AppendToOutput("#%d", s - r + 1); |
1516 return 7; | 1516 return 7; |
1517 } | 1517 } |
1518 } | 1518 } |
1519 case 'Z': { // IBZ-r. | 1519 case 'Z': { // IBZ-r. |
1520 ASSERT((format[3] == '-') && (format[4] == 'r')); | 1520 ASSERT((format[3] == '-') && (format[4] == 'r')); |
1521 unsigned reg_size = (instr->SixtyFourBits() == 1) ? kXRegSize : kWRegSize; | 1521 unsigned reg_size = (instr->SixtyFourBits() == 1) ? kXRegSizeInBits |
| 1522 : kWRegSizeInBits; |
1522 AppendToOutput("#%d", reg_size - r); | 1523 AppendToOutput("#%d", reg_size - r); |
1523 return 5; | 1524 return 5; |
1524 } | 1525 } |
1525 default: { | 1526 default: { |
1526 UNREACHABLE(); | 1527 UNREACHABLE(); |
1527 return 0; | 1528 return 0; |
1528 } | 1529 } |
1529 } | 1530 } |
1530 } | 1531 } |
1531 | 1532 |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1846 decoder.AppendVisitor(&disasm); | 1847 decoder.AppendVisitor(&disasm); |
1847 | 1848 |
1848 for (byte* pc = start; pc < end; pc += v8::internal::kInstructionSize) { | 1849 for (byte* pc = start; pc < end; pc += v8::internal::kInstructionSize) { |
1849 decoder.Decode(reinterpret_cast<v8::internal::Instruction*>(pc)); | 1850 decoder.Decode(reinterpret_cast<v8::internal::Instruction*>(pc)); |
1850 } | 1851 } |
1851 } | 1852 } |
1852 | 1853 |
1853 } // namespace disasm | 1854 } // namespace disasm |
1854 | 1855 |
1855 #endif // V8_TARGET_ARCH_A64 | 1856 #endif // V8_TARGET_ARCH_A64 |
OLD | NEW |