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

Side by Side Diff: runtime/vm/assembler_mips.h

Issue 2937933002: Reduce copying, redundancy & repetition for codegen of comparison instructions (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | runtime/vm/constants_arm.h » ('j') | runtime/vm/constants_arm.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef RUNTIME_VM_ASSEMBLER_MIPS_H_ 5 #ifndef RUNTIME_VM_ASSEMBLER_MIPS_H_
6 #define RUNTIME_VM_ASSEMBLER_MIPS_H_ 6 #define RUNTIME_VM_ASSEMBLER_MIPS_H_
7 7
8 #ifndef RUNTIME_VM_ASSEMBLER_H_ 8 #ifndef RUNTIME_VM_ASSEMBLER_H_
9 #error Do not include assembler_mips.h directly; use assembler.h instead. 9 #error Do not include assembler_mips.h directly; use assembler.h instead.
10 #endif 10 #endif
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 static bool IsValidImm(int32_t value) { 170 static bool IsValidImm(int32_t value) {
171 // We want both value and value + 1 to fit in an int16_t. 171 // We want both value and value + 1 to fit in an int16_t.
172 return (-0x08000 <= value) && (value < 0x7fff); 172 return (-0x08000 <= value) && (value < 0x7fff);
173 } 173 }
174 174
175 void set_rel_op(RelationOperator value) { 175 void set_rel_op(RelationOperator value) {
176 ASSERT(IsValidRelOp(value)); 176 ASSERT(IsValidRelOp(value));
177 bits_ = RelOpBits::update(value, bits_); 177 bits_ = RelOpBits::update(value, bits_);
178 } 178 }
179 179
180 void SetToInvalidState() {
Vyacheslav Egorov (Google) 2017/06/15 11:32:46 Maybe this method should be private?
erikcorry 2017/06/19 07:15:08 Done.
181 bits_ = RelOpBits::update(INVALID_RELATION, bits_);
182 }
183
184 bool IsValid() { return rel_op() != INVALID_RELATION; }
185
180 // Uninitialized condition. 186 // Uninitialized condition.
181 Condition() : ValueObject(), bits_(0) {} 187 Condition() : ValueObject(), bits_(0) {}
Vyacheslav Egorov (Google) 2017/06/15 11:32:46 I would suggest that this one sets bits_ to invali
erikcorry 2017/06/19 07:15:09 Done.
182 188
183 // Copy constructor. 189 // Copy constructor.
184 Condition(const Condition& other) : ValueObject(), bits_(other.bits_) {} 190 Condition(const Condition& other) : ValueObject(), bits_(other.bits_) {}
185 191
186 // Copy assignment operator. 192 // Copy assignment operator.
187 Condition& operator=(const Condition& other) { 193 Condition& operator=(const Condition& other) {
188 bits_ = other.bits_; 194 bits_ = other.bits_;
189 return *this; 195 return *this;
190 } 196 }
191 197
192 Condition(Register left, 198 Condition(Register left,
193 Register right, 199 Register right,
194 RelationOperator rel_op, 200 RelationOperator rel_op,
195 int16_t imm = 0) { 201 int16_t imm = 0) {
196 // At most one constant, ZR or immediate. 202 // At most one constant, ZR or immediate.
197 ASSERT(!(((left == ZR) || (left == IMM)) && 203 ASSERT(!(((left == ZR) || (left == IMM)) &&
198 ((right == ZR) || (right == IMM)))); 204 ((right == ZR) || (right == IMM))));
199 // Non-zero immediate value is only allowed for IMM. 205 // Non-zero immediate value is only allowed for IMM.
200 ASSERT((imm != 0) == ((left == IMM) || (right == IMM))); 206 ASSERT((imm != 0) == ((left == IMM) || (right == IMM)));
201 set_left(left); 207 set_left(left);
202 set_right(right); 208 set_right(right);
203 set_rel_op(rel_op); 209 if (rel_op == INVALID_RELATION) {
Vyacheslav Egorov (Google) 2017/06/15 11:32:46 ... and here ASSERT(rel_op != INVALID_RELATION)
erikcorry 2017/06/19 07:15:09 I put the assert in the getters for the register n
210 SetToInvalidState();
211 } else {
212 set_rel_op(rel_op);
213 }
204 set_imm(imm); 214 set_imm(imm);
205 } 215 }
206 216
207 private: 217 private:
208 static bool IsValidRelOp(RelationOperator value) { 218 static bool IsValidRelOp(RelationOperator value) {
Vyacheslav Egorov (Google) 2017/06/15 11:32:46 I would not be surprised if this gets completely o
erikcorry 2017/06/19 07:15:09 Ack
209 return (AL <= value) && (value <= ULE); 219 return (AL <= value) && (value <= ULE);
210 } 220 }
211 221
212 static bool IsValidRegister(Register value) { 222 static bool IsValidRegister(Register value) {
213 return (ZR <= value) && (value <= IMM) && (value != AT); 223 return (ZR <= value) && (value <= IMM) && (value != AT);
214 } 224 }
215 225
216 void set_left(Register value) { 226 void set_left(Register value) {
217 ASSERT(IsValidRegister(value)); 227 ASSERT(IsValidRegister(value));
218 bits_ = LeftBits::update(value, bits_); 228 bits_ = LeftBits::update(value, bits_);
(...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 Register value, 1703 Register value,
1694 Label* no_update); 1704 Label* no_update);
1695 1705
1696 DISALLOW_ALLOCATION(); 1706 DISALLOW_ALLOCATION();
1697 DISALLOW_COPY_AND_ASSIGN(Assembler); 1707 DISALLOW_COPY_AND_ASSIGN(Assembler);
1698 }; 1708 };
1699 1709
1700 } // namespace dart 1710 } // namespace dart
1701 1711
1702 #endif // RUNTIME_VM_ASSEMBLER_MIPS_H_ 1712 #endif // RUNTIME_VM_ASSEMBLER_MIPS_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/constants_arm.h » ('j') | runtime/vm/constants_arm.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698