OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 93 |
94 private: | 94 private: |
95 // Bottleneck functions to print into the out_buffer. | 95 // Bottleneck functions to print into the out_buffer. |
96 void PrintChar(const char ch); | 96 void PrintChar(const char ch); |
97 void Print(const char* str); | 97 void Print(const char* str); |
98 | 98 |
99 // Printing of common values. | 99 // Printing of common values. |
100 void PrintRegister(int reg); | 100 void PrintRegister(int reg); |
101 void PrintSRegister(int reg); | 101 void PrintSRegister(int reg); |
102 void PrintDRegister(int reg); | 102 void PrintDRegister(int reg); |
103 int FormatVFPRegister(Instr* instr, const char* format); | 103 int FormatVFPRegister(Instruction* instr, const char* format); |
104 void PrintMovwMovt(Instr* instr); | 104 void PrintMovwMovt(Instruction* instr); |
105 int FormatVFPinstruction(Instr* instr, const char* format); | 105 int FormatVFPinstruction(Instruction* instr, const char* format); |
106 void PrintCondition(Instr* instr); | 106 void PrintCondition(Instruction* instr); |
107 void PrintShiftRm(Instr* instr); | 107 void PrintShiftRm(Instruction* instr); |
108 void PrintShiftImm(Instr* instr); | 108 void PrintShiftImm(Instruction* instr); |
109 void PrintShiftSat(Instr* instr); | 109 void PrintShiftSat(Instruction* instr); |
110 void PrintPU(Instr* instr); | 110 void PrintPU(Instruction* instr); |
111 void PrintSoftwareInterrupt(SoftwareInterruptCodes svc); | 111 void PrintSoftwareInterrupt(SoftwareInterruptCodes svc); |
112 | 112 |
113 // Handle formatting of instructions and their options. | 113 // Handle formatting of instructions and their options. |
114 int FormatRegister(Instr* instr, const char* option); | 114 int FormatRegister(Instruction* instr, const char* option); |
115 int FormatOption(Instr* instr, const char* option); | 115 int FormatOption(Instruction* instr, const char* option); |
116 void Format(Instr* instr, const char* format); | 116 void Format(Instruction* instr, const char* format); |
117 void Unknown(Instr* instr); | 117 void Unknown(Instruction* instr); |
118 | 118 |
119 // Each of these functions decodes one particular instruction type, a 3-bit | 119 // Each of these functions decodes one particular instruction type, a 3-bit |
120 // field in the instruction encoding. | 120 // field in the instruction encoding. |
121 // Types 0 and 1 are combined as they are largely the same except for the way | 121 // Types 0 and 1 are combined as they are largely the same except for the way |
122 // they interpret the shifter operand. | 122 // they interpret the shifter operand. |
123 void DecodeType01(Instr* instr); | 123 void DecodeType01(Instruction* instr); |
124 void DecodeType2(Instr* instr); | 124 void DecodeType2(Instruction* instr); |
125 void DecodeType3(Instr* instr); | 125 void DecodeType3(Instruction* instr); |
126 void DecodeType4(Instr* instr); | 126 void DecodeType4(Instruction* instr); |
127 void DecodeType5(Instr* instr); | 127 void DecodeType5(Instruction* instr); |
128 void DecodeType6(Instr* instr); | 128 void DecodeType6(Instruction* instr); |
129 // Type 7 includes special Debugger instructions. | 129 // Type 7 includes special Debugger instructions. |
130 int DecodeType7(Instr* instr); | 130 int DecodeType7(Instruction* instr); |
131 // For VFP support. | 131 // For VFP support. |
132 void DecodeTypeVFP(Instr* instr); | 132 void DecodeTypeVFP(Instruction* instr); |
133 void DecodeType6CoprocessorIns(Instr* instr); | 133 void DecodeType6CoprocessorIns(Instruction* instr); |
134 | 134 |
135 void DecodeVMOVBetweenCoreAndSinglePrecisionRegisters(Instr* instr); | 135 void DecodeVMOVBetweenCoreAndSinglePrecisionRegisters(Instruction* instr); |
136 void DecodeVCMP(Instr* instr); | 136 void DecodeVCMP(Instruction* instr); |
137 void DecodeVCVTBetweenDoubleAndSingle(Instr* instr); | 137 void DecodeVCVTBetweenDoubleAndSingle(Instruction* instr); |
138 void DecodeVCVTBetweenFloatingPointAndInteger(Instr* instr); | 138 void DecodeVCVTBetweenFloatingPointAndInteger(Instruction* instr); |
139 | 139 |
140 const disasm::NameConverter& converter_; | 140 const disasm::NameConverter& converter_; |
141 v8::internal::Vector<char> out_buffer_; | 141 v8::internal::Vector<char> out_buffer_; |
142 int out_buffer_pos_; | 142 int out_buffer_pos_; |
143 | 143 |
144 DISALLOW_COPY_AND_ASSIGN(Decoder); | 144 DISALLOW_COPY_AND_ASSIGN(Decoder); |
145 }; | 145 }; |
146 | 146 |
147 | 147 |
148 // Support for assertions in the Decoder formatting functions. | 148 // Support for assertions in the Decoder formatting functions. |
(...skipping 13 matching lines...) Expand all Loading... |
162 while (cur != '\0' && (out_buffer_pos_ < (out_buffer_.length() - 1))) { | 162 while (cur != '\0' && (out_buffer_pos_ < (out_buffer_.length() - 1))) { |
163 PrintChar(cur); | 163 PrintChar(cur); |
164 cur = *str++; | 164 cur = *str++; |
165 } | 165 } |
166 out_buffer_[out_buffer_pos_] = 0; | 166 out_buffer_[out_buffer_pos_] = 0; |
167 } | 167 } |
168 | 168 |
169 | 169 |
170 // These condition names are defined in a way to match the native disassembler | 170 // These condition names are defined in a way to match the native disassembler |
171 // formatting. See for example the command "objdump -d <binary file>". | 171 // formatting. See for example the command "objdump -d <binary file>". |
172 static const char* cond_names[max_condition] = { | 172 static const char* cond_names[number_of_conditions] = { |
173 "eq", "ne", "cs" , "cc" , "mi" , "pl" , "vs" , "vc" , | 173 "eq", "ne", "cs" , "cc" , "mi" , "pl" , "vs" , "vc" , |
174 "hi", "ls", "ge", "lt", "gt", "le", "", "invalid", | 174 "hi", "ls", "ge", "lt", "gt", "le", "", "invalid", |
175 }; | 175 }; |
176 | 176 |
177 | 177 |
178 // Print the condition guarding the instruction. | 178 // Print the condition guarding the instruction. |
179 void Decoder::PrintCondition(Instr* instr) { | 179 void Decoder::PrintCondition(Instruction* instr) { |
180 Print(cond_names[instr->ConditionField()]); | 180 Print(cond_names[instr->ConditionValue()]); |
181 } | 181 } |
182 | 182 |
183 | 183 |
184 // Print the register name according to the active name converter. | 184 // Print the register name according to the active name converter. |
185 void Decoder::PrintRegister(int reg) { | 185 void Decoder::PrintRegister(int reg) { |
186 Print(converter_.NameOfCPURegister(reg)); | 186 Print(converter_.NameOfCPURegister(reg)); |
187 } | 187 } |
188 | 188 |
189 // Print the VFP S register name according to the active name converter. | 189 // Print the VFP S register name according to the active name converter. |
190 void Decoder::PrintSRegister(int reg) { | 190 void Decoder::PrintSRegister(int reg) { |
191 Print(assembler::arm::VFPRegisters::Name(reg, false)); | 191 Print(assembler::arm::VFPRegisters::Name(reg, false)); |
192 } | 192 } |
193 | 193 |
194 // Print the VFP D register name according to the active name converter. | 194 // Print the VFP D register name according to the active name converter. |
195 void Decoder::PrintDRegister(int reg) { | 195 void Decoder::PrintDRegister(int reg) { |
196 Print(assembler::arm::VFPRegisters::Name(reg, true)); | 196 Print(assembler::arm::VFPRegisters::Name(reg, true)); |
197 } | 197 } |
198 | 198 |
199 | 199 |
200 // These shift names are defined in a way to match the native disassembler | 200 // These shift names are defined in a way to match the native disassembler |
201 // formatting. See for example the command "objdump -d <binary file>". | 201 // formatting. See for example the command "objdump -d <binary file>". |
202 static const char* shift_names[max_shift] = { | 202 static const char* shift_names[number_of_shifts] = { |
203 "lsl", "lsr", "asr", "ror" | 203 "lsl", "lsr", "asr", "ror" |
204 }; | 204 }; |
205 | 205 |
206 | 206 |
207 // Print the register shift operands for the instruction. Generally used for | 207 // Print the register shift operands for the instruction. Generally used for |
208 // data processing instructions. | 208 // data processing instructions. |
209 void Decoder::PrintShiftRm(Instr* instr) { | 209 void Decoder::PrintShiftRm(Instruction* instr) { |
210 Shift shift = instr->ShiftField(); | 210 ShiftOp shift = instr->ShiftField(); |
211 int shift_amount = instr->ShiftAmountField(); | 211 int shift_index = instr->ShiftValue(); |
212 int rm = instr->RmField(); | 212 int shift_amount = instr->ShiftAmountValue(); |
| 213 int rm = instr->RmValue(); |
213 | 214 |
214 PrintRegister(rm); | 215 PrintRegister(rm); |
215 | 216 |
216 if ((instr->RegShiftField() == 0) && (shift == LSL) && (shift_amount == 0)) { | 217 if ((instr->RegShiftValue() == 0) && (shift == LSL) && (shift_amount == 0)) { |
217 // Special case for using rm only. | 218 // Special case for using rm only. |
218 return; | 219 return; |
219 } | 220 } |
220 if (instr->RegShiftField() == 0) { | 221 if (instr->RegShiftValue() == 0) { |
221 // by immediate | 222 // by immediate |
222 if ((shift == ROR) && (shift_amount == 0)) { | 223 if ((shift == ROR) && (shift_amount == 0)) { |
223 Print(", RRX"); | 224 Print(", RRX"); |
224 return; | 225 return; |
225 } else if (((shift == LSR) || (shift == ASR)) && (shift_amount == 0)) { | 226 } else if (((shift == LSR) || (shift == ASR)) && (shift_amount == 0)) { |
226 shift_amount = 32; | 227 shift_amount = 32; |
227 } | 228 } |
228 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, | 229 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, |
229 ", %s #%d", | 230 ", %s #%d", |
230 shift_names[shift], shift_amount); | 231 shift_names[shift_index], |
| 232 shift_amount); |
231 } else { | 233 } else { |
232 // by register | 234 // by register |
233 int rs = instr->RsField(); | 235 int rs = instr->RsValue(); |
234 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, | 236 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, |
235 ", %s ", shift_names[shift]); | 237 ", %s ", shift_names[shift_index]); |
236 PrintRegister(rs); | 238 PrintRegister(rs); |
237 } | 239 } |
238 } | 240 } |
239 | 241 |
240 | 242 |
241 // Print the immediate operand for the instruction. Generally used for data | 243 // Print the immediate operand for the instruction. Generally used for data |
242 // processing instructions. | 244 // processing instructions. |
243 void Decoder::PrintShiftImm(Instr* instr) { | 245 void Decoder::PrintShiftImm(Instruction* instr) { |
244 int rotate = instr->RotateField() * 2; | 246 int rotate = instr->RotateValue() * 2; |
245 int immed8 = instr->Immed8Field(); | 247 int immed8 = instr->Immed8Value(); |
246 int imm = (immed8 >> rotate) | (immed8 << (32 - rotate)); | 248 int imm = (immed8 >> rotate) | (immed8 << (32 - rotate)); |
247 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, | 249 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, |
248 "#%d", imm); | 250 "#%d", imm); |
249 } | 251 } |
250 | 252 |
251 | 253 |
252 // Print the optional shift and immediate used by saturating instructions. | 254 // Print the optional shift and immediate used by saturating instructions. |
253 void Decoder::PrintShiftSat(Instr* instr) { | 255 void Decoder::PrintShiftSat(Instruction* instr) { |
254 int shift = instr->Bits(11, 7); | 256 int shift = instr->Bits(11, 7); |
255 if (shift > 0) { | 257 if (shift > 0) { |
256 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, | 258 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, |
257 ", %s #%d", | 259 ", %s #%d", |
258 shift_names[instr->Bit(6) * 2], | 260 shift_names[instr->Bit(6) * 2], |
259 instr->Bits(11, 7)); | 261 instr->Bits(11, 7)); |
260 } | 262 } |
261 } | 263 } |
262 | 264 |
263 | 265 |
264 // Print PU formatting to reduce complexity of FormatOption. | 266 // Print PU formatting to reduce complexity of FormatOption. |
265 void Decoder::PrintPU(Instr* instr) { | 267 void Decoder::PrintPU(Instruction* instr) { |
266 switch (instr->PUField()) { | 268 switch (instr->PUField()) { |
267 case 0: { | 269 case da_x: { |
268 Print("da"); | 270 Print("da"); |
269 break; | 271 break; |
270 } | 272 } |
271 case 1: { | 273 case ia_x: { |
272 Print("ia"); | 274 Print("ia"); |
273 break; | 275 break; |
274 } | 276 } |
275 case 2: { | 277 case db_x: { |
276 Print("db"); | 278 Print("db"); |
277 break; | 279 break; |
278 } | 280 } |
279 case 3: { | 281 case ib_x: { |
280 Print("ib"); | 282 Print("ib"); |
281 break; | 283 break; |
282 } | 284 } |
283 default: { | 285 default: { |
284 UNREACHABLE(); | 286 UNREACHABLE(); |
285 break; | 287 break; |
286 } | 288 } |
287 } | 289 } |
288 } | 290 } |
289 | 291 |
290 | 292 |
291 // Print SoftwareInterrupt codes. Factoring this out reduces the complexity of | 293 // Print SoftwareInterrupt codes. Factoring this out reduces the complexity of |
292 // the FormatOption method. | 294 // the FormatOption method. |
293 void Decoder::PrintSoftwareInterrupt(SoftwareInterruptCodes svc) { | 295 void Decoder::PrintSoftwareInterrupt(SoftwareInterruptCodes svc) { |
294 switch (svc) { | 296 switch (svc) { |
295 case call_rt_redirected: | 297 case call_rt_redirected: |
296 Print("call_rt_redirected"); | 298 Print("call_rt_redirected"); |
297 return; | 299 return; |
298 case break_point: | 300 case break_point: |
299 Print("break_point"); | 301 Print("break_point"); |
300 return; | 302 return; |
301 default: | 303 default: |
302 if (svc >= stop) { | 304 if (svc >= stop_code) { |
303 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, | 305 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, |
304 "%d - 0x%x", | 306 "%d - 0x%x", |
305 svc & kStopCodeMask, | 307 svc & kStopCodeMask, |
306 svc & kStopCodeMask); | 308 svc & kStopCodeMask); |
307 } else { | 309 } else { |
308 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, | 310 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, |
309 "%d", | 311 "%d", |
310 svc); | 312 svc); |
311 } | 313 } |
312 return; | 314 return; |
313 } | 315 } |
314 } | 316 } |
315 | 317 |
316 | 318 |
317 // Handle all register based formatting in this function to reduce the | 319 // Handle all register based formatting in this function to reduce the |
318 // complexity of FormatOption. | 320 // complexity of FormatOption. |
319 int Decoder::FormatRegister(Instr* instr, const char* format) { | 321 int Decoder::FormatRegister(Instruction* instr, const char* format) { |
320 ASSERT(format[0] == 'r'); | 322 ASSERT(format[0] == 'r'); |
321 if (format[1] == 'n') { // 'rn: Rn register | 323 if (format[1] == 'n') { // 'rn: Rn register |
322 int reg = instr->RnField(); | 324 int reg = instr->RnValue(); |
323 PrintRegister(reg); | 325 PrintRegister(reg); |
324 return 2; | 326 return 2; |
325 } else if (format[1] == 'd') { // 'rd: Rd register | 327 } else if (format[1] == 'd') { // 'rd: Rd register |
326 int reg = instr->RdField(); | 328 int reg = instr->RdValue(); |
327 PrintRegister(reg); | 329 PrintRegister(reg); |
328 return 2; | 330 return 2; |
329 } else if (format[1] == 's') { // 'rs: Rs register | 331 } else if (format[1] == 's') { // 'rs: Rs register |
330 int reg = instr->RsField(); | 332 int reg = instr->RsValue(); |
331 PrintRegister(reg); | 333 PrintRegister(reg); |
332 return 2; | 334 return 2; |
333 } else if (format[1] == 'm') { // 'rm: Rm register | 335 } else if (format[1] == 'm') { // 'rm: Rm register |
334 int reg = instr->RmField(); | 336 int reg = instr->RmValue(); |
335 PrintRegister(reg); | 337 PrintRegister(reg); |
336 return 2; | 338 return 2; |
337 } else if (format[1] == 't') { // 'rt: Rt register | 339 } else if (format[1] == 't') { // 'rt: Rt register |
338 int reg = instr->RtField(); | 340 int reg = instr->RtValue(); |
339 PrintRegister(reg); | 341 PrintRegister(reg); |
340 return 2; | 342 return 2; |
341 } else if (format[1] == 'l') { | 343 } else if (format[1] == 'l') { |
342 // 'rlist: register list for load and store multiple instructions | 344 // 'rlist: register list for load and store multiple instructions |
343 ASSERT(STRING_STARTS_WITH(format, "rlist")); | 345 ASSERT(STRING_STARTS_WITH(format, "rlist")); |
344 int rlist = instr->RlistField(); | 346 int rlist = instr->RlistValue(); |
345 int reg = 0; | 347 int reg = 0; |
346 Print("{"); | 348 Print("{"); |
347 // Print register list in ascending order, by scanning the bit mask. | 349 // Print register list in ascending order, by scanning the bit mask. |
348 while (rlist != 0) { | 350 while (rlist != 0) { |
349 if ((rlist & 1) != 0) { | 351 if ((rlist & 1) != 0) { |
350 PrintRegister(reg); | 352 PrintRegister(reg); |
351 if ((rlist >> 1) != 0) { | 353 if ((rlist >> 1) != 0) { |
352 Print(", "); | 354 Print(", "); |
353 } | 355 } |
354 } | 356 } |
355 reg++; | 357 reg++; |
356 rlist >>= 1; | 358 rlist >>= 1; |
357 } | 359 } |
358 Print("}"); | 360 Print("}"); |
359 return 5; | 361 return 5; |
360 } | 362 } |
361 UNREACHABLE(); | 363 UNREACHABLE(); |
362 return -1; | 364 return -1; |
363 } | 365 } |
364 | 366 |
365 | 367 |
366 // Handle all VFP register based formatting in this function to reduce the | 368 // Handle all VFP register based formatting in this function to reduce the |
367 // complexity of FormatOption. | 369 // complexity of FormatOption. |
368 int Decoder::FormatVFPRegister(Instr* instr, const char* format) { | 370 int Decoder::FormatVFPRegister(Instruction* instr, const char* format) { |
369 ASSERT((format[0] == 'S') || (format[0] == 'D')); | 371 ASSERT((format[0] == 'S') || (format[0] == 'D')); |
370 | 372 |
371 if (format[1] == 'n') { | 373 if (format[1] == 'n') { |
372 int reg = instr->VnField(); | 374 int reg = instr->VnValue(); |
373 if (format[0] == 'S') PrintSRegister(((reg << 1) | instr->NField())); | 375 if (format[0] == 'S') PrintSRegister(((reg << 1) | instr->NValue())); |
374 if (format[0] == 'D') PrintDRegister(reg); | 376 if (format[0] == 'D') PrintDRegister(reg); |
375 return 2; | 377 return 2; |
376 } else if (format[1] == 'm') { | 378 } else if (format[1] == 'm') { |
377 int reg = instr->VmField(); | 379 int reg = instr->VmValue(); |
378 if (format[0] == 'S') PrintSRegister(((reg << 1) | instr->MField())); | 380 if (format[0] == 'S') PrintSRegister(((reg << 1) | instr->MValue())); |
379 if (format[0] == 'D') PrintDRegister(reg); | 381 if (format[0] == 'D') PrintDRegister(reg); |
380 return 2; | 382 return 2; |
381 } else if (format[1] == 'd') { | 383 } else if (format[1] == 'd') { |
382 int reg = instr->VdField(); | 384 int reg = instr->VdValue(); |
383 if (format[0] == 'S') PrintSRegister(((reg << 1) | instr->DField())); | 385 if (format[0] == 'S') PrintSRegister(((reg << 1) | instr->DValue())); |
384 if (format[0] == 'D') PrintDRegister(reg); | 386 if (format[0] == 'D') PrintDRegister(reg); |
385 return 2; | 387 return 2; |
386 } | 388 } |
387 | 389 |
388 UNREACHABLE(); | 390 UNREACHABLE(); |
389 return -1; | 391 return -1; |
390 } | 392 } |
391 | 393 |
392 | 394 |
393 int Decoder::FormatVFPinstruction(Instr* instr, const char* format) { | 395 int Decoder::FormatVFPinstruction(Instruction* instr, const char* format) { |
394 Print(format); | 396 Print(format); |
395 return 0; | 397 return 0; |
396 } | 398 } |
397 | 399 |
398 | 400 |
399 // Print the movw or movt instruction. | 401 // Print the movw or movt instruction. |
400 void Decoder::PrintMovwMovt(Instr* instr) { | 402 void Decoder::PrintMovwMovt(Instruction* instr) { |
401 int imm = instr->ImmedMovwMovtField(); | 403 int imm = instr->ImmedMovwMovtValue(); |
402 int rd = instr->RdField(); | 404 int rd = instr->RdValue(); |
403 PrintRegister(rd); | 405 PrintRegister(rd); |
404 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, | 406 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, |
405 ", #%d", imm); | 407 ", #%d", imm); |
406 } | 408 } |
407 | 409 |
408 | 410 |
409 // FormatOption takes a formatting string and interprets it based on | 411 // FormatOption takes a formatting string and interprets it based on |
410 // the current instructions. The format string points to the first | 412 // the current instructions. The format string points to the first |
411 // character of the option string (the option escape has already been | 413 // character of the option string (the option escape has already been |
412 // consumed by the caller.) FormatOption returns the number of | 414 // consumed by the caller.) FormatOption returns the number of |
413 // characters that were consumed from the formatting string. | 415 // characters that were consumed from the formatting string. |
414 int Decoder::FormatOption(Instr* instr, const char* format) { | 416 int Decoder::FormatOption(Instruction* instr, const char* format) { |
415 switch (format[0]) { | 417 switch (format[0]) { |
416 case 'a': { // 'a: accumulate multiplies | 418 case 'a': { // 'a: accumulate multiplies |
417 if (instr->Bit(21) == 0) { | 419 if (instr->Bit(21) == 0) { |
418 Print("ul"); | 420 Print("ul"); |
419 } else { | 421 } else { |
420 Print("la"); | 422 Print("la"); |
421 } | 423 } |
422 return 1; | 424 return 1; |
423 } | 425 } |
424 case 'b': { // 'b: byte loads or stores | 426 case 'b': { // 'b: byte loads or stores |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 reinterpret_cast<byte*>(instr->InstructionBits() & 0x0fffffff); | 509 reinterpret_cast<byte*>(instr->InstructionBits() & 0x0fffffff); |
508 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, | 510 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, |
509 "%s", converter_.NameInCode(str)); | 511 "%s", converter_.NameInCode(str)); |
510 return 3; | 512 return 3; |
511 } | 513 } |
512 case 'o': { | 514 case 'o': { |
513 if ((format[3] == '1') && (format[4] == '2')) { | 515 if ((format[3] == '1') && (format[4] == '2')) { |
514 // 'off12: 12-bit offset for load and store instructions | 516 // 'off12: 12-bit offset for load and store instructions |
515 ASSERT(STRING_STARTS_WITH(format, "off12")); | 517 ASSERT(STRING_STARTS_WITH(format, "off12")); |
516 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, | 518 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, |
517 "%d", instr->Offset12Field()); | 519 "%d", instr->Offset12Value()); |
518 return 5; | 520 return 5; |
519 } else if (format[3] == '0') { | 521 } else if (format[3] == '0') { |
520 // 'off0to3and8to19 16-bit immediate encoded in bits 19-8 and 3-0. | 522 // 'off0to3and8to19 16-bit immediate encoded in bits 19-8 and 3-0. |
521 ASSERT(STRING_STARTS_WITH(format, "off0to3and8to19")); | 523 ASSERT(STRING_STARTS_WITH(format, "off0to3and8to19")); |
522 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, | 524 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, |
523 "%d", | 525 "%d", |
524 (instr->Bits(19, 8) << 4) + | 526 (instr->Bits(19, 8) << 4) + |
525 instr->Bits(3, 0)); | 527 instr->Bits(3, 0)); |
526 return 15; | 528 return 15; |
527 } | 529 } |
528 // 'off8: 8-bit offset for extra load and store instructions | 530 // 'off8: 8-bit offset for extra load and store instructions |
529 ASSERT(STRING_STARTS_WITH(format, "off8")); | 531 ASSERT(STRING_STARTS_WITH(format, "off8")); |
530 int offs8 = (instr->ImmedHField() << 4) | instr->ImmedLField(); | 532 int offs8 = (instr->ImmedHValue() << 4) | instr->ImmedLValue(); |
531 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, | 533 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, |
532 "%d", offs8); | 534 "%d", offs8); |
533 return 4; | 535 return 4; |
534 } | 536 } |
535 case 'p': { // 'pu: P and U bits for load and store instructions | 537 case 'p': { // 'pu: P and U bits for load and store instructions |
536 ASSERT(STRING_STARTS_WITH(format, "pu")); | 538 ASSERT(STRING_STARTS_WITH(format, "pu")); |
537 PrintPU(instr); | 539 PrintPU(instr); |
538 return 2; | 540 return 2; |
539 } | 541 } |
540 case 'r': { | 542 case 'r': { |
541 return FormatRegister(instr, format); | 543 return FormatRegister(instr, format); |
542 } | 544 } |
543 case 's': { | 545 case 's': { |
544 if (format[1] == 'h') { // 'shift_op or 'shift_rm or 'shift_sat. | 546 if (format[1] == 'h') { // 'shift_op or 'shift_rm or 'shift_sat. |
545 if (format[6] == 'o') { // 'shift_op | 547 if (format[6] == 'o') { // 'shift_op |
546 ASSERT(STRING_STARTS_WITH(format, "shift_op")); | 548 ASSERT(STRING_STARTS_WITH(format, "shift_op")); |
547 if (instr->TypeField() == 0) { | 549 if (instr->TypeValue() == 0) { |
548 PrintShiftRm(instr); | 550 PrintShiftRm(instr); |
549 } else { | 551 } else { |
550 ASSERT(instr->TypeField() == 1); | 552 ASSERT(instr->TypeValue() == 1); |
551 PrintShiftImm(instr); | 553 PrintShiftImm(instr); |
552 } | 554 } |
553 return 8; | 555 return 8; |
554 } else if (format[6] == 's') { // 'shift_sat. | 556 } else if (format[6] == 's') { // 'shift_sat. |
555 ASSERT(STRING_STARTS_WITH(format, "shift_sat")); | 557 ASSERT(STRING_STARTS_WITH(format, "shift_sat")); |
556 PrintShiftSat(instr); | 558 PrintShiftSat(instr); |
557 return 9; | 559 return 9; |
558 } else { // 'shift_rm | 560 } else { // 'shift_rm |
559 ASSERT(STRING_STARTS_WITH(format, "shift_rm")); | 561 ASSERT(STRING_STARTS_WITH(format, "shift_rm")); |
560 PrintShiftRm(instr); | 562 PrintShiftRm(instr); |
561 return 8; | 563 return 8; |
562 } | 564 } |
563 } else if (format[1] == 'v') { // 'svc | 565 } else if (format[1] == 'v') { // 'svc |
564 ASSERT(STRING_STARTS_WITH(format, "svc")); | 566 ASSERT(STRING_STARTS_WITH(format, "svc")); |
565 PrintSoftwareInterrupt(instr->SvcField()); | 567 PrintSoftwareInterrupt(instr->SvcValue()); |
566 return 3; | 568 return 3; |
567 } else if (format[1] == 'i') { // 'sign: signed extra loads and stores | 569 } else if (format[1] == 'i') { // 'sign: signed extra loads and stores |
568 ASSERT(STRING_STARTS_WITH(format, "sign")); | 570 ASSERT(STRING_STARTS_WITH(format, "sign")); |
569 if (instr->HasSign()) { | 571 if (instr->HasSign()) { |
570 Print("s"); | 572 Print("s"); |
571 } | 573 } |
572 return 4; | 574 return 4; |
573 } | 575 } |
574 // 's: S field of data processing instructions | 576 // 's: S field of data processing instructions |
575 if (instr->HasS()) { | 577 if (instr->HasS()) { |
576 Print("s"); | 578 Print("s"); |
577 } | 579 } |
578 return 1; | 580 return 1; |
579 } | 581 } |
580 case 't': { // 'target: target of branch instructions | 582 case 't': { // 'target: target of branch instructions |
581 ASSERT(STRING_STARTS_WITH(format, "target")); | 583 ASSERT(STRING_STARTS_WITH(format, "target")); |
582 int off = (instr->SImmed24Field() << 2) + 8; | 584 int off = (instr->SImmed24Value() << 2) + 8; |
583 out_buffer_pos_ += v8i::OS::SNPrintF( | 585 out_buffer_pos_ += v8i::OS::SNPrintF( |
584 out_buffer_ + out_buffer_pos_, | 586 out_buffer_ + out_buffer_pos_, |
585 "%+d -> %s", | 587 "%+d -> %s", |
586 off, | 588 off, |
587 converter_.NameOfAddress(reinterpret_cast<byte*>(instr) + off)); | 589 converter_.NameOfAddress(reinterpret_cast<byte*>(instr) + off)); |
588 return 6; | 590 return 6; |
589 } | 591 } |
590 case 'u': { // 'u: signed or unsigned multiplies | 592 case 'u': { // 'u: signed or unsigned multiplies |
591 // The manual gets the meaning of bit 22 backwards in the multiply | 593 // The manual gets the meaning of bit 22 backwards in the multiply |
592 // instruction overview on page A3.16.2. The instructions that | 594 // instruction overview on page A3.16.2. The instructions that |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 } | 628 } |
627 } | 629 } |
628 UNREACHABLE(); | 630 UNREACHABLE(); |
629 return -1; | 631 return -1; |
630 } | 632 } |
631 | 633 |
632 | 634 |
633 // Format takes a formatting string for a whole instruction and prints it into | 635 // Format takes a formatting string for a whole instruction and prints it into |
634 // the output buffer. All escaped options are handed to FormatOption to be | 636 // the output buffer. All escaped options are handed to FormatOption to be |
635 // parsed further. | 637 // parsed further. |
636 void Decoder::Format(Instr* instr, const char* format) { | 638 void Decoder::Format(Instruction* instr, const char* format) { |
637 char cur = *format++; | 639 char cur = *format++; |
638 while ((cur != 0) && (out_buffer_pos_ < (out_buffer_.length() - 1))) { | 640 while ((cur != 0) && (out_buffer_pos_ < (out_buffer_.length() - 1))) { |
639 if (cur == '\'') { // Single quote is used as the formatting escape. | 641 if (cur == '\'') { // Single quote is used as the formatting escape. |
640 format += FormatOption(instr, format); | 642 format += FormatOption(instr, format); |
641 } else { | 643 } else { |
642 out_buffer_[out_buffer_pos_++] = cur; | 644 out_buffer_[out_buffer_pos_++] = cur; |
643 } | 645 } |
644 cur = *format++; | 646 cur = *format++; |
645 } | 647 } |
646 out_buffer_[out_buffer_pos_] = '\0'; | 648 out_buffer_[out_buffer_pos_] = '\0'; |
647 } | 649 } |
648 | 650 |
649 | 651 |
650 // For currently unimplemented decodings the disassembler calls Unknown(instr) | 652 // For currently unimplemented decodings the disassembler calls Unknown(instr) |
651 // which will just print "unknown" of the instruction bits. | 653 // which will just print "unknown" of the instruction bits. |
652 void Decoder::Unknown(Instr* instr) { | 654 void Decoder::Unknown(Instruction* instr) { |
653 Format(instr, "unknown"); | 655 Format(instr, "unknown"); |
654 } | 656 } |
655 | 657 |
656 | 658 |
657 void Decoder::DecodeType01(Instr* instr) { | 659 void Decoder::DecodeType01(Instruction* instr) { |
658 int type = instr->TypeField(); | 660 int type = instr->TypeValue(); |
659 if ((type == 0) && instr->IsSpecialType0()) { | 661 if ((type == 0) && instr->IsSpecialType0()) { |
660 // multiply instruction or extra loads and stores | 662 // multiply instruction or extra loads and stores |
661 if (instr->Bits(7, 4) == 9) { | 663 if (instr->Bits(7, 4) == 9) { |
662 if (instr->Bit(24) == 0) { | 664 if (instr->Bit(24) == 0) { |
663 // multiply instructions | 665 // multiply instructions |
664 if (instr->Bit(23) == 0) { | 666 if (instr->Bit(23) == 0) { |
665 if (instr->Bit(21) == 0) { | 667 if (instr->Bit(21) == 0) { |
666 // The MUL instruction description (A 4.1.33) refers to Rd as being | 668 // The MUL instruction description (A 4.1.33) refers to Rd as being |
667 // the destination for the operation, but it confusingly uses the | 669 // the destination for the operation, but it confusingly uses the |
668 // Rn field to encode it. | 670 // Rn field to encode it. |
(...skipping 13 matching lines...) Expand all Loading... |
682 // RdHi == Rn field | 684 // RdHi == Rn field |
683 // The order of registers is: <RdLo>, <RdHi>, <Rm>, <Rs> | 685 // The order of registers is: <RdLo>, <RdHi>, <Rm>, <Rs> |
684 Format(instr, "'um'al'cond's 'rd, 'rn, 'rm, 'rs"); | 686 Format(instr, "'um'al'cond's 'rd, 'rn, 'rm, 'rs"); |
685 } | 687 } |
686 } else { | 688 } else { |
687 Unknown(instr); // not used by V8 | 689 Unknown(instr); // not used by V8 |
688 } | 690 } |
689 } else if ((instr->Bit(20) == 0) && ((instr->Bits(7, 4) & 0xd) == 0xd)) { | 691 } else if ((instr->Bit(20) == 0) && ((instr->Bits(7, 4) & 0xd) == 0xd)) { |
690 // ldrd, strd | 692 // ldrd, strd |
691 switch (instr->PUField()) { | 693 switch (instr->PUField()) { |
692 case 0: { | 694 case da_x: { |
693 if (instr->Bit(22) == 0) { | 695 if (instr->Bit(22) == 0) { |
694 Format(instr, "'memop'cond's 'rd, ['rn], -'rm"); | 696 Format(instr, "'memop'cond's 'rd, ['rn], -'rm"); |
695 } else { | 697 } else { |
696 Format(instr, "'memop'cond's 'rd, ['rn], #-'off8"); | 698 Format(instr, "'memop'cond's 'rd, ['rn], #-'off8"); |
697 } | 699 } |
698 break; | 700 break; |
699 } | 701 } |
700 case 1: { | 702 case ia_x: { |
701 if (instr->Bit(22) == 0) { | 703 if (instr->Bit(22) == 0) { |
702 Format(instr, "'memop'cond's 'rd, ['rn], +'rm"); | 704 Format(instr, "'memop'cond's 'rd, ['rn], +'rm"); |
703 } else { | 705 } else { |
704 Format(instr, "'memop'cond's 'rd, ['rn], #+'off8"); | 706 Format(instr, "'memop'cond's 'rd, ['rn], #+'off8"); |
705 } | 707 } |
706 break; | 708 break; |
707 } | 709 } |
708 case 2: { | 710 case db_x: { |
709 if (instr->Bit(22) == 0) { | 711 if (instr->Bit(22) == 0) { |
710 Format(instr, "'memop'cond's 'rd, ['rn, -'rm]'w"); | 712 Format(instr, "'memop'cond's 'rd, ['rn, -'rm]'w"); |
711 } else { | 713 } else { |
712 Format(instr, "'memop'cond's 'rd, ['rn, #-'off8]'w"); | 714 Format(instr, "'memop'cond's 'rd, ['rn, #-'off8]'w"); |
713 } | 715 } |
714 break; | 716 break; |
715 } | 717 } |
716 case 3: { | 718 case ib_x: { |
717 if (instr->Bit(22) == 0) { | 719 if (instr->Bit(22) == 0) { |
718 Format(instr, "'memop'cond's 'rd, ['rn, +'rm]'w"); | 720 Format(instr, "'memop'cond's 'rd, ['rn, +'rm]'w"); |
719 } else { | 721 } else { |
720 Format(instr, "'memop'cond's 'rd, ['rn, #+'off8]'w"); | 722 Format(instr, "'memop'cond's 'rd, ['rn, #+'off8]'w"); |
721 } | 723 } |
722 break; | 724 break; |
723 } | 725 } |
724 default: { | 726 default: { |
725 // The PU field is a 2-bit field. | 727 // The PU field is a 2-bit field. |
726 UNREACHABLE(); | 728 UNREACHABLE(); |
727 break; | 729 break; |
728 } | 730 } |
729 } | 731 } |
730 } else { | 732 } else { |
731 // extra load/store instructions | 733 // extra load/store instructions |
732 switch (instr->PUField()) { | 734 switch (instr->PUField()) { |
733 case 0: { | 735 case da_x: { |
734 if (instr->Bit(22) == 0) { | 736 if (instr->Bit(22) == 0) { |
735 Format(instr, "'memop'cond'sign'h 'rd, ['rn], -'rm"); | 737 Format(instr, "'memop'cond'sign'h 'rd, ['rn], -'rm"); |
736 } else { | 738 } else { |
737 Format(instr, "'memop'cond'sign'h 'rd, ['rn], #-'off8"); | 739 Format(instr, "'memop'cond'sign'h 'rd, ['rn], #-'off8"); |
738 } | 740 } |
739 break; | 741 break; |
740 } | 742 } |
741 case 1: { | 743 case ia_x: { |
742 if (instr->Bit(22) == 0) { | 744 if (instr->Bit(22) == 0) { |
743 Format(instr, "'memop'cond'sign'h 'rd, ['rn], +'rm"); | 745 Format(instr, "'memop'cond'sign'h 'rd, ['rn], +'rm"); |
744 } else { | 746 } else { |
745 Format(instr, "'memop'cond'sign'h 'rd, ['rn], #+'off8"); | 747 Format(instr, "'memop'cond'sign'h 'rd, ['rn], #+'off8"); |
746 } | 748 } |
747 break; | 749 break; |
748 } | 750 } |
749 case 2: { | 751 case db_x: { |
750 if (instr->Bit(22) == 0) { | 752 if (instr->Bit(22) == 0) { |
751 Format(instr, "'memop'cond'sign'h 'rd, ['rn, -'rm]'w"); | 753 Format(instr, "'memop'cond'sign'h 'rd, ['rn, -'rm]'w"); |
752 } else { | 754 } else { |
753 Format(instr, "'memop'cond'sign'h 'rd, ['rn, #-'off8]'w"); | 755 Format(instr, "'memop'cond'sign'h 'rd, ['rn, #-'off8]'w"); |
754 } | 756 } |
755 break; | 757 break; |
756 } | 758 } |
757 case 3: { | 759 case ib_x: { |
758 if (instr->Bit(22) == 0) { | 760 if (instr->Bit(22) == 0) { |
759 Format(instr, "'memop'cond'sign'h 'rd, ['rn, +'rm]'w"); | 761 Format(instr, "'memop'cond'sign'h 'rd, ['rn, +'rm]'w"); |
760 } else { | 762 } else { |
761 Format(instr, "'memop'cond'sign'h 'rd, ['rn, #+'off8]'w"); | 763 Format(instr, "'memop'cond'sign'h 'rd, ['rn, #+'off8]'w"); |
762 } | 764 } |
763 break; | 765 break; |
764 } | 766 } |
765 default: { | 767 default: { |
766 // The PU field is a 2-bit field. | 768 // The PU field is a 2-bit field. |
767 UNREACHABLE(); | 769 UNREACHABLE(); |
768 break; | 770 break; |
769 } | 771 } |
770 } | 772 } |
771 return; | 773 return; |
772 } | 774 } |
773 } else if ((type == 0) && instr->IsMiscType0()) { | 775 } else if ((type == 0) && instr->IsMiscType0()) { |
774 if (instr->Bits(22, 21) == 1) { | 776 if (instr->Bits(22, 21) == 1) { |
775 switch (instr->Bits(7, 4)) { | 777 switch (instr->BitField(7, 4)) { |
776 case BX: | 778 case BX: |
777 Format(instr, "bx'cond 'rm"); | 779 Format(instr, "bx'cond 'rm"); |
778 break; | 780 break; |
779 case BLX: | 781 case BLX: |
780 Format(instr, "blx'cond 'rm"); | 782 Format(instr, "blx'cond 'rm"); |
781 break; | 783 break; |
782 case BKPT: | 784 case BKPT: |
783 Format(instr, "bkpt 'off0to3and8to19"); | 785 Format(instr, "bkpt 'off0to3and8to19"); |
784 break; | 786 break; |
785 default: | 787 default: |
786 Unknown(instr); // not used by V8 | 788 Unknown(instr); // not used by V8 |
787 break; | 789 break; |
788 } | 790 } |
789 } else if (instr->Bits(22, 21) == 3) { | 791 } else if (instr->Bits(22, 21) == 3) { |
790 switch (instr->Bits(7, 4)) { | 792 switch (instr->BitField(7, 4)) { |
791 case CLZ: | 793 case CLZ: |
792 Format(instr, "clz'cond 'rd, 'rm"); | 794 Format(instr, "clz'cond 'rd, 'rm"); |
793 break; | 795 break; |
794 default: | 796 default: |
795 Unknown(instr); // not used by V8 | 797 Unknown(instr); // not used by V8 |
796 break; | 798 break; |
797 } | 799 } |
798 } else { | 800 } else { |
799 Unknown(instr); // not used by V8 | 801 Unknown(instr); // not used by V8 |
800 } | 802 } |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 default: { | 889 default: { |
888 // The Opcode field is a 4-bit field. | 890 // The Opcode field is a 4-bit field. |
889 UNREACHABLE(); | 891 UNREACHABLE(); |
890 break; | 892 break; |
891 } | 893 } |
892 } | 894 } |
893 } | 895 } |
894 } | 896 } |
895 | 897 |
896 | 898 |
897 void Decoder::DecodeType2(Instr* instr) { | 899 void Decoder::DecodeType2(Instruction* instr) { |
898 switch (instr->PUField()) { | 900 switch (instr->PUField()) { |
899 case 0: { | 901 case da_x: { |
900 if (instr->HasW()) { | 902 if (instr->HasW()) { |
901 Unknown(instr); // not used in V8 | 903 Unknown(instr); // not used in V8 |
902 } | 904 } |
903 Format(instr, "'memop'cond'b 'rd, ['rn], #-'off12"); | 905 Format(instr, "'memop'cond'b 'rd, ['rn], #-'off12"); |
904 break; | 906 break; |
905 } | 907 } |
906 case 1: { | 908 case ia_x: { |
907 if (instr->HasW()) { | 909 if (instr->HasW()) { |
908 Unknown(instr); // not used in V8 | 910 Unknown(instr); // not used in V8 |
909 } | 911 } |
910 Format(instr, "'memop'cond'b 'rd, ['rn], #+'off12"); | 912 Format(instr, "'memop'cond'b 'rd, ['rn], #+'off12"); |
911 break; | 913 break; |
912 } | 914 } |
913 case 2: { | 915 case db_x: { |
914 Format(instr, "'memop'cond'b 'rd, ['rn, #-'off12]'w"); | 916 Format(instr, "'memop'cond'b 'rd, ['rn, #-'off12]'w"); |
915 break; | 917 break; |
916 } | 918 } |
917 case 3: { | 919 case ib_x: { |
918 Format(instr, "'memop'cond'b 'rd, ['rn, #+'off12]'w"); | 920 Format(instr, "'memop'cond'b 'rd, ['rn, #+'off12]'w"); |
919 break; | 921 break; |
920 } | 922 } |
921 default: { | 923 default: { |
922 // The PU field is a 2-bit field. | 924 // The PU field is a 2-bit field. |
923 UNREACHABLE(); | 925 UNREACHABLE(); |
924 break; | 926 break; |
925 } | 927 } |
926 } | 928 } |
927 } | 929 } |
928 | 930 |
929 | 931 |
930 void Decoder::DecodeType3(Instr* instr) { | 932 void Decoder::DecodeType3(Instruction* instr) { |
931 switch (instr->PUField()) { | 933 switch (instr->PUField()) { |
932 case 0: { | 934 case da_x: { |
933 ASSERT(!instr->HasW()); | 935 ASSERT(!instr->HasW()); |
934 Format(instr, "'memop'cond'b 'rd, ['rn], -'shift_rm"); | 936 Format(instr, "'memop'cond'b 'rd, ['rn], -'shift_rm"); |
935 break; | 937 break; |
936 } | 938 } |
937 case 1: { | 939 case ia_x: { |
938 if (instr->HasW()) { | 940 if (instr->HasW()) { |
939 ASSERT(instr->Bits(5, 4) == 0x1); | 941 ASSERT(instr->Bits(5, 4) == 0x1); |
940 if (instr->Bit(22) == 0x1) { | 942 if (instr->Bit(22) == 0x1) { |
941 Format(instr, "usat 'rd, #'imm05@16, 'rm'shift_sat"); | 943 Format(instr, "usat 'rd, #'imm05@16, 'rm'shift_sat"); |
942 } else { | 944 } else { |
943 UNREACHABLE(); // SSAT. | 945 UNREACHABLE(); // SSAT. |
944 } | 946 } |
945 } else { | 947 } else { |
946 Format(instr, "'memop'cond'b 'rd, ['rn], +'shift_rm"); | 948 Format(instr, "'memop'cond'b 'rd, ['rn], +'shift_rm"); |
947 } | 949 } |
948 break; | 950 break; |
949 } | 951 } |
950 case 2: { | 952 case db_x: { |
951 Format(instr, "'memop'cond'b 'rd, ['rn, -'shift_rm]'w"); | 953 Format(instr, "'memop'cond'b 'rd, ['rn, -'shift_rm]'w"); |
952 break; | 954 break; |
953 } | 955 } |
954 case 3: { | 956 case ib_x: { |
955 if (instr->HasW() && (instr->Bits(6, 4) == 0x5)) { | 957 if (instr->HasW() && (instr->Bits(6, 4) == 0x5)) { |
956 uint32_t widthminus1 = static_cast<uint32_t>(instr->Bits(20, 16)); | 958 uint32_t widthminus1 = static_cast<uint32_t>(instr->Bits(20, 16)); |
957 uint32_t lsbit = static_cast<uint32_t>(instr->Bits(11, 7)); | 959 uint32_t lsbit = static_cast<uint32_t>(instr->Bits(11, 7)); |
958 uint32_t msbit = widthminus1 + lsbit; | 960 uint32_t msbit = widthminus1 + lsbit; |
959 if (msbit <= 31) { | 961 if (msbit <= 31) { |
960 if (instr->Bit(22)) { | 962 if (instr->Bit(22)) { |
961 Format(instr, "ubfx'cond 'rd, 'rm, 'f"); | 963 Format(instr, "ubfx'cond 'rd, 'rm, 'f"); |
962 } else { | 964 } else { |
963 Format(instr, "sbfx'cond 'rd, 'rm, 'f"); | 965 Format(instr, "sbfx'cond 'rd, 'rm, 'f"); |
964 } | 966 } |
965 } else { | 967 } else { |
966 UNREACHABLE(); | 968 UNREACHABLE(); |
967 } | 969 } |
968 } else if (!instr->HasW() && (instr->Bits(6, 4) == 0x1)) { | 970 } else if (!instr->HasW() && (instr->Bits(6, 4) == 0x1)) { |
969 uint32_t lsbit = static_cast<uint32_t>(instr->Bits(11, 7)); | 971 uint32_t lsbit = static_cast<uint32_t>(instr->Bits(11, 7)); |
970 uint32_t msbit = static_cast<uint32_t>(instr->Bits(20, 16)); | 972 uint32_t msbit = static_cast<uint32_t>(instr->Bits(20, 16)); |
971 if (msbit >= lsbit) { | 973 if (msbit >= lsbit) { |
972 if (instr->RmField() == 15) { | 974 if (instr->RmValue() == 15) { |
973 Format(instr, "bfc'cond 'rd, 'f"); | 975 Format(instr, "bfc'cond 'rd, 'f"); |
974 } else { | 976 } else { |
975 Format(instr, "bfi'cond 'rd, 'rm, 'f"); | 977 Format(instr, "bfi'cond 'rd, 'rm, 'f"); |
976 } | 978 } |
977 } else { | 979 } else { |
978 UNREACHABLE(); | 980 UNREACHABLE(); |
979 } | 981 } |
980 } else { | 982 } else { |
981 Format(instr, "'memop'cond'b 'rd, ['rn, +'shift_rm]'w"); | 983 Format(instr, "'memop'cond'b 'rd, ['rn, +'shift_rm]'w"); |
982 } | 984 } |
983 break; | 985 break; |
984 } | 986 } |
985 default: { | 987 default: { |
986 // The PU field is a 2-bit field. | 988 // The PU field is a 2-bit field. |
987 UNREACHABLE(); | 989 UNREACHABLE(); |
988 break; | 990 break; |
989 } | 991 } |
990 } | 992 } |
991 } | 993 } |
992 | 994 |
993 | 995 |
994 void Decoder::DecodeType4(Instr* instr) { | 996 void Decoder::DecodeType4(Instruction* instr) { |
995 ASSERT(instr->Bit(22) == 0); // Privileged mode currently not supported. | 997 ASSERT(instr->Bit(22) == 0); // Privileged mode currently not supported. |
996 if (instr->HasL()) { | 998 if (instr->HasL()) { |
997 Format(instr, "ldm'cond'pu 'rn'w, 'rlist"); | 999 Format(instr, "ldm'cond'pu 'rn'w, 'rlist"); |
998 } else { | 1000 } else { |
999 Format(instr, "stm'cond'pu 'rn'w, 'rlist"); | 1001 Format(instr, "stm'cond'pu 'rn'w, 'rlist"); |
1000 } | 1002 } |
1001 } | 1003 } |
1002 | 1004 |
1003 | 1005 |
1004 void Decoder::DecodeType5(Instr* instr) { | 1006 void Decoder::DecodeType5(Instruction* instr) { |
1005 Format(instr, "b'l'cond 'target"); | 1007 Format(instr, "b'l'cond 'target"); |
1006 } | 1008 } |
1007 | 1009 |
1008 | 1010 |
1009 void Decoder::DecodeType6(Instr* instr) { | 1011 void Decoder::DecodeType6(Instruction* instr) { |
1010 DecodeType6CoprocessorIns(instr); | 1012 DecodeType6CoprocessorIns(instr); |
1011 } | 1013 } |
1012 | 1014 |
1013 | 1015 |
1014 int Decoder::DecodeType7(Instr* instr) { | 1016 int Decoder::DecodeType7(Instruction* instr) { |
1015 if (instr->Bit(24) == 1) { | 1017 if (instr->Bit(24) == 1) { |
1016 if (instr->SvcField() >= stop) { | 1018 if (instr->SvcValue() >= stop_code) { |
1017 Format(instr, "stop'cond 'svc"); | 1019 Format(instr, "stop'cond 'svc"); |
1018 // Also print the stop message. Its address is encoded | 1020 // Also print the stop message. Its address is encoded |
1019 // in the following 4 bytes. | 1021 // in the following 4 bytes. |
1020 out_buffer_pos_ += | 1022 out_buffer_pos_ += |
1021 v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, | 1023 v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, |
1022 "\n %p %08x stop message: %s", | 1024 "\n %p %08x stop message: %s", |
1023 reinterpret_cast<int32_t*>(instr + Instr::kInstrSize), | 1025 reinterpret_cast<int32_t*>(instr |
1024 *reinterpret_cast<char**>(instr + Instr::kInstrSize), | 1026 + Instruction::kInstrSize), |
1025 *reinterpret_cast<char**>(instr + Instr::kInstrSize)); | 1027 *reinterpret_cast<char**>(instr |
1026 // We have decoded 2 * Instr::kInstrSize bytes. | 1028 + Instruction::kInstrSize), |
1027 return 2 * Instr::kInstrSize; | 1029 *reinterpret_cast<char**>(instr |
| 1030 + Instruction::kInstrSize)); |
| 1031 // We have decoded 2 * Instruction::kInstrSize bytes. |
| 1032 return 2 * Instruction::kInstrSize; |
1028 } else { | 1033 } else { |
1029 Format(instr, "svc'cond 'svc"); | 1034 Format(instr, "svc'cond 'svc"); |
1030 } | 1035 } |
1031 } else { | 1036 } else { |
1032 DecodeTypeVFP(instr); | 1037 DecodeTypeVFP(instr); |
1033 } | 1038 } |
1034 return Instr::kInstrSize; | 1039 return Instruction::kInstrSize; |
1035 } | 1040 } |
1036 | 1041 |
1037 | 1042 |
1038 // void Decoder::DecodeTypeVFP(Instr* instr) | 1043 // void Decoder::DecodeTypeVFP(Instruction* instr) |
1039 // vmov: Sn = Rt | 1044 // vmov: Sn = Rt |
1040 // vmov: Rt = Sn | 1045 // vmov: Rt = Sn |
1041 // vcvt: Dd = Sm | 1046 // vcvt: Dd = Sm |
1042 // vcvt: Sd = Dm | 1047 // vcvt: Sd = Dm |
1043 // Dd = vadd(Dn, Dm) | 1048 // Dd = vadd(Dn, Dm) |
1044 // Dd = vsub(Dn, Dm) | 1049 // Dd = vsub(Dn, Dm) |
1045 // Dd = vmul(Dn, Dm) | 1050 // Dd = vmul(Dn, Dm) |
1046 // Dd = vdiv(Dn, Dm) | 1051 // Dd = vdiv(Dn, Dm) |
1047 // vcmp(Dd, Dm) | 1052 // vcmp(Dd, Dm) |
1048 // vmrs | 1053 // vmrs |
1049 // vmsr | 1054 // vmsr |
1050 // Dd = vsqrt(Dm) | 1055 // Dd = vsqrt(Dm) |
1051 void Decoder::DecodeTypeVFP(Instr* instr) { | 1056 void Decoder::DecodeTypeVFP(Instruction* instr) { |
1052 ASSERT((instr->TypeField() == 7) && (instr->Bit(24) == 0x0) ); | 1057 ASSERT((instr->TypeValue() == 7) && (instr->Bit(24) == 0x0) ); |
1053 ASSERT(instr->Bits(11, 9) == 0x5); | 1058 ASSERT(instr->Bits(11, 9) == 0x5); |
1054 | 1059 |
1055 if (instr->Bit(4) == 0) { | 1060 if (instr->Bit(4) == 0) { |
1056 if (instr->Opc1Field() == 0x7) { | 1061 if (instr->Opc1Value() == 0x7) { |
1057 // Other data processing instructions | 1062 // Other data processing instructions |
1058 if ((instr->Opc2Field() == 0x0) && (instr->Opc3Field() == 0x1)) { | 1063 if ((instr->Opc2Value() == 0x0) && (instr->Opc3Value() == 0x1)) { |
1059 // vmov register to register. | 1064 // vmov register to register. |
1060 if (instr->SzField() == 0x1) { | 1065 if (instr->SzValue() == 0x1) { |
1061 Format(instr, "vmov.f64'cond 'Dd, 'Dm"); | 1066 Format(instr, "vmov.f64'cond 'Dd, 'Dm"); |
1062 } else { | 1067 } else { |
1063 Format(instr, "vmov.f32'cond 'Sd, 'Sm"); | 1068 Format(instr, "vmov.f32'cond 'Sd, 'Sm"); |
1064 } | 1069 } |
1065 } else if ((instr->Opc2Field() == 0x7) && (instr->Opc3Field() == 0x3)) { | 1070 } else if ((instr->Opc2Value() == 0x7) && (instr->Opc3Value() == 0x3)) { |
1066 DecodeVCVTBetweenDoubleAndSingle(instr); | 1071 DecodeVCVTBetweenDoubleAndSingle(instr); |
1067 } else if ((instr->Opc2Field() == 0x8) && (instr->Opc3Field() & 0x1)) { | 1072 } else if ((instr->Opc2Value() == 0x8) && (instr->Opc3Value() & 0x1)) { |
1068 DecodeVCVTBetweenFloatingPointAndInteger(instr); | 1073 DecodeVCVTBetweenFloatingPointAndInteger(instr); |
1069 } else if (((instr->Opc2Field() >> 1) == 0x6) && | 1074 } else if (((instr->Opc2Value() >> 1) == 0x6) && |
1070 (instr->Opc3Field() & 0x1)) { | 1075 (instr->Opc3Value() & 0x1)) { |
1071 DecodeVCVTBetweenFloatingPointAndInteger(instr); | 1076 DecodeVCVTBetweenFloatingPointAndInteger(instr); |
1072 } else if (((instr->Opc2Field() == 0x4) || (instr->Opc2Field() == 0x5)) && | 1077 } else if (((instr->Opc2Value() == 0x4) || (instr->Opc2Value() == 0x5)) && |
1073 (instr->Opc3Field() & 0x1)) { | 1078 (instr->Opc3Value() & 0x1)) { |
1074 DecodeVCMP(instr); | 1079 DecodeVCMP(instr); |
1075 } else if (((instr->Opc2Field() == 0x1)) && (instr->Opc3Field() == 0x3)) { | 1080 } else if (((instr->Opc2Value() == 0x1)) && (instr->Opc3Value() == 0x3)) { |
1076 Format(instr, "vsqrt.f64'cond 'Dd, 'Dm"); | 1081 Format(instr, "vsqrt.f64'cond 'Dd, 'Dm"); |
1077 } else if (instr->Opc3Field() == 0x0) { | 1082 } else if (instr->Opc3Value() == 0x0) { |
1078 if (instr->SzField() == 0x1) { | 1083 if (instr->SzValue() == 0x1) { |
1079 Format(instr, "vmov.f64'cond 'Dd, 'd"); | 1084 Format(instr, "vmov.f64'cond 'Dd, 'd"); |
1080 } else { | 1085 } else { |
1081 Unknown(instr); // Not used by V8. | 1086 Unknown(instr); // Not used by V8. |
1082 } | 1087 } |
1083 } else { | 1088 } else { |
1084 Unknown(instr); // Not used by V8. | 1089 Unknown(instr); // Not used by V8. |
1085 } | 1090 } |
1086 } else if (instr->Opc1Field() == 0x3) { | 1091 } else if (instr->Opc1Value() == 0x3) { |
1087 if (instr->SzField() == 0x1) { | 1092 if (instr->SzValue() == 0x1) { |
1088 if (instr->Opc3Field() & 0x1) { | 1093 if (instr->Opc3Value() & 0x1) { |
1089 Format(instr, "vsub.f64'cond 'Dd, 'Dn, 'Dm"); | 1094 Format(instr, "vsub.f64'cond 'Dd, 'Dn, 'Dm"); |
1090 } else { | 1095 } else { |
1091 Format(instr, "vadd.f64'cond 'Dd, 'Dn, 'Dm"); | 1096 Format(instr, "vadd.f64'cond 'Dd, 'Dn, 'Dm"); |
1092 } | 1097 } |
1093 } else { | 1098 } else { |
1094 Unknown(instr); // Not used by V8. | 1099 Unknown(instr); // Not used by V8. |
1095 } | 1100 } |
1096 } else if ((instr->Opc1Field() == 0x2) && !(instr->Opc3Field() & 0x1)) { | 1101 } else if ((instr->Opc1Value() == 0x2) && !(instr->Opc3Value() & 0x1)) { |
1097 if (instr->SzField() == 0x1) { | 1102 if (instr->SzValue() == 0x1) { |
1098 Format(instr, "vmul.f64'cond 'Dd, 'Dn, 'Dm"); | 1103 Format(instr, "vmul.f64'cond 'Dd, 'Dn, 'Dm"); |
1099 } else { | 1104 } else { |
1100 Unknown(instr); // Not used by V8. | 1105 Unknown(instr); // Not used by V8. |
1101 } | 1106 } |
1102 } else if ((instr->Opc1Field() == 0x4) && !(instr->Opc3Field() & 0x1)) { | 1107 } else if ((instr->Opc1Value() == 0x4) && !(instr->Opc3Value() & 0x1)) { |
1103 if (instr->SzField() == 0x1) { | 1108 if (instr->SzValue() == 0x1) { |
1104 Format(instr, "vdiv.f64'cond 'Dd, 'Dn, 'Dm"); | 1109 Format(instr, "vdiv.f64'cond 'Dd, 'Dn, 'Dm"); |
1105 } else { | 1110 } else { |
1106 Unknown(instr); // Not used by V8. | 1111 Unknown(instr); // Not used by V8. |
1107 } | 1112 } |
1108 } else { | 1113 } else { |
1109 Unknown(instr); // Not used by V8. | 1114 Unknown(instr); // Not used by V8. |
1110 } | 1115 } |
1111 } else { | 1116 } else { |
1112 if ((instr->VCField() == 0x0) && | 1117 if ((instr->VCValue() == 0x0) && |
1113 (instr->VAField() == 0x0)) { | 1118 (instr->VAValue() == 0x0)) { |
1114 DecodeVMOVBetweenCoreAndSinglePrecisionRegisters(instr); | 1119 DecodeVMOVBetweenCoreAndSinglePrecisionRegisters(instr); |
1115 } else if ((instr->VCField() == 0x0) && | 1120 } else if ((instr->VCValue() == 0x0) && |
1116 (instr->VAField() == 0x7) && | 1121 (instr->VAValue() == 0x7) && |
1117 (instr->Bits(19, 16) == 0x1)) { | 1122 (instr->Bits(19, 16) == 0x1)) { |
1118 if (instr->VLField() == 0) { | 1123 if (instr->VLValue() == 0) { |
1119 if (instr->Bits(15, 12) == 0xF) { | 1124 if (instr->Bits(15, 12) == 0xF) { |
1120 Format(instr, "vmsr'cond FPSCR, APSR"); | 1125 Format(instr, "vmsr'cond FPSCR, APSR"); |
1121 } else { | 1126 } else { |
1122 Format(instr, "vmsr'cond FPSCR, 'rt"); | 1127 Format(instr, "vmsr'cond FPSCR, 'rt"); |
1123 } | 1128 } |
1124 } else { | 1129 } else { |
1125 if (instr->Bits(15, 12) == 0xF) { | 1130 if (instr->Bits(15, 12) == 0xF) { |
1126 Format(instr, "vmrs'cond APSR, FPSCR"); | 1131 Format(instr, "vmrs'cond APSR, FPSCR"); |
1127 } else { | 1132 } else { |
1128 Format(instr, "vmrs'cond 'rt, FPSCR"); | 1133 Format(instr, "vmrs'cond 'rt, FPSCR"); |
1129 } | 1134 } |
1130 } | 1135 } |
1131 } | 1136 } |
1132 } | 1137 } |
1133 } | 1138 } |
1134 | 1139 |
1135 | 1140 |
1136 void Decoder::DecodeVMOVBetweenCoreAndSinglePrecisionRegisters(Instr* instr) { | 1141 void Decoder::DecodeVMOVBetweenCoreAndSinglePrecisionRegisters( |
1137 ASSERT((instr->Bit(4) == 1) && (instr->VCField() == 0x0) && | 1142 Instruction* instr) { |
1138 (instr->VAField() == 0x0)); | 1143 ASSERT((instr->Bit(4) == 1) && (instr->VCValue() == 0x0) && |
| 1144 (instr->VAValue() == 0x0)); |
1139 | 1145 |
1140 bool to_arm_register = (instr->VLField() == 0x1); | 1146 bool to_arm_register = (instr->VLValue() == 0x1); |
1141 | 1147 |
1142 if (to_arm_register) { | 1148 if (to_arm_register) { |
1143 Format(instr, "vmov'cond 'rt, 'Sn"); | 1149 Format(instr, "vmov'cond 'rt, 'Sn"); |
1144 } else { | 1150 } else { |
1145 Format(instr, "vmov'cond 'Sn, 'rt"); | 1151 Format(instr, "vmov'cond 'Sn, 'rt"); |
1146 } | 1152 } |
1147 } | 1153 } |
1148 | 1154 |
1149 | 1155 |
1150 void Decoder::DecodeVCMP(Instr* instr) { | 1156 void Decoder::DecodeVCMP(Instruction* instr) { |
1151 ASSERT((instr->Bit(4) == 0) && (instr->Opc1Field() == 0x7)); | 1157 ASSERT((instr->Bit(4) == 0) && (instr->Opc1Value() == 0x7)); |
1152 ASSERT(((instr->Opc2Field() == 0x4) || (instr->Opc2Field() == 0x5)) && | 1158 ASSERT(((instr->Opc2Value() == 0x4) || (instr->Opc2Value() == 0x5)) && |
1153 (instr->Opc3Field() & 0x1)); | 1159 (instr->Opc3Value() & 0x1)); |
1154 | 1160 |
1155 // Comparison. | 1161 // Comparison. |
1156 bool dp_operation = (instr->SzField() == 1); | 1162 bool dp_operation = (instr->SzValue() == 1); |
1157 bool raise_exception_for_qnan = (instr->Bit(7) == 0x1); | 1163 bool raise_exception_for_qnan = (instr->Bit(7) == 0x1); |
1158 | 1164 |
1159 if (dp_operation && !raise_exception_for_qnan) { | 1165 if (dp_operation && !raise_exception_for_qnan) { |
1160 if (instr->Opc2Field() == 0x4) { | 1166 if (instr->Opc2Value() == 0x4) { |
1161 Format(instr, "vcmp.f64'cond 'Dd, 'Dm"); | 1167 Format(instr, "vcmp.f64'cond 'Dd, 'Dm"); |
1162 } else if (instr->Opc2Field() == 0x5) { | 1168 } else if (instr->Opc2Value() == 0x5) { |
1163 Format(instr, "vcmp.f64'cond 'Dd, #0.0"); | 1169 Format(instr, "vcmp.f64'cond 'Dd, #0.0"); |
1164 } else { | 1170 } else { |
1165 Unknown(instr); // invalid | 1171 Unknown(instr); // invalid |
1166 } | 1172 } |
1167 } else { | 1173 } else { |
1168 Unknown(instr); // Not used by V8. | 1174 Unknown(instr); // Not used by V8. |
1169 } | 1175 } |
1170 } | 1176 } |
1171 | 1177 |
1172 | 1178 |
1173 void Decoder::DecodeVCVTBetweenDoubleAndSingle(Instr* instr) { | 1179 void Decoder::DecodeVCVTBetweenDoubleAndSingle(Instruction* instr) { |
1174 ASSERT((instr->Bit(4) == 0) && (instr->Opc1Field() == 0x7)); | 1180 ASSERT((instr->Bit(4) == 0) && (instr->Opc1Value() == 0x7)); |
1175 ASSERT((instr->Opc2Field() == 0x7) && (instr->Opc3Field() == 0x3)); | 1181 ASSERT((instr->Opc2Value() == 0x7) && (instr->Opc3Value() == 0x3)); |
1176 | 1182 |
1177 bool double_to_single = (instr->SzField() == 1); | 1183 bool double_to_single = (instr->SzValue() == 1); |
1178 | 1184 |
1179 if (double_to_single) { | 1185 if (double_to_single) { |
1180 Format(instr, "vcvt.f32.f64'cond 'Sd, 'Dm"); | 1186 Format(instr, "vcvt.f32.f64'cond 'Sd, 'Dm"); |
1181 } else { | 1187 } else { |
1182 Format(instr, "vcvt.f64.f32'cond 'Dd, 'Sm"); | 1188 Format(instr, "vcvt.f64.f32'cond 'Dd, 'Sm"); |
1183 } | 1189 } |
1184 } | 1190 } |
1185 | 1191 |
1186 | 1192 |
1187 void Decoder::DecodeVCVTBetweenFloatingPointAndInteger(Instr* instr) { | 1193 void Decoder::DecodeVCVTBetweenFloatingPointAndInteger(Instruction* instr) { |
1188 ASSERT((instr->Bit(4) == 0) && (instr->Opc1Field() == 0x7)); | 1194 ASSERT((instr->Bit(4) == 0) && (instr->Opc1Value() == 0x7)); |
1189 ASSERT(((instr->Opc2Field() == 0x8) && (instr->Opc3Field() & 0x1)) || | 1195 ASSERT(((instr->Opc2Value() == 0x8) && (instr->Opc3Value() & 0x1)) || |
1190 (((instr->Opc2Field() >> 1) == 0x6) && (instr->Opc3Field() & 0x1))); | 1196 (((instr->Opc2Value() >> 1) == 0x6) && (instr->Opc3Value() & 0x1))); |
1191 | 1197 |
1192 bool to_integer = (instr->Bit(18) == 1); | 1198 bool to_integer = (instr->Bit(18) == 1); |
1193 bool dp_operation = (instr->SzField() == 1); | 1199 bool dp_operation = (instr->SzValue() == 1); |
1194 if (to_integer) { | 1200 if (to_integer) { |
1195 bool unsigned_integer = (instr->Bit(16) == 0); | 1201 bool unsigned_integer = (instr->Bit(16) == 0); |
1196 | 1202 |
1197 if (dp_operation) { | 1203 if (dp_operation) { |
1198 if (unsigned_integer) { | 1204 if (unsigned_integer) { |
1199 Format(instr, "vcvt.u32.f64'cond 'Sd, 'Dm"); | 1205 Format(instr, "vcvt.u32.f64'cond 'Sd, 'Dm"); |
1200 } else { | 1206 } else { |
1201 Format(instr, "vcvt.s32.f64'cond 'Sd, 'Dm"); | 1207 Format(instr, "vcvt.s32.f64'cond 'Sd, 'Dm"); |
1202 } | 1208 } |
1203 } else { | 1209 } else { |
(...skipping 21 matching lines...) Expand all Loading... |
1225 } | 1231 } |
1226 } | 1232 } |
1227 } | 1233 } |
1228 | 1234 |
1229 | 1235 |
1230 // Decode Type 6 coprocessor instructions. | 1236 // Decode Type 6 coprocessor instructions. |
1231 // Dm = vmov(Rt, Rt2) | 1237 // Dm = vmov(Rt, Rt2) |
1232 // <Rt, Rt2> = vmov(Dm) | 1238 // <Rt, Rt2> = vmov(Dm) |
1233 // Ddst = MEM(Rbase + 4*offset). | 1239 // Ddst = MEM(Rbase + 4*offset). |
1234 // MEM(Rbase + 4*offset) = Dsrc. | 1240 // MEM(Rbase + 4*offset) = Dsrc. |
1235 void Decoder::DecodeType6CoprocessorIns(Instr* instr) { | 1241 void Decoder::DecodeType6CoprocessorIns(Instruction* instr) { |
1236 ASSERT((instr->TypeField() == 6)); | 1242 ASSERT(instr->TypeValue() == 6); |
1237 | 1243 |
1238 if (instr->CoprocessorField() == 0xA) { | 1244 if (instr->CoprocessorValue() == 0xA) { |
1239 switch (instr->OpcodeField()) { | 1245 switch (instr->OpcodeValue()) { |
1240 case 0x8: | 1246 case 0x8: |
1241 case 0xA: | 1247 case 0xA: |
1242 if (instr->HasL()) { | 1248 if (instr->HasL()) { |
1243 Format(instr, "vldr'cond 'Sd, ['rn - 4*'imm08@00]"); | 1249 Format(instr, "vldr'cond 'Sd, ['rn - 4*'imm08@00]"); |
1244 } else { | 1250 } else { |
1245 Format(instr, "vstr'cond 'Sd, ['rn - 4*'imm08@00]"); | 1251 Format(instr, "vstr'cond 'Sd, ['rn - 4*'imm08@00]"); |
1246 } | 1252 } |
1247 break; | 1253 break; |
1248 case 0xC: | 1254 case 0xC: |
1249 case 0xE: | 1255 case 0xE: |
1250 if (instr->HasL()) { | 1256 if (instr->HasL()) { |
1251 Format(instr, "vldr'cond 'Sd, ['rn + 4*'imm08@00]"); | 1257 Format(instr, "vldr'cond 'Sd, ['rn + 4*'imm08@00]"); |
1252 } else { | 1258 } else { |
1253 Format(instr, "vstr'cond 'Sd, ['rn + 4*'imm08@00]"); | 1259 Format(instr, "vstr'cond 'Sd, ['rn + 4*'imm08@00]"); |
1254 } | 1260 } |
1255 break; | 1261 break; |
1256 default: | 1262 default: |
1257 Unknown(instr); // Not used by V8. | 1263 Unknown(instr); // Not used by V8. |
1258 break; | 1264 break; |
1259 } | 1265 } |
1260 } else if (instr->CoprocessorField() == 0xB) { | 1266 } else if (instr->CoprocessorValue() == 0xB) { |
1261 switch (instr->OpcodeField()) { | 1267 switch (instr->OpcodeValue()) { |
1262 case 0x2: | 1268 case 0x2: |
1263 // Load and store double to two GP registers | 1269 // Load and store double to two GP registers |
1264 if (instr->Bits(7, 4) != 0x1) { | 1270 if (instr->Bits(7, 4) != 0x1) { |
1265 Unknown(instr); // Not used by V8. | 1271 Unknown(instr); // Not used by V8. |
1266 } else if (instr->HasL()) { | 1272 } else if (instr->HasL()) { |
1267 Format(instr, "vmov'cond 'rt, 'rn, 'Dm"); | 1273 Format(instr, "vmov'cond 'rt, 'rn, 'Dm"); |
1268 } else { | 1274 } else { |
1269 Format(instr, "vmov'cond 'Dm, 'rt, 'rn"); | 1275 Format(instr, "vmov'cond 'Dm, 'rt, 'rn"); |
1270 } | 1276 } |
1271 break; | 1277 break; |
(...skipping 16 matching lines...) Expand all Loading... |
1288 break; | 1294 break; |
1289 } | 1295 } |
1290 } else { | 1296 } else { |
1291 UNIMPLEMENTED(); // Not used by V8. | 1297 UNIMPLEMENTED(); // Not used by V8. |
1292 } | 1298 } |
1293 } | 1299 } |
1294 | 1300 |
1295 | 1301 |
1296 // Disassemble the instruction at *instr_ptr into the output buffer. | 1302 // Disassemble the instruction at *instr_ptr into the output buffer. |
1297 int Decoder::InstructionDecode(byte* instr_ptr) { | 1303 int Decoder::InstructionDecode(byte* instr_ptr) { |
1298 Instr* instr = Instr::At(instr_ptr); | 1304 Instruction* instr = Instruction::At(instr_ptr); |
1299 // Print raw instruction bytes. | 1305 // Print raw instruction bytes. |
1300 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, | 1306 out_buffer_pos_ += v8i::OS::SNPrintF(out_buffer_ + out_buffer_pos_, |
1301 "%08x ", | 1307 "%08x ", |
1302 instr->InstructionBits()); | 1308 instr->InstructionBits()); |
1303 if (instr->ConditionField() == special_condition) { | 1309 if (instr->ConditionField() == special_condition) { |
1304 UNIMPLEMENTED(); | 1310 UNIMPLEMENTED(); |
1305 return Instr::kInstrSize; | 1311 return Instruction::kInstrSize; |
1306 } | 1312 } |
1307 switch (instr->TypeField()) { | 1313 switch (instr->TypeValue()) { |
1308 case 0: | 1314 case 0: |
1309 case 1: { | 1315 case 1: { |
1310 DecodeType01(instr); | 1316 DecodeType01(instr); |
1311 break; | 1317 break; |
1312 } | 1318 } |
1313 case 2: { | 1319 case 2: { |
1314 DecodeType2(instr); | 1320 DecodeType2(instr); |
1315 break; | 1321 break; |
1316 } | 1322 } |
1317 case 3: { | 1323 case 3: { |
(...skipping 14 matching lines...) Expand all Loading... |
1332 } | 1338 } |
1333 case 7: { | 1339 case 7: { |
1334 return DecodeType7(instr); | 1340 return DecodeType7(instr); |
1335 } | 1341 } |
1336 default: { | 1342 default: { |
1337 // The type field is 3-bits in the ARM encoding. | 1343 // The type field is 3-bits in the ARM encoding. |
1338 UNREACHABLE(); | 1344 UNREACHABLE(); |
1339 break; | 1345 break; |
1340 } | 1346 } |
1341 } | 1347 } |
1342 return Instr::kInstrSize; | 1348 return Instruction::kInstrSize; |
1343 } | 1349 } |
1344 | 1350 |
1345 | 1351 |
1346 } } // namespace assembler::arm | 1352 } } // namespace assembler::arm |
1347 | 1353 |
1348 | 1354 |
1349 | 1355 |
1350 //------------------------------------------------------------------------------ | 1356 //------------------------------------------------------------------------------ |
1351 | 1357 |
1352 namespace disasm { | 1358 namespace disasm { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1426 pc += d.InstructionDecode(buffer, pc); | 1432 pc += d.InstructionDecode(buffer, pc); |
1427 fprintf(f, "%p %08x %s\n", | 1433 fprintf(f, "%p %08x %s\n", |
1428 prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); | 1434 prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); |
1429 } | 1435 } |
1430 } | 1436 } |
1431 | 1437 |
1432 | 1438 |
1433 } // namespace disasm | 1439 } // namespace disasm |
1434 | 1440 |
1435 #endif // V8_TARGET_ARCH_ARM | 1441 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |