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

Side by Side 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, 6 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2012 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can
4 * be found in the LICENSE file.
5 * Copyright 2012, Google Inc.
6 */
7
8 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_MIPS_MODEL_INL_H
9 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_MIPS_MODEL_INL_H
10 /*
11 * Inline definitions for the classes defined in model.h
12 */
13
14 namespace nacl_mips_dec {
15
16 Register::Register(uint32_t number) : _number(number) {}
17 uint32_t Register::Bitmask() const {
18 if (_number == 31) return 0;
19
20 return (1 << _number);
21 }
22
23 bool Register::Equals(const Register &other) const {
24 return _number == other._number;
25 }
26
27 RegisterList::RegisterList(uint32_t bits) : _bits(bits) {}
28 RegisterList::RegisterList(Register reg) : _bits(reg.Bitmask()) {}
29
30 bool RegisterList::operator[](Register reg) const {
31 return _bits & reg.Bitmask();
32 }
33
34 bool RegisterList::ContainsAll(const RegisterList other) const {
35 return (_bits & other._bits) == other._bits;
36 }
37
38 bool RegisterList::ContainsAny(const RegisterList other) const {
39 return _bits & other._bits;
40 }
41
42 const RegisterList RegisterList::operator&(const RegisterList other) const {
43 return RegisterList(_bits & other._bits);
44 }
45
46 inline Instruction::Instruction(uint32_t bits) : _bits(bits) {}
47
48 inline uint32_t Instruction::Bits(int hi, int lo) const {
49 uint32_t right_justified = _bits >> lo;
50 int bit_count = hi - lo + 1;
51 uint32_t mask = (1 << bit_count) - 1;
52 return right_justified & mask;
53 }
54
55 inline const Register Instruction::Reg(int hi, int lo) const {
56 return Register(Bits(hi, lo));
57 }
58
59 inline bool Instruction::Bit(int index) const {
60 return (_bits >> index) & 1;
61 }
62
63 inline uint32_t Instruction::operator&(uint32_t mask) const {
64 return _bits & mask;
65 }
66
67 } // namespace
68
69 #endif // NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_MIPS_MODEL_INL_H
OLDNEW
« 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