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