30#if V8_TARGET_ARCH_S390X
67 void Print(
const char* str);
71 void PrintDRegister(
int reg);
76 int FormatFloatingRegister(Instruction*
instr,
const char* option);
77 int FormatMask(Instruction*
instr,
const char* option);
78 int FormatDisplacement(Instruction*
instr,
const char* option);
79 int FormatImmediate(Instruction*
instr,
const char* option);
81 void Format(Instruction*
instr,
const char* format);
83 void UnknownFormat(Instruction*
instr,
const char* opcname);
85 bool DecodeSpecial(Instruction*
instr);
86 bool DecodeGeneric(Instruction*
instr);
94#define STRING_STARTS_WITH(string, compare_string) \
95 (strncmp(string, compare_string, strlen(compare_string)) == 0)
116void Decoder::PrintDRegister(
int reg) {
125 Print(
"call rt redirected");
148 if (format[1] ==
'1') {
152 }
else if (format[1] ==
'2') {
156 if (format[2] ==
'd') {
157 if (
reg == 0)
return 4;
164 }
else if (format[1] ==
'3') {
168 }
else if (format[1] ==
'4') {
172 }
else if (format[1] ==
'5') {
176 }
else if (format[1] ==
'6') {
180 }
else if (format[1] ==
'7') {
189int Decoder::FormatFloatingRegister(Instruction*
instr,
const char* format) {
193 if (format[1] ==
'1') {
194 RRInstruction* rrinstr =
reinterpret_cast<RRInstruction*
>(
instr);
195 int reg = rrinstr->R1Value();
198 }
else if (format[1] ==
'2') {
199 RRInstruction* rrinstr =
reinterpret_cast<RRInstruction*
>(
instr);
200 int reg = rrinstr->R2Value();
203 }
else if (format[1] ==
'3') {
204 RRDInstruction* rrdinstr =
reinterpret_cast<RRDInstruction*
>(
instr);
205 int reg = rrdinstr->R1Value();
208 }
else if (format[1] ==
'5') {
209 RREInstruction* rreinstr =
reinterpret_cast<RREInstruction*
>(
instr);
210 int reg = rreinstr->R1Value();
213 }
else if (format[1] ==
'6') {
214 RREInstruction* rreinstr =
reinterpret_cast<RREInstruction*
>(
instr);
215 int reg = rreinstr->R2Value();
218 }
else if (format[1] ==
'4') {
219 VRR_E_Instruction* vrreinstr =
reinterpret_cast<VRR_E_Instruction*
>(
instr);
220 int reg = vrreinstr->R4Value();
235 if (
instr->Bit(10) == 1) {
241 if (
instr->Bit(0) == 1) {
252 return FormatFloatingRegister(
instr, format);
255 return FormatImmediate(
instr, format);
265 if (
instr->Bit(0) == 1) {
272 if (
instr->Bit(1) == 1) {
280 if ((format[6] ==
'2') && (format[7] ==
'6')) {
281 int off = ((
instr->Bits(25, 2)) << 8) >> 6;
286 }
else if ((format[6] ==
'1') && (format[7] ==
'6')) {
287 int off = ((
instr->Bits(15, 2)) << 18) >> 16;
295 return FormatMask(
instr, format);
299 return FormatDisplacement(
instr, format);
309int Decoder::FormatMask(Instruction*
instr,
const char* format) {
312 if ((format[1] ==
'1')) {
313 value =
reinterpret_cast<RRInstruction*
>(
instr)->R1Value();
317 }
else if (format[1] ==
'2') {
318 value =
reinterpret_cast<RXInstruction*
>(
instr)->B2Value();
322 }
else if (format[1] ==
'3') {
323 value =
reinterpret_cast<RRFInstruction*
>(
instr)->M4Value();
327 }
else if (format[1] ==
'4') {
328 value =
reinterpret_cast<VRR_C_Instruction*
>(
instr)->M4Value();
332 }
else if (format[1] ==
'5') {
333 value =
reinterpret_cast<VRR_C_Instruction*
>(
instr)->M5Value();
337 }
else if (format[1] ==
'6') {
338 value =
reinterpret_cast<VRR_C_Instruction*
>(
instr)->M6Value();
347int Decoder::FormatDisplacement(Instruction*
instr,
const char* format) {
350 if (format[1] ==
'1') {
351 RSInstruction* rsinstr =
reinterpret_cast<RSInstruction*
>(
instr);
352 uint16_t value = rsinstr->D2Value();
357 }
else if (format[1] ==
'2') {
358 RXYInstruction* rxyinstr =
reinterpret_cast<RXYInstruction*
>(
instr);
359 int32_t value = rxyinstr->D2Value();
363 }
else if (format[1] ==
'4') {
364 SSInstruction* ssInstr =
reinterpret_cast<SSInstruction*
>(
instr);
365 uint16_t value = ssInstr->D2Value();
369 }
else if (format[1] ==
'3') {
370 SSInstruction* ssInstr =
reinterpret_cast<SSInstruction*
>(
instr);
371 uint16_t value = ssInstr->D1Value();
383int Decoder::FormatImmediate(Instruction*
instr,
const char* format) {
386 if (format[1] ==
'1') {
387 RIInstruction* riinstr =
reinterpret_cast<RIInstruction*
>(
instr);
388 int16_t value = riinstr->I2Value();
392 }
else if (format[1] ==
'2') {
393 RILInstruction* rilinstr =
reinterpret_cast<RILInstruction*
>(
instr);
394 int32_t value = rilinstr->I2Value();
398 }
else if (format[1] ==
'3') {
399 IInstruction* iinstr =
reinterpret_cast<IInstruction*
>(
instr);
400 int8_t value = iinstr->IValue();
404 }
else if (format[1] ==
'4') {
405 RIInstruction* riinstr =
reinterpret_cast<RIInstruction*
>(
instr);
406 int16_t value = riinstr->I2Value() * 2;
416 }
else if (format[1] ==
'5') {
417 RILInstruction* rilinstr =
reinterpret_cast<RILInstruction*
>(
instr);
418 int32_t value = rilinstr->I2Value() * 2;
428 }
else if (format[1] ==
'6') {
429 RIInstruction* riinstr =
reinterpret_cast<RIInstruction*
>(
instr);
430 uint16_t value = riinstr->I2UnsignedValue();
434 }
else if (format[1] ==
'7') {
435 RILInstruction* rilinstr =
reinterpret_cast<RILInstruction*
>(
instr);
436 uint32_t value = rilinstr->I2UnsignedValue();
440 }
else if (format[1] ==
'8') {
441 SSInstruction* ssinstr =
reinterpret_cast<SSInstruction*
>(
instr);
442 uint8_t value = ssinstr->Length();
446 }
else if (format[1] ==
'9') {
447 RIEInstruction* rie_instr =
reinterpret_cast<RIEInstruction*
>(
instr);
448 uint8_t value = rie_instr->I3Value();
452 }
else if (format[1] ==
'a') {
453 RIEInstruction* rie_instr =
reinterpret_cast<RIEInstruction*
>(
instr);
454 uint8_t value = rie_instr->I4Value();
458 }
else if (format[1] ==
'b') {
459 RIEInstruction* rie_instr =
reinterpret_cast<RIEInstruction*
>(
instr);
460 uint8_t value = rie_instr->I5Value();
464 }
else if (format[1] ==
'c') {
465 SSInstruction* ssinstr =
reinterpret_cast<SSInstruction*
>(
instr);
466 int8_t value = ssinstr->Length();
470 }
else if (format[1] ==
'd') {
471 SILInstruction* silinstr =
reinterpret_cast<SILInstruction*
>(
instr);
472 int16_t value = silinstr->I2Value();
476 }
else if (format[1] ==
'e') {
477 RILInstruction* rilinstr =
reinterpret_cast<RILInstruction*
>(
instr);
478 int32_t value = rilinstr->I2Value() * 2;
497 char cur = *format++;
511#define VERIFY(condition) \
512 if (!(condition)) { \
524void Decoder::UnknownFormat(Instruction*
instr,
const char* name) {
526 snprintf(buffer,
sizeof(buffer),
"%s (unknown-format)", name);
531#undef STRING_STARTS_WITH
535bool Decoder::DecodeSpecial(Instruction*
instr) {
726bool Decoder::DecodeGeneric(Instruction*
instr) {
730#define DECODE_RR_INSTRUCTIONS(name, opcode_name, opcode_value) \
732 Format(instr, #name "\t'r1,'r2"); \
735#undef DECODE_RR_INSTRUCTIONS
738#define DECODE_RS_A_INSTRUCTIONS(name, opcode_name, opcode_value) \
740 Format(instr, #name "\t'r1,'r2,'d1('r3)"); \
743#undef DECODE_RS_A_INSTRUCTIONS
745#define DECODE_RSI_INSTRUCTIONS(name, opcode_name, opcode_value) \
747 Format(instr, #name "\t'r1,'r2,'i4"); \
750#undef DECODE_RSI_INSTRUCTIONS
752#define DECODE_RI_A_INSTRUCTIONS(name, opcode_name, opcode_value) \
754 Format(instr, #name "\t'r1,'i1"); \
757#undef DECODE_RI_A_INSTRUCTIONS
759#define DECODE_RI_B_INSTRUCTIONS(name, opcode_name, opcode_value) \
761 Format(instr, #name "\t'r1,'i4"); \
764#undef DECODE_RI_B_INSTRUCTIONS
766#define DECODE_RI_C_INSTRUCTIONS(name, opcode_name, opcode_value) \
768 Format(instr, #name "\t'm1,'i4"); \
771#undef DECODE_RI_C_INSTRUCTIONS
773#define DECODE_RRE_INSTRUCTIONS(name, opcode_name, opcode_value) \
775 Format(instr, #name "\t'r5,'r6"); \
778#undef DECODE_RRE_INSTRUCTIONS
780#define DECODE_RRF_A_INSTRUCTIONS(name, opcode_name, opcode_val) \
782 Format(instr, #name "\t'r5,'r6,'r3"); \
785#undef DECODE_RRF_A_INSTRUCTIONS
787#define DECODE_RRF_C_INSTRUCTIONS(name, opcode_name, opcode_val) \
789 Format(instr, #name "\t'r5,'r6,'m2"); \
792#undef DECODE_RRF_C_INSTRUCTIONS
794#define DECODE_RRF_E_INSTRUCTIONS(name, opcode_name, opcode_val) \
796 Format(instr, #name "\t'r5,'m2,'f6"); \
799#undef DECODE_RRF_E_INSTRUCTIONS
801#define DECODE_RX_A_INSTRUCTIONS(name, opcode_name, opcode_value) \
803 Format(instr, #name "\t'r1,'d1('r2d,'r3)"); \
806#undef DECODE_RX_A_INSTRUCTIONS
808#define DECODE_RX_B_INSTRUCTIONS(name, opcode_name, opcode_value) \
810 Format(instr, #name "\t'm1,'d1('r2d,'r3)"); \
813#undef DECODE_RX_B_INSTRUCTIONS
815#define DECODE_RRD_INSTRUCTIONS(name, opcode_name, opcode_value) \
817 Format(instr, #name "\t'f3,'f5,'f6"); \
820#undef DECODE_RRD_INSTRUCTIONS
822#define DECODE_SI_INSTRUCTIONS(name, opcode_name, opcode_value) \
824 Format(instr, #name "\t'd1('r3),'i8"); \
827#undef DECODE_SI_INSTRUCTIONS
830#define DECODE_VRR_A_INSTRUCTIONS(name, opcode_name, opcode_value) \
832 Format(instr, #name "\t'f1,'f2,'m4,'m5,'m6"); \
835#undef DECODE_VRR_A_INSTRUCTIONS
837#define DECODE_VRR_B_INSTRUCTIONS(name, opcode_name, opcode_value) \
839 Format(instr, #name "\t'f1,'f2,'f3,'m4,'m6"); \
842#undef DECODE_VRR_B_INSTRUCTIONS
844#define DECODE_VRR_C_INSTRUCTIONS(name, opcode_name, opcode_value) \
846 Format(instr, #name "\t'f1,'f2,'f3,'m4"); \
849#undef DECODE_VRR_C_INSTRUCTIONS
851#define DECODE_VRR_E_INSTRUCTIONS(name, opcode_name, opcode_value) \
853 Format(instr, #name "\t'f1,'f2,'f3,'f4,'m5,'m3"); \
856#undef DECODE_VRR_E_INSTRUCTIONS
858#define DECODE_VRR_F_INSTRUCTIONS(name, opcode_name, opcode_value) \
860 Format(instr, #name "\t'f1,'r1,'r2"); \
863#undef DECODE_VRR_F_INSTRUCTIONS
865#define DECODE_VRX_INSTRUCTIONS(name, opcode_name, opcode_value) \
867 Format(instr, #name "\t'f1,'d1('r2d,'r3),'m4"); \
870#undef DECODE_VRX_INSTRUCTIONS
872#define DECODE_VRS_A_INSTRUCTIONS(name, opcode_name, opcode_value) \
874 Format(instr, #name "\t'f1,'f2,'d1('r3),'m4"); \
877#undef DECODE_VRS_A_INSTRUCTIONS
879#define DECODE_VRS_B_INSTRUCTIONS(name, opcode_name, opcode_value) \
881 Format(instr, #name "\t'f1,'r2,'d1('r3),'m4"); \
884#undef DECODE_VRS_B_INSTRUCTIONS
886#define DECODE_VRS_C_INSTRUCTIONS(name, opcode_name, opcode_value) \
888 Format(instr, #name "\t'r1,'f2,'d1('r3),'m4"); \
891#undef DECODE_VRS_C_INSTRUCTIONS
893#define DECODE_VRI_A_INSTRUCTIONS(name, opcode_name, opcode_value) \
895 Format(instr, #name "\t'f1,'i1,'m4"); \
898#undef DECODE_VRI_A_INSTRUCTIONS
900#define DECODE_VRI_C_INSTRUCTIONS(name, opcode_name, opcode_value) \
902 Format(instr, #name "\t'f1,'f2,'i1,'m4"); \
905#undef DECODE_VRI_C_INSTRUCTIONS
907#define DECODE_RIL_A_INSTRUCTIONS(name, opcode_name, opcode_value) \
909 Format(instr, #name "\t'r1,'i7"); \
912#undef DECODE_RIL_A_INSTRUCTIONS
914#define DECODE_RIL_B_INSTRUCTIONS(name, opcode_name, opcode_value) \
916 Format(instr, #name "\t'r1,'ie"); \
919#undef DECODE_RIL_B_INSTRUCTIONS
921#define DECODE_RIL_C_INSTRUCTIONS(name, opcode_name, opcode_value) \
923 Format(instr, #name "\t'm1,'ie"); \
926#undef DECODE_RIL_C_INSTRUCTIONS
928#define DECODE_SIY_INSTRUCTIONS(name, opcode_name, opcode_value) \
930 Format(instr, #name "\t'd2('r3),'i8"); \
933#undef DECODE_SIY_INSTRUCTIONS
935#define DECODE_RIE_D_INSTRUCTIONS(name, opcode_name, opcode_value) \
937 Format(instr, #name "\t'r1,'r2,'i1"); \
940#undef DECODE_RIE_D_INSTRUCTIONS
942#define DECODE_RIE_E_INSTRUCTIONS(name, opcode_name, opcode_value) \
944 Format(instr, #name "\t'r1,'r2,'i4"); \
947#undef DECODE_RIE_E_INSTRUCTIONS
949#define DECODE_RIE_F_INSTRUCTIONS(name, opcode_name, opcode_value) \
951 Format(instr, #name "\t'r1,'r2,'i9,'ia,'ib"); \
954#undef DECODE_RIE_F_INSTRUCTIONS
956#define DECODE_RSY_A_INSTRUCTIONS(name, opcode_name, opcode_value) \
958 Format(instr, #name "\t'r1,'r2,'d2('r3)"); \
961#undef DECODE_RSY_A_INSTRUCTIONS
963#define DECODE_RSY_B_INSTRUCTIONS(name, opcode_name, opcode_value) \
965 Format(instr, #name "\t'm2,'r1,'d2('r3)"); \
968#undef DECODE_RSY_B_INSTRUCTIONS
970#define DECODE_RXY_A_INSTRUCTIONS(name, opcode_name, opcode_value) \
972 Format(instr, #name "\t'r1,'d2('r2d,'r3)"); \
975#undef DECODE_RXY_A_INSTRUCTIONS
977#define DECODE_RXY_B_INSTRUCTIONS(name, opcode_name, opcode_value) \
979 Format(instr, #name "\t'm1,'d2('r2d,'r3)"); \
982#undef DECODE_RXY_B_INSTRUCTIONS
984#define DECODE_RXE_INSTRUCTIONS(name, opcode_name, opcode_value) \
986 Format(instr, #name "\t'f1,'d1('r2d, 'r3)"); \
989#undef DECODE_RXE_INSTRUCTIONS
991#define DECODE_SIL_INSTRUCTIONS(name, opcode_name, opcode_value) \
993 Format(instr, #name "\t'd3('r3),'id"); \
996#undef DECODE_SIL_INSTRUCTIONS
998#define DECODE_SS_A_INSTRUCTIONS(name, opcode_name, opcode_value) \
1000 Format(instr, #name "\t'd3('i8,'r3),'d4('r7)"); \
1003#undef DECODE_SS_A_INSTRUCTIONS
1014 int instrLength =
instr->InstructionLength();
1017 if (instrLength == 2) {
1021 }
else if (instrLength == 4) {
1031 bool decoded = DecodeSpecial(
instr);
1032 if (!decoded) decoded = DecodeGeneric(
instr);
1054 return RegisterName(i::Register::from_code(
reg));
1076 uint8_t* instruction) {
1078 return d.InstructionDecode(instruction);
1085 UnimplementedOpcodeAction unimplemented_action) {
1086 NameConverter converter;
1088 for (uint8_t*
pc = begin;
pc <
end;) {
1091 uint8_t* prev_pc =
pc;
1092 pc += d.InstructionDecode(buffer,
pc);
static V8_EXPORT_PRIVATE void Disassemble(FILE *f, uint8_t *begin, uint8_t *end, UnimplementedOpcodeAction unimplemented_action=kAbortOnUnimplementedOpcode)
V8_EXPORT_PRIVATE int InstructionDecode(v8::base::Vector< char > buffer, uint8_t *instruction)
int ConstantPoolSizeAt(uint8_t *instruction)
Disassembler(const NameConverter &converter, UnimplementedOpcodeAction unimplemented_opcode_action=kAbortOnUnimplementedOpcode)
const NameConverter & converter_
virtual const char * NameOfAddress(uint8_t *addr) const
virtual const char * NameOfXMMRegister(int reg) const
virtual const char * NameInCode(uint8_t *addr) const
virtual const char * NameOfConstant(uint8_t *addr) const
v8::base::EmbeddedVector< char, 128 > tmp_buffer_
virtual const char * NameOfByteCPURegister(int reg) const
virtual const char * NameOfCPURegister(int reg) const
constexpr T * begin() const
void Format(Instruction *instr, const char *format)
int InstructionDecode(uint8_t *instruction)
void Unknown(Instruction *instr)
const disasm::NameConverter & converter_
void PrintRegister(int reg)
void PrintChar(const char ch)
v8::base::Vector< char > out_buffer_
int FormatOption(Instruction *instr, const char *option)
int FormatRegister(Instruction *instr, const char *option)
void Print(const char *str)
Decoder & operator=(const Decoder &)=delete
static Instruction * At(Address pc)
static constexpr DwVfpRegister from_code(int8_t code)
#define SIGN_EXT_IMM16(imm)
#define S390_RIE_E_OPCODE_LIST(V)
#define S390_RRD_OPCODE_LIST(V)
#define S390_RX_B_OPCODE_LIST(V)
#define S390_VRR_E_OPCODE_LIST(V)
#define S390_SIY_OPCODE_LIST(V)
#define S390_RRF_A_OPCODE_LIST(V)
#define S390_VRI_A_OPCODE_LIST(V)
#define S390_VRI_C_OPCODE_LIST(V)
#define S390_RRF_C_OPCODE_LIST(V)
#define S390_RRE_OPCODE_LIST(V)
#define S390_VRR_C_OPCODE_LIST(V)
#define S390_SS_A_OPCODE_LIST(V)
#define S390_RSY_B_OPCODE_LIST(V)
#define S390_RXE_OPCODE_LIST(V)
#define S390_VRS_A_OPCODE_LIST(V)
#define S390_RIE_F_OPCODE_LIST(V)
#define S390_VRR_A_OPCODE_LIST(V)
#define S390_RXY_A_OPCODE_LIST(V)
#define S390_VRS_B_OPCODE_LIST(V)
#define S390_RI_B_OPCODE_LIST(V)
#define S390_RS_A_OPCODE_LIST(V)
#define S390_RSY_A_OPCODE_LIST(V)
#define S390_RI_A_OPCODE_LIST(V)
#define S390_VRR_F_OPCODE_LIST(V)
#define S390_VRR_B_OPCODE_LIST(V)
#define S390_SIL_OPCODE_LIST(V)
#define S390_RXY_B_OPCODE_LIST(V)
#define S390_RIL_A_OPCODE_LIST(V)
#define S390_RIL_B_OPCODE_LIST(V)
#define S390_VRS_C_OPCODE_LIST(V)
#define S390_RRF_E_OPCODE_LIST(V)
#define S390_RIL_C_OPCODE_LIST(V)
#define S390_RIE_D_OPCODE_LIST(V)
#define S390_VRX_OPCODE_LIST(V)
#define S390_RI_C_OPCODE_LIST(V)
#define S390_RX_A_OPCODE_LIST(V)
#define S390_SI_OPCODE_LIST(V)
#define S390_RSI_OPCODE_LIST(V)
#define S390_RR_OPCODE_LIST(V)
#define STRING_STARTS_WITH(string, compare_string)
int SNPrintF(Vector< char > str, const char *format,...)
constexpr BarrierOption LD
constexpr SoftwareInterruptCodes kStopCode
void PrintF(const char *format,...)
constexpr MiscInstructionsBits74 BKPT
constexpr SoftwareInterruptCodes kBreakpoint
constexpr SoftwareInterruptCodes kCallRtRedirected
constexpr uint32_t kStopCodeMask
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)