30 #if V8_TARGET_ARCH_S390 32 #include "src/base/platform/platform.h" 33 #include "src/disasm.h" 34 #include "src/macro-assembler.h" 35 #include "src/register-configuration.h" 36 #include "src/s390/constants-s390.h" 49 : converter_(converter), out_buffer_(out_buffer), out_buffer_pos_(0) {
50 out_buffer_[out_buffer_pos_] =
'\0';
57 int InstructionDecode(byte* instruction);
61 void PrintChar(
const char ch);
62 void Print(
const char* str);
65 void PrintRegister(
int reg);
66 void PrintDRegister(
int reg);
67 void PrintSoftwareInterrupt(SoftwareInterruptCodes svc);
70 int FormatRegister(Instruction* instr,
const char* option);
71 int FormatFloatingRegister(Instruction* instr,
const char* option);
72 int FormatMask(Instruction* instr,
const char* option);
73 int FormatDisplacement(Instruction* instr,
const char* option);
74 int FormatImmediate(Instruction* instr,
const char* option);
75 int FormatOption(Instruction* instr,
const char* option);
76 void Format(Instruction* instr,
const char* format);
77 void Unknown(Instruction* instr);
78 void UnknownFormat(Instruction* instr,
const char* opcname);
80 bool DecodeSpecial(Instruction* instr);
81 bool DecodeGeneric(Instruction* instr);
84 Vector<char> out_buffer_;
87 DISALLOW_COPY_AND_ASSIGN(Decoder);
91 #define STRING_STARTS_WITH(string, compare_string) \ 92 (strncmp(string, compare_string, strlen(compare_string)) == 0) 95 void Decoder::PrintChar(
const char ch) { out_buffer_[out_buffer_pos_++] = ch; }
98 void Decoder::Print(
const char* str) {
100 while (cur !=
'\0' && (out_buffer_pos_ < (out_buffer_.length() - 1))) {
104 out_buffer_[out_buffer_pos_] = 0;
108 void Decoder::PrintRegister(
int reg) {
109 Print(converter_.NameOfCPURegister(reg));
113 void Decoder::PrintDRegister(
int reg) {
114 Print(RegisterName(DoubleRegister::from_code(reg)));
119 void Decoder::PrintSoftwareInterrupt(SoftwareInterruptCodes svc) {
121 case kCallRtRedirected:
122 Print(
"call rt redirected");
128 if (svc >= kStopCode) {
129 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"%d - 0x%x",
130 svc & kStopCodeMask, svc & kStopCodeMask);
132 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"%d", svc);
140 int Decoder::FormatRegister(Instruction* instr,
const char* format) {
141 DCHECK_EQ(format[0],
'r');
143 if (format[1] ==
'1') {
144 int reg = instr->Bits<SixByteInstr,
int>(39, 36);
147 }
else if (format[1] ==
'2') {
148 int reg = instr->Bits<SixByteInstr,
int>(35, 32);
151 if (format[2] ==
'd') {
152 if (reg == 0)
return 4;
159 }
else if (format[1] ==
'3') {
160 int reg = instr->Bits<SixByteInstr,
int>(31, 28);
163 }
else if (format[1] ==
'4') {
164 int reg = instr->Bits<SixByteInstr,
int>(27, 24);
167 }
else if (format[1] ==
'5') {
168 int reg = instr->Bits<SixByteInstr,
int>(23, 20);
171 }
else if (format[1] ==
'6') {
172 int reg = instr->Bits<SixByteInstr,
int>(19, 16);
175 }
else if (format[1] ==
'7') {
176 int reg = instr->Bits<SixByteInstr,
int>(15, 12);
184 int Decoder::FormatFloatingRegister(Instruction* instr,
const char* format) {
185 DCHECK_EQ(format[0],
'f');
188 if (format[1] ==
'1') {
189 RRInstruction* rrinstr =
reinterpret_cast<RRInstruction*
>(instr);
190 int reg = rrinstr->R1Value();
193 }
else if (format[1] ==
'2') {
194 RRInstruction* rrinstr =
reinterpret_cast<RRInstruction*
>(instr);
195 int reg = rrinstr->R2Value();
198 }
else if (format[1] ==
'3') {
199 RRDInstruction* rrdinstr =
reinterpret_cast<RRDInstruction*
>(instr);
200 int reg = rrdinstr->R1Value();
203 }
else if (format[1] ==
'5') {
204 RREInstruction* rreinstr =
reinterpret_cast<RREInstruction*
>(instr);
205 int reg = rreinstr->R1Value();
208 }
else if (format[1] ==
'6') {
209 RREInstruction* rreinstr =
reinterpret_cast<RREInstruction*
>(instr);
210 int reg = rreinstr->R2Value();
222 int Decoder::FormatOption(Instruction* instr,
const char* format) {
225 if (instr->Bit(10) == 1) {
231 if (instr->Bit(0) == 1) {
239 return FormatRegister(instr, format);
242 return FormatFloatingRegister(instr, format);
245 return FormatImmediate(instr, format);
248 int32_t value = instr->Bits(15, 0);
249 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"%d", value);
254 if (instr->Bit(0) == 1) {
261 if (instr->Bit(1) == 1) {
268 DCHECK(STRING_STARTS_WITH(format,
"target"));
269 if ((format[6] ==
'2') && (format[7] ==
'6')) {
270 int off = ((instr->Bits(25, 2)) << 8) >> 6;
271 out_buffer_pos_ += SNPrintF(
272 out_buffer_ + out_buffer_pos_,
"%+d -> %s", off,
273 converter_.NameOfAddress(reinterpret_cast<byte*>(instr) + off));
275 }
else if ((format[6] ==
'1') && (format[7] ==
'6')) {
276 int off = ((instr->Bits(15, 2)) << 18) >> 16;
277 out_buffer_pos_ += SNPrintF(
278 out_buffer_ + out_buffer_pos_,
"%+d -> %s", off,
279 converter_.NameOfAddress(reinterpret_cast<byte*>(instr) + off));
284 return FormatMask(instr, format);
288 return FormatDisplacement(instr, format);
299 int Decoder::FormatMask(Instruction* instr,
const char* format) {
300 DCHECK_EQ(format[0],
'm');
302 if ((format[1] ==
'1')) {
303 value =
reinterpret_cast<RRInstruction*
>(instr)->R1Value();
304 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"0x%x", value);
306 }
else if (format[1] ==
'2') {
307 value =
reinterpret_cast<RXInstruction*
>(instr)->B2Value();
308 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"0x%x", value);
310 }
else if (format[1] ==
'3') {
311 value =
reinterpret_cast<RRFInstruction*
>(instr)->M4Value();
312 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"0x%x", value);
316 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"%d", value);
320 int Decoder::FormatDisplacement(Instruction* instr,
const char* format) {
321 DCHECK_EQ(format[0],
'd');
323 if (format[1] ==
'1') {
324 RSInstruction* rsinstr =
reinterpret_cast<RSInstruction*
>(instr);
325 uint16_t value = rsinstr->D2Value();
326 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"%d", value);
329 }
else if (format[1] ==
'2') {
330 RXYInstruction* rxyinstr =
reinterpret_cast<RXYInstruction*
>(instr);
331 int32_t value = rxyinstr->D2Value();
332 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"%d", value);
334 }
else if (format[1] ==
'4') {
335 SSInstruction* ssInstr =
reinterpret_cast<SSInstruction*
>(instr);
336 uint16_t value = ssInstr->D2Value();
337 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"%d", value);
339 }
else if (format[1] ==
'3') {
340 SSInstruction* ssInstr =
reinterpret_cast<SSInstruction*
>(instr);
341 uint16_t value = ssInstr->D1Value();
342 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"%d", value);
345 int32_t value = SIGN_EXT_IMM16(instr->Bits(15, 0) & ~3);
346 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"%d", value);
351 int Decoder::FormatImmediate(Instruction* instr,
const char* format) {
352 DCHECK_EQ(format[0],
'i');
354 if (format[1] ==
'1') {
355 RIInstruction* riinstr =
reinterpret_cast<RIInstruction*
>(instr);
356 int16_t value = riinstr->I2Value();
357 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"%d", value);
359 }
else if (format[1] ==
'2') {
360 RILInstruction* rilinstr =
reinterpret_cast<RILInstruction*
>(instr);
361 int32_t value = rilinstr->I2Value();
362 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"%d", value);
364 }
else if (format[1] ==
'3') {
365 IInstruction* iinstr =
reinterpret_cast<IInstruction*
>(instr);
366 int8_t value = iinstr->IValue();
367 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"%d", value);
369 }
else if (format[1] ==
'4') {
370 RIInstruction* riinstr =
reinterpret_cast<RIInstruction*
>(instr);
371 int16_t value = riinstr->I2Value() * 2;
373 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"*+");
375 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"*");
377 out_buffer_pos_ += SNPrintF(
378 out_buffer_ + out_buffer_pos_,
"%d -> %s", value,
379 converter_.NameOfAddress(reinterpret_cast<byte*>(instr) + value));
381 }
else if (format[1] ==
'5') {
382 RILInstruction* rilinstr =
reinterpret_cast<RILInstruction*
>(instr);
383 int32_t value = rilinstr->I2Value() * 2;
385 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"*+");
387 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"*");
389 out_buffer_pos_ += SNPrintF(
390 out_buffer_ + out_buffer_pos_,
"%d -> %s", value,
391 converter_.NameOfAddress(reinterpret_cast<byte*>(instr) + value));
393 }
else if (format[1] ==
'6') {
394 RIInstruction* riinstr =
reinterpret_cast<RIInstruction*
>(instr);
395 uint16_t value = riinstr->I2UnsignedValue();
396 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"%d", value);
398 }
else if (format[1] ==
'7') {
399 RILInstruction* rilinstr =
reinterpret_cast<RILInstruction*
>(instr);
400 uint32_t value = rilinstr->I2UnsignedValue();
401 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"%d", value);
403 }
else if (format[1] ==
'8') {
404 SSInstruction* ssinstr =
reinterpret_cast<SSInstruction*
>(instr);
405 uint8_t value = ssinstr->Length();
406 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"%d", value);
408 }
else if (format[1] ==
'9') {
409 RIEInstruction* rie_instr =
reinterpret_cast<RIEInstruction*
>(instr);
410 uint8_t value = rie_instr->I3Value();
411 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"%d", value);
413 }
else if (format[1] ==
'a') {
414 RIEInstruction* rie_instr =
reinterpret_cast<RIEInstruction*
>(instr);
415 uint8_t value = rie_instr->I4Value();
416 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"%d", value);
418 }
else if (format[1] ==
'b') {
419 RIEInstruction* rie_instr =
reinterpret_cast<RIEInstruction*
>(instr);
420 uint8_t value = rie_instr->I5Value();
421 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"%d", value);
423 }
else if (format[1] ==
'c') {
424 SSInstruction* ssinstr =
reinterpret_cast<SSInstruction*
>(instr);
425 int8_t value = ssinstr->Length();
426 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"%d", value);
428 }
else if (format[1] ==
'd') {
429 SILInstruction* silinstr =
reinterpret_cast<SILInstruction*
>(instr);
430 int16_t value = silinstr->I2Value();
431 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"%d", value);
433 }
else if (format[1] ==
'e') {
434 RILInstruction* rilinstr =
reinterpret_cast<RILInstruction*
>(instr);
435 int32_t value = rilinstr->I2Value() * 2;
437 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"*+");
439 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"*");
441 out_buffer_pos_ += SNPrintF(
442 out_buffer_ + out_buffer_pos_,
"%d -> %s", value,
443 converter_.NameOfAddress(reinterpret_cast<byte*>(instr) + value));
453 void Decoder::Format(Instruction* instr,
const char* format) {
454 char cur = *format++;
455 while ((cur != 0) && (out_buffer_pos_ < (out_buffer_.length() - 1))) {
457 format += FormatOption(instr, format);
459 out_buffer_[out_buffer_pos_++] = cur;
463 out_buffer_[out_buffer_pos_] =
'\0';
468 #define VERIFY(condition) \ 469 if (!(condition)) { \ 476 void Decoder::Unknown(Instruction* instr) { Format(instr,
"unknown"); }
481 void Decoder::UnknownFormat(Instruction* instr,
const char* name) {
483 snprintf(buffer,
sizeof(buffer),
"%s (unknown-format)", name);
484 Format(instr, buffer);
488 #undef STRING_STARTS_WITH 492 bool Decoder::DecodeSpecial(Instruction* instr) {
493 Opcode opcode = instr->S390OpcodeValue();
496 Format(instr,
"bkpt");
499 Format(instr,
"dumy\t'r1, 'd2 ( 'r2d, 'r3 )");
503 Format(instr,
"ldr\t'f1,'f2");
506 Format(instr,
"bcr\t'm1,'r2");
509 Format(instr,
"or\t'r1,'r2");
512 Format(instr,
"cr\t'r1,'r2");
515 Format(instr,
"mr\t'r1,'r2");
518 Format(instr,
"her\t'r1,'r2");
522 Format(instr,
"bras\t'r1,'i1");
526 Format(instr,
"mdbr\t'f5,'f6");
529 Format(instr,
"sdbr\t'f5,'f6");
532 Format(instr,
"adbr\t'f5,'f6");
535 Format(instr,
"cdbr\t'f5,'f6");
538 Format(instr,
"meebr\t'f5,'f6");
541 Format(instr,
"sqdbr\t'f5,'f6");
544 Format(instr,
"sqebr\t'f5,'f6");
547 Format(instr,
"lcdbr\t'f5,'f6");
550 Format(instr,
"lcebr\t'f5,'f6");
553 Format(instr,
"ltebr\t'f5,'f6");
556 Format(instr,
"ldebr\t'f5,'f6");
559 Format(instr,
"cebr\t'f5,'f6");
562 Format(instr,
"aebr\t'f5,'f6");
565 Format(instr,
"sebr\t'f5,'f6");
568 Format(instr,
"debr\t'f5,'f6");
571 Format(instr,
"ltdbr\t'f5,'f6");
574 Format(instr,
"ldgr\t'f5,'f6");
577 Format(instr,
"ddbr\t'f5,'f6");
580 Format(instr,
"lzdr\t'f5");
584 Format(instr,
"fiebra\t'f5,'m2,'f6,'m3");
587 Format(instr,
"fidbra\t'f5,'m2,'f6,'m3");
591 Format(instr,
"ic\t'r1,'d1('r2d,'r3)");
594 Format(instr,
"al\t'r1,'d1('r2d,'r3)");
597 Format(instr,
"le\t'f1,'d1('r2d,'r3)");
600 Format(instr,
"ld\t'f1,'d1('r2d,'r3)");
603 Format(instr,
"ste\t'f1,'d1('r2d,'r3)");
606 Format(instr,
"std\t'f1,'d1('r2d,'r3)");
612 Format(instr,
"trap4");
616 Format(instr,
"cfi\t'r1,'i2");
619 Format(instr,
"cgfi\t'r1,'i2");
622 Format(instr,
"afi\t'r1,'i2");
625 Format(instr,
"agfi\t'r1,'i2");
628 Format(instr,
"msfi\t'r1,'i2");
631 Format(instr,
"msgfi\t'r1,'i2");
634 Format(instr,
"alsih\t'r1,'i2");
637 Format(instr,
"alsihn\t'r1,'i2");
640 Format(instr,
"cih\t'r1,'i2");
643 Format(instr,
"aih\t'r1,'i2");
646 Format(instr,
"lgfi\t'r1,'i2");
650 Format(instr,
"asi\t'd2('r3),'ic");
653 Format(instr,
"agsi\t'd2('r3),'ic");
657 Format(instr,
"lt\t'r1,'d2('r2d,'r3)");
660 Format(instr,
"ldy\t'f1,'d2('r2d,'r3)");
663 Format(instr,
"ley\t'f1,'d2('r2d,'r3)");
666 Format(instr,
"stdy\t'f1,'d2('r2d,'r3)");
669 Format(instr,
"stey\t'f1,'d2('r2d,'r3)");
673 Format(instr,
"ldeb\t'f1,'d2('r2d,'r3)");
683 bool Decoder::DecodeGeneric(Instruction* instr) {
684 Opcode opcode = instr->S390OpcodeValue();
687 #define DECODE_RR_INSTRUCTIONS(name, opcode_name, opcode_value) \ 689 Format(instr, #name "\t'r1,'r2"); \ 691 S390_RR_OPCODE_LIST(DECODE_RR_INSTRUCTIONS)
692 #undef DECODE_RR_INSTRUCTIONS 695 #define DECODE_RS_A_INSTRUCTIONS(name, opcode_name, opcode_value) \ 697 Format(instr, #name "\t'r1,'r2,'d1('r3)"); \ 699 S390_RS_A_OPCODE_LIST(DECODE_RS_A_INSTRUCTIONS)
700 #undef DECODE_RS_A_INSTRUCTIONS 702 #define DECODE_RSI_INSTRUCTIONS(name, opcode_name, opcode_value) \ 704 Format(instr, #name "\t'r1,'r2,'i4"); \ 706 S390_RSI_OPCODE_LIST(DECODE_RSI_INSTRUCTIONS)
707 #undef DECODE_RSI_INSTRUCTIONS 709 #define DECODE_RI_A_INSTRUCTIONS(name, opcode_name, opcode_value) \ 711 Format(instr, #name "\t'r1,'i1"); \ 713 S390_RI_A_OPCODE_LIST(DECODE_RI_A_INSTRUCTIONS)
714 #undef DECODE_RI_A_INSTRUCTIONS 716 #define DECODE_RI_B_INSTRUCTIONS(name, opcode_name, opcode_value) \ 718 Format(instr, #name "\t'r1,'i4"); \ 720 S390_RI_B_OPCODE_LIST(DECODE_RI_B_INSTRUCTIONS)
721 #undef DECODE_RI_B_INSTRUCTIONS 723 #define DECODE_RI_C_INSTRUCTIONS(name, opcode_name, opcode_value) \ 725 Format(instr, #name "\t'm1,'i4"); \ 727 S390_RI_C_OPCODE_LIST(DECODE_RI_C_INSTRUCTIONS)
728 #undef DECODE_RI_C_INSTRUCTIONS 730 #define DECODE_RRE_INSTRUCTIONS(name, opcode_name, opcode_value) \ 732 Format(instr, #name "\t'r5,'r6"); \ 734 S390_RRE_OPCODE_LIST(DECODE_RRE_INSTRUCTIONS)
735 #undef DECODE_RRE_INSTRUCTIONS 737 #define DECODE_RRF_A_INSTRUCTIONS(name, opcode_name, opcode_val) \ 739 Format(instr, #name "\t'r5,'r6,'r3"); \ 741 S390_RRF_A_OPCODE_LIST(DECODE_RRF_A_INSTRUCTIONS)
742 #undef DECODE_RRF_A_INSTRUCTIONS 744 #define DECODE_RRF_C_INSTRUCTIONS(name, opcode_name, opcode_val) \ 746 Format(instr, #name "\t'r5,'r6,'m2"); \ 748 S390_RRF_C_OPCODE_LIST(DECODE_RRF_C_INSTRUCTIONS)
749 #undef DECODE_RRF_C_INSTRUCTIONS 751 #define DECODE_RRF_E_INSTRUCTIONS(name, opcode_name, opcode_val) \ 753 Format(instr, #name "\t'r5,'m2,'f6"); \ 755 S390_RRF_E_OPCODE_LIST(DECODE_RRF_E_INSTRUCTIONS)
756 #undef DECODE_RRF_E_INSTRUCTIONS 758 #define DECODE_RX_A_INSTRUCTIONS(name, opcode_name, opcode_value) \ 760 Format(instr, #name "\t'r1,'d1('r2d,'r3)"); \ 762 S390_RX_A_OPCODE_LIST(DECODE_RX_A_INSTRUCTIONS)
763 #undef DECODE_RX_A_INSTRUCTIONS 765 #define DECODE_RX_B_INSTRUCTIONS(name, opcode_name, opcode_value) \ 767 Format(instr, #name "\t'm1,'d1('r2d,'r3)"); \ 769 S390_RX_B_OPCODE_LIST(DECODE_RX_B_INSTRUCTIONS)
770 #undef DECODE_RX_B_INSTRUCTIONS 772 #define DECODE_RRD_INSTRUCTIONS(name, opcode_name, opcode_value) \ 774 Format(instr, #name "\t'f3,'f5,'f6"); \ 776 S390_RRD_OPCODE_LIST(DECODE_RRD_INSTRUCTIONS)
777 #undef DECODE_RRD_INSTRUCTIONS 779 #define DECODE_SI_INSTRUCTIONS(name, opcode_name, opcode_value) \ 781 Format(instr, #name "\t'd1('r3),'i8"); \ 783 S390_SI_OPCODE_LIST(DECODE_SI_INSTRUCTIONS)
784 #undef DECODE_SI_INSTRUCTIONS 787 #define DECODE_VRR_C_INSTRUCTIONS(name, opcode_name, opcode_value) \ 789 Format(instr, #name "\t'f1,'f2,'f3"); \ 791 S390_VRR_C_OPCODE_LIST(DECODE_VRR_C_INSTRUCTIONS)
792 #undef DECODE_VRR_C_INSTRUCTIONS 794 #define DECODE_RIL_A_INSTRUCTIONS(name, opcode_name, opcode_value) \ 796 Format(instr, #name "\t'r1,'i7"); \ 798 S390_RIL_A_OPCODE_LIST(DECODE_RIL_A_INSTRUCTIONS)
799 #undef DECODE_RIL_A_INSTRUCTIONS 801 #define DECODE_RIL_B_INSTRUCTIONS(name, opcode_name, opcode_value) \ 803 Format(instr, #name "\t'r1,'ie"); \ 805 S390_RIL_B_OPCODE_LIST(DECODE_RIL_B_INSTRUCTIONS)
806 #undef DECODE_RIL_B_INSTRUCTIONS 808 #define DECODE_RIL_C_INSTRUCTIONS(name, opcode_name, opcode_value) \ 810 Format(instr, #name "\t'm1,'ie"); \ 812 S390_RIL_C_OPCODE_LIST(DECODE_RIL_C_INSTRUCTIONS)
813 #undef DECODE_RIL_C_INSTRUCTIONS 815 #define DECODE_SIY_INSTRUCTIONS(name, opcode_name, opcode_value) \ 817 Format(instr, #name "\t'd2('r3),'i8"); \ 819 S390_SIY_OPCODE_LIST(DECODE_SIY_INSTRUCTIONS)
820 #undef DECODE_SIY_INSTRUCTIONS 822 #define DECODE_RIE_D_INSTRUCTIONS(name, opcode_name, opcode_value) \ 824 Format(instr, #name "\t'r1,'r2,'i1"); \ 826 S390_RIE_D_OPCODE_LIST(DECODE_RIE_D_INSTRUCTIONS)
827 #undef DECODE_RIE_D_INSTRUCTIONS 829 #define DECODE_RIE_E_INSTRUCTIONS(name, opcode_name, opcode_value) \ 831 Format(instr, #name "\t'r1,'r2,'i4"); \ 833 S390_RIE_E_OPCODE_LIST(DECODE_RIE_E_INSTRUCTIONS)
834 #undef DECODE_RIE_E_INSTRUCTIONS 836 #define DECODE_RIE_F_INSTRUCTIONS(name, opcode_name, opcode_value) \ 838 Format(instr, #name "\t'r1,'r2,'i9,'ia,'ib"); \ 840 S390_RIE_F_OPCODE_LIST(DECODE_RIE_F_INSTRUCTIONS)
841 #undef DECODE_RIE_F_INSTRUCTIONS 843 #define DECODE_RSY_A_INSTRUCTIONS(name, opcode_name, opcode_value) \ 845 Format(instr, #name "\t'r1,'r2,'d2('r3)"); \ 847 S390_RSY_A_OPCODE_LIST(DECODE_RSY_A_INSTRUCTIONS)
848 #undef DECODE_RSY_A_INSTRUCTIONS 850 #define DECODE_RSY_B_INSTRUCTIONS(name, opcode_name, opcode_value) \ 852 Format(instr, #name "\t'm2,'r1,'d2('r3)"); \ 854 S390_RSY_B_OPCODE_LIST(DECODE_RSY_B_INSTRUCTIONS)
855 #undef DECODE_RSY_B_INSTRUCTIONS 857 #define DECODE_RXY_A_INSTRUCTIONS(name, opcode_name, opcode_value) \ 859 Format(instr, #name "\t'r1,'d2('r2d,'r3)"); \ 861 S390_RXY_A_OPCODE_LIST(DECODE_RXY_A_INSTRUCTIONS)
862 #undef DECODE_RXY_A_INSTRUCTIONS 864 #define DECODE_RXY_B_INSTRUCTIONS(name, opcode_name, opcode_value) \ 866 Format(instr, #name "\t'm1,'d2('r2d,'r3)"); \ 868 S390_RXY_B_OPCODE_LIST(DECODE_RXY_B_INSTRUCTIONS)
869 #undef DECODE_RXY_B_INSTRUCTIONS 871 #define DECODE_RXE_INSTRUCTIONS(name, opcode_name, opcode_value) \ 873 Format(instr, #name "\t'f1,'d1('r2d, 'r3)"); \ 875 S390_RXE_OPCODE_LIST(DECODE_RXE_INSTRUCTIONS)
876 #undef DECODE_RXE_INSTRUCTIONS 878 #define DECODE_SIL_INSTRUCTIONS(name, opcode_name, opcode_value) \ 880 Format(instr, #name "\t'd3('r3),'id"); \ 882 S390_SIL_OPCODE_LIST(DECODE_SIL_INSTRUCTIONS)
883 #undef DECODE_SIL_INSTRUCTIONS 885 #define DECODE_SS_A_INSTRUCTIONS(name, opcode_name, opcode_value) \ 887 Format(instr, #name "\t'd3('i8,'r3),'d4('r7)"); \ 889 S390_SS_A_OPCODE_LIST(DECODE_SS_A_INSTRUCTIONS)
890 #undef DECODE_SS_A_INSTRUCTIONS 899 int Decoder::InstructionDecode(byte* instr_ptr) {
900 Instruction* instr = Instruction::At(instr_ptr);
901 int instrLength = instr->InstructionLength();
904 if (instrLength == 2) {
905 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
906 "%04x ", instr->InstructionBits<TwoByteInstr>());
907 }
else if (instrLength == 4) {
908 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
909 "%08x ", instr->InstructionBits<FourByteInstr>());
911 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
912 "%012" PRIx64
" ", instr->InstructionBits<SixByteInstr>());
915 bool decoded = DecodeSpecial(instr);
917 decoded = DecodeGeneric(instr);
930 const char* NameConverter::NameOfAddress(byte* addr)
const {
931 v8::internal::SNPrintF(tmp_buffer_,
"%p", static_cast<void*>(addr));
932 return tmp_buffer_.start();
935 const char* NameConverter::NameOfConstant(byte* addr)
const {
936 return NameOfAddress(addr);
939 const char* NameConverter::NameOfCPURegister(
int reg)
const {
940 return RegisterName(i::Register::from_code(reg));
943 const char* NameConverter::NameOfByteCPURegister(
int reg)
const {
947 const char* NameConverter::NameOfXMMRegister(
int reg)
const {
953 const char* NameConverter::NameInCode(byte* addr)
const {
964 return d.InstructionDecode(instruction);
968 int Disassembler::ConstantPoolSizeAt(byte* instruction) {
return -1; }
970 void Disassembler::Disassemble(FILE* f, byte* begin, byte* end,
971 UnimplementedOpcodeAction unimplemented_action) {
972 NameConverter converter;
973 Disassembler d(converter, unimplemented_action);
974 for (byte* pc = begin; pc < end;) {
978 pc += d.InstructionDecode(buffer, pc);
979 v8::internal::PrintF(f,
"%p %08x %s\n", static_cast<void*>(prev_pc),
980 *reinterpret_cast<int32_t*>(prev_pc), buffer.start());
986 #endif // V8_TARGET_ARCH_S390