30#if V8_TARGET_ARCH_PPC64
65 enum PrefixType { not_prefixed, is_prefixed };
67 static PrefixType PrefixStatus;
68 static uint64_t PrefixValue;
69 uint64_t GetPrefixValue();
70 void SetAsPrefixed(uint64_t v);
77 void Print(
const char* str);
81 void PrintDRegister(
int reg);
82 void PrintVectorRegister(
int reg);
83 int FormatFPRegister(Instruction*
instr,
const char* format);
84 int FormatVectorRegister(Instruction*
instr,
const char* format);
86 const char* NameOfVectorRegister(
int reg)
const;
91 void Format(Instruction*
instr,
const char* format);
93 void UnknownFormat(Instruction*
instr,
const char* opcname);
95 void DecodeExtP(Instruction*
instr);
96 void DecodeExt0(Instruction*
instr);
97 void DecodeExt1(Instruction*
instr);
98 void DecodeExt2(Instruction*
instr);
99 void DecodeExt3(Instruction*
instr);
100 void DecodeExt4(Instruction*
instr);
101 void DecodeExt5(Instruction*
instr);
102 void DecodeExt6(Instruction*
instr);
111Decoder::PrefixType Decoder::PrefixStatus = not_prefixed;
112uint64_t Decoder::PrefixValue = 0;
114uint64_t Decoder::GetPrefixValue() {
return PrefixValue; }
116void Decoder::SetAsPrefixed(uint64_t v) {
117 PrefixStatus = is_prefixed;
121void Decoder::ResetPrefix() {
122 PrefixStatus = not_prefixed;
126bool Decoder::IsPrefixed() {
return PrefixStatus == is_prefixed; }
129#define STRING_STARTS_WITH(string, compare_string) \
130 (strncmp(string, compare_string, strlen(compare_string)) == 0)
151void Decoder::PrintDRegister(
int reg) {
156void Decoder::PrintVectorRegister(
int reg) {
165 Print(
"call rt redirected");
188 if ((format[1] ==
't') || (format[1] ==
's')) {
192 }
else if (format[1] ==
'a') {
196 }
else if (format[1] ==
'b') {
207int Decoder::FormatFPRegister(Instruction*
instr,
const char* format) {
208 DCHECK(format[0] ==
'D' || format[0] ==
'X');
212 if (format[1] ==
't' || format[1] ==
's') {
214 }
else if (format[1] ==
'a') {
216 }
else if (format[1] ==
'b') {
218 }
else if (format[1] ==
'c') {
229int Decoder::FormatVectorRegister(Instruction*
instr,
const char* format) {
232 if (format[1] ==
't' || format[1] ==
's') {
234 }
else if (format[1] ==
'a') {
236 }
else if (format[1] ==
'b') {
238 }
else if (format[1] ==
'c') {
244 PrintVectorRegister(
reg);
257 if (
instr->Bit(10) == 1) {
263 if (
instr->Bit(0) == 1) {
274 return FormatFPRegister(
instr, format);
278 if (
instr->Bit(0) == 1) {
279 return FormatVectorRegister(
instr, format);
282 return FormatFPRegister(
instr, format);
285 return FormatVectorRegister(
instr, format);
289 uint32_t imm_value =
instr->Bits(15, 0);
291 uint64_t prefix_value = GetPrefixValue();
294 value = (
static_cast<int64_t
>(imm_value) << 48) >> 48;
301 int8_t value =
instr->Bits(18, 11);
313 uint8_t value =
instr->Bits(19, 12);
325 uint8_t value =
instr->Bits(19, 16);
332 if (
instr->Bit(0) == 1) {
339 if (
instr->Bit(1) == 1) {
345 int code =
instr->Bits(20, 18);
355 if ((format[6] ==
'2') && (format[7] ==
'6')) {
356 int off = ((
instr->Bits(25, 2)) << 8) >> 6;
361 }
else if ((format[6] ==
'1') && (format[7] ==
'6')) {
362 int off = ((
instr->Bits(15, 2)) << 18) >> 16;
374 if (opcode ==
EXT5 ||
375 (opcode ==
EXT2 &&
instr->Bits(10, 2) << 2 == SRADIX)) {
377 value = (sh | (
instr->Bit(1) << 5));
380 value = (sh << 26) >> 26;
388 if (format[1] ==
'e') {
389 if (
instr->OpcodeValue() << 26 !=
EXT5) {
391 value = (
instr->Bits(10, 6) << 26) >> 26;
394 value = (
instr->Bits(10, 6) | (
instr->Bit(5) << 5));
396 }
else if (format[1] ==
'b') {
397 if (
instr->OpcodeValue() << 26 !=
EXT5) {
399 value = (
instr->Bits(5, 1) << 26) >> 26;
402 value = (
instr->Bits(10, 6) | (
instr->Bit(5) << 5));
430 char cur = *format++;
444#define VERIFY(condition) \
445 if (!(condition)) { \
457void Decoder::UnknownFormat(Instruction*
instr,
const char* name) {
459 snprintf(buffer,
sizeof(buffer),
"%s (unknown-format)", name);
463void Decoder::DecodeExtP(Instruction*
instr) {
464 switch (
EXTP | (
instr->BitField(25, 25))) {
465 case PLOAD_STORE_8LS:
466 case PLOAD_STORE_MLS: {
470 SetAsPrefixed(
instr->Bits(17, 0));
472 Instruction* next_instr =
reinterpret_cast<Instruction*
>(
474 switch (next_instr->OpcodeBase()) {
477 if (next_instr->RAValue() == 0) {
480 Format(next_instr,
" 'rt, ");
483 Format(next_instr,
" 'rt, 'ra, ");
485 Format(next_instr,
"'int34");
490 Format(next_instr,
"plbz 'rt, 'int34('ra)");
495 Format(next_instr,
"plhz 'rt, 'int34('ra)");
500 Format(next_instr,
"plha 'rt, 'int34('ra)");
505 Format(next_instr,
"plwz 'rt, 'int34('ra)");
510 Format(next_instr,
"plwa 'rt, 'int34('ra)");
515 Format(next_instr,
"pld 'rt, 'int34('ra)");
520 Format(next_instr,
"plfs 'Dt, 'int34('ra)");
525 Format(next_instr,
"plfd 'Dt, 'int34('ra)");
530 Format(next_instr,
"pstb 'rs, 'int34('ra)");
535 Format(next_instr,
"psth 'rs, 'int34('ra)");
540 Format(next_instr,
"pstw 'rs, 'int34('ra)");
545 Format(next_instr,
"pstd 'rs, 'int34('ra)");
550 Format(next_instr,
"pstfs 'Dt, 'int34('ra)");
555 Format(next_instr,
"pstfd 'Dt, 'int34('ra)");
570void Decoder::DecodeExt0(Instruction*
instr) {
572 switch (
EXT0 | (
instr->BitField(20, 16)) | (
instr->BitField(10, 0))) {
573#define DECODE_VX_D_FORM__INSTRUCTIONS(name, opcode_name, opcode_value) \
574 case opcode_name: { \
575 Format(instr, #name " 'Vt, 'Vb"); \
579#undef DECODE_VX_D_FORM__INSTRUCTIONS
580#define DECODE_VX_F_FORM__INSTRUCTIONS(name, opcode_name, opcode_value) \
581 case opcode_name: { \
582 Format(instr, #name " 'rt, 'Vb"); \
586#undef DECODE_VX_F_FORM__INSTRUCTIONS
589 switch (
EXT0 | (
instr->BitField(5, 0))) {
590#define DECODE_VA_A_FORM__INSTRUCTIONS(name, opcode_name, opcode_value) \
591 case opcode_name: { \
592 Format(instr, #name " 'Vt, 'Va, 'Vb, 'Vc"); \
596#undef DECODE_VA_A_FORM__INSTRUCTIONS
598 switch (
EXT0 | (
instr->BitField(9, 0))) {
600#define DECODE_VC_FORM__INSTRUCTIONS(name, opcode_name, opcode_value) \
601 case opcode_name: { \
602 Format(instr, #name " 'Vt, 'Va, 'Vb"); \
606#undef DECODE_VC_FORM__INSTRUCTIONS
608 switch (
EXT0 | (
instr->BitField(10, 0))) {
609#define DECODE_VX_A_FORM__INSTRUCTIONS(name, opcode_name, opcode_value) \
610 case opcode_name: { \
611 Format(instr, #name " 'Vt, 'Vb, 'UIM"); \
615#undef DECODE_VX_A_FORM__INSTRUCTIONS
616#define DECODE_VX_B_FORM__INSTRUCTIONS(name, opcode_name, opcode_value) \
617 case opcode_name: { \
618 Format(instr, #name " 'Vt, 'Va, 'Vb"); \
622#undef DECODE_VX_B_FORM__INSTRUCTIONS
623#define DECODE_VX_C_FORM__INSTRUCTIONS(name, opcode_name, opcode_value) \
624 case opcode_name: { \
625 Format(instr, #name " 'Vt, 'Vb"); \
629#undef DECODE_VX_C_FORM__INSTRUCTIONS
630#define DECODE_VX_E_FORM__INSTRUCTIONS(name, opcode_name, opcode_value) \
631 case opcode_name: { \
632 Format(instr, #name " 'Vt, 'SIM"); \
636#undef DECODE_VX_E_FORM__INSTRUCTIONS
637#define DECODE_VX_G_FORM__INSTRUCTIONS(name, opcode_name, opcode_value) \
638 case opcode_name: { \
639 Format(instr, #name " 'Vt, 'rb, 'UIM"); \
643#undef DECODE_VX_G_FORM__INSTRUCTIONS
647void Decoder::DecodeExt1(Instruction*
instr) {
648 switch (
EXT1 | (
instr->BitField(10, 1))) {
650 UnknownFormat(
instr,
"mcrf");
654 int bo =
instr->BitField(25, 21);
655 int bi =
instr->Bits(20, 16);
659 UnknownFormat(
instr,
"bclrx-dcbnzf");
663 UnknownFormat(
instr,
"bclrx-dcbezf");
684 UnknownFormat(
instr,
"bclrx-dcbbzt");
688 UnknownFormat(
instr,
"bclrx-dcbnezt");
709 UnknownFormat(
instr,
"bclrx-dcbnz");
713 UnknownFormat(
instr,
"bclrx-dcbez");
724 switch (
instr->BitField(25, 21)) {
726 UnknownFormat(
instr,
"bcctrx-dcbnzf");
730 UnknownFormat(
instr,
"bcctrx-dcbezf");
734 UnknownFormat(
instr,
"bcctrx-bf");
738 UnknownFormat(
instr,
"bcctrx-dcbnzt");
742 UnknownFormat(
instr,
"bcctrx-dcbezf");
746 UnknownFormat(
instr,
"bcctrx-bt");
750 UnknownFormat(
instr,
"bcctrx-dcbnz");
754 UnknownFormat(
instr,
"bcctrx-dcbez");
758 if (
instr->Bit(0) == 1) {
792 UnknownFormat(
instr,
"crnand");
796 UnknownFormat(
instr,
"crand");
800 UnknownFormat(
instr,
"creqv");
804 UnknownFormat(
instr,
"crorc");
808 UnknownFormat(
instr,
"cror");
817void Decoder::DecodeExt2(Instruction*
instr) {
819 switch (
EXT2 | (
instr->BitField(10, 1))) {
970 switch (
EXT2 | (
instr->BitField(10, 2))) {
977 switch (
EXT2 | (
instr->BitField(10, 0))) {
997 switch (
EXT2 | (
instr->BitField(10, 1))) {
999 if (
instr->Bit(21)) {
1067 if (
instr->Bit(21)) {
1131 int spr =
instr->Bits(20, 11);
1140 int spr =
instr->Bits(20, 11);
1143 }
else if (288 == spr) {
1296 switch (
EXT2 | (
instr->BitField(5, 1))) {
1307void Decoder::DecodeExt3(Instruction*
instr) {
1308 switch (
EXT3 | (
instr->BitField(10, 1))) {
1331void Decoder::DecodeExt4(Instruction*
instr) {
1332 switch (
EXT4 | (
instr->BitField(5, 1))) {
1367 switch (
EXT4 | (
instr->BitField(10, 1))) {
1474void Decoder::DecodeExt5(Instruction*
instr) {
1475 switch (
EXT5 | (
instr->BitField(4, 2))) {
1493 switch (
EXT5 | (
instr->BitField(4, 1))) {
1502void Decoder::DecodeExt6(Instruction*
instr) {
1503 switch (
EXT6 | (
instr->BitField(10, 1))) {
1509 switch (
EXT6 | (
instr->BitField(10, 3))) {
1510#define DECODE_XX3_VECTOR_B_FORM_INSTRUCTIONS(name, opcode_name, opcode_value) \
1511 case opcode_name: { \
1512 Format(instr, #name " 'Xt, 'Xa, 'Xb"); \
1516#undef DECODE_XX3_VECTOR_B_FORM_INSTRUCTIONS
1517#define DECODE_XX3_SCALAR_INSTRUCTIONS(name, opcode_name, opcode_value) \
1518 case opcode_name: { \
1519 Format(instr, #name " 'Dt, 'Da, 'Db"); \
1523#undef DECODE_XX3_SCALAR_INSTRUCTIONS
1526 switch (
EXT6 | (
instr->BitField(20, 16)) | (
instr->BitField(10, 2))) {
1527#define DECODE_XX2_B_INSTRUCTIONS(name, opcode_name, opcode_value) \
1528 case opcode_name: { \
1529 Format(instr, #name " 'Xt, 'Xb"); \
1533#undef DECODE_XX2_B_INSTRUCTIONS
1535 switch (
EXT6 | (
instr->BitField(10, 2))) {
1536#define DECODE_XX2_VECTOR_A_INSTRUCTIONS(name, opcode_name, opcode_value) \
1537 case opcode_name: { \
1538 Format(instr, #name " 'Xt, 'Xb"); \
1542#undef DECODE_XX2_VECTOR_A_INSTRUCTIONS
1543#define DECODE_XX2_SCALAR_A_INSTRUCTIONS(name, opcode_name, opcode_value) \
1544 case opcode_name: { \
1545 Format(instr, #name " 'Dt, 'Db"); \
1549#undef DECODE_XX2_SCALAR_A_INSTRUCTIONS
1560 uint32_t opcode =
instr->OpcodeValue() << 26;
1562 if (opcode !=
EXTP) {
1564 "%08x ",
instr->InstructionBits());
1568 Instruction* next_instr =
reinterpret_cast<Instruction*
>(
1572 instr->InstructionBits(), next_instr->InstructionBits());
1584 PrintSoftwareInterrupt(
instr->SvcValue());
1588 UnknownFormat(
instr,
"mulli");
1596 if (
instr->Bit(21)) {
1604 if (
instr->Bit(21)) {
1616 UnknownFormat(
instr,
"addicx");
1620 if (
instr->RAValue() == 0) {
1629 if (
instr->RAValue() == 0) {
1637 int bo =
instr->Bits(25, 21) << 21;
1638 int bi =
instr->Bits(20, 16);
1686 UnknownFormat(
instr,
"sc");
1706 Format(
instr,
"rlwimi'. 'ra, 'rs, 'sh, 'me, 'mb");
1710 Format(
instr,
"rlwinm'. 'ra, 'rs, 'sh, 'me, 'mb");
1802 UnknownFormat(
instr,
"lmw");
1806 UnknownFormat(
instr,
"stmw");
1858 switch (
instr->Bits(1, 0)) {
1872 if (
instr->Bit(0) == 0) {
1911 return RegisterName(i::Register::from_code(
reg));
1931 uint8_t* instruction) {
1933 return d.InstructionDecode(instruction);
1940 UnimplementedOpcodeAction unimplemented_action) {
1941 NameConverter converter;
1943 for (uint8_t*
pc = begin;
pc <
end;) {
1946 uint8_t* prev_pc =
pc;
1947 pc += d.InstructionDecode(buffer,
pc);
1953#undef STRING_STARTS_WITH
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 PPC_VX_OPCODE_A_FORM_LIST(V)
#define PPC_VX_OPCODE_G_FORM_LIST(V)
#define PPC_VA_OPCODE_A_FORM_LIST(V)
#define PPC_VX_OPCODE_C_FORM_LIST(V)
#define SIGN_EXT_IMM5(imm)
#define PPC_VX_OPCODE_B_FORM_LIST(V)
#define PPC_VX_OPCODE_D_FORM_LIST(V)
#define PPC_XX3_OPCODE_SCALAR_LIST(V)
#define SIGN_EXT_IMM16(imm)
#define PPC_XX2_OPCODE_VECTOR_A_FORM_LIST(V)
#define SIGN_EXT_IMM34(imm)
#define PPC_XX3_OPCODE_VECTOR_B_FORM_LIST(V)
#define PPC_VX_OPCODE_E_FORM_LIST(V)
#define PPC_VC_OPCODE_LIST(V)
#define PPC_VX_OPCODE_F_FORM_LIST(V)
#define PPC_XX2_OPCODE_B_FORM_LIST(V)
#define PPC_XX2_OPCODE_SCALAR_A_FORM_LIST(V)
#define ABI_USES_FUNCTION_DESCRIPTORS
#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 FPDataProcessing2SourceOp FSUB
constexpr FPDataProcessing1SourceOp FABS
constexpr SoftwareInterruptCodes kBreakpoint
constexpr SoftwareInterruptCodes kCallRtRedirected
constexpr FPDataProcessing2SourceOp FDIV
constexpr FPDataProcessing2SourceOp FADD
constexpr FPDataProcessing1SourceOp FNEG
constexpr uint8_t kInstrSize
constexpr MiscInstructionsBits74 BX
constexpr FPDataProcessing2SourceOp FMUL
constexpr FPDataProcessing1SourceOp FSQRT
constexpr uint32_t kStopCodeMask
#define DCHECK_NE(v1, v2)
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)