| OLD | NEW |
| (Empty) | |
| 1 /* |
| 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 |
| 4 * found in the LICENSE file. |
| 5 */ |
| 6 |
| 7 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_NAMED_CLASS_DECODER_H_ |
| 8 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_NAMED_CLASS_DECODER_H_ |
| 9 |
| 10 #ifndef NACL_TRUSTED_BUT_NOT_TCB |
| 11 #error("This file is not meant for use in the TCB") |
| 12 #endif |
| 13 |
| 14 #include "native_client/src/trusted/validator_arm/inst_classes.h" |
| 15 |
| 16 namespace nacl_arm_test { |
| 17 |
| 18 // Defines a wrapper class used for testing, that adds a name to |
| 19 // an existing class decoder, so that we can give better error messages |
| 20 // if testing finds a consistency issue in modeling instructions. |
| 21 class NamedClassDecoder : public nacl_arm_dec::ClassDecoder { |
| 22 public: |
| 23 explicit NamedClassDecoder(const nacl_arm_dec::ClassDecoder& wrapped_decoder, |
| 24 const char* name) |
| 25 : wrapped_decoder_(wrapped_decoder), |
| 26 name_(name) |
| 27 {} |
| 28 virtual ~NamedClassDecoder() {} |
| 29 |
| 30 // Returns the class decoder that is being named. |
| 31 const ClassDecoder& named_decoder() const { |
| 32 return wrapped_decoder_; |
| 33 } |
| 34 |
| 35 // Returns the name of the wrapped class decoder. |
| 36 const char* name() const { |
| 37 return name_; |
| 38 } |
| 39 |
| 40 // Virtual dispatching. |
| 41 virtual nacl_arm_dec::SafetyLevel safety(nacl_arm_dec::Instruction i) const { |
| 42 return wrapped_decoder_.safety(i); |
| 43 } |
| 44 |
| 45 virtual nacl_arm_dec::RegisterList defs(nacl_arm_dec::Instruction i) const { |
| 46 return wrapped_decoder_.defs(i); |
| 47 } |
| 48 |
| 49 virtual nacl_arm_dec::RegisterList |
| 50 immediate_addressing_defs(nacl_arm_dec::Instruction i) const { |
| 51 return wrapped_decoder_.immediate_addressing_defs(i); |
| 52 } |
| 53 |
| 54 virtual bool writes_memory(nacl_arm_dec::Instruction i) const { |
| 55 return wrapped_decoder_.writes_memory(i); |
| 56 } |
| 57 |
| 58 virtual nacl_arm_dec::Register |
| 59 base_address_register(nacl_arm_dec::Instruction i) const { |
| 60 return wrapped_decoder_.base_address_register(i); |
| 61 } |
| 62 |
| 63 virtual bool offset_is_immediate(nacl_arm_dec::Instruction i) const { |
| 64 return wrapped_decoder_.offset_is_immediate(i); |
| 65 } |
| 66 |
| 67 virtual nacl_arm_dec::Register |
| 68 branch_target_register(nacl_arm_dec::Instruction i) const { |
| 69 return wrapped_decoder_.branch_target_register(i); |
| 70 } |
| 71 |
| 72 virtual bool is_relative_branch(nacl_arm_dec::Instruction i) const { |
| 73 return wrapped_decoder_.is_relative_branch(i); |
| 74 } |
| 75 |
| 76 virtual int32_t branch_target_offset(nacl_arm_dec::Instruction i) const { |
| 77 return wrapped_decoder_.branch_target_offset(i); |
| 78 } |
| 79 |
| 80 virtual bool is_literal_pool_head(nacl_arm_dec::Instruction i) const { |
| 81 return wrapped_decoder_.is_literal_pool_head(i); |
| 82 } |
| 83 |
| 84 virtual bool clears_bits(nacl_arm_dec::Instruction i, uint32_t mask) const { |
| 85 return wrapped_decoder_.clears_bits(i, mask); |
| 86 } |
| 87 |
| 88 virtual bool sets_Z_if_bits_clear(nacl_arm_dec::Instruction i, |
| 89 nacl_arm_dec::Register r, |
| 90 uint32_t mask) const { |
| 91 return wrapped_decoder_.sets_Z_if_bits_clear(i, r, mask); |
| 92 } |
| 93 |
| 94 private: |
| 95 const nacl_arm_dec::ClassDecoder& wrapped_decoder_; |
| 96 const char* name_; |
| 97 }; |
| 98 |
| 99 } // namespace |
| 100 |
| 101 #endif // NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_ARM_NAMED_CLASS_DECODER_H_ |
| OLD | NEW |