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

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

Issue 12545024: Adds a few MIPS arithmetic instructions to the simulator, assembler, disassembler (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/assembler_mips_test.cc » ('j') | runtime/vm/assembler_mips_test.cc » ('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 VM_ASSEMBLER_MIPS_H_ 5 #ifndef VM_ASSEMBLER_MIPS_H_
6 #define VM_ASSEMBLER_MIPS_H_ 6 #define VM_ASSEMBLER_MIPS_H_
7 7
8 #ifndef VM_ASSEMBLER_H_ 8 #ifndef 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 ASSERT(delay_slot_available_); 213 ASSERT(delay_slot_available_);
214 ASSERT(buffer_.Load<int32_t>(buffer_.GetPosition() - sizeof(int32_t)) == 214 ASSERT(buffer_.Load<int32_t>(buffer_.GetPosition() - sizeof(int32_t)) ==
215 Instr::kNopInstruction); 215 Instr::kNopInstruction);
216 buffer_.Remit<int32_t>(); 216 buffer_.Remit<int32_t>();
217 delay_slot_available_ = false; 217 delay_slot_available_ = false;
218 in_delay_slot_ = true; 218 in_delay_slot_ = true;
219 return this; 219 return this;
220 } 220 }
221 221
222 // CPU instructions. 222 // CPU instructions.
223 void addi(Register rt, Register rs, const Immediate& imm) {
224 ASSERT(Utils::IsUint(16, imm.value()));
Ivan Posva 2013/03/11 06:03:27 I would expect that imm is checked against Utils::
zra 2013/03/11 15:46:03 Yah, you're right. I've already fixed this in my n
225 uint16_t imm_value = static_cast<uint16_t>(imm.value());
226 EmitIType(ADDI, rs, rt, imm_value);
Ivan Posva 2013/03/11 06:03:27 Also I am not sure we even use this instruction du
zra 2013/03/11 15:46:03 Should I remove it?
227 }
228
229 void addiu(Register rt, Register rs, const Immediate& imm) {
230 ASSERT(Utils::IsUint(16, imm.value()));
Ivan Posva 2013/03/11 06:03:27 ditto (sign extension)
zra 2013/03/11 15:46:03 In next CL
231 uint16_t imm_value = static_cast<uint16_t>(imm.value());
232 EmitIType(ADDIU, rs, rt, imm_value);
233 }
234
235 void addu(Register rd, Register rs, Register rt) {
236 EmitRType(SPECIAL, rs, rt, rd, 0, ADDU);
237 }
238
239 void and_(Register rd, Register rs, Register rt) {
240 EmitRType(SPECIAL, rs, rt, rd, 0, AND);
241 }
242
243 void andi(Register rt, Register rs, const Immediate& imm) {
244 ASSERT(Utils::IsUint(16, imm.value()));
245 uint16_t imm_value = static_cast<uint16_t>(imm.value());
246 EmitIType(ANDI, rs, rt, imm_value);
247 }
248
249 void clo(Register rd, Register rs) {
250 EmitRType(SPECIAL2, rs, rd, rd, 0, CLO);
251 }
252
253 void clz(Register rd, Register rs) {
254 EmitRType(SPECIAL2, rs, rd, rd, 0, CLZ);
255 }
256
257 void div(Register rs, Register rt) {
258 EmitRType(SPECIAL, rs, rt, R0, 0, DIV);
259 }
260
261 void divu(Register rs, Register rt) {
262 EmitRType(SPECIAL, rs, rt, R0, 0, DIVU);
263 }
264
265 void lui(Register rt, const Immediate& imm) {
266 ASSERT(Utils::IsUint(16, imm.value()));
267 uint16_t imm_value = static_cast<uint16_t>(imm.value());
268 EmitIType(LUI, R0, rt, imm_value);
269 }
270
271 void mfhi(Register rd) {
272 EmitRType(SPECIAL, R0, R0, rd, 0, MFHI);
273 }
274
275 void mflo(Register rd) {
276 EmitRType(SPECIAL, R0, R0, rd, 0, MFLO);
277 }
278
223 void ori(Register rt, Register rs, const Immediate& imm) { 279 void ori(Register rt, Register rs, const Immediate& imm) {
224 ASSERT(Utils::IsUint(16, imm.value())); 280 ASSERT(Utils::IsUint(16, imm.value()));
225 uint16_t imm_value = static_cast<uint16_t>(imm.value()); 281 uint16_t imm_value = static_cast<uint16_t>(imm.value());
226 EmitIType(ORI, rs, rt, imm_value); 282 EmitIType(ORI, rs, rt, imm_value);
227 } 283 }
228 284
229 void jr(Register rs) { 285 void jr(Register rs) {
230 ASSERT(!in_delay_slot_); // Jump within a delay slot is not supported. 286 ASSERT(!in_delay_slot_); // Jump within a delay slot is not supported.
231 EmitRType(SPECIAL, rs, R0, R0, 0, JR); 287 EmitRType(SPECIAL, rs, R0, R0, 0, JR);
232 Emit(Instr::kNopInstruction); // Branch delay NOP. 288 Emit(Instr::kNopInstruction); // Branch delay NOP.
233 delay_slot_available_ = true; 289 delay_slot_available_ = true;
234 } 290 }
235 291
292 void sll(Register rd, Register rt, int sa) {
293 EmitRType(SPECIAL, R0, rt, rd, sa, SLL);
294 }
295
296 // Macros.
297 void LoadImmediate(Register rd, int32_t value) {
298 lui(rd, Immediate((value >> 16) & 0xffff));
299 ori(rd, rd, Immediate(value & 0xffff));
300 }
301
236 private: 302 private:
237 AssemblerBuffer buffer_; 303 AssemblerBuffer buffer_;
238 GrowableObjectArray& object_pool_; // Objects and patchable jump targets. 304 GrowableObjectArray& object_pool_; // Objects and patchable jump targets.
239 int prologue_offset_; 305 int prologue_offset_;
240 306
241 bool delay_slot_available_; 307 bool delay_slot_available_;
242 bool in_delay_slot_; 308 bool in_delay_slot_;
243 309
244 class CodeComment : public ZoneAllocated { 310 class CodeComment : public ZoneAllocated {
245 public: 311 public:
(...skipping 25 matching lines...) Expand all
271 void EmitIType(Opcode opcode, 337 void EmitIType(Opcode opcode,
272 Register rs, 338 Register rs,
273 Register rt, 339 Register rt,
274 uint16_t imm) { 340 uint16_t imm) {
275 Emit(opcode << kOpcodeShift | 341 Emit(opcode << kOpcodeShift |
276 rs << kRsShift | 342 rs << kRsShift |
277 rt << kRtShift | 343 rt << kRtShift |
278 imm); 344 imm);
279 } 345 }
280 346
347 void EmitRegImmType(Opcode opcode,
348 Register rs,
349 RtRegImm code,
350 uint16_t imm) {
351 Emit(opcode << kOpcodeShift |
352 rs << kRsShift |
353 code << kRtShift |
354 imm);
355 }
356
281 void EmitJType(Opcode opcode, Label* label) { 357 void EmitJType(Opcode opcode, Label* label) {
282 UNIMPLEMENTED(); 358 UNIMPLEMENTED();
283 } 359 }
284 360
285 void EmitRType(Opcode opcode, 361 void EmitRType(Opcode opcode,
286 Register rs, 362 Register rs,
287 Register rt, 363 Register rt,
288 Register rd, 364 Register rd,
289 int sa, 365 int sa,
290 SpecialFunction func) { 366 SpecialFunction func) {
291 ASSERT(Utils::IsUint(5, sa)); 367 ASSERT(Utils::IsUint(5, sa));
292 Emit(opcode << kOpcodeShift | 368 Emit(opcode << kOpcodeShift |
293 rs << kRsShift | 369 rs << kRsShift |
294 rt << kRtShift | 370 rt << kRtShift |
295 rd << kRdShift | 371 rd << kRdShift |
296 sa << kSaShift | 372 sa << kSaShift |
297 func << kFunctionShift); 373 func << kFunctionShift);
298 } 374 }
299 375
300 DISALLOW_ALLOCATION(); 376 DISALLOW_ALLOCATION();
301 DISALLOW_COPY_AND_ASSIGN(Assembler); 377 DISALLOW_COPY_AND_ASSIGN(Assembler);
302 }; 378 };
303 379
304 } // namespace dart 380 } // namespace dart
305 381
306 #endif // VM_ASSEMBLER_MIPS_H_ 382 #endif // VM_ASSEMBLER_MIPS_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/assembler_mips_test.cc » ('j') | runtime/vm/assembler_mips_test.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698