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");
695 if (instr->Bit(22) == 0) {
700 Format(instr,
"mla'cond's 'rn, 'rm, 'rs, 'rd");
706 Format(instr,
"mls'cond's 'rn, 'rm, 'rs, 'rd");
716 Format(instr,
"'um'al'cond's 'rd, 'rn, 'rm, 'rs");
721 }
else if ((instr->Bit(20) == 0) && ((instr->Bits(7, 4) & 0xd) == 0xd)) {
723 switch (instr->PUField()) {
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");
736 Format(instr,
"'memop'cond's 'rd, ['rn], #+'off8");
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");
749 if (instr->Bit(22) == 0) {
750 Format(instr,
"'memop'cond's 'rd, ['rn, +'rm]'w");
752 Format(instr,
"'memop'cond's 'rd, ['rn, #+'off8]'w");
764 switch (instr->PUField()) {
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");
777 Format(instr,
"'memop'cond'sign'h 'rd, ['rn], #+'off8");
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");
790 if (instr->Bit(22) == 0) {
791 Format(instr,
"'memop'cond'sign'h 'rd, ['rn, +'rm]'w");
793 Format(instr,
"'memop'cond'sign'h 'rd, ['rn, #+'off8]'w");
805 }
else if ((type == 0) && instr->IsMiscType0()) {
806 if (instr->Bits(22, 21) == 1) {
807 switch (instr->BitField(7, 4)) {
809 Format(instr,
"bx'cond 'rm");
812 Format(instr,
"blx'cond 'rm");
815 Format(instr,
"bkpt 'off0to3and8to19");
821 }
else if (instr->Bits(22, 21) == 3) {
822 switch (instr->BitField(7, 4)) {
824 Format(instr,
"clz'cond 'rd, 'rm");
833 }
else if ((type == 1) && instr->IsNopType1()) {
834 Format(instr,
"nop'cond");
836 switch (instr->OpcodeField()) {
838 Format(instr,
"and'cond's 'rd, 'rn, 'shift_op");
842 Format(instr,
"eor'cond's 'rd, 'rn, 'shift_op");
846 Format(instr,
"sub'cond's 'rd, 'rn, 'shift_op");
850 Format(instr,
"rsb'cond's 'rd, 'rn, 'shift_op");
854 Format(instr,
"add'cond's 'rd, 'rn, 'shift_op");
858 Format(instr,
"adc'cond's 'rd, 'rn, 'shift_op");
862 Format(instr,
"sbc'cond's 'rd, 'rn, 'shift_op");
866 Format(instr,
"rsc'cond's 'rd, 'rn, 'shift_op");
871 Format(instr,
"tst'cond 'rn, 'shift_op");
873 Format(instr,
"movw'cond 'mw");
879 Format(instr,
"teq'cond 'rn, 'shift_op");
889 Format(instr,
"cmp'cond 'rn, 'shift_op");
891 Format(instr,
"movt'cond 'mw");
897 Format(instr,
"cmn'cond 'rn, 'shift_op");
906 Format(instr,
"orr'cond's 'rd, 'rn, 'shift_op");
910 Format(instr,
"mov'cond's 'rd, 'shift_op");
914 Format(instr,
"bic'cond's 'rd, 'rn, 'shift_op");
918 Format(instr,
"mvn'cond's 'rd, 'shift_op");
931 void Decoder::DecodeType2(Instruction* instr) {
932 switch (instr->PUField()) {
938 Format(instr,
"'memop'cond'b 'rd, ['rn], #-'off12");
946 Format(instr,
"'memop'cond'b 'rd, ['rn], #+'off12");
950 Format(instr,
"'memop'cond'b 'rd, ['rn, #-'off12]'w");
954 Format(instr,
"'memop'cond'b 'rd, ['rn, #+'off12]'w");
966 void Decoder::DecodeType3(Instruction* instr) {
967 switch (instr->PUField()) {
969 VERIFY(!instr->HasW());
970 Format(instr,
"'memop'cond'b 'rd, ['rn], -'shift_rm");
975 VERIFY(instr->Bits(5, 4) == 0x1);
976 if (instr->Bit(22) == 0x1) {
977 Format(instr,
"usat 'rd, #'imm05@16, 'rm'shift_sat");
982 Format(instr,
"'memop'cond'b 'rd, ['rn], +'shift_rm");
987 if (FLAG_enable_sudiv) {
988 if (!instr->HasW()) {
989 if (instr->Bits(5, 4) == 0x1) {
990 if ((instr->Bit(22) == 0x0) && (instr->Bit(20) == 0x1)) {
992 Format(instr,
"sdiv'cond'b 'rn, 'rm, 'rs");
998 Format(instr,
"'memop'cond'b 'rd, ['rn, -'shift_rm]'w");
1002 if (instr->HasW() && (instr->Bits(6, 4) == 0x5)) {
1003 uint32_t widthminus1 =
static_cast<uint32_t
>(instr->Bits(20, 16));
1004 uint32_t lsbit =
static_cast<uint32_t
>(instr->Bits(11, 7));
1005 uint32_t msbit = widthminus1 + lsbit;
1007 if (instr->Bit(22)) {
1008 Format(instr,
"ubfx'cond 'rd, 'rm, 'f");
1010 Format(instr,
"sbfx'cond 'rd, 'rm, 'f");
1015 }
else if (!instr->HasW() && (instr->Bits(6, 4) == 0x1)) {
1016 uint32_t lsbit =
static_cast<uint32_t
>(instr->Bits(11, 7));
1017 uint32_t msbit =
static_cast<uint32_t
>(instr->Bits(20, 16));
1018 if (msbit >= lsbit) {
1019 if (instr->RmValue() == 15) {
1020 Format(instr,
"bfc'cond 'rd, 'f");
1022 Format(instr,
"bfi'cond 'rd, 'rm, 'f");
1028 Format(instr,
"'memop'cond'b 'rd, ['rn, +'shift_rm]'w");
1041 void Decoder::DecodeType4(Instruction* instr) {
1042 if (instr->Bit(22) != 0) {
1046 if (instr->HasL()) {
1047 Format(instr,
"ldm'cond'pu 'rn'w, 'rlist");
1049 Format(instr,
"stm'cond'pu 'rn'w, 'rlist");
1055 void Decoder::DecodeType5(Instruction* instr) {
1056 Format(instr,
"b'l'cond 'target");
1060 void Decoder::DecodeType6(Instruction* instr) {
1061 DecodeType6CoprocessorIns(instr);
1065 int Decoder::DecodeType7(Instruction* instr) {
1066 if (instr->Bit(24) == 1) {
1068 Format(instr,
"stop'cond 'svc");
1071 out_buffer_pos_ +=
OS::SNPrintF(out_buffer_ + out_buffer_pos_,
1072 "\n %p %08x stop message: %s",
1073 reinterpret_cast<int32_t*>(instr
1075 *reinterpret_cast<char**>(instr
1077 *reinterpret_cast<char**>(instr
1082 Format(instr,
"svc'cond 'svc");
1085 DecodeTypeVFP(instr);
1106 void Decoder::DecodeTypeVFP(Instruction* instr) {
1107 VERIFY((instr->TypeValue() == 7) && (instr->Bit(24) == 0x0) );
1108 VERIFY(instr->Bits(11, 9) == 0x5);
1110 if (instr->Bit(4) == 0) {
1111 if (instr->Opc1Value() == 0x7) {
1113 if ((instr->Opc2Value() == 0x0) && (instr->Opc3Value() == 0x1)) {
1115 if (instr->SzValue() == 0x1) {
1116 Format(instr,
"vmov.f64'cond 'Dd, 'Dm");
1118 Format(instr,
"vmov.f32'cond 'Sd, 'Sm");
1120 }
else if ((instr->Opc2Value() == 0x0) && (instr->Opc3Value() == 0x3)) {
1122 Format(instr,
"vabs.f64'cond 'Dd, 'Dm");
1123 }
else if ((instr->Opc2Value() == 0x1) && (instr->Opc3Value() == 0x1)) {
1125 Format(instr,
"vneg.f64'cond 'Dd, 'Dm");
1126 }
else if ((instr->Opc2Value() == 0x7) && (instr->Opc3Value() == 0x3)) {
1127 DecodeVCVTBetweenDoubleAndSingle(instr);
1128 }
else if ((instr->Opc2Value() == 0x8) && (instr->Opc3Value() & 0x1)) {
1129 DecodeVCVTBetweenFloatingPointAndInteger(instr);
1130 }
else if (((instr->Opc2Value() >> 1) == 0x6) &&
1131 (instr->Opc3Value() & 0x1)) {
1132 DecodeVCVTBetweenFloatingPointAndInteger(instr);
1133 }
else if (((instr->Opc2Value() == 0x4) || (instr->Opc2Value() == 0x5)) &&
1134 (instr->Opc3Value() & 0x1)) {
1136 }
else if (((instr->Opc2Value() == 0x1)) && (instr->Opc3Value() == 0x3)) {
1137 Format(instr,
"vsqrt.f64'cond 'Dd, 'Dm");
1138 }
else if (instr->Opc3Value() == 0x0) {
1139 if (instr->SzValue() == 0x1) {
1140 Format(instr,
"vmov.f64'cond 'Dd, 'd");
1147 }
else if (instr->Opc1Value() == 0x3) {
1148 if (instr->SzValue() == 0x1) {
1149 if (instr->Opc3Value() & 0x1) {
1150 Format(instr,
"vsub.f64'cond 'Dd, 'Dn, 'Dm");
1152 Format(instr,
"vadd.f64'cond 'Dd, 'Dn, 'Dm");
1157 }
else if ((instr->Opc1Value() == 0x2) && !(instr->Opc3Value() & 0x1)) {
1158 if (instr->SzValue() == 0x1) {
1159 Format(instr,
"vmul.f64'cond 'Dd, 'Dn, 'Dm");
1163 }
else if ((instr->Opc1Value() == 0x4) && !(instr->Opc3Value() & 0x1)) {
1164 if (instr->SzValue() == 0x1) {
1165 Format(instr,
"vdiv.f64'cond 'Dd, 'Dn, 'Dm");
1173 if ((instr->VCValue() == 0x0) &&
1174 (instr->VAValue() == 0x0)) {
1175 DecodeVMOVBetweenCoreAndSinglePrecisionRegisters(instr);
1176 }
else if ((instr->VCValue() == 0x0) &&
1177 (instr->VAValue() == 0x7) &&
1178 (instr->Bits(19, 16) == 0x1)) {
1179 if (instr->VLValue() == 0) {
1180 if (instr->Bits(15, 12) == 0xF) {
1181 Format(instr,
"vmsr'cond FPSCR, APSR");
1183 Format(instr,
"vmsr'cond FPSCR, 'rt");
1186 if (instr->Bits(15, 12) == 0xF) {
1187 Format(instr,
"vmrs'cond APSR, FPSCR");
1189 Format(instr,
"vmrs'cond 'rt, FPSCR");
1197 void Decoder::DecodeVMOVBetweenCoreAndSinglePrecisionRegisters(
1198 Instruction* instr) {
1199 VERIFY((instr->Bit(4) == 1) && (instr->VCValue() == 0x0) &&
1200 (instr->VAValue() == 0x0));
1202 bool to_arm_register = (instr->VLValue() == 0x1);
1204 if (to_arm_register) {
1205 Format(instr,
"vmov'cond 'rt, 'Sn");
1207 Format(instr,
"vmov'cond 'Sn, 'rt");
1212 void Decoder::DecodeVCMP(Instruction* instr) {
1213 VERIFY((instr->Bit(4) == 0) && (instr->Opc1Value() == 0x7));
1214 VERIFY(((instr->Opc2Value() == 0x4) || (instr->Opc2Value() == 0x5)) &&
1215 (instr->Opc3Value() & 0x1));
1218 bool dp_operation = (instr->SzValue() == 1);
1219 bool raise_exception_for_qnan = (instr->Bit(7) == 0x1);
1221 if (dp_operation && !raise_exception_for_qnan) {
1222 if (instr->Opc2Value() == 0x4) {
1223 Format(instr,
"vcmp.f64'cond 'Dd, 'Dm");
1224 }
else if (instr->Opc2Value() == 0x5) {
1225 Format(instr,
"vcmp.f64'cond 'Dd, #0.0");
1235 void Decoder::DecodeVCVTBetweenDoubleAndSingle(Instruction* instr) {
1236 VERIFY((instr->Bit(4) == 0) && (instr->Opc1Value() == 0x7));
1237 VERIFY((instr->Opc2Value() == 0x7) && (instr->Opc3Value() == 0x3));
1239 bool double_to_single = (instr->SzValue() == 1);
1241 if (double_to_single) {
1242 Format(instr,
"vcvt.f32.f64'cond 'Sd, 'Dm");
1244 Format(instr,
"vcvt.f64.f32'cond 'Dd, 'Sm");
1249 void Decoder::DecodeVCVTBetweenFloatingPointAndInteger(Instruction* instr) {
1250 VERIFY((instr->Bit(4) == 0) && (instr->Opc1Value() == 0x7));
1251 VERIFY(((instr->Opc2Value() == 0x8) && (instr->Opc3Value() & 0x1)) ||
1252 (((instr->Opc2Value() >> 1) == 0x6) && (instr->Opc3Value() & 0x1)));
1254 bool to_integer = (instr->Bit(18) == 1);
1255 bool dp_operation = (instr->SzValue() == 1);
1257 bool unsigned_integer = (instr->Bit(16) == 0);
1260 if (unsigned_integer) {
1261 Format(instr,
"vcvt.u32.f64'cond 'Sd, 'Dm");
1263 Format(instr,
"vcvt.s32.f64'cond 'Sd, 'Dm");
1266 if (unsigned_integer) {
1267 Format(instr,
"vcvt.u32.f32'cond 'Sd, 'Sm");
1269 Format(instr,
"vcvt.s32.f32'cond 'Sd, 'Sm");
1273 bool unsigned_integer = (instr->Bit(7) == 0);
1276 if (unsigned_integer) {
1277 Format(instr,
"vcvt.f64.u32'cond 'Dd, 'Sm");
1279 Format(instr,
"vcvt.f64.s32'cond 'Dd, 'Sm");
1282 if (unsigned_integer) {
1283 Format(instr,
"vcvt.f32.u32'cond 'Sd, 'Sm");
1285 Format(instr,
"vcvt.f32.s32'cond 'Sd, 'Sm");
1297 void Decoder::DecodeType6CoprocessorIns(Instruction* instr) {
1298 VERIFY(instr->TypeValue() == 6);
1300 if (instr->CoprocessorValue() == 0xA) {
1301 switch (instr->OpcodeValue()) {
1304 if (instr->HasL()) {
1305 Format(instr,
"vldr'cond 'Sd, ['rn - 4*'imm08@00]");
1307 Format(instr,
"vstr'cond 'Sd, ['rn - 4*'imm08@00]");
1312 if (instr->HasL()) {
1313 Format(instr,
"vldr'cond 'Sd, ['rn + 4*'imm08@00]");
1315 Format(instr,
"vstr'cond 'Sd, ['rn + 4*'imm08@00]");
1324 bool to_vfp_register = (instr->VLValue() == 0x1);
1325 if (to_vfp_register) {
1326 Format(instr,
"vldm'cond'pu 'rn'w, {'Sd-'Sd+}");
1328 Format(instr,
"vstm'cond'pu 'rn'w, {'Sd-'Sd+}");
1335 }
else if (instr->CoprocessorValue() == 0xB) {
1336 switch (instr->OpcodeValue()) {
1339 if (instr->Bits(7, 4) != 0x1) {
1341 }
else if (instr->HasL()) {
1342 Format(instr,
"vmov'cond 'rt, 'rn, 'Dm");
1344 Format(instr,
"vmov'cond 'Dm, 'rt, 'rn");
1348 if (instr->HasL()) {
1349 Format(instr,
"vldr'cond 'Dd, ['rn - 4*'imm08@00]");
1351 Format(instr,
"vstr'cond 'Dd, ['rn - 4*'imm08@00]");
1355 if (instr->HasL()) {
1356 Format(instr,
"vldr'cond 'Dd, ['rn + 4*'imm08@00]");
1358 Format(instr,
"vstr'cond 'Dd, ['rn + 4*'imm08@00]");
1364 bool to_vfp_register = (instr->VLValue() == 0x1);
1365 if (to_vfp_register) {
1366 Format(instr,
"vldm'cond'pu 'rn'w, {'Dd-'Dd+}");
1368 Format(instr,
"vstm'cond'pu 'rn'w, {'Dd-'Dd+}");
1382 bool Decoder::IsConstantPoolAt(
byte* instr_ptr) {
1383 int instruction_bits = *(
reinterpret_cast<int*
>(instr_ptr));
1388 int Decoder::ConstantPoolSizeAt(
byte* instr_ptr) {
1389 if (IsConstantPoolAt(instr_ptr)) {
1390 int instruction_bits = *(
reinterpret_cast<int*
>(instr_ptr));
1399 int Decoder::InstructionDecode(
byte* instr_ptr) {
1402 out_buffer_pos_ +=
OS::SNPrintF(out_buffer_ + out_buffer_pos_,
1404 instr->InstructionBits());
1409 int instruction_bits = *(
reinterpret_cast<int*
>(instr_ptr));
1411 out_buffer_pos_ +=
OS::SNPrintF(out_buffer_ + out_buffer_pos_,
1412 "constant pool begin (length %d)",
1417 switch (instr->TypeValue()) {
1420 DecodeType01(instr);
1444 return DecodeType7(instr);
1503 : converter_(converter) {}
1506 Disassembler::~Disassembler() {}
1510 byte* instruction) {
1511 v8::internal::Decoder d(converter_, buffer);
1512 return d.InstructionDecode(instruction);
1516 int Disassembler::ConstantPoolSizeAt(
byte* instruction) {
1517 return v8::internal::Decoder::ConstantPoolSizeAt(instruction);
1521 void Disassembler::Disassemble(FILE* f,
byte* begin,
byte* end) {
1522 NameConverter converter;
1523 Disassembler d(converter);
1524 for (
byte*
pc = begin;
pc < end;) {
1528 pc += d.InstructionDecode(buffer,
pc);
1529 fprintf(f,
"%p %08x %s\n",
1530 prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer.
start());
1537 #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