59 #if defined(V8_TARGET_ARCH_ARM)
79 Vector<char> out_buffer)
80 : converter_(converter),
81 out_buffer_(out_buffer),
83 out_buffer_[out_buffer_pos_] =
'\0';
90 int InstructionDecode(
byte* instruction);
92 static bool IsConstantPoolAt(
byte* instr_ptr);
93 static int ConstantPoolSizeAt(
byte* instr_ptr);
97 void PrintChar(
const char ch);
98 void Print(
const char* str);
101 void PrintRegister(
int reg);
102 void PrintSRegister(
int reg);
103 void PrintDRegister(
int reg);
104 int FormatVFPRegister(Instruction* instr,
const char* format);
105 void PrintMovwMovt(Instruction* instr);
106 int FormatVFPinstruction(Instruction* instr,
const char* format);
107 void PrintCondition(Instruction* instr);
108 void PrintShiftRm(Instruction* instr);
109 void PrintShiftImm(Instruction* instr);
110 void PrintShiftSat(Instruction* instr);
111 void PrintPU(Instruction* instr);
115 int FormatRegister(Instruction* instr,
const char* option);
116 int FormatOption(Instruction* instr,
const char* option);
117 void Format(Instruction* instr,
const char* format);
118 void Unknown(Instruction* instr);
124 void DecodeType01(Instruction* instr);
125 void DecodeType2(Instruction* instr);
126 void DecodeType3(Instruction* instr);
127 void DecodeType4(Instruction* instr);
128 void DecodeType5(Instruction* instr);
129 void DecodeType6(Instruction* instr);
131 int DecodeType7(Instruction* instr);
133 void DecodeTypeVFP(Instruction* instr);
134 void DecodeType6CoprocessorIns(Instruction* instr);
136 void DecodeVMOVBetweenCoreAndSinglePrecisionRegisters(Instruction* instr);
137 void DecodeVCMP(Instruction* instr);
138 void DecodeVCVTBetweenDoubleAndSingle(Instruction* instr);
139 void DecodeVCVTBetweenFloatingPointAndInteger(Instruction* instr);
142 Vector<char> out_buffer_;
150 #define STRING_STARTS_WITH(string, compare_string) \
151 (strncmp(string, compare_string, strlen(compare_string)) == 0)
155 void Decoder::PrintChar(
const char ch) {
156 out_buffer_[out_buffer_pos_++] = ch;
163 while (cur !=
'\0' && (out_buffer_pos_ < (out_buffer_.length() - 1))) {
167 out_buffer_[out_buffer_pos_] = 0;
174 "eq",
"ne",
"cs" ,
"cc" ,
"mi" ,
"pl" ,
"vs" ,
"vc" ,
175 "hi",
"ls",
"ge",
"lt",
"gt",
"le",
"",
"invalid",
180 void Decoder::PrintCondition(Instruction* instr) {
181 Print(cond_names[instr->ConditionValue()]);
186 void Decoder::PrintRegister(
int reg) {
187 Print(converter_.NameOfCPURegister(reg));
191 void Decoder::PrintSRegister(
int reg) {
196 void Decoder::PrintDRegister(
int reg) {
204 "lsl",
"lsr",
"asr",
"ror"
210 void Decoder::PrintShiftRm(Instruction* instr) {
211 ShiftOp shift = instr->ShiftField();
212 int shift_index = instr->ShiftValue();
213 int shift_amount = instr->ShiftAmountValue();
214 int rm = instr->RmValue();
218 if ((instr->RegShiftValue() == 0) && (shift ==
LSL) && (shift_amount == 0)) {
222 if (instr->RegShiftValue() == 0) {
224 if ((shift ==
ROR) && (shift_amount == 0)) {
227 }
else if (((shift ==
LSR) || (shift ==
ASR)) && (shift_amount == 0)) {
230 out_buffer_pos_ +=
OS::SNPrintF(out_buffer_ + out_buffer_pos_,
232 shift_names[shift_index],
236 int rs = instr->RsValue();
237 out_buffer_pos_ +=
OS::SNPrintF(out_buffer_ + out_buffer_pos_,
238 ", %s ", shift_names[shift_index]);
246 void Decoder::PrintShiftImm(Instruction* instr) {
247 int rotate = instr->RotateValue() * 2;
248 int immed8 = instr->Immed8Value();
249 int imm = (immed8 >> rotate) | (immed8 << (32 - rotate));
250 out_buffer_pos_ +=
OS::SNPrintF(out_buffer_ + out_buffer_pos_,
256 void Decoder::PrintShiftSat(Instruction* instr) {
257 int shift = instr->Bits(11, 7);
259 out_buffer_pos_ +=
OS::SNPrintF(out_buffer_ + out_buffer_pos_,
261 shift_names[instr->Bit(6) * 2],
268 void Decoder::PrintPU(Instruction* instr) {
269 switch (instr->PUField()) {
299 Print(
"call rt redirected");
306 out_buffer_pos_ +=
OS::SNPrintF(out_buffer_ + out_buffer_pos_,
309 svc & kStopCodeMask);
311 out_buffer_pos_ +=
OS::SNPrintF(out_buffer_ + out_buffer_pos_,
322 int Decoder::FormatRegister(Instruction* instr,
const char* format) {
324 if (format[1] ==
'n') {
325 int reg = instr->RnValue();
328 }
else if (format[1] ==
'd') {
329 int reg = instr->RdValue();
332 }
else if (format[1] ==
's') {
333 int reg = instr->RsValue();
336 }
else if (format[1] ==
'm') {
337 int reg = instr->RmValue();
340 }
else if (format[1] ==
't') {
341 int reg = instr->RtValue();
344 }
else if (format[1] ==
'l') {
346 ASSERT(STRING_STARTS_WITH(format,
"rlist"));
347 int rlist = instr->RlistValue();
352 if ((rlist & 1) != 0) {
354 if ((rlist >> 1) != 0) {
371 int Decoder::FormatVFPRegister(Instruction* instr,
const char* format) {
372 ASSERT((format[0] ==
'S') || (format[0] ==
'D'));
379 if (format[1] ==
'n') {
380 reg = instr->VFPNRegValue(precision);
381 }
else if (format[1] ==
'm') {
382 reg = instr->VFPMRegValue(precision);
383 }
else if (format[1] ==
'd') {
384 reg = instr->VFPDRegValue(precision);
385 if (format[2] ==
'+') {
386 int immed8 = instr->Immed8Value();
387 if (format[0] ==
'S') reg += immed8 - 1;
388 if (format[0] ==
'D') reg += (immed8 / 2 - 1);
390 if (format[2] ==
'+') retval = 3;
405 int Decoder::FormatVFPinstruction(Instruction* instr,
const char* format) {
412 void Decoder::PrintMovwMovt(Instruction* instr) {
413 int imm = instr->ImmedMovwMovtValue();
414 int rd = instr->RdValue();
416 out_buffer_pos_ +=
OS::SNPrintF(out_buffer_ + out_buffer_pos_,
426 int Decoder::FormatOption(Instruction* instr,
const char* format) {
429 if (instr->Bit(21) == 0) {
443 ASSERT(STRING_STARTS_WITH(format,
"cond"));
444 PrintCondition(instr);
448 double d = instr->DoubleImmedVmov();
449 out_buffer_pos_ +=
OS::SNPrintF(out_buffer_ + out_buffer_pos_,
454 uint32_t lsbit = instr->Bits(11, 7);
455 uint32_t width = instr->Bits(20, 16) + 1;
456 if (instr->Bit(21) == 0) {
462 ASSERT((width + lsbit) <= 32);
463 out_buffer_pos_ +=
OS::SNPrintF(out_buffer_ + out_buffer_pos_,
464 "#%d, #%d", lsbit, width);
477 int width = (format[3] -
'0') * 10 + (format[4] -
'0');
478 int lsb = (format[6] -
'0') * 10 + (format[7] -
'0');
480 ASSERT((width >= 1) && (width <= 32));
481 ASSERT((lsb >= 0) && (lsb <= 31));
482 ASSERT((width + lsb) <= 32);
484 out_buffer_pos_ +=
OS::SNPrintF(out_buffer_ + out_buffer_pos_,
486 instr->Bits(width + lsb - 1, lsb));
490 if (instr->HasLink()) {
496 if (format[1] ==
'w') {
498 PrintMovwMovt(instr);
501 if (format[1] ==
'e') {
502 ASSERT(STRING_STARTS_WITH(format,
"memop"));
506 if ((instr->Bits(27, 25) == 0) && (instr->Bit(20) == 0) &&
507 (instr->Bits(7, 6) == 3) && (instr->Bit(4) == 1)) {
508 if (instr->Bit(5) == 1) {
520 ASSERT(STRING_STARTS_WITH(format,
"msg"));
522 reinterpret_cast<byte*
>(instr->InstructionBits() & 0x0fffffff);
523 out_buffer_pos_ +=
OS::SNPrintF(out_buffer_ + out_buffer_pos_,
524 "%s", converter_.NameInCode(str));
528 if ((format[3] ==
'1') && (format[4] ==
'2')) {
530 ASSERT(STRING_STARTS_WITH(format,
"off12"));
531 out_buffer_pos_ +=
OS::SNPrintF(out_buffer_ + out_buffer_pos_,
532 "%d", instr->Offset12Value());
534 }
else if (format[3] ==
'0') {
536 ASSERT(STRING_STARTS_WITH(format,
"off0to3and8to19"));
537 out_buffer_pos_ +=
OS::SNPrintF(out_buffer_ + out_buffer_pos_,
539 (instr->Bits(19, 8) << 4) +
544 ASSERT(STRING_STARTS_WITH(format,
"off8"));
545 int offs8 = (instr->ImmedHValue() << 4) | instr->ImmedLValue();
546 out_buffer_pos_ +=
OS::SNPrintF(out_buffer_ + out_buffer_pos_,
551 ASSERT(STRING_STARTS_WITH(format,
"pu"));
556 return FormatRegister(instr, format);
559 if (format[1] ==
'h') {
560 if (format[6] ==
'o') {
561 ASSERT(STRING_STARTS_WITH(format,
"shift_op"));
562 if (instr->TypeValue() == 0) {
565 ASSERT(instr->TypeValue() == 1);
566 PrintShiftImm(instr);
569 }
else if (format[6] ==
's') {
570 ASSERT(STRING_STARTS_WITH(format,
"shift_sat"));
571 PrintShiftSat(instr);
574 ASSERT(STRING_STARTS_WITH(format,
"shift_rm"));
578 }
else if (format[1] ==
'v') {
579 ASSERT(STRING_STARTS_WITH(format,
"svc"));
580 PrintSoftwareInterrupt(instr->SvcValue());
582 }
else if (format[1] ==
'i') {
583 ASSERT(STRING_STARTS_WITH(format,
"sign"));
584 if (instr->HasSign()) {
596 ASSERT(STRING_STARTS_WITH(format,
"target"));
597 int off = (instr->SImmed24Value() << 2) + 8;
598 out_buffer_pos_ +=
OS::SNPrintF(out_buffer_ + out_buffer_pos_,
601 converter_.NameOfAddress(
602 reinterpret_cast<byte*>(instr) + off));
618 if (instr->Bit(22) == 0) {
626 return FormatVFPinstruction(instr, format);
630 return FormatVFPRegister(instr, format);
651 void Decoder::Format(Instruction* instr,
const char* format) {
652 char cur = *format++;
653 while ((cur != 0) && (out_buffer_pos_ < (out_buffer_.length() - 1))) {
655 format += FormatOption(instr, format);
657 out_buffer_[out_buffer_pos_++] = cur;
661 out_buffer_[out_buffer_pos_] =
'\0';
667 #define VERIFY(condition) \
676 void Decoder::Unknown(Instruction* instr) {
677 Format(instr,
"unknown");
681 void Decoder::DecodeType01(Instruction* instr) {
682 int type = instr->TypeValue();
683 if ((type == 0) && instr->IsSpecialType0()) {
685 if (instr->Bits(7, 4) == 9) {
686 if (instr->Bit(24) == 0) {
688 if (instr->Bit(23) == 0) {
689 if (instr->Bit(21) == 0) {
693 Format(instr,
"mul'cond's 'rn, 'rm, 'rs");
699 Format(instr,
"mla'cond's 'rn, 'rm, 'rs, 'rd");
708 Format(instr,
"'um'al'cond's 'rd, 'rn, 'rm, 'rs");
713 }
else if ((instr->Bit(20) == 0) && ((instr->Bits(7, 4) & 0xd) == 0xd)) {
715 switch (instr->PUField()) {
717 if (instr->Bit(22) == 0) {
718 Format(instr,
"'memop'cond's 'rd, ['rn], -'rm");
720 Format(instr,
"'memop'cond's 'rd, ['rn], #-'off8");
725 if (instr->Bit(22) == 0) {
726 Format(instr,
"'memop'cond's 'rd, ['rn], +'rm");
728 Format(instr,
"'memop'cond's 'rd, ['rn], #+'off8");
733 if (instr->Bit(22) == 0) {
734 Format(instr,
"'memop'cond's 'rd, ['rn, -'rm]'w");
736 Format(instr,
"'memop'cond's 'rd, ['rn, #-'off8]'w");
741 if (instr->Bit(22) == 0) {
742 Format(instr,
"'memop'cond's 'rd, ['rn, +'rm]'w");
744 Format(instr,
"'memop'cond's 'rd, ['rn, #+'off8]'w");
756 switch (instr->PUField()) {
758 if (instr->Bit(22) == 0) {
759 Format(instr,
"'memop'cond'sign'h 'rd, ['rn], -'rm");
761 Format(instr,
"'memop'cond'sign'h 'rd, ['rn], #-'off8");
766 if (instr->Bit(22) == 0) {
767 Format(instr,
"'memop'cond'sign'h 'rd, ['rn], +'rm");
769 Format(instr,
"'memop'cond'sign'h 'rd, ['rn], #+'off8");
774 if (instr->Bit(22) == 0) {
775 Format(instr,
"'memop'cond'sign'h 'rd, ['rn, -'rm]'w");
777 Format(instr,
"'memop'cond'sign'h 'rd, ['rn, #-'off8]'w");
782 if (instr->Bit(22) == 0) {
783 Format(instr,
"'memop'cond'sign'h 'rd, ['rn, +'rm]'w");
785 Format(instr,
"'memop'cond'sign'h 'rd, ['rn, #+'off8]'w");
797 }
else if ((type == 0) && instr->IsMiscType0()) {
798 if (instr->Bits(22, 21) == 1) {
799 switch (instr->BitField(7, 4)) {
801 Format(instr,
"bx'cond 'rm");
804 Format(instr,
"blx'cond 'rm");
807 Format(instr,
"bkpt 'off0to3and8to19");
813 }
else if (instr->Bits(22, 21) == 3) {
814 switch (instr->BitField(7, 4)) {
816 Format(instr,
"clz'cond 'rd, 'rm");
826 switch (instr->OpcodeField()) {
828 Format(instr,
"and'cond's 'rd, 'rn, 'shift_op");
832 Format(instr,
"eor'cond's 'rd, 'rn, 'shift_op");
836 Format(instr,
"sub'cond's 'rd, 'rn, 'shift_op");
840 Format(instr,
"rsb'cond's 'rd, 'rn, 'shift_op");
844 Format(instr,
"add'cond's 'rd, 'rn, 'shift_op");
848 Format(instr,
"adc'cond's 'rd, 'rn, 'shift_op");
852 Format(instr,
"sbc'cond's 'rd, 'rn, 'shift_op");
856 Format(instr,
"rsc'cond's 'rd, 'rn, 'shift_op");
861 Format(instr,
"tst'cond 'rn, 'shift_op");
863 Format(instr,
"movw'cond 'mw");
869 Format(instr,
"teq'cond 'rn, 'shift_op");
879 Format(instr,
"cmp'cond 'rn, 'shift_op");
881 Format(instr,
"movt'cond 'mw");
887 Format(instr,
"cmn'cond 'rn, 'shift_op");
896 Format(instr,
"orr'cond's 'rd, 'rn, 'shift_op");
900 Format(instr,
"mov'cond's 'rd, 'shift_op");
904 Format(instr,
"bic'cond's 'rd, 'rn, 'shift_op");
908 Format(instr,
"mvn'cond's 'rd, 'shift_op");
921 void Decoder::DecodeType2(Instruction* instr) {
922 switch (instr->PUField()) {
928 Format(instr,
"'memop'cond'b 'rd, ['rn], #-'off12");
936 Format(instr,
"'memop'cond'b 'rd, ['rn], #+'off12");
940 Format(instr,
"'memop'cond'b 'rd, ['rn, #-'off12]'w");
944 Format(instr,
"'memop'cond'b 'rd, ['rn, #+'off12]'w");
956 void Decoder::DecodeType3(Instruction* instr) {
957 switch (instr->PUField()) {
959 VERIFY(!instr->HasW());
960 Format(instr,
"'memop'cond'b 'rd, ['rn], -'shift_rm");
965 VERIFY(instr->Bits(5, 4) == 0x1);
966 if (instr->Bit(22) == 0x1) {
967 Format(instr,
"usat 'rd, #'imm05@16, 'rm'shift_sat");
972 Format(instr,
"'memop'cond'b 'rd, ['rn], +'shift_rm");
977 Format(instr,
"'memop'cond'b 'rd, ['rn, -'shift_rm]'w");
981 if (instr->HasW() && (instr->Bits(6, 4) == 0x5)) {
982 uint32_t widthminus1 =
static_cast<uint32_t
>(instr->Bits(20, 16));
983 uint32_t lsbit =
static_cast<uint32_t
>(instr->Bits(11, 7));
984 uint32_t msbit = widthminus1 + lsbit;
986 if (instr->Bit(22)) {
987 Format(instr,
"ubfx'cond 'rd, 'rm, 'f");
989 Format(instr,
"sbfx'cond 'rd, 'rm, 'f");
994 }
else if (!instr->HasW() && (instr->Bits(6, 4) == 0x1)) {
995 uint32_t lsbit =
static_cast<uint32_t
>(instr->Bits(11, 7));
996 uint32_t msbit =
static_cast<uint32_t
>(instr->Bits(20, 16));
997 if (msbit >= lsbit) {
998 if (instr->RmValue() == 15) {
999 Format(instr,
"bfc'cond 'rd, 'f");
1001 Format(instr,
"bfi'cond 'rd, 'rm, 'f");
1007 Format(instr,
"'memop'cond'b 'rd, ['rn, +'shift_rm]'w");
1020 void Decoder::DecodeType4(Instruction* instr) {
1021 if (instr->Bit(22) != 0) {
1025 if (instr->HasL()) {
1026 Format(instr,
"ldm'cond'pu 'rn'w, 'rlist");
1028 Format(instr,
"stm'cond'pu 'rn'w, 'rlist");
1034 void Decoder::DecodeType5(Instruction* instr) {
1035 Format(instr,
"b'l'cond 'target");
1039 void Decoder::DecodeType6(Instruction* instr) {
1040 DecodeType6CoprocessorIns(instr);
1044 int Decoder::DecodeType7(Instruction* instr) {
1045 if (instr->Bit(24) == 1) {
1047 Format(instr,
"stop'cond 'svc");
1050 out_buffer_pos_ +=
OS::SNPrintF(out_buffer_ + out_buffer_pos_,
1051 "\n %p %08x stop message: %s",
1052 reinterpret_cast<int32_t*>(instr
1054 *reinterpret_cast<char**>(instr
1056 *reinterpret_cast<char**>(instr
1061 Format(instr,
"svc'cond 'svc");
1064 DecodeTypeVFP(instr);
1085 void Decoder::DecodeTypeVFP(Instruction* instr) {
1086 VERIFY((instr->TypeValue() == 7) && (instr->Bit(24) == 0x0) );
1087 VERIFY(instr->Bits(11, 9) == 0x5);
1089 if (instr->Bit(4) == 0) {
1090 if (instr->Opc1Value() == 0x7) {
1092 if ((instr->Opc2Value() == 0x0) && (instr->Opc3Value() == 0x1)) {
1094 if (instr->SzValue() == 0x1) {
1095 Format(instr,
"vmov.f64'cond 'Dd, 'Dm");
1097 Format(instr,
"vmov.f32'cond 'Sd, 'Sm");
1099 }
else if ((instr->Opc2Value() == 0x0) && (instr->Opc3Value() == 0x3)) {
1101 Format(instr,
"vabs.f64'cond 'Dd, 'Dm");
1102 }
else if ((instr->Opc2Value() == 0x1) && (instr->Opc3Value() == 0x1)) {
1104 Format(instr,
"vneg.f64'cond 'Dd, 'Dm");
1105 }
else if ((instr->Opc2Value() == 0x7) && (instr->Opc3Value() == 0x3)) {
1106 DecodeVCVTBetweenDoubleAndSingle(instr);
1107 }
else if ((instr->Opc2Value() == 0x8) && (instr->Opc3Value() & 0x1)) {
1108 DecodeVCVTBetweenFloatingPointAndInteger(instr);
1109 }
else if (((instr->Opc2Value() >> 1) == 0x6) &&
1110 (instr->Opc3Value() & 0x1)) {
1111 DecodeVCVTBetweenFloatingPointAndInteger(instr);
1112 }
else if (((instr->Opc2Value() == 0x4) || (instr->Opc2Value() == 0x5)) &&
1113 (instr->Opc3Value() & 0x1)) {
1115 }
else if (((instr->Opc2Value() == 0x1)) && (instr->Opc3Value() == 0x3)) {
1116 Format(instr,
"vsqrt.f64'cond 'Dd, 'Dm");
1117 }
else if (instr->Opc3Value() == 0x0) {
1118 if (instr->SzValue() == 0x1) {
1119 Format(instr,
"vmov.f64'cond 'Dd, 'd");
1126 }
else if (instr->Opc1Value() == 0x3) {
1127 if (instr->SzValue() == 0x1) {
1128 if (instr->Opc3Value() & 0x1) {
1129 Format(instr,
"vsub.f64'cond 'Dd, 'Dn, 'Dm");
1131 Format(instr,
"vadd.f64'cond 'Dd, 'Dn, 'Dm");
1136 }
else if ((instr->Opc1Value() == 0x2) && !(instr->Opc3Value() & 0x1)) {
1137 if (instr->SzValue() == 0x1) {
1138 Format(instr,
"vmul.f64'cond 'Dd, 'Dn, 'Dm");
1142 }
else if ((instr->Opc1Value() == 0x4) && !(instr->Opc3Value() & 0x1)) {
1143 if (instr->SzValue() == 0x1) {
1144 Format(instr,
"vdiv.f64'cond 'Dd, 'Dn, 'Dm");
1152 if ((instr->VCValue() == 0x0) &&
1153 (instr->VAValue() == 0x0)) {
1154 DecodeVMOVBetweenCoreAndSinglePrecisionRegisters(instr);
1155 }
else if ((instr->VCValue() == 0x0) &&
1156 (instr->VAValue() == 0x7) &&
1157 (instr->Bits(19, 16) == 0x1)) {
1158 if (instr->VLValue() == 0) {
1159 if (instr->Bits(15, 12) == 0xF) {
1160 Format(instr,
"vmsr'cond FPSCR, APSR");
1162 Format(instr,
"vmsr'cond FPSCR, 'rt");
1165 if (instr->Bits(15, 12) == 0xF) {
1166 Format(instr,
"vmrs'cond APSR, FPSCR");
1168 Format(instr,
"vmrs'cond 'rt, FPSCR");
1176 void Decoder::DecodeVMOVBetweenCoreAndSinglePrecisionRegisters(
1177 Instruction* instr) {
1178 VERIFY((instr->Bit(4) == 1) && (instr->VCValue() == 0x0) &&
1179 (instr->VAValue() == 0x0));
1181 bool to_arm_register = (instr->VLValue() == 0x1);
1183 if (to_arm_register) {
1184 Format(instr,
"vmov'cond 'rt, 'Sn");
1186 Format(instr,
"vmov'cond 'Sn, 'rt");
1191 void Decoder::DecodeVCMP(Instruction* instr) {
1192 VERIFY((instr->Bit(4) == 0) && (instr->Opc1Value() == 0x7));
1193 VERIFY(((instr->Opc2Value() == 0x4) || (instr->Opc2Value() == 0x5)) &&
1194 (instr->Opc3Value() & 0x1));
1197 bool dp_operation = (instr->SzValue() == 1);
1198 bool raise_exception_for_qnan = (instr->Bit(7) == 0x1);
1200 if (dp_operation && !raise_exception_for_qnan) {
1201 if (instr->Opc2Value() == 0x4) {
1202 Format(instr,
"vcmp.f64'cond 'Dd, 'Dm");
1203 }
else if (instr->Opc2Value() == 0x5) {
1204 Format(instr,
"vcmp.f64'cond 'Dd, #0.0");
1214 void Decoder::DecodeVCVTBetweenDoubleAndSingle(Instruction* instr) {
1215 VERIFY((instr->Bit(4) == 0) && (instr->Opc1Value() == 0x7));
1216 VERIFY((instr->Opc2Value() == 0x7) && (instr->Opc3Value() == 0x3));
1218 bool double_to_single = (instr->SzValue() == 1);
1220 if (double_to_single) {
1221 Format(instr,
"vcvt.f32.f64'cond 'Sd, 'Dm");
1223 Format(instr,
"vcvt.f64.f32'cond 'Dd, 'Sm");
1228 void Decoder::DecodeVCVTBetweenFloatingPointAndInteger(Instruction* instr) {
1229 VERIFY((instr->Bit(4) == 0) && (instr->Opc1Value() == 0x7));
1230 VERIFY(((instr->Opc2Value() == 0x8) && (instr->Opc3Value() & 0x1)) ||
1231 (((instr->Opc2Value() >> 1) == 0x6) && (instr->Opc3Value() & 0x1)));
1233 bool to_integer = (instr->Bit(18) == 1);
1234 bool dp_operation = (instr->SzValue() == 1);
1236 bool unsigned_integer = (instr->Bit(16) == 0);
1239 if (unsigned_integer) {
1240 Format(instr,
"vcvt.u32.f64'cond 'Sd, 'Dm");
1242 Format(instr,
"vcvt.s32.f64'cond 'Sd, 'Dm");
1245 if (unsigned_integer) {
1246 Format(instr,
"vcvt.u32.f32'cond 'Sd, 'Sm");
1248 Format(instr,
"vcvt.s32.f32'cond 'Sd, 'Sm");
1252 bool unsigned_integer = (instr->Bit(7) == 0);
1255 if (unsigned_integer) {
1256 Format(instr,
"vcvt.f64.u32'cond 'Dd, 'Sm");
1258 Format(instr,
"vcvt.f64.s32'cond 'Dd, 'Sm");
1261 if (unsigned_integer) {
1262 Format(instr,
"vcvt.f32.u32'cond 'Sd, 'Sm");
1264 Format(instr,
"vcvt.f32.s32'cond 'Sd, 'Sm");
1276 void Decoder::DecodeType6CoprocessorIns(Instruction* instr) {
1277 VERIFY(instr->TypeValue() == 6);
1279 if (instr->CoprocessorValue() == 0xA) {
1280 switch (instr->OpcodeValue()) {
1283 if (instr->HasL()) {
1284 Format(instr,
"vldr'cond 'Sd, ['rn - 4*'imm08@00]");
1286 Format(instr,
"vstr'cond 'Sd, ['rn - 4*'imm08@00]");
1291 if (instr->HasL()) {
1292 Format(instr,
"vldr'cond 'Sd, ['rn + 4*'imm08@00]");
1294 Format(instr,
"vstr'cond 'Sd, ['rn + 4*'imm08@00]");
1303 bool to_vfp_register = (instr->VLValue() == 0x1);
1304 if (to_vfp_register) {
1305 Format(instr,
"vldm'cond'pu 'rn'w, {'Sd-'Sd+}");
1307 Format(instr,
"vstm'cond'pu 'rn'w, {'Sd-'Sd+}");
1314 }
else if (instr->CoprocessorValue() == 0xB) {
1315 switch (instr->OpcodeValue()) {
1318 if (instr->Bits(7, 4) != 0x1) {
1320 }
else if (instr->HasL()) {
1321 Format(instr,
"vmov'cond 'rt, 'rn, 'Dm");
1323 Format(instr,
"vmov'cond 'Dm, 'rt, 'rn");
1327 if (instr->HasL()) {
1328 Format(instr,
"vldr'cond 'Dd, ['rn - 4*'imm08@00]");
1330 Format(instr,
"vstr'cond 'Dd, ['rn - 4*'imm08@00]");
1334 if (instr->HasL()) {
1335 Format(instr,
"vldr'cond 'Dd, ['rn + 4*'imm08@00]");
1337 Format(instr,
"vstr'cond 'Dd, ['rn + 4*'imm08@00]");
1343 bool to_vfp_register = (instr->VLValue() == 0x1);
1344 if (to_vfp_register) {
1345 Format(instr,
"vldm'cond'pu 'rn'w, {'Dd-'Dd+}");
1347 Format(instr,
"vstm'cond'pu 'rn'w, {'Dd-'Dd+}");
1361 bool Decoder::IsConstantPoolAt(
byte* instr_ptr) {
1362 int instruction_bits = *(
reinterpret_cast<int*
>(instr_ptr));
1367 int Decoder::ConstantPoolSizeAt(
byte* instr_ptr) {
1368 if (IsConstantPoolAt(instr_ptr)) {
1369 int instruction_bits = *(
reinterpret_cast<int*
>(instr_ptr));
1378 int Decoder::InstructionDecode(
byte* instr_ptr) {
1381 out_buffer_pos_ +=
OS::SNPrintF(out_buffer_ + out_buffer_pos_,
1383 instr->InstructionBits());
1388 int instruction_bits = *(
reinterpret_cast<int*
>(instr_ptr));
1390 out_buffer_pos_ +=
OS::SNPrintF(out_buffer_ + out_buffer_pos_,
1391 "constant pool begin (length %d)",
1396 switch (instr->TypeValue()) {
1399 DecodeType01(instr);
1423 return DecodeType7(instr);
1482 : converter_(converter) {}
1485 Disassembler::~Disassembler() {}
1489 byte* instruction) {
1490 v8::internal::Decoder d(converter_, buffer);
1491 return d.InstructionDecode(instruction);
1495 int Disassembler::ConstantPoolSizeAt(
byte* instruction) {
1496 return v8::internal::Decoder::ConstantPoolSizeAt(instruction);
1500 void Disassembler::Disassemble(FILE* f,
byte* begin,
byte* end) {
1501 NameConverter converter;
1502 Disassembler d(converter);
1503 for (
byte*
pc = begin;
pc < end;) {
1507 pc += d.InstructionDecode(buffer,
pc);
1508 fprintf(f,
"%p %08x %s\n",
1509 prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer.
start());
1516 #endif // V8_TARGET_ARCH_ARM
Disassembler(const NameConverter &converter)
virtual const char * NameOfXMMRegister(int reg) const
v8::internal::EmbeddedVector< char, 128 > tmp_buffer_
virtual const char * NameOfConstant(byte *addr) const
static const char * Name(int reg, bool is_double)
#define ASSERT(condition)
v8::Handle< v8::Value > Print(const v8::Arguments &args)
const uint32_t kStopCodeMask
virtual const char * NameInCode(byte *addr) const
static const char * Name(int reg)
virtual const char * NameOfByteCPURegister(int reg) const
static Instruction * At(byte *pc)
virtual const char * NameOfCPURegister(int reg) const
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
virtual const char * NameOfAddress(byte *addr) const
static int SNPrintF(Vector< char > str, const char *format,...)
const int kConstantPoolMarker
const int kConstantPoolMarkerMask
const int kConstantPoolLengthMask