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

Side by Side Diff: src/trusted/validator_mips/model.h

Issue 11876041: [MIPS] Add thread-pointer to data addressing register list. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Update the comment. Created 7 years, 10 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_mips/inst_classes.h ('k') | src/trusted/validator_mips/ncval.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_MIPS_MODEL_H 7 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_MIPS_MODEL_H
8 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_MIPS_MODEL_H 8 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_MIPS_MODEL_H
9 9
10 /* 10 /*
(...skipping 12 matching lines...) Expand all
23 23
24 /* 24 /*
25 * A value class that names a single register. We could use a typedef for this, 25 * A value class that names a single register. We could use a typedef for this,
26 * but it introduces some ambiguity problems because of the implicit conversion 26 * but it introduces some ambiguity problems because of the implicit conversion
27 * to/from int. 27 * to/from int.
28 * 28 *
29 * May be implicitly converted to a single-entry RegisterList (see below). 29 * May be implicitly converted to a single-entry RegisterList (see below).
30 */ 30 */
31 class Register { 31 class Register {
32 public: 32 public:
33 typedef uint8_t Number;
33 explicit inline Register(uint32_t); 34 explicit inline Register(uint32_t);
34 35
35 /* 36 /*
36 * Produces the bitmask used to represent this register. 37 * Produces the bitmask used to represent this register.
37 */ 38 */
38 inline uint32_t Bitmask() const; 39 inline uint32_t Bitmask() const;
39 40
40 inline bool Equals(const Register &) const; 41 inline bool Equals(const Register &) const;
41 42
43 static const Number kJumpMask = 14; // $t6 = holds mask for jr.
44 static const Number kLoadStoreMask = 15; // $t7 = holds mask for load/store.
45 static const Number kTls = 24; // $t8 = holds tls index.
46 static const Number kSp = 29; // Stack pointer.
47
48 static const Number kNone = 32;
49
50 /*
51 * A special value used to indicate that a register field is not used.
52 * This is specially chosen to ensure that bitmask() == 0, so it can be added
53 * to any RegisterList with no effect.
54 */
55 static Register None() { return Register(kNone); }
56
57 /* Registers with special meaning in our model: */
58 static Register JumpMask() { return Register(kJumpMask); }
59 static Register LoadStoreMask() { return Register(kLoadStoreMask); }
60 static Register Tls() { return Register(kTls); }
61 static Register Sp() { return Register(kSp); }
62
42 private: 63 private:
43 uint32_t _number; 64 uint32_t _number;
44 }; 65 };
45 66
46 const Register kRegisterNone(0);
47
48 // Registers with special meaning in our model:
49 const Register kRegisterStack(29);
50 const Register kRegisterJumpMask(14); // $t6 = holds mask for jr.
51 const Register kRegisterLoadStoreMask(15); // $t7 = holds mask for load/store.
52 const Register kRegisterTls(24); // $t8 = holds tls index.
53
54 const Register kRegisterZero(0);
55
56 /* 67 /*
57 * A collection of Registers. Used to describe the side effects of operations. 68 * A collection of Registers. Used to describe the side effects of operations.
58 * 69 *
59 * Note that this is technically a set, not a list -- but RegisterSet is a 70 * Note that this is technically a set, not a list -- but RegisterSet is a
60 * well-known term that means something else. 71 * well-known term that means something else.
61 */ 72 */
62 class RegisterList { 73 class RegisterList {
63 public: 74 public:
64 /* 75 /*
65 * Produces a RegisterList that contains the registers specified in the 76 * Produces a RegisterList that contains the registers specified in the
(...skipping 19 matching lines...) Expand all
85 inline bool operator[](const Register) const; 96 inline bool operator[](const Register) const;
86 97
87 // Checks whether this list contains all the registers in the operand. 98 // Checks whether this list contains all the registers in the operand.
88 inline bool ContainsAll(RegisterList) const; 99 inline bool ContainsAll(RegisterList) const;
89 100
90 // Checks whether this list contains any of the registers in the operand. 101 // Checks whether this list contains any of the registers in the operand.
91 inline bool ContainsAny(RegisterList) const; 102 inline bool ContainsAny(RegisterList) const;
92 103
93 inline const RegisterList operator&(const RegisterList) const; 104 inline const RegisterList operator&(const RegisterList) const;
94 105
106 /*
107 * A list containing every possible register, even some we do not define.
108 * Used exclusively as a bogus scary return value for forbidden instructions.
109 */
110 static RegisterList Everything() { return RegisterList(-1); }
111
112 /* A list of registers that can not be modified by untrusted code. */
113 static RegisterList ReservedRegs() {
114 return RegisterList(((1 << Register::kJumpMask) |
115 (1 << Register::kLoadStoreMask) |
116 (1 << Register::kTls)));
117 }
118
119 /* A list of registers that can be used for addressing memory locations. */
120 static RegisterList DataAddrRegs() {
121 return RegisterList(((1 << Register::kSp) |
122 (1 << Register::kTls)));
123 }
124
95 private: 125 private:
96 uint32_t _bits; 126 uint32_t _bits;
97 }; 127 };
98 128
99 /* 129 /*
100 * A list containing every possible register, even some we don't define.
101 * Used exclusively as a bogus scary return value for forbidden instructions.
102 */
103 static const RegisterList kRegisterListEverything = RegisterList(-1);
104
105 static uint32_t const kReservedRegsBitmask = kRegisterTls.Bitmask()
106 + kRegisterJumpMask.Bitmask()
107 + kRegisterLoadStoreMask.Bitmask();
108 static RegisterList const kRegListReserved = RegisterList(kReservedRegsBitmask);
109
110 /*
111 * A 32-bit Mips instruction of unspecified type. 130 * A 32-bit Mips instruction of unspecified type.
112 * 131 *
113 * This class is designed for efficiency: 132 * This class is designed for efficiency:
114 * - Its public methods for bitfield extraction are short and inline. 133 * - Its public methods for bitfield extraction are short and inline.
115 * - It has no vtable, so on 32-bit platforms it's exactly the size of the 134 * - It has no vtable, so on 32-bit platforms it's exactly the size of the
116 * instruction it models. 135 * instruction it models.
117 */ 136 */
118 class Instruction { 137 class Instruction {
119 public: 138 public:
120 explicit inline Instruction(uint32_t bits); 139 explicit inline Instruction(uint32_t bits);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 173
155 // Opcode for nop instruction. 174 // Opcode for nop instruction.
156 uint32_t const kNop = 0x0; 175 uint32_t const kNop = 0x0;
157 176
158 } // namespace 177 } // namespace
159 178
160 // Definitions for our inlined functions. 179 // Definitions for our inlined functions.
161 #include "native_client/src/trusted/validator_mips/model-inl.h" 180 #include "native_client/src/trusted/validator_mips/model-inl.h"
162 181
163 #endif // NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_MIPS_MODEL_H 182 #endif // NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_MIPS_MODEL_H
OLDNEW
« no previous file with comments | « src/trusted/validator_mips/inst_classes.h ('k') | src/trusted/validator_mips/ncval.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698