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_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 Loading... | |
| 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 */ | |
|
Mark Seaborn
2015/12/27 03:46:35
Nit: Fix indentation here
petarj
2015/12/28 14:07:00
Done.
| |
| 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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 |
| OLD | NEW |