33 #if V8_TARGET_ARCH_ARM
53 Vector<char> out_buffer)
54 : converter_(converter),
55 out_buffer_(out_buffer),
57 out_buffer_[out_buffer_pos_] =
'\0';
64 int InstructionDecode(
byte* instruction);
66 static bool IsConstantPoolAt(
byte* instr_ptr);
67 static int ConstantPoolSizeAt(
byte* instr_ptr);
71 void PrintChar(
const char ch);
72 void Print(
const char* str);
75 void PrintRegister(
int reg);
76 void PrintSRegister(
int reg);
77 void PrintDRegister(
int reg);
78 int FormatVFPRegister(Instruction* instr,
const char* format);
79 void PrintMovwMovt(Instruction* instr);
80 int FormatVFPinstruction(Instruction* instr,
const char* format);
81 void PrintCondition(Instruction* instr);
82 void PrintShiftRm(Instruction* instr);
83 void PrintShiftImm(Instruction* instr);
84 void PrintShiftSat(Instruction* instr);
85 void PrintPU(Instruction* instr);
89 int FormatRegister(Instruction* instr,
const char* option);
90 void FormatNeonList(
int Vd,
int type);
91 void FormatNeonMemory(
int Rn,
int align,
int Rm);
92 int FormatOption(Instruction* instr,
const char* option);
93 void Format(Instruction* instr,
const char* format);
94 void Unknown(Instruction* instr);
100 void DecodeType01(Instruction* instr);
101 void DecodeType2(Instruction* instr);
102 void DecodeType3(Instruction* instr);
103 void DecodeType4(Instruction* instr);
104 void DecodeType5(Instruction* instr);
105 void DecodeType6(Instruction* instr);
107 int DecodeType7(Instruction* instr);
109 void DecodeTypeVFP(Instruction* instr);
110 void DecodeType6CoprocessorIns(Instruction* instr);
112 void DecodeSpecialCondition(Instruction* instr);
114 void DecodeVMOVBetweenCoreAndSinglePrecisionRegisters(Instruction* instr);
115 void DecodeVCMP(Instruction* instr);
116 void DecodeVCVTBetweenDoubleAndSingle(Instruction* instr);
117 void DecodeVCVTBetweenFloatingPointAndInteger(Instruction* instr);
120 Vector<char> out_buffer_;
128 #define STRING_STARTS_WITH(string, compare_string) \
129 (strncmp(string, compare_string, strlen(compare_string)) == 0)
133 void Decoder::PrintChar(
const char ch) {
134 out_buffer_[out_buffer_pos_++] = ch;
139 void Decoder::Print(
const char* str) {
141 while (cur !=
'\0' && (out_buffer_pos_ < (out_buffer_.length() - 1))) {
145 out_buffer_[out_buffer_pos_] = 0;
152 "eq",
"ne",
"cs" ,
"cc" ,
"mi" ,
"pl" ,
"vs" ,
"vc" ,
153 "hi",
"ls",
"ge",
"lt",
"gt",
"le",
"",
"invalid",
158 void Decoder::PrintCondition(Instruction* instr) {
159 Print(cond_names[instr->ConditionValue()]);
164 void Decoder::PrintRegister(
int reg) {
165 Print(converter_.NameOfCPURegister(reg));
170 void Decoder::PrintSRegister(
int reg) {
176 void Decoder::PrintDRegister(
int reg) {
184 "lsl",
"lsr",
"asr",
"ror"
190 void Decoder::PrintShiftRm(Instruction* instr) {
192 int shift_index = instr->ShiftValue();
193 int shift_amount = instr->ShiftAmountValue();
194 int rm = instr->RmValue();
198 if ((instr->RegShiftValue() == 0) && (
shift ==
LSL) && (shift_amount == 0)) {
202 if (instr->RegShiftValue() == 0) {
204 if ((
shift ==
ROR) && (shift_amount == 0)) {
210 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
212 shift_names[shift_index],
216 int rs = instr->RsValue();
217 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
218 ", %s ", shift_names[shift_index]);
226 void Decoder::PrintShiftImm(Instruction* instr) {
227 int rotate = instr->RotateValue() * 2;
228 int immed8 = instr->Immed8Value();
229 int imm = (immed8 >> rotate) | (immed8 << (32 - rotate));
230 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
"#%d", imm);
235 void Decoder::PrintShiftSat(Instruction* instr) {
236 int shift = instr->Bits(11, 7);
238 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
240 shift_names[instr->Bit(6) * 2],
247 void Decoder::PrintPU(Instruction* instr) {
248 switch (instr->PUField()) {
278 Print(
"call rt redirected");
285 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
290 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
301 int Decoder::FormatRegister(Instruction* instr,
const char* format) {
303 if (format[1] ==
'n') {
304 int reg = instr->RnValue();
307 }
else if (format[1] ==
'd') {
308 int reg = instr->RdValue();
311 }
else if (format[1] ==
's') {
312 int reg = instr->RsValue();
315 }
else if (format[1] ==
'm') {
316 int reg = instr->RmValue();
319 }
else if (format[1] ==
't') {
320 int reg = instr->RtValue();
323 }
else if (format[1] ==
'l') {
325 DCHECK(STRING_STARTS_WITH(format,
"rlist"));
326 int rlist = instr->RlistValue();
331 if ((rlist & 1) != 0) {
333 if ((rlist >> 1) != 0) {
350 int Decoder::FormatVFPRegister(Instruction* instr,
const char* format) {
351 DCHECK((format[0] ==
'S') || (format[0] ==
'D'));
358 if (format[1] ==
'n') {
359 reg = instr->VFPNRegValue(precision);
360 }
else if (format[1] ==
'm') {
361 reg = instr->VFPMRegValue(precision);
362 }
else if (format[1] ==
'd') {
363 if ((instr->TypeValue() == 7) &&
364 (instr->Bit(24) == 0x0) &&
365 (instr->Bits(11, 9) == 0x5) &&
366 (instr->Bit(4) == 0x1)) {
368 reg = instr->Bits(19, 16) | (instr->Bit(7) << 4);
370 reg = instr->VFPDRegValue(precision);
373 if (format[2] ==
'+') {
374 int immed8 = instr->Immed8Value();
375 if (format[0] ==
'S') reg += immed8 - 1;
376 if (format[0] ==
'D') reg += (immed8 / 2 - 1);
378 if (format[2] ==
'+') retval = 3;
393 int Decoder::FormatVFPinstruction(Instruction* instr,
const char* format) {
399 void Decoder::FormatNeonList(
int Vd,
int type) {
401 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
403 }
else if (type ==
nlt_2) {
404 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
405 "{d%d, d%d}", Vd, Vd + 1);
406 }
else if (type ==
nlt_3) {
407 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
408 "{d%d, d%d, d%d}", Vd, Vd + 1, Vd + 2);
409 }
else if (type ==
nlt_4) {
410 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
411 "{d%d, d%d, d%d, d%d}", Vd, Vd + 1, Vd + 2, Vd + 3);
416 void Decoder::FormatNeonMemory(
int Rn,
int align,
int Rm) {
417 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
420 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
421 ":%d", (1 << align) << 6);
425 }
else if (Rm == 13) {
428 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
435 void Decoder::PrintMovwMovt(Instruction* instr) {
436 int imm = instr->ImmedMovwMovtValue();
437 int rd = instr->RdValue();
439 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
", #%d", imm);
448 int Decoder::FormatOption(Instruction* instr,
const char* format) {
451 if (instr->Bit(21) == 0) {
465 DCHECK(STRING_STARTS_WITH(format,
"cond"));
466 PrintCondition(instr);
470 double d = instr->DoubleImmedVmov();
471 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
"#%g", d);
475 uint32_t lsbit = instr->Bits(11, 7);
476 uint32_t width = instr->Bits(20, 16) + 1;
477 if (instr->Bit(21) == 0) {
483 DCHECK((width + lsbit) <= 32);
484 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
485 "#%d, #%d", lsbit, width);
498 int width = (format[3] -
'0') * 10 + (format[4] -
'0');
499 int lsb = (format[6] -
'0') * 10 + (format[7] -
'0');
501 DCHECK((width >= 1) && (width <= 32));
502 DCHECK((lsb >= 0) && (lsb <= 31));
503 DCHECK((width + lsb) <= 32);
505 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
507 instr->Bits(width + lsb - 1, lsb));
511 if (instr->HasLink()) {
517 if (format[1] ==
'w') {
519 PrintMovwMovt(instr);
522 if (format[1] ==
'e') {
523 DCHECK(STRING_STARTS_WITH(format,
"memop"));
527 if ((instr->Bits(27, 25) == 0) && (instr->Bit(20) == 0) &&
528 (instr->Bits(7, 6) == 3) && (instr->Bit(4) == 1)) {
529 if (instr->Bit(5) == 1) {
541 DCHECK(STRING_STARTS_WITH(format,
"msg"));
543 reinterpret_cast<byte*
>(instr->InstructionBits() & 0x0fffffff);
544 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
545 "%s", converter_.NameInCode(str));
549 if ((format[3] ==
'1') && (format[4] ==
'2')) {
551 DCHECK(STRING_STARTS_WITH(format,
"off12"));
552 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
553 "%d", instr->Offset12Value());
555 }
else if (format[3] ==
'0') {
557 DCHECK(STRING_STARTS_WITH(format,
"off0to3and8to19"));
558 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
560 (instr->Bits(19, 8) << 4) +
565 DCHECK(STRING_STARTS_WITH(format,
"off8"));
566 int offs8 = (instr->ImmedHValue() << 4) | instr->ImmedLValue();
567 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
"%d", offs8);
571 DCHECK(STRING_STARTS_WITH(format,
"pu"));
576 return FormatRegister(instr, format);
579 if (format[1] ==
'h') {
580 if (format[6] ==
'o') {
581 DCHECK(STRING_STARTS_WITH(format,
"shift_op"));
582 if (instr->TypeValue() == 0) {
585 DCHECK(instr->TypeValue() == 1);
586 PrintShiftImm(instr);
589 }
else if (format[6] ==
's') {
590 DCHECK(STRING_STARTS_WITH(format,
"shift_sat"));
591 PrintShiftSat(instr);
594 DCHECK(STRING_STARTS_WITH(format,
"shift_rm"));
598 }
else if (format[1] ==
'v') {
599 DCHECK(STRING_STARTS_WITH(format,
"svc"));
600 PrintSoftwareInterrupt(instr->SvcValue());
602 }
else if (format[1] ==
'i') {
603 DCHECK(STRING_STARTS_WITH(format,
"sign"));
604 if (instr->HasSign()) {
616 DCHECK(STRING_STARTS_WITH(format,
"target"));
617 int off = (instr->SImmed24Value() << 2) + 8;
618 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
621 converter_.NameOfAddress(
622 reinterpret_cast<byte*
>(instr) + off));
638 if (instr->Bit(22) == 0) {
646 return FormatVFPinstruction(instr, format);
650 return FormatVFPRegister(instr, format);
671 void Decoder::Format(Instruction* instr,
const char* format) {
672 char cur = *format++;
673 while ((cur != 0) && (out_buffer_pos_ < (out_buffer_.length() - 1))) {
675 format += FormatOption(instr, format);
677 out_buffer_[out_buffer_pos_++] = cur;
681 out_buffer_[out_buffer_pos_] =
'\0';
687 #define VERIFY(condition) \
696 void Decoder::Unknown(Instruction* instr) {
697 Format(instr,
"unknown");
701 void Decoder::DecodeType01(Instruction* instr) {
702 int type = instr->TypeValue();
703 if ((type == 0) && instr->IsSpecialType0()) {
705 if (instr->Bits(7, 4) == 9) {
706 if (instr->Bit(24) == 0) {
708 if (instr->Bit(23) == 0) {
709 if (instr->Bit(21) == 0) {
713 Format(instr,
"mul'cond's 'rn, 'rm, 'rs");
715 if (instr->Bit(22) == 0) {
720 Format(instr,
"mla'cond's 'rn, 'rm, 'rs, 'rd");
726 Format(instr,
"mls'cond's 'rn, 'rm, 'rs, 'rd");
736 Format(instr,
"'um'al'cond's 'rd, 'rn, 'rm, 'rs");
741 }
else if ((instr->Bit(20) == 0) && ((instr->Bits(7, 4) & 0xd) == 0xd)) {
743 switch (instr->PUField()) {
745 if (instr->Bit(22) == 0) {
746 Format(instr,
"'memop'cond's 'rd, ['rn], -'rm");
748 Format(instr,
"'memop'cond's 'rd, ['rn], #-'off8");
753 if (instr->Bit(22) == 0) {
754 Format(instr,
"'memop'cond's 'rd, ['rn], +'rm");
756 Format(instr,
"'memop'cond's 'rd, ['rn], #+'off8");
761 if (instr->Bit(22) == 0) {
762 Format(instr,
"'memop'cond's 'rd, ['rn, -'rm]'w");
764 Format(instr,
"'memop'cond's 'rd, ['rn, #-'off8]'w");
769 if (instr->Bit(22) == 0) {
770 Format(instr,
"'memop'cond's 'rd, ['rn, +'rm]'w");
772 Format(instr,
"'memop'cond's 'rd, ['rn, #+'off8]'w");
784 switch (instr->PUField()) {
786 if (instr->Bit(22) == 0) {
787 Format(instr,
"'memop'cond'sign'h 'rd, ['rn], -'rm");
789 Format(instr,
"'memop'cond'sign'h 'rd, ['rn], #-'off8");
794 if (instr->Bit(22) == 0) {
795 Format(instr,
"'memop'cond'sign'h 'rd, ['rn], +'rm");
797 Format(instr,
"'memop'cond'sign'h 'rd, ['rn], #+'off8");
802 if (instr->Bit(22) == 0) {
803 Format(instr,
"'memop'cond'sign'h 'rd, ['rn, -'rm]'w");
805 Format(instr,
"'memop'cond'sign'h 'rd, ['rn, #-'off8]'w");
810 if (instr->Bit(22) == 0) {
811 Format(instr,
"'memop'cond'sign'h 'rd, ['rn, +'rm]'w");
813 Format(instr,
"'memop'cond'sign'h 'rd, ['rn, #+'off8]'w");
825 }
else if ((type == 0) && instr->IsMiscType0()) {
826 if (instr->Bits(22, 21) == 1) {
827 switch (instr->BitField(7, 4)) {
829 Format(instr,
"bx'cond 'rm");
832 Format(instr,
"blx'cond 'rm");
835 Format(instr,
"bkpt 'off0to3and8to19");
841 }
else if (instr->Bits(22, 21) == 3) {
842 switch (instr->BitField(7, 4)) {
844 Format(instr,
"clz'cond 'rd, 'rm");
853 }
else if ((type == 1) && instr->IsNopType1()) {
854 Format(instr,
"nop'cond");
856 switch (instr->OpcodeField()) {
858 Format(instr,
"and'cond's 'rd, 'rn, 'shift_op");
862 Format(instr,
"eor'cond's 'rd, 'rn, 'shift_op");
866 Format(instr,
"sub'cond's 'rd, 'rn, 'shift_op");
870 Format(instr,
"rsb'cond's 'rd, 'rn, 'shift_op");
874 Format(instr,
"add'cond's 'rd, 'rn, 'shift_op");
878 Format(instr,
"adc'cond's 'rd, 'rn, 'shift_op");
882 Format(instr,
"sbc'cond's 'rd, 'rn, 'shift_op");
886 Format(instr,
"rsc'cond's 'rd, 'rn, 'shift_op");
891 Format(instr,
"tst'cond 'rn, 'shift_op");
893 Format(instr,
"movw'cond 'mw");
899 Format(instr,
"teq'cond 'rn, 'shift_op");
909 Format(instr,
"cmp'cond 'rn, 'shift_op");
911 Format(instr,
"movt'cond 'mw");
917 Format(instr,
"cmn'cond 'rn, 'shift_op");
926 Format(instr,
"orr'cond's 'rd, 'rn, 'shift_op");
930 Format(instr,
"mov'cond's 'rd, 'shift_op");
934 Format(instr,
"bic'cond's 'rd, 'rn, 'shift_op");
938 Format(instr,
"mvn'cond's 'rd, 'shift_op");
951 void Decoder::DecodeType2(Instruction* instr) {
952 switch (instr->PUField()) {
958 Format(instr,
"'memop'cond'b 'rd, ['rn], #-'off12");
966 Format(instr,
"'memop'cond'b 'rd, ['rn], #+'off12");
970 Format(instr,
"'memop'cond'b 'rd, ['rn, #-'off12]'w");
974 Format(instr,
"'memop'cond'b 'rd, ['rn, #+'off12]'w");
986 void Decoder::DecodeType3(Instruction* instr) {
987 switch (instr->PUField()) {
989 VERIFY(!instr->HasW());
990 Format(instr,
"'memop'cond'b 'rd, ['rn], -'shift_rm");
994 if (instr->Bit(4) == 0) {
995 Format(instr,
"'memop'cond'b 'rd, ['rn], +'shift_rm");
997 if (instr->Bit(5) == 0) {
998 switch (instr->Bits(22, 21)) {
1000 if (instr->Bit(20) == 0) {
1001 if (instr->Bit(6) == 0) {
1002 Format(instr,
"pkhbt'cond 'rd, 'rn, 'rm, lsl #'imm05@07");
1004 if (instr->Bits(11, 7) == 0) {
1005 Format(instr,
"pkhtb'cond 'rd, 'rn, 'rm, asr #32");
1007 Format(instr,
"pkhtb'cond 'rd, 'rn, 'rm, asr #'imm05@07");
1021 Format(instr,
"usat 'rd, #'imm05@16, 'rm'shift_sat");
1025 switch (instr->Bits(22, 21)) {
1033 if ((instr->Bit(20) == 0) && (instr->Bits(9, 6) == 1)) {
1034 if (instr->Bits(19, 16) == 0xF) {
1035 switch (instr->Bits(11, 10)) {
1037 Format(instr,
"uxtb16'cond 'rd, 'rm");
1040 Format(instr,
"uxtb16'cond 'rd, 'rm, ror #8");
1043 Format(instr,
"uxtb16'cond 'rd, 'rm, ror #16");
1046 Format(instr,
"uxtb16'cond 'rd, 'rm, ror #24");
1057 if ((instr->Bit(20) == 0) && (instr->Bits(9, 6) == 1)) {
1058 if (instr->Bits(19, 16) == 0xF) {
1059 switch (instr->Bits(11, 10)) {
1061 Format(instr,
"uxtb'cond 'rd, 'rm");
1064 Format(instr,
"uxtb'cond 'rd, 'rm, ror #8");
1067 Format(instr,
"uxtb'cond 'rd, 'rm, ror #16");
1070 Format(instr,
"uxtb'cond 'rd, 'rm, ror #24");
1074 switch (instr->Bits(11, 10)) {
1076 Format(instr,
"uxtab'cond 'rd, 'rn, 'rm");
1079 Format(instr,
"uxtab'cond 'rd, 'rn, 'rm, ror #8");
1082 Format(instr,
"uxtab'cond 'rd, 'rn, 'rm, ror #16");
1085 Format(instr,
"uxtab'cond 'rd, 'rn, 'rm, ror #24");
1099 if (FLAG_enable_sudiv) {
1100 if (instr->Bits(5, 4) == 0x1) {
1101 if ((instr->Bit(22) == 0x0) && (instr->Bit(20) == 0x1)) {
1102 if (instr->Bit(21) == 0x1) {
1104 Format(instr,
"udiv'cond'b 'rn, 'rm, 'rs");
1107 Format(instr,
"sdiv'cond'b 'rn, 'rm, 'rs");
1113 Format(instr,
"'memop'cond'b 'rd, ['rn, -'shift_rm]'w");
1117 if (instr->HasW() && (instr->Bits(6, 4) == 0x5)) {
1120 uint32_t msbit = widthminus1 + lsbit;
1122 if (instr->Bit(22)) {
1123 Format(instr,
"ubfx'cond 'rd, 'rm, 'f");
1125 Format(instr,
"sbfx'cond 'rd, 'rm, 'f");
1130 }
else if (!instr->HasW() && (instr->Bits(6, 4) == 0x1)) {
1133 if (msbit >= lsbit) {
1134 if (instr->RmValue() == 15) {
1135 Format(instr,
"bfc'cond 'rd, 'f");
1137 Format(instr,
"bfi'cond 'rd, 'rm, 'f");
1143 Format(instr,
"'memop'cond'b 'rd, ['rn, +'shift_rm]'w");
1156 void Decoder::DecodeType4(Instruction* instr) {
1157 if (instr->Bit(22) != 0) {
1161 if (instr->HasL()) {
1162 Format(instr,
"ldm'cond'pu 'rn'w, 'rlist");
1164 Format(instr,
"stm'cond'pu 'rn'w, 'rlist");
1170 void Decoder::DecodeType5(Instruction* instr) {
1171 Format(instr,
"b'l'cond 'target");
1175 void Decoder::DecodeType6(Instruction* instr) {
1176 DecodeType6CoprocessorIns(instr);
1180 int Decoder::DecodeType7(Instruction* instr) {
1181 if (instr->Bit(24) == 1) {
1183 Format(instr,
"stop'cond 'svc");
1186 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
1187 "\n %p %08x stop message: %s",
1188 reinterpret_cast<void*
>(instr
1192 *
reinterpret_cast<char**
>(instr
1197 Format(instr,
"svc'cond 'svc");
1200 DecodeTypeVFP(instr);
1224 void Decoder::DecodeTypeVFP(Instruction* instr) {
1225 VERIFY((instr->TypeValue() == 7) && (instr->Bit(24) == 0x0) );
1226 VERIFY(instr->Bits(11, 9) == 0x5);
1228 if (instr->Bit(4) == 0) {
1229 if (instr->Opc1Value() == 0x7) {
1231 if ((instr->Opc2Value() == 0x0) && (instr->Opc3Value() == 0x1)) {
1233 if (instr->SzValue() == 0x1) {
1234 Format(instr,
"vmov'cond.f64 'Dd, 'Dm");
1236 Format(instr,
"vmov'cond.f32 'Sd, 'Sm");
1238 }
else if ((instr->Opc2Value() == 0x0) && (instr->Opc3Value() == 0x3)) {
1240 Format(instr,
"vabs'cond.f64 'Dd, 'Dm");
1241 }
else if ((instr->Opc2Value() == 0x1) && (instr->Opc3Value() == 0x1)) {
1243 Format(instr,
"vneg'cond.f64 'Dd, 'Dm");
1244 }
else if ((instr->Opc2Value() == 0x7) && (instr->Opc3Value() == 0x3)) {
1245 DecodeVCVTBetweenDoubleAndSingle(instr);
1246 }
else if ((instr->Opc2Value() == 0x8) && (instr->Opc3Value() & 0x1)) {
1247 DecodeVCVTBetweenFloatingPointAndInteger(instr);
1248 }
else if ((instr->Opc2Value() == 0xA) && (instr->Opc3Value() == 0x3) &&
1249 (instr->Bit(8) == 1)) {
1251 int fraction_bits = 32 - ((instr->Bits(3, 0) << 1) | instr->Bit(5));
1252 Format(instr,
"vcvt'cond.f64.s32 'Dd, 'Dd");
1253 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
1254 ", #%d", fraction_bits);
1255 }
else if (((instr->Opc2Value() >> 1) == 0x6) &&
1256 (instr->Opc3Value() & 0x1)) {
1257 DecodeVCVTBetweenFloatingPointAndInteger(instr);
1258 }
else if (((instr->Opc2Value() == 0x4) || (instr->Opc2Value() == 0x5)) &&
1259 (instr->Opc3Value() & 0x1)) {
1261 }
else if (((instr->Opc2Value() == 0x1)) && (instr->Opc3Value() == 0x3)) {
1262 Format(instr,
"vsqrt'cond.f64 'Dd, 'Dm");
1263 }
else if (instr->Opc3Value() == 0x0) {
1264 if (instr->SzValue() == 0x1) {
1265 Format(instr,
"vmov'cond.f64 'Dd, 'd");
1272 }
else if (instr->Opc1Value() == 0x3) {
1273 if (instr->SzValue() == 0x1) {
1274 if (instr->Opc3Value() & 0x1) {
1275 Format(instr,
"vsub'cond.f64 'Dd, 'Dn, 'Dm");
1277 Format(instr,
"vadd'cond.f64 'Dd, 'Dn, 'Dm");
1282 }
else if ((instr->Opc1Value() == 0x2) && !(instr->Opc3Value() & 0x1)) {
1283 if (instr->SzValue() == 0x1) {
1284 Format(instr,
"vmul'cond.f64 'Dd, 'Dn, 'Dm");
1288 }
else if ((instr->Opc1Value() == 0x0) && !(instr->Opc3Value() & 0x1)) {
1289 if (instr->SzValue() == 0x1) {
1290 Format(instr,
"vmla'cond.f64 'Dd, 'Dn, 'Dm");
1294 }
else if ((instr->Opc1Value() == 0x0) && (instr->Opc3Value() & 0x1)) {
1295 if (instr->SzValue() == 0x1) {
1296 Format(instr,
"vmls'cond.f64 'Dd, 'Dn, 'Dm");
1300 }
else if ((instr->Opc1Value() == 0x4) && !(instr->Opc3Value() & 0x1)) {
1301 if (instr->SzValue() == 0x1) {
1302 Format(instr,
"vdiv'cond.f64 'Dd, 'Dn, 'Dm");
1310 if ((instr->VCValue() == 0x0) &&
1311 (instr->VAValue() == 0x0)) {
1312 DecodeVMOVBetweenCoreAndSinglePrecisionRegisters(instr);
1313 }
else if ((instr->VLValue() == 0x0) &&
1314 (instr->VCValue() == 0x1) &&
1315 (instr->Bit(23) == 0x0)) {
1316 if (instr->Bit(21) == 0x0) {
1317 Format(instr,
"vmov'cond.32 'Dd[0], 'rt");
1319 Format(instr,
"vmov'cond.32 'Dd[1], 'rt");
1321 }
else if ((instr->VLValue() == 0x1) &&
1322 (instr->VCValue() == 0x1) &&
1323 (instr->Bit(23) == 0x0)) {
1324 if (instr->Bit(21) == 0x0) {
1325 Format(instr,
"vmov'cond.32 'rt, 'Dd[0]");
1327 Format(instr,
"vmov'cond.32 'rt, 'Dd[1]");
1329 }
else if ((instr->VCValue() == 0x0) &&
1330 (instr->VAValue() == 0x7) &&
1331 (instr->Bits(19, 16) == 0x1)) {
1332 if (instr->VLValue() == 0) {
1333 if (instr->Bits(15, 12) == 0xF) {
1334 Format(instr,
"vmsr'cond FPSCR, APSR");
1336 Format(instr,
"vmsr'cond FPSCR, 'rt");
1339 if (instr->Bits(15, 12) == 0xF) {
1340 Format(instr,
"vmrs'cond APSR, FPSCR");
1342 Format(instr,
"vmrs'cond 'rt, FPSCR");
1350 void Decoder::DecodeVMOVBetweenCoreAndSinglePrecisionRegisters(
1351 Instruction* instr) {
1352 VERIFY((instr->Bit(4) == 1) && (instr->VCValue() == 0x0) &&
1353 (instr->VAValue() == 0x0));
1355 bool to_arm_register = (instr->VLValue() == 0x1);
1357 if (to_arm_register) {
1358 Format(instr,
"vmov'cond 'rt, 'Sn");
1360 Format(instr,
"vmov'cond 'Sn, 'rt");
1365 void Decoder::DecodeVCMP(Instruction* instr) {
1366 VERIFY((instr->Bit(4) == 0) && (instr->Opc1Value() == 0x7));
1367 VERIFY(((instr->Opc2Value() == 0x4) || (instr->Opc2Value() == 0x5)) &&
1368 (instr->Opc3Value() & 0x1));
1371 bool dp_operation = (instr->SzValue() == 1);
1372 bool raise_exception_for_qnan = (instr->Bit(7) == 0x1);
1374 if (dp_operation && !raise_exception_for_qnan) {
1375 if (instr->Opc2Value() == 0x4) {
1376 Format(instr,
"vcmp'cond.f64 'Dd, 'Dm");
1377 }
else if (instr->Opc2Value() == 0x5) {
1378 Format(instr,
"vcmp'cond.f64 'Dd, #0.0");
1388 void Decoder::DecodeVCVTBetweenDoubleAndSingle(Instruction* instr) {
1389 VERIFY((instr->Bit(4) == 0) && (instr->Opc1Value() == 0x7));
1390 VERIFY((instr->Opc2Value() == 0x7) && (instr->Opc3Value() == 0x3));
1392 bool double_to_single = (instr->SzValue() == 1);
1394 if (double_to_single) {
1395 Format(instr,
"vcvt'cond.f32.f64 'Sd, 'Dm");
1397 Format(instr,
"vcvt'cond.f64.f32 'Dd, 'Sm");
1402 void Decoder::DecodeVCVTBetweenFloatingPointAndInteger(Instruction* instr) {
1403 VERIFY((instr->Bit(4) == 0) && (instr->Opc1Value() == 0x7));
1404 VERIFY(((instr->Opc2Value() == 0x8) && (instr->Opc3Value() & 0x1)) ||
1405 (((instr->Opc2Value() >> 1) == 0x6) && (instr->Opc3Value() & 0x1)));
1407 bool to_integer = (instr->Bit(18) == 1);
1408 bool dp_operation = (instr->SzValue() == 1);
1410 bool unsigned_integer = (instr->Bit(16) == 0);
1413 if (unsigned_integer) {
1414 Format(instr,
"vcvt'cond.u32.f64 'Sd, 'Dm");
1416 Format(instr,
"vcvt'cond.s32.f64 'Sd, 'Dm");
1419 if (unsigned_integer) {
1420 Format(instr,
"vcvt'cond.u32.f32 'Sd, 'Sm");
1422 Format(instr,
"vcvt'cond.s32.f32 'Sd, 'Sm");
1426 bool unsigned_integer = (instr->Bit(7) == 0);
1429 if (unsigned_integer) {
1430 Format(instr,
"vcvt'cond.f64.u32 'Dd, 'Sm");
1432 Format(instr,
"vcvt'cond.f64.s32 'Dd, 'Sm");
1435 if (unsigned_integer) {
1436 Format(instr,
"vcvt'cond.f32.u32 'Sd, 'Sm");
1438 Format(instr,
"vcvt'cond.f32.s32 'Sd, 'Sm");
1450 void Decoder::DecodeType6CoprocessorIns(Instruction* instr) {
1451 VERIFY(instr->TypeValue() == 6);
1453 if (instr->CoprocessorValue() == 0xA) {
1454 switch (instr->OpcodeValue()) {
1457 if (instr->HasL()) {
1458 Format(instr,
"vldr'cond 'Sd, ['rn - 4*'imm08@00]");
1460 Format(instr,
"vstr'cond 'Sd, ['rn - 4*'imm08@00]");
1465 if (instr->HasL()) {
1466 Format(instr,
"vldr'cond 'Sd, ['rn + 4*'imm08@00]");
1468 Format(instr,
"vstr'cond 'Sd, ['rn + 4*'imm08@00]");
1477 bool to_vfp_register = (instr->VLValue() == 0x1);
1478 if (to_vfp_register) {
1479 Format(instr,
"vldm'cond'pu 'rn'w, {'Sd-'Sd+}");
1481 Format(instr,
"vstm'cond'pu 'rn'w, {'Sd-'Sd+}");
1488 }
else if (instr->CoprocessorValue() == 0xB) {
1489 switch (instr->OpcodeValue()) {
1492 if (instr->Bits(7, 6) != 0 || instr->Bit(4) != 1) {
1494 }
else if (instr->HasL()) {
1495 Format(instr,
"vmov'cond 'rt, 'rn, 'Dm");
1497 Format(instr,
"vmov'cond 'Dm, 'rt, 'rn");
1502 if (instr->HasL()) {
1503 Format(instr,
"vldr'cond 'Dd, ['rn - 4*'imm08@00]");
1505 Format(instr,
"vstr'cond 'Dd, ['rn - 4*'imm08@00]");
1510 if (instr->HasL()) {
1511 Format(instr,
"vldr'cond 'Dd, ['rn + 4*'imm08@00]");
1513 Format(instr,
"vstr'cond 'Dd, ['rn + 4*'imm08@00]");
1522 bool to_vfp_register = (instr->VLValue() == 0x1);
1523 if (to_vfp_register) {
1524 Format(instr,
"vldm'cond'pu 'rn'w, {'Dd-'Dd+}");
1526 Format(instr,
"vstm'cond'pu 'rn'w, {'Dd-'Dd+}");
1539 void Decoder::DecodeSpecialCondition(Instruction* instr) {
1540 switch (instr->SpecialValue()) {
1542 if ((instr->Bits(18, 16) == 0) && (instr->Bits(11, 6) == 0x28) &&
1543 (instr->Bit(4) == 1)) {
1545 if ((instr->VdValue() & 1) != 0) Unknown(instr);
1546 int Vd = (instr->Bit(22) << 3) | (instr->VdValue() >> 1);
1547 int Vm = (instr->Bit(5) << 4) | instr->VmValue();
1548 int imm3 = instr->Bits(21, 19);
1549 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
1550 "vmovl.s%d q%d, d%d", imm3*8, Vd, Vm);
1556 if ((instr->Bits(18, 16) == 0) && (instr->Bits(11, 6) == 0x28) &&
1557 (instr->Bit(4) == 1)) {
1559 if ((instr->VdValue() & 1) != 0) Unknown(instr);
1560 int Vd = (instr->Bit(22) << 3) | (instr->VdValue() >> 1);
1561 int Vm = (instr->Bit(5) << 4) | instr->VmValue();
1562 int imm3 = instr->Bits(21, 19);
1563 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
1564 "vmovl.u%d q%d, d%d", imm3*8, Vd, Vm);
1570 if (instr->Bits(21, 20) == 0) {
1572 int Vd = (instr->Bit(22) << 4) | instr->VdValue();
1573 int Rn = instr->VnValue();
1574 int type = instr->Bits(11, 8);
1575 int size = instr->Bits(7, 6);
1576 int align = instr->Bits(5, 4);
1577 int Rm = instr->VmValue();
1578 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
1579 "vst1.%d ", (1 <<
size) << 3);
1580 FormatNeonList(Vd, type);
1582 FormatNeonMemory(Rn, align, Rm);
1583 }
else if (instr->Bits(21, 20) == 2) {
1585 int Vd = (instr->Bit(22) << 4) | instr->VdValue();
1586 int Rn = instr->VnValue();
1587 int type = instr->Bits(11, 8);
1588 int size = instr->Bits(7, 6);
1589 int align = instr->Bits(5, 4);
1590 int Rm = instr->VmValue();
1591 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
1592 "vld1.%d ", (1 <<
size) << 3);
1593 FormatNeonList(Vd, type);
1595 FormatNeonMemory(Rn, align, Rm);
1602 if ((instr->Bits(22, 20) == 5) && (instr->Bits(15, 12) == 0xf)) {
1603 int Rn = instr->Bits(19, 16);
1604 int offset = instr->Bits(11, 0);
1606 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
1608 }
else if (instr->Bit(23) == 0) {
1609 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
1610 "pld [r%d, #-%d]", Rn, offset);
1612 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
1613 "pld [r%d, #+%d]", Rn, offset);
1627 bool Decoder::IsConstantPoolAt(
byte* instr_ptr) {
1628 int instruction_bits = *(
reinterpret_cast<int*
>(instr_ptr));
1633 int Decoder::ConstantPoolSizeAt(
byte* instr_ptr) {
1634 if (IsConstantPoolAt(instr_ptr)) {
1635 int instruction_bits = *(
reinterpret_cast<int*
>(instr_ptr));
1644 int Decoder::InstructionDecode(
byte* instr_ptr) {
1647 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
1649 instr->InstructionBits());
1651 DecodeSpecialCondition(instr);
1654 int instruction_bits = *(
reinterpret_cast<int*
>(instr_ptr));
1656 out_buffer_pos_ +=
SNPrintF(out_buffer_ + out_buffer_pos_,
1657 "constant pool begin (length %d)",
1665 SNPrintF(out_buffer_ + out_buffer_pos_,
1666 " (0x%08x)", target->InstructionBits());
1669 switch (instr->TypeValue()) {
1672 DecodeType01(instr);
1696 return DecodeType7(instr);
1755 : converter_(converter) {}
1758 Disassembler::~Disassembler() {}
1762 byte* instruction) {
1764 return d.InstructionDecode(instruction);
1768 int Disassembler::ConstantPoolSizeAt(
byte* instruction) {
1769 return v8::internal::Decoder::ConstantPoolSizeAt(instruction);
1773 void Disassembler::Disassemble(FILE* f,
byte* begin,
byte* end) {
1774 NameConverter converter;
1775 Disassembler d(converter);
1776 for (
byte*
pc = begin;
pc < end;) {
1780 pc += d.InstructionDecode(buffer,
pc);
1783 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 Instruction * At(byte *pc)
static const char * Name(int reg)
static const char * Name(int reg, bool is_double)
enable harmony numeric enable harmony object literal extensions Optimize object size
enable harmony numeric enable harmony object literal extensions Optimize object Array shift
#define DCHECK(condition)
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
int DecodeConstantPoolLength(int instr)
int SNPrintF(Vector< char > str, const char *format,...)
const int kCodeAgeJumpInstruction
const int kConstantPoolMarkerMask
void PrintF(const char *format,...)
const int kConstantPoolMarker
const uint32_t kStopCodeMask
Debugger support for the V8 JavaScript engine.