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

Unified Diff: src/trusted/validator_mips/model-inl.h

Issue 9979025: [MIPS] Adding validator for MIPS architecture. (Closed) Base URL: http://src.chromium.org/native_client/trunk/src/native_client/
Patch Set: Minor style changes. Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
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 100755
index 0000000000000000000000000000000000000000..692675e723143baae161471130dd474b45461704
--- /dev/null
+++ b/src/trusted/validator_mips/model-inl.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2012 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 2012, 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 {
Brad Chen 2012/05/04 22:49:50 Avoid operator overloading.
petarj 2012/05/08 14:54:19 Taken from validator_arm/model-inl.h
Brad Chen 2012/05/29 16:20:39 I guess we could get a second opinion from Karl or
+ 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

Powered by Google App Engine
This is Rietveld 408576698