| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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_ARM_CONSTANTS_ARM_H_ | 5 #ifndef V8_ARM_CONSTANTS_ARM_H_ |
| 6 #define V8_ARM_CONSTANTS_ARM_H_ | 6 #define V8_ARM_CONSTANTS_ARM_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "src/base/logging.h" | 10 #include "src/base/logging.h" |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 // Get the raw instruction bits. | 470 // Get the raw instruction bits. |
| 471 inline Instr InstructionBits() const { | 471 inline Instr InstructionBits() const { |
| 472 return *reinterpret_cast<const Instr*>(this); | 472 return *reinterpret_cast<const Instr*>(this); |
| 473 } | 473 } |
| 474 | 474 |
| 475 // Set the raw instruction bits to value. | 475 // Set the raw instruction bits to value. |
| 476 inline void SetInstructionBits(Instr value) { | 476 inline void SetInstructionBits(Instr value) { |
| 477 *reinterpret_cast<Instr*>(this) = value; | 477 *reinterpret_cast<Instr*>(this) = value; |
| 478 } | 478 } |
| 479 | 479 |
| 480 // Read one particular bit out of the instruction bits. | 480 // Extract a single bit from the instruction bits and return it as bit 0 in |
| 481 // the result. |
| 481 inline int Bit(int nr) const { | 482 inline int Bit(int nr) const { |
| 482 return (InstructionBits() >> nr) & 1; | 483 return (InstructionBits() >> nr) & 1; |
| 483 } | 484 } |
| 484 | 485 |
| 485 // Read a bit field's value out of the instruction bits. | 486 // Extract a bit field <hi:lo> from the instruction bits and return it in the |
| 487 // least-significant bits of the result. |
| 486 inline int Bits(int hi, int lo) const { | 488 inline int Bits(int hi, int lo) const { |
| 487 return (InstructionBits() >> lo) & ((2 << (hi - lo)) - 1); | 489 return (InstructionBits() >> lo) & ((2 << (hi - lo)) - 1); |
| 488 } | 490 } |
| 489 | 491 |
| 490 // Read a bit field out of the instruction bits. | 492 // Read a bit field <hi:lo>, leaving its position unchanged in the result. |
| 491 inline int BitField(int hi, int lo) const { | 493 inline int BitField(int hi, int lo) const { |
| 492 return InstructionBits() & (((2 << (hi - lo)) - 1) << lo); | 494 return InstructionBits() & (((2 << (hi - lo)) - 1) << lo); |
| 493 } | 495 } |
| 494 | 496 |
| 495 // Static support. | 497 // Static support. |
| 496 | 498 |
| 497 // Read one particular bit out of the instruction bits. | 499 // Extract a single bit from the instruction bits and return it as bit 0 in |
| 500 // the result. |
| 498 static inline int Bit(Instr instr, int nr) { | 501 static inline int Bit(Instr instr, int nr) { |
| 499 return (instr >> nr) & 1; | 502 return (instr >> nr) & 1; |
| 500 } | 503 } |
| 501 | 504 |
| 502 // Read the value of a bit field out of the instruction bits. | 505 // Extract a bit field <hi:lo> from the instruction bits and return it in the |
| 506 // least-significant bits of the result. |
| 503 static inline int Bits(Instr instr, int hi, int lo) { | 507 static inline int Bits(Instr instr, int hi, int lo) { |
| 504 return (instr >> lo) & ((2 << (hi - lo)) - 1); | 508 return (instr >> lo) & ((2 << (hi - lo)) - 1); |
| 505 } | 509 } |
| 506 | 510 |
| 507 | 511 // Read a bit field <hi:lo>, leaving its position unchanged in the result. |
| 508 // Read a bit field out of the instruction bits. | |
| 509 static inline int BitField(Instr instr, int hi, int lo) { | 512 static inline int BitField(Instr instr, int hi, int lo) { |
| 510 return instr & (((2 << (hi - lo)) - 1) << lo); | 513 return instr & (((2 << (hi - lo)) - 1) << lo); |
| 511 } | 514 } |
| 512 | 515 |
| 513 | |
| 514 // Accessors for the different named fields used in the ARM encoding. | 516 // Accessors for the different named fields used in the ARM encoding. |
| 515 // The naming of these accessor corresponds to figure A3-1. | 517 // The naming of these accessor corresponds to figure A3-1. |
| 516 // | 518 // |
| 517 // Two kind of accessors are declared: | 519 // Two kind of accessors are declared: |
| 518 // - <Name>Field() will return the raw field, i.e. the field's bits at their | 520 // - <Name>Field() will return the raw field, i.e. the field's bits at their |
| 519 // original place in the instruction encoding. | 521 // original place in the instruction encoding. |
| 520 // e.g. if instr is the 'addgt r0, r1, r2' instruction, encoded as | 522 // e.g. if instr is the 'addgt r0, r1, r2' instruction, encoded as |
| 521 // 0xC0810002 ConditionField(instr) will return 0xC0000000. | 523 // 0xC0810002 ConditionField(instr) will return 0xC0000000. |
| 522 // - <Name>Value() will return the field value, shifted back to bit 0. | 524 // - <Name>Value() will return the field value, shifted back to bit 0. |
| 523 // e.g. if instr is the 'addgt r0, r1, r2' instruction, encoded as | 525 // e.g. if instr is the 'addgt r0, r1, r2' instruction, encoded as |
| 524 // 0xC0810002 ConditionField(instr) will return 0xC. | 526 // 0xC0810002 ConditionField(instr) will return 0xC. |
| 525 | 527 |
| 526 | 528 |
| 527 // Generally applicable fields | 529 // Generally applicable fields |
| 528 inline Condition ConditionValue() const { | 530 inline int ConditionValue() const { return Bits(31, 28); } |
| 529 return static_cast<Condition>(Bits(31, 28)); | |
| 530 } | |
| 531 inline Condition ConditionField() const { | 531 inline Condition ConditionField() const { |
| 532 return static_cast<Condition>(BitField(31, 28)); | 532 return static_cast<Condition>(BitField(31, 28)); |
| 533 } | 533 } |
| 534 DECLARE_STATIC_TYPED_ACCESSOR(Condition, ConditionValue); | 534 DECLARE_STATIC_TYPED_ACCESSOR(int, ConditionValue); |
| 535 DECLARE_STATIC_TYPED_ACCESSOR(Condition, ConditionField); | 535 DECLARE_STATIC_TYPED_ACCESSOR(Condition, ConditionField); |
| 536 | 536 |
| 537 inline int TypeValue() const { return Bits(27, 25); } | 537 inline int TypeValue() const { return Bits(27, 25); } |
| 538 inline int SpecialValue() const { return Bits(27, 23); } | 538 inline int SpecialValue() const { return Bits(27, 23); } |
| 539 | 539 |
| 540 inline int RnValue() const { return Bits(19, 16); } | 540 inline int RnValue() const { return Bits(19, 16); } |
| 541 DECLARE_STATIC_ACCESSOR(RnValue); | 541 DECLARE_STATIC_ACCESSOR(RnValue); |
| 542 inline int RdValue() const { return Bits(15, 12); } | 542 inline int RdValue() const { return Bits(15, 12); } |
| 543 DECLARE_STATIC_ACCESSOR(RdValue); | 543 DECLARE_STATIC_ACCESSOR(RdValue); |
| 544 | 544 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 | 715 |
| 716 private: | 716 private: |
| 717 static const char* names_[kNumVFPRegisters]; | 717 static const char* names_[kNumVFPRegisters]; |
| 718 }; | 718 }; |
| 719 | 719 |
| 720 | 720 |
| 721 } // namespace internal | 721 } // namespace internal |
| 722 } // namespace v8 | 722 } // namespace v8 |
| 723 | 723 |
| 724 #endif // V8_ARM_CONSTANTS_ARM_H_ | 724 #endif // V8_ARM_CONSTANTS_ARM_H_ |
| OLD | NEW |