OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are |
| 4 // met: |
| 5 // |
| 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. |
| 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 |
| 28 #include "v8.h" |
| 29 |
| 30 #if V8_TARGET_ARCH_A64 |
| 31 |
| 32 #include "globals.h" |
| 33 #include "utils.h" |
| 34 #include "a64/decoder-a64.h" |
| 35 |
| 36 |
| 37 namespace v8 { |
| 38 namespace internal { |
| 39 |
| 40 // Top-level instruction decode function. |
| 41 void Decoder::Decode(Instruction *instr) { |
| 42 if (instr->Bits(28, 27) == 0) { |
| 43 VisitUnallocated(instr); |
| 44 } else { |
| 45 switch (instr->Bits(27, 24)) { |
| 46 // 0: PC relative addressing. |
| 47 case 0x0: DecodePCRelAddressing(instr); break; |
| 48 |
| 49 // 1: Add/sub immediate. |
| 50 case 0x1: DecodeAddSubImmediate(instr); break; |
| 51 |
| 52 // A: Logical shifted register. |
| 53 // Add/sub with carry. |
| 54 // Conditional compare register. |
| 55 // Conditional compare immediate. |
| 56 // Conditional select. |
| 57 // Data processing 1 source. |
| 58 // Data processing 2 source. |
| 59 // B: Add/sub shifted register. |
| 60 // Add/sub extended register. |
| 61 // Data processing 3 source. |
| 62 case 0xA: |
| 63 case 0xB: DecodeDataProcessing(instr); break; |
| 64 |
| 65 // 2: Logical immediate. |
| 66 // Move wide immediate. |
| 67 case 0x2: DecodeLogical(instr); break; |
| 68 |
| 69 // 3: Bitfield. |
| 70 // Extract. |
| 71 case 0x3: DecodeBitfieldExtract(instr); break; |
| 72 |
| 73 // 4: Unconditional branch immediate. |
| 74 // Exception generation. |
| 75 // Compare and branch immediate. |
| 76 // 5: Compare and branch immediate. |
| 77 // Conditional branch. |
| 78 // System. |
| 79 // 6,7: Unconditional branch. |
| 80 // Test and branch immediate. |
| 81 case 0x4: |
| 82 case 0x5: |
| 83 case 0x6: |
| 84 case 0x7: DecodeBranchSystemException(instr); break; |
| 85 |
| 86 // 8,9: Load/store register pair post-index. |
| 87 // Load register literal. |
| 88 // Load/store register unscaled immediate. |
| 89 // Load/store register immediate post-index. |
| 90 // Load/store register immediate pre-index. |
| 91 // Load/store register offset. |
| 92 // C,D: Load/store register pair offset. |
| 93 // Load/store register pair pre-index. |
| 94 // Load/store register unsigned immediate. |
| 95 // Advanced SIMD. |
| 96 case 0x8: |
| 97 case 0x9: |
| 98 case 0xC: |
| 99 case 0xD: DecodeLoadStore(instr); break; |
| 100 |
| 101 // E: FP fixed point conversion. |
| 102 // FP integer conversion. |
| 103 // FP data processing 1 source. |
| 104 // FP compare. |
| 105 // FP immediate. |
| 106 // FP data processing 2 source. |
| 107 // FP conditional compare. |
| 108 // FP conditional select. |
| 109 // Advanced SIMD. |
| 110 // F: FP data processing 3 source. |
| 111 // Advanced SIMD. |
| 112 case 0xE: |
| 113 case 0xF: DecodeFP(instr); break; |
| 114 } |
| 115 } |
| 116 } |
| 117 |
| 118 |
| 119 void Decoder::AppendVisitor(DecoderVisitor* new_visitor) { |
| 120 visitors_.remove(new_visitor); |
| 121 visitors_.push_front(new_visitor); |
| 122 } |
| 123 |
| 124 |
| 125 void Decoder::PrependVisitor(DecoderVisitor* new_visitor) { |
| 126 visitors_.remove(new_visitor); |
| 127 visitors_.push_back(new_visitor); |
| 128 } |
| 129 |
| 130 |
| 131 void Decoder::InsertVisitorBefore(DecoderVisitor* new_visitor, |
| 132 DecoderVisitor* registered_visitor) { |
| 133 visitors_.remove(new_visitor); |
| 134 std::list<DecoderVisitor*>::iterator it; |
| 135 for (it = visitors_.begin(); it != visitors_.end(); it++) { |
| 136 if (*it == registered_visitor) { |
| 137 visitors_.insert(it, new_visitor); |
| 138 return; |
| 139 } |
| 140 } |
| 141 // We reached the end of the list. The last element must be |
| 142 // registered_visitor. |
| 143 ASSERT(*it == registered_visitor); |
| 144 visitors_.insert(it, new_visitor); |
| 145 } |
| 146 |
| 147 |
| 148 void Decoder::InsertVisitorAfter(DecoderVisitor* new_visitor, |
| 149 DecoderVisitor* registered_visitor) { |
| 150 visitors_.remove(new_visitor); |
| 151 std::list<DecoderVisitor*>::iterator it; |
| 152 for (it = visitors_.begin(); it != visitors_.end(); it++) { |
| 153 if (*it == registered_visitor) { |
| 154 it++; |
| 155 visitors_.insert(it, new_visitor); |
| 156 return; |
| 157 } |
| 158 } |
| 159 // We reached the end of the list. The last element must be |
| 160 // registered_visitor. |
| 161 ASSERT(*it == registered_visitor); |
| 162 visitors_.push_back(new_visitor); |
| 163 } |
| 164 |
| 165 |
| 166 void Decoder::RemoveVisitor(DecoderVisitor* visitor) { |
| 167 visitors_.remove(visitor); |
| 168 } |
| 169 |
| 170 |
| 171 void Decoder::DecodePCRelAddressing(Instruction* instr) { |
| 172 ASSERT(instr->Bits(27, 24) == 0x0); |
| 173 // We know bit 28 is set, as <b28:b27> = 0 is filtered out at the top level |
| 174 // decode. |
| 175 ASSERT(instr->Bit(28) == 0x1); |
| 176 VisitPCRelAddressing(instr); |
| 177 } |
| 178 |
| 179 |
| 180 void Decoder::DecodeBranchSystemException(Instruction* instr) { |
| 181 ASSERT((instr->Bits(27, 24) == 0x4) || |
| 182 (instr->Bits(27, 24) == 0x5) || |
| 183 (instr->Bits(27, 24) == 0x6) || |
| 184 (instr->Bits(27, 24) == 0x7) ); |
| 185 |
| 186 switch (instr->Bits(31, 29)) { |
| 187 case 0: |
| 188 case 4: { |
| 189 VisitUnconditionalBranch(instr); |
| 190 break; |
| 191 } |
| 192 case 1: |
| 193 case 5: { |
| 194 if (instr->Bit(25) == 0) { |
| 195 VisitCompareBranch(instr); |
| 196 } else { |
| 197 VisitTestBranch(instr); |
| 198 } |
| 199 break; |
| 200 } |
| 201 case 2: { |
| 202 if (instr->Bit(25) == 0) { |
| 203 if ((instr->Bit(24) == 0x1) || |
| 204 (instr->Mask(0x01000010) == 0x00000010)) { |
| 205 VisitUnallocated(instr); |
| 206 } else { |
| 207 VisitConditionalBranch(instr); |
| 208 } |
| 209 } else { |
| 210 VisitUnallocated(instr); |
| 211 } |
| 212 break; |
| 213 } |
| 214 case 6: { |
| 215 if (instr->Bit(25) == 0) { |
| 216 if (instr->Bit(24) == 0) { |
| 217 if ((instr->Bits(4, 2) != 0) || |
| 218 (instr->Mask(0x00E0001D) == 0x00200001) || |
| 219 (instr->Mask(0x00E0001D) == 0x00400001) || |
| 220 (instr->Mask(0x00E0001E) == 0x00200002) || |
| 221 (instr->Mask(0x00E0001E) == 0x00400002) || |
| 222 (instr->Mask(0x00E0001C) == 0x00600000) || |
| 223 (instr->Mask(0x00E0001C) == 0x00800000) || |
| 224 (instr->Mask(0x00E0001F) == 0x00A00000) || |
| 225 (instr->Mask(0x00C0001C) == 0x00C00000)) { |
| 226 VisitUnallocated(instr); |
| 227 } else { |
| 228 VisitException(instr); |
| 229 } |
| 230 } else { |
| 231 if (instr->Bits(23, 22) == 0) { |
| 232 const Instr masked_003FF0E0 = instr->Mask(0x003FF0E0); |
| 233 if ((instr->Bits(21, 19) == 0x4) || |
| 234 (masked_003FF0E0 == 0x00033000) || |
| 235 (masked_003FF0E0 == 0x003FF020) || |
| 236 (masked_003FF0E0 == 0x003FF060) || |
| 237 (masked_003FF0E0 == 0x003FF0E0) || |
| 238 (instr->Mask(0x00388000) == 0x00008000) || |
| 239 (instr->Mask(0x0038E000) == 0x00000000) || |
| 240 (instr->Mask(0x0039E000) == 0x00002000) || |
| 241 (instr->Mask(0x003AE000) == 0x00002000) || |
| 242 (instr->Mask(0x003CE000) == 0x00042000) || |
| 243 (instr->Mask(0x003FFFC0) == 0x000320C0) || |
| 244 (instr->Mask(0x003FF100) == 0x00032100) || |
| 245 (instr->Mask(0x003FF200) == 0x00032200) || |
| 246 (instr->Mask(0x003FF400) == 0x00032400) || |
| 247 (instr->Mask(0x003FF800) == 0x00032800) || |
| 248 (instr->Mask(0x0038F000) == 0x00005000) || |
| 249 (instr->Mask(0x0038E000) == 0x00006000)) { |
| 250 VisitUnallocated(instr); |
| 251 } else { |
| 252 VisitSystem(instr); |
| 253 } |
| 254 } else { |
| 255 VisitUnallocated(instr); |
| 256 } |
| 257 } |
| 258 } else { |
| 259 if ((instr->Bit(24) == 0x1) || |
| 260 (instr->Bits(20, 16) != 0x1F) || |
| 261 (instr->Bits(15, 10) != 0) || |
| 262 (instr->Bits(4, 0) != 0) || |
| 263 (instr->Bits(24, 21) == 0x3) || |
| 264 (instr->Bits(24, 22) == 0x3)) { |
| 265 VisitUnallocated(instr); |
| 266 } else { |
| 267 VisitUnconditionalBranchToRegister(instr); |
| 268 } |
| 269 } |
| 270 break; |
| 271 } |
| 272 case 3: |
| 273 case 7: { |
| 274 VisitUnallocated(instr); |
| 275 break; |
| 276 } |
| 277 } |
| 278 } |
| 279 |
| 280 |
| 281 void Decoder::DecodeLoadStore(Instruction* instr) { |
| 282 ASSERT((instr->Bits(27, 24) == 0x8) || |
| 283 (instr->Bits(27, 24) == 0x9) || |
| 284 (instr->Bits(27, 24) == 0xC) || |
| 285 (instr->Bits(27, 24) == 0xD) ); |
| 286 |
| 287 if (instr->Bit(24) == 0) { |
| 288 if (instr->Bit(28) == 0) { |
| 289 if (instr->Bit(29) == 0) { |
| 290 if (instr->Bit(26) == 0) { |
| 291 // TODO(all): VisitLoadStoreExclusive. |
| 292 VisitUnimplemented(instr); |
| 293 } else { |
| 294 DecodeAdvSIMDLoadStore(instr); |
| 295 } |
| 296 } else { |
| 297 if ((instr->Bits(31, 30) == 0x3) || |
| 298 (instr->Mask(0xC4400000) == 0x40000000)) { |
| 299 VisitUnallocated(instr); |
| 300 } else { |
| 301 if (instr->Bit(23) == 0) { |
| 302 if (instr->Mask(0xC4400000) == 0xC0400000) { |
| 303 VisitUnallocated(instr); |
| 304 } else { |
| 305 VisitLoadStorePairNonTemporal(instr); |
| 306 } |
| 307 } else { |
| 308 VisitLoadStorePairPostIndex(instr); |
| 309 } |
| 310 } |
| 311 } |
| 312 } else { |
| 313 if (instr->Bit(29) == 0) { |
| 314 if (instr->Mask(0xC4000000) == 0xC4000000) { |
| 315 VisitUnallocated(instr); |
| 316 } else { |
| 317 VisitLoadLiteral(instr); |
| 318 } |
| 319 } else { |
| 320 if ((instr->Mask(0x84C00000) == 0x80C00000) || |
| 321 (instr->Mask(0x44800000) == 0x44800000) || |
| 322 (instr->Mask(0x84800000) == 0x84800000)) { |
| 323 VisitUnallocated(instr); |
| 324 } else { |
| 325 if (instr->Bit(21) == 0) { |
| 326 switch (instr->Bits(11, 10)) { |
| 327 case 0: { |
| 328 VisitLoadStoreUnscaledOffset(instr); |
| 329 break; |
| 330 } |
| 331 case 1: { |
| 332 if (instr->Mask(0xC4C00000) == 0xC0800000) { |
| 333 VisitUnallocated(instr); |
| 334 } else { |
| 335 VisitLoadStorePostIndex(instr); |
| 336 } |
| 337 break; |
| 338 } |
| 339 case 2: { |
| 340 // TODO(all): VisitLoadStoreRegisterOffsetUnpriv. |
| 341 VisitUnimplemented(instr); |
| 342 break; |
| 343 } |
| 344 case 3: { |
| 345 if (instr->Mask(0xC4C00000) == 0xC0800000) { |
| 346 VisitUnallocated(instr); |
| 347 } else { |
| 348 VisitLoadStorePreIndex(instr); |
| 349 } |
| 350 break; |
| 351 } |
| 352 } |
| 353 } else { |
| 354 if (instr->Bits(11, 10) == 0x2) { |
| 355 if (instr->Bit(14) == 0) { |
| 356 VisitUnallocated(instr); |
| 357 } else { |
| 358 VisitLoadStoreRegisterOffset(instr); |
| 359 } |
| 360 } else { |
| 361 VisitUnallocated(instr); |
| 362 } |
| 363 } |
| 364 } |
| 365 } |
| 366 } |
| 367 } else { |
| 368 if (instr->Bit(28) == 0) { |
| 369 if (instr->Bit(29) == 0) { |
| 370 VisitUnallocated(instr); |
| 371 } else { |
| 372 if ((instr->Bits(31, 30) == 0x3) || |
| 373 (instr->Mask(0xC4400000) == 0x40000000)) { |
| 374 VisitUnallocated(instr); |
| 375 } else { |
| 376 if (instr->Bit(23) == 0) { |
| 377 VisitLoadStorePairOffset(instr); |
| 378 } else { |
| 379 VisitLoadStorePairPreIndex(instr); |
| 380 } |
| 381 } |
| 382 } |
| 383 } else { |
| 384 if (instr->Bit(29) == 0) { |
| 385 VisitUnallocated(instr); |
| 386 } else { |
| 387 if ((instr->Mask(0x84C00000) == 0x80C00000) || |
| 388 (instr->Mask(0x44800000) == 0x44800000) || |
| 389 (instr->Mask(0x84800000) == 0x84800000)) { |
| 390 VisitUnallocated(instr); |
| 391 } else { |
| 392 VisitLoadStoreUnsignedOffset(instr); |
| 393 } |
| 394 } |
| 395 } |
| 396 } |
| 397 } |
| 398 |
| 399 |
| 400 void Decoder::DecodeLogical(Instruction* instr) { |
| 401 ASSERT(instr->Bits(27, 24) == 0x2); |
| 402 |
| 403 if (instr->Mask(0x80400000) == 0x00400000) { |
| 404 VisitUnallocated(instr); |
| 405 } else { |
| 406 if (instr->Bit(23) == 0) { |
| 407 VisitLogicalImmediate(instr); |
| 408 } else { |
| 409 if (instr->Bits(30, 29) == 0x1) { |
| 410 VisitUnallocated(instr); |
| 411 } else { |
| 412 VisitMoveWideImmediate(instr); |
| 413 } |
| 414 } |
| 415 } |
| 416 } |
| 417 |
| 418 |
| 419 void Decoder::DecodeBitfieldExtract(Instruction* instr) { |
| 420 ASSERT(instr->Bits(27, 24) == 0x3); |
| 421 |
| 422 if ((instr->Mask(0x80400000) == 0x80000000) || |
| 423 (instr->Mask(0x80400000) == 0x00400000) || |
| 424 (instr->Mask(0x80008000) == 0x00008000)) { |
| 425 VisitUnallocated(instr); |
| 426 } else if (instr->Bit(23) == 0) { |
| 427 if ((instr->Mask(0x80200000) == 0x00200000) || |
| 428 (instr->Mask(0x60000000) == 0x60000000)) { |
| 429 VisitUnallocated(instr); |
| 430 } else { |
| 431 VisitBitfield(instr); |
| 432 } |
| 433 } else { |
| 434 if ((instr->Mask(0x60200000) == 0x00200000) || |
| 435 (instr->Mask(0x60000000) != 0x00000000)) { |
| 436 VisitUnallocated(instr); |
| 437 } else { |
| 438 VisitExtract(instr); |
| 439 } |
| 440 } |
| 441 } |
| 442 |
| 443 |
| 444 void Decoder::DecodeAddSubImmediate(Instruction* instr) { |
| 445 ASSERT(instr->Bits(27, 24) == 0x1); |
| 446 if (instr->Bit(23) == 1) { |
| 447 VisitUnallocated(instr); |
| 448 } else { |
| 449 VisitAddSubImmediate(instr); |
| 450 } |
| 451 } |
| 452 |
| 453 |
| 454 void Decoder::DecodeDataProcessing(Instruction* instr) { |
| 455 ASSERT((instr->Bits(27, 24) == 0xA) || |
| 456 (instr->Bits(27, 24) == 0xB) ); |
| 457 |
| 458 if (instr->Bit(24) == 0) { |
| 459 if (instr->Bit(28) == 0) { |
| 460 if (instr->Mask(0x80008000) == 0x00008000) { |
| 461 VisitUnallocated(instr); |
| 462 } else { |
| 463 VisitLogicalShifted(instr); |
| 464 } |
| 465 } else { |
| 466 switch (instr->Bits(23, 21)) { |
| 467 case 0: { |
| 468 if (instr->Mask(0x0000FC00) != 0) { |
| 469 VisitUnallocated(instr); |
| 470 } else { |
| 471 VisitAddSubWithCarry(instr); |
| 472 } |
| 473 break; |
| 474 } |
| 475 case 2: { |
| 476 if ((instr->Bit(29) == 0) || |
| 477 (instr->Mask(0x00000410) != 0)) { |
| 478 VisitUnallocated(instr); |
| 479 } else { |
| 480 if (instr->Bit(11) == 0) { |
| 481 VisitConditionalCompareRegister(instr); |
| 482 } else { |
| 483 VisitConditionalCompareImmediate(instr); |
| 484 } |
| 485 } |
| 486 break; |
| 487 } |
| 488 case 4: { |
| 489 if (instr->Mask(0x20000800) != 0x00000000) { |
| 490 VisitUnallocated(instr); |
| 491 } else { |
| 492 VisitConditionalSelect(instr); |
| 493 } |
| 494 break; |
| 495 } |
| 496 case 6: { |
| 497 if (instr->Bit(29) == 0x1) { |
| 498 VisitUnallocated(instr); |
| 499 } else { |
| 500 if (instr->Bit(30) == 0) { |
| 501 if ((instr->Bit(15) == 0x1) || |
| 502 (instr->Bits(15, 11) == 0) || |
| 503 (instr->Bits(15, 12) == 0x1) || |
| 504 (instr->Bits(15, 12) == 0x3) || |
| 505 (instr->Bits(15, 13) == 0x3) || |
| 506 (instr->Mask(0x8000EC00) == 0x00004C00) || |
| 507 (instr->Mask(0x8000E800) == 0x80004000) || |
| 508 (instr->Mask(0x8000E400) == 0x80004000)) { |
| 509 VisitUnallocated(instr); |
| 510 } else { |
| 511 VisitDataProcessing2Source(instr); |
| 512 } |
| 513 } else { |
| 514 if ((instr->Bit(13) == 1) || |
| 515 (instr->Bits(20, 16) != 0) || |
| 516 (instr->Bits(15, 14) != 0) || |
| 517 (instr->Mask(0xA01FFC00) == 0x00000C00) || |
| 518 (instr->Mask(0x201FF800) == 0x00001800)) { |
| 519 VisitUnallocated(instr); |
| 520 } else { |
| 521 VisitDataProcessing1Source(instr); |
| 522 } |
| 523 } |
| 524 break; |
| 525 } |
| 526 } |
| 527 case 1: |
| 528 case 3: |
| 529 case 5: |
| 530 case 7: VisitUnallocated(instr); break; |
| 531 } |
| 532 } |
| 533 } else { |
| 534 if (instr->Bit(28) == 0) { |
| 535 if (instr->Bit(21) == 0) { |
| 536 if ((instr->Bits(23, 22) == 0x3) || |
| 537 (instr->Mask(0x80008000) == 0x00008000)) { |
| 538 VisitUnallocated(instr); |
| 539 } else { |
| 540 VisitAddSubShifted(instr); |
| 541 } |
| 542 } else { |
| 543 if ((instr->Mask(0x00C00000) != 0x00000000) || |
| 544 (instr->Mask(0x00001400) == 0x00001400) || |
| 545 (instr->Mask(0x00001800) == 0x00001800)) { |
| 546 VisitUnallocated(instr); |
| 547 } else { |
| 548 VisitAddSubExtended(instr); |
| 549 } |
| 550 } |
| 551 } else { |
| 552 if ((instr->Bit(30) == 0x1) || |
| 553 (instr->Bits(30, 29) == 0x1) || |
| 554 (instr->Mask(0xE0600000) == 0x00200000) || |
| 555 (instr->Mask(0xE0608000) == 0x00400000) || |
| 556 (instr->Mask(0x60608000) == 0x00408000) || |
| 557 (instr->Mask(0x60E00000) == 0x00E00000) || |
| 558 (instr->Mask(0x60E00000) == 0x00800000) || |
| 559 (instr->Mask(0x60E00000) == 0x00600000)) { |
| 560 VisitUnallocated(instr); |
| 561 } else { |
| 562 VisitDataProcessing3Source(instr); |
| 563 } |
| 564 } |
| 565 } |
| 566 } |
| 567 |
| 568 |
| 569 void Decoder::DecodeFP(Instruction* instr) { |
| 570 ASSERT((instr->Bits(27, 24) == 0xE) || |
| 571 (instr->Bits(27, 24) == 0xF) ); |
| 572 |
| 573 if (instr->Bit(28) == 0) { |
| 574 DecodeAdvSIMDDataProcessing(instr); |
| 575 } else { |
| 576 if (instr->Bit(29) == 1) { |
| 577 VisitUnallocated(instr); |
| 578 } else { |
| 579 if (instr->Bits(31, 30) == 0x3) { |
| 580 VisitUnallocated(instr); |
| 581 } else if (instr->Bits(31, 30) == 0x1) { |
| 582 DecodeAdvSIMDDataProcessing(instr); |
| 583 } else { |
| 584 if (instr->Bit(24) == 0) { |
| 585 if (instr->Bit(21) == 0) { |
| 586 if ((instr->Bit(23) == 1) || |
| 587 (instr->Bit(18) == 1) || |
| 588 (instr->Mask(0x80008000) == 0x00000000) || |
| 589 (instr->Mask(0x000E0000) == 0x00000000) || |
| 590 (instr->Mask(0x000E0000) == 0x000A0000) || |
| 591 (instr->Mask(0x00160000) == 0x00000000) || |
| 592 (instr->Mask(0x00160000) == 0x00120000)) { |
| 593 VisitUnallocated(instr); |
| 594 } else { |
| 595 VisitFPFixedPointConvert(instr); |
| 596 } |
| 597 } else { |
| 598 if (instr->Bits(15, 10) == 32) { |
| 599 VisitUnallocated(instr); |
| 600 } else if (instr->Bits(15, 10) == 0) { |
| 601 if ((instr->Bits(23, 22) == 0x3) || |
| 602 (instr->Mask(0x000E0000) == 0x000A0000) || |
| 603 (instr->Mask(0x000E0000) == 0x000C0000) || |
| 604 (instr->Mask(0x00160000) == 0x00120000) || |
| 605 (instr->Mask(0x00160000) == 0x00140000) || |
| 606 (instr->Mask(0x20C40000) == 0x00800000) || |
| 607 (instr->Mask(0x20C60000) == 0x00840000) || |
| 608 (instr->Mask(0xA0C60000) == 0x80060000) || |
| 609 (instr->Mask(0xA0C60000) == 0x00860000) || |
| 610 (instr->Mask(0xA0C60000) == 0x00460000) || |
| 611 (instr->Mask(0xA0CE0000) == 0x80860000) || |
| 612 (instr->Mask(0xA0CE0000) == 0x804E0000) || |
| 613 (instr->Mask(0xA0CE0000) == 0x000E0000) || |
| 614 (instr->Mask(0xA0D60000) == 0x00160000) || |
| 615 (instr->Mask(0xA0D60000) == 0x80560000) || |
| 616 (instr->Mask(0xA0D60000) == 0x80960000)) { |
| 617 VisitUnallocated(instr); |
| 618 } else { |
| 619 VisitFPIntegerConvert(instr); |
| 620 } |
| 621 } else if (instr->Bits(14, 10) == 16) { |
| 622 const Instr masked_A0DF8000 = instr->Mask(0xA0DF8000); |
| 623 if ((instr->Mask(0x80180000) != 0) || |
| 624 (masked_A0DF8000 == 0x00020000) || |
| 625 (masked_A0DF8000 == 0x00030000) || |
| 626 (masked_A0DF8000 == 0x00068000) || |
| 627 (masked_A0DF8000 == 0x00428000) || |
| 628 (masked_A0DF8000 == 0x00430000) || |
| 629 (masked_A0DF8000 == 0x00468000) || |
| 630 (instr->Mask(0xA0D80000) == 0x00800000) || |
| 631 (instr->Mask(0xA0DE0000) == 0x00C00000) || |
| 632 (instr->Mask(0xA0DF0000) == 0x00C30000) || |
| 633 (instr->Mask(0xA0DC0000) == 0x00C40000)) { |
| 634 VisitUnallocated(instr); |
| 635 } else { |
| 636 VisitFPDataProcessing1Source(instr); |
| 637 } |
| 638 } else if (instr->Bits(13, 10) == 8) { |
| 639 if ((instr->Bits(15, 14) != 0) || |
| 640 (instr->Bits(2, 0) != 0) || |
| 641 (instr->Mask(0x80800000) != 0x00000000)) { |
| 642 VisitUnallocated(instr); |
| 643 } else { |
| 644 VisitFPCompare(instr); |
| 645 } |
| 646 } else if (instr->Bits(12, 10) == 4) { |
| 647 if ((instr->Bits(9, 5) != 0) || |
| 648 (instr->Mask(0x80800000) != 0x00000000)) { |
| 649 VisitUnallocated(instr); |
| 650 } else { |
| 651 VisitFPImmediate(instr); |
| 652 } |
| 653 } else { |
| 654 if (instr->Mask(0x80800000) != 0x00000000) { |
| 655 VisitUnallocated(instr); |
| 656 } else { |
| 657 switch (instr->Bits(11, 10)) { |
| 658 case 1: { |
| 659 VisitFPConditionalCompare(instr); |
| 660 break; |
| 661 } |
| 662 case 2: { |
| 663 if ((instr->Bits(15, 14) == 0x3) || |
| 664 (instr->Mask(0x00009000) == 0x00009000) || |
| 665 (instr->Mask(0x0000A000) == 0x0000A000)) { |
| 666 VisitUnallocated(instr); |
| 667 } else { |
| 668 VisitFPDataProcessing2Source(instr); |
| 669 } |
| 670 break; |
| 671 } |
| 672 case 3: { |
| 673 VisitFPConditionalSelect(instr); |
| 674 break; |
| 675 } |
| 676 default: UNREACHABLE(); |
| 677 } |
| 678 } |
| 679 } |
| 680 } |
| 681 } else { |
| 682 // Bit 30 == 1 has been handled earlier. |
| 683 ASSERT(instr->Bit(30) == 0); |
| 684 if (instr->Mask(0xA0800000) != 0) { |
| 685 VisitUnallocated(instr); |
| 686 } else { |
| 687 VisitFPDataProcessing3Source(instr); |
| 688 } |
| 689 } |
| 690 } |
| 691 } |
| 692 } |
| 693 } |
| 694 |
| 695 |
| 696 void Decoder::DecodeAdvSIMDLoadStore(Instruction* instr) { |
| 697 // TODO(all): Implement Advanced SIMD load/store instruction decode. |
| 698 ASSERT(instr->Bits(29, 25) == 0x6); |
| 699 VisitUnimplemented(instr); |
| 700 } |
| 701 |
| 702 |
| 703 void Decoder::DecodeAdvSIMDDataProcessing(Instruction* instr) { |
| 704 // TODO(all): Implement Advanced SIMD data processing instruction decode. |
| 705 ASSERT(instr->Bits(27, 25) == 0x7); |
| 706 VisitUnimplemented(instr); |
| 707 } |
| 708 |
| 709 |
| 710 #define DEFINE_VISITOR_CALLERS(A) \ |
| 711 void Decoder::Visit##A(Instruction *instr) { \ |
| 712 if (!(instr->Mask(A##FMask) == A##Fixed)) { \ |
| 713 ASSERT(instr->Mask(A##FMask) == A##Fixed); \ |
| 714 } \ |
| 715 std::list<DecoderVisitor*>::iterator it; \ |
| 716 for (it = visitors_.begin(); it != visitors_.end(); it++) { \ |
| 717 (*it)->Visit##A(instr); \ |
| 718 } \ |
| 719 } |
| 720 VISITOR_LIST(DEFINE_VISITOR_CALLERS) |
| 721 #undef DEFINE_VISITOR_CALLERS |
| 722 |
| 723 |
| 724 } } // namespace v8::internal |
| 725 |
| 726 #endif // V8_TARGET_ARCH_A64 |
OLD | NEW |