33 #if V8_TARGET_ARCH_MIPS64
52 : converter_(converter),
53 out_buffer_(out_buffer),
55 out_buffer_[out_buffer_pos_] =
'\0';
62 int InstructionDecode(
byte* instruction);
66 void PrintChar(
const char ch);
67 void Print(
const char* str);
70 void PrintRegister(
int reg);
71 void PrintFPURegister(
int freg);
72 void PrintRs(Instruction* instr);
73 void PrintRt(Instruction* instr);
74 void PrintRd(Instruction* instr);
75 void PrintFs(Instruction* instr);
76 void PrintFt(Instruction* instr);
77 void PrintFd(Instruction* instr);
78 void PrintSa(Instruction* instr);
79 void PrintSd(Instruction* instr);
80 void PrintSs1(Instruction* instr);
81 void PrintSs2(Instruction* instr);
82 void PrintBc(Instruction* instr);
83 void PrintCc(Instruction* instr);
84 void PrintFunction(Instruction* instr);
85 void PrintSecondaryField(Instruction* instr);
86 void PrintUImm16(Instruction* instr);
87 void PrintSImm16(Instruction* instr);
88 void PrintXImm16(Instruction* instr);
89 void PrintXImm21(Instruction* instr);
90 void PrintXImm26(Instruction* instr);
91 void PrintCode(Instruction* instr);
93 void PrintInstructionName(Instruction* instr);
96 int FormatRegister(Instruction* instr,
const char* option);
97 int FormatFPURegister(Instruction* instr,
const char* option);
98 int FormatOption(Instruction* instr,
const char* option);
99 void Format(Instruction* instr,
const char* format);
100 void Unknown(Instruction* instr);
101 int DecodeBreakInstr(Instruction* instr);
104 int DecodeTypeRegister(Instruction* instr);
105 void DecodeTypeImmediate(Instruction* instr);
106 void DecodeTypeJump(Instruction* instr);
117 #define STRING_STARTS_WITH(string, compare_string) \
118 (strncmp(string, compare_string, strlen(compare_string)) == 0)
122 void Decoder::PrintChar(
const char ch) {
123 out_buffer_[out_buffer_pos_++] = ch;
128 void Decoder::Print(
const char* str) {
130 while (cur !=
'\0' && (out_buffer_pos_ < (out_buffer_.length() - 1))) {
134 out_buffer_[out_buffer_pos_] = 0;
139 void Decoder::PrintRegister(
int reg) {
140 Print(converter_.NameOfCPURegister(reg));
144 void Decoder::PrintRs(Instruction* instr) {
145 int reg = instr->RsValue();
150 void Decoder::PrintRt(Instruction* instr) {
151 int reg = instr->RtValue();
156 void Decoder::PrintRd(Instruction* instr) {
157 int reg = instr->RdValue();
163 void Decoder::PrintFPURegister(
int freg) {
164 Print(converter_.NameOfXMMRegister(freg));
168 void Decoder::PrintFs(Instruction* instr) {
169 int freg = instr->RsValue();
170 PrintFPURegister(freg);
174 void Decoder::PrintFt(Instruction* instr) {
175 int freg = instr->RtValue();
176 PrintFPURegister(freg);
180 void Decoder::PrintFd(Instruction* instr) {
181 int freg = instr->RdValue();
182 PrintFPURegister(freg);
187 void Decoder::PrintSa(Instruction* instr) {
188 int sa = instr->SaValue();
189 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
"%d", sa);
194 void Decoder::PrintSd(Instruction* instr) {
195 int sd = instr->RdValue();
196 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
"%d", sd);
201 void Decoder::PrintSs1(Instruction* instr) {
202 int ss = instr->RdValue();
203 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
"%d", ss + 1);
208 void Decoder::PrintSs2(Instruction* instr) {
209 int ss = instr->RdValue();
210 int pos = instr->SaValue();
212 SNPrintF(out_buffer_ + out_buffer_pos_,
"%d", ss - pos + 1);
217 void Decoder::PrintBc(Instruction* instr) {
218 int cc = instr->FBccValue();
219 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
"%d",
cc);
224 void Decoder::PrintCc(Instruction* instr) {
225 int cc = instr->FCccValue();
226 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
"cc(%d)",
cc);
231 void Decoder::PrintUImm16(Instruction* instr) {
232 int32_t imm = instr->Imm16Value();
233 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
"%u", imm);
238 void Decoder::PrintSImm16(Instruction* instr) {
239 int32_t imm = ((instr->Imm16Value()) << 16) >> 16;
240 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
"%d", imm);
245 void Decoder::PrintXImm16(Instruction* instr) {
246 int32_t imm = instr->Imm16Value();
247 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
"0x%x", imm);
252 void Decoder::PrintXImm21(Instruction* instr) {
254 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
"0x%x", imm);
259 void Decoder::PrintXImm26(Instruction* instr) {
261 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
"0x%x", imm);
266 void Decoder::PrintCode(Instruction* instr) {
267 if (instr->OpcodeFieldRaw() !=
SPECIAL)
269 switch (instr->FunctionFieldRaw()) {
271 int32_t code = instr->Bits(25, 6);
272 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
273 "0x%05x (%d)", code, code);
282 int32_t code = instr->Bits(15, 6);
284 SNPrintF(out_buffer_ + out_buffer_pos_,
"0x%03x", code);
294 void Decoder::PrintInstructionName(Instruction* instr) {
300 int Decoder::FormatRegister(Instruction* instr,
const char* format) {
302 if (format[1] ==
's') {
303 int reg = instr->RsValue();
306 }
else if (format[1] ==
't') {
307 int reg = instr->RtValue();
310 }
else if (format[1] ==
'd') {
311 int reg = instr->RdValue();
322 int Decoder::FormatFPURegister(Instruction* instr,
const char* format) {
324 if (format[1] ==
's') {
325 int reg = instr->FsValue();
326 PrintFPURegister(reg);
328 }
else if (format[1] ==
't') {
329 int reg = instr->FtValue();
330 PrintFPURegister(reg);
332 }
else if (format[1] ==
'd') {
333 int reg = instr->FdValue();
334 PrintFPURegister(reg);
336 }
else if (format[1] ==
'r') {
337 int reg = instr->FrValue();
338 PrintFPURegister(reg);
351 int Decoder::FormatOption(Instruction* instr,
const char* format) {
354 DCHECK(STRING_STARTS_WITH(format,
"code"));
359 if (format[3] ==
'1') {
360 DCHECK(STRING_STARTS_WITH(format,
"imm16"));
361 if (format[5] ==
's') {
362 DCHECK(STRING_STARTS_WITH(format,
"imm16s"));
364 }
else if (format[5] ==
'u') {
365 DCHECK(STRING_STARTS_WITH(format,
"imm16u"));
368 DCHECK(STRING_STARTS_WITH(format,
"imm16x"));
372 }
else if (format[3] ==
'2' && format[4] ==
'1') {
373 DCHECK(STRING_STARTS_WITH(format,
"imm21x"));
376 }
else if (format[3] ==
'2' && format[4] ==
'6') {
377 DCHECK(STRING_STARTS_WITH(format,
"imm26x"));
383 return FormatRegister(instr, format);
386 return FormatFPURegister(instr, format);
391 DCHECK(STRING_STARTS_WITH(format,
"sa"));
396 DCHECK(STRING_STARTS_WITH(format,
"sd"));
401 if (format[2] ==
'1') {
402 DCHECK(STRING_STARTS_WITH(format,
"ss1"));
406 DCHECK(STRING_STARTS_WITH(format,
"ss2"));
414 DCHECK(STRING_STARTS_WITH(format,
"bc"));
419 DCHECK(STRING_STARTS_WITH(format,
"Cc"));
432 void Decoder::Format(Instruction* instr,
const char* format) {
433 char cur = *format++;
434 while ((cur != 0) && (out_buffer_pos_ < (out_buffer_.length() - 1))) {
436 format += FormatOption(instr, format);
438 out_buffer_[out_buffer_pos_++] = cur;
442 out_buffer_[out_buffer_pos_] =
'\0';
448 void Decoder::Unknown(Instruction* instr) {
449 Format(instr,
"unknown");
453 int Decoder::DecodeBreakInstr(Instruction* instr) {
455 if (instr->Bits(25, 6) ==
static_cast<int>(
kMaxStopCode)) {
457 Format(instr,
"break, code: 'code");
458 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
459 "\n%p %08lx stop msg: %s",
461 (
reinterpret_cast<int32_t*
>(instr
463 reinterpret_cast<uint64_t
>
464 (*
reinterpret_cast<char**
>(instr
466 *
reinterpret_cast<char**
>(instr
471 Format(instr,
"break, code: 'code");
477 int Decoder::DecodeTypeRegister(Instruction* instr) {
478 switch (instr->OpcodeFieldRaw()) {
480 switch (instr->RsFieldRaw()) {
482 Format(instr,
"mfc1 'rt, 'fs");
485 Format(instr,
"dmfc1 'rt, 'fs");
488 Format(instr,
"mfhc1 'rt, 'fs");
491 Format(instr,
"mtc1 'rt, 'fs");
494 Format(instr,
"dmtc1 'rt, 'fs");
498 Format(instr,
"ctc1 'rt, 'fs");
501 Format(instr,
"cfc1 'rt, 'fs");
504 Format(instr,
"mthc1 'rt, 'fs");
507 switch (instr->FunctionFieldRaw()) {
509 Format(instr,
"add.d 'fd, 'fs, 'ft");
512 Format(instr,
"sub.d 'fd, 'fs, 'ft");
515 Format(instr,
"mul.d 'fd, 'fs, 'ft");
518 Format(instr,
"div.d 'fd, 'fs, 'ft");
521 Format(instr,
"abs.d 'fd, 'fs");
524 Format(instr,
"mov.d 'fd, 'fs");
527 Format(instr,
"neg.d 'fd, 'fs");
530 Format(instr,
"sqrt.d 'fd, 'fs");
533 Format(instr,
"cvt.w.d 'fd, 'fs");
536 Format(instr,
"cvt.l.d 'fd, 'fs");
539 Format(instr,
"trunc.w.d 'fd, 'fs");
542 Format(instr,
"trunc.l.d 'fd, 'fs");
545 Format(instr,
"round.w.d 'fd, 'fs");
548 Format(instr,
"round.l.d 'fd, 'fs");
551 Format(instr,
"floor.w.d 'fd, 'fs");
554 Format(instr,
"floor.l.d 'fd, 'fs");
557 Format(instr,
"ceil.w.d 'fd, 'fs");
560 Format(instr,
"ceil.l.d 'fd, 'fs");
563 Format(instr,
"cvt.s.d 'fd, 'fs");
566 Format(instr,
"c.f.d 'fs, 'ft, 'Cc");
569 Format(instr,
"c.un.d 'fs, 'ft, 'Cc");
572 Format(instr,
"c.eq.d 'fs, 'ft, 'Cc");
575 Format(instr,
"c.ueq.d 'fs, 'ft, 'Cc");
578 Format(instr,
"c.olt.d 'fs, 'ft, 'Cc");
581 Format(instr,
"c.ult.d 'fs, 'ft, 'Cc");
584 Format(instr,
"c.ole.d 'fs, 'ft, 'Cc");
587 Format(instr,
"c.ule.d 'fs, 'ft, 'Cc");
590 Format(instr,
"unknown.cop1.d");
595 switch (instr->FunctionFieldRaw()) {
597 Format(instr,
"cvt.d.w 'fd, 'fs");
604 switch (instr->FunctionFieldRaw()) {
606 Format(instr,
"cvt.d.l 'fd, 'fs");
609 Format(instr,
"cvt.s.l 'fd, 'fs");
612 Format(instr,
"cmp.un.d 'fd, 'fs, 'ft");
615 Format(instr,
"cmp.eq.d 'fd, 'fs, 'ft");
618 Format(instr,
"cmp.ueq.d 'fd, 'fs, 'ft");
621 Format(instr,
"cmp.lt.d 'fd, 'fs, 'ft");
624 Format(instr,
"cmp.ult.d 'fd, 'fs, 'ft");
627 Format(instr,
"cmp.le.d 'fd, 'fs, 'ft");
630 Format(instr,
"cmp.ule.d 'fd, 'fs, 'ft");
633 Format(instr,
"cmp.or.d 'fd, 'fs, 'ft");
636 Format(instr,
"cmp.une.d 'fd, 'fs, 'ft");
639 Format(instr,
"cmp.ne.d 'fd, 'fs, 'ft");
650 switch (instr->FunctionFieldRaw()) {
652 Format(instr,
"madd.d 'fd, 'fr, 'fs, 'ft");
659 switch (instr->FunctionFieldRaw()) {
661 Format(instr,
"jr 'rs");
664 Format(instr,
"jalr 'rs");
667 if (0x0 ==
static_cast<int>(instr->InstructionBits()))
668 Format(instr,
"nop");
670 Format(instr,
"sll 'rd, 'rt, 'sa");
673 Format(instr,
"dsll 'rd, 'rt, 'sa");
677 Format(instr,
"dmult 'rs, 'rt");
679 if (instr->SaValue() ==
MUL_OP) {
680 Format(instr,
"dmul 'rd, 'rs, 'rt");
682 Format(instr,
"dmuh 'rd, 'rs, 'rt");
687 Format(instr,
"dsll32 'rd, 'rt, 'sa");
690 if (instr->RsValue() == 0) {
691 Format(instr,
"srl 'rd, 'rt, 'sa");
694 Format(instr,
"rotr 'rd, 'rt, 'sa");
701 if (instr->RsValue() == 0) {
702 Format(instr,
"dsrl 'rd, 'rt, 'sa");
705 Format(instr,
"drotr 'rd, 'rt, 'sa");
712 Format(instr,
"dsrl32 'rd, 'rt, 'sa");
715 Format(instr,
"sra 'rd, 'rt, 'sa");
718 Format(instr,
"dsra 'rd, 'rt, 'sa");
721 Format(instr,
"dsra32 'rd, 'rt, 'sa");
724 Format(instr,
"sllv 'rd, 'rt, 'rs");
727 Format(instr,
"dsllv 'rd, 'rt, 'rs");
730 if (instr->SaValue() == 0) {
731 Format(instr,
"srlv 'rd, 'rt, 'rs");
734 Format(instr,
"rotrv 'rd, 'rt, 'rs");
741 if (instr->SaValue() == 0) {
742 Format(instr,
"dsrlv 'rd, 'rt, 'rs");
745 Format(instr,
"drotrv 'rd, 'rt, 'rs");
752 Format(instr,
"srav 'rd, 'rt, 'rs");
755 Format(instr,
"dsrav 'rd, 'rt, 'rs");
758 if (instr->Bits(25, 16) == 0) {
759 Format(instr,
"mfhi 'rd");
761 if ((instr->FunctionFieldRaw() ==
CLZ_R6)
762 && (instr->FdValue() == 1)) {
763 Format(instr,
"clz 'rd, 'rs");
764 }
else if ((instr->FunctionFieldRaw() ==
CLO_R6)
765 && (instr->FdValue() == 1)) {
766 Format(instr,
"clo 'rd, 'rs");
771 Format(instr,
"mflo 'rd");
775 Format(instr,
"dmultu 'rs, 'rt");
777 if (instr->SaValue() ==
MUL_OP) {
778 Format(instr,
"dmulu 'rd, 'rs, 'rt");
780 Format(instr,
"dmuhu 'rd, 'rs, 'rt");
786 Format(instr,
"mult 'rs, 'rt");
788 if (instr->SaValue() ==
MUL_OP) {
789 Format(instr,
"mul 'rd, 'rs, 'rt");
791 Format(instr,
"muh 'rd, 'rs, 'rt");
797 Format(instr,
"multu 'rs, 'rt");
799 if (instr->SaValue() ==
MUL_OP) {
800 Format(instr,
"mulu 'rd, 'rs, 'rt");
802 Format(instr,
"muhu 'rd, 'rs, 'rt");
809 Format(instr,
"div 'rs, 'rt");
811 if (instr->SaValue() ==
DIV_OP) {
812 Format(instr,
"div 'rd, 'rs, 'rt");
814 Format(instr,
"mod 'rd, 'rs, 'rt");
820 Format(instr,
"ddiv 'rs, 'rt");
822 if (instr->SaValue() ==
DIV_OP) {
823 Format(instr,
"ddiv 'rd, 'rs, 'rt");
825 Format(instr,
"dmod 'rd, 'rs, 'rt");
831 Format(instr,
"divu 'rs, 'rt");
833 if (instr->SaValue() ==
DIV_OP) {
834 Format(instr,
"divu 'rd, 'rs, 'rt");
836 Format(instr,
"modu 'rd, 'rs, 'rt");
842 Format(instr,
"ddivu 'rs, 'rt");
844 if (instr->SaValue() ==
DIV_OP) {
845 Format(instr,
"ddivu 'rd, 'rs, 'rt");
847 Format(instr,
"dmodu 'rd, 'rs, 'rt");
852 Format(instr,
"add 'rd, 'rs, 'rt");
855 Format(instr,
"dadd 'rd, 'rs, 'rt");
858 Format(instr,
"addu 'rd, 'rs, 'rt");
861 Format(instr,
"daddu 'rd, 'rs, 'rt");
864 Format(instr,
"sub 'rd, 'rs, 'rt");
867 Format(instr,
"dsub 'rd, 'rs, 'rt");
870 Format(instr,
"subu 'rd, 'rs, 'rt");
873 Format(instr,
"dsubu 'rd, 'rs, 'rt");
876 Format(instr,
"and 'rd, 'rs, 'rt");
879 if (0 == instr->RsValue()) {
880 Format(instr,
"mov 'rd, 'rt");
881 }
else if (0 == instr->RtValue()) {
882 Format(instr,
"mov 'rd, 'rs");
884 Format(instr,
"or 'rd, 'rs, 'rt");
888 Format(instr,
"xor 'rd, 'rs, 'rt");
891 Format(instr,
"nor 'rd, 'rs, 'rt");
894 Format(instr,
"slt 'rd, 'rs, 'rt");
897 Format(instr,
"sltu 'rd, 'rs, 'rt");
900 return DecodeBreakInstr(instr);
902 Format(instr,
"tge 'rs, 'rt, code: 'code");
905 Format(instr,
"tgeu 'rs, 'rt, code: 'code");
908 Format(instr,
"tlt 'rs, 'rt, code: 'code");
911 Format(instr,
"tltu 'rs, 'rt, code: 'code");
914 Format(instr,
"teq 'rs, 'rt, code: 'code");
917 Format(instr,
"tne 'rs, 'rt, code: 'code");
920 Format(instr,
"movz 'rd, 'rs, 'rt");
923 Format(instr,
"movn 'rd, 'rs, 'rt");
926 if (instr->Bit(16)) {
927 Format(instr,
"movt 'rd, 'rs, 'bc");
929 Format(instr,
"movf 'rd, 'rs, 'bc");
933 Format(instr,
"seleqz 'rd, 'rs, 'rt");
936 Format(instr,
"selnez 'rd, 'rs, 'rt");
943 switch (instr->FunctionFieldRaw()) {
945 Format(instr,
"mul 'rd, 'rs, 'rt");
949 Format(instr,
"clz 'rd, 'rs");
957 switch (instr->FunctionFieldRaw()) {
959 Format(instr,
"ins 'rt, 'rs, 'sa, 'ss2");
963 Format(instr,
"ext 'rt, 'rs, 'sa, 'ss1");
977 void Decoder::DecodeTypeImmediate(Instruction* instr) {
978 switch (instr->OpcodeFieldRaw()) {
980 switch (instr->RsFieldRaw()) {
982 if (instr->FBtrueValue()) {
983 Format(instr,
"bc1t 'bc, 'imm16u");
985 Format(instr,
"bc1f 'bc, 'imm16u");
989 Format(instr,
"bc1eqz 'ft, 'imm16u");
992 Format(instr,
"bc1nez 'ft, 'imm16u");
995 switch (instr->FunctionValue()) {
997 Format(instr,
"cmp.af.S 'ft, 'fs, 'fd");
1000 Format(instr,
"cmp.un.S 'ft, 'fs, 'fd");
1003 Format(instr,
"cmp.eq.S 'ft, 'fs, 'fd");
1006 Format(instr,
"cmp.ueq.S 'ft, 'fs, 'fd");
1009 Format(instr,
"cmp.lt.S 'ft, 'fs, 'fd");
1012 Format(instr,
"cmp.ult.S 'ft, 'fs, 'fd");
1015 Format(instr,
"cmp.le.S 'ft, 'fs, 'fd");
1018 Format(instr,
"cmp.ule.S 'ft, 'fs, 'fd");
1021 Format(instr,
"cmp.or.S 'ft, 'fs, 'fd");
1024 Format(instr,
"cmp.une.S 'ft, 'fs, 'fd");
1027 Format(instr,
"cmp.ne.S 'ft, 'fs, 'fd");
1034 switch (instr->FunctionValue()) {
1036 Format(instr,
"cmp.af.D 'ft, 'fs, 'fd");
1039 Format(instr,
"cmp.un.D 'ft, 'fs, 'fd");
1042 Format(instr,
"cmp.eq.D 'ft, 'fs, 'fd");
1045 Format(instr,
"cmp.ueq.D 'ft, 'fs, 'fd");
1048 Format(instr,
"cmp.lt.D 'ft, 'fs, 'fd");
1051 Format(instr,
"cmp.ult.D 'ft, 'fs, 'fd");
1054 Format(instr,
"cmp.le.D 'ft, 'fs, 'fd");
1057 Format(instr,
"cmp.ule.D 'ft, 'fs, 'fd");
1060 Format(instr,
"cmp.or.D 'ft, 'fs, 'fd");
1063 Format(instr,
"cmp.une.D 'ft, 'fs, 'fd");
1066 Format(instr,
"cmp.ne.D 'ft, 'fs, 'fd");
1073 switch (instr->FunctionValue()) {
1075 Format(instr,
"sel.S 'ft, 'fs, 'fd");
1078 Format(instr,
"seleqz.S 'ft, 'fs, 'fd");
1081 Format(instr,
"selnez.S 'ft, 'fs, 'fd");
1084 Format(instr,
"min.S 'ft, 'fs, 'fd");
1087 Format(instr,
"mina.S 'ft, 'fs, 'fd");
1090 Format(instr,
"max.S 'ft, 'fs, 'fd");
1093 Format(instr,
"maxa.S 'ft, 'fs, 'fd");
1100 switch (instr->FunctionValue()) {
1102 Format(instr,
"sel.D 'ft, 'fs, 'fd");
1105 Format(instr,
"seleqz.D 'ft, 'fs, 'fd");
1108 Format(instr,
"selnez.D 'ft, 'fs, 'fd");
1111 Format(instr,
"min.D 'ft, 'fs, 'fd");
1114 Format(instr,
"mina.D 'ft, 'fs, 'fd");
1117 Format(instr,
"max.D 'ft, 'fs, 'fd");
1120 Format(instr,
"maxa.D 'ft, 'fs, 'fd");
1133 switch (instr->RtFieldRaw()) {
1135 Format(instr,
"bltz 'rs, 'imm16u");
1138 Format(instr,
"bltzal 'rs, 'imm16u");
1141 Format(instr,
"bgez 'rs, 'imm16u");
1144 Format(instr,
"bgezal 'rs, 'imm16u");
1147 Format(instr,
"bgezall 'rs, 'imm16u");
1150 Format(instr,
"dahi 'rs, 'imm16u");
1153 Format(instr,
"dati 'rs, 'imm16u");
1161 Format(instr,
"beq 'rs, 'rt, 'imm16u");
1164 Format(instr,
"bne 'rs, 'rt, 'imm16u");
1167 if ((instr->RtFieldRaw() == 0)
1168 && (instr->RsFieldRaw() != 0)) {
1169 Format(instr,
"blez 'rs, 'imm16u");
1170 }
else if ((instr->RtFieldRaw() != instr->RsFieldRaw())
1171 && (instr->RsFieldRaw() != 0) && (instr->RtFieldRaw() != 0)) {
1172 Format(instr,
"bgeuc 'rs, 'rt, 'imm16u");
1173 }
else if ((instr->RtFieldRaw() == instr->RsFieldRaw())
1174 && (instr->RtFieldRaw() != 0)) {
1175 Format(instr,
"bgezalc 'rs, 'imm16u");
1176 }
else if ((instr->RsFieldRaw() == 0)
1177 && (instr->RtFieldRaw() != 0)) {
1178 Format(instr,
"blezalc 'rs, 'imm16u");
1184 if ((instr->RtFieldRaw() == 0)
1185 && (instr->RsFieldRaw() != 0)) {
1186 Format(instr,
"bgtz 'rs, 'imm16u");
1187 }
else if ((instr->RtFieldRaw() != instr->RsFieldRaw())
1188 && (instr->RsFieldRaw() != 0) && (instr->RtFieldRaw() != 0)) {
1189 Format(instr,
"bltuc 'rs, 'rt, 'imm16u");
1190 }
else if ((instr->RtFieldRaw() == instr->RsFieldRaw())
1191 && (instr->RtFieldRaw() != 0)) {
1192 Format(instr,
"bltzalc 'rt, 'imm16u");
1193 }
else if ((instr->RsFieldRaw() == 0)
1194 && (instr->RtFieldRaw() != 0)) {
1195 Format(instr,
"bgtzalc 'rt, 'imm16u");
1201 if ((instr->RtFieldRaw() == instr->RsFieldRaw())
1202 && (instr->RtFieldRaw() != 0)) {
1203 Format(instr,
"bgezc 'rt, 'imm16u");
1204 }
else if ((instr->RtFieldRaw() != instr->RsFieldRaw())
1205 && (instr->RsFieldRaw() != 0) && (instr->RtFieldRaw() != 0)) {
1206 Format(instr,
"bgec 'rs, 'rt, 'imm16u");
1207 }
else if ((instr->RsFieldRaw() == 0)
1208 && (instr->RtFieldRaw() != 0)) {
1209 Format(instr,
"blezc 'rt, 'imm16u");
1215 if ((instr->RtFieldRaw() == instr->RsFieldRaw())
1216 && (instr->RtFieldRaw() != 0)) {
1217 Format(instr,
"bltzc 'rt, 'imm16u");
1218 }
else if ((instr->RtFieldRaw() != instr->RsFieldRaw())
1219 && (instr->RsFieldRaw() != 0) && (instr->RtFieldRaw() != 0)) {
1220 Format(instr,
"bltc 'rs, 'rt, 'imm16u");
1221 }
else if ((instr->RsFieldRaw() == 0)
1222 && (instr->RtFieldRaw() != 0)) {
1223 Format(instr,
"bgtzc 'rt, 'imm16u");
1229 if (instr->RsFieldRaw() != 0) {
1230 Format(instr,
"beqzc 'rs, 'imm21x");
1234 if (instr->RsFieldRaw() != 0) {
1235 Format(instr,
"bnezc 'rs, 'imm21x");
1241 Format(instr,
"addi 'rt, 'rs, 'imm16s");
1244 if (instr->RsFieldRaw() >= instr->RtFieldRaw()) {
1245 Format(instr,
"bovc 'rs, 'rt, 'imm16s");
1246 }
else if (instr->RsFieldRaw() < instr->RtFieldRaw()) {
1247 Format(instr,
"beqc 'rs, 'rt, 'imm16s");
1255 Format(instr,
"daddi 'rt, 'rs, 'imm16s");
1258 if (instr->RsFieldRaw() >= instr->RtFieldRaw()) {
1259 Format(instr,
"bnvc 'rs, 'rt, 'imm16s");
1260 }
else if (instr->RsFieldRaw() < instr->RtFieldRaw()) {
1261 Format(instr,
"bnec 'rs, 'rt, 'imm16s");
1268 Format(instr,
"addiu 'rt, 'rs, 'imm16s");
1271 Format(instr,
"daddiu 'rt, 'rs, 'imm16s");
1274 Format(instr,
"slti 'rt, 'rs, 'imm16s");
1277 Format(instr,
"sltiu 'rt, 'rs, 'imm16u");
1280 Format(instr,
"andi 'rt, 'rs, 'imm16x");
1283 Format(instr,
"ori 'rt, 'rs, 'imm16x");
1286 Format(instr,
"xori 'rt, 'rs, 'imm16x");
1290 Format(instr,
"lui 'rt, 'imm16x");
1292 if (instr->RsValue() != 0) {
1293 Format(instr,
"aui 'rt, 'imm16x");
1295 Format(instr,
"lui 'rt, 'imm16x");
1300 Format(instr,
"daui 'rt, 'imm16x");
1304 Format(instr,
"lb 'rt, 'imm16s('rs)");
1307 Format(instr,
"lh 'rt, 'imm16s('rs)");
1310 Format(instr,
"lwl 'rt, 'imm16s('rs)");
1313 Format(instr,
"ldl 'rt, 'imm16s('rs)");
1316 Format(instr,
"lw 'rt, 'imm16s('rs)");
1319 Format(instr,
"lwu 'rt, 'imm16s('rs)");
1322 Format(instr,
"ld 'rt, 'imm16s('rs)");
1325 Format(instr,
"lbu 'rt, 'imm16s('rs)");
1328 Format(instr,
"lhu 'rt, 'imm16s('rs)");
1331 Format(instr,
"lwr 'rt, 'imm16s('rs)");
1334 Format(instr,
"ldr 'rt, 'imm16s('rs)");
1337 Format(instr,
"pref 'rt, 'imm16s('rs)");
1340 Format(instr,
"sb 'rt, 'imm16s('rs)");
1343 Format(instr,
"sh 'rt, 'imm16s('rs)");
1346 Format(instr,
"swl 'rt, 'imm16s('rs)");
1349 Format(instr,
"sw 'rt, 'imm16s('rs)");
1352 Format(instr,
"sd 'rt, 'imm16s('rs)");
1355 Format(instr,
"swr 'rt, 'imm16s('rs)");
1358 Format(instr,
"lwc1 'ft, 'imm16s('rs)");
1361 Format(instr,
"ldc1 'ft, 'imm16s('rs)");
1364 Format(instr,
"swc1 'ft, 'imm16s('rs)");
1367 Format(instr,
"sdc1 'ft, 'imm16s('rs)");
1370 printf(
"a 0x%x \n", instr->OpcodeFieldRaw());
1377 void Decoder::DecodeTypeJump(Instruction* instr) {
1378 switch (instr->OpcodeFieldRaw()) {
1380 Format(instr,
"j 'imm26x");
1383 Format(instr,
"jal 'imm26x");
1395 int Decoder::InstructionDecode(
byte* instr_ptr) {
1398 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
1400 instr->InstructionBits());
1401 switch (instr->InstructionType()) {
1403 return DecodeTypeRegister(instr);
1406 DecodeTypeImmediate(instr);
1410 DecodeTypeJump(instr);
1414 Format(instr,
"UNSUPPORTED");
1467 : converter_(converter) {}
1470 Disassembler::~Disassembler() {}
1474 byte* instruction) {
1476 return d.InstructionDecode(instruction);
1481 int Disassembler::ConstantPoolSizeAt(
byte* instruction) {
1486 void Disassembler::Disassemble(FILE* f,
byte* begin,
byte* end) {
1487 NameConverter converter;
1488 Disassembler d(converter);
1489 for (
byte*
pc = begin;
pc < end;) {
1493 pc += d.InstructionDecode(buffer,
pc);
1495 prev_pc, *
reinterpret_cast<int32_t*
>(prev_pc), buffer.
start());
Disassembler(const NameConverter &converter)
v8::internal::EmbeddedVector< char, 128 > tmp_buffer_
virtual const char * NameInCode(byte *addr) const
virtual const char * NameOfByteCPURegister(int reg) const
virtual const char * NameOfXMMRegister(int reg) const
virtual const char * NameOfAddress(byte *addr) const
virtual const char * NameOfCPURegister(int reg) const
virtual const char * NameOfConstant(byte *addr) const
static const char * Name(int reg)
static Instruction * At(byte *pc)
static const char * Name(int reg)
#define UNSUPPORTED_MIPS()
static const ArchVariants kArchVariant
#define DCHECK(condition)
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
const uint32_t kMaxStopCode
int SNPrintF(Vector< char > str, const char *format,...)
void PrintF(const char *format,...)
Debugger support for the V8 JavaScript engine.