Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: src/trusted/validator_arm/baseline_classes.h

Issue 10459058: Define a baseline and testing patterns for ARM load_store_word_byte table. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/trusted/validator_arm/armv7.table ('k') | src/trusted/validator_arm/baseline_classes.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 // Methods for class. 316 // Methods for class.
317 inline Binary3RegisterOp() : ClassDecoder() {} 317 inline Binary3RegisterOp() : ClassDecoder() {}
318 virtual ~Binary3RegisterOp() {} 318 virtual ~Binary3RegisterOp() {}
319 virtual SafetyLevel safety(Instruction i) const; 319 virtual SafetyLevel safety(Instruction i) const;
320 virtual RegisterList defs(Instruction i) const; 320 virtual RegisterList defs(Instruction i) const;
321 321
322 private: 322 private:
323 NACL_DISALLOW_COPY_AND_ASSIGN(Binary3RegisterOp); 323 NACL_DISALLOW_COPY_AND_ASSIGN(Binary3RegisterOp);
324 }; 324 };
325 325
326 // Models a 2-register load/store immediate operation of the forms: 326 // Models a 2-register load/store 8-bit immediate operation of the forms:
327 // Op<c> <Rt>, [<Rn>{, #+/-<imm8>}] 327 // Op<c> <Rt>, [<Rn>{, #+/-<imm8>}]
328 // Op<c> <Rt>, [<Rn>], #+/-<imm8> 328 // Op<c> <Rt>, [<Rn>], #+/-<imm8>
329 // Op<c> <Rt>, [<Rn>, #+/-<imm8>]! 329 // Op<c> <Rt>, [<Rn>, #+/-<imm8>]!
330 // +--------+------+--+--+--+--+--+--------+--------+--------+--------+--------+ 330 // +--------+------+--+--+--+--+--+--------+--------+--------+--------+--------+
331 // |31302928|272625|24|23|22|21|20|19181716|15141312|1110 9 8| 7 6 5 4| 3 2 1 0| 331 // |31302928|272625|24|23|22|21|20|19181716|15141312|1110 9 8| 7 6 5 4| 3 2 1 0|
332 // +--------+------+--+--+--+--+--+--------+--------+--------+--------+--------+ 332 // +--------+------+--+--+--+--+--+--------+--------+--------+--------+--------+
333 // | cond | | P| U| | W| | Rn | Rt | imm4H | | imm4L | 333 // | cond | | P| U| | W| | Rn | Rt | imm4H | | imm4L |
334 // +--------+------+--+--+--+--+--+--------+--------+--------+--------+--------+ 334 // +--------+------+--+--+--+--+--+--------+--------+--------+--------+--------+
335 // wback = (P=0 || W=1) 335 // wback = (P=0 || W=1)
336 // 336 //
337 // if P=0 and W=1, should not parse as this instruction. 337 // if P=0 and W=1, should not parse as this instruction.
338 // if Rt=15 then Unpredictable 338 // if Rt=15 then Unpredictable
339 // if wback && (Rn=15 or Rn=Rt) then unpredictable. 339 // if wback && (Rn=15 or Rn=Rt) then unpredictable.
340 // NaCl disallows writing to PC. 340 // NaCl disallows writing to PC.
341 class LoadStore2RegisterImmediateOp : public ClassDecoder { 341 class LoadStore2RegisterImm8Op : public ClassDecoder {
342 public: 342 public:
343 static const Imm4Bits0To3Interface imm4L; 343 static const Imm4Bits0To3Interface imm4L;
344 static const Imm4Bits8To11Interface imm4H; 344 static const Imm4Bits8To11Interface imm4H;
345 static const RegTBits12To15Interface t; 345 static const RegTBits12To15Interface t;
346 static const RegNBits16To19Interface n; 346 static const RegNBits16To19Interface n;
347 static const WritesBit21Interface writes; 347 static const WritesBit21Interface writes;
348 static const AddOffsetBit23Interface direction; 348 static const AddOffsetBit23Interface direction;
349 static const PrePostIndexingBit24Interface indexing; 349 static const PrePostIndexingBit24Interface indexing;
350 static const ConditionBits28To31Interface cond; 350 static const ConditionBits28To31Interface cond;
351 inline LoadStore2RegisterImmediateOp() : ClassDecoder() {} 351 inline LoadStore2RegisterImm8Op() : ClassDecoder(), is_load_(false) {}
352 virtual ~LoadStore2RegisterImmediateOp() {} 352 virtual ~LoadStore2RegisterImm8Op() {}
353 virtual SafetyLevel safety(Instruction i) const; 353 virtual SafetyLevel safety(Instruction i) const;
354 virtual RegisterList immediate_addressing_defs(Instruction i) const; 354 virtual RegisterList immediate_addressing_defs(Instruction i) const;
355 virtual Register base_address_register(const Instruction i) const; 355 virtual Register base_address_register(const Instruction i) const;
356 inline bool HasWriteBack(const Instruction i) const { 356 inline bool HasWriteBack(const Instruction i) const {
357 return indexing.IsPostIndexing(i) || writes.IsDefined(i); 357 return indexing.IsPostIndexing(i) || writes.IsDefined(i);
358 } 358 }
359 359
360 protected:
361 bool is_load_; // true if load (rather than store).
362
360 private: 363 private:
361 NACL_DISALLOW_COPY_AND_ASSIGN(LoadStore2RegisterImmediateOp); 364 NACL_DISALLOW_COPY_AND_ASSIGN(LoadStore2RegisterImm8Op);
362 }; 365 };
363 366
364 // Defines the virtuals for a load immediate instruction. 367 // Defines the virtuals for a load immediate instruction.
365 class Load2RegisterImmediateOp : public LoadStore2RegisterImmediateOp { 368 class Load2RegisterImm8Op : public LoadStore2RegisterImm8Op {
366 public: 369 public:
367 inline Load2RegisterImmediateOp() : LoadStore2RegisterImmediateOp() {} 370 inline Load2RegisterImm8Op() : LoadStore2RegisterImm8Op() {
368 virtual ~Load2RegisterImmediateOp() {} 371 is_load_ = true;
372 }
373 virtual ~Load2RegisterImm8Op() {}
369 virtual RegisterList defs(Instruction i) const; 374 virtual RegisterList defs(Instruction i) const;
370 virtual bool offset_is_immediate(Instruction i) const; 375 virtual bool offset_is_immediate(Instruction i) const;
371 376
372 private: 377 private:
373 NACL_DISALLOW_COPY_AND_ASSIGN(Load2RegisterImmediateOp); 378 NACL_DISALLOW_COPY_AND_ASSIGN(Load2RegisterImm8Op);
374 }; 379 };
375 380
376 // Defines the virtuals for a store immediate instruction. 381 // Defines the virtuals for a store immediate instruction.
377 class Store2RegisterImmediateOp : public LoadStore2RegisterImmediateOp { 382 class Store2RegisterImm8Op : public LoadStore2RegisterImm8Op {
378 public: 383 public:
379 inline Store2RegisterImmediateOp() : LoadStore2RegisterImmediateOp() {} 384 inline Store2RegisterImm8Op() : LoadStore2RegisterImm8Op() {
380 virtual ~Store2RegisterImmediateOp() {} 385 is_load_ = false;
386 }
387 virtual ~Store2RegisterImm8Op() {}
381 virtual RegisterList defs(Instruction i) const; 388 virtual RegisterList defs(Instruction i) const;
382 389
383 protected: 390 protected:
384 NACL_DISALLOW_COPY_AND_ASSIGN(Store2RegisterImmediateOp); 391 NACL_DISALLOW_COPY_AND_ASSIGN(Store2RegisterImm8Op);
385 }; 392 };
386 393
387 // Models a 2-register immediate load/store operation where the source/target 394 // Models a 2-register immediate load/store operation where the source/target
388 // is double wide (i.e. Rt and Rt2). 395 // is double wide (i.e. Rt and Rt2).
389 class LoadStore2RegisterImmediateDoubleOp 396 class LoadStore2RegisterImm8DoubleOp
390 : public LoadStore2RegisterImmediateOp { 397 : public LoadStore2RegisterImm8Op {
391 public: 398 public:
392 // Interface for components in the instruction (and not inherited). 399 // Interface for components in the instruction (and not inherited).
393 static const RegT2Bits12To15Interface t2; 400 static const RegT2Bits12To15Interface t2;
394 401
395 LoadStore2RegisterImmediateDoubleOp() 402 LoadStore2RegisterImm8DoubleOp()
396 : LoadStore2RegisterImmediateOp() {} 403 : LoadStore2RegisterImm8Op() {}
397 virtual ~LoadStore2RegisterImmediateDoubleOp() {} 404 virtual ~LoadStore2RegisterImm8DoubleOp() {}
398 virtual SafetyLevel safety(Instruction i) const; 405 virtual SafetyLevel safety(Instruction i) const;
399 406
400 private: 407 private:
401 NACL_DISALLOW_COPY_AND_ASSIGN(LoadStore2RegisterImmediateDoubleOp); 408 NACL_DISALLOW_COPY_AND_ASSIGN(LoadStore2RegisterImm8DoubleOp);
402 }; 409 };
403 410
404 // Defines the virtuals for a load immediate double instruction. 411 // Defines the virtuals for a load immediate double instruction.
405 class Load2RegisterImmediateDoubleOp 412 class Load2RegisterImm8DoubleOp
406 : public LoadStore2RegisterImmediateDoubleOp { 413 : public LoadStore2RegisterImm8DoubleOp {
407 public: 414 public:
408 inline Load2RegisterImmediateDoubleOp() 415 inline Load2RegisterImm8DoubleOp() : LoadStore2RegisterImm8DoubleOp() {
409 : LoadStore2RegisterImmediateDoubleOp() {} 416 is_load_ = true;
410 virtual ~Load2RegisterImmediateDoubleOp() {} 417 }
418 virtual ~Load2RegisterImm8DoubleOp() {}
411 virtual RegisterList defs(Instruction i) const; 419 virtual RegisterList defs(Instruction i) const;
412 virtual bool offset_is_immediate(Instruction i) const; 420 virtual bool offset_is_immediate(Instruction i) const;
413 421
414 private: 422 private:
415 NACL_DISALLOW_COPY_AND_ASSIGN(Load2RegisterImmediateDoubleOp); 423 NACL_DISALLOW_COPY_AND_ASSIGN(Load2RegisterImm8DoubleOp);
416 }; 424 };
417 425
418 // Defines the virtuals for a store immediate double instruction. 426 // Defines the virtuals for a store immediate double instruction.
419 class Store2RegisterImmediateDoubleOp 427 class Store2RegisterImm8DoubleOp
420 : public LoadStore2RegisterImmediateDoubleOp { 428 : public LoadStore2RegisterImm8DoubleOp {
421 public: 429 public:
422 inline Store2RegisterImmediateDoubleOp() 430 inline Store2RegisterImm8DoubleOp()
423 : LoadStore2RegisterImmediateDoubleOp() {} 431 : LoadStore2RegisterImm8DoubleOp() {
424 virtual ~Store2RegisterImmediateDoubleOp() {} 432 is_load_ = false;
433 }
434 virtual ~Store2RegisterImm8DoubleOp() {}
425 virtual RegisterList defs(Instruction i) const; 435 virtual RegisterList defs(Instruction i) const;
426 436
427 protected: 437 protected:
428 NACL_DISALLOW_COPY_AND_ASSIGN(Store2RegisterImmediateDoubleOp); 438 NACL_DISALLOW_COPY_AND_ASSIGN(Store2RegisterImm8DoubleOp);
439 };
440
441 // Models a 2-register load/store 12-bit immediate operation of the forms:
442 // Op<c> <Rt>, [<Rn> {, #+/-<imm12>}]
443 // Op<c> <Rt>, [<Rn>], #+/-<imm12>
444 // Op<c> <Rt>, [<Rn>, #+/-<imm12>]
445 // +--------+------+--+--+--+--+--+--------+--------+------------------------+
446 // |31302928|272625|24|23|22|21|20|19181716|15141312|1110 9 8 7 6 5 4 3 2 1 0|
447 // +--------+------+--+--+--+--+--+--------+--------+------------------------+
448 // | conds | | P| U| | w| | Rn | Rt | imm12 |
449 // +--------+------+--+--+--+--+--+--------+--------+------------------------+
450 // wback = (P=0 || W==1)
451 //
452 // if P=0 and W=1, should not parse as this instruction.
453 // if wback && (Rn=15 or Rn=Rt) then unpredictable.
454 // NaCl disallows writing to PC.
455 //
456 // Note: NaCl disallows Rt=PC for stores (not just loads), even
457 // though it isn't a requirement of the corresponding baseline
458 // classees. This is done so that StrImmediate (in the actual class
459 // decoders) behave the same as instances of this. This simplifies
460 // what we need to model in actual classes.
461 //
462 // For store register immediate (Str rule 194, A1 on page 384):
463 // if Rn=Sp && P=1 && U=0 && W=1 && imm12=4, then PUSH (A8.6.123, A2 on A8-248).
464 // Note: This is just a special case instruction that behaves like a
465 // Store2RegisterImm12Op instruction. That is, the push saves the
466 // value of Rt at Sp-4, and then decrements sp by 4. Since this doesn't
467 // effect the NaCl constraints we need for such stores, we do not model
468 // it as a special instruction.
469 //
470 // For load register immediate (Ldr rule 59, A1 on page 122):
471 // If Rn=Sp && P=0 && U=1 && W=0 && imm12=4, then POP ().
472 // Note: This is just a speciial case instruction that behaves like a
473 // Load2RegisterImm12Op instruction. That is, the pop loads from the
474 // top of stack the value of Rt, and then increments the stack by 4. Since
475 // this doesn't effect the NaCl constraints we need for such loads, we do
476 // not model it as a special instruction.
477 class LoadStore2RegisterImm12Op : public ClassDecoder {
478 public:
479 static const Imm12Bits0To11Interface imm12;
480 static const RegTBits12To15Interface t;
481 static const RegNBits16To19Interface n;
482 static const WritesBit21Interface writes;
483 static const AddOffsetBit23Interface direction;
484 static const PrePostIndexingBit24Interface indexing;
485 static const ConditionBits28To31Interface cond;
486 inline LoadStore2RegisterImm12Op() : ClassDecoder() , is_load_(false) {}
487 virtual ~LoadStore2RegisterImm12Op() {}
488 virtual SafetyLevel safety(Instruction i) const;
489 virtual RegisterList immediate_addressing_defs(Instruction i) const;
490 virtual Register base_address_register(const Instruction i) const;
491 inline bool HasWriteBack(const Instruction i) const {
492 return indexing.IsPostIndexing(i) || writes.IsDefined(i);
493 }
494
495 protected:
496 bool is_load_; // true if load (rather than store).
497
498 private:
499 NACL_DISALLOW_COPY_AND_ASSIGN(LoadStore2RegisterImm12Op);
500 };
501
502 // Defines the virtuals for a load immediate instruction.
503 class Load2RegisterImm12Op : public LoadStore2RegisterImm12Op {
504 public:
505 inline Load2RegisterImm12Op() : LoadStore2RegisterImm12Op() {
506 is_load_ = true;
507 }
508 virtual ~Load2RegisterImm12Op() {}
509 virtual RegisterList defs(Instruction i) const;
510 virtual bool offset_is_immediate(Instruction i) const;
511
512 private:
513 NACL_DISALLOW_COPY_AND_ASSIGN(Load2RegisterImm12Op);
514 };
515
516 // Defines the virtuals for a store immediate instruction.
517 // Note: See class LoadStore2RegisterImm12Op for more information
518 // on how PUSH (i.e. when Rn=Sp && U=0 && W=1 && Imm12=4) is handled.
519 class Store2RegisterImm12Op : public LoadStore2RegisterImm12Op {
520 public:
521 inline Store2RegisterImm12Op() : LoadStore2RegisterImm12Op() {
522 is_load_ = false;
523 }
524 virtual ~Store2RegisterImm12Op() {}
525 virtual RegisterList defs(Instruction i) const;
526
527 protected:
528 NACL_DISALLOW_COPY_AND_ASSIGN(Store2RegisterImm12Op);
429 }; 529 };
430 530
431 // Models a 3-register binary operation of the form: 531 // Models a 3-register binary operation of the form:
432 // Op(S)<c> <Rd>, <Rn>, <Rm> 532 // Op(S)<c> <Rd>, <Rn>, <Rm>
433 // +--------+--------------+--+--------+--------+--------+--------+--------+ 533 // +--------+--------------+--+--------+--------+--------+--------+--------+
434 // |31302928|27262524232221|20|19181716|15141312|1110 9 8| 7 6 5 4| 3 2 1 0| 534 // |31302928|27262524232221|20|19181716|15141312|1110 9 8| 7 6 5 4| 3 2 1 0|
435 // +--------+--------------+--+--------+--------+--------+--------+--------+ 535 // +--------+--------------+--+--------+--------+--------+--------+--------+
436 // | cond | | S| Rd | | Rm | | Rn | 536 // | cond | | S| Rd | | Rm | | Rn |
437 // +--------+--------------+--+--------+--------+--------+--------+--------+ 537 // +--------+--------------+--+--------+--------+--------+--------+--------+
438 // Definitions: 538 // Definitions:
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 public: 700 public:
601 // Interfaces for components in the instruction. 701 // Interfaces for components in the instruction.
602 static const RegMBits0To3Interface m; 702 static const RegMBits0To3Interface m;
603 static const RegTBits12To15Interface t; 703 static const RegTBits12To15Interface t;
604 static const RegNBits16To19Interface n; 704 static const RegNBits16To19Interface n;
605 static const WritesBit21Interface writes; 705 static const WritesBit21Interface writes;
606 static const AddOffsetBit23Interface direction; 706 static const AddOffsetBit23Interface direction;
607 static const PrePostIndexingBit24Interface indexing; 707 static const PrePostIndexingBit24Interface indexing;
608 static const ConditionBits28To31Interface cond; 708 static const ConditionBits28To31Interface cond;
609 709
610 inline LoadStore3RegisterOp() : ClassDecoder() {} 710 inline LoadStore3RegisterOp() : ClassDecoder(), is_load_(false) {}
611 virtual ~LoadStore3RegisterOp() {} 711 virtual ~LoadStore3RegisterOp() {}
612 virtual SafetyLevel safety(Instruction i) const; 712 virtual SafetyLevel safety(Instruction i) const;
613 virtual Register base_address_register(const Instruction i) const; 713 virtual Register base_address_register(const Instruction i) const;
614 inline bool HasWriteBack(const Instruction i) const { 714 inline bool HasWriteBack(const Instruction i) const {
615 return indexing.IsPostIndexing(i) || writes.IsDefined(i); 715 return indexing.IsPostIndexing(i) || writes.IsDefined(i);
616 } 716 }
617 717
718 protected:
719 bool is_load_; // true if load (rather than store).
720
618 private: 721 private:
619 NACL_DISALLOW_COPY_AND_ASSIGN(LoadStore3RegisterOp); 722 NACL_DISALLOW_COPY_AND_ASSIGN(LoadStore3RegisterOp);
620 }; 723 };
621 724
622 // Defines the virtuals for a load register instruction. 725 // Defines the virtuals for a load register instruction.
623 class Load3RegisterOp : public LoadStore3RegisterOp { 726 class Load3RegisterOp : public LoadStore3RegisterOp {
624 public: 727 public:
625 inline Load3RegisterOp() : LoadStore3RegisterOp() {} 728 inline Load3RegisterOp() : LoadStore3RegisterOp() {
729 is_load_ = true;
730 }
626 virtual ~Load3RegisterOp() {} 731 virtual ~Load3RegisterOp() {}
627 virtual RegisterList defs(Instruction i) const; 732 virtual RegisterList defs(Instruction i) const;
628 733
629 private: 734 private:
630 NACL_DISALLOW_COPY_AND_ASSIGN(Load3RegisterOp); 735 NACL_DISALLOW_COPY_AND_ASSIGN(Load3RegisterOp);
631 }; 736 };
632 737
633 // Defines the virtuals for a store register instruction. 738 // Defines the virtuals for a store register instruction.
634 class Store3RegisterOp : public LoadStore3RegisterOp { 739 class Store3RegisterOp : public LoadStore3RegisterOp {
635 public: 740 public:
636 inline Store3RegisterOp() : LoadStore3RegisterOp() {} 741 inline Store3RegisterOp() : LoadStore3RegisterOp() {
742 is_load_ = false;
743 }
637 virtual ~Store3RegisterOp() {} 744 virtual ~Store3RegisterOp() {}
638 virtual RegisterList defs(Instruction i) const; 745 virtual RegisterList defs(Instruction i) const;
639 746
640 private: 747 private:
641 NACL_DISALLOW_COPY_AND_ASSIGN(Store3RegisterOp); 748 NACL_DISALLOW_COPY_AND_ASSIGN(Store3RegisterOp);
642 }; 749 };
643 750
644 // Models a 3-register load/store operation where the source/target is double 751 // Models a 3-register load/store operation where the source/target is double
645 // wide (i.e. Rt and Rt2). 752 // wide (i.e. Rt and Rt2).
646 class LoadStore3RegisterDoubleOp : public LoadStore3RegisterOp { 753 class LoadStore3RegisterDoubleOp : public LoadStore3RegisterOp {
647 public: 754 public:
648 // Interface for components in the instruction (and not inherited). 755 // Interface for components in the instruction (and not inherited).
649 static const RegT2Bits12To15Interface t2; 756 static const RegT2Bits12To15Interface t2;
650 757
651 LoadStore3RegisterDoubleOp() : LoadStore3RegisterOp() {} 758 LoadStore3RegisterDoubleOp() : LoadStore3RegisterOp() {}
652 virtual ~LoadStore3RegisterDoubleOp() {} 759 virtual ~LoadStore3RegisterDoubleOp() {}
653 virtual SafetyLevel safety(Instruction i) const; 760 virtual SafetyLevel safety(Instruction i) const;
654 761
655 private: 762 private:
656 NACL_DISALLOW_COPY_AND_ASSIGN(LoadStore3RegisterDoubleOp); 763 NACL_DISALLOW_COPY_AND_ASSIGN(LoadStore3RegisterDoubleOp);
657 }; 764 };
658 765
659 // Defines the virtuals for a load double register instruction 766 // Defines the virtuals for a load double register instruction
660 class Load3RegisterDoubleOp : public LoadStore3RegisterDoubleOp { 767 class Load3RegisterDoubleOp : public LoadStore3RegisterDoubleOp {
661 public: 768 public:
662 Load3RegisterDoubleOp() : LoadStore3RegisterDoubleOp() {} 769 Load3RegisterDoubleOp() : LoadStore3RegisterDoubleOp() {
770 is_load_ = true;
771 }
663 virtual ~Load3RegisterDoubleOp() {} 772 virtual ~Load3RegisterDoubleOp() {}
664 virtual RegisterList defs(Instruction i) const; 773 virtual RegisterList defs(Instruction i) const;
665 774
666 private: 775 private:
667 NACL_DISALLOW_COPY_AND_ASSIGN(Load3RegisterDoubleOp); 776 NACL_DISALLOW_COPY_AND_ASSIGN(Load3RegisterDoubleOp);
668 }; 777 };
669 778
670 // Defines the virtuals for s store double register instruction. 779 // Defines the virtuals for s store double register instruction.
671 class Store3RegisterDoubleOp : public LoadStore3RegisterDoubleOp { 780 class Store3RegisterDoubleOp : public LoadStore3RegisterDoubleOp {
672 public: 781 public:
673 Store3RegisterDoubleOp() : LoadStore3RegisterDoubleOp() {} 782 Store3RegisterDoubleOp() : LoadStore3RegisterDoubleOp() {
783 is_load_ = false;
784 }
674 virtual ~Store3RegisterDoubleOp() {} 785 virtual ~Store3RegisterDoubleOp() {}
675 virtual RegisterList defs(Instruction i) const; 786 virtual RegisterList defs(Instruction i) const;
676 787
677 private: 788 private:
678 NACL_DISALLOW_COPY_AND_ASSIGN(Store3RegisterDoubleOp); 789 NACL_DISALLOW_COPY_AND_ASSIGN(Store3RegisterDoubleOp);
679 }; 790 };
680 791
792 // Models a 3-register with (shifted) immediate 5 load/store operation of
793 // the forms:
794 // Op<c> <Rt>, [<Rn>, +/-<Rm> {, <shift>}]{!}
795 // Op<c> <Rt>, [<Rn>], +-<Rm> {, <shift>}
796 // +------+------+--+--+--+--+--+--------+--------+----------+----+--+---------+
797 // |31..28|272625|24|23|22|21|20|19181716|15141312|1110 9 8 7| 6 5| 4| 3 2 1 0 |
798 // +------+------+--+--+--+--+--+--------+--------+----------+----+--+---------+
799 // | cond | | P| U| | W| | Rm | Rt | imm5 |type| | Rm |
800 // +------+------+--+--+--+--+--+--------+--------+----------+----+--+---------+
801 // wback = (P=0 || W=1)
802 //
803 // If P=0 and W=1, should not parse as this instruction.
804 // If Rm=15 then unpredicatble.
805 // If wback && (Rn=15 or Rn=Rt) then unpredictable.
806 // if ArchVersion() < 6 && wback && Rm=Rn then unpredictable.
807 // NaCl Disallows writing to PC.
808 //
809 // Note: We NaCl disallow Rt=PC for stores (not just loads), even
810 // though it isn't a requirement of the corresponding baseline
811 // classes. This is done so that StrRegister (in the actual class
812 // decoders) behave the same as this. This simplifies what we need to
813 // model in actual classes.
814 class LoadStore3RegisterImm5Op : public ClassDecoder {
815 public:
816 // Interfaces for components in the instruction.
817 static const RegMBits0To3Interface m;
818 static const RegTBits12To15Interface t;
819 static const RegNBits16To19Interface n;
820 static const WritesBit21Interface writes;
821 static const AddOffsetBit23Interface direction;
822 static const PrePostIndexingBit24Interface indexing;
823 static const ConditionBits28To31Interface cond;
824 static const ShiftTypeBits5To6Interface shift_type;
825 static const Imm5Bits7To11Interface imm;
826
827 inline LoadStore3RegisterImm5Op() : ClassDecoder(), is_load_(false) {}
828 virtual ~LoadStore3RegisterImm5Op() {}
829 virtual SafetyLevel safety(Instruction i) const;
830 virtual Register base_address_register(const Instruction i) const;
831 inline bool HasWriteBack(const Instruction i) const {
832 return indexing.IsPostIndexing(i) || writes.IsDefined(i);
833 }
834
835 // The immediate value stored in the instruction.
836 inline uint32_t ImmediateValue(const Instruction& i) const {
837 return shift_type.DecodeImmShift(i, imm.value(i));
838 }
839
840 protected:
841 bool is_load_; // true if load (rather than store).
842
843 private:
844 NACL_DISALLOW_COPY_AND_ASSIGN(LoadStore3RegisterImm5Op);
845 };
846
847 // Defines the virtuals for a load register instruction.
848 class Load3RegisterImm5Op : public LoadStore3RegisterImm5Op {
849 public:
850 inline Load3RegisterImm5Op() : LoadStore3RegisterImm5Op() {
851 is_load_ = true;
852 }
853 virtual ~Load3RegisterImm5Op() {}
854 virtual RegisterList defs(Instruction i) const;
855
856 private:
857 NACL_DISALLOW_COPY_AND_ASSIGN(Load3RegisterImm5Op);
858 };
859
860 // Defines the virtuals for a store register instruction.
861 class Store3RegisterImm5Op : public LoadStore3RegisterImm5Op {
862 public:
863 inline Store3RegisterImm5Op() : LoadStore3RegisterImm5Op() {
864 is_load_ = false;
865 }
866 virtual ~Store3RegisterImm5Op() {}
867 virtual RegisterList defs(Instruction i) const;
868
869 private:
870 NACL_DISALLOW_COPY_AND_ASSIGN(Store3RegisterImm5Op);
871 };
872
681 // Models a 2-register immediate-shifted unary operation of the form: 873 // Models a 2-register immediate-shifted unary operation of the form:
682 // Op(S)<c> <Rd>, <Rm> {,<shift>} 874 // Op(S)<c> <Rd>, <Rm> {,<shift>}
683 // +--------+--------------+--+--------+--------+----------+----+--+--------+ 875 // +--------+--------------+--+--------+--------+----------+----+--+--------+
684 // |31302928|27262524232221|20|19181716|15141312|1110 9 8 7| 6 5| 4| 3 2 1 0| 876 // |31302928|27262524232221|20|19181716|15141312|1110 9 8 7| 6 5| 4| 3 2 1 0|
685 // +--------+--------------+--+--------+--------+----------+----+--+--------+ 877 // +--------+--------------+--+--------+--------+----------+----+--+--------+
686 // | cond | | S| | Rd | imm5 |type| | Rm | 878 // | cond | | S| | Rd | imm5 |type| | Rm |
687 // +--------+--------------+--+--------+--------+----------+----+--+--------+ 879 // +--------+--------------+--+--------+--------+----------+----+--+--------+
688 // Definitions: 880 // Definitions:
689 // Rd - The destination register. 881 // Rd - The destination register.
690 // Rm - The source operand that is (optionally) shifted. 882 // Rm - The source operand that is (optionally) shifted.
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 virtual SafetyLevel safety(Instruction i) const; 1131 virtual SafetyLevel safety(Instruction i) const;
940 virtual RegisterList defs(Instruction i) const; 1132 virtual RegisterList defs(Instruction i) const;
941 1133
942 private: 1134 private:
943 NACL_DISALLOW_COPY_AND_ASSIGN(Binary3RegisterShiftedTest); 1135 NACL_DISALLOW_COPY_AND_ASSIGN(Binary3RegisterShiftedTest);
944 }; 1136 };
945 1137
946 } // namespace 1138 } // namespace
947 1139
948 #endif // NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_BASELINE_CLASSES_H_ 1140 #endif // NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_BASELINE_CLASSES_H_
OLDNEW
« no previous file with comments | « src/trusted/validator_arm/armv7.table ('k') | src/trusted/validator_arm/baseline_classes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698