OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_MIPS_CONSTANTS_H_ | 5 #ifndef V8_MIPS_CONSTANTS_H_ |
6 #define V8_MIPS_CONSTANTS_H_ | 6 #define V8_MIPS_CONSTANTS_H_ |
7 | 7 |
8 #include "src/base/logging.h" | 8 #include "src/base/logging.h" |
9 #include "src/base/macros.h" | 9 #include "src/base/macros.h" |
10 #include "src/globals.h" | 10 #include "src/globals.h" |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 // Misc masks. | 296 // Misc masks. |
297 const int kHiMask = 0xffff << 16; | 297 const int kHiMask = 0xffff << 16; |
298 const int kLoMask = 0xffff; | 298 const int kLoMask = 0xffff; |
299 const int kSignMask = 0x80000000; | 299 const int kSignMask = 0x80000000; |
300 const int kJumpAddrMask = (1 << (kImm26Bits + kImmFieldShift)) - 1; | 300 const int kJumpAddrMask = (1 << (kImm26Bits + kImmFieldShift)) - 1; |
301 const int64_t kHi16MaskOf64 = (int64_t)0xffff << 48; | 301 const int64_t kHi16MaskOf64 = (int64_t)0xffff << 48; |
302 const int64_t kSe16MaskOf64 = (int64_t)0xffff << 32; | 302 const int64_t kSe16MaskOf64 = (int64_t)0xffff << 32; |
303 const int64_t kTh16MaskOf64 = (int64_t)0xffff << 16; | 303 const int64_t kTh16MaskOf64 = (int64_t)0xffff << 16; |
304 const int32_t kJalRawMark = 0x00000000; | 304 const int32_t kJalRawMark = 0x00000000; |
305 const int32_t kJRawMark = 0xf0000000; | 305 const int32_t kJRawMark = 0xf0000000; |
306 const int32_t kJumpRawMask = 0xf0000000; | |
306 | 307 |
307 // ----- MIPS Opcodes and Function Fields. | 308 // ----- MIPS Opcodes and Function Fields. |
308 // We use this presentation to stay close to the table representation in | 309 // We use this presentation to stay close to the table representation in |
309 // MIPS32 Architecture For Programmers, Volume II: The MIPS32 Instruction Set. | 310 // MIPS32 Architecture For Programmers, Volume II: The MIPS32 Instruction Set. |
310 enum Opcode { | 311 enum Opcode : uint32_t { |
311 SPECIAL = 0 << kOpcodeShift, | 312 SPECIAL = 0U << kOpcodeShift, |
312 REGIMM = 1 << kOpcodeShift, | 313 REGIMM = 1U << kOpcodeShift, |
313 | 314 |
314 J = ((0 << 3) + 2) << kOpcodeShift, | 315 J = ((0U << 3) + 2) << kOpcodeShift, |
315 JAL = ((0 << 3) + 3) << kOpcodeShift, | 316 JAL = ((0U << 3) + 3) << kOpcodeShift, |
316 BEQ = ((0 << 3) + 4) << kOpcodeShift, | 317 BEQ = ((0U << 3) + 4) << kOpcodeShift, |
317 BNE = ((0 << 3) + 5) << kOpcodeShift, | 318 BNE = ((0U << 3) + 5) << kOpcodeShift, |
318 BLEZ = ((0 << 3) + 6) << kOpcodeShift, | 319 BLEZ = ((0U << 3) + 6) << kOpcodeShift, |
319 BGTZ = ((0 << 3) + 7) << kOpcodeShift, | 320 BGTZ = ((0U << 3) + 7) << kOpcodeShift, |
320 | 321 |
321 ADDI = ((1 << 3) + 0) << kOpcodeShift, | 322 ADDI = ((1U << 3) + 0) << kOpcodeShift, |
322 ADDIU = ((1 << 3) + 1) << kOpcodeShift, | 323 ADDIU = ((1U << 3) + 1) << kOpcodeShift, |
323 SLTI = ((1 << 3) + 2) << kOpcodeShift, | 324 SLTI = ((1U << 3) + 2) << kOpcodeShift, |
324 SLTIU = ((1 << 3) + 3) << kOpcodeShift, | 325 SLTIU = ((1U << 3) + 3) << kOpcodeShift, |
325 ANDI = ((1 << 3) + 4) << kOpcodeShift, | 326 ANDI = ((1U << 3) + 4) << kOpcodeShift, |
326 ORI = ((1 << 3) + 5) << kOpcodeShift, | 327 ORI = ((1U << 3) + 5) << kOpcodeShift, |
327 XORI = ((1 << 3) + 6) << kOpcodeShift, | 328 XORI = ((1U << 3) + 6) << kOpcodeShift, |
328 LUI = ((1 << 3) + 7) << kOpcodeShift, // LUI/AUI family. | 329 LUI = ((1U << 3) + 7) << kOpcodeShift, // LUI/AUI family. |
329 DAUI = ((3 << 3) + 5) << kOpcodeShift, | 330 DAUI = ((3U << 3) + 5) << kOpcodeShift, |
330 | 331 |
331 BEQC = ((2 << 3) + 0) << kOpcodeShift, | 332 BEQC = ((2U << 3) + 0) << kOpcodeShift, |
332 COP1 = ((2 << 3) + 1) << kOpcodeShift, // Coprocessor 1 class. | 333 COP1 = ((2U << 3) + 1) << kOpcodeShift, // Coprocessor 1 class. |
333 BEQL = ((2 << 3) + 4) << kOpcodeShift, | 334 BEQL = ((2U << 3) + 4) << kOpcodeShift, |
334 BNEL = ((2 << 3) + 5) << kOpcodeShift, | 335 BNEL = ((2U << 3) + 5) << kOpcodeShift, |
335 BLEZL = ((2 << 3) + 6) << kOpcodeShift, | 336 BLEZL = ((2U << 3) + 6) << kOpcodeShift, |
336 BGTZL = ((2 << 3) + 7) << kOpcodeShift, | 337 BGTZL = ((2U << 3) + 7) << kOpcodeShift, |
337 | 338 |
338 DADDI = ((3 << 3) + 0) << kOpcodeShift, // This is also BNEC. | 339 DADDI = ((3U << 3) + 0) << kOpcodeShift, // This is also BNEC. |
339 DADDIU = ((3 << 3) + 1) << kOpcodeShift, | 340 DADDIU = ((3U << 3) + 1) << kOpcodeShift, |
340 LDL = ((3 << 3) + 2) << kOpcodeShift, | 341 LDL = ((3U << 3) + 2) << kOpcodeShift, |
341 LDR = ((3 << 3) + 3) << kOpcodeShift, | 342 LDR = ((3U << 3) + 3) << kOpcodeShift, |
342 SPECIAL2 = ((3 << 3) + 4) << kOpcodeShift, | 343 SPECIAL2 = ((3U << 3) + 4) << kOpcodeShift, |
343 SPECIAL3 = ((3 << 3) + 7) << kOpcodeShift, | 344 SPECIAL3 = ((3U << 3) + 7) << kOpcodeShift, |
344 | 345 |
345 LB = ((4 << 3) + 0) << kOpcodeShift, | 346 LB = ((4U << 3) + 0) << kOpcodeShift, |
346 LH = ((4 << 3) + 1) << kOpcodeShift, | 347 LH = ((4U << 3) + 1) << kOpcodeShift, |
347 LWL = ((4 << 3) + 2) << kOpcodeShift, | 348 LWL = ((4U << 3) + 2) << kOpcodeShift, |
348 LW = ((4 << 3) + 3) << kOpcodeShift, | 349 LW = ((4U << 3) + 3) << kOpcodeShift, |
349 LBU = ((4 << 3) + 4) << kOpcodeShift, | 350 LBU = ((4U << 3) + 4) << kOpcodeShift, |
350 LHU = ((4 << 3) + 5) << kOpcodeShift, | 351 LHU = ((4U << 3) + 5) << kOpcodeShift, |
351 LWR = ((4 << 3) + 6) << kOpcodeShift, | 352 LWR = ((4U << 3) + 6) << kOpcodeShift, |
352 LWU = ((4 << 3) + 7) << kOpcodeShift, | 353 LWU = ((4U << 3) + 7) << kOpcodeShift, |
353 | 354 |
354 SB = ((5 << 3) + 0) << kOpcodeShift, | 355 SB = ((5U << 3) + 0) << kOpcodeShift, |
355 SH = ((5 << 3) + 1) << kOpcodeShift, | 356 SH = ((5U << 3) + 1) << kOpcodeShift, |
356 SWL = ((5 << 3) + 2) << kOpcodeShift, | 357 SWL = ((5U << 3) + 2) << kOpcodeShift, |
357 SW = ((5 << 3) + 3) << kOpcodeShift, | 358 SW = ((5U << 3) + 3) << kOpcodeShift, |
358 SDL = ((5 << 3) + 4) << kOpcodeShift, | 359 SDL = ((5U << 3) + 4) << kOpcodeShift, |
359 SDR = ((5 << 3) + 5) << kOpcodeShift, | 360 SDR = ((5U << 3) + 5) << kOpcodeShift, |
360 SWR = ((5 << 3) + 6) << kOpcodeShift, | 361 SWR = ((5U << 3) + 6) << kOpcodeShift, |
361 | 362 |
362 LWC1 = ((6 << 3) + 1) << kOpcodeShift, | 363 LWC1 = ((6U << 3) + 1) << kOpcodeShift, |
363 BC = ((6 << 3) + 2) << kOpcodeShift, | 364 BC = ((6U << 3) + 2) << kOpcodeShift, |
364 LLD = ((6 << 3) + 4) << kOpcodeShift, | 365 LLD = ((6U << 3) + 4) << kOpcodeShift, |
365 LDC1 = ((6 << 3) + 5) << kOpcodeShift, | 366 LDC1 = ((6U << 3) + 5) << kOpcodeShift, |
366 POP66 = ((6 << 3) + 6) << kOpcodeShift, | 367 POP66 = ((6U << 3) + 6) << kOpcodeShift, |
367 LD = ((6 << 3) + 7) << kOpcodeShift, | 368 LD = ((6U << 3) + 7) << kOpcodeShift, |
368 | 369 |
369 PREF = ((6 << 3) + 3) << kOpcodeShift, | 370 PREF = ((6U << 3) + 3) << kOpcodeShift, |
370 | 371 |
371 SWC1 = ((7 << 3) + 1) << kOpcodeShift, | 372 SWC1 = ((7U << 3) + 1) << kOpcodeShift, |
372 BALC = ((7 << 3) + 2) << kOpcodeShift, | 373 BALC = ((7U << 3) + 2) << kOpcodeShift, |
373 PCREL = ((7 << 3) + 3) << kOpcodeShift, | 374 PCREL = ((7U << 3) + 3) << kOpcodeShift, |
374 SCD = ((7 << 3) + 4) << kOpcodeShift, | 375 SCD = ((7U << 3) + 4) << kOpcodeShift, |
375 SDC1 = ((7 << 3) + 5) << kOpcodeShift, | 376 SDC1 = ((7U << 3) + 5) << kOpcodeShift, |
376 POP76 = ((7 << 3) + 6) << kOpcodeShift, | 377 POP76 = ((7U << 3) + 6) << kOpcodeShift, |
377 SD = ((7 << 3) + 7) << kOpcodeShift, | 378 SD = ((7U << 3) + 7) << kOpcodeShift, |
378 | 379 |
379 COP1X = ((1 << 4) + 3) << kOpcodeShift | 380 COP1X = ((1U << 4) + 3) << kOpcodeShift, |
381 | |
382 // New r6 instruction. | |
383 POP06 = BLEZ, // bgeuc/bleuc, blezalc, bgezalc | |
384 POP07 = BGTZ, // bltuc/bgtuc, bgtzalc, bltzalc | |
385 POP10 = ADDI, // beqzalc, bovc, beqc | |
386 POP26 = BLEZL, // bgezc, blezc, bgec/blec | |
387 POP27 = BGTZL, // bgtzc, bltzc, bltc/bgtc | |
388 POP30 = DADDI, // bnezalc, bvnc, bnec | |
Ilija.Pavlovic1
2015/12/18 11:38:22
change: "bvnc" into "bnvc"
balazs.kilvady
2015/12/18 19:18:05
Mea culpa, That is a typo from the 32-bit version.
ivica.bogosavljevic
2015/12/22 10:22:40
Acknowledged.
ivica.bogosavljevic
2015/12/22 10:22:40
Acknowledged.
| |
380 }; | 389 }; |
381 | 390 |
382 enum SecondaryField { | 391 enum SecondaryField : uint32_t { |
383 // SPECIAL Encoding of Function Field. | 392 // SPECIAL Encoding of Function Field. |
384 SLL = ((0 << 3) + 0), | 393 SLL = ((0U << 3) + 0), |
385 MOVCI = ((0 << 3) + 1), | 394 MOVCI = ((0U << 3) + 1), |
386 SRL = ((0 << 3) + 2), | 395 SRL = ((0U << 3) + 2), |
387 SRA = ((0 << 3) + 3), | 396 SRA = ((0U << 3) + 3), |
388 SLLV = ((0 << 3) + 4), | 397 SLLV = ((0U << 3) + 4), |
389 SRLV = ((0 << 3) + 6), | 398 SRLV = ((0U << 3) + 6), |
390 SRAV = ((0 << 3) + 7), | 399 SRAV = ((0U << 3) + 7), |
391 | 400 |
392 JR = ((1 << 3) + 0), | 401 JR = ((1U << 3) + 0), |
393 JALR = ((1 << 3) + 1), | 402 JALR = ((1U << 3) + 1), |
394 MOVZ = ((1 << 3) + 2), | 403 MOVZ = ((1U << 3) + 2), |
395 MOVN = ((1 << 3) + 3), | 404 MOVN = ((1U << 3) + 3), |
396 BREAK = ((1 << 3) + 5), | 405 BREAK = ((1U << 3) + 5), |
397 | 406 |
398 MFHI = ((2 << 3) + 0), | 407 MFHI = ((2U << 3) + 0), |
399 CLZ_R6 = ((2 << 3) + 0), | 408 CLZ_R6 = ((2U << 3) + 0), |
400 CLO_R6 = ((2 << 3) + 1), | 409 CLO_R6 = ((2U << 3) + 1), |
401 MFLO = ((2 << 3) + 2), | 410 MFLO = ((2U << 3) + 2), |
402 DCLZ_R6 = ((2 << 3) + 2), | 411 DCLZ_R6 = ((2U << 3) + 2), |
403 DCLO_R6 = ((2 << 3) + 3), | 412 DCLO_R6 = ((2U << 3) + 3), |
404 DSLLV = ((2 << 3) + 4), | 413 DSLLV = ((2U << 3) + 4), |
405 DSRLV = ((2 << 3) + 6), | 414 DSRLV = ((2U << 3) + 6), |
406 DSRAV = ((2 << 3) + 7), | 415 DSRAV = ((2U << 3) + 7), |
407 | 416 |
408 MULT = ((3 << 3) + 0), | 417 MULT = ((3U << 3) + 0), |
409 MULTU = ((3 << 3) + 1), | 418 MULTU = ((3U << 3) + 1), |
410 DIV = ((3 << 3) + 2), | 419 DIV = ((3U << 3) + 2), |
411 DIVU = ((3 << 3) + 3), | 420 DIVU = ((3U << 3) + 3), |
412 DMULT = ((3 << 3) + 4), | 421 DMULT = ((3U << 3) + 4), |
413 DMULTU = ((3 << 3) + 5), | 422 DMULTU = ((3U << 3) + 5), |
414 DDIV = ((3 << 3) + 6), | 423 DDIV = ((3U << 3) + 6), |
415 DDIVU = ((3 << 3) + 7), | 424 DDIVU = ((3U << 3) + 7), |
416 | 425 |
417 ADD = ((4 << 3) + 0), | 426 ADD = ((4U << 3) + 0), |
418 ADDU = ((4 << 3) + 1), | 427 ADDU = ((4U << 3) + 1), |
419 SUB = ((4 << 3) + 2), | 428 SUB = ((4U << 3) + 2), |
420 SUBU = ((4 << 3) + 3), | 429 SUBU = ((4U << 3) + 3), |
421 AND = ((4 << 3) + 4), | 430 AND = ((4U << 3) + 4), |
422 OR = ((4 << 3) + 5), | 431 OR = ((4U << 3) + 5), |
423 XOR = ((4 << 3) + 6), | 432 XOR = ((4U << 3) + 6), |
424 NOR = ((4 << 3) + 7), | 433 NOR = ((4U << 3) + 7), |
425 | 434 |
426 SLT = ((5 << 3) + 2), | 435 SLT = ((5U << 3) + 2), |
427 SLTU = ((5 << 3) + 3), | 436 SLTU = ((5U << 3) + 3), |
428 DADD = ((5 << 3) + 4), | 437 DADD = ((5U << 3) + 4), |
429 DADDU = ((5 << 3) + 5), | 438 DADDU = ((5U << 3) + 5), |
430 DSUB = ((5 << 3) + 6), | 439 DSUB = ((5U << 3) + 6), |
431 DSUBU = ((5 << 3) + 7), | 440 DSUBU = ((5U << 3) + 7), |
432 | 441 |
433 TGE = ((6 << 3) + 0), | 442 TGE = ((6U << 3) + 0), |
434 TGEU = ((6 << 3) + 1), | 443 TGEU = ((6U << 3) + 1), |
435 TLT = ((6 << 3) + 2), | 444 TLT = ((6U << 3) + 2), |
436 TLTU = ((6 << 3) + 3), | 445 TLTU = ((6U << 3) + 3), |
437 TEQ = ((6 << 3) + 4), | 446 TEQ = ((6U << 3) + 4), |
438 SELEQZ_S = ((6 << 3) + 5), | 447 SELEQZ_S = ((6U << 3) + 5), |
439 TNE = ((6 << 3) + 6), | 448 TNE = ((6U << 3) + 6), |
440 SELNEZ_S = ((6 << 3) + 7), | 449 SELNEZ_S = ((6U << 3) + 7), |
441 | 450 |
442 DSLL = ((7 << 3) + 0), | 451 DSLL = ((7U << 3) + 0), |
443 DSRL = ((7 << 3) + 2), | 452 DSRL = ((7U << 3) + 2), |
444 DSRA = ((7 << 3) + 3), | 453 DSRA = ((7U << 3) + 3), |
445 DSLL32 = ((7 << 3) + 4), | 454 DSLL32 = ((7U << 3) + 4), |
446 DSRL32 = ((7 << 3) + 6), | 455 DSRL32 = ((7U << 3) + 6), |
447 DSRA32 = ((7 << 3) + 7), | 456 DSRA32 = ((7U << 3) + 7), |
448 | 457 |
449 // Multiply integers in r6. | 458 // Multiply integers in r6. |
450 MUL_MUH = ((3 << 3) + 0), // MUL, MUH. | 459 MUL_MUH = ((3U << 3) + 0), // MUL, MUH. |
451 MUL_MUH_U = ((3 << 3) + 1), // MUL_U, MUH_U. | 460 MUL_MUH_U = ((3U << 3) + 1), // MUL_U, MUH_U. |
452 D_MUL_MUH = ((7 << 2) + 0), // DMUL, DMUH. | 461 D_MUL_MUH = ((7U << 2) + 0), // DMUL, DMUH. |
453 D_MUL_MUH_U = ((7 << 2) + 1), // DMUL_U, DMUH_U. | 462 D_MUL_MUH_U = ((7U << 2) + 1), // DMUL_U, DMUH_U. |
454 RINT = ((3 << 3) + 2), | 463 RINT = ((3U << 3) + 2), |
455 | 464 |
456 MUL_OP = ((0 << 3) + 2), | 465 MUL_OP = ((0U << 3) + 2), |
457 MUH_OP = ((0 << 3) + 3), | 466 MUH_OP = ((0U << 3) + 3), |
458 DIV_OP = ((0 << 3) + 2), | 467 DIV_OP = ((0U << 3) + 2), |
459 MOD_OP = ((0 << 3) + 3), | 468 MOD_OP = ((0U << 3) + 3), |
460 | 469 |
461 DIV_MOD = ((3 << 3) + 2), | 470 DIV_MOD = ((3U << 3) + 2), |
462 DIV_MOD_U = ((3 << 3) + 3), | 471 DIV_MOD_U = ((3U << 3) + 3), |
463 D_DIV_MOD = ((3 << 3) + 6), | 472 D_DIV_MOD = ((3U << 3) + 6), |
464 D_DIV_MOD_U = ((3 << 3) + 7), | 473 D_DIV_MOD_U = ((3U << 3) + 7), |
465 | 474 |
466 // drotr in special4? | 475 // drotr in special4? |
467 | 476 |
468 // SPECIAL2 Encoding of Function Field. | 477 // SPECIAL2 Encoding of Function Field. |
469 MUL = ((0 << 3) + 2), | 478 MUL = ((0U << 3) + 2), |
470 CLZ = ((4 << 3) + 0), | 479 CLZ = ((4U << 3) + 0), |
471 CLO = ((4 << 3) + 1), | 480 CLO = ((4U << 3) + 1), |
472 DCLZ = ((4 << 3) + 4), | 481 DCLZ = ((4U << 3) + 4), |
473 DCLO = ((4 << 3) + 5), | 482 DCLO = ((4U << 3) + 5), |
474 | 483 |
475 // SPECIAL3 Encoding of Function Field. | 484 // SPECIAL3 Encoding of Function Field. |
476 EXT = ((0 << 3) + 0), | 485 EXT = ((0U << 3) + 0), |
477 DEXTM = ((0 << 3) + 1), | 486 DEXTM = ((0U << 3) + 1), |
478 DEXTU = ((0 << 3) + 2), | 487 DEXTU = ((0U << 3) + 2), |
479 DEXT = ((0 << 3) + 3), | 488 DEXT = ((0U << 3) + 3), |
480 INS = ((0 << 3) + 4), | 489 INS = ((0U << 3) + 4), |
481 DINSM = ((0 << 3) + 5), | 490 DINSM = ((0U << 3) + 5), |
482 DINSU = ((0 << 3) + 6), | 491 DINSU = ((0U << 3) + 6), |
483 DINS = ((0 << 3) + 7), | 492 DINS = ((0U << 3) + 7), |
484 | 493 |
485 BSHFL = ((4 << 3) + 0), | 494 BSHFL = ((4U << 3) + 0), |
486 DBSHFL = ((4 << 3) + 4), | 495 DBSHFL = ((4U << 3) + 4), |
487 | 496 |
488 // SPECIAL3 Encoding of sa Field. | 497 // SPECIAL3 Encoding of sa Field. |
489 BITSWAP = ((0 << 3) + 0), | 498 BITSWAP = ((0U << 3) + 0), |
490 ALIGN = ((0 << 3) + 2), | 499 ALIGN = ((0U << 3) + 2), |
491 WSBH = ((0 << 3) + 2), | 500 WSBH = ((0U << 3) + 2), |
492 SEB = ((2 << 3) + 0), | 501 SEB = ((2U << 3) + 0), |
493 SEH = ((3 << 3) + 0), | 502 SEH = ((3U << 3) + 0), |
494 | 503 |
495 DBITSWAP = ((0 << 3) + 0), | 504 DBITSWAP = ((0U << 3) + 0), |
496 DALIGN = ((0 << 3) + 1), | 505 DALIGN = ((0U << 3) + 1), |
497 DBITSWAP_SA = ((0 << 3) + 0) << kSaShift, | 506 DBITSWAP_SA = ((0U << 3) + 0) << kSaShift, |
498 DSBH = ((0 << 3) + 2), | 507 DSBH = ((0U << 3) + 2), |
499 DSHD = ((0 << 3) + 5), | 508 DSHD = ((0U << 3) + 5), |
500 | 509 |
501 // REGIMM encoding of rt Field. | 510 // REGIMM encoding of rt Field. |
502 BLTZ = ((0 << 3) + 0) << 16, | 511 BLTZ = ((0U << 3) + 0) << 16, |
503 BGEZ = ((0 << 3) + 1) << 16, | 512 BGEZ = ((0U << 3) + 1) << 16, |
504 BLTZAL = ((2 << 3) + 0) << 16, | 513 BLTZAL = ((2U << 3) + 0) << 16, |
505 BGEZAL = ((2 << 3) + 1) << 16, | 514 BGEZAL = ((2U << 3) + 1) << 16, |
506 BGEZALL = ((2 << 3) + 3) << 16, | 515 BGEZALL = ((2U << 3) + 3) << 16, |
507 DAHI = ((0 << 3) + 6) << 16, | 516 DAHI = ((0U << 3) + 6) << 16, |
508 DATI = ((3 << 3) + 6) << 16, | 517 DATI = ((3U << 3) + 6) << 16, |
509 | 518 |
510 // COP1 Encoding of rs Field. | 519 // COP1 Encoding of rs Field. |
511 MFC1 = ((0 << 3) + 0) << 21, | 520 MFC1 = ((0U << 3) + 0) << 21, |
512 DMFC1 = ((0 << 3) + 1) << 21, | 521 DMFC1 = ((0U << 3) + 1) << 21, |
513 CFC1 = ((0 << 3) + 2) << 21, | 522 CFC1 = ((0U << 3) + 2) << 21, |
514 MFHC1 = ((0 << 3) + 3) << 21, | 523 MFHC1 = ((0U << 3) + 3) << 21, |
515 MTC1 = ((0 << 3) + 4) << 21, | 524 MTC1 = ((0U << 3) + 4) << 21, |
516 DMTC1 = ((0 << 3) + 5) << 21, | 525 DMTC1 = ((0U << 3) + 5) << 21, |
517 CTC1 = ((0 << 3) + 6) << 21, | 526 CTC1 = ((0U << 3) + 6) << 21, |
518 MTHC1 = ((0 << 3) + 7) << 21, | 527 MTHC1 = ((0U << 3) + 7) << 21, |
519 BC1 = ((1 << 3) + 0) << 21, | 528 BC1 = ((1U << 3) + 0) << 21, |
520 S = ((2 << 3) + 0) << 21, | 529 S = ((2U << 3) + 0) << 21, |
521 D = ((2 << 3) + 1) << 21, | 530 D = ((2U << 3) + 1) << 21, |
522 W = ((2 << 3) + 4) << 21, | 531 W = ((2U << 3) + 4) << 21, |
523 L = ((2 << 3) + 5) << 21, | 532 L = ((2U << 3) + 5) << 21, |
524 PS = ((2 << 3) + 6) << 21, | 533 PS = ((2U << 3) + 6) << 21, |
525 // COP1 Encoding of Function Field When rs=S. | 534 // COP1 Encoding of Function Field When rs=S. |
526 | 535 |
527 ADD_S = ((0 << 3) + 0), | 536 ADD_S = ((0U << 3) + 0), |
528 SUB_S = ((0 << 3) + 1), | 537 SUB_S = ((0U << 3) + 1), |
529 MUL_S = ((0 << 3) + 2), | 538 MUL_S = ((0U << 3) + 2), |
530 DIV_S = ((0 << 3) + 3), | 539 DIV_S = ((0U << 3) + 3), |
531 ABS_S = ((0 << 3) + 5), | 540 ABS_S = ((0U << 3) + 5), |
532 SQRT_S = ((0 << 3) + 4), | 541 SQRT_S = ((0U << 3) + 4), |
533 MOV_S = ((0 << 3) + 6), | 542 MOV_S = ((0U << 3) + 6), |
534 NEG_S = ((0 << 3) + 7), | 543 NEG_S = ((0U << 3) + 7), |
535 ROUND_L_S = ((1 << 3) + 0), | 544 ROUND_L_S = ((1U << 3) + 0), |
536 TRUNC_L_S = ((1 << 3) + 1), | 545 TRUNC_L_S = ((1U << 3) + 1), |
537 CEIL_L_S = ((1 << 3) + 2), | 546 CEIL_L_S = ((1U << 3) + 2), |
538 FLOOR_L_S = ((1 << 3) + 3), | 547 FLOOR_L_S = ((1U << 3) + 3), |
539 ROUND_W_S = ((1 << 3) + 4), | 548 ROUND_W_S = ((1U << 3) + 4), |
540 TRUNC_W_S = ((1 << 3) + 5), | 549 TRUNC_W_S = ((1U << 3) + 5), |
541 CEIL_W_S = ((1 << 3) + 6), | 550 CEIL_W_S = ((1U << 3) + 6), |
542 FLOOR_W_S = ((1 << 3) + 7), | 551 FLOOR_W_S = ((1U << 3) + 7), |
543 RECIP_S = ((2 << 3) + 5), | 552 RECIP_S = ((2U << 3) + 5), |
544 RSQRT_S = ((2 << 3) + 6), | 553 RSQRT_S = ((2U << 3) + 6), |
545 CLASS_S = ((3 << 3) + 3), | 554 CLASS_S = ((3U << 3) + 3), |
546 CVT_D_S = ((4 << 3) + 1), | 555 CVT_D_S = ((4U << 3) + 1), |
547 CVT_W_S = ((4 << 3) + 4), | 556 CVT_W_S = ((4U << 3) + 4), |
548 CVT_L_S = ((4 << 3) + 5), | 557 CVT_L_S = ((4U << 3) + 5), |
549 CVT_PS_S = ((4 << 3) + 6), | 558 CVT_PS_S = ((4U << 3) + 6), |
550 // COP1 Encoding of Function Field When rs=D. | 559 // COP1 Encoding of Function Field When rs=D. |
551 ADD_D = ((0 << 3) + 0), | 560 ADD_D = ((0U << 3) + 0), |
552 SUB_D = ((0 << 3) + 1), | 561 SUB_D = ((0U << 3) + 1), |
553 MUL_D = ((0 << 3) + 2), | 562 MUL_D = ((0U << 3) + 2), |
554 DIV_D = ((0 << 3) + 3), | 563 DIV_D = ((0U << 3) + 3), |
555 SQRT_D = ((0 << 3) + 4), | 564 SQRT_D = ((0U << 3) + 4), |
556 ABS_D = ((0 << 3) + 5), | 565 ABS_D = ((0U << 3) + 5), |
557 MOV_D = ((0 << 3) + 6), | 566 MOV_D = ((0U << 3) + 6), |
558 NEG_D = ((0 << 3) + 7), | 567 NEG_D = ((0U << 3) + 7), |
559 ROUND_L_D = ((1 << 3) + 0), | 568 ROUND_L_D = ((1U << 3) + 0), |
560 TRUNC_L_D = ((1 << 3) + 1), | 569 TRUNC_L_D = ((1U << 3) + 1), |
561 CEIL_L_D = ((1 << 3) + 2), | 570 CEIL_L_D = ((1U << 3) + 2), |
562 FLOOR_L_D = ((1 << 3) + 3), | 571 FLOOR_L_D = ((1U << 3) + 3), |
563 ROUND_W_D = ((1 << 3) + 4), | 572 ROUND_W_D = ((1U << 3) + 4), |
564 TRUNC_W_D = ((1 << 3) + 5), | 573 TRUNC_W_D = ((1U << 3) + 5), |
565 CEIL_W_D = ((1 << 3) + 6), | 574 CEIL_W_D = ((1U << 3) + 6), |
566 FLOOR_W_D = ((1 << 3) + 7), | 575 FLOOR_W_D = ((1U << 3) + 7), |
567 RECIP_D = ((2 << 3) + 5), | 576 RECIP_D = ((2U << 3) + 5), |
568 RSQRT_D = ((2 << 3) + 6), | 577 RSQRT_D = ((2U << 3) + 6), |
569 CLASS_D = ((3 << 3) + 3), | 578 CLASS_D = ((3U << 3) + 3), |
570 MIN = ((3 << 3) + 4), | 579 MIN = ((3U << 3) + 4), |
571 MINA = ((3 << 3) + 5), | 580 MINA = ((3U << 3) + 5), |
572 MAX = ((3 << 3) + 6), | 581 MAX = ((3U << 3) + 6), |
573 MAXA = ((3 << 3) + 7), | 582 MAXA = ((3U << 3) + 7), |
574 CVT_S_D = ((4 << 3) + 0), | 583 CVT_S_D = ((4U << 3) + 0), |
575 CVT_W_D = ((4 << 3) + 4), | 584 CVT_W_D = ((4U << 3) + 4), |
576 CVT_L_D = ((4 << 3) + 5), | 585 CVT_L_D = ((4U << 3) + 5), |
577 C_F_D = ((6 << 3) + 0), | 586 C_F_D = ((6U << 3) + 0), |
578 C_UN_D = ((6 << 3) + 1), | 587 C_UN_D = ((6U << 3) + 1), |
579 C_EQ_D = ((6 << 3) + 2), | 588 C_EQ_D = ((6U << 3) + 2), |
580 C_UEQ_D = ((6 << 3) + 3), | 589 C_UEQ_D = ((6U << 3) + 3), |
581 C_OLT_D = ((6 << 3) + 4), | 590 C_OLT_D = ((6U << 3) + 4), |
582 C_ULT_D = ((6 << 3) + 5), | 591 C_ULT_D = ((6U << 3) + 5), |
583 C_OLE_D = ((6 << 3) + 6), | 592 C_OLE_D = ((6U << 3) + 6), |
584 C_ULE_D = ((6 << 3) + 7), | 593 C_ULE_D = ((6U << 3) + 7), |
585 | 594 |
586 // COP1 Encoding of Function Field When rs=W or L. | 595 // COP1 Encoding of Function Field When rs=W or L. |
587 CVT_S_W = ((4 << 3) + 0), | 596 CVT_S_W = ((4U << 3) + 0), |
588 CVT_D_W = ((4 << 3) + 1), | 597 CVT_D_W = ((4U << 3) + 1), |
589 CVT_S_L = ((4 << 3) + 0), | 598 CVT_S_L = ((4U << 3) + 0), |
590 CVT_D_L = ((4 << 3) + 1), | 599 CVT_D_L = ((4U << 3) + 1), |
591 BC1EQZ = ((2 << 2) + 1) << 21, | 600 BC1EQZ = ((2U << 2) + 1) << 21, |
592 BC1NEZ = ((3 << 2) + 1) << 21, | 601 BC1NEZ = ((3U << 2) + 1) << 21, |
593 // COP1 CMP positive predicates Bit 5..4 = 00. | 602 // COP1 CMP positive predicates Bit 5..4 = 00. |
594 CMP_AF = ((0 << 3) + 0), | 603 CMP_AF = ((0U << 3) + 0), |
595 CMP_UN = ((0 << 3) + 1), | 604 CMP_UN = ((0U << 3) + 1), |
596 CMP_EQ = ((0 << 3) + 2), | 605 CMP_EQ = ((0U << 3) + 2), |
597 CMP_UEQ = ((0 << 3) + 3), | 606 CMP_UEQ = ((0U << 3) + 3), |
598 CMP_LT = ((0 << 3) + 4), | 607 CMP_LT = ((0U << 3) + 4), |
599 CMP_ULT = ((0 << 3) + 5), | 608 CMP_ULT = ((0U << 3) + 5), |
600 CMP_LE = ((0 << 3) + 6), | 609 CMP_LE = ((0U << 3) + 6), |
601 CMP_ULE = ((0 << 3) + 7), | 610 CMP_ULE = ((0U << 3) + 7), |
602 CMP_SAF = ((1 << 3) + 0), | 611 CMP_SAF = ((1U << 3) + 0), |
603 CMP_SUN = ((1 << 3) + 1), | 612 CMP_SUN = ((1U << 3) + 1), |
604 CMP_SEQ = ((1 << 3) + 2), | 613 CMP_SEQ = ((1U << 3) + 2), |
605 CMP_SUEQ = ((1 << 3) + 3), | 614 CMP_SUEQ = ((1U << 3) + 3), |
606 CMP_SSLT = ((1 << 3) + 4), | 615 CMP_SSLT = ((1U << 3) + 4), |
607 CMP_SSULT = ((1 << 3) + 5), | 616 CMP_SSULT = ((1U << 3) + 5), |
608 CMP_SLE = ((1 << 3) + 6), | 617 CMP_SLE = ((1U << 3) + 6), |
609 CMP_SULE = ((1 << 3) + 7), | 618 CMP_SULE = ((1U << 3) + 7), |
610 // COP1 CMP negative predicates Bit 5..4 = 01. | 619 // COP1 CMP negative predicates Bit 5..4 = 01. |
611 CMP_AT = ((2 << 3) + 0), // Reserved, not implemented. | 620 CMP_AT = ((2U << 3) + 0), // Reserved, not implemented. |
612 CMP_OR = ((2 << 3) + 1), | 621 CMP_OR = ((2U << 3) + 1), |
613 CMP_UNE = ((2 << 3) + 2), | 622 CMP_UNE = ((2U << 3) + 2), |
614 CMP_NE = ((2 << 3) + 3), | 623 CMP_NE = ((2U << 3) + 3), |
615 CMP_UGE = ((2 << 3) + 4), // Reserved, not implemented. | 624 CMP_UGE = ((2U << 3) + 4), // Reserved, not implemented. |
616 CMP_OGE = ((2 << 3) + 5), // Reserved, not implemented. | 625 CMP_OGE = ((2U << 3) + 5), // Reserved, not implemented. |
617 CMP_UGT = ((2 << 3) + 6), // Reserved, not implemented. | 626 CMP_UGT = ((2U << 3) + 6), // Reserved, not implemented. |
618 CMP_OGT = ((2 << 3) + 7), // Reserved, not implemented. | 627 CMP_OGT = ((2U << 3) + 7), // Reserved, not implemented. |
619 CMP_SAT = ((3 << 3) + 0), // Reserved, not implemented. | 628 CMP_SAT = ((3U << 3) + 0), // Reserved, not implemented. |
620 CMP_SOR = ((3 << 3) + 1), | 629 CMP_SOR = ((3U << 3) + 1), |
621 CMP_SUNE = ((3 << 3) + 2), | 630 CMP_SUNE = ((3U << 3) + 2), |
622 CMP_SNE = ((3 << 3) + 3), | 631 CMP_SNE = ((3U << 3) + 3), |
623 CMP_SUGE = ((3 << 3) + 4), // Reserved, not implemented. | 632 CMP_SUGE = ((3U << 3) + 4), // Reserved, not implemented. |
624 CMP_SOGE = ((3 << 3) + 5), // Reserved, not implemented. | 633 CMP_SOGE = ((3U << 3) + 5), // Reserved, not implemented. |
625 CMP_SUGT = ((3 << 3) + 6), // Reserved, not implemented. | 634 CMP_SUGT = ((3U << 3) + 6), // Reserved, not implemented. |
626 CMP_SOGT = ((3 << 3) + 7), // Reserved, not implemented. | 635 CMP_SOGT = ((3U << 3) + 7), // Reserved, not implemented. |
627 | 636 |
628 SEL = ((2 << 3) + 0), | 637 SEL = ((2U << 3) + 0), |
629 MOVF = ((2 << 3) + 1), // Function field for MOVT.fmt and MOVF.fmt | 638 MOVF = ((2U << 3) + 1), // Function field for MOVT.fmt and MOVF.fmt |
630 MOVZ_C = ((2 << 3) + 2), // COP1 on FPR registers. | 639 MOVZ_C = ((2U << 3) + 2), // COP1 on FPR registers. |
631 MOVN_C = ((2 << 3) + 3), // COP1 on FPR registers. | 640 MOVN_C = ((2U << 3) + 3), // COP1 on FPR registers. |
632 SELEQZ_C = ((2 << 3) + 4), // COP1 on FPR registers. | 641 SELEQZ_C = ((2U << 3) + 4), // COP1 on FPR registers. |
633 SELNEZ_C = ((2 << 3) + 7), // COP1 on FPR registers. | 642 SELNEZ_C = ((2U << 3) + 7), // COP1 on FPR registers. |
634 | 643 |
635 // COP1 Encoding of Function Field When rs=PS. | 644 // COP1 Encoding of Function Field When rs=PS. |
636 // COP1X Encoding of Function Field. | 645 // COP1X Encoding of Function Field. |
637 MADD_D = ((4 << 3) + 1), | 646 MADD_D = ((4U << 3) + 1), |
638 | 647 |
639 // PCREL Encoding of rt Field. | 648 // PCREL Encoding of rt Field. |
640 ADDIUPC = ((0 << 2) + 0), | 649 ADDIUPC = ((0U << 2) + 0), |
641 LWPC = ((0 << 2) + 1), | 650 LWPC = ((0U << 2) + 1), |
642 LWUPC = ((0 << 2) + 2), | 651 LWUPC = ((0U << 2) + 2), |
643 LDPC = ((0 << 3) + 6), | 652 LDPC = ((0U << 3) + 6), |
644 // reserved ((1 << 3) + 6), | 653 // reserved ((1U << 3) + 6), |
645 AUIPC = ((3 << 3) + 6), | 654 AUIPC = ((3U << 3) + 6), |
646 ALUIPC = ((3 << 3) + 7), | 655 ALUIPC = ((3U << 3) + 7), |
647 | 656 |
648 // POP66 Encoding of rs Field. | 657 // POP66 Encoding of rs Field. |
649 JIC = ((0 << 5) + 0), | 658 JIC = ((0U << 5) + 0), |
650 | 659 |
651 // POP76 Encoding of rs Field. | 660 // POP76 Encoding of rs Field. |
652 JIALC = ((0 << 5) + 0), | 661 JIALC = ((0U << 5) + 0), |
653 | 662 |
654 NULLSF = 0 | 663 NULLSF = 0U |
655 }; | 664 }; |
656 | 665 |
657 | 666 |
658 // ----- Emulated conditions. | 667 // ----- Emulated conditions. |
659 // On MIPS we use this enum to abstract from conditional branch instructions. | 668 // On MIPS we use this enum to abstract from conditional branch instructions. |
660 // The 'U' prefix is used to specify unsigned comparisons. | 669 // The 'U' prefix is used to specify unsigned comparisons. |
661 // Opposite conditions must be paired as odd/even numbers | 670 // Opposite conditions must be paired as odd/even numbers |
662 // because 'NegateCondition' function flips LSB to negate condition. | 671 // because 'NegateCondition' function flips LSB to negate condition. |
663 enum Condition { | 672 enum Condition { |
664 // Any value < 0 is considered no_condition. | 673 // Any value < 0 is considered no_condition. |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
867 extern const Instr kRtMask; | 876 extern const Instr kRtMask; |
868 extern const Instr kLwSwInstrTypeMask; | 877 extern const Instr kLwSwInstrTypeMask; |
869 extern const Instr kLwSwInstrArgumentMask; | 878 extern const Instr kLwSwInstrArgumentMask; |
870 extern const Instr kLwSwOffsetMask; | 879 extern const Instr kLwSwOffsetMask; |
871 | 880 |
872 // Break 0xfffff, reserved for redirected real time call. | 881 // Break 0xfffff, reserved for redirected real time call. |
873 const Instr rtCallRedirInstr = SPECIAL | BREAK | call_rt_redirected << 6; | 882 const Instr rtCallRedirInstr = SPECIAL | BREAK | call_rt_redirected << 6; |
874 // A nop instruction. (Encoding of sll 0 0 0). | 883 // A nop instruction. (Encoding of sll 0 0 0). |
875 const Instr nopInstr = 0; | 884 const Instr nopInstr = 0; |
876 | 885 |
886 static constexpr uint64_t OpcodeToBitNumber(Opcode opcode) { | |
887 return 1ULL << (static_cast<uint32_t>(opcode) >> kOpcodeShift); | |
888 } | |
889 | |
890 | |
877 class Instruction { | 891 class Instruction { |
878 public: | 892 public: |
879 enum { | 893 enum { |
880 kInstrSize = 4, | 894 kInstrSize = 4, |
881 kInstrSizeLog2 = 2, | 895 kInstrSizeLog2 = 2, |
882 // On MIPS PC cannot actually be directly accessed. We behave as if PC was | 896 // On MIPS PC cannot actually be directly accessed. We behave as if PC was |
883 // always the value of the current instruction being executed. | 897 // always the value of the current instruction being executed. |
884 kPCReadOffset = 0 | 898 kPCReadOffset = 0 |
885 }; | 899 }; |
886 | 900 |
887 // Get the raw instruction bits. | 901 // Get the raw instruction bits. |
888 inline Instr InstructionBits() const { | 902 inline Instr InstructionBits() const { |
889 return *reinterpret_cast<const Instr*>(this); | 903 return *reinterpret_cast<const Instr*>(this); |
890 } | 904 } |
891 | 905 |
892 // Set the raw instruction bits to value. | 906 // Set the raw instruction bits to value. |
893 inline void SetInstructionBits(Instr value) { | 907 inline void SetInstructionBits(Instr value) { |
894 *reinterpret_cast<Instr*>(this) = value; | 908 *reinterpret_cast<Instr*>(this) = value; |
895 } | 909 } |
896 | 910 |
897 // Read one particular bit out of the instruction bits. | 911 // Read one particular bit out of the instruction bits. |
898 inline int Bit(int nr) const { | 912 inline int Bit(int nr) const { |
899 return (InstructionBits() >> nr) & 1; | 913 return (InstructionBits() >> nr) & 1; |
900 } | 914 } |
901 | 915 |
902 // Read a bit field out of the instruction bits. | 916 // Read a bit field out of the instruction bits. |
903 inline int Bits(int hi, int lo) const { | 917 inline int Bits(int hi, int lo) const { |
904 return (InstructionBits() >> lo) & ((2 << (hi - lo)) - 1); | 918 return (InstructionBits() >> lo) & ((2U << (hi - lo)) - 1); |
905 } | 919 } |
906 | 920 |
907 // Instruction type. | 921 // Instruction type. |
908 enum Type { | 922 enum Type { |
909 kRegisterType, | 923 kRegisterType, |
910 kImmediateType, | 924 kImmediateType, |
911 kJumpType, | 925 kJumpType, |
912 kUnsupported = -1 | 926 kUnsupported = -1 |
913 }; | 927 }; |
914 | 928 |
915 enum TypeChecks { NORMAL, EXTRA }; | 929 enum TypeChecks { NORMAL, EXTRA }; |
916 | 930 |
917 | 931 |
918 #define OpcodeToBitNumber(opcode) \ | 932 static constexpr uint64_t kOpcodeImmediateTypeMask = |
919 (1ULL << (static_cast<uint32_t>(opcode) >> kOpcodeShift)) | |
920 | |
921 static const uint64_t kOpcodeImmediateTypeMask = | |
922 OpcodeToBitNumber(REGIMM) | OpcodeToBitNumber(BEQ) | | 933 OpcodeToBitNumber(REGIMM) | OpcodeToBitNumber(BEQ) | |
923 OpcodeToBitNumber(BNE) | OpcodeToBitNumber(BLEZ) | | 934 OpcodeToBitNumber(BNE) | OpcodeToBitNumber(BLEZ) | |
924 OpcodeToBitNumber(BGTZ) | OpcodeToBitNumber(ADDI) | | 935 OpcodeToBitNumber(BGTZ) | OpcodeToBitNumber(ADDI) | |
925 OpcodeToBitNumber(DADDI) | OpcodeToBitNumber(ADDIU) | | 936 OpcodeToBitNumber(DADDI) | OpcodeToBitNumber(ADDIU) | |
926 OpcodeToBitNumber(DADDIU) | OpcodeToBitNumber(SLTI) | | 937 OpcodeToBitNumber(DADDIU) | OpcodeToBitNumber(SLTI) | |
927 OpcodeToBitNumber(SLTIU) | OpcodeToBitNumber(ANDI) | | 938 OpcodeToBitNumber(SLTIU) | OpcodeToBitNumber(ANDI) | |
928 OpcodeToBitNumber(ORI) | OpcodeToBitNumber(XORI) | | 939 OpcodeToBitNumber(ORI) | OpcodeToBitNumber(XORI) | |
929 OpcodeToBitNumber(LUI) | OpcodeToBitNumber(BEQL) | | 940 OpcodeToBitNumber(LUI) | OpcodeToBitNumber(BEQL) | |
930 OpcodeToBitNumber(BNEL) | OpcodeToBitNumber(BLEZL) | | 941 OpcodeToBitNumber(BNEL) | OpcodeToBitNumber(BLEZL) | |
931 OpcodeToBitNumber(BGTZL) | OpcodeToBitNumber(POP66) | | 942 OpcodeToBitNumber(BGTZL) | OpcodeToBitNumber(POP66) | |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1095 return FunctionValue(); | 1106 return FunctionValue(); |
1096 case COP1: | 1107 case COP1: |
1097 return RsValue(); | 1108 return RsValue(); |
1098 case REGIMM: | 1109 case REGIMM: |
1099 return RtValue(); | 1110 return RtValue(); |
1100 default: | 1111 default: |
1101 return NULLSF; | 1112 return NULLSF; |
1102 } | 1113 } |
1103 } | 1114 } |
1104 | 1115 |
1116 inline int32_t ImmValue(int bits) const { | |
1117 DCHECK(InstructionType() == kImmediateType); | |
1118 return Bits(bits - 1, 0); | |
1119 } | |
1120 | |
1105 inline int32_t Imm16Value() const { | 1121 inline int32_t Imm16Value() const { |
1106 DCHECK(InstructionType() == kImmediateType); | 1122 DCHECK(InstructionType() == kImmediateType); |
1107 return Bits(kImm16Shift + kImm16Bits - 1, kImm16Shift); | 1123 return Bits(kImm16Shift + kImm16Bits - 1, kImm16Shift); |
1108 } | 1124 } |
1109 | 1125 |
1110 inline int32_t Imm18Value() const { | 1126 inline int32_t Imm18Value() const { |
1111 DCHECK(InstructionType() == kImmediateType); | 1127 DCHECK(InstructionType() == kImmediateType); |
1112 return Bits(kImm18Shift + kImm18Bits - 1, kImm18Shift); | 1128 return Bits(kImm18Shift + kImm18Bits - 1, kImm18Shift); |
1113 } | 1129 } |
1114 | 1130 |
1115 inline int32_t Imm19Value() const { | 1131 inline int32_t Imm19Value() const { |
1116 DCHECK(InstructionType() == kImmediateType); | 1132 DCHECK(InstructionType() == kImmediateType); |
1117 return Bits(kImm19Shift + kImm19Bits - 1, kImm19Shift); | 1133 return Bits(kImm19Shift + kImm19Bits - 1, kImm19Shift); |
1118 } | 1134 } |
1119 | 1135 |
1120 inline int32_t Imm21Value() const { | 1136 inline int32_t Imm21Value() const { |
1121 DCHECK(InstructionType() == kImmediateType); | 1137 DCHECK(InstructionType() == kImmediateType); |
1122 return Bits(kImm21Shift + kImm21Bits - 1, kImm21Shift); | 1138 return Bits(kImm21Shift + kImm21Bits - 1, kImm21Shift); |
1123 } | 1139 } |
1124 | 1140 |
1125 inline int32_t Imm26Value() const { | 1141 inline int32_t Imm26Value() const { |
1126 DCHECK((InstructionType() == kJumpType) || | 1142 DCHECK((InstructionType() == kJumpType) || |
1127 (InstructionType() == kImmediateType)); | 1143 (InstructionType() == kImmediateType)); |
1128 return Bits(kImm26Shift + kImm26Bits - 1, kImm26Shift); | 1144 return Bits(kImm26Shift + kImm26Bits - 1, kImm26Shift); |
1129 } | 1145 } |
1130 | 1146 |
1131 // Say if the instruction should not be used in a branch delay slot. | 1147 static bool IsForbiddenAfterBranchInstr(Instr instr); |
1132 bool IsForbiddenInBranchDelay() const; | 1148 |
1149 // Say if the instruction should not be used in a branch delay slot or | |
1150 // immediately after a compact branch. | |
1151 inline bool IsForbiddenAfterBranch() const { | |
1152 return IsForbiddenAfterBranchInstr(InstructionBits()); | |
1153 } | |
1154 | |
1155 inline bool IsForbiddenInBranchDelay() const { | |
1156 return IsForbiddenAfterBranch(); | |
1157 } | |
1133 // Say if the instruction 'links'. e.g. jal, bal. | 1158 // Say if the instruction 'links'. e.g. jal, bal. |
1134 bool IsLinkingInstruction() const; | 1159 bool IsLinkingInstruction() const; |
1135 // Say if the instruction is a break or a trap. | 1160 // Say if the instruction is a break or a trap. |
1136 bool IsTrap() const; | 1161 bool IsTrap() const; |
1137 | 1162 |
1138 // Instructions are read of out a code stream. The only way to get a | 1163 // Instructions are read of out a code stream. The only way to get a |
1139 // reference to an instruction is to convert a pointer. There is no way | 1164 // reference to an instruction is to convert a pointer. There is no way |
1140 // to allocate or create instances of class Instruction. | 1165 // to allocate or create instances of class Instruction. |
1141 // Use the At(pc) function to create references to Instruction. | 1166 // Use the At(pc) function to create references to Instruction. |
1142 static Instruction* At(byte* pc) { | 1167 static Instruction* At(byte* pc) { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1265 } | 1290 } |
1266 return kUnsupported; | 1291 return kUnsupported; |
1267 } | 1292 } |
1268 | 1293 |
1269 #undef OpcodeToBitNumber | 1294 #undef OpcodeToBitNumber |
1270 #undef FunctionFieldToBitNumber | 1295 #undef FunctionFieldToBitNumber |
1271 } // namespace internal | 1296 } // namespace internal |
1272 } // namespace v8 | 1297 } // namespace v8 |
1273 | 1298 |
1274 #endif // #ifndef V8_MIPS_CONSTANTS_H_ | 1299 #endif // #ifndef V8_MIPS_CONSTANTS_H_ |
OLD | NEW |