OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_CONSTANTS_ARM64_H_ | 5 #ifndef VM_CONSTANTS_ARM64_H_ |
6 #define VM_CONSTANTS_ARM64_H_ | 6 #define VM_CONSTANTS_ARM64_H_ |
7 | 7 |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 | 9 |
10 namespace dart { | 10 namespace dart { |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 kImm9Shift = 12, | 492 kImm9Shift = 12, |
493 kImm9Bits = 9, | 493 kImm9Bits = 9, |
494 kImm12Shift = 10, | 494 kImm12Shift = 10, |
495 kImm12Bits = 12, | 495 kImm12Bits = 12, |
496 kImm12ShiftShift = 22, | 496 kImm12ShiftShift = 22, |
497 kImm12ShiftBits = 2, | 497 kImm12ShiftBits = 2, |
498 kImm14Shift = 5, | 498 kImm14Shift = 5, |
499 kImm14Bits = 14, | 499 kImm14Bits = 14, |
500 kImm16Shift = 5, | 500 kImm16Shift = 5, |
501 kImm16Bits = 16, | 501 kImm16Bits = 16, |
| 502 kImm16Mask = 0xffff << kImm16Shift, |
502 kImm19Shift = 5, | 503 kImm19Shift = 5, |
503 kImm19Bits = 19, | 504 kImm19Bits = 19, |
504 kImm19Mask = 0x7ffff, | 505 kImm19Mask = 0x7ffff << kImm19Shift, |
505 kImm26Shift = 0, | 506 kImm26Shift = 0, |
506 kImm26Bits = 26, | 507 kImm26Bits = 26, |
507 | 508 |
508 kCondShift = 0, | 509 kCondShift = 0, |
509 kCondBits = 4, | 510 kCondBits = 4, |
510 | 511 |
511 // Bitfield immediates. | 512 // Bitfield immediates. |
512 kNShift = 22, | 513 kNShift = 22, |
513 kNBits = 1, | 514 kNBits = 1, |
514 kImmRShift = 16, | 515 kImmRShift = 16, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 kInstrSize = 4, | 579 kInstrSize = 4, |
579 kInstrSizeLog2 = 2, | 580 kInstrSizeLog2 = 2, |
580 kPCReadOffset = 8 | 581 kPCReadOffset = 8 |
581 }; | 582 }; |
582 | 583 |
583 static const int32_t kNopInstruction = HINT; // hint #0 === nop. | 584 static const int32_t kNopInstruction = HINT; // hint #0 === nop. |
584 static const int32_t kBreakPointInstruction = // hlt #kImmExceptionIsDebug. | 585 static const int32_t kBreakPointInstruction = // hlt #kImmExceptionIsDebug. |
585 HLT | (kImmExceptionIsDebug << kImm16Shift); | 586 HLT | (kImmExceptionIsDebug << kImm16Shift); |
586 static const int kBreakPointInstructionSize = kInstrSize; | 587 static const int kBreakPointInstructionSize = kInstrSize; |
587 | 588 |
| 589 // Read one particular bit out of the instruction bits. |
| 590 inline int Bit(int nr) const { |
| 591 return (InstructionBits() >> nr) & 1; |
| 592 } |
| 593 |
| 594 // Read a bit field out of the instruction bits. |
| 595 inline int Bits(int shift, int count) const { |
| 596 return (InstructionBits() >> shift) & ((1 << count) - 1); |
| 597 } |
| 598 |
588 // Get the raw instruction bits. | 599 // Get the raw instruction bits. |
589 inline int32_t InstructionBits() const { | 600 inline int32_t InstructionBits() const { |
590 return *reinterpret_cast<const int32_t*>(this); | 601 return *reinterpret_cast<const int32_t*>(this); |
591 } | 602 } |
592 | 603 |
593 // Set the raw instruction bits to value. | 604 // Set the raw instruction bits to value. |
594 inline void SetInstructionBits(int32_t value) { | 605 inline void SetInstructionBits(int32_t value) { |
595 *reinterpret_cast<int32_t*>(this) = value; | 606 *reinterpret_cast<int32_t*>(this) = value; |
596 } | 607 } |
597 | 608 |
598 // Read one particular bit out of the instruction bits. | 609 inline void SetMoveWideBits( |
599 inline int Bit(int nr) const { | 610 MoveWideOp op, Register rd, uint16_t imm, int hw, OperandSize sz) { |
600 return (InstructionBits() >> nr) & 1; | 611 ASSERT((hw >= 0) && (hw <= 3)); |
| 612 ASSERT((sz == kDoubleWord) || (sz == kWord)); |
| 613 const int32_t size = (sz == kDoubleWord) ? B31 : 0; |
| 614 SetInstructionBits( |
| 615 op | size | |
| 616 (static_cast<int32_t>(rd) << kRdShift) | |
| 617 (static_cast<int32_t>(hw) << kHWShift) | |
| 618 (static_cast<int32_t>(imm) << kImm16Shift)); |
601 } | 619 } |
602 | 620 |
603 // Read a bit field out of the instruction bits. | 621 inline void SetUnconditionalBranchRegBits( |
604 inline int Bits(int shift, int count) const { | 622 UnconditionalBranchRegOp op, Register rn) { |
605 return (InstructionBits() >> shift) & ((1 << count) - 1); | 623 SetInstructionBits( |
| 624 op | |
| 625 (static_cast<int32_t>(rn) << kRnShift)); |
606 } | 626 } |
607 | 627 |
608 inline int NField() const { return Bit(22); } | 628 inline int NField() const { return Bit(22); } |
609 inline int SField() const { return Bit(kSShift); } | 629 inline int SField() const { return Bit(kSShift); } |
610 inline int SFField() const { return Bit(kSFShift); } | 630 inline int SFField() const { return Bit(kSFShift); } |
611 inline int SzField() const { return Bits(kSzShift, kSzBits); } | 631 inline int SzField() const { return Bits(kSzShift, kSzBits); } |
612 inline Register RdField() const { return static_cast<Register>( | 632 inline Register RdField() const { return static_cast<Register>( |
613 Bits(kRdShift, kRdBits)); } | 633 Bits(kRdShift, kRdBits)); } |
614 inline Register RnField() const { return static_cast<Register>( | 634 inline Register RnField() const { return static_cast<Register>( |
615 Bits(kRnShift, kRnBits)); } | 635 Bits(kRnShift, kRnBits)); } |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 static Instr* At(uword pc) { return reinterpret_cast<Instr*>(pc); } | 791 static Instr* At(uword pc) { return reinterpret_cast<Instr*>(pc); } |
772 | 792 |
773 private: | 793 private: |
774 DISALLOW_ALLOCATION(); | 794 DISALLOW_ALLOCATION(); |
775 DISALLOW_IMPLICIT_CONSTRUCTORS(Instr); | 795 DISALLOW_IMPLICIT_CONSTRUCTORS(Instr); |
776 }; | 796 }; |
777 | 797 |
778 } // namespace dart | 798 } // namespace dart |
779 | 799 |
780 #endif // VM_CONSTANTS_ARM64_H_ | 800 #endif // VM_CONSTANTS_ARM64_H_ |
OLD | NEW |