Index: src/trusted/validator_mips/model-inl.h |
diff --git a/src/trusted/validator_mips/model-inl.h b/src/trusted/validator_mips/model-inl.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..dd724f463e64131a95ce8c47f2db8b6a68d8de8b |
--- /dev/null |
+++ b/src/trusted/validator_mips/model-inl.h |
@@ -0,0 +1,83 @@ |
+/* |
+ * Copyright 2009 The Native Client Authors. All rights reserved. |
+ * Use of this source code is governed by a BSD-style license that can |
+ * be found in the LICENSE file. |
+ * Copyright 2009, Google Inc. |
+ */ |
+ |
+#ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_MIPS_MODEL_INL_H |
+#define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_MIPS_MODEL_INL_H |
+/* |
+ * Inline definitions for the classes defined in model.h |
+ */ |
+ |
+namespace nacl_mips_dec { |
+ |
+Register::Register(uint32_t number) : _number(number) {} |
+uint32_t Register::bitmask() const { |
+ if (_number == 31) return 0; |
+ |
+ return (1 << _number); |
+} |
+ |
+bool Register::operator==(const Register &other) const { |
+ return _number == other._number; |
+} |
+ |
+bool Register::operator!=(const Register &other) const { |
+ return _number != other._number; |
+} |
+ |
+ |
+RegisterList::RegisterList(uint32_t bits) : _bits(bits) {} |
+RegisterList::RegisterList(Register r) : _bits(r.bitmask()) {} |
+ |
+bool RegisterList::operator[](Register r) const { |
+ return _bits & r.bitmask(); |
+} |
+ |
+bool RegisterList::contains_all(const RegisterList other) const { |
+ return (_bits & other._bits) == other._bits; |
+} |
+ |
+bool RegisterList::contains_any(const RegisterList other) const { |
+ return _bits & other._bits; |
+} |
+ |
+const RegisterList RegisterList::operator&(const RegisterList other) const { |
+ return RegisterList(_bits & other._bits); |
+} |
+ |
+bool RegisterList::operator==(const RegisterList other) const { |
+ return _bits == other._bits; |
+} |
+ |
+const RegisterList operator+(const RegisterList a, const RegisterList b) { |
+ return RegisterList(a._bits | b._bits); |
+} |
+ |
+ |
+inline Instruction::Instruction(uint32_t bits) : _bits(bits) {} |
+ |
+inline uint32_t Instruction::bits(int hi, int lo) const { |
+ uint32_t right_justified = _bits >> lo; |
+ int bit_count = hi - lo + 1; |
+ uint32_t mask = (1 << bit_count) - 1; |
+ return right_justified & mask; |
+} |
+ |
+inline const Register Instruction::reg(int hi, int lo) const { |
+ return Register(bits(hi, lo)); |
+} |
+ |
+inline bool Instruction::bit(int index) const { |
+ return (_bits >> index) & 1; |
+} |
+ |
+inline uint32_t Instruction::operator&(uint32_t mask) const { |
+ return _bits & mask; |
+} |
+ |
+} // namespace |
+ |
+#endif // NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_MIPS_MODEL_INL_H |