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 // UNIMPLEMENTED_ macro for MIPS. | 8 // UNIMPLEMENTED_ macro for MIPS. |
9 #ifdef DEBUG | 9 #ifdef DEBUG |
10 #define UNIMPLEMENTED_MIPS() \ | 10 #define UNIMPLEMENTED_MIPS() \ |
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 | 621 |
622 cc_default = kNoCondition | 622 cc_default = kNoCondition |
623 }; | 623 }; |
624 | 624 |
625 | 625 |
626 // Returns the equivalent of !cc. | 626 // Returns the equivalent of !cc. |
627 // Negation of the default kNoCondition (-1) results in a non-default | 627 // Negation of the default kNoCondition (-1) results in a non-default |
628 // no_condition value (-2). As long as tests for no_condition check | 628 // no_condition value (-2). As long as tests for no_condition check |
629 // for condition < 0, this will work as expected. | 629 // for condition < 0, this will work as expected. |
630 inline Condition NegateCondition(Condition cc) { | 630 inline Condition NegateCondition(Condition cc) { |
631 ASSERT(cc != cc_always); | 631 DCHECK(cc != cc_always); |
632 return static_cast<Condition>(cc ^ 1); | 632 return static_cast<Condition>(cc ^ 1); |
633 } | 633 } |
634 | 634 |
635 | 635 |
636 // Commute a condition such that {a cond b == b cond' a}. | 636 // Commute a condition such that {a cond b == b cond' a}. |
637 inline Condition CommuteCondition(Condition cc) { | 637 inline Condition CommuteCondition(Condition cc) { |
638 switch (cc) { | 638 switch (cc) { |
639 case Uless: | 639 case Uless: |
640 return Ugreater; | 640 return Ugreater; |
641 case Ugreater: | 641 case Ugreater: |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 Type InstructionType() const; | 782 Type InstructionType() const; |
783 | 783 |
784 | 784 |
785 // Accessors for the different named fields used in the MIPS encoding. | 785 // Accessors for the different named fields used in the MIPS encoding. |
786 inline Opcode OpcodeValue() const { | 786 inline Opcode OpcodeValue() const { |
787 return static_cast<Opcode>( | 787 return static_cast<Opcode>( |
788 Bits(kOpcodeShift + kOpcodeBits - 1, kOpcodeShift)); | 788 Bits(kOpcodeShift + kOpcodeBits - 1, kOpcodeShift)); |
789 } | 789 } |
790 | 790 |
791 inline int RsValue() const { | 791 inline int RsValue() const { |
792 ASSERT(InstructionType() == kRegisterType || | 792 DCHECK(InstructionType() == kRegisterType || |
793 InstructionType() == kImmediateType); | 793 InstructionType() == kImmediateType); |
794 return Bits(kRsShift + kRsBits - 1, kRsShift); | 794 return Bits(kRsShift + kRsBits - 1, kRsShift); |
795 } | 795 } |
796 | 796 |
797 inline int RtValue() const { | 797 inline int RtValue() const { |
798 ASSERT(InstructionType() == kRegisterType || | 798 DCHECK(InstructionType() == kRegisterType || |
799 InstructionType() == kImmediateType); | 799 InstructionType() == kImmediateType); |
800 return Bits(kRtShift + kRtBits - 1, kRtShift); | 800 return Bits(kRtShift + kRtBits - 1, kRtShift); |
801 } | 801 } |
802 | 802 |
803 inline int RdValue() const { | 803 inline int RdValue() const { |
804 ASSERT(InstructionType() == kRegisterType); | 804 DCHECK(InstructionType() == kRegisterType); |
805 return Bits(kRdShift + kRdBits - 1, kRdShift); | 805 return Bits(kRdShift + kRdBits - 1, kRdShift); |
806 } | 806 } |
807 | 807 |
808 inline int SaValue() const { | 808 inline int SaValue() const { |
809 ASSERT(InstructionType() == kRegisterType); | 809 DCHECK(InstructionType() == kRegisterType); |
810 return Bits(kSaShift + kSaBits - 1, kSaShift); | 810 return Bits(kSaShift + kSaBits - 1, kSaShift); |
811 } | 811 } |
812 | 812 |
813 inline int FunctionValue() const { | 813 inline int FunctionValue() const { |
814 ASSERT(InstructionType() == kRegisterType || | 814 DCHECK(InstructionType() == kRegisterType || |
815 InstructionType() == kImmediateType); | 815 InstructionType() == kImmediateType); |
816 return Bits(kFunctionShift + kFunctionBits - 1, kFunctionShift); | 816 return Bits(kFunctionShift + kFunctionBits - 1, kFunctionShift); |
817 } | 817 } |
818 | 818 |
819 inline int FdValue() const { | 819 inline int FdValue() const { |
820 return Bits(kFdShift + kFdBits - 1, kFdShift); | 820 return Bits(kFdShift + kFdBits - 1, kFdShift); |
821 } | 821 } |
822 | 822 |
823 inline int FsValue() const { | 823 inline int FsValue() const { |
824 return Bits(kFsShift + kFsBits - 1, kFsShift); | 824 return Bits(kFsShift + kFsBits - 1, kFsShift); |
(...skipping 21 matching lines...) Expand all Loading... |
846 inline int FBtrueValue() const { | 846 inline int FBtrueValue() const { |
847 return Bits(kFBtrueShift + kFBtrueBits - 1, kFBtrueShift); | 847 return Bits(kFBtrueShift + kFBtrueBits - 1, kFBtrueShift); |
848 } | 848 } |
849 | 849 |
850 // Return the fields at their original place in the instruction encoding. | 850 // Return the fields at their original place in the instruction encoding. |
851 inline Opcode OpcodeFieldRaw() const { | 851 inline Opcode OpcodeFieldRaw() const { |
852 return static_cast<Opcode>(InstructionBits() & kOpcodeMask); | 852 return static_cast<Opcode>(InstructionBits() & kOpcodeMask); |
853 } | 853 } |
854 | 854 |
855 inline int RsFieldRaw() const { | 855 inline int RsFieldRaw() const { |
856 ASSERT(InstructionType() == kRegisterType || | 856 DCHECK(InstructionType() == kRegisterType || |
857 InstructionType() == kImmediateType); | 857 InstructionType() == kImmediateType); |
858 return InstructionBits() & kRsFieldMask; | 858 return InstructionBits() & kRsFieldMask; |
859 } | 859 } |
860 | 860 |
861 // Same as above function, but safe to call within InstructionType(). | 861 // Same as above function, but safe to call within InstructionType(). |
862 inline int RsFieldRawNoAssert() const { | 862 inline int RsFieldRawNoAssert() const { |
863 return InstructionBits() & kRsFieldMask; | 863 return InstructionBits() & kRsFieldMask; |
864 } | 864 } |
865 | 865 |
866 inline int RtFieldRaw() const { | 866 inline int RtFieldRaw() const { |
867 ASSERT(InstructionType() == kRegisterType || | 867 DCHECK(InstructionType() == kRegisterType || |
868 InstructionType() == kImmediateType); | 868 InstructionType() == kImmediateType); |
869 return InstructionBits() & kRtFieldMask; | 869 return InstructionBits() & kRtFieldMask; |
870 } | 870 } |
871 | 871 |
872 inline int RdFieldRaw() const { | 872 inline int RdFieldRaw() const { |
873 ASSERT(InstructionType() == kRegisterType); | 873 DCHECK(InstructionType() == kRegisterType); |
874 return InstructionBits() & kRdFieldMask; | 874 return InstructionBits() & kRdFieldMask; |
875 } | 875 } |
876 | 876 |
877 inline int SaFieldRaw() const { | 877 inline int SaFieldRaw() const { |
878 ASSERT(InstructionType() == kRegisterType); | 878 DCHECK(InstructionType() == kRegisterType); |
879 return InstructionBits() & kSaFieldMask; | 879 return InstructionBits() & kSaFieldMask; |
880 } | 880 } |
881 | 881 |
882 inline int FunctionFieldRaw() const { | 882 inline int FunctionFieldRaw() const { |
883 return InstructionBits() & kFunctionFieldMask; | 883 return InstructionBits() & kFunctionFieldMask; |
884 } | 884 } |
885 | 885 |
886 // Get the secondary field according to the opcode. | 886 // Get the secondary field according to the opcode. |
887 inline int SecondaryValue() const { | 887 inline int SecondaryValue() const { |
888 Opcode op = OpcodeFieldRaw(); | 888 Opcode op = OpcodeFieldRaw(); |
889 switch (op) { | 889 switch (op) { |
890 case SPECIAL: | 890 case SPECIAL: |
891 case SPECIAL2: | 891 case SPECIAL2: |
892 return FunctionValue(); | 892 return FunctionValue(); |
893 case COP1: | 893 case COP1: |
894 return RsValue(); | 894 return RsValue(); |
895 case REGIMM: | 895 case REGIMM: |
896 return RtValue(); | 896 return RtValue(); |
897 default: | 897 default: |
898 return NULLSF; | 898 return NULLSF; |
899 } | 899 } |
900 } | 900 } |
901 | 901 |
902 inline int32_t Imm16Value() const { | 902 inline int32_t Imm16Value() const { |
903 ASSERT(InstructionType() == kImmediateType); | 903 DCHECK(InstructionType() == kImmediateType); |
904 return Bits(kImm16Shift + kImm16Bits - 1, kImm16Shift); | 904 return Bits(kImm16Shift + kImm16Bits - 1, kImm16Shift); |
905 } | 905 } |
906 | 906 |
907 inline int32_t Imm21Value() const { | 907 inline int32_t Imm21Value() const { |
908 ASSERT(InstructionType() == kImmediateType); | 908 DCHECK(InstructionType() == kImmediateType); |
909 return Bits(kImm21Shift + kImm21Bits - 1, kImm21Shift); | 909 return Bits(kImm21Shift + kImm21Bits - 1, kImm21Shift); |
910 } | 910 } |
911 | 911 |
912 inline int32_t Imm26Value() const { | 912 inline int32_t Imm26Value() const { |
913 ASSERT(InstructionType() == kJumpType); | 913 DCHECK(InstructionType() == kJumpType); |
914 return Bits(kImm26Shift + kImm26Bits - 1, kImm26Shift); | 914 return Bits(kImm26Shift + kImm26Bits - 1, kImm26Shift); |
915 } | 915 } |
916 | 916 |
917 // Say if the instruction should not be used in a branch delay slot. | 917 // Say if the instruction should not be used in a branch delay slot. |
918 bool IsForbiddenInBranchDelay() const; | 918 bool IsForbiddenInBranchDelay() const; |
919 // Say if the instruction 'links'. e.g. jal, bal. | 919 // Say if the instruction 'links'. e.g. jal, bal. |
920 bool IsLinkingInstruction() const; | 920 bool IsLinkingInstruction() const; |
921 // Say if the instruction is a break or a trap. | 921 // Say if the instruction is a break or a trap. |
922 bool IsTrap() const; | 922 bool IsTrap() const; |
923 | 923 |
(...skipping 19 matching lines...) Expand all Loading... |
943 | 943 |
944 // TODO(plind): below should be based on kPointerSize | 944 // TODO(plind): below should be based on kPointerSize |
945 // TODO(plind): find all usages and remove the needless instructions for n64. | 945 // TODO(plind): find all usages and remove the needless instructions for n64. |
946 const int kCArgsSlotsSize = kCArgSlotCount * Instruction::kInstrSize * 2; | 946 const int kCArgsSlotsSize = kCArgSlotCount * Instruction::kInstrSize * 2; |
947 | 947 |
948 const int kBranchReturnOffset = 2 * Instruction::kInstrSize; | 948 const int kBranchReturnOffset = 2 * Instruction::kInstrSize; |
949 | 949 |
950 } } // namespace v8::internal | 950 } } // namespace v8::internal |
951 | 951 |
952 #endif // #ifndef V8_MIPS_CONSTANTS_H_ | 952 #endif // #ifndef V8_MIPS_CONSTANTS_H_ |
OLD | NEW |