| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_ACTUAL_CLASSES_H_ | 7 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_ACTUAL_CLASSES_H_ |
| 8 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_ACTUAL_CLASSES_H_ | 8 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_ACTUAL_CLASSES_H_ |
| 9 | 9 |
| 10 #include "native_client/src/trusted/validator_arm/inst_classes.h" | 10 #include "native_client/src/trusted/validator_arm/inst_classes.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 * | 26 * |
| 27 * TODO(karl): finish updating this file to match what we want for the | 27 * TODO(karl): finish updating this file to match what we want for the |
| 28 * arm validator. | 28 * arm validator. |
| 29 */ | 29 */ |
| 30 namespace nacl_arm_dec { | 30 namespace nacl_arm_dec { |
| 31 | 31 |
| 32 // ************************************************************** | 32 // ************************************************************** |
| 33 // N E W C L A S S D E C O D E R S | 33 // N E W C L A S S D E C O D E R S |
| 34 // ************************************************************** | 34 // ************************************************************** |
| 35 | 35 |
| 36 // Data processing and arithmetic |
| 36 class Defs12To15 : public ClassDecoder { | 37 class Defs12To15 : public ClassDecoder { |
| 37 public: | 38 public: |
| 38 inline Defs12To15() : ClassDecoder() {} | 39 inline Defs12To15() : ClassDecoder() {} |
| 39 virtual ~Defs12To15() {} | 40 virtual ~Defs12To15() {} |
| 40 | 41 |
| 41 // We use Rd to capture the register being set. | 42 // We use Rd to capture the register being set. |
| 42 static const RegDBits12To15Interface d; | 43 static const RegDBits12To15Interface d; |
| 43 static const UpdatesFlagsRegisterBit20Interface flags; | 44 static const UpdatesConditionsBit20Interface conditions; |
| 44 | 45 |
| 45 virtual SafetyLevel safety(Instruction i) const; | 46 virtual SafetyLevel safety(Instruction i) const; |
| 46 virtual RegisterList defs(Instruction i) const; | 47 virtual RegisterList defs(Instruction i) const; |
| 47 | 48 |
| 48 private: | 49 private: |
| 49 NACL_DISALLOW_COPY_AND_ASSIGN(Defs12To15); | 50 NACL_DISALLOW_COPY_AND_ASSIGN(Defs12To15); |
| 50 }; | 51 }; |
| 51 | 52 |
| 52 // Defs12To15 where registers Rn, Rd, Rs, and Rm are not Pc. | 53 // Defs12To15 where registers Rn, Rd, Rs, and Rm are not Pc. |
| 54 // Note: Some instructions may use other names for the registers, |
| 55 // but they have the same placement within the instruction, and |
| 56 // hence do not need a separate class decoder. |
| 53 class Defs12To15RdRnRsRmNotPc : public Defs12To15 { | 57 class Defs12To15RdRnRsRmNotPc : public Defs12To15 { |
| 54 public: | 58 public: |
| 55 static const RegMBits0To3Interface m; | 59 static const RegMBits0To3Interface m; |
| 56 static const RegSBits8To11Interface s; | 60 static const RegSBits8To11Interface s; |
| 57 static const RegNBits16To19Interface n; | 61 static const RegNBits16To19Interface n; |
| 58 | 62 |
| 59 inline Defs12To15RdRnRsRmNotPc() : Defs12To15() {} | 63 inline Defs12To15RdRnRsRmNotPc() : Defs12To15() {} |
| 60 virtual ~Defs12To15RdRnRsRmNotPc() {} | 64 virtual ~Defs12To15RdRnRsRmNotPc() {} |
| 61 | 65 |
| 62 virtual SafetyLevel safety(Instruction i) const; | 66 virtual SafetyLevel safety(Instruction i) const; |
| 67 |
| 68 private: |
| 69 NACL_DISALLOW_COPY_AND_ASSIGN(Defs12To15RdRnRsRmNotPc); |
| 63 }; | 70 }; |
| 64 | 71 |
| 65 // ************************************************************** | 72 // ************************************************************** |
| 66 // O L D C L A S S D E C O D E R S | 73 // O L D C L A S S D E C O D E R S |
| 67 // ************************************************************** | 74 // ************************************************************** |
| 68 | 75 |
| 69 class OldClassDecoder : public ClassDecoder { | 76 class OldClassDecoder : public ClassDecoder { |
| 70 public: | 77 public: |
| 71 inline OldClassDecoder() : ClassDecoder() {} | 78 inline OldClassDecoder() : ClassDecoder() {} |
| 72 virtual ~OldClassDecoder() {} | 79 virtual ~OldClassDecoder() {} |
| 73 | 80 |
| 74 // Many instructions define control bits in bits 20-24. The useful bits | 81 // Many instructions define control bits in bits 20-24. The useful bits |
| 75 // are defined here. | 82 // are defined here. |
| 76 | 83 |
| 77 // True if U (updates flags register) flag is defined. | 84 // True if S (updates condition flags in APSR register) flag is defined. |
| 78 inline bool UpdatesFlagsRegister(const Instruction& i) const { | 85 inline bool UpdatesConditions(const Instruction& i) const { |
| 79 return i.bit(20); | 86 return i.bit(20); |
| 80 } | 87 } |
| 81 | 88 |
| 82 // True if W (does write) flag is defined. | 89 // True if W (does write) flag is defined. |
| 83 inline bool WritesFlag(const Instruction& i) const { | 90 inline bool WritesFlag(const Instruction& i) const { |
| 84 return i.bit(21); | 91 return i.bit(21); |
| 85 } | 92 } |
| 86 // True if P (pre-indexing) flag is defined. | 93 // True if P (pre-indexing) flag is defined. |
| 87 inline bool PreindexingFlag(const Instruction& i) const { | 94 inline bool PreindexingFlag(const Instruction& i) const { |
| 88 return i.bit(24); | 95 return i.bit(24); |
| (...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 public: | 820 public: |
| 814 inline MoveFromCoprocessor() {} | 821 inline MoveFromCoprocessor() {} |
| 815 virtual ~MoveFromCoprocessor() {} | 822 virtual ~MoveFromCoprocessor() {} |
| 816 | 823 |
| 817 virtual RegisterList defs(Instruction i) const; | 824 virtual RegisterList defs(Instruction i) const; |
| 818 // Defines the destination core register. | 825 // Defines the destination core register. |
| 819 inline Register Rt(const Instruction& i) const { | 826 inline Register Rt(const Instruction& i) const { |
| 820 Register rt = i.reg(15, 12); | 827 Register rt = i.reg(15, 12); |
| 821 if (rt == kRegisterPc) { | 828 if (rt == kRegisterPc) { |
| 822 // Per ARM ISA spec: r15 here is a synonym for the flags register! | 829 // Per ARM ISA spec: r15 here is a synonym for the flags register! |
| 823 return kRegisterFlags; | 830 return kConditions; |
| 824 } | 831 } |
| 825 return rt; | 832 return rt; |
| 826 } | 833 } |
| 827 | 834 |
| 828 private: | 835 private: |
| 829 NACL_DISALLOW_COPY_AND_ASSIGN(MoveFromCoprocessor); | 836 NACL_DISALLOW_COPY_AND_ASSIGN(MoveFromCoprocessor); |
| 830 }; | 837 }; |
| 831 | 838 |
| 832 // MRRC/MRRC2, which load pairs of registers from a coprocessor register. | 839 // MRRC/MRRC2, which load pairs of registers from a coprocessor register. |
| 833 class MoveDoubleFromCoprocessor : public CoprocessorOp { | 840 class MoveDoubleFromCoprocessor : public CoprocessorOp { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 } | 904 } |
| 898 virtual int32_t branch_target_offset(Instruction i) const; | 905 virtual int32_t branch_target_offset(Instruction i) const; |
| 899 | 906 |
| 900 private: | 907 private: |
| 901 NACL_DISALLOW_COPY_AND_ASSIGN(Branch); | 908 NACL_DISALLOW_COPY_AND_ASSIGN(Branch); |
| 902 }; | 909 }; |
| 903 | 910 |
| 904 } // namespace | 911 } // namespace |
| 905 | 912 |
| 906 #endif // NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_ACTUAL_CLASSES_H_ | 913 #endif // NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_ACTUAL_CLASSES_H_ |
| OLD | NEW |