| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 // Returns the length of the disassembled machine instruction in bytes. | 90 // Returns the length of the disassembled machine instruction in bytes. |
| 91 int InstructionDecode(byte_* instruction); | 91 int InstructionDecode(byte_* instruction); |
| 92 | 92 |
| 93 private: | 93 private: |
| 94 // Bottleneck functions to print into the out_buffer. | 94 // Bottleneck functions to print into the out_buffer. |
| 95 void PrintChar(const char ch); | 95 void PrintChar(const char ch); |
| 96 void Print(const char* str); | 96 void Print(const char* str); |
| 97 | 97 |
| 98 // Printing of common values. | 98 // Printing of common values. |
| 99 void PrintRegister(int reg); | 99 void PrintRegister(int reg); |
| 100 void PrintCRegister(int creg); | 100 void PrintFPURegister(int freg); |
| 101 void PrintRs(Instruction* instr); | 101 void PrintRs(Instruction* instr); |
| 102 void PrintRt(Instruction* instr); | 102 void PrintRt(Instruction* instr); |
| 103 void PrintRd(Instruction* instr); | 103 void PrintRd(Instruction* instr); |
| 104 void PrintFs(Instruction* instr); | 104 void PrintFs(Instruction* instr); |
| 105 void PrintFt(Instruction* instr); | 105 void PrintFt(Instruction* instr); |
| 106 void PrintFd(Instruction* instr); | 106 void PrintFd(Instruction* instr); |
| 107 void PrintSa(Instruction* instr); | 107 void PrintSa(Instruction* instr); |
| 108 void PrintSd(Instruction* instr); |
| 109 void PrintBc(Instruction* instr); |
| 110 void PrintCc(Instruction* instr); |
| 108 void PrintFunction(Instruction* instr); | 111 void PrintFunction(Instruction* instr); |
| 109 void PrintSecondaryField(Instruction* instr); | 112 void PrintSecondaryField(Instruction* instr); |
| 110 void PrintUImm16(Instruction* instr); | 113 void PrintUImm16(Instruction* instr); |
| 111 void PrintSImm16(Instruction* instr); | 114 void PrintSImm16(Instruction* instr); |
| 112 void PrintXImm16(Instruction* instr); | 115 void PrintXImm16(Instruction* instr); |
| 113 void PrintImm26(Instruction* instr); | 116 void PrintImm26(Instruction* instr); |
| 114 void PrintCode(Instruction* instr); // For break and trap instructions. | 117 void PrintCode(Instruction* instr); // For break and trap instructions. |
| 115 // Printing of instruction name. | 118 // Printing of instruction name. |
| 116 void PrintInstructionName(Instruction* instr); | 119 void PrintInstructionName(Instruction* instr); |
| 117 | 120 |
| 118 // Handle formatting of instructions and their options. | 121 // Handle formatting of instructions and their options. |
| 119 int FormatRegister(Instruction* instr, const char* option); | 122 int FormatRegister(Instruction* instr, const char* option); |
| 120 int FormatCRegister(Instruction* instr, const char* option); | 123 int FormatFPURegister(Instruction* instr, const char* option); |
| 121 int FormatOption(Instruction* instr, const char* option); | 124 int FormatOption(Instruction* instr, const char* option); |
| 122 void Format(Instruction* instr, const char* format); | 125 void Format(Instruction* instr, const char* format); |
| 123 void Unknown(Instruction* instr); | 126 void Unknown(Instruction* instr); |
| 124 | 127 |
| 125 // Each of these functions decodes one particular instruction type. | 128 // Each of these functions decodes one particular instruction type. |
| 126 void DecodeTypeRegister(Instruction* instr); | 129 void DecodeTypeRegister(Instruction* instr); |
| 127 void DecodeTypeImmediate(Instruction* instr); | 130 void DecodeTypeImmediate(Instruction* instr); |
| 128 void DecodeTypeJump(Instruction* instr); | 131 void DecodeTypeJump(Instruction* instr); |
| 129 | 132 |
| 130 const disasm::NameConverter& converter_; | 133 const disasm::NameConverter& converter_; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 PrintRegister(reg); | 177 PrintRegister(reg); |
| 175 } | 178 } |
| 176 | 179 |
| 177 | 180 |
| 178 void Decoder::PrintRd(Instruction* instr) { | 181 void Decoder::PrintRd(Instruction* instr) { |
| 179 int reg = instr->RdField(); | 182 int reg = instr->RdField(); |
| 180 PrintRegister(reg); | 183 PrintRegister(reg); |
| 181 } | 184 } |
| 182 | 185 |
| 183 | 186 |
| 184 // Print the Cregister name according to the active name converter. | 187 // Print the FPUregister name according to the active name converter. |
| 185 void Decoder::PrintCRegister(int creg) { | 188 void Decoder::PrintFPURegister(int freg) { |
| 186 Print(converter_.NameOfXMMRegister(creg)); | 189 Print(converter_.NameOfXMMRegister(freg)); |
| 187 } | 190 } |
| 188 | 191 |
| 189 | 192 |
| 190 void Decoder::PrintFs(Instruction* instr) { | 193 void Decoder::PrintFs(Instruction* instr) { |
| 191 int creg = instr->RsField(); | 194 int freg = instr->RsField(); |
| 192 PrintCRegister(creg); | 195 PrintFPURegister(freg); |
| 193 } | 196 } |
| 194 | 197 |
| 195 | 198 |
| 196 void Decoder::PrintFt(Instruction* instr) { | 199 void Decoder::PrintFt(Instruction* instr) { |
| 197 int creg = instr->RtField(); | 200 int freg = instr->RtField(); |
| 198 PrintCRegister(creg); | 201 PrintFPURegister(freg); |
| 199 } | 202 } |
| 200 | 203 |
| 201 | 204 |
| 202 void Decoder::PrintFd(Instruction* instr) { | 205 void Decoder::PrintFd(Instruction* instr) { |
| 203 int creg = instr->RdField(); | 206 int freg = instr->RdField(); |
| 204 PrintCRegister(creg); | 207 PrintFPURegister(freg); |
| 205 } | 208 } |
| 206 | 209 |
| 207 | 210 |
| 208 // Print the integer value of the sa field. | 211 // Print the integer value of the sa field. |
| 209 void Decoder::PrintSa(Instruction* instr) { | 212 void Decoder::PrintSa(Instruction* instr) { |
| 210 int sa = instr->SaField(); | 213 int sa = instr->SaField(); |
| 211 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, | 214 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, |
| 212 "%d", sa); | 215 "%d", sa); |
| 213 } | 216 } |
| 214 | 217 |
| 215 | 218 |
| 219 // Print the integer value of the rd field, (when it is not used as reg). |
| 220 void Decoder::PrintSd(Instruction* instr) { |
| 221 int sd = instr->RdField(); |
| 222 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, |
| 223 "%d", sd); |
| 224 } |
| 225 |
| 226 |
| 227 // Print the integer value of the cc field for the bc1t/f instructions. |
| 228 void Decoder::PrintBc(Instruction* instr) { |
| 229 int cc = instr->FBccField(); |
| 230 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, |
| 231 "%d", cc); |
| 232 } |
| 233 |
| 234 |
| 235 // Print the integer value of the cc field for the FP compare instructions. |
| 236 void Decoder::PrintCc(Instruction* instr) { |
| 237 int cc = instr->FCccField(); |
| 238 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, |
| 239 "cc(%d)", cc); |
| 240 } |
| 241 |
| 242 |
| 216 // Print 16-bit unsigned immediate value. | 243 // Print 16-bit unsigned immediate value. |
| 217 void Decoder::PrintUImm16(Instruction* instr) { | 244 void Decoder::PrintUImm16(Instruction* instr) { |
| 218 int32_t imm = instr->Imm16Field(); | 245 int32_t imm = instr->Imm16Field(); |
| 219 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, | 246 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, |
| 220 "%u", imm); | 247 "%u", imm); |
| 221 } | 248 } |
| 222 | 249 |
| 223 | 250 |
| 224 // Print 16-bit signed immediate value. | 251 // Print 16-bit signed immediate value. |
| 225 void Decoder::PrintSImm16(Instruction* instr) { | 252 void Decoder::PrintSImm16(Instruction* instr) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 246 | 273 |
| 247 | 274 |
| 248 // Print 26-bit immediate value. | 275 // Print 26-bit immediate value. |
| 249 void Decoder::PrintCode(Instruction* instr) { | 276 void Decoder::PrintCode(Instruction* instr) { |
| 250 if (instr->OpcodeFieldRaw() != SPECIAL) | 277 if (instr->OpcodeFieldRaw() != SPECIAL) |
| 251 return; // Not a break or trap instruction. | 278 return; // Not a break or trap instruction. |
| 252 switch (instr->FunctionFieldRaw()) { | 279 switch (instr->FunctionFieldRaw()) { |
| 253 case BREAK: { | 280 case BREAK: { |
| 254 int32_t code = instr->Bits(25, 6); | 281 int32_t code = instr->Bits(25, 6); |
| 255 out_buffer_pos_ += | 282 out_buffer_pos_ += |
| 256 v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, "0x%05x", code); | 283 v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, "0x%05x (%d)", |
| 284 code, code); |
| 257 break; | 285 break; |
| 258 } | 286 } |
| 259 case TGE: | 287 case TGE: |
| 260 case TGEU: | 288 case TGEU: |
| 261 case TLT: | 289 case TLT: |
| 262 case TLTU: | 290 case TLTU: |
| 263 case TEQ: | 291 case TEQ: |
| 264 case TNE: { | 292 case TNE: { |
| 265 int32_t code = instr->Bits(15, 6); | 293 int32_t code = instr->Bits(15, 6); |
| 266 out_buffer_pos_ += | 294 out_buffer_pos_ += |
| (...skipping 26 matching lines...) Expand all Loading... |
| 293 } else if (format[1] == 'd') { // 'rd: rd register | 321 } else if (format[1] == 'd') { // 'rd: rd register |
| 294 int reg = instr->RdField(); | 322 int reg = instr->RdField(); |
| 295 PrintRegister(reg); | 323 PrintRegister(reg); |
| 296 return 2; | 324 return 2; |
| 297 } | 325 } |
| 298 UNREACHABLE(); | 326 UNREACHABLE(); |
| 299 return -1; | 327 return -1; |
| 300 } | 328 } |
| 301 | 329 |
| 302 | 330 |
| 303 // Handle all Cregister based formatting in this function to reduce the | 331 // Handle all FPUregister based formatting in this function to reduce the |
| 304 // complexity of FormatOption. | 332 // complexity of FormatOption. |
| 305 int Decoder::FormatCRegister(Instruction* instr, const char* format) { | 333 int Decoder::FormatFPURegister(Instruction* instr, const char* format) { |
| 306 ASSERT(format[0] == 'f'); | 334 ASSERT(format[0] == 'f'); |
| 307 if (format[1] == 's') { // 'fs: fs register | 335 if (format[1] == 's') { // 'fs: fs register |
| 308 int reg = instr->RsField(); | 336 int reg = instr->FsField(); |
| 309 PrintCRegister(reg); | 337 PrintFPURegister(reg); |
| 310 return 2; | 338 return 2; |
| 311 } else if (format[1] == 't') { // 'ft: ft register | 339 } else if (format[1] == 't') { // 'ft: ft register |
| 312 int reg = instr->RtField(); | 340 int reg = instr->FtField(); |
| 313 PrintCRegister(reg); | 341 PrintFPURegister(reg); |
| 314 return 2; | 342 return 2; |
| 315 } else if (format[1] == 'd') { // 'fd: fd register | 343 } else if (format[1] == 'd') { // 'fd: fd register |
| 316 int reg = instr->RdField(); | 344 int reg = instr->FdField(); |
| 317 PrintCRegister(reg); | 345 PrintFPURegister(reg); |
| 318 return 2; | 346 return 2; |
| 319 } | 347 } |
| 320 UNREACHABLE(); | 348 UNREACHABLE(); |
| 321 return -1; | 349 return -1; |
| 322 } | 350 } |
| 323 | 351 |
| 324 | 352 |
| 325 // FormatOption takes a formatting string and interprets it based on | 353 // FormatOption takes a formatting string and interprets it based on |
| 326 // the current instructions. The format string points to the first | 354 // the current instructions. The format string points to the first |
| 327 // character of the option string (the option escape has already been | 355 // character of the option string (the option escape has already been |
| (...skipping 22 matching lines...) Expand all Loading... |
| 350 return 6; | 378 return 6; |
| 351 } else { | 379 } else { |
| 352 ASSERT(STRING_STARTS_WITH(format, "imm26")); | 380 ASSERT(STRING_STARTS_WITH(format, "imm26")); |
| 353 PrintImm26(instr); | 381 PrintImm26(instr); |
| 354 return 5; | 382 return 5; |
| 355 } | 383 } |
| 356 } | 384 } |
| 357 case 'r': { // 'r: registers | 385 case 'r': { // 'r: registers |
| 358 return FormatRegister(instr, format); | 386 return FormatRegister(instr, format); |
| 359 } | 387 } |
| 360 case 'f': { // 'f: Cregisters | 388 case 'f': { // 'f: FPUregisters |
| 361 return FormatCRegister(instr, format); | 389 return FormatFPURegister(instr, format); |
| 362 } | 390 } |
| 363 case 's': { // 'sa | 391 case 's': { // 'sa |
| 364 ASSERT(STRING_STARTS_WITH(format, "sa")); | 392 switch (format[1]) { |
| 365 PrintSa(instr); | 393 case 'a': { |
| 394 ASSERT(STRING_STARTS_WITH(format, "sa")); |
| 395 PrintSa(instr); |
| 396 return 2; |
| 397 } |
| 398 case 'd': { |
| 399 ASSERT(STRING_STARTS_WITH(format, "sd")); |
| 400 PrintSd(instr); |
| 401 return 2; |
| 402 } |
| 403 } |
| 404 } |
| 405 case 'b': { // 'bc - Special for bc1 cc field. |
| 406 ASSERT(STRING_STARTS_WITH(format, "bc")); |
| 407 PrintBc(instr); |
| 408 return 2; |
| 409 } |
| 410 case 'C': { // 'Cc - Special for c.xx.d cc field. |
| 411 ASSERT(STRING_STARTS_WITH(format, "Cc")); |
| 412 PrintCc(instr); |
| 366 return 2; | 413 return 2; |
| 367 } | 414 } |
| 368 }; | 415 }; |
| 369 UNREACHABLE(); | 416 UNREACHABLE(); |
| 370 return -1; | 417 return -1; |
| 371 } | 418 } |
| 372 | 419 |
| 373 | 420 |
| 374 // Format takes a formatting string for a whole instruction and prints it into | 421 // Format takes a formatting string for a whole instruction and prints it into |
| 375 // the output buffer. All escaped options are handed to FormatOption to be | 422 // the output buffer. All escaped options are handed to FormatOption to be |
| (...skipping 16 matching lines...) Expand all Loading... |
| 392 // which will just print "unknown" of the instruction bits. | 439 // which will just print "unknown" of the instruction bits. |
| 393 void Decoder::Unknown(Instruction* instr) { | 440 void Decoder::Unknown(Instruction* instr) { |
| 394 Format(instr, "unknown"); | 441 Format(instr, "unknown"); |
| 395 } | 442 } |
| 396 | 443 |
| 397 | 444 |
| 398 void Decoder::DecodeTypeRegister(Instruction* instr) { | 445 void Decoder::DecodeTypeRegister(Instruction* instr) { |
| 399 switch (instr->OpcodeFieldRaw()) { | 446 switch (instr->OpcodeFieldRaw()) { |
| 400 case COP1: // Coprocessor instructions | 447 case COP1: // Coprocessor instructions |
| 401 switch (instr->RsFieldRaw()) { | 448 switch (instr->RsFieldRaw()) { |
| 402 case BC1: // branch on coprocessor condition | 449 case BC1: // bc1 handled in DecodeTypeImmediate. |
| 403 UNREACHABLE(); | 450 UNREACHABLE(); |
| 404 break; | 451 break; |
| 405 case MFC1: | 452 case MFC1: |
| 406 Format(instr, "mfc1 'rt, 'fs"); | 453 Format(instr, "mfc1 'rt, 'fs"); |
| 407 break; | 454 break; |
| 408 case MFHC1: | 455 case MFHC1: |
| 409 Format(instr, "mfhc1 rt, 'fs"); | 456 Format(instr, "mfhc1 'rt, 'fs"); |
| 410 break; | 457 break; |
| 411 case MTC1: | 458 case MTC1: |
| 412 Format(instr, "mtc1 'rt, 'fs"); | 459 Format(instr, "mtc1 'rt, 'fs"); |
| 413 break; | 460 break; |
| 414 case MTHC1: | 461 case MTHC1: |
| 415 Format(instr, "mthc1 rt, 'fs"); | 462 Format(instr, "mthc1 'rt, 'fs"); |
| 463 break; |
| 464 case D: |
| 465 switch (instr->FunctionFieldRaw()) { |
| 466 case ADD_D: |
| 467 Format(instr, "add.d 'fd, 'fs, 'ft"); |
| 468 break; |
| 469 case SUB_D: |
| 470 Format(instr, "sub.d 'fd, 'fs, 'ft"); |
| 471 break; |
| 472 case MUL_D: |
| 473 Format(instr, "mul.d 'fd, 'fs, 'ft"); |
| 474 break; |
| 475 case DIV_D: |
| 476 Format(instr, "div.d 'fd, 'fs, 'ft"); |
| 477 break; |
| 478 case ABS_D: |
| 479 Format(instr, "abs.d 'fd, 'fs"); |
| 480 break; |
| 481 case MOV_D: |
| 482 Format(instr, "mov.d 'fd, 'fs"); |
| 483 break; |
| 484 case NEG_D: |
| 485 Format(instr, "neg.d 'fd, 'fs"); |
| 486 break; |
| 487 case CVT_W_D: |
| 488 Format(instr, "cvt.w.d 'fd, 'fs"); |
| 489 break; |
| 490 case C_F_D: |
| 491 Format(instr, "c.f.d 'fs, 'ft, 'Cc"); |
| 492 break; |
| 493 case C_UN_D: |
| 494 Format(instr, "c.un.d 'fs, 'ft, 'Cc"); |
| 495 break; |
| 496 case C_EQ_D: |
| 497 Format(instr, "c.eq.d 'fs, 'ft, 'Cc"); |
| 498 break; |
| 499 case C_UEQ_D: |
| 500 Format(instr, "c.ueq.d 'fs, 'ft, 'Cc"); |
| 501 break; |
| 502 case C_OLT_D: |
| 503 Format(instr, "c.olt.d 'fs, 'ft, 'Cc"); |
| 504 break; |
| 505 case C_ULT_D: |
| 506 Format(instr, "c.ult.d 'fs, 'ft, 'Cc"); |
| 507 break; |
| 508 case C_OLE_D: |
| 509 Format(instr, "c.ole.d 'fs, 'ft, 'Cc"); |
| 510 break; |
| 511 case C_ULE_D: |
| 512 Format(instr, "c.ule.d 'fs, 'ft, 'Cc"); |
| 513 break; |
| 514 case CVT_L_D: |
| 515 case CVT_S_D: |
| 516 UNIMPLEMENTED_MIPS(); |
| 517 break; |
| 518 default: |
| 519 Format(instr, "unknown.cop1.d"); |
| 520 break; |
| 521 }; |
| 416 break; | 522 break; |
| 417 case S: | 523 case S: |
| 418 case D: | |
| 419 UNIMPLEMENTED_MIPS(); | 524 UNIMPLEMENTED_MIPS(); |
| 420 break; | 525 break; |
| 421 case W: | 526 case W: |
| 422 switch (instr->FunctionFieldRaw()) { | 527 switch (instr->FunctionFieldRaw()) { |
| 423 case CVT_S_W: | 528 case CVT_S_W: |
| 424 UNIMPLEMENTED_MIPS(); | 529 UNIMPLEMENTED_MIPS(); |
| 425 break; | 530 break; |
| 426 case CVT_D_W: // Convert word to double. | 531 case CVT_D_W: // Convert word to double. |
| 427 Format(instr, "cvt.d.w 'fd, 'fs"); | 532 Format(instr, "cvt.d.w 'fd, 'fs"); |
| 428 break; | 533 break; |
| 429 default: | 534 default: |
| 430 UNREACHABLE(); | 535 UNREACHABLE(); |
| 431 }; | 536 }; |
| 432 break; | 537 break; |
| 433 case L: | 538 case L: |
| 434 case PS: | 539 case PS: |
| 435 UNIMPLEMENTED_MIPS(); | 540 UNIMPLEMENTED_MIPS(); |
| 436 break; | 541 break; |
| 437 break; | |
| 438 default: | 542 default: |
| 439 UNREACHABLE(); | 543 UNREACHABLE(); |
| 440 }; | 544 }; |
| 441 break; | 545 break; |
| 442 case SPECIAL: | 546 case SPECIAL: |
| 443 switch (instr->FunctionFieldRaw()) { | 547 switch (instr->FunctionFieldRaw()) { |
| 444 case JR: | 548 case JR: |
| 445 Format(instr, "jr 'rs"); | 549 Format(instr, "jr 'rs"); |
| 446 break; | 550 break; |
| 447 case JALR: | 551 case JALR: |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 break; | 640 break; |
| 537 case TLTU: | 641 case TLTU: |
| 538 Format(instr, "tltu 'rs, 'rt, code: 'code"); | 642 Format(instr, "tltu 'rs, 'rt, code: 'code"); |
| 539 break; | 643 break; |
| 540 case TEQ: | 644 case TEQ: |
| 541 Format(instr, "teq 'rs, 'rt, code: 'code"); | 645 Format(instr, "teq 'rs, 'rt, code: 'code"); |
| 542 break; | 646 break; |
| 543 case TNE: | 647 case TNE: |
| 544 Format(instr, "tne 'rs, 'rt, code: 'code"); | 648 Format(instr, "tne 'rs, 'rt, code: 'code"); |
| 545 break; | 649 break; |
| 650 case MOVZ: |
| 651 Format(instr, "movz 'rd, 'rs, 'rt"); |
| 652 break; |
| 653 case MOVN: |
| 654 Format(instr, "movn 'rd, 'rs, 'rt"); |
| 655 break; |
| 546 default: | 656 default: |
| 547 UNREACHABLE(); | 657 UNREACHABLE(); |
| 548 }; | 658 }; |
| 549 break; | 659 break; |
| 550 case SPECIAL2: | 660 case SPECIAL2: |
| 551 switch (instr->FunctionFieldRaw()) { | 661 switch (instr->FunctionFieldRaw()) { |
| 552 case MUL: | 662 case MUL: |
| 663 Format(instr, "mul 'rd, 'rs, 'rt"); |
| 664 break; |
| 665 case CLZ: |
| 666 Format(instr, "clz 'rd, 'rs"); |
| 667 break; |
| 668 default: |
| 669 UNREACHABLE(); |
| 670 }; |
| 671 break; |
| 672 case SPECIAL3: |
| 673 switch (instr->FunctionFieldRaw()) { |
| 674 case INS: |
| 675 Format(instr, "ins 'rt, 'rs, 'sd, 'sa"); |
| 676 break; |
| 677 case EXT: |
| 678 Format(instr, "ext 'rt, 'rs, 'sd, 'sa"); |
| 553 break; | 679 break; |
| 554 default: | 680 default: |
| 555 UNREACHABLE(); | 681 UNREACHABLE(); |
| 556 }; | 682 }; |
| 557 break; | 683 break; |
| 558 default: | 684 default: |
| 559 UNREACHABLE(); | 685 UNREACHABLE(); |
| 560 }; | 686 }; |
| 561 } | 687 } |
| 562 | 688 |
| 563 | 689 |
| 564 void Decoder::DecodeTypeImmediate(Instruction* instr) { | 690 void Decoder::DecodeTypeImmediate(Instruction* instr) { |
| 565 switch (instr->OpcodeFieldRaw()) { | 691 switch (instr->OpcodeFieldRaw()) { |
| 566 // ------------- REGIMM class. | 692 // ------------- REGIMM class. |
| 693 case COP1: |
| 694 switch (instr->RsFieldRaw()) { |
| 695 case BC1: |
| 696 if (instr->FBtrueField()) { |
| 697 Format(instr, "bc1t 'bc, 'imm16u"); |
| 698 } else { |
| 699 Format(instr, "bc1f 'bc, 'imm16u"); |
| 700 } |
| 701 break; |
| 702 default: |
| 703 UNREACHABLE(); |
| 704 }; |
| 705 break; // Case COP1. |
| 567 case REGIMM: | 706 case REGIMM: |
| 568 switch (instr->RtFieldRaw()) { | 707 switch (instr->RtFieldRaw()) { |
| 569 case BLTZ: | 708 case BLTZ: |
| 570 Format(instr, "bltz 'rs, 'imm16u"); | 709 Format(instr, "bltz 'rs, 'imm16u"); |
| 571 break; | 710 break; |
| 572 case BLTZAL: | 711 case BLTZAL: |
| 573 Format(instr, "bltzal 'rs, 'imm16u"); | 712 Format(instr, "bltzal 'rs, 'imm16u"); |
| 574 break; | 713 break; |
| 575 case BGEZ: | 714 case BGEZ: |
| 576 Format(instr, "bgez 'rs, 'imm16u"); | 715 Format(instr, "bgez 'rs, 'imm16u"); |
| 577 break; | 716 break; |
| 578 case BGEZAL: | 717 case BGEZAL: |
| 579 Format(instr, "bgezal 'rs, 'imm16u"); | 718 Format(instr, "bgezal 'rs, 'imm16u"); |
| 580 break; | 719 break; |
| 581 default: | 720 default: |
| 582 UNREACHABLE(); | 721 UNREACHABLE(); |
| 583 }; | 722 }; |
| 584 break; // case REGIMM | 723 break; // Case REGIMM. |
| 585 // ------------- Branch instructions. | 724 // ------------- Branch instructions. |
| 586 case BEQ: | 725 case BEQ: |
| 587 Format(instr, "beq 'rs, 'rt, 'imm16u"); | 726 Format(instr, "beq 'rs, 'rt, 'imm16u"); |
| 588 break; | 727 break; |
| 589 case BNE: | 728 case BNE: |
| 590 Format(instr, "bne 'rs, 'rt, 'imm16u"); | 729 Format(instr, "bne 'rs, 'rt, 'imm16u"); |
| 591 break; | 730 break; |
| 592 case BLEZ: | 731 case BLEZ: |
| 593 Format(instr, "blez 'rs, 'imm16u"); | 732 Format(instr, "blez 'rs, 'imm16u"); |
| 594 break; | 733 break; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 617 case XORI: | 756 case XORI: |
| 618 Format(instr, "xori 'rt, 'rs, 'imm16x"); | 757 Format(instr, "xori 'rt, 'rs, 'imm16x"); |
| 619 break; | 758 break; |
| 620 case LUI: | 759 case LUI: |
| 621 Format(instr, "lui 'rt, 'imm16x"); | 760 Format(instr, "lui 'rt, 'imm16x"); |
| 622 break; | 761 break; |
| 623 // ------------- Memory instructions. | 762 // ------------- Memory instructions. |
| 624 case LB: | 763 case LB: |
| 625 Format(instr, "lb 'rt, 'imm16s('rs)"); | 764 Format(instr, "lb 'rt, 'imm16s('rs)"); |
| 626 break; | 765 break; |
| 766 case LH: |
| 767 Format(instr, "lh 'rt, 'imm16s('rs)"); |
| 768 break; |
| 627 case LW: | 769 case LW: |
| 628 Format(instr, "lw 'rt, 'imm16s('rs)"); | 770 Format(instr, "lw 'rt, 'imm16s('rs)"); |
| 629 break; | 771 break; |
| 630 case LBU: | 772 case LBU: |
| 631 Format(instr, "lbu 'rt, 'imm16s('rs)"); | 773 Format(instr, "lbu 'rt, 'imm16s('rs)"); |
| 632 break; | 774 break; |
| 775 case LHU: |
| 776 Format(instr, "lhu 'rt, 'imm16s('rs)"); |
| 777 break; |
| 633 case SB: | 778 case SB: |
| 634 Format(instr, "sb 'rt, 'imm16s('rs)"); | 779 Format(instr, "sb 'rt, 'imm16s('rs)"); |
| 635 break; | 780 break; |
| 781 case SH: |
| 782 Format(instr, "sh 'rt, 'imm16s('rs)"); |
| 783 break; |
| 636 case SW: | 784 case SW: |
| 637 Format(instr, "sw 'rt, 'imm16s('rs)"); | 785 Format(instr, "sw 'rt, 'imm16s('rs)"); |
| 638 break; | 786 break; |
| 639 case LWC1: | 787 case LWC1: |
| 640 Format(instr, "lwc1 'ft, 'imm16s('rs)"); | 788 Format(instr, "lwc1 'ft, 'imm16s('rs)"); |
| 641 break; | 789 break; |
| 642 case LDC1: | 790 case LDC1: |
| 643 Format(instr, "ldc1 'ft, 'imm16s('rs)"); | 791 Format(instr, "ldc1 'ft, 'imm16s('rs)"); |
| 644 break; | 792 break; |
| 645 case SWC1: | 793 case SWC1: |
| 646 Format(instr, "swc1 'rt, 'imm16s('fs)"); | 794 Format(instr, "swc1 'ft, 'imm16s('rs)"); |
| 647 break; | 795 break; |
| 648 case SDC1: | 796 case SDC1: |
| 649 Format(instr, "sdc1 'rt, 'imm16s('fs)"); | 797 Format(instr, "sdc1 'ft, 'imm16s('rs)"); |
| 650 break; | 798 break; |
| 651 default: | 799 default: |
| 652 UNREACHABLE(); | 800 UNREACHABLE(); |
| 653 break; | 801 break; |
| 654 }; | 802 }; |
| 655 } | 803 } |
| 656 | 804 |
| 657 | 805 |
| 658 void Decoder::DecodeTypeJump(Instruction* instr) { | 806 void Decoder::DecodeTypeJump(Instruction* instr) { |
| 659 switch (instr->OpcodeFieldRaw()) { | 807 switch (instr->OpcodeFieldRaw()) { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 | 899 |
| 752 Disassembler::~Disassembler() {} | 900 Disassembler::~Disassembler() {} |
| 753 | 901 |
| 754 | 902 |
| 755 int Disassembler::InstructionDecode(v8::internal::Vector<char> buffer, | 903 int Disassembler::InstructionDecode(v8::internal::Vector<char> buffer, |
| 756 byte_* instruction) { | 904 byte_* instruction) { |
| 757 assembler::mips::Decoder d(converter_, buffer); | 905 assembler::mips::Decoder d(converter_, buffer); |
| 758 return d.InstructionDecode(instruction); | 906 return d.InstructionDecode(instruction); |
| 759 } | 907 } |
| 760 | 908 |
| 761 | 909 // The MIPS assembler does not currently use constant pools. |
| 762 int Disassembler::ConstantPoolSizeAt(byte_* instruction) { | 910 int Disassembler::ConstantPoolSizeAt(byte_* instruction) { |
| 763 UNIMPLEMENTED_MIPS(); | |
| 764 return -1; | 911 return -1; |
| 765 } | 912 } |
| 766 | 913 |
| 767 | 914 |
| 768 void Disassembler::Disassemble(FILE* f, byte_* begin, byte_* end) { | 915 void Disassembler::Disassemble(FILE* f, byte_* begin, byte_* end) { |
| 769 NameConverter converter; | 916 NameConverter converter; |
| 770 Disassembler d(converter); | 917 Disassembler d(converter); |
| 771 for (byte_* pc = begin; pc < end;) { | 918 for (byte_* pc = begin; pc < end;) { |
| 772 v8::internal::EmbeddedVector<char, 128> buffer; | 919 v8::internal::EmbeddedVector<char, 128> buffer; |
| 773 buffer[0] = '\0'; | 920 buffer[0] = '\0'; |
| 774 byte_* prev_pc = pc; | 921 byte_* prev_pc = pc; |
| 775 pc += d.InstructionDecode(buffer, pc); | 922 pc += d.InstructionDecode(buffer, pc); |
| 776 fprintf(f, "%p %08x %s\n", | 923 fprintf(f, "%p %08x %s\n", |
| 777 prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); | 924 prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); |
| 778 } | 925 } |
| 779 } | 926 } |
| 780 | 927 |
| 781 #undef UNSUPPORTED | 928 #undef UNSUPPORTED |
| 782 | 929 |
| 783 } // namespace disasm | 930 } // namespace disasm |
| 784 | 931 |
| OLD | NEW |