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

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

Issue 9960043: Finish separation of testing from sel_ldr validation. Also, automate (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years, 8 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/inst_classes.h" 7 #include "native_client/src/trusted/validator_arm/inst_classes.h"
8 8
9 #include <assert.h> 9 #include <assert.h>
10 #include <string.h> 10 #include <string.h>
11 11
12 // Implementations of instruction classes, for those not completely defined in 12 // Implementations of instruction classes, for those not completely defined in
13 // in the header. 13 // in the header.
14 14
15 namespace nacl_arm_dec { 15 namespace nacl_arm_dec {
16 16
17 const char* ClassDecoder::name() const {
18 // This should never be called!
19 assert(0);
20 return "???";
21 }
22
23 uint32_t ShiftTypeBits5To6Interface::ComputeDecodeImmShift( 17 uint32_t ShiftTypeBits5To6Interface::ComputeDecodeImmShift(
24 uint32_t shift_type, uint32_t imm5_value) { 18 uint32_t shift_type, uint32_t imm5_value) {
25 switch (shift_type) { 19 switch (shift_type) {
26 case 0: 20 case 0:
27 return imm5_value; 21 return imm5_value;
28 case 1: 22 case 1:
29 case 2: 23 case 2:
30 return imm5_value == 0 ? 32 : imm5_value; 24 return imm5_value == 0 ? 32 : imm5_value;
31 case 3: 25 case 3:
32 return imm5_value == 0 ? 1 : imm5_value; 26 return imm5_value == 0 ? 1 : imm5_value;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 73
80 RegisterList Unary2RegisterOp::defs(const Instruction i) const { 74 RegisterList Unary2RegisterOp::defs(const Instruction i) const {
81 return d_.reg(i) + flags_.reg_if_updated(i); 75 return d_.reg(i) + flags_.reg_if_updated(i);
82 } 76 }
83 77
84 // Binary3RegisterOp 78 // Binary3RegisterOp
85 SafetyLevel Binary3RegisterOp::safety(const Instruction i) const { 79 SafetyLevel Binary3RegisterOp::safety(const Instruction i) const {
86 // Unsafe if any register contains PC (ARM restriction). 80 // Unsafe if any register contains PC (ARM restriction).
87 if ((d_.reg(i) + m_.reg(i) + n_.reg(i))[kRegisterPc]) return UNPREDICTABLE; 81 if ((d_.reg(i) + m_.reg(i) + n_.reg(i))[kRegisterPc]) return UNPREDICTABLE;
88 82
83
89 // Note: We would restrict out PC as well for Rd in NaCl, but no need 84 // Note: We would restrict out PC as well for Rd in NaCl, but no need
90 // since the ARM restriction doesn't allow it anyway. 85 // since the ARM restriction doesn't allow it anyway.
91 return MAY_BE_SAFE; 86 return MAY_BE_SAFE;
92 } 87 }
93 88
94 RegisterList Binary3RegisterOp::defs(const Instruction i) const { 89 RegisterList Binary3RegisterOp::defs(const Instruction i) const {
95 return d_.reg(i) + flags_.reg_if_updated(i); 90 return d_.reg(i) + flags_.reg_if_updated(i);
96 } 91 }
97 92
98 // Unary2RegisterImmedShiftedOp 93 // Unary2RegisterImmedShiftedOp
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 return kRegisterPc + (PreindexingFlag(i) ? kRegisterLink : kRegisterNone); 572 return kRegisterPc + (PreindexingFlag(i) ? kRegisterLink : kRegisterNone);
578 } 573 }
579 574
580 int32_t Branch::branch_target_offset(const Instruction i) const { 575 int32_t Branch::branch_target_offset(const Instruction i) const {
581 // Sign extend and shift left 2: 576 // Sign extend and shift left 2:
582 int32_t offset = (int32_t)(i.bits(23, 0) << 8) >> 6; 577 int32_t offset = (int32_t)(i.bits(23, 0) << 8) >> 6;
583 return offset + 8; // because r15 reads as 8 bytes ahead 578 return offset + 8; // because r15 reads as 8 bytes ahead
584 } 579 }
585 580
586 } // namespace 581 } // namespace
OLDNEW
« no previous file with comments | « src/trusted/validator_arm/inst_classes.h ('k') | src/trusted/validator_arm/inst_classes_testers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698