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

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: Rebased patch, conflict resolved. Created 8 years, 7 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
« no previous file with comments | « src/trusted/validator_mips/model.h ('k') | src/trusted/validator_mips/ncval.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f855e33a794dc38a592a2653619731d7519593e3
--- /dev/null
+++ b/src/trusted/validator_mips/model-inl.h
@@ -0,0 +1,69 @@
+/*
+ * 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::Equals(const Register &other) const {
+ return _number == other._number;
+}
+
+RegisterList::RegisterList(uint32_t bits) : _bits(bits) {}
+RegisterList::RegisterList(Register reg) : _bits(reg.Bitmask()) {}
+
+bool RegisterList::operator[](Register reg) const {
+ return _bits & reg.Bitmask();
+}
+
+bool RegisterList::ContainsAll(const RegisterList other) const {
+ return (_bits & other._bits) == other._bits;
+}
+
+bool RegisterList::ContainsAny(const RegisterList other) const {
+ return _bits & other._bits;
+}
+
+const RegisterList RegisterList::operator&(const RegisterList other) const {
+ return RegisterList(_bits & other._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
« no previous file with comments | « src/trusted/validator_mips/model.h ('k') | src/trusted/validator_mips/ncval.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698