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

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: Minor style changes. 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 unified diff | Download patch
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::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
24 return _number == other._number;
25 }
26
27 bool Register::operator!=(const Register &other) const {
28 return _number != other._number;
29 }
30
31
32 RegisterList::RegisterList(uint32_t bits) : _bits(bits) {}
33 RegisterList::RegisterList(Register r) : _bits(r.bitmask()) {}
34
35 bool RegisterList::operator[](Register r) const {
36 return _bits & r.bitmask();
37 }
38
39 bool RegisterList::contains_all(const RegisterList other) const {
40 return (_bits & other._bits) == other._bits;
41 }
42
43 bool RegisterList::contains_any(const RegisterList other) const {
44 return _bits & other._bits;
45 }
46
47 const RegisterList RegisterList::operator&(const RegisterList other) const {
48 return RegisterList(_bits & other._bits);
49 }
50
51 bool RegisterList::operator==(const RegisterList other) const {
52 return _bits == other._bits;
53 }
54
55 const RegisterList operator+(const RegisterList a, const RegisterList b) {
56 return RegisterList(a._bits | b._bits);
57 }
58
59
60 inline Instruction::Instruction(uint32_t bits) : _bits(bits) {}
61
62 inline uint32_t Instruction::bits(int hi, int lo) const {
63 uint32_t right_justified = _bits >> lo;
64 int bit_count = hi - lo + 1;
65 uint32_t mask = (1 << bit_count) - 1;
66 return right_justified & mask;
67 }
68
69 inline const Register Instruction::reg(int hi, int lo) const {
70 return Register(bits(hi, lo));
71 }
72
73 inline bool Instruction::bit(int index) const {
74 return (_bits >> index) & 1;
75 }
76
77 inline uint32_t Instruction::operator&(uint32_t mask) const {
78 return _bits & mask;
79 }
80
81 } // namespace
82
83 #endif // NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_MIPS_MODEL_INL_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698