| 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_BASELINE_CLASSES_H_ | 7 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_BASELINE_CLASSES_H_ |
| 8 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_BASELINE_CLASSES_H_ | 8 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_BASELINE_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" |
| 11 | 11 |
| 12 // TODO(jfb) Remove these forward declatations? They're only needed for |
| 13 // friend classes which shouldn't be needed themselves. |
| 14 namespace nacl_arm_test { |
| 15 class LoadStore2RegisterImm8OpTester; |
| 16 class LoadStore2RegisterImm8DoubleOpTester; |
| 17 class LoadStore2RegisterImm12OpTester; |
| 18 class LoadStore3RegisterOpTester; |
| 19 class LoadStore3RegisterDoubleOpTester; |
| 20 class LoadStore3RegisterImm5OpTester; |
| 21 } // namespace nacl_arm_test |
| 22 |
| 12 /* | 23 /* |
| 13 * Models the baseline "instruction classes" that capture what the | 24 * Models the baseline "instruction classes" that capture what the |
| 14 * decoder produces. | 25 * decoder produces. |
| 15 * | 26 * |
| 16 * The baseline model is intentionally very close to the data formats | 27 * The baseline model is intentionally very close to the data formats |
| 17 * used in "ARM Architecture Reference Manual ARM*v7-A and ARM*v7-R | 28 * used in "ARM Architecture Reference Manual ARM*v7-A and ARM*v7-R |
| 18 * edition, Errata markup". For each data layout, there is a separate | 29 * edition, Errata markup". For each data layout, there is a separate |
| 19 * class. In addition, the test infrastructure is based on testing if | 30 * class. In addition, the test infrastructure is based on testing if |
| 20 * the baseline class decoders do as expected (in terms of the | 31 * the baseline class decoders do as expected (in terms of the |
| 21 * manual). | 32 * manual). |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 // bits in the APSR. | 159 // bits in the APSR. |
| 149 // MSR<c> <spec_reg>, #<const> | 160 // MSR<c> <spec_reg>, #<const> |
| 150 // +--------+----------------+----+------------+------------------------+ | 161 // +--------+----------------+----+------------+------------------------+ |
| 151 // |31302928|2726252423222120|1918|171615141312|1110 9 8 7 6 5 4 3 2 1 0| | 162 // |31302928|2726252423222120|1918|171615141312|1110 9 8 7 6 5 4 3 2 1 0| |
| 152 // +--------+----------------+----+------------+------------------------+ | 163 // +--------+----------------+----+------------+------------------------+ |
| 153 // | cond | |mask| | imm12 | | 164 // | cond | |mask| | imm12 | |
| 154 // +--------+----------------+----+------------+------------------------+ | 165 // +--------+----------------+----+------------+------------------------+ |
| 155 // Definitions: | 166 // Definitions: |
| 156 // mask = Defines which parts of the APSR is set. When mask<1>=1, | 167 // mask = Defines which parts of the APSR is set. When mask<1>=1, |
| 157 // the N, Z, C, V, and Q bits (31:27) are updated. When | 168 // the N, Z, C, V, and Q bits (31:27) are updated. When |
| 158 // mask<0>=1, the GE bits (3:0 and 19:16) are updated. | 169 // mask<0>=1, the GE bits (19:16) are updated. |
| 159 // Note: If mask=3, then N, Z, C, V, Q, and GE bits are updated. | 170 // Note: If mask=3, then N, Z, C, V, Q, and GE bits are updated. |
| 160 // Note: mask=0 should not parse. | 171 // Note: mask=0 should not parse. |
| 161 class MoveImmediate12ToApsr : public ClassDecoder { | 172 class MoveImmediate12ToApsr : public ClassDecoder { |
| 162 public: | 173 public: |
| 163 // Interfaces for components in the instruction. | 174 // Interfaces for components in the instruction. |
| 164 static const Imm12Bits0To11Interface imm12; | 175 static const Imm12Bits0To11Interface imm12; |
| 165 static const Imm2Bits18To19Interface mask; | 176 static const Imm2Bits18To19Interface mask; |
| 166 static const ConditionBits28To31Interface cond; | 177 static const ConditionBits28To31Interface cond; |
| 167 | 178 |
| 168 // Methods for class. | 179 // Methods for class. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 | 241 |
| 231 private: | 242 private: |
| 232 NACL_DISALLOW_COPY_AND_ASSIGN(BranchImmediate24); | 243 NACL_DISALLOW_COPY_AND_ASSIGN(BranchImmediate24); |
| 233 }; | 244 }; |
| 234 | 245 |
| 235 // Defines a break point, which is also used to act as a constant pool header | 246 // Defines a break point, which is also used to act as a constant pool header |
| 236 // if the constant is 0x7777. | 247 // if the constant is 0x7777. |
| 237 class BreakPointAndConstantPoolHead : public Immediate16Use { | 248 class BreakPointAndConstantPoolHead : public Immediate16Use { |
| 238 public: | 249 public: |
| 239 BreakPointAndConstantPoolHead() {} | 250 BreakPointAndConstantPoolHead() {} |
| 251 virtual SafetyLevel safety(Instruction i) const; |
| 240 virtual bool is_literal_pool_head(Instruction i) const; | 252 virtual bool is_literal_pool_head(Instruction i) const; |
| 241 | 253 |
| 242 private: | 254 private: |
| 243 NACL_DISALLOW_COPY_AND_ASSIGN(BreakPointAndConstantPoolHead); | 255 NACL_DISALLOW_COPY_AND_ASSIGN(BreakPointAndConstantPoolHead); |
| 244 }; | 256 }; |
| 245 | 257 |
| 246 // Models a branch to address in Rm. | 258 // Models a branch to address in Rm. |
| 247 // Op<c> <Rm> | 259 // Op<c> <Rm> |
| 248 // +--------+---------------------------------------------+--+--+--------+ | 260 // +--------+---------------------------------------------+--+--+--------+ |
| 249 // |31302928|2726252423222212019181716151413121110 9 8 7 6| 5| 4| 3 2 1 0| | 261 // |31302928|2726252423222212019181716151413121110 9 8 7 6| 5| 4| 3 2 1 0| |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 public: | 624 public: |
| 613 static const Imm4Bits0To3Interface imm4L; | 625 static const Imm4Bits0To3Interface imm4L; |
| 614 static const Imm4Bits8To11Interface imm4H; | 626 static const Imm4Bits8To11Interface imm4H; |
| 615 static const RegBits12To15Interface t; | 627 static const RegBits12To15Interface t; |
| 616 static const RegBits16To19Interface n; | 628 static const RegBits16To19Interface n; |
| 617 static const WritesBit21Interface writes; | 629 static const WritesBit21Interface writes; |
| 618 static const AddOffsetBit23Interface direction; | 630 static const AddOffsetBit23Interface direction; |
| 619 static const PrePostIndexingBit24Interface indexing; | 631 static const PrePostIndexingBit24Interface indexing; |
| 620 static const ConditionBits28To31Interface cond; | 632 static const ConditionBits28To31Interface cond; |
| 621 | 633 |
| 622 LoadStore2RegisterImm8Op() : ClassDecoder(), is_load_(false) {} | |
| 623 virtual SafetyLevel safety(Instruction i) const; | 634 virtual SafetyLevel safety(Instruction i) const; |
| 624 virtual RegisterList immediate_addressing_defs(Instruction i) const; | 635 virtual RegisterList immediate_addressing_defs(Instruction i) const; |
| 625 virtual Register base_address_register(const Instruction i) const; | 636 virtual Register base_address_register(const Instruction i) const; |
| 626 | 637 |
| 627 bool HasWriteBack(const Instruction i) const { | 638 bool HasWriteBack(const Instruction i) const { |
| 628 return indexing.IsPostIndexing(i) || writes.IsDefined(i); | 639 return indexing.IsPostIndexing(i) || writes.IsDefined(i); |
| 629 } | 640 } |
| 630 | 641 |
| 631 protected: | 642 protected: |
| 643 // TODO(jfb) Remove friend? It looks like its usage of the protected |
| 644 // ctor shouldn't be. |
| 645 friend class nacl_arm_test::LoadStore2RegisterImm8OpTester; |
| 646 explicit LoadStore2RegisterImm8Op(bool is_load) |
| 647 : ClassDecoder(), is_load_(is_load) {} |
| 632 bool is_load_; // true if load (rather than store). | 648 bool is_load_; // true if load (rather than store). |
| 633 | 649 |
| 634 private: | 650 private: |
| 635 NACL_DISALLOW_COPY_AND_ASSIGN(LoadStore2RegisterImm8Op); | 651 NACL_DISALLOW_DEFAULT_COPY_AND_ASSIGN(LoadStore2RegisterImm8Op); |
| 636 }; | 652 }; |
| 637 | 653 |
| 638 // Defines the virtuals for a load immediate instruction. | 654 // Defines the virtuals for a load immediate instruction. |
| 639 class Load2RegisterImm8Op : public LoadStore2RegisterImm8Op { | 655 class Load2RegisterImm8Op : public LoadStore2RegisterImm8Op { |
| 640 public: | 656 public: |
| 641 Load2RegisterImm8Op() : LoadStore2RegisterImm8Op() { | 657 Load2RegisterImm8Op() : LoadStore2RegisterImm8Op(true) { |
| 642 is_load_ = true; | |
| 643 } | 658 } |
| 644 virtual RegisterList defs(Instruction i) const; | 659 virtual RegisterList defs(Instruction i) const; |
| 645 virtual bool offset_is_immediate(Instruction i) const; | 660 virtual bool offset_is_immediate(Instruction i) const; |
| 646 | 661 |
| 647 private: | 662 private: |
| 648 NACL_DISALLOW_COPY_AND_ASSIGN(Load2RegisterImm8Op); | 663 NACL_DISALLOW_COPY_AND_ASSIGN(Load2RegisterImm8Op); |
| 649 }; | 664 }; |
| 650 | 665 |
| 651 // Defines the virtuals for a store immediate instruction. | 666 // Defines the virtuals for a store immediate instruction. |
| 652 class Store2RegisterImm8Op : public LoadStore2RegisterImm8Op { | 667 class Store2RegisterImm8Op : public LoadStore2RegisterImm8Op { |
| 653 public: | 668 public: |
| 654 Store2RegisterImm8Op() : LoadStore2RegisterImm8Op() { | 669 Store2RegisterImm8Op() : LoadStore2RegisterImm8Op(false) { |
| 655 is_load_ = false; | |
| 656 } | 670 } |
| 657 virtual RegisterList defs(Instruction i) const; | 671 virtual RegisterList defs(Instruction i) const; |
| 658 | 672 |
| 659 protected: | 673 protected: |
| 660 NACL_DISALLOW_COPY_AND_ASSIGN(Store2RegisterImm8Op); | 674 NACL_DISALLOW_COPY_AND_ASSIGN(Store2RegisterImm8Op); |
| 661 }; | 675 }; |
| 662 | 676 |
| 663 // Models a 2-register immediate load/store operation where the source/target | 677 // Models a 2-register immediate load/store operation where the source/target |
| 664 // is double wide (i.e. Rt and Rt2). | 678 // is double wide (i.e. Rt and Rt2). |
| 665 class LoadStore2RegisterImm8DoubleOp | 679 class LoadStore2RegisterImm8DoubleOp |
| 666 : public LoadStore2RegisterImm8Op { | 680 : public LoadStore2RegisterImm8Op { |
| 667 public: | 681 public: |
| 668 // Interface for components in the instruction (and not inherited). | 682 // Interface for components in the instruction (and not inherited). |
| 669 static const RegBits12To15Plus1Interface t2; | 683 static const RegBits12To15Plus1Interface t2; |
| 670 | 684 |
| 671 LoadStore2RegisterImm8DoubleOp() | |
| 672 : LoadStore2RegisterImm8Op() {} | |
| 673 virtual SafetyLevel safety(Instruction i) const; | 685 virtual SafetyLevel safety(Instruction i) const; |
| 674 | 686 |
| 687 protected: |
| 688 // TODO(jfb) Remove friend? It looks like its usage of the protected |
| 689 // ctor shouldn't be. |
| 690 friend class nacl_arm_test::LoadStore2RegisterImm8DoubleOpTester; |
| 691 explicit LoadStore2RegisterImm8DoubleOp(bool is_load) |
| 692 : LoadStore2RegisterImm8Op(is_load) {} |
| 693 |
| 675 private: | 694 private: |
| 676 NACL_DISALLOW_COPY_AND_ASSIGN(LoadStore2RegisterImm8DoubleOp); | 695 NACL_DISALLOW_DEFAULT_COPY_AND_ASSIGN(LoadStore2RegisterImm8DoubleOp); |
| 677 }; | 696 }; |
| 678 | 697 |
| 679 // Defines the virtuals for a load immediate double instruction. | 698 // Defines the virtuals for a load immediate double instruction. |
| 680 class Load2RegisterImm8DoubleOp | 699 class Load2RegisterImm8DoubleOp |
| 681 : public LoadStore2RegisterImm8DoubleOp { | 700 : public LoadStore2RegisterImm8DoubleOp { |
| 682 public: | 701 public: |
| 683 Load2RegisterImm8DoubleOp() : LoadStore2RegisterImm8DoubleOp() { | 702 Load2RegisterImm8DoubleOp() : LoadStore2RegisterImm8DoubleOp(true) { |
| 684 is_load_ = true; | |
| 685 } | 703 } |
| 686 virtual RegisterList defs(Instruction i) const; | 704 virtual RegisterList defs(Instruction i) const; |
| 687 virtual bool offset_is_immediate(Instruction i) const; | 705 virtual bool offset_is_immediate(Instruction i) const; |
| 688 | 706 |
| 689 private: | 707 private: |
| 690 NACL_DISALLOW_COPY_AND_ASSIGN(Load2RegisterImm8DoubleOp); | 708 NACL_DISALLOW_COPY_AND_ASSIGN(Load2RegisterImm8DoubleOp); |
| 691 }; | 709 }; |
| 692 | 710 |
| 693 // Defines the virtuals for a store immediate double instruction. | 711 // Defines the virtuals for a store immediate double instruction. |
| 694 class Store2RegisterImm8DoubleOp | 712 class Store2RegisterImm8DoubleOp |
| 695 : public LoadStore2RegisterImm8DoubleOp { | 713 : public LoadStore2RegisterImm8DoubleOp { |
| 696 public: | 714 public: |
| 697 Store2RegisterImm8DoubleOp() | 715 Store2RegisterImm8DoubleOp() |
| 698 : LoadStore2RegisterImm8DoubleOp() { | 716 : LoadStore2RegisterImm8DoubleOp(false) { |
| 699 is_load_ = false; | |
| 700 } | 717 } |
| 701 virtual RegisterList defs(Instruction i) const; | 718 virtual RegisterList defs(Instruction i) const; |
| 702 | 719 |
| 703 protected: | 720 protected: |
| 704 NACL_DISALLOW_COPY_AND_ASSIGN(Store2RegisterImm8DoubleOp); | 721 NACL_DISALLOW_COPY_AND_ASSIGN(Store2RegisterImm8DoubleOp); |
| 705 }; | 722 }; |
| 706 | 723 |
| 707 // Models a 2-register load/store 12-bit immediate operation of the forms: | 724 // Models a 2-register load/store 12-bit immediate operation of the forms: |
| 708 // Op<c> <Rt>, [<Rn> {, #+/-<imm12>}] | 725 // Op<c> <Rt>, [<Rn> {, #+/-<imm12>}] |
| 709 // Op<c> <Rt>, [<Rn>], #+/-<imm12> | 726 // Op<c> <Rt>, [<Rn>], #+/-<imm12> |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 // not model it as a special instruction. | 761 // not model it as a special instruction. |
| 745 class LoadStore2RegisterImm12Op : public ClassDecoder { | 762 class LoadStore2RegisterImm12Op : public ClassDecoder { |
| 746 public: | 763 public: |
| 747 static const Imm12Bits0To11Interface imm12; | 764 static const Imm12Bits0To11Interface imm12; |
| 748 static const RegBits12To15Interface t; | 765 static const RegBits12To15Interface t; |
| 749 static const RegBits16To19Interface n; | 766 static const RegBits16To19Interface n; |
| 750 static const WritesBit21Interface writes; | 767 static const WritesBit21Interface writes; |
| 751 static const AddOffsetBit23Interface direction; | 768 static const AddOffsetBit23Interface direction; |
| 752 static const PrePostIndexingBit24Interface indexing; | 769 static const PrePostIndexingBit24Interface indexing; |
| 753 static const ConditionBits28To31Interface cond; | 770 static const ConditionBits28To31Interface cond; |
| 754 LoadStore2RegisterImm12Op() : ClassDecoder() , is_load_(false) {} | 771 |
| 755 virtual SafetyLevel safety(Instruction i) const; | 772 virtual SafetyLevel safety(Instruction i) const; |
| 756 virtual RegisterList immediate_addressing_defs(Instruction i) const; | 773 virtual RegisterList immediate_addressing_defs(Instruction i) const; |
| 757 virtual Register base_address_register(const Instruction i) const; | 774 virtual Register base_address_register(const Instruction i) const; |
| 758 bool HasWriteBack(const Instruction i) const { | 775 bool HasWriteBack(const Instruction i) const { |
| 759 return indexing.IsPostIndexing(i) || writes.IsDefined(i); | 776 return indexing.IsPostIndexing(i) || writes.IsDefined(i); |
| 760 } | 777 } |
| 761 | 778 |
| 762 protected: | 779 protected: |
| 780 // TODO(jfb) Remove friend? It looks like its usage of the protected |
| 781 // ctor shouldn't be. |
| 782 friend class nacl_arm_test::LoadStore2RegisterImm12OpTester; |
| 783 explicit LoadStore2RegisterImm12Op(bool is_load) |
| 784 : ClassDecoder() , is_load_(is_load) {} |
| 763 bool is_load_; // true if load (rather than store). | 785 bool is_load_; // true if load (rather than store). |
| 764 | 786 |
| 765 private: | 787 private: |
| 766 NACL_DISALLOW_COPY_AND_ASSIGN(LoadStore2RegisterImm12Op); | 788 NACL_DISALLOW_DEFAULT_COPY_AND_ASSIGN(LoadStore2RegisterImm12Op); |
| 767 }; | 789 }; |
| 768 | 790 |
| 769 // Defines the virtuals for a load immediate instruction. | 791 // Defines the virtuals for a load immediate instruction. |
| 770 class Load2RegisterImm12Op : public LoadStore2RegisterImm12Op { | 792 class Load2RegisterImm12Op : public LoadStore2RegisterImm12Op { |
| 771 public: | 793 public: |
| 772 Load2RegisterImm12Op() : LoadStore2RegisterImm12Op() { | 794 Load2RegisterImm12Op() : LoadStore2RegisterImm12Op(true) { |
| 773 is_load_ = true; | |
| 774 } | 795 } |
| 775 virtual RegisterList defs(Instruction i) const; | 796 virtual RegisterList defs(Instruction i) const; |
| 776 virtual bool offset_is_immediate(Instruction i) const; | 797 virtual bool offset_is_immediate(Instruction i) const; |
| 777 | 798 |
| 778 private: | 799 private: |
| 779 NACL_DISALLOW_COPY_AND_ASSIGN(Load2RegisterImm12Op); | 800 NACL_DISALLOW_COPY_AND_ASSIGN(Load2RegisterImm12Op); |
| 780 }; | 801 }; |
| 781 | 802 |
| 782 // Defines the virtuals for a store immediate instruction. | 803 // Defines the virtuals for a store immediate instruction. |
| 783 // Note: See class LoadStore2RegisterImm12Op for more information | 804 // Note: See class LoadStore2RegisterImm12Op for more information |
| 784 // on how PUSH (i.e. when Rn=Sp && U=0 && W=1 && Imm12=4) is handled. | 805 // on how PUSH (i.e. when Rn=Sp && U=0 && W=1 && Imm12=4) is handled. |
| 785 class Store2RegisterImm12Op : public LoadStore2RegisterImm12Op { | 806 class Store2RegisterImm12Op : public LoadStore2RegisterImm12Op { |
| 786 public: | 807 public: |
| 787 Store2RegisterImm12Op() : LoadStore2RegisterImm12Op() { | 808 Store2RegisterImm12Op() : LoadStore2RegisterImm12Op(false) { |
| 788 is_load_ = false; | |
| 789 } | 809 } |
| 790 virtual RegisterList defs(Instruction i) const; | 810 virtual RegisterList defs(Instruction i) const; |
| 791 | 811 |
| 792 private: | 812 private: |
| 793 NACL_DISALLOW_COPY_AND_ASSIGN(Store2RegisterImm12Op); | 813 NACL_DISALLOW_COPY_AND_ASSIGN(Store2RegisterImm12Op); |
| 794 }; | 814 }; |
| 795 | 815 |
| 796 // Defines virtual for a store immediate instruction with the following | 816 // Defines virtual for a store immediate instruction with the following |
| 797 // constraint: | 817 // constraint: |
| 798 // if wback && Rn=Rt then unpredictable. | 818 // if wback && Rn=Rt then unpredictable. |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 public: | 1178 public: |
| 1159 // Interfaces for components in the instruction. | 1179 // Interfaces for components in the instruction. |
| 1160 static const RegBits0To3Interface m; | 1180 static const RegBits0To3Interface m; |
| 1161 static const RegBits12To15Interface t; | 1181 static const RegBits12To15Interface t; |
| 1162 static const RegBits16To19Interface n; | 1182 static const RegBits16To19Interface n; |
| 1163 static const WritesBit21Interface writes; | 1183 static const WritesBit21Interface writes; |
| 1164 static const AddOffsetBit23Interface direction; | 1184 static const AddOffsetBit23Interface direction; |
| 1165 static const PrePostIndexingBit24Interface indexing; | 1185 static const PrePostIndexingBit24Interface indexing; |
| 1166 static const ConditionBits28To31Interface cond; | 1186 static const ConditionBits28To31Interface cond; |
| 1167 | 1187 |
| 1168 LoadStore3RegisterOp() : ClassDecoder(), is_load_(false) {} | |
| 1169 virtual SafetyLevel safety(Instruction i) const; | 1188 virtual SafetyLevel safety(Instruction i) const; |
| 1170 virtual Register base_address_register(const Instruction i) const; | 1189 virtual Register base_address_register(const Instruction i) const; |
| 1171 bool HasWriteBack(const Instruction i) const { | 1190 bool HasWriteBack(const Instruction i) const { |
| 1172 return indexing.IsPostIndexing(i) || writes.IsDefined(i); | 1191 return indexing.IsPostIndexing(i) || writes.IsDefined(i); |
| 1173 } | 1192 } |
| 1174 | 1193 |
| 1175 protected: | 1194 protected: |
| 1195 // TODO(jfb) Remove friend? It looks like its usage of the protected |
| 1196 // ctor shouldn't be. |
| 1197 friend class nacl_arm_test::LoadStore3RegisterOpTester; |
| 1198 explicit LoadStore3RegisterOp(bool is_load) |
| 1199 : ClassDecoder(), is_load_(is_load) {} |
| 1176 bool is_load_; // true if load (rather than store). | 1200 bool is_load_; // true if load (rather than store). |
| 1177 | 1201 |
| 1178 private: | 1202 private: |
| 1179 NACL_DISALLOW_COPY_AND_ASSIGN(LoadStore3RegisterOp); | 1203 NACL_DISALLOW_DEFAULT_COPY_AND_ASSIGN(LoadStore3RegisterOp); |
| 1180 }; | 1204 }; |
| 1181 | 1205 |
| 1182 // Defines the virtuals for a load register instruction. | 1206 // Defines the virtuals for a load register instruction. |
| 1183 class Load3RegisterOp : public LoadStore3RegisterOp { | 1207 class Load3RegisterOp : public LoadStore3RegisterOp { |
| 1184 public: | 1208 public: |
| 1185 Load3RegisterOp() : LoadStore3RegisterOp() { | 1209 Load3RegisterOp() : LoadStore3RegisterOp(true) { |
| 1186 is_load_ = true; | |
| 1187 } | 1210 } |
| 1188 virtual RegisterList defs(Instruction i) const; | 1211 virtual RegisterList defs(Instruction i) const; |
| 1189 | 1212 |
| 1190 private: | 1213 private: |
| 1191 NACL_DISALLOW_COPY_AND_ASSIGN(Load3RegisterOp); | 1214 NACL_DISALLOW_COPY_AND_ASSIGN(Load3RegisterOp); |
| 1192 }; | 1215 }; |
| 1193 | 1216 |
| 1194 // Defines the virtuals for a store register instruction. | 1217 // Defines the virtuals for a store register instruction. |
| 1195 class Store3RegisterOp : public LoadStore3RegisterOp { | 1218 class Store3RegisterOp : public LoadStore3RegisterOp { |
| 1196 public: | 1219 public: |
| 1197 Store3RegisterOp() : LoadStore3RegisterOp() { | 1220 Store3RegisterOp() : LoadStore3RegisterOp(false) { |
| 1198 is_load_ = false; | |
| 1199 } | 1221 } |
| 1200 virtual RegisterList defs(Instruction i) const; | 1222 virtual RegisterList defs(Instruction i) const; |
| 1201 | 1223 |
| 1202 private: | 1224 private: |
| 1203 NACL_DISALLOW_COPY_AND_ASSIGN(Store3RegisterOp); | 1225 NACL_DISALLOW_COPY_AND_ASSIGN(Store3RegisterOp); |
| 1204 }; | 1226 }; |
| 1205 | 1227 |
| 1206 // Models a 3-register load/store operation where the source/target is double | 1228 // Models a 3-register load/store operation where the source/target is double |
| 1207 // wide (i.e. Rt and Rt2). | 1229 // wide (i.e. Rt and Rt2). |
| 1208 class LoadStore3RegisterDoubleOp : public LoadStore3RegisterOp { | 1230 class LoadStore3RegisterDoubleOp : public LoadStore3RegisterOp { |
| 1209 public: | 1231 public: |
| 1210 // Interface for components in the instruction (and not inherited). | 1232 // Interface for components in the instruction (and not inherited). |
| 1211 static const RegBits12To15Plus1Interface t2; | 1233 static const RegBits12To15Plus1Interface t2; |
| 1212 | 1234 |
| 1213 LoadStore3RegisterDoubleOp() : LoadStore3RegisterOp() {} | |
| 1214 virtual SafetyLevel safety(Instruction i) const; | 1235 virtual SafetyLevel safety(Instruction i) const; |
| 1215 | 1236 |
| 1237 protected: |
| 1238 // TODO(jfb) Remove friend? It looks like its usage of the protected |
| 1239 // ctor shouldn't be. |
| 1240 friend class nacl_arm_test::LoadStore3RegisterDoubleOpTester; |
| 1241 explicit LoadStore3RegisterDoubleOp(bool is_load) |
| 1242 : LoadStore3RegisterOp(is_load) {} |
| 1243 |
| 1216 private: | 1244 private: |
| 1217 NACL_DISALLOW_COPY_AND_ASSIGN(LoadStore3RegisterDoubleOp); | 1245 NACL_DISALLOW_DEFAULT_COPY_AND_ASSIGN(LoadStore3RegisterDoubleOp); |
| 1218 }; | 1246 }; |
| 1219 | 1247 |
| 1220 // Defines the virtuals for a load double register instruction | 1248 // Defines the virtuals for a load double register instruction |
| 1221 class Load3RegisterDoubleOp : public LoadStore3RegisterDoubleOp { | 1249 class Load3RegisterDoubleOp : public LoadStore3RegisterDoubleOp { |
| 1222 public: | 1250 public: |
| 1223 Load3RegisterDoubleOp() : LoadStore3RegisterDoubleOp() { | 1251 Load3RegisterDoubleOp() : LoadStore3RegisterDoubleOp(true) { |
| 1224 is_load_ = true; | |
| 1225 } | 1252 } |
| 1226 virtual RegisterList defs(Instruction i) const; | 1253 virtual RegisterList defs(Instruction i) const; |
| 1227 | 1254 |
| 1228 private: | 1255 private: |
| 1229 NACL_DISALLOW_COPY_AND_ASSIGN(Load3RegisterDoubleOp); | 1256 NACL_DISALLOW_COPY_AND_ASSIGN(Load3RegisterDoubleOp); |
| 1230 }; | 1257 }; |
| 1231 | 1258 |
| 1232 // Defines the virtuals for s store double register instruction. | 1259 // Defines the virtuals for s store double register instruction. |
| 1233 class Store3RegisterDoubleOp : public LoadStore3RegisterDoubleOp { | 1260 class Store3RegisterDoubleOp : public LoadStore3RegisterDoubleOp { |
| 1234 public: | 1261 public: |
| 1235 Store3RegisterDoubleOp() : LoadStore3RegisterDoubleOp() { | 1262 Store3RegisterDoubleOp() : LoadStore3RegisterDoubleOp(false) { |
| 1236 is_load_ = false; | |
| 1237 } | 1263 } |
| 1238 virtual RegisterList defs(Instruction i) const; | 1264 virtual RegisterList defs(Instruction i) const; |
| 1239 | 1265 |
| 1240 private: | 1266 private: |
| 1241 NACL_DISALLOW_COPY_AND_ASSIGN(Store3RegisterDoubleOp); | 1267 NACL_DISALLOW_COPY_AND_ASSIGN(Store3RegisterDoubleOp); |
| 1242 }; | 1268 }; |
| 1243 | 1269 |
| 1244 // Models a 2-register store (exclusive) operation with a register to hold the | 1270 // Models a 2-register store (exclusive) operation with a register to hold the |
| 1245 // status of the update. | 1271 // status of the update. |
| 1246 // Op<c><q> <Rd>, <Rt>, [<Rn>] | 1272 // Op<c><q> <Rd>, <Rt>, [<Rn>] |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1302 // | cond | | P| U| | W| | Rm | Rt | imm5 |type| | Rm | | 1328 // | cond | | P| U| | W| | Rm | Rt | imm5 |type| | Rm | |
| 1303 // +------+------+--+--+--+--+--+--------+--------+----------+----+--+---------+ | 1329 // +------+------+--+--+--+--+--+--------+--------+----------+----+--+---------+ |
| 1304 // wback = (P=0 || W=1) | 1330 // wback = (P=0 || W=1) |
| 1305 // | 1331 // |
| 1306 // If P=0 and W=1, should not parse as this instruction. | 1332 // If P=0 and W=1, should not parse as this instruction. |
| 1307 // If Rm=15 then unpredicatble. | 1333 // If Rm=15 then unpredicatble. |
| 1308 // If wback && (Rn=15 or Rn=Rt) then unpredictable. | 1334 // If wback && (Rn=15 or Rn=Rt) then unpredictable. |
| 1309 // if ArchVersion() < 6 && wback && Rm=Rn then unpredictable. | 1335 // if ArchVersion() < 6 && wback && Rm=Rn then unpredictable. |
| 1310 // NaCl Disallows writing to PC. | 1336 // NaCl Disallows writing to PC. |
| 1311 // | 1337 // |
| 1312 // Note: We NaCl disallow Rt=PC for stores (not just loads), even | 1338 // Note: NaCl disallows Rt=PC for stores (not just loads), even |
| 1313 // though it isn't a requirement of the corresponding baseline | 1339 // though it isn't a requirement of the corresponding baseline |
| 1314 // classes. This is done so that StrRegister (in the actual class | 1340 // classes. This is done so that StrRegister (in the actual class |
| 1315 // decoders) behave the same as this. This simplifies what we need to | 1341 // decoders) behave the same as this. This simplifies what we need to |
| 1316 // model in actual classes. | 1342 // model in actual classes. |
| 1317 class LoadStore3RegisterImm5Op : public ClassDecoder { | 1343 class LoadStore3RegisterImm5Op : public ClassDecoder { |
| 1318 public: | 1344 public: |
| 1319 // Interfaces for components in the instruction. | 1345 // Interfaces for components in the instruction. |
| 1320 static const RegBits0To3Interface m; | 1346 static const RegBits0To3Interface m; |
| 1321 static const RegBits12To15Interface t; | 1347 static const RegBits12To15Interface t; |
| 1322 static const RegBits16To19Interface n; | 1348 static const RegBits16To19Interface n; |
| 1323 static const WritesBit21Interface writes; | 1349 static const WritesBit21Interface writes; |
| 1324 static const AddOffsetBit23Interface direction; | 1350 static const AddOffsetBit23Interface direction; |
| 1325 static const PrePostIndexingBit24Interface indexing; | 1351 static const PrePostIndexingBit24Interface indexing; |
| 1326 static const ConditionBits28To31Interface cond; | 1352 static const ConditionBits28To31Interface cond; |
| 1327 static const ShiftTypeBits5To6Interface shift_type; | 1353 static const ShiftTypeBits5To6Interface shift_type; |
| 1328 static const Imm5Bits7To11Interface imm; | 1354 static const Imm5Bits7To11Interface imm; |
| 1329 | 1355 |
| 1330 LoadStore3RegisterImm5Op() : ClassDecoder(), is_load_(false) {} | |
| 1331 virtual SafetyLevel safety(Instruction i) const; | 1356 virtual SafetyLevel safety(Instruction i) const; |
| 1332 virtual Register base_address_register(const Instruction i) const; | 1357 virtual Register base_address_register(const Instruction i) const; |
| 1333 | 1358 |
| 1334 bool HasWriteBack(const Instruction i) const { | 1359 bool HasWriteBack(const Instruction i) const { |
| 1335 return indexing.IsPostIndexing(i) || writes.IsDefined(i); | 1360 return indexing.IsPostIndexing(i) || writes.IsDefined(i); |
| 1336 } | 1361 } |
| 1337 | 1362 |
| 1338 // The immediate value stored in the instruction. | 1363 // The immediate value stored in the instruction. |
| 1339 uint32_t ImmediateValue(const Instruction& i) const { | 1364 uint32_t ImmediateValue(const Instruction& i) const { |
| 1340 return shift_type.DecodeImmShift(i, imm.value(i)); | 1365 return shift_type.DecodeImmShift(i, imm.value(i)); |
| 1341 } | 1366 } |
| 1342 | 1367 |
| 1343 protected: | 1368 protected: |
| 1369 // TODO(jfb) Remove friend? It looks like its usage of the protected |
| 1370 // ctor shouldn't be. |
| 1371 friend class nacl_arm_test::LoadStore3RegisterImm5OpTester; |
| 1372 explicit LoadStore3RegisterImm5Op(bool is_load) |
| 1373 : ClassDecoder(), is_load_(is_load) {} |
| 1344 bool is_load_; // true if load (rather than store). | 1374 bool is_load_; // true if load (rather than store). |
| 1345 | 1375 |
| 1346 private: | 1376 private: |
| 1347 NACL_DISALLOW_COPY_AND_ASSIGN(LoadStore3RegisterImm5Op); | 1377 NACL_DISALLOW_DEFAULT_COPY_AND_ASSIGN(LoadStore3RegisterImm5Op); |
| 1348 }; | 1378 }; |
| 1349 | 1379 |
| 1350 // Defines the virtuals for a load register instruction. | 1380 // Defines the virtuals for a load register instruction. |
| 1351 class Load3RegisterImm5Op : public LoadStore3RegisterImm5Op { | 1381 class Load3RegisterImm5Op : public LoadStore3RegisterImm5Op { |
| 1352 public: | 1382 public: |
| 1353 Load3RegisterImm5Op() : LoadStore3RegisterImm5Op() { | 1383 Load3RegisterImm5Op() : LoadStore3RegisterImm5Op(true) { |
| 1354 is_load_ = true; | |
| 1355 } | 1384 } |
| 1356 virtual RegisterList defs(Instruction i) const; | 1385 virtual RegisterList defs(Instruction i) const; |
| 1357 | 1386 |
| 1358 private: | 1387 private: |
| 1359 NACL_DISALLOW_COPY_AND_ASSIGN(Load3RegisterImm5Op); | 1388 NACL_DISALLOW_COPY_AND_ASSIGN(Load3RegisterImm5Op); |
| 1360 }; | 1389 }; |
| 1361 | 1390 |
| 1362 // Defines the virtuals for a store register instruction. | 1391 // Defines the virtuals for a store register instruction. |
| 1363 class Store3RegisterImm5Op : public LoadStore3RegisterImm5Op { | 1392 class Store3RegisterImm5Op : public LoadStore3RegisterImm5Op { |
| 1364 public: | 1393 public: |
| 1365 Store3RegisterImm5Op() : LoadStore3RegisterImm5Op() { | 1394 Store3RegisterImm5Op() : LoadStore3RegisterImm5Op(false) { |
| 1366 is_load_ = false; | |
| 1367 } | 1395 } |
| 1368 virtual RegisterList defs(Instruction i) const; | 1396 virtual RegisterList defs(Instruction i) const; |
| 1369 | 1397 |
| 1370 private: | 1398 private: |
| 1371 NACL_DISALLOW_COPY_AND_ASSIGN(Store3RegisterImm5Op); | 1399 NACL_DISALLOW_COPY_AND_ASSIGN(Store3RegisterImm5Op); |
| 1372 }; | 1400 }; |
| 1373 | 1401 |
| 1374 // Models a 2-register immediate-shifted unary operation of the form: | 1402 // Models a 2-register immediate-shifted unary operation of the form: |
| 1375 // Op(S)<c> <Rd>, <Rm> {,<shift>} | 1403 // Op(S)<c> <Rd>, <Rm> {,<shift>} |
| 1376 // +--------+--------------+--+--------+--------+----------+----+--+--------+ | 1404 // +--------+--------------+--+--------+--------+----------+----+--+--------+ |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1985 virtual SafetyLevel safety(Instruction i) const; | 2013 virtual SafetyLevel safety(Instruction i) const; |
| 1986 | 2014 |
| 1987 uint32_t be_value(const Instruction& i) const { | 2015 uint32_t be_value(const Instruction& i) const { |
| 1988 return (b.value(i) << 1) | e.value(i); | 2016 return (b.value(i) << 1) | e.value(i); |
| 1989 } | 2017 } |
| 1990 }; | 2018 }; |
| 1991 | 2019 |
| 1992 } // namespace nacl_arm_dec | 2020 } // namespace nacl_arm_dec |
| 1993 | 2021 |
| 1994 #endif // NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_BASELINE_CLASSES_H_ | 2022 #endif // NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_BASELINE_CLASSES_H_ |
| OLD | NEW |