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

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

Issue 10879090: ARM validator: continue with extra_load_store_instructions. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Update with more tables. Created 8 years, 3 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
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 #include "native_client/src/trusted/validator_arm/baseline_classes.h" 7 #include "native_client/src/trusted/validator_arm/baseline_classes.h"
8 8
9 #include <assert.h> 9 #include <assert.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 bool BranchImmediate24::is_relative_branch(Instruction i) const { 75 bool BranchImmediate24::is_relative_branch(Instruction i) const {
76 UNREFERENCED_PARAMETER(i); 76 UNREFERENCED_PARAMETER(i);
77 return true; 77 return true;
78 } 78 }
79 79
80 int32_t BranchImmediate24::branch_target_offset(Instruction i) const { 80 int32_t BranchImmediate24::branch_target_offset(Instruction i) const {
81 return imm24.relative_address(i); 81 return imm24.relative_address(i);
82 } 82 }
83 83
84 // BreakPointAndConstantPoolHead 84 // BreakPointAndConstantPoolHead
85 SafetyLevel BreakPointAndConstantPoolHead::safety(const Instruction i) const {
86 return i.GetCondition() == Instruction::AL
87 ? MAY_BE_SAFE
88 : UNPREDICTABLE;
89 }
90
85 bool BreakPointAndConstantPoolHead:: 91 bool BreakPointAndConstantPoolHead::
86 is_literal_pool_head(const Instruction i) const { 92 is_literal_pool_head(const Instruction i) const {
87 return i.GetCondition() == Instruction::AL && 93 return i.GetCondition() == Instruction::AL &&
88 value(i) == 0x7777; 94 value(i) == 0x7777;
89 } 95 }
90 96
91 // BranchToRegister 97 // BranchToRegister
92 SafetyLevel BranchToRegister::safety(const Instruction i) const { 98 SafetyLevel BranchToRegister::safety(const Instruction i) const {
99 // Extra NaCl constraint: can't branch to PC. This would branch to 8 bytes
100 // after the current instruction. This instruction should be in an instruction
101 // pair, the mask should therefore be to PC and fail checking, but there's
102 // little harm in checking.
103 if (m.reg(i).Equals(kRegisterPc)) return FORBIDDEN_OPERANDS;
104
105 // Redundant with the above, but this is actually UNPREDICTABLE. Expect DCE.
93 if (link_register.IsUpdated(i) && m.reg(i).Equals(kRegisterPc)) { 106 if (link_register.IsUpdated(i) && m.reg(i).Equals(kRegisterPc)) {
94 return UNPREDICTABLE; 107 return UNPREDICTABLE;
95 } 108 }
96 109
97 return MAY_BE_SAFE; 110 return MAY_BE_SAFE;
98 } 111 }
99 112
100 RegisterList BranchToRegister::defs(const Instruction i) const { 113 RegisterList BranchToRegister::defs(const Instruction i) const {
101 return RegisterList(kRegisterPc). 114 return RegisterList(kRegisterPc).
102 Add(link_register.IsUpdated(i) ? kRegisterLink : kRegisterNone); 115 Add(link_register.IsUpdated(i) ? kRegisterLink : kRegisterNone);
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 return UNPREDICTABLE; 363 return UNPREDICTABLE;
351 } 364 }
352 365
353 if (HasWriteBack(i) && 366 if (HasWriteBack(i) &&
354 (n.reg(i).Equals(kRegisterPc) || 367 (n.reg(i).Equals(kRegisterPc) ||
355 // NOTE: The manual states that that it is also unpredictable 368 // NOTE: The manual states that that it is also unpredictable
356 // when HasWriteBack(i) and Rn=Rt. However, the compilers 369 // when HasWriteBack(i) and Rn=Rt. However, the compilers
357 // may not check for this. For the moment, we are changing 370 // may not check for this. For the moment, we are changing
358 // the code to ignore this case for stores. 371 // the code to ignore this case for stores.
359 // TODO(karl): Should we not allow this? 372 // TODO(karl): Should we not allow this?
373 // TODO(jfb) Fix this.
360 (is_load_ && n.reg(i).Equals(t.reg(i))))) { 374 (is_load_ && n.reg(i).Equals(t.reg(i))))) {
361 return UNPREDICTABLE; 375 return UNPREDICTABLE;
362 } 376 }
363 377
364 // Above implies literal loads can't writeback, the following checks the 378 // Above implies literal loads can't writeback, the following checks the
365 // ARM restriction that literal loads can't have P == W. 379 // ARM restriction that literal loads can't have P == W.
366 // This should always decode to another instruction, but checking it is good. 380 // This should always decode to another instruction, but checking it is good.
367 if (n.reg(i).Equals(kRegisterPc) && 381 if (n.reg(i).Equals(kRegisterPc) &&
368 (indexing.IsDefined(i) == writes.IsDefined(i))) { 382 (indexing.IsDefined(i) == writes.IsDefined(i))) {
369 return UNPREDICTABLE; 383 return UNPREDICTABLE;
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 return UNPREDICTABLE; 672 return UNPREDICTABLE;
659 } 673 }
660 674
661 if (HasWriteBack(i) && 675 if (HasWriteBack(i) &&
662 (n.reg(i).Equals(kRegisterPc) || 676 (n.reg(i).Equals(kRegisterPc) ||
663 // NOTE: The manual states that that it is also unpredictable 677 // NOTE: The manual states that that it is also unpredictable
664 // when HasWriteBack(i) and Rn=Rt. However, the compilers 678 // when HasWriteBack(i) and Rn=Rt. However, the compilers
665 // may not check for this. For the moment, we are changing 679 // may not check for this. For the moment, we are changing
666 // the code to ignore this case for stores. 680 // the code to ignore this case for stores.
667 // TODO(karl): Should we not allow this? 681 // TODO(karl): Should we not allow this?
682 // TODO(jfb) Fix this.
668 (is_load_ && n.reg(i).Equals(t.reg(i))))) { 683 (is_load_ && n.reg(i).Equals(t.reg(i))))) {
669 return UNPREDICTABLE; 684 return UNPREDICTABLE;
670 } 685 }
671 686
687 // TODO(jfb) if ArchVersion() < 6 && wback && m == n then UNPREDICTABLE;
688
672 // Don't let addressing writeback alter PC (NaCl constraint). 689 // Don't let addressing writeback alter PC (NaCl constraint).
673 if (defs(i).Contains(kRegisterPc)) return FORBIDDEN_OPERANDS; 690 if (defs(i).Contains(kRegisterPc)) return FORBIDDEN_OPERANDS;
674 691
675 return MAY_BE_SAFE; 692 return MAY_BE_SAFE;
676 } 693 }
677 694
678 Register LoadStore3RegisterOp::base_address_register( 695 Register LoadStore3RegisterOp::base_address_register(
679 const Instruction i) const { 696 const Instruction i) const {
680 return n.reg(i); 697 return n.reg(i);
681 } 698 }
(...skipping 25 matching lines...) Expand all
707 724
708 if (RegisterList(t2.reg(i)).Add(m.reg(i)).Contains(kRegisterPc)) { 725 if (RegisterList(t2.reg(i)).Add(m.reg(i)).Contains(kRegisterPc)) {
709 return UNPREDICTABLE; 726 return UNPREDICTABLE;
710 } 727 }
711 728
712 // NOTE: The manual states that that it is also unpredictable 729 // NOTE: The manual states that that it is also unpredictable
713 // when HasWriteBack(i) and Rn=Rt2. However, the compilers 730 // when HasWriteBack(i) and Rn=Rt2. However, the compilers
714 // may not check for this. For the moment, we are changing 731 // may not check for this. For the moment, we are changing
715 // the code to ignore this case for stores. 732 // the code to ignore this case for stores.
716 // TODO(karl): Should we not allow this? 733 // TODO(karl): Should we not allow this?
734 // TODO(jfb) Fix this.
717 if (is_load_ && HasWriteBack(i) && n.reg(i).Equals(t2.reg(i))) { 735 if (is_load_ && HasWriteBack(i) && n.reg(i).Equals(t2.reg(i))) {
718 return UNPREDICTABLE; 736 return UNPREDICTABLE;
719 } 737 }
720 738
739 if (is_load_ && (m.reg(i).Equals(t.reg(i)) || m.reg(i).Equals(t2.reg(i)))) {
740 return UNPREDICTABLE;
741 }
742
721 // Now apply non-double width restrictions for this instruction. 743 // Now apply non-double width restrictions for this instruction.
722 return LoadStore3RegisterOp::safety(i); 744 return LoadStore3RegisterOp::safety(i);
723 } 745 }
724 746
725 // StoreExclusive3RegisterOp 747 // StoreExclusive3RegisterOp
726 SafetyLevel StoreExclusive3RegisterOp::safety(const Instruction i) const { 748 SafetyLevel StoreExclusive3RegisterOp::safety(const Instruction i) const {
727 // Arm restrictions for this instruction. 749 // Arm restrictions for this instruction.
728 if (RegisterList(d.reg(i)).Add(t.reg(i)).Add(n.reg(i)). 750 if (RegisterList(d.reg(i)).Add(t.reg(i)).Add(n.reg(i)).
729 Contains(kRegisterPc)) { 751 Contains(kRegisterPc)) {
730 return UNPREDICTABLE; 752 return UNPREDICTABLE;
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 if (be_value(i) == 0x3) 1071 if (be_value(i) == 0x3)
1050 return UNDEFINED; 1072 return UNDEFINED;
1051 1073
1052 if (t.reg(i).Equals(kRegisterPc)) 1074 if (t.reg(i).Equals(kRegisterPc))
1053 return UNPREDICTABLE; 1075 return UNPREDICTABLE;
1054 1076
1055 return CondVfpOp::safety(i); 1077 return CondVfpOp::safety(i);
1056 } 1078 }
1057 1079
1058 } // namespace nacl_arm_dec 1080 } // namespace nacl_arm_dec
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698