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

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

Issue 1535443005: [MIPS] Make validator allow only two load patterns via $t8 (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client@master
Patch Set: Minor update. Created 4 years, 11 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
« no previous file with comments | « src/trusted/validator_mips/gen/decode.cc ('k') | src/trusted/validator_mips/mips-opt.table » ('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_INST_CLASSES_H 7 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_MIPS_INST_CLASSES_H
8 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_MIPS_INST_CLASSES_H 8 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_MIPS_INST_CLASSES_H
9 9
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 129 }
130 130
131 /* 131 /*
132 * For load and store instructions. 132 * For load and store instructions.
133 */ 133 */
134 virtual bool IsLoadStore() const { 134 virtual bool IsLoadStore() const {
135 return false; 135 return false;
136 } 136 }
137 137
138 /* 138 /*
139 * For lw instruction.
140 */
141 virtual bool IsLoadWord() const {
142 return false;
143 }
144
145 /*
139 * For direct jumps, returning the destination address. 146 * For direct jumps, returning the destination address.
140 */ 147 */
141 virtual uint32_t DestAddr(const Instruction instr, uint32_t addr) const { 148 virtual uint32_t DestAddr(const Instruction instr, uint32_t addr) const {
142 UNREFERENCED_PARAMETER(instr); 149 UNREFERENCED_PARAMETER(instr);
143 UNREFERENCED_PARAMETER(addr); 150 UNREFERENCED_PARAMETER(addr);
144 return 0; 151 return 0;
145 } 152 }
146 153
147 /* 154 /*
148 * Used by jump register instructions; returns the register that holds the 155 * Used by jump register instructions; returns the register that holds the
(...skipping 15 matching lines...) Expand all
164 171
165 protected: 172 protected:
166 ClassDecoder() {} 173 ClassDecoder() {}
167 virtual ~ClassDecoder() {} 174 virtual ~ClassDecoder() {}
168 }; 175 };
169 176
170 /* 177 /*
171 * Current MIPS NaCl halt (break). 178 * Current MIPS NaCl halt (break).
172 */ 179 */
173 class NaClHalt : public ClassDecoder { 180 class NaClHalt : public ClassDecoder {
174 public: 181 public:
175 virtual ~NaClHalt() {} 182 virtual ~NaClHalt() {}
176 virtual SafetyLevel safety(const Instruction instr) const { 183 virtual SafetyLevel safety(const Instruction instr) const {
177 UNREFERENCED_PARAMETER(instr); 184 UNREFERENCED_PARAMETER(instr);
178 return MAY_BE_SAFE; 185 return MAY_BE_SAFE;
179 } 186 }
180 }; 187 };
181 188
182 /* 189 /*
183 * Represents an instruction that is forbidden under all circumstances, so we 190 * Represents an instruction that is forbidden under all circumstances, so we
184 * didn't bother decoding it further. 191 * didn't bother decoding it further.
185 */ 192 */
186 class Forbidden : public ClassDecoder { 193 class Forbidden : public ClassDecoder {
187 public: 194 public:
188 virtual ~Forbidden() {} 195 virtual ~Forbidden() {}
189 virtual SafetyLevel safety(const Instruction instr) const { 196 virtual SafetyLevel safety(const Instruction instr) const {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 return true; 288 return true;
282 } 289 }
283 virtual ~AbstractLoadStore() {} 290 virtual ~AbstractLoadStore() {}
284 virtual SafetyLevel safety(const Instruction instr) const { 291 virtual SafetyLevel safety(const Instruction instr) const {
285 UNREFERENCED_PARAMETER(instr); 292 UNREFERENCED_PARAMETER(instr);
286 return MAY_BE_SAFE; 293 return MAY_BE_SAFE;
287 } 294 }
288 virtual Register BaseAddressRegister(const Instruction instr) const { 295 virtual Register BaseAddressRegister(const Instruction instr) const {
289 return instr.Reg(25, 21); 296 return instr.Reg(25, 21);
290 } 297 }
298 virtual uint32_t GetImm(const Instruction instr) const {
299 return instr.Bits(15, 0);
300 }
291 }; 301 };
292 302
293 /* 303 /*
294 * Store instructions. 304 * Store instructions.
295 */ 305 */
296 class Store : public AbstractLoadStore { 306 class Store : public AbstractLoadStore {
297 public: 307 public:
298 virtual ~Store() {} 308 virtual ~Store() {}
299 }; 309 };
300 310
301 /* 311 /*
302 * Load instructions, which alter the destination register. 312 * Load instructions, which alter the destination register.
303 */ 313 */
304 class Load : public AbstractLoadStore { 314 class Load : public AbstractLoadStore {
305 public: 315 public:
306 virtual ~Load() {} 316 virtual ~Load() {}
307 virtual Register DestGprReg(const Instruction instr) const { 317 virtual Register DestGprReg(const Instruction instr) const {
308 return instr.Reg(20, 16); 318 return instr.Reg(20, 16);
309 } 319 }
310 }; 320 };
311 321
312 /* 322 /*
323 * Load word instruction, for loading thread pointer.
324 */
325 class LoadWord : public Load {
326 public:
327 virtual ~LoadWord() {}
328 virtual bool IsLoadWord() const {
329 return true;
330 }
331 };
332
333 /*
313 * Floating point load and store instructions. 334 * Floating point load and store instructions.
314 */ 335 */
315 class FPLoadStore : public AbstractLoadStore { 336 class FPLoadStore : public AbstractLoadStore {
316 public: 337 public:
317 virtual ~FPLoadStore() {} 338 virtual ~FPLoadStore() {}
318 }; 339 };
319 340
320 /* 341 /*
321 * Store Conditional class, containing the sc instruction, 342 * Store Conditional class, containing the sc instruction,
322 * which might alter the contents of the register which is the 1st operand. 343 * which might alter the contents of the register which is the 1st operand.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 * Unknown instructions, treated as forbidden. 446 * Unknown instructions, treated as forbidden.
426 */ 447 */
427 class Unrecognized : public ClassDecoder { 448 class Unrecognized : public ClassDecoder {
428 public: 449 public:
429 virtual ~Unrecognized() {} 450 virtual ~Unrecognized() {}
430 virtual SafetyLevel safety(const Instruction instr) const { 451 virtual SafetyLevel safety(const Instruction instr) const {
431 UNREFERENCED_PARAMETER(instr); 452 UNREFERENCED_PARAMETER(instr);
432 return FORBIDDEN; 453 return FORBIDDEN;
433 } 454 }
434 }; 455 };
435 } // namespace 456 } // namespace nacl_mips_dec
436 457
437 #endif // NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_MIPS_INST_CLASSES_H 458 #endif // NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_MIPS_INST_CLASSES_H
OLDNEW
« no previous file with comments | « src/trusted/validator_mips/gen/decode.cc ('k') | src/trusted/validator_mips/mips-opt.table » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698