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

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

Issue 11876041: [MIPS] Add thread-pointer to data addressing register list. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Update the comment. Created 7 years, 11 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/inst_classes.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.h
diff --git a/src/trusted/validator_mips/model.h b/src/trusted/validator_mips/model.h
index fc709cb936b523b59bd080a9e8d0a1f7a64afd5d..12a268ccefe9ae49b0d23151d2d43549181ed12e 100644
--- a/src/trusted/validator_mips/model.h
+++ b/src/trusted/validator_mips/model.h
@@ -30,6 +30,7 @@ namespace nacl_mips_dec {
*/
class Register {
public:
+ typedef uint8_t Number;
explicit inline Register(uint32_t);
/*
@@ -39,19 +40,29 @@ class Register {
inline bool Equals(const Register &) const;
- private:
- uint32_t _number;
-};
+ static const Number kJumpMask = 14; // $t6 = holds mask for jr.
+ static const Number kLoadStoreMask = 15; // $t7 = holds mask for load/store.
+ static const Number kTls = 24; // $t8 = holds tls index.
+ static const Number kSp = 29; // Stack pointer.
-const Register kRegisterNone(0);
+ static const Number kNone = 32;
-// Registers with special meaning in our model:
-const Register kRegisterStack(29);
-const Register kRegisterJumpMask(14); // $t6 = holds mask for jr.
-const Register kRegisterLoadStoreMask(15); // $t7 = holds mask for load/store.
-const Register kRegisterTls(24); // $t8 = holds tls index.
+ /*
+ * A special value used to indicate that a register field is not used.
+ * This is specially chosen to ensure that bitmask() == 0, so it can be added
+ * to any RegisterList with no effect.
+ */
+ static Register None() { return Register(kNone); }
-const Register kRegisterZero(0);
+ /* Registers with special meaning in our model: */
+ static Register JumpMask() { return Register(kJumpMask); }
+ static Register LoadStoreMask() { return Register(kLoadStoreMask); }
+ static Register Tls() { return Register(kTls); }
+ static Register Sp() { return Register(kSp); }
+
+ private:
+ uint32_t _number;
+};
/*
* A collection of Registers. Used to describe the side effects of operations.
@@ -92,22 +103,30 @@ class RegisterList {
inline const RegisterList operator&(const RegisterList) const;
+ /*
+ * A list containing every possible register, even some we do not define.
+ * Used exclusively as a bogus scary return value for forbidden instructions.
+ */
+ static RegisterList Everything() { return RegisterList(-1); }
+
+ /* A list of registers that can not be modified by untrusted code. */
+ static RegisterList ReservedRegs() {
+ return RegisterList(((1 << Register::kJumpMask) |
+ (1 << Register::kLoadStoreMask) |
+ (1 << Register::kTls)));
+ }
+
+ /* A list of registers that can be used for addressing memory locations. */
+ static RegisterList DataAddrRegs() {
+ return RegisterList(((1 << Register::kSp) |
+ (1 << Register::kTls)));
+ }
+
private:
uint32_t _bits;
};
/*
- * A list containing every possible register, even some we don't define.
- * Used exclusively as a bogus scary return value for forbidden instructions.
- */
-static const RegisterList kRegisterListEverything = RegisterList(-1);
-
-static uint32_t const kReservedRegsBitmask = kRegisterTls.Bitmask()
- + kRegisterJumpMask.Bitmask()
- + kRegisterLoadStoreMask.Bitmask();
-static RegisterList const kRegListReserved = RegisterList(kReservedRegsBitmask);
-
-/*
* A 32-bit Mips instruction of unspecified type.
*
* This class is designed for efficiency:
« no previous file with comments | « src/trusted/validator_mips/inst_classes.h ('k') | src/trusted/validator_mips/ncval.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698