| 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_ARM_INST_CLASSES_H_ | 7 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_INST_CLASSES_H_ |
| 8 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_INST_CLASSES_H_ | 8 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_INST_CLASSES_H_ |
| 9 | 9 |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 inline Imm4Bits16To19Interface() {} | 216 inline Imm4Bits16To19Interface() {} |
| 217 static inline uint32_t value(const Instruction& i) { | 217 static inline uint32_t value(const Instruction& i) { |
| 218 return i.bits(19, 16); | 218 return i.bits(19, 16); |
| 219 } | 219 } |
| 220 | 220 |
| 221 private: | 221 private: |
| 222 NACL_DISALLOW_COPY_AND_ASSIGN(Imm4Bits16To19Interface); | 222 NACL_DISALLOW_COPY_AND_ASSIGN(Imm4Bits16To19Interface); |
| 223 }; | 223 }; |
| 224 | 224 |
| 225 // Interface class to pull out S (update) bit from bit 20, which | 225 // Interface class to pull out S (update) bit from bit 20, which |
| 226 // defines if the flags register is updated by the instruction. | 226 // defines if the condition bits in APSR are updated by the instruction. |
| 227 class UpdatesFlagsRegisterBit20Interface { | 227 class UpdatesConditionsBit20Interface { |
| 228 public: | 228 public: |
| 229 inline UpdatesFlagsRegisterBit20Interface() {} | 229 inline UpdatesConditionsBit20Interface() {} |
| 230 // Returns true if bit is set that states that the flags register is updated. | 230 // Returns true if bit is set that states that the condition bits |
| 231 // APSR is updated. |
| 231 static inline bool is_updated(const Instruction i) { | 232 static inline bool is_updated(const Instruction i) { |
| 232 return i.bit(20); | 233 return i.bit(20); |
| 233 } | 234 } |
| 234 // Returns the flags register if it is used. | 235 // Returns the conditions register if it is used. |
| 235 static inline Register reg_if_updated(const Instruction i) { | 236 static inline Register conds_if_updated(const Instruction i) { |
| 236 return is_updated(i) ? kRegisterFlags : kRegisterNone; | 237 return is_updated(i) ? kConditions : kRegisterNone; |
| 237 } | 238 } |
| 238 | 239 |
| 239 private: | 240 private: |
| 240 NACL_DISALLOW_COPY_AND_ASSIGN(UpdatesFlagsRegisterBit20Interface); | 241 NACL_DISALLOW_COPY_AND_ASSIGN(UpdatesConditionsBit20Interface); |
| 241 }; | 242 }; |
| 242 | 243 |
| 243 // A class decoder is designed to decode a set of instructions that | 244 // A class decoder is designed to decode a set of instructions that |
| 244 // have the same semantics, in terms of what the validator needs. This | 245 // have the same semantics, in terms of what the validator needs. This |
| 245 // includes the bit ranges in the instruction that correspond to | 246 // includes the bit ranges in the instruction that correspond to |
| 246 // assigned registers. as well as whether the instruction is safe to | 247 // assigned registers. as well as whether the instruction is safe to |
| 247 // use within the validator. | 248 // use within the validator. |
| 248 // | 249 // |
| 249 // The important property of these class decoders is that the | 250 // The important property of these class decoders is that the |
| 250 // corresponding DecoderState (defined in decoder.h) will inspect the | 251 // corresponding DecoderState (defined in decoder.h) will inspect the |
| (...skipping 20 matching lines...) Expand all Loading... |
| 271 // cannot touch global state, this will not check things that may vary with | 272 // cannot touch global state, this will not check things that may vary with |
| 272 // ABI version. | 273 // ABI version. |
| 273 // | 274 // |
| 274 // The most positive result this can return is called MAY_BE_SAFE because it | 275 // The most positive result this can return is called MAY_BE_SAFE because it |
| 275 // is necessary, but not sufficient: the validator has the final say. | 276 // is necessary, but not sufficient: the validator has the final say. |
| 276 virtual SafetyLevel safety(Instruction i) const = 0; | 277 virtual SafetyLevel safety(Instruction i) const = 0; |
| 277 | 278 |
| 278 // Gets the set of registers affected when an instruction executes. This set | 279 // Gets the set of registers affected when an instruction executes. This set |
| 279 // is complete, and includes | 280 // is complete, and includes |
| 280 // - explicit destination register(s), | 281 // - explicit destination register(s), |
| 281 // - changes to flags, | 282 // - changes to condition flags, |
| 282 // - indexed-addressing writeback, | 283 // - indexed-addressing writeback, |
| 283 // - changes to r15 by branches, | 284 // - changes to r15 by branches, |
| 284 // - implicit register results, like branch-with-link. | 285 // - implicit register results, like branch-with-link. |
| 285 // | 286 // |
| 287 // Note: If you are unsure if an instruction changes condition flags, be |
| 288 // conservative and add it to the set of registers returned by this |
| 289 // function. Failure to do so may cause a potential break in pattern |
| 290 // atomicity, which checks that two instructions run under the same condition. |
| 291 // |
| 286 // The default implementation returns a ridiculous bitmask that suggests that | 292 // The default implementation returns a ridiculous bitmask that suggests that |
| 287 // all possible side effects will occur -- override if this is not | 293 // all possible side effects will occur -- override if this is not |
| 288 // appropriate. :-) | 294 // appropriate. :-) |
| 289 virtual RegisterList defs(Instruction i) const { | 295 virtual RegisterList defs(Instruction i) const { |
| 290 UNREFERENCED_PARAMETER(i); | 296 UNREFERENCED_PARAMETER(i); |
| 291 return kRegisterListEverything; | 297 return kRegisterListEverything; |
| 292 } | 298 } |
| 293 | 299 |
| 294 // Gets the set of registers that this instruction defines through immediate | 300 // Gets the set of registers that this instruction defines through immediate |
| 295 // indexed addressing writeback -- a subset of the defs() set. | 301 // indexed addressing writeback -- a subset of the defs() set. |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 inline Unpredictable() : UnsafeClassDecoder(UNPREDICTABLE) {} | 479 inline Unpredictable() : UnsafeClassDecoder(UNPREDICTABLE) {} |
| 474 virtual ~Unpredictable() {} | 480 virtual ~Unpredictable() {} |
| 475 | 481 |
| 476 private: | 482 private: |
| 477 NACL_DISALLOW_COPY_AND_ASSIGN(Unpredictable); | 483 NACL_DISALLOW_COPY_AND_ASSIGN(Unpredictable); |
| 478 }; | 484 }; |
| 479 | 485 |
| 480 } // namespace | 486 } // namespace |
| 481 | 487 |
| 482 #endif // NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_INST_CLASSES_H_ | 488 #endif // NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_INST_CLASSES_H_ |
| OLD | NEW |