OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 static const int kFunctionBits = 6; | 197 static const int kFunctionBits = 6; |
198 static const int kLuiShift = 16; | 198 static const int kLuiShift = 16; |
199 | 199 |
200 static const int kImm16Shift = 0; | 200 static const int kImm16Shift = 0; |
201 static const int kImm16Bits = 16; | 201 static const int kImm16Bits = 16; |
202 static const int kImm26Shift = 0; | 202 static const int kImm26Shift = 0; |
203 static const int kImm26Bits = 26; | 203 static const int kImm26Bits = 26; |
204 static const int kImm28Shift = 0; | 204 static const int kImm28Shift = 0; |
205 static const int kImm28Bits = 28; | 205 static const int kImm28Bits = 28; |
206 | 206 |
| 207 // In branches and jumps immediate fields point to words, not bytes, |
| 208 // and are therefore shifted by 2. |
| 209 static const int kImmFieldShift = 2; |
| 210 |
207 static const int kFsShift = 11; | 211 static const int kFsShift = 11; |
208 static const int kFsBits = 5; | 212 static const int kFsBits = 5; |
209 static const int kFtShift = 16; | 213 static const int kFtShift = 16; |
210 static const int kFtBits = 5; | 214 static const int kFtBits = 5; |
211 static const int kFdShift = 6; | 215 static const int kFdShift = 6; |
212 static const int kFdBits = 5; | 216 static const int kFdBits = 5; |
213 static const int kFCccShift = 8; | 217 static const int kFCccShift = 8; |
214 static const int kFCccBits = 3; | 218 static const int kFCccBits = 3; |
215 static const int kFBccShift = 18; | 219 static const int kFBccShift = 18; |
216 static const int kFBccBits = 3; | 220 static const int kFBccBits = 3; |
217 static const int kFBtrueShift = 16; | 221 static const int kFBtrueShift = 16; |
218 static const int kFBtrueBits = 1; | 222 static const int kFBtrueBits = 1; |
219 | 223 |
220 // ----- Miscellaneous useful masks. | 224 // ----- Miscellaneous useful masks. |
221 // Instruction bit masks. | 225 // Instruction bit masks. |
222 static const int kOpcodeMask = ((1 << kOpcodeBits) - 1) << kOpcodeShift; | 226 static const int kOpcodeMask = ((1 << kOpcodeBits) - 1) << kOpcodeShift; |
223 static const int kImm16Mask = ((1 << kImm16Bits) - 1) << kImm16Shift; | 227 static const int kImm16Mask = ((1 << kImm16Bits) - 1) << kImm16Shift; |
224 static const int kImm26Mask = ((1 << kImm26Bits) - 1) << kImm26Shift; | 228 static const int kImm26Mask = ((1 << kImm26Bits) - 1) << kImm26Shift; |
225 static const int kImm28Mask = ((1 << kImm28Bits) - 1) << kImm28Shift; | 229 static const int kImm28Mask = ((1 << kImm28Bits) - 1) << kImm28Shift; |
226 static const int kRsFieldMask = ((1 << kRsBits) - 1) << kRsShift; | 230 static const int kRsFieldMask = ((1 << kRsBits) - 1) << kRsShift; |
227 static const int kRtFieldMask = ((1 << kRtBits) - 1) << kRtShift; | 231 static const int kRtFieldMask = ((1 << kRtBits) - 1) << kRtShift; |
228 static const int kRdFieldMask = ((1 << kRdBits) - 1) << kRdShift; | 232 static const int kRdFieldMask = ((1 << kRdBits) - 1) << kRdShift; |
229 static const int kSaFieldMask = ((1 << kSaBits) - 1) << kSaShift; | 233 static const int kSaFieldMask = ((1 << kSaBits) - 1) << kSaShift; |
230 static const int kFunctionFieldMask = | 234 static const int kFunctionFieldMask = |
231 ((1 << kFunctionBits) - 1) << kFunctionShift; | 235 ((1 << kFunctionBits) - 1) << kFunctionShift; |
232 // Misc masks. | 236 // Misc masks. |
233 static const int kHiMask = 0xffff << 16; | 237 static const int kHiMask = 0xffff << 16; |
234 static const int kLoMask = 0xffff; | 238 static const int kLoMask = 0xffff; |
235 static const int kSignMask = 0x80000000; | 239 static const int kSignMask = 0x80000000; |
236 | 240 static const int kJumpAddrMask = (1 << (kImm26Bits + kImmFieldShift)) - 1; |
237 | 241 |
238 // ----- MIPS Opcodes and Function Fields. | 242 // ----- MIPS Opcodes and Function Fields. |
239 // We use this presentation to stay close to the table representation in | 243 // We use this presentation to stay close to the table representation in |
240 // MIPS32 Architecture For Programmers, Volume II: The MIPS32 Instruction Set. | 244 // MIPS32 Architecture For Programmers, Volume II: The MIPS32 Instruction Set. |
241 enum Opcode { | 245 enum Opcode { |
242 SPECIAL = 0 << kOpcodeShift, | 246 SPECIAL = 0 << kOpcodeShift, |
243 REGIMM = 1 << kOpcodeShift, | 247 REGIMM = 1 << kOpcodeShift, |
244 | 248 |
245 J = ((0 << 3) + 2) << kOpcodeShift, | 249 J = ((0 << 3) + 2) << kOpcodeShift, |
246 JAL = ((0 << 3) + 3) << kOpcodeShift, | 250 JAL = ((0 << 3) + 3) << kOpcodeShift, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 LWC1 = ((6 << 3) + 1) << kOpcodeShift, | 287 LWC1 = ((6 << 3) + 1) << kOpcodeShift, |
284 LDC1 = ((6 << 3) + 5) << kOpcodeShift, | 288 LDC1 = ((6 << 3) + 5) << kOpcodeShift, |
285 | 289 |
286 SWC1 = ((7 << 3) + 1) << kOpcodeShift, | 290 SWC1 = ((7 << 3) + 1) << kOpcodeShift, |
287 SDC1 = ((7 << 3) + 5) << kOpcodeShift | 291 SDC1 = ((7 << 3) + 5) << kOpcodeShift |
288 }; | 292 }; |
289 | 293 |
290 enum SecondaryField { | 294 enum SecondaryField { |
291 // SPECIAL Encoding of Function Field. | 295 // SPECIAL Encoding of Function Field. |
292 SLL = ((0 << 3) + 0), | 296 SLL = ((0 << 3) + 0), |
| 297 MOVCI = ((0 << 3) + 1), |
293 SRL = ((0 << 3) + 2), | 298 SRL = ((0 << 3) + 2), |
294 SRA = ((0 << 3) + 3), | 299 SRA = ((0 << 3) + 3), |
295 SLLV = ((0 << 3) + 4), | 300 SLLV = ((0 << 3) + 4), |
296 SRLV = ((0 << 3) + 6), | 301 SRLV = ((0 << 3) + 6), |
297 SRAV = ((0 << 3) + 7), | 302 SRAV = ((0 << 3) + 7), |
298 MOVCI = ((0 << 3) + 1), | |
299 | 303 |
300 JR = ((1 << 3) + 0), | 304 JR = ((1 << 3) + 0), |
301 JALR = ((1 << 3) + 1), | 305 JALR = ((1 << 3) + 1), |
302 MOVZ = ((1 << 3) + 2), | 306 MOVZ = ((1 << 3) + 2), |
303 MOVN = ((1 << 3) + 3), | 307 MOVN = ((1 << 3) + 3), |
304 BREAK = ((1 << 3) + 5), | 308 BREAK = ((1 << 3) + 5), |
305 | 309 |
306 MFHI = ((2 << 3) + 0), | 310 MFHI = ((2 << 3) + 0), |
307 MFLO = ((2 << 3) + 2), | 311 MFLO = ((2 << 3) + 2), |
308 | 312 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 case less_equal: | 495 case less_equal: |
492 return greater_equal; | 496 return greater_equal; |
493 default: | 497 default: |
494 return cc; | 498 return cc; |
495 }; | 499 }; |
496 } | 500 } |
497 | 501 |
498 | 502 |
499 // ----- Coprocessor conditions. | 503 // ----- Coprocessor conditions. |
500 enum FPUCondition { | 504 enum FPUCondition { |
501 F, // False. | 505 kNoFPUCondition = -1, |
502 UN, // Unordered. | 506 |
503 EQ, // Equal. | 507 F = 0, // False. |
504 UEQ, // Unordered or Equal. | 508 UN = 1, // Unordered. |
505 OLT, // Ordered or Less Than. | 509 EQ = 2, // Equal. |
506 ULT, // Unordered or Less Than. | 510 UEQ = 3, // Unordered or Equal. |
507 OLE, // Ordered or Less Than or Equal. | 511 OLT = 4, // Ordered or Less Than. |
508 ULE // Unordered or Less Than or Equal. | 512 ULT = 5, // Unordered or Less Than. |
| 513 OLE = 6, // Ordered or Less Than or Equal. |
| 514 ULE = 7 // Unordered or Less Than or Equal. |
509 }; | 515 }; |
510 | 516 |
511 | 517 |
| 518 // FPU rounding modes. |
| 519 enum FPURoundingMode { |
| 520 RN = 0 << 0, // Round to Nearest. |
| 521 RZ = 1 << 0, // Round towards zero. |
| 522 RP = 2 << 0, // Round towards Plus Infinity. |
| 523 RM = 3 << 0, // Round towards Minus Infinity. |
| 524 |
| 525 // Aliases. |
| 526 kRoundToNearest = RN, |
| 527 kRoundToZero = RZ, |
| 528 kRoundToPlusInf = RP, |
| 529 kRoundToMinusInf = RM |
| 530 }; |
| 531 |
| 532 static const uint32_t kFPURoundingModeMask = 3 << 0; |
| 533 |
| 534 enum CheckForInexactConversion { |
| 535 kCheckForInexactConversion, |
| 536 kDontCheckForInexactConversion |
| 537 }; |
| 538 |
| 539 |
512 // ----------------------------------------------------------------------------- | 540 // ----------------------------------------------------------------------------- |
513 // Hints. | 541 // Hints. |
514 | 542 |
515 // Branch hints are not used on the MIPS. They are defined so that they can | 543 // Branch hints are not used on the MIPS. They are defined so that they can |
516 // appear in shared function signatures, but will be ignored in MIPS | 544 // appear in shared function signatures, but will be ignored in MIPS |
517 // implementations. | 545 // implementations. |
518 enum Hint { | 546 enum Hint { |
519 no_hint = 0 | 547 no_hint = 0 |
520 }; | 548 }; |
521 | 549 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 } | 737 } |
710 } | 738 } |
711 | 739 |
712 inline int32_t Imm16Value() const { | 740 inline int32_t Imm16Value() const { |
713 ASSERT(InstructionType() == kImmediateType); | 741 ASSERT(InstructionType() == kImmediateType); |
714 return Bits(kImm16Shift + kImm16Bits - 1, kImm16Shift); | 742 return Bits(kImm16Shift + kImm16Bits - 1, kImm16Shift); |
715 } | 743 } |
716 | 744 |
717 inline int32_t Imm26Value() const { | 745 inline int32_t Imm26Value() const { |
718 ASSERT(InstructionType() == kJumpType); | 746 ASSERT(InstructionType() == kJumpType); |
719 return Bits(kImm16Shift + kImm26Bits - 1, kImm26Shift); | 747 return Bits(kImm26Shift + kImm26Bits - 1, kImm26Shift); |
720 } | 748 } |
721 | 749 |
722 // Say if the instruction should not be used in a branch delay slot. | 750 // Say if the instruction should not be used in a branch delay slot. |
723 bool IsForbiddenInBranchDelay() const; | 751 bool IsForbiddenInBranchDelay() const; |
724 // Say if the instruction 'links'. eg: jal, bal. | 752 // Say if the instruction 'links'. eg: jal, bal. |
725 bool IsLinkingInstruction() const; | 753 bool IsLinkingInstruction() const; |
726 // Say if the instruction is a break or a trap. | 754 // Say if the instruction is a break or a trap. |
727 bool IsTrap() const; | 755 bool IsTrap() const; |
728 | 756 |
729 // Instructions are read of out a code stream. The only way to get a | 757 // Instructions are read of out a code stream. The only way to get a |
(...skipping 24 matching lines...) Expand all Loading... |
754 static const int kBranchReturnOffset = 2 * Instruction::kInstrSize; | 782 static const int kBranchReturnOffset = 2 * Instruction::kInstrSize; |
755 | 783 |
756 static const int kDoubleAlignmentBits = 3; | 784 static const int kDoubleAlignmentBits = 3; |
757 static const int kDoubleAlignment = (1 << kDoubleAlignmentBits); | 785 static const int kDoubleAlignment = (1 << kDoubleAlignmentBits); |
758 static const int kDoubleAlignmentMask = kDoubleAlignment - 1; | 786 static const int kDoubleAlignmentMask = kDoubleAlignment - 1; |
759 | 787 |
760 | 788 |
761 } } // namespace v8::internal | 789 } } // namespace v8::internal |
762 | 790 |
763 #endif // #ifndef V8_MIPS_CONSTANTS_H_ | 791 #endif // #ifndef V8_MIPS_CONSTANTS_H_ |
OLD | NEW |