Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: src/mips/constants-mips.h

Issue 1396133002: MIPS: r6 compact branch optimization. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/mips/assembler-mips-inl.h ('k') | src/mips/constants-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "src/globals.h" 7 #include "src/globals.h"
8 // UNIMPLEMENTED_ macro for MIPS. 8 // UNIMPLEMENTED_ macro for MIPS.
9 #ifdef DEBUG 9 #ifdef DEBUG
10 #define UNIMPLEMENTED_MIPS() \ 10 #define UNIMPLEMENTED_MIPS() \
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 const int kFdBits = 5; 291 const int kFdBits = 5;
292 const int kFCccShift = 8; 292 const int kFCccShift = 8;
293 const int kFCccBits = 3; 293 const int kFCccBits = 3;
294 const int kFBccShift = 18; 294 const int kFBccShift = 18;
295 const int kFBccBits = 3; 295 const int kFBccBits = 3;
296 const int kFBtrueShift = 16; 296 const int kFBtrueShift = 16;
297 const int kFBtrueBits = 1; 297 const int kFBtrueBits = 1;
298 298
299 // ----- Miscellaneous useful masks. 299 // ----- Miscellaneous useful masks.
300 // Instruction bit masks. 300 // Instruction bit masks.
301 const int kOpcodeMask = ((1 << kOpcodeBits) - 1) << kOpcodeShift; 301 const int kOpcodeMask = ((1 << kOpcodeBits) - 1) << kOpcodeShift;
302 const int kImm16Mask = ((1 << kImm16Bits) - 1) << kImm16Shift; 302 const int kImm16Mask = ((1 << kImm16Bits) - 1) << kImm16Shift;
303 const int kImm18Mask = ((1 << kImm18Bits) - 1) << kImm18Shift; 303 const int kImm18Mask = ((1 << kImm18Bits) - 1) << kImm18Shift;
304 const int kImm19Mask = ((1 << kImm19Bits) - 1) << kImm19Shift; 304 const int kImm19Mask = ((1 << kImm19Bits) - 1) << kImm19Shift;
305 const int kImm21Mask = ((1 << kImm21Bits) - 1) << kImm21Shift; 305 const int kImm21Mask = ((1 << kImm21Bits) - 1) << kImm21Shift;
306 const int kImm26Mask = ((1 << kImm26Bits) - 1) << kImm26Shift; 306 const int kImm26Mask = ((1 << kImm26Bits) - 1) << kImm26Shift;
307 const int kImm28Mask = ((1 << kImm28Bits) - 1) << kImm28Shift; 307 const int kImm28Mask = ((1 << kImm28Bits) - 1) << kImm28Shift;
308 const int kRsFieldMask = ((1 << kRsBits) - 1) << kRsShift; 308 const int kRsFieldMask = ((1 << kRsBits) - 1) << kRsShift;
309 const int kRtFieldMask = ((1 << kRtBits) - 1) << kRtShift; 309 const int kRtFieldMask = ((1 << kRtBits) - 1) << kRtShift;
310 const int kRdFieldMask = ((1 << kRdBits) - 1) << kRdShift; 310 const int kRdFieldMask = ((1 << kRdBits) - 1) << kRdShift;
311 const int kSaFieldMask = ((1 << kSaBits) - 1) << kSaShift; 311 const int kSaFieldMask = ((1 << kSaBits) - 1) << kSaShift;
312 const int kFunctionFieldMask = ((1 << kFunctionBits) - 1) << kFunctionShift; 312 const int kFunctionFieldMask = ((1 << kFunctionBits) - 1) << kFunctionShift;
313 // Misc masks. 313 // Misc masks.
314 const int kHiMask = 0xffff << 16; 314 const int kHiMask = 0xffff << 16;
315 const int kLoMask = 0xffff; 315 const int kLoMask = 0xffff;
316 const int kSignMask = 0x80000000; 316 const int kSignMask = 0x80000000;
317 const int kJumpAddrMask = (1 << (kImm26Bits + kImmFieldShift)) - 1; 317 const int kJumpAddrMask = (1 << (kImm26Bits + kImmFieldShift)) - 1;
318 318
319 // ----- MIPS Opcodes and Function Fields. 319 // ----- MIPS Opcodes and Function Fields.
320 // We use this presentation to stay close to the table representation in 320 // We use this presentation to stay close to the table representation in
321 // MIPS32 Architecture For Programmers, Volume II: The MIPS32 Instruction Set. 321 // MIPS32 Architecture For Programmers, Volume II: The MIPS32 Instruction Set.
322 enum Opcode { 322 enum Opcode : uint32_t {
323 SPECIAL = 0 << kOpcodeShift, 323 SPECIAL = 0U << kOpcodeShift,
324 REGIMM = 1 << kOpcodeShift, 324 REGIMM = 1U << kOpcodeShift,
325 325
326 J = ((0 << 3) + 2) << kOpcodeShift, 326 J = ((0U << 3) + 2) << kOpcodeShift,
327 JAL = ((0 << 3) + 3) << kOpcodeShift, 327 JAL = ((0U << 3) + 3) << kOpcodeShift,
328 BEQ = ((0 << 3) + 4) << kOpcodeShift, 328 BEQ = ((0U << 3) + 4) << kOpcodeShift,
329 BNE = ((0 << 3) + 5) << kOpcodeShift, 329 BNE = ((0U << 3) + 5) << kOpcodeShift,
330 BLEZ = ((0 << 3) + 6) << kOpcodeShift, 330 BLEZ = ((0U << 3) + 6) << kOpcodeShift,
331 BGTZ = ((0 << 3) + 7) << kOpcodeShift, 331 BGTZ = ((0U << 3) + 7) << kOpcodeShift,
332 332
333 ADDI = ((1 << 3) + 0) << kOpcodeShift, 333 ADDI = ((1U << 3) + 0) << kOpcodeShift,
334 ADDIU = ((1 << 3) + 1) << kOpcodeShift, 334 ADDIU = ((1U << 3) + 1) << kOpcodeShift,
335 SLTI = ((1 << 3) + 2) << kOpcodeShift, 335 SLTI = ((1U << 3) + 2) << kOpcodeShift,
336 SLTIU = ((1 << 3) + 3) << kOpcodeShift, 336 SLTIU = ((1U << 3) + 3) << kOpcodeShift,
337 ANDI = ((1 << 3) + 4) << kOpcodeShift, 337 ANDI = ((1U << 3) + 4) << kOpcodeShift,
338 ORI = ((1 << 3) + 5) << kOpcodeShift, 338 ORI = ((1U << 3) + 5) << kOpcodeShift,
339 XORI = ((1 << 3) + 6) << kOpcodeShift, 339 XORI = ((1U << 3) + 6) << kOpcodeShift,
340 LUI = ((1 << 3) + 7) << kOpcodeShift, // LUI/AUI family. 340 LUI = ((1U << 3) + 7) << kOpcodeShift, // LUI/AUI family.
341 341
342 BEQC = ((2 << 3) + 0) << kOpcodeShift, 342 BEQC = ((2U << 3) + 0) << kOpcodeShift,
343 COP1 = ((2 << 3) + 1) << kOpcodeShift, // Coprocessor 1 class. 343 COP1 = ((2U << 3) + 1) << kOpcodeShift, // Coprocessor 1 class.
344 BEQL = ((2 << 3) + 4) << kOpcodeShift, 344 BEQL = ((2U << 3) + 4) << kOpcodeShift,
345 BNEL = ((2 << 3) + 5) << kOpcodeShift, 345 BNEL = ((2U << 3) + 5) << kOpcodeShift,
346 BLEZL = ((2 << 3) + 6) << kOpcodeShift, 346 BLEZL = ((2U << 3) + 6) << kOpcodeShift,
347 BGTZL = ((2 << 3) + 7) << kOpcodeShift, 347 BGTZL = ((2U << 3) + 7) << kOpcodeShift,
348 348
349 DADDI = ((3 << 3) + 0) << kOpcodeShift, // This is also BNEC. 349 DADDI = ((3U << 3) + 0) << kOpcodeShift, // This is also BNEC.
350 SPECIAL2 = ((3 << 3) + 4) << kOpcodeShift, 350 SPECIAL2 = ((3U << 3) + 4) << kOpcodeShift,
351 SPECIAL3 = ((3 << 3) + 7) << kOpcodeShift, 351 SPECIAL3 = ((3U << 3) + 7) << kOpcodeShift,
352 352
353 LB = ((4 << 3) + 0) << kOpcodeShift, 353 LB = ((4U << 3) + 0) << kOpcodeShift,
354 LH = ((4 << 3) + 1) << kOpcodeShift, 354 LH = ((4U << 3) + 1) << kOpcodeShift,
355 LWL = ((4 << 3) + 2) << kOpcodeShift, 355 LWL = ((4U << 3) + 2) << kOpcodeShift,
356 LW = ((4 << 3) + 3) << kOpcodeShift, 356 LW = ((4U << 3) + 3) << kOpcodeShift,
357 LBU = ((4 << 3) + 4) << kOpcodeShift, 357 LBU = ((4U << 3) + 4) << kOpcodeShift,
358 LHU = ((4 << 3) + 5) << kOpcodeShift, 358 LHU = ((4U << 3) + 5) << kOpcodeShift,
359 LWR = ((4 << 3) + 6) << kOpcodeShift, 359 LWR = ((4U << 3) + 6) << kOpcodeShift,
360 SB = ((5 << 3) + 0) << kOpcodeShift, 360 SB = ((5U << 3) + 0) << kOpcodeShift,
361 SH = ((5 << 3) + 1) << kOpcodeShift, 361 SH = ((5U << 3) + 1) << kOpcodeShift,
362 SWL = ((5 << 3) + 2) << kOpcodeShift, 362 SWL = ((5U << 3) + 2) << kOpcodeShift,
363 SW = ((5 << 3) + 3) << kOpcodeShift, 363 SW = ((5U << 3) + 3) << kOpcodeShift,
364 SWR = ((5 << 3) + 6) << kOpcodeShift, 364 SWR = ((5U << 3) + 6) << kOpcodeShift,
365 365
366 LWC1 = ((6 << 3) + 1) << kOpcodeShift, 366 LWC1 = ((6U << 3) + 1) << kOpcodeShift,
367 BC = ((6 << 3) + 2) << kOpcodeShift, 367 BC = ((6U << 3) + 2) << kOpcodeShift,
368 LDC1 = ((6 << 3) + 5) << kOpcodeShift, 368 LDC1 = ((6U << 3) + 5) << kOpcodeShift,
369 POP66 = ((6 << 3) + 6) << kOpcodeShift, 369 POP66 = ((6U << 3) + 6) << kOpcodeShift, // beqzc, jic
370 370
371 PREF = ((6 << 3) + 3) << kOpcodeShift, 371 PREF = ((6U << 3) + 3) << kOpcodeShift,
372 372
373 SWC1 = ((7 << 3) + 1) << kOpcodeShift, 373 SWC1 = ((7U << 3) + 1) << kOpcodeShift,
374 BALC = ((7 << 3) + 2) << kOpcodeShift, 374 BALC = ((7U << 3) + 2) << kOpcodeShift,
375 PCREL = ((7 << 3) + 3) << kOpcodeShift, 375 PCREL = ((7U << 3) + 3) << kOpcodeShift,
376 SDC1 = ((7 << 3) + 5) << kOpcodeShift, 376 SDC1 = ((7U << 3) + 5) << kOpcodeShift,
377 POP76 = ((7 << 3) + 6) << kOpcodeShift, 377 POP76 = ((7U << 3) + 6) << kOpcodeShift, // bnezc, jialc
378 378
379 COP1X = ((1 << 4) + 3) << kOpcodeShift 379 COP1X = ((1U << 4) + 3) << kOpcodeShift,
380
381 // New r6 instruction.
382 POP06 = BLEZ, // bgeuc/bleuc, blezalc, bgezalc
383 POP07 = BGTZ, // bltuc/bgtuc, bgtzalc, bltzalc
384 POP10 = ADDI, // beqzalc, bovc, beqc
385 POP26 = BLEZL, // bgezc, blezc, bgec/blec
386 POP27 = BGTZL, // bgtzc, bltzc, bltc/bgtc
387 POP30 = DADDI, // bnezalc, bvnc, bnec
380 }; 388 };
381 389
382 enum SecondaryField { 390 enum SecondaryField : uint32_t {
383 // SPECIAL Encoding of Function Field. 391 // SPECIAL Encoding of Function Field.
384 SLL = ((0 << 3) + 0), 392 SLL = ((0U << 3) + 0),
385 MOVCI = ((0 << 3) + 1), 393 MOVCI = ((0U << 3) + 1),
386 SRL = ((0 << 3) + 2), 394 SRL = ((0U << 3) + 2),
387 SRA = ((0 << 3) + 3), 395 SRA = ((0U << 3) + 3),
388 SLLV = ((0 << 3) + 4), 396 SLLV = ((0U << 3) + 4),
389 SRLV = ((0 << 3) + 6), 397 SRLV = ((0U << 3) + 6),
390 SRAV = ((0 << 3) + 7), 398 SRAV = ((0U << 3) + 7),
391 399
392 JR = ((1 << 3) + 0), 400 JR = ((1U << 3) + 0),
393 JALR = ((1 << 3) + 1), 401 JALR = ((1U << 3) + 1),
394 MOVZ = ((1 << 3) + 2), 402 MOVZ = ((1U << 3) + 2),
395 MOVN = ((1 << 3) + 3), 403 MOVN = ((1U << 3) + 3),
396 BREAK = ((1 << 3) + 5), 404 BREAK = ((1U << 3) + 5),
397 405
398 MFHI = ((2 << 3) + 0), 406 MFHI = ((2U << 3) + 0),
399 CLZ_R6 = ((2 << 3) + 0), 407 CLZ_R6 = ((2U << 3) + 0),
400 CLO_R6 = ((2 << 3) + 1), 408 CLO_R6 = ((2U << 3) + 1),
401 MFLO = ((2 << 3) + 2), 409 MFLO = ((2U << 3) + 2),
402 410
403 MULT = ((3 << 3) + 0), 411 MULT = ((3U << 3) + 0),
404 MULTU = ((3 << 3) + 1), 412 MULTU = ((3U << 3) + 1),
405 DIV = ((3 << 3) + 2), 413 DIV = ((3U << 3) + 2),
406 DIVU = ((3 << 3) + 3), 414 DIVU = ((3U << 3) + 3),
407 415
408 ADD = ((4 << 3) + 0), 416 ADD = ((4U << 3) + 0),
409 ADDU = ((4 << 3) + 1), 417 ADDU = ((4U << 3) + 1),
410 SUB = ((4 << 3) + 2), 418 SUB = ((4U << 3) + 2),
411 SUBU = ((4 << 3) + 3), 419 SUBU = ((4U << 3) + 3),
412 AND = ((4 << 3) + 4), 420 AND = ((4U << 3) + 4),
413 OR = ((4 << 3) + 5), 421 OR = ((4U << 3) + 5),
414 XOR = ((4 << 3) + 6), 422 XOR = ((4U << 3) + 6),
415 NOR = ((4 << 3) + 7), 423 NOR = ((4U << 3) + 7),
416 424
417 SLT = ((5 << 3) + 2), 425 SLT = ((5U << 3) + 2),
418 SLTU = ((5 << 3) + 3), 426 SLTU = ((5U << 3) + 3),
419 427
420 TGE = ((6 << 3) + 0), 428 TGE = ((6U << 3) + 0),
421 TGEU = ((6 << 3) + 1), 429 TGEU = ((6U << 3) + 1),
422 TLT = ((6 << 3) + 2), 430 TLT = ((6U << 3) + 2),
423 TLTU = ((6 << 3) + 3), 431 TLTU = ((6U << 3) + 3),
424 TEQ = ((6 << 3) + 4), 432 TEQ = ((6U << 3) + 4),
425 SELEQZ_S = ((6 << 3) + 5), 433 SELEQZ_S = ((6U << 3) + 5),
426 TNE = ((6 << 3) + 6), 434 TNE = ((6U << 3) + 6),
427 SELNEZ_S = ((6 << 3) + 7), 435 SELNEZ_S = ((6U << 3) + 7),
428 436
429 // Multiply integers in r6. 437 // Multiply integers in r6.
430 MUL_MUH = ((3 << 3) + 0), // MUL, MUH. 438 MUL_MUH = ((3U << 3) + 0), // MUL, MUH.
431 MUL_MUH_U = ((3 << 3) + 1), // MUL_U, MUH_U. 439 MUL_MUH_U = ((3U << 3) + 1), // MUL_U, MUH_U.
432 RINT = ((3 << 3) + 2), 440 RINT = ((3U << 3) + 2),
433 441
434 MUL_OP = ((0 << 3) + 2), 442 MUL_OP = ((0U << 3) + 2),
435 MUH_OP = ((0 << 3) + 3), 443 MUH_OP = ((0U << 3) + 3),
436 DIV_OP = ((0 << 3) + 2), 444 DIV_OP = ((0U << 3) + 2),
437 MOD_OP = ((0 << 3) + 3), 445 MOD_OP = ((0U << 3) + 3),
438 446
439 DIV_MOD = ((3 << 3) + 2), 447 DIV_MOD = ((3U << 3) + 2),
440 DIV_MOD_U = ((3 << 3) + 3), 448 DIV_MOD_U = ((3U << 3) + 3),
441 449
442 // SPECIAL2 Encoding of Function Field. 450 // SPECIAL2 Encoding of Function Field.
443 MUL = ((0 << 3) + 2), 451 MUL = ((0U << 3) + 2),
444 CLZ = ((4 << 3) + 0), 452 CLZ = ((4U << 3) + 0),
445 CLO = ((4 << 3) + 1), 453 CLO = ((4U << 3) + 1),
446 454
447 // SPECIAL3 Encoding of Function Field. 455 // SPECIAL3 Encoding of Function Field.
448 EXT = ((0 << 3) + 0), 456 EXT = ((0U << 3) + 0),
449 INS = ((0 << 3) + 4), 457 INS = ((0U << 3) + 4),
450 BSHFL = ((4 << 3) + 0), 458 BSHFL = ((4U << 3) + 0),
451 459
452 // SPECIAL3 Encoding of sa Field. 460 // SPECIAL3 Encoding of sa Field.
453 BITSWAP = ((0 << 3) + 0), 461 BITSWAP = ((0U << 3) + 0),
454 ALIGN = ((0 << 3) + 2), 462 ALIGN = ((0U << 3) + 2),
455 WSBH = ((0 << 3) + 2), 463 WSBH = ((0U << 3) + 2),
456 SEB = ((2 << 3) + 0), 464 SEB = ((2U << 3) + 0),
457 SEH = ((3 << 3) + 0), 465 SEH = ((3U << 3) + 0),
458 466
459 // REGIMM encoding of rt Field. 467 // REGIMM encoding of rt Field.
460 BLTZ = ((0 << 3) + 0) << 16, 468 BLTZ = ((0U << 3) + 0) << 16,
461 BGEZ = ((0 << 3) + 1) << 16, 469 BGEZ = ((0U << 3) + 1) << 16,
462 BLTZAL = ((2 << 3) + 0) << 16, 470 BLTZAL = ((2U << 3) + 0) << 16,
463 BGEZAL = ((2 << 3) + 1) << 16, 471 BGEZAL = ((2U << 3) + 1) << 16,
464 BGEZALL = ((2 << 3) + 3) << 16, 472 BGEZALL = ((2U << 3) + 3) << 16,
465 473
466 // COP1 Encoding of rs Field. 474 // COP1 Encoding of rs Field.
467 MFC1 = ((0 << 3) + 0) << 21, 475 MFC1 = ((0U << 3) + 0) << 21,
468 CFC1 = ((0 << 3) + 2) << 21, 476 CFC1 = ((0U << 3) + 2) << 21,
469 MFHC1 = ((0 << 3) + 3) << 21, 477 MFHC1 = ((0U << 3) + 3) << 21,
470 MTC1 = ((0 << 3) + 4) << 21, 478 MTC1 = ((0U << 3) + 4) << 21,
471 CTC1 = ((0 << 3) + 6) << 21, 479 CTC1 = ((0U << 3) + 6) << 21,
472 MTHC1 = ((0 << 3) + 7) << 21, 480 MTHC1 = ((0U << 3) + 7) << 21,
473 BC1 = ((1 << 3) + 0) << 21, 481 BC1 = ((1U << 3) + 0) << 21,
474 S = ((2 << 3) + 0) << 21, 482 S = ((2U << 3) + 0) << 21,
475 D = ((2 << 3) + 1) << 21, 483 D = ((2U << 3) + 1) << 21,
476 W = ((2 << 3) + 4) << 21, 484 W = ((2U << 3) + 4) << 21,
477 L = ((2 << 3) + 5) << 21, 485 L = ((2U << 3) + 5) << 21,
478 PS = ((2 << 3) + 6) << 21, 486 PS = ((2U << 3) + 6) << 21,
479 // COP1 Encoding of Function Field When rs=S. 487 // COP1 Encoding of Function Field When rs=S.
480 488
481 ADD_S = ((0 << 3) + 0), 489 ADD_S = ((0U << 3) + 0),
482 SUB_S = ((0 << 3) + 1), 490 SUB_S = ((0U << 3) + 1),
483 MUL_S = ((0 << 3) + 2), 491 MUL_S = ((0U << 3) + 2),
484 DIV_S = ((0 << 3) + 3), 492 DIV_S = ((0U << 3) + 3),
485 ABS_S = ((0 << 3) + 5), 493 ABS_S = ((0U << 3) + 5),
486 SQRT_S = ((0 << 3) + 4), 494 SQRT_S = ((0U << 3) + 4),
487 MOV_S = ((0 << 3) + 6), 495 MOV_S = ((0U << 3) + 6),
488 NEG_S = ((0 << 3) + 7), 496 NEG_S = ((0U << 3) + 7),
489 ROUND_L_S = ((1 << 3) + 0), 497 ROUND_L_S = ((1U << 3) + 0),
490 TRUNC_L_S = ((1 << 3) + 1), 498 TRUNC_L_S = ((1U << 3) + 1),
491 CEIL_L_S = ((1 << 3) + 2), 499 CEIL_L_S = ((1U << 3) + 2),
492 FLOOR_L_S = ((1 << 3) + 3), 500 FLOOR_L_S = ((1U << 3) + 3),
493 ROUND_W_S = ((1 << 3) + 4), 501 ROUND_W_S = ((1U << 3) + 4),
494 TRUNC_W_S = ((1 << 3) + 5), 502 TRUNC_W_S = ((1U << 3) + 5),
495 CEIL_W_S = ((1 << 3) + 6), 503 CEIL_W_S = ((1U << 3) + 6),
496 FLOOR_W_S = ((1 << 3) + 7), 504 FLOOR_W_S = ((1U << 3) + 7),
497 RECIP_S = ((2 << 3) + 5), 505 RECIP_S = ((2U << 3) + 5),
498 RSQRT_S = ((2 << 3) + 6), 506 RSQRT_S = ((2U << 3) + 6),
499 CLASS_S = ((3 << 3) + 3), 507 CLASS_S = ((3U << 3) + 3),
500 CVT_D_S = ((4 << 3) + 1), 508 CVT_D_S = ((4U << 3) + 1),
501 CVT_W_S = ((4 << 3) + 4), 509 CVT_W_S = ((4U << 3) + 4),
502 CVT_L_S = ((4 << 3) + 5), 510 CVT_L_S = ((4U << 3) + 5),
503 CVT_PS_S = ((4 << 3) + 6), 511 CVT_PS_S = ((4U << 3) + 6),
504 512
505 // COP1 Encoding of Function Field When rs=D. 513 // COP1 Encoding of Function Field When rs=D.
506 ADD_D = ((0 << 3) + 0), 514 ADD_D = ((0U << 3) + 0),
507 SUB_D = ((0 << 3) + 1), 515 SUB_D = ((0U << 3) + 1),
508 MUL_D = ((0 << 3) + 2), 516 MUL_D = ((0U << 3) + 2),
509 DIV_D = ((0 << 3) + 3), 517 DIV_D = ((0U << 3) + 3),
510 SQRT_D = ((0 << 3) + 4), 518 SQRT_D = ((0U << 3) + 4),
511 ABS_D = ((0 << 3) + 5), 519 ABS_D = ((0U << 3) + 5),
512 MOV_D = ((0 << 3) + 6), 520 MOV_D = ((0U << 3) + 6),
513 NEG_D = ((0 << 3) + 7), 521 NEG_D = ((0U << 3) + 7),
514 ROUND_L_D = ((1 << 3) + 0), 522 ROUND_L_D = ((1U << 3) + 0),
515 TRUNC_L_D = ((1 << 3) + 1), 523 TRUNC_L_D = ((1U << 3) + 1),
516 CEIL_L_D = ((1 << 3) + 2), 524 CEIL_L_D = ((1U << 3) + 2),
517 FLOOR_L_D = ((1 << 3) + 3), 525 FLOOR_L_D = ((1U << 3) + 3),
518 ROUND_W_D = ((1 << 3) + 4), 526 ROUND_W_D = ((1U << 3) + 4),
519 TRUNC_W_D = ((1 << 3) + 5), 527 TRUNC_W_D = ((1U << 3) + 5),
520 CEIL_W_D = ((1 << 3) + 6), 528 CEIL_W_D = ((1U << 3) + 6),
521 FLOOR_W_D = ((1 << 3) + 7), 529 FLOOR_W_D = ((1U << 3) + 7),
522 RECIP_D = ((2 << 3) + 5), 530 RECIP_D = ((2U << 3) + 5),
523 RSQRT_D = ((2 << 3) + 6), 531 RSQRT_D = ((2U << 3) + 6),
524 CLASS_D = ((3 << 3) + 3), 532 CLASS_D = ((3U << 3) + 3),
525 MIN = ((3 << 3) + 4), 533 MIN = ((3U << 3) + 4),
526 MINA = ((3 << 3) + 5), 534 MINA = ((3U << 3) + 5),
527 MAX = ((3 << 3) + 6), 535 MAX = ((3U << 3) + 6),
528 MAXA = ((3 << 3) + 7), 536 MAXA = ((3U << 3) + 7),
529 CVT_S_D = ((4 << 3) + 0), 537 CVT_S_D = ((4U << 3) + 0),
530 CVT_W_D = ((4 << 3) + 4), 538 CVT_W_D = ((4U << 3) + 4),
531 CVT_L_D = ((4 << 3) + 5), 539 CVT_L_D = ((4U << 3) + 5),
532 C_F_D = ((6 << 3) + 0), 540 C_F_D = ((6U << 3) + 0),
533 C_UN_D = ((6 << 3) + 1), 541 C_UN_D = ((6U << 3) + 1),
534 C_EQ_D = ((6 << 3) + 2), 542 C_EQ_D = ((6U << 3) + 2),
535 C_UEQ_D = ((6 << 3) + 3), 543 C_UEQ_D = ((6U << 3) + 3),
536 C_OLT_D = ((6 << 3) + 4), 544 C_OLT_D = ((6U << 3) + 4),
537 C_ULT_D = ((6 << 3) + 5), 545 C_ULT_D = ((6U << 3) + 5),
538 C_OLE_D = ((6 << 3) + 6), 546 C_OLE_D = ((6U << 3) + 6),
539 C_ULE_D = ((6 << 3) + 7), 547 C_ULE_D = ((6U << 3) + 7),
540 548
541 // COP1 Encoding of Function Field When rs=W or L. 549 // COP1 Encoding of Function Field When rs=W or L.
542 CVT_S_W = ((4 << 3) + 0), 550 CVT_S_W = ((4U << 3) + 0),
543 CVT_D_W = ((4 << 3) + 1), 551 CVT_D_W = ((4U << 3) + 1),
544 CVT_S_L = ((4 << 3) + 0), 552 CVT_S_L = ((4U << 3) + 0),
545 CVT_D_L = ((4 << 3) + 1), 553 CVT_D_L = ((4U << 3) + 1),
546 BC1EQZ = ((2 << 2) + 1) << 21, 554 BC1EQZ = ((2U << 2) + 1) << 21,
547 BC1NEZ = ((3 << 2) + 1) << 21, 555 BC1NEZ = ((3U << 2) + 1) << 21,
548 // COP1 CMP positive predicates Bit 5..4 = 00. 556 // COP1 CMP positive predicates Bit 5..4 = 00.
549 CMP_AF = ((0 << 3) + 0), 557 CMP_AF = ((0U << 3) + 0),
550 CMP_UN = ((0 << 3) + 1), 558 CMP_UN = ((0U << 3) + 1),
551 CMP_EQ = ((0 << 3) + 2), 559 CMP_EQ = ((0U << 3) + 2),
552 CMP_UEQ = ((0 << 3) + 3), 560 CMP_UEQ = ((0U << 3) + 3),
553 CMP_LT = ((0 << 3) + 4), 561 CMP_LT = ((0U << 3) + 4),
554 CMP_ULT = ((0 << 3) + 5), 562 CMP_ULT = ((0U << 3) + 5),
555 CMP_LE = ((0 << 3) + 6), 563 CMP_LE = ((0U << 3) + 6),
556 CMP_ULE = ((0 << 3) + 7), 564 CMP_ULE = ((0U << 3) + 7),
557 CMP_SAF = ((1 << 3) + 0), 565 CMP_SAF = ((1U << 3) + 0),
558 CMP_SUN = ((1 << 3) + 1), 566 CMP_SUN = ((1U << 3) + 1),
559 CMP_SEQ = ((1 << 3) + 2), 567 CMP_SEQ = ((1U << 3) + 2),
560 CMP_SUEQ = ((1 << 3) + 3), 568 CMP_SUEQ = ((1U << 3) + 3),
561 CMP_SSLT = ((1 << 3) + 4), 569 CMP_SSLT = ((1U << 3) + 4),
562 CMP_SSULT = ((1 << 3) + 5), 570 CMP_SSULT = ((1U << 3) + 5),
563 CMP_SLE = ((1 << 3) + 6), 571 CMP_SLE = ((1U << 3) + 6),
564 CMP_SULE = ((1 << 3) + 7), 572 CMP_SULE = ((1U << 3) + 7),
565 // COP1 CMP negative predicates Bit 5..4 = 01. 573 // COP1 CMP negative predicates Bit 5..4 = 01.
566 CMP_AT = ((2 << 3) + 0), // Reserved, not implemented. 574 CMP_AT = ((2U << 3) + 0), // Reserved, not implemented.
567 CMP_OR = ((2 << 3) + 1), 575 CMP_OR = ((2U << 3) + 1),
568 CMP_UNE = ((2 << 3) + 2), 576 CMP_UNE = ((2U << 3) + 2),
569 CMP_NE = ((2 << 3) + 3), 577 CMP_NE = ((2U << 3) + 3),
570 CMP_UGE = ((2 << 3) + 4), // Reserved, not implemented. 578 CMP_UGE = ((2U << 3) + 4), // Reserved, not implemented.
571 CMP_OGE = ((2 << 3) + 5), // Reserved, not implemented. 579 CMP_OGE = ((2U << 3) + 5), // Reserved, not implemented.
572 CMP_UGT = ((2 << 3) + 6), // Reserved, not implemented. 580 CMP_UGT = ((2U << 3) + 6), // Reserved, not implemented.
573 CMP_OGT = ((2 << 3) + 7), // Reserved, not implemented. 581 CMP_OGT = ((2U << 3) + 7), // Reserved, not implemented.
574 CMP_SAT = ((3 << 3) + 0), // Reserved, not implemented. 582 CMP_SAT = ((3U << 3) + 0), // Reserved, not implemented.
575 CMP_SOR = ((3 << 3) + 1), 583 CMP_SOR = ((3U << 3) + 1),
576 CMP_SUNE = ((3 << 3) + 2), 584 CMP_SUNE = ((3U << 3) + 2),
577 CMP_SNE = ((3 << 3) + 3), 585 CMP_SNE = ((3U << 3) + 3),
578 CMP_SUGE = ((3 << 3) + 4), // Reserved, not implemented. 586 CMP_SUGE = ((3U << 3) + 4), // Reserved, not implemented.
579 CMP_SOGE = ((3 << 3) + 5), // Reserved, not implemented. 587 CMP_SOGE = ((3U << 3) + 5), // Reserved, not implemented.
580 CMP_SUGT = ((3 << 3) + 6), // Reserved, not implemented. 588 CMP_SUGT = ((3U << 3) + 6), // Reserved, not implemented.
581 CMP_SOGT = ((3 << 3) + 7), // Reserved, not implemented. 589 CMP_SOGT = ((3U << 3) + 7), // Reserved, not implemented.
582 590
583 SEL = ((2 << 3) + 0), 591 SEL = ((2U << 3) + 0),
584 MOVZ_C = ((2 << 3) + 2), 592 MOVZ_C = ((2U << 3) + 2),
585 MOVN_C = ((2 << 3) + 3), 593 MOVN_C = ((2U << 3) + 3),
586 SELEQZ_C = ((2 << 3) + 4), // COP1 on FPR registers. 594 SELEQZ_C = ((2U << 3) + 4), // COP1 on FPR registers.
587 MOVF = ((2 << 3) + 1), // Function field for MOVT.fmt and MOVF.fmt 595 MOVF = ((2U << 3) + 1), // Function field for MOVT.fmt and MOVF.fmt
588 SELNEZ_C = ((2 << 3) + 7), // COP1 on FPR registers. 596 SELNEZ_C = ((2U << 3) + 7), // COP1 on FPR registers.
589 // COP1 Encoding of Function Field When rs=PS. 597 // COP1 Encoding of Function Field When rs=PS.
590 // COP1X Encoding of Function Field. 598 // COP1X Encoding of Function Field.
591 MADD_D = ((4 << 3) + 1), 599 MADD_D = ((4U << 3) + 1),
592 600
593 // PCREL Encoding of rt Field. 601 // PCREL Encoding of rt Field.
594 ADDIUPC = ((0 << 2) + 0), 602 ADDIUPC = ((0U << 2) + 0),
595 LWPC = ((0 << 2) + 1), 603 LWPC = ((0U << 2) + 1),
596 AUIPC = ((3 << 3) + 6), 604 AUIPC = ((3U << 3) + 6),
597 ALUIPC = ((3 << 3) + 7), 605 ALUIPC = ((3U << 3) + 7),
598 606
599 // POP66 Encoding of rs Field. 607 // POP66 Encoding of rs Field.
600 JIC = ((0 << 5) + 0), 608 JIC = ((0U << 5) + 0),
601 609
602 // POP76 Encoding of rs Field. 610 // POP76 Encoding of rs Field.
603 JIALC = ((0 << 5) + 0), 611 JIALC = ((0U << 5) + 0),
604 612
605 NULLSF = 0 613 NULLSF = 0U
606 }; 614 };
607 615
608 616
609 // ----- Emulated conditions. 617 // ----- Emulated conditions.
610 // On MIPS we use this enum to abstract from conditional branch instructions. 618 // On MIPS we use this enum to abstract from conditional branch instructions.
611 // The 'U' prefix is used to specify unsigned comparisons. 619 // The 'U' prefix is used to specify unsigned comparisons.
612 // Opposite conditions must be paired as odd/even numbers 620 // Opposite conditions must be paired as odd/even numbers
613 // because 'NegateCondition' function flips LSB to negate condition. 621 // because 'NegateCondition' function flips LSB to negate condition.
614 enum Condition { 622 enum Condition {
615 // Any value < 0 is considered no_condition. 623 // Any value < 0 is considered no_condition.
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 extern const Instr kRtMask; 821 extern const Instr kRtMask;
814 extern const Instr kLwSwInstrTypeMask; 822 extern const Instr kLwSwInstrTypeMask;
815 extern const Instr kLwSwInstrArgumentMask; 823 extern const Instr kLwSwInstrArgumentMask;
816 extern const Instr kLwSwOffsetMask; 824 extern const Instr kLwSwOffsetMask;
817 825
818 // Break 0xfffff, reserved for redirected real time call. 826 // Break 0xfffff, reserved for redirected real time call.
819 const Instr rtCallRedirInstr = SPECIAL | BREAK | call_rt_redirected << 6; 827 const Instr rtCallRedirInstr = SPECIAL | BREAK | call_rt_redirected << 6;
820 // A nop instruction. (Encoding of sll 0 0 0). 828 // A nop instruction. (Encoding of sll 0 0 0).
821 const Instr nopInstr = 0; 829 const Instr nopInstr = 0;
822 830
831 static constexpr uint64_t OpcodeToBitNumber(Opcode opcode) {
832 return 1ULL << (static_cast<uint32_t>(opcode) >> kOpcodeShift);
833 }
834
823 835
824 class Instruction { 836 class Instruction {
825 public: 837 public:
826 enum { 838 enum {
827 kInstrSize = 4, 839 kInstrSize = 4,
828 kInstrSizeLog2 = 2, 840 kInstrSizeLog2 = 2,
829 // On MIPS PC cannot actually be directly accessed. We behave as if PC was 841 // On MIPS PC cannot actually be directly accessed. We behave as if PC was
830 // always the value of the current instruction being executed. 842 // always the value of the current instruction being executed.
831 kPCReadOffset = 0 843 kPCReadOffset = 0
832 }; 844 };
833 845
834 // Get the raw instruction bits. 846 // Get the raw instruction bits.
835 inline Instr InstructionBits() const { 847 inline Instr InstructionBits() const {
836 return *reinterpret_cast<const Instr*>(this); 848 return *reinterpret_cast<const Instr*>(this);
837 } 849 }
838 850
839 // Set the raw instruction bits to value. 851 // Set the raw instruction bits to value.
840 inline void SetInstructionBits(Instr value) { 852 inline void SetInstructionBits(Instr value) {
841 *reinterpret_cast<Instr*>(this) = value; 853 *reinterpret_cast<Instr*>(this) = value;
842 } 854 }
843 855
844 // Read one particular bit out of the instruction bits. 856 // Read one particular bit out of the instruction bits.
845 inline int Bit(int nr) const { 857 inline int Bit(int nr) const {
846 return (InstructionBits() >> nr) & 1; 858 return (InstructionBits() >> nr) & 1;
847 } 859 }
848 860
849 // Read a bit field out of the instruction bits. 861 // Read a bit field out of the instruction bits.
850 inline int Bits(int hi, int lo) const { 862 inline int Bits(int hi, int lo) const {
851 return (InstructionBits() >> lo) & ((2 << (hi - lo)) - 1); 863 return (InstructionBits() >> lo) & ((2U << (hi - lo)) - 1);
852 } 864 }
853 865
854 // Instruction type. 866 // Instruction type.
855 enum Type { 867 enum Type {
856 kRegisterType, 868 kRegisterType,
857 kImmediateType, 869 kImmediateType,
858 kJumpType, 870 kJumpType,
859 kUnsupported = -1 871 kUnsupported = -1
860 }; 872 };
861 873
862 enum TypeChecks { NORMAL, EXTRA }; 874 enum TypeChecks { NORMAL, EXTRA };
863 875
864 876
865 #define OpcodeToBitNumber(opcode) \ 877 static constexpr uint64_t kOpcodeImmediateTypeMask =
866 (1ULL << (static_cast<uint32_t>(opcode) >> kOpcodeShift))
867
868 static const uint64_t kOpcodeImmediateTypeMask =
869 OpcodeToBitNumber(REGIMM) | OpcodeToBitNumber(BEQ) | 878 OpcodeToBitNumber(REGIMM) | OpcodeToBitNumber(BEQ) |
870 OpcodeToBitNumber(BNE) | OpcodeToBitNumber(BLEZ) | 879 OpcodeToBitNumber(BNE) | OpcodeToBitNumber(BLEZ) |
871 OpcodeToBitNumber(BGTZ) | OpcodeToBitNumber(ADDI) | 880 OpcodeToBitNumber(BGTZ) | OpcodeToBitNumber(ADDI) |
872 OpcodeToBitNumber(DADDI) | OpcodeToBitNumber(ADDIU) | 881 OpcodeToBitNumber(DADDI) | OpcodeToBitNumber(ADDIU) |
873 OpcodeToBitNumber(SLTI) | OpcodeToBitNumber(SLTIU) | 882 OpcodeToBitNumber(SLTI) | OpcodeToBitNumber(SLTIU) |
874 OpcodeToBitNumber(ANDI) | OpcodeToBitNumber(ORI) | 883 OpcodeToBitNumber(ANDI) | OpcodeToBitNumber(ORI) |
875 OpcodeToBitNumber(XORI) | OpcodeToBitNumber(LUI) | 884 OpcodeToBitNumber(XORI) | OpcodeToBitNumber(LUI) |
876 OpcodeToBitNumber(BEQL) | OpcodeToBitNumber(BNEL) | 885 OpcodeToBitNumber(BEQL) | OpcodeToBitNumber(BNEL) |
877 OpcodeToBitNumber(BLEZL) | OpcodeToBitNumber(BGTZL) | 886 OpcodeToBitNumber(BLEZL) | OpcodeToBitNumber(BGTZL) |
878 OpcodeToBitNumber(POP66) | OpcodeToBitNumber(POP76) | 887 OpcodeToBitNumber(POP66) | OpcodeToBitNumber(POP76) |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 return FunctionValue(); 1034 return FunctionValue();
1026 case COP1: 1035 case COP1:
1027 return RsValue(); 1036 return RsValue();
1028 case REGIMM: 1037 case REGIMM:
1029 return RtValue(); 1038 return RtValue();
1030 default: 1039 default:
1031 return NULLSF; 1040 return NULLSF;
1032 } 1041 }
1033 } 1042 }
1034 1043
1044 inline int32_t ImmValue(int bits) const {
1045 DCHECK(InstructionType() == kImmediateType);
1046 return Bits(bits - 1, 0);
1047 }
1048
1035 inline int32_t Imm16Value() const { 1049 inline int32_t Imm16Value() const {
1036 DCHECK(InstructionType() == kImmediateType); 1050 DCHECK(InstructionType() == kImmediateType);
1037 return Bits(kImm16Shift + kImm16Bits - 1, kImm16Shift); 1051 return Bits(kImm16Shift + kImm16Bits - 1, kImm16Shift);
1038 } 1052 }
1039 1053
1040 inline int32_t Imm18Value() const { 1054 inline int32_t Imm18Value() const {
1041 DCHECK(InstructionType() == kImmediateType); 1055 DCHECK(InstructionType() == kImmediateType);
1042 return Bits(kImm18Shift + kImm18Bits - 1, kImm18Shift); 1056 return Bits(kImm18Shift + kImm18Bits - 1, kImm18Shift);
1043 } 1057 }
1044 1058
1045 inline int32_t Imm19Value() const { 1059 inline int32_t Imm19Value() const {
1046 DCHECK(InstructionType() == kImmediateType); 1060 DCHECK(InstructionType() == kImmediateType);
1047 return Bits(kImm19Shift + kImm19Bits - 1, kImm19Shift); 1061 return Bits(kImm19Shift + kImm19Bits - 1, kImm19Shift);
1048 } 1062 }
1049 1063
1050 inline int32_t Imm21Value() const { 1064 inline int32_t Imm21Value() const {
1051 DCHECK(InstructionType() == kImmediateType); 1065 DCHECK(InstructionType() == kImmediateType);
1052 return Bits(kImm21Shift + kImm21Bits - 1, kImm21Shift); 1066 return Bits(kImm21Shift + kImm21Bits - 1, kImm21Shift);
1053 } 1067 }
1054 1068
1055 inline int32_t Imm26Value() const { 1069 inline int32_t Imm26Value() const {
1056 DCHECK((InstructionType() == kJumpType) || 1070 DCHECK((InstructionType() == kJumpType) ||
1057 (InstructionType() == kImmediateType)); 1071 (InstructionType() == kImmediateType));
1058 return Bits(kImm26Shift + kImm26Bits - 1, kImm26Shift); 1072 return Bits(kImm26Shift + kImm26Bits - 1, kImm26Shift);
1059 } 1073 }
1060 1074
1061 // Say if the instruction should not be used in a branch delay slot. 1075 static bool IsForbiddenAfterBranchInstr(Instr instr);
1062 bool IsForbiddenInBranchDelay() const; 1076
1077 // Say if the instruction should not be used in a branch delay slot or
1078 // immediately after a compact branch.
1079 inline bool IsForbiddenAfterBranch() const {
1080 return IsForbiddenAfterBranchInstr(InstructionBits());
1081 }
1082
1083 inline bool IsForbiddenInBranchDelay() const {
1084 return IsForbiddenAfterBranch();
1085 }
1086
1063 // Say if the instruction 'links'. e.g. jal, bal. 1087 // Say if the instruction 'links'. e.g. jal, bal.
1064 bool IsLinkingInstruction() const; 1088 bool IsLinkingInstruction() const;
1065 // Say if the instruction is a break or a trap. 1089 // Say if the instruction is a break or a trap.
1066 bool IsTrap() const; 1090 bool IsTrap() const;
1067 1091
1068 // Instructions are read of out a code stream. The only way to get a 1092 // Instructions are read of out a code stream. The only way to get a
1069 // reference to an instruction is to convert a pointer. There is no way 1093 // reference to an instruction is to convert a pointer. There is no way
1070 // to allocate or create instances of class Instruction. 1094 // to allocate or create instances of class Instruction.
1071 // Use the At(pc) function to create references to Instruction. 1095 // Use the At(pc) function to create references to Instruction.
1072 static Instruction* At(byte* pc) { 1096 static Instruction* At(byte* pc) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 } 1199 }
1176 } 1200 }
1177 } 1201 }
1178 1202
1179 #undef OpcodeToBitNumber 1203 #undef OpcodeToBitNumber
1180 #undef FunctionFieldToBitNumber 1204 #undef FunctionFieldToBitNumber
1181 } // namespace internal 1205 } // namespace internal
1182 } // namespace v8 1206 } // namespace v8
1183 1207
1184 #endif // #ifndef V8_MIPS_CONSTANTS_H_ 1208 #endif // #ifndef V8_MIPS_CONSTANTS_H_
OLDNEW
« no previous file with comments | « src/mips/assembler-mips-inl.h ('k') | src/mips/constants-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698