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

Unified Diff: runtime/vm/assembler_mips.h

Issue 2937933002: Reduce copying, redundancy & repetition for codegen of comparison instructions (Closed)
Patch Set: Feedback from Slava Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/constants_arm.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/assembler_mips.h
diff --git a/runtime/vm/assembler_mips.h b/runtime/vm/assembler_mips.h
index 2236b7fc3d8b6fe6766d4731c71a057ecbdede2f..7073e3078830b282307b06d35b3b03f4fb5be6e4 100644
--- a/runtime/vm/assembler_mips.h
+++ b/runtime/vm/assembler_mips.h
@@ -162,10 +162,20 @@ class Condition : public ValueObject {
: public BitField<uword, RelationOperator, kRelOpPos, kRelOpSize> {};
class ImmBits : public BitField<uword, uint16_t, kImmPos, kImmSize> {};
- Register left() const { return LeftBits::decode(bits_); }
- Register right() const { return RightBits::decode(bits_); }
+ Register left() const {
+ ASSERT(IsValid());
+ return LeftBits::decode(bits_);
+ }
+
+ Register right() const {
+ ASSERT(IsValid());
+ return RightBits::decode(bits_);
+ }
RelationOperator rel_op() const { return RelOpBits::decode(bits_); }
- int16_t imm() const { return static_cast<int16_t>(ImmBits::decode(bits_)); }
+ int16_t imm() const {
+ ASSERT(IsValid());
+ return static_cast<int16_t>(ImmBits::decode(bits_));
+ }
static bool IsValidImm(int32_t value) {
// We want both value and value + 1 to fit in an int16_t.
@@ -177,8 +187,10 @@ class Condition : public ValueObject {
bits_ = RelOpBits::update(value, bits_);
}
+ bool IsValid() const { return rel_op() != INVALID_RELATION; }
+
// Uninitialized condition.
- Condition() : ValueObject(), bits_(0) {}
+ Condition() : ValueObject(), bits_(RelOpBits::update(INVALID_RELATION, 0)) {}
// Copy constructor.
Condition(const Condition& other) : ValueObject(), bits_(other.bits_) {}
@@ -200,11 +212,19 @@ class Condition : public ValueObject {
ASSERT((imm != 0) == ((left == IMM) || (right == IMM)));
set_left(left);
set_right(right);
- set_rel_op(rel_op);
+ if (rel_op == INVALID_RELATION) {
+ SetToInvalidState();
+ } else {
+ set_rel_op(rel_op);
+ }
set_imm(imm);
}
private:
+ void SetToInvalidState() {
+ bits_ = RelOpBits::update(INVALID_RELATION, bits_);
+ }
+
static bool IsValidRelOp(RelationOperator value) {
return (AL <= value) && (value <= ULE);
}
« no previous file with comments | « no previous file | runtime/vm/constants_arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698