Chromium Code Reviews| 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" |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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: We NaCl disallow Rt=PC for stores (not just loads), even | |
|
sehr (please use chromium)
2012/06/05 20:16:20
NaCl disallows?
Karl
2012/06/05 20:42:16
Done.
| |
| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 566 public: | 666 public: |
| 567 // Interfaces for components in the instruction. | 667 // Interfaces for components in the instruction. |
| 568 static const RegMBits0To3Interface m; | 668 static const RegMBits0To3Interface m; |
| 569 static const RegTBits12To15Interface t; | 669 static const RegTBits12To15Interface t; |
| 570 static const RegNBits16To19Interface n; | 670 static const RegNBits16To19Interface n; |
| 571 static const WritesBit21Interface writes; | 671 static const WritesBit21Interface writes; |
| 572 static const AddOffsetBit23Interface direction; | 672 static const AddOffsetBit23Interface direction; |
| 573 static const PrePostIndexingBit24Interface indexing; | 673 static const PrePostIndexingBit24Interface indexing; |
| 574 static const ConditionBits28To31Interface cond; | 674 static const ConditionBits28To31Interface cond; |
| 575 | 675 |
| 576 inline LoadStore3RegisterOp() : ClassDecoder() {} | 676 inline LoadStore3RegisterOp() : ClassDecoder(), is_load_(false) {} |
| 577 virtual ~LoadStore3RegisterOp() {} | 677 virtual ~LoadStore3RegisterOp() {} |
| 578 virtual SafetyLevel safety(Instruction i) const; | 678 virtual SafetyLevel safety(Instruction i) const; |
| 579 virtual Register base_address_register(const Instruction i) const; | 679 virtual Register base_address_register(const Instruction i) const; |
| 580 inline bool HasWriteBack(const Instruction i) const { | 680 inline bool HasWriteBack(const Instruction i) const { |
| 581 return indexing.IsPostIndexing(i) || writes.IsDefined(i); | 681 return indexing.IsPostIndexing(i) || writes.IsDefined(i); |
| 582 } | 682 } |
| 583 | 683 |
| 684 protected: | |
| 685 bool is_load_; // true if load (rather than store). | |
| 686 | |
| 584 private: | 687 private: |
| 585 NACL_DISALLOW_COPY_AND_ASSIGN(LoadStore3RegisterOp); | 688 NACL_DISALLOW_COPY_AND_ASSIGN(LoadStore3RegisterOp); |
| 586 }; | 689 }; |
| 587 | 690 |
| 588 // Defines the virtuals for a load register instruction. | 691 // Defines the virtuals for a load register instruction. |
| 589 class Load3RegisterOp : public LoadStore3RegisterOp { | 692 class Load3RegisterOp : public LoadStore3RegisterOp { |
| 590 public: | 693 public: |
| 591 inline Load3RegisterOp() : LoadStore3RegisterOp() {} | 694 inline Load3RegisterOp() : LoadStore3RegisterOp() { |
| 695 is_load_ = true; | |
| 696 } | |
| 592 virtual ~Load3RegisterOp() {} | 697 virtual ~Load3RegisterOp() {} |
| 593 virtual RegisterList defs(Instruction i) const; | 698 virtual RegisterList defs(Instruction i) const; |
| 594 | 699 |
| 595 private: | 700 private: |
| 596 NACL_DISALLOW_COPY_AND_ASSIGN(Load3RegisterOp); | 701 NACL_DISALLOW_COPY_AND_ASSIGN(Load3RegisterOp); |
| 597 }; | 702 }; |
| 598 | 703 |
| 599 // Defines the virtuals for a store register instruction. | 704 // Defines the virtuals for a store register instruction. |
| 600 class Store3RegisterOp : public LoadStore3RegisterOp { | 705 class Store3RegisterOp : public LoadStore3RegisterOp { |
| 601 public: | 706 public: |
| 602 inline Store3RegisterOp() : LoadStore3RegisterOp() {} | 707 inline Store3RegisterOp() : LoadStore3RegisterOp() { |
| 708 is_load_ = false; | |
| 709 } | |
| 603 virtual ~Store3RegisterOp() {} | 710 virtual ~Store3RegisterOp() {} |
| 604 virtual RegisterList defs(Instruction i) const; | 711 virtual RegisterList defs(Instruction i) const; |
| 605 | 712 |
| 606 private: | 713 private: |
| 607 NACL_DISALLOW_COPY_AND_ASSIGN(Store3RegisterOp); | 714 NACL_DISALLOW_COPY_AND_ASSIGN(Store3RegisterOp); |
| 608 }; | 715 }; |
| 609 | 716 |
| 610 // Models a 3-register load/store operation where the source/target is double | 717 // Models a 3-register load/store operation where the source/target is double |
| 611 // wide (i.e. Rt and Rt2). | 718 // wide (i.e. Rt and Rt2). |
| 612 class LoadStore3RegisterDoubleOp : public LoadStore3RegisterOp { | 719 class LoadStore3RegisterDoubleOp : public LoadStore3RegisterOp { |
| 613 public: | 720 public: |
| 614 // Interface for components in the instruction (and not inherited). | 721 // Interface for components in the instruction (and not inherited). |
| 615 static const RegT2Bits12To15Interface t2; | 722 static const RegT2Bits12To15Interface t2; |
| 616 | 723 |
| 617 LoadStore3RegisterDoubleOp() : LoadStore3RegisterOp() {} | 724 LoadStore3RegisterDoubleOp() : LoadStore3RegisterOp() {} |
| 618 virtual ~LoadStore3RegisterDoubleOp() {} | 725 virtual ~LoadStore3RegisterDoubleOp() {} |
| 619 virtual SafetyLevel safety(Instruction i) const; | 726 virtual SafetyLevel safety(Instruction i) const; |
| 620 | 727 |
| 621 private: | 728 private: |
| 622 NACL_DISALLOW_COPY_AND_ASSIGN(LoadStore3RegisterDoubleOp); | 729 NACL_DISALLOW_COPY_AND_ASSIGN(LoadStore3RegisterDoubleOp); |
| 623 }; | 730 }; |
| 624 | 731 |
| 625 // Defines the virtuals for a load double register instruction | 732 // Defines the virtuals for a load double register instruction |
| 626 class Load3RegisterDoubleOp : public LoadStore3RegisterDoubleOp { | 733 class Load3RegisterDoubleOp : public LoadStore3RegisterDoubleOp { |
| 627 public: | 734 public: |
| 628 Load3RegisterDoubleOp() : LoadStore3RegisterDoubleOp() {} | 735 Load3RegisterDoubleOp() : LoadStore3RegisterDoubleOp() { |
| 736 is_load_ = true; | |
| 737 } | |
| 629 virtual ~Load3RegisterDoubleOp() {} | 738 virtual ~Load3RegisterDoubleOp() {} |
| 630 virtual RegisterList defs(Instruction i) const; | 739 virtual RegisterList defs(Instruction i) const; |
| 631 | 740 |
| 632 private: | 741 private: |
| 633 NACL_DISALLOW_COPY_AND_ASSIGN(Load3RegisterDoubleOp); | 742 NACL_DISALLOW_COPY_AND_ASSIGN(Load3RegisterDoubleOp); |
| 634 }; | 743 }; |
| 635 | 744 |
| 636 // Defines the virtuals for s store double register instruction. | 745 // Defines the virtuals for s store double register instruction. |
| 637 class Store3RegisterDoubleOp : public LoadStore3RegisterDoubleOp { | 746 class Store3RegisterDoubleOp : public LoadStore3RegisterDoubleOp { |
| 638 public: | 747 public: |
| 639 Store3RegisterDoubleOp() : LoadStore3RegisterDoubleOp() {} | 748 Store3RegisterDoubleOp() : LoadStore3RegisterDoubleOp() { |
| 749 is_load_ = false; | |
| 750 } | |
| 640 virtual ~Store3RegisterDoubleOp() {} | 751 virtual ~Store3RegisterDoubleOp() {} |
| 641 virtual RegisterList defs(Instruction i) const; | 752 virtual RegisterList defs(Instruction i) const; |
| 642 | 753 |
| 643 private: | 754 private: |
| 644 NACL_DISALLOW_COPY_AND_ASSIGN(Store3RegisterDoubleOp); | 755 NACL_DISALLOW_COPY_AND_ASSIGN(Store3RegisterDoubleOp); |
| 645 }; | 756 }; |
| 646 | 757 |
| 758 // Models a 3-register with (shifted) immediate 5 load/store operation of | |
| 759 // the forms: | |
| 760 // Op<c> <Rt>, [<Rn>, +/-<Rm> {, <shift>}]{!} | |
| 761 // Op<c> <Rt>, [<Rn>], +-<Rm> {, <shift>} | |
| 762 // +------+------+--+--+--+--+--+--------+--------+----------+----+--+---------+ | |
| 763 // |31..28|272625|24|23|22|21|20|19181716|15141312|1110 9 8 7| 6 5| 4| 3 2 1 0 | | |
| 764 // +------+------+--+--+--+--+--+--------+--------+----------+----+--+---------+ | |
| 765 // | cond | | P| U| | W| | Rm | Rt | imm5 |type| | Rm | | |
| 766 // +------+------+--+--+--+--+--+--------+--------+----------+----+--+---------+ | |
| 767 // wback = (P=0 || W=1) | |
| 768 // | |
| 769 // If P=0 and W=1, should not parse as this instruction. | |
| 770 // If Rm=15 then unpredicatble. | |
| 771 // If wback && (Rn=15 or Rn=Rt) then unpredictable. | |
| 772 // if ArchVersion() < 6 && wback && Rm=Rn then unpredictable. | |
| 773 // NaCl Disallows writing to PC. | |
| 774 // | |
| 775 // Note: We NaCl disallow Rt=PC for stores (not just loads), even | |
| 776 // though it isn't a requirement of the corresponding baseline | |
| 777 // classes. This is done so that StrRegister (in the actual class | |
| 778 // decoders) behave the same as this. This simplifies what we need to | |
| 779 // model in actual classes. | |
| 780 class LoadStore3RegisterImm5Op : public ClassDecoder { | |
| 781 public: | |
| 782 // Interfaces for components in the instruction. | |
| 783 static const RegMBits0To3Interface m; | |
| 784 static const RegTBits12To15Interface t; | |
| 785 static const RegNBits16To19Interface n; | |
| 786 static const WritesBit21Interface writes; | |
| 787 static const AddOffsetBit23Interface direction; | |
| 788 static const PrePostIndexingBit24Interface indexing; | |
| 789 static const ConditionBits28To31Interface cond; | |
| 790 static const ShiftTypeBits5To6Interface shift_type; | |
| 791 static const Imm5Bits7To11Interface imm; | |
| 792 | |
| 793 inline LoadStore3RegisterImm5Op() : ClassDecoder(), is_load_(false) {} | |
| 794 virtual ~LoadStore3RegisterImm5Op() {} | |
| 795 virtual SafetyLevel safety(Instruction i) const; | |
| 796 virtual Register base_address_register(const Instruction i) const; | |
| 797 inline bool HasWriteBack(const Instruction i) const { | |
| 798 return indexing.IsPostIndexing(i) || writes.IsDefined(i); | |
| 799 } | |
| 800 | |
| 801 // The immediate value stored in the instruction. | |
| 802 inline uint32_t ImmediateValue(const Instruction& i) const { | |
| 803 return shift_type.DecodeImmShift(i, imm.value(i)); | |
| 804 } | |
| 805 | |
| 806 protected: | |
| 807 bool is_load_; // true if load (rather than store). | |
| 808 | |
| 809 private: | |
| 810 NACL_DISALLOW_COPY_AND_ASSIGN(LoadStore3RegisterImm5Op); | |
| 811 }; | |
| 812 | |
| 813 // Defines the virtuals for a load register instruction. | |
| 814 class Load3RegisterImm5Op : public LoadStore3RegisterImm5Op { | |
| 815 public: | |
| 816 inline Load3RegisterImm5Op() : LoadStore3RegisterImm5Op() { | |
| 817 is_load_ = true; | |
| 818 } | |
| 819 virtual ~Load3RegisterImm5Op() {} | |
| 820 virtual RegisterList defs(Instruction i) const; | |
| 821 | |
| 822 private: | |
| 823 NACL_DISALLOW_COPY_AND_ASSIGN(Load3RegisterImm5Op); | |
| 824 }; | |
| 825 | |
| 826 // Defines the virtuals for a store register instruction. | |
| 827 class Store3RegisterImm5Op : public LoadStore3RegisterImm5Op { | |
| 828 public: | |
| 829 inline Store3RegisterImm5Op() : LoadStore3RegisterImm5Op() { | |
| 830 is_load_ = false; | |
| 831 } | |
| 832 virtual ~Store3RegisterImm5Op() {} | |
| 833 virtual RegisterList defs(Instruction i) const; | |
| 834 | |
| 835 private: | |
| 836 NACL_DISALLOW_COPY_AND_ASSIGN(Store3RegisterImm5Op); | |
| 837 }; | |
| 838 | |
| 647 // Models a 2-register immediate-shifted unary operation of the form: | 839 // Models a 2-register immediate-shifted unary operation of the form: |
| 648 // Op(S)<c> <Rd>, <Rm> {,<shift>} | 840 // Op(S)<c> <Rd>, <Rm> {,<shift>} |
| 649 // +--------+--------------+--+--------+--------+----------+----+--+--------+ | 841 // +--------+--------------+--+--------+--------+----------+----+--+--------+ |
| 650 // |31302928|27262524232221|20|19181716|15141312|1110 9 8 7| 6 5| 4| 3 2 1 0| | 842 // |31302928|27262524232221|20|19181716|15141312|1110 9 8 7| 6 5| 4| 3 2 1 0| |
| 651 // +--------+--------------+--+--------+--------+----------+----+--+--------+ | 843 // +--------+--------------+--+--------+--------+----------+----+--+--------+ |
| 652 // | cond | | S| | Rd | imm5 |type| | Rm | | 844 // | cond | | S| | Rd | imm5 |type| | Rm | |
| 653 // +--------+--------------+--+--------+--------+----------+----+--+--------+ | 845 // +--------+--------------+--+--------+--------+----------+----+--+--------+ |
| 654 // Definitions: | 846 // Definitions: |
| 655 // Rd - The destination register. | 847 // Rd - The destination register. |
| 656 // Rm - The source operand that is (optionally) shifted. | 848 // Rm - The source operand that is (optionally) shifted. |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 905 virtual SafetyLevel safety(Instruction i) const; | 1097 virtual SafetyLevel safety(Instruction i) const; |
| 906 virtual RegisterList defs(Instruction i) const; | 1098 virtual RegisterList defs(Instruction i) const; |
| 907 | 1099 |
| 908 private: | 1100 private: |
| 909 NACL_DISALLOW_COPY_AND_ASSIGN(Binary3RegisterShiftedTest); | 1101 NACL_DISALLOW_COPY_AND_ASSIGN(Binary3RegisterShiftedTest); |
| 910 }; | 1102 }; |
| 911 | 1103 |
| 912 } // namespace | 1104 } // namespace |
| 913 | 1105 |
| 914 #endif // NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_BASELINE_CLASSES_H_ | 1106 #endif // NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_BASELINE_CLASSES_H_ |
| OLD | NEW |