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

Side by Side Diff: src/mips/assembler-mips.h

Issue 1320006: Updates and fixes for MIPS support. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. 1 // Copyright (c) 1994-2006 Sun Microsystems Inc.
2 // All Rights Reserved. 2 // All Rights Reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // - Redistributions of source code must retain the above copyright notice, 8 // - Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer. 9 // this list of conditions and the following disclaimer.
10 // 10 //
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 bool is_valid() const { return 0 <= code_ && code_ < kNumFPURegister ; } 132 bool is_valid() const { return 0 <= code_ && code_ < kNumFPURegister ; }
133 bool is(FPURegister creg) const { return code_ == creg.code_; } 133 bool is(FPURegister creg) const { return code_ == creg.code_; }
134 int code() const { 134 int code() const {
135 ASSERT(is_valid()); 135 ASSERT(is_valid());
136 return code_; 136 return code_;
137 } 137 }
138 int bit() const { 138 int bit() const {
139 ASSERT(is_valid()); 139 ASSERT(is_valid());
140 return 1 << code_; 140 return 1 << code_;
141 } 141 }
142 142 void setcode(int f) {
Søren Thygesen Gjesse 2010/05/25 09:00:56 setcode -> set_code
143 code_ = f;
144 ASSERT(is_valid());
145 }
143 // Unfortunately we can't make this private in a struct. 146 // Unfortunately we can't make this private in a struct.
144 int code_; 147 int code_;
145 }; 148 };
146 149
147 extern const FPURegister no_creg; 150 extern const FPURegister no_creg;
148 151
149 extern const FPURegister f0; 152 extern const FPURegister f0;
150 extern const FPURegister f1; 153 extern const FPURegister f1;
151 extern const FPURegister f2; 154 extern const FPURegister f2;
152 extern const FPURegister f3; 155 extern const FPURegister f3;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 263
261 explicit MemOperand(Register rn, int16_t offset = 0); 264 explicit MemOperand(Register rn, int16_t offset = 0);
262 265
263 private: 266 private:
264 int16_t offset_; 267 int16_t offset_;
265 268
266 friend class Assembler; 269 friend class Assembler;
267 }; 270 };
268 271
269 272
273 // CpuFeatures keeps track of which features are supported by the target CPU.
274 // Supported features must be enabled by a Scope before use.
275 class CpuFeatures : public AllStatic {
276 public:
277 // Detect features of the target CPU. Set safe defaults if the serializer
278 // is enabled (snapshots must be portable).
279 static void Probe();
280
281 // Check whether a feature is supported by the target CPU.
282 static bool IsSupported(CpuFeature f) {
283 if (f == FPU && !FLAG_enable_fpu) return false;
284 return (supported_ & (1u << f)) != 0;
285 }
286
287 // Check whether a feature is currently enabled.
288 static bool IsEnabled(CpuFeature f) {
289 return (enabled_ & (1u << f)) != 0;
290 }
291
292 // Enable a specified feature within a scope.
293 class Scope BASE_EMBEDDED {
294 #ifdef DEBUG
295 public:
296 explicit Scope(CpuFeature f) {
297 ASSERT(CpuFeatures::IsSupported(f));
298 ASSERT(!Serializer::enabled() ||
299 (found_by_runtime_probing_ & (1u << f)) == 0);
300 old_enabled_ = CpuFeatures::enabled_;
301 CpuFeatures::enabled_ |= 1u << f;
302 }
303 ~Scope() { CpuFeatures::enabled_ = old_enabled_; }
304 private:
305 unsigned old_enabled_;
306 #else
307 public:
308 explicit Scope(CpuFeature f) {}
309 #endif
310 };
311
312 private:
313 static unsigned supported_;
314 static unsigned enabled_;
315 static unsigned found_by_runtime_probing_;
316 };
317
318
270 class Assembler : public Malloced { 319 class Assembler : public Malloced {
271 public: 320 public:
272 // Create an assembler. Instructions and relocation information are emitted 321 // Create an assembler. Instructions and relocation information are emitted
273 // into a buffer, with the instructions starting from the beginning and the 322 // into a buffer, with the instructions starting from the beginning and the
274 // relocation information starting from the end of the buffer. See CodeDesc 323 // relocation information starting from the end of the buffer. See CodeDesc
275 // for a detailed comment on the layout (globals.h). 324 // for a detailed comment on the layout (globals.h).
276 // 325 //
277 // If the provided buffer is NULL, the assembler allocates and grows its own 326 // If the provided buffer is NULL, the assembler allocates and grows its own
278 // buffer, and buffer_size determines the initial buffer size. The buffer is 327 // buffer, and buffer_size determines the initial buffer size. The buffer is
279 // owned by the assembler and deallocated upon destruction of the assembler. 328 // owned by the assembler and deallocated upon destruction of the assembler.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 // Jump targets must be in the current 256 MB-aligned region. ie 28 bits. 439 // Jump targets must be in the current 256 MB-aligned region. ie 28 bits.
391 void j(int32_t target); 440 void j(int32_t target);
392 void jal(int32_t target); 441 void jal(int32_t target);
393 void jalr(Register rs, Register rd = ra); 442 void jalr(Register rs, Register rd = ra);
394 void jr(Register target); 443 void jr(Register target);
395 444
396 445
397 //-------Data-processing-instructions--------- 446 //-------Data-processing-instructions---------
398 447
399 // Arithmetic. 448 // Arithmetic.
400 void add(Register rd, Register rs, Register rt);
401 void addu(Register rd, Register rs, Register rt); 449 void addu(Register rd, Register rs, Register rt);
402 void sub(Register rd, Register rs, Register rt);
403 void subu(Register rd, Register rs, Register rt); 450 void subu(Register rd, Register rs, Register rt);
404 void mult(Register rs, Register rt); 451 void mult(Register rs, Register rt);
405 void multu(Register rs, Register rt); 452 void multu(Register rs, Register rt);
406 void div(Register rs, Register rt); 453 void div(Register rs, Register rt);
407 void divu(Register rs, Register rt); 454 void divu(Register rs, Register rt);
408 void mul(Register rd, Register rs, Register rt); 455 void mul(Register rd, Register rs, Register rt);
409 456
410 void addi(Register rd, Register rs, int32_t j);
411 void addiu(Register rd, Register rs, int32_t j); 457 void addiu(Register rd, Register rs, int32_t j);
412 458
413 // Logical. 459 // Logical.
414 void and_(Register rd, Register rs, Register rt); 460 void and_(Register rd, Register rs, Register rt);
415 void or_(Register rd, Register rs, Register rt); 461 void or_(Register rd, Register rs, Register rt);
416 void xor_(Register rd, Register rs, Register rt); 462 void xor_(Register rd, Register rs, Register rt);
417 void nor(Register rd, Register rs, Register rt); 463 void nor(Register rd, Register rs, Register rt);
418 464
419 void andi(Register rd, Register rs, int32_t j); 465 void andi(Register rd, Register rs, int32_t j);
420 void ori(Register rd, Register rs, int32_t j); 466 void ori(Register rd, Register rs, int32_t j);
421 void xori(Register rd, Register rs, int32_t j); 467 void xori(Register rd, Register rs, int32_t j);
422 void lui(Register rd, int32_t j); 468 void lui(Register rd, int32_t j);
423 469
424 // Shifts. 470 // Shifts.
425 void sll(Register rd, Register rt, uint16_t sa); 471 void sll(Register rd, Register rt, uint16_t sa);
426 void sllv(Register rd, Register rt, Register rs); 472 void sllv(Register rd, Register rt, Register rs);
427 void srl(Register rd, Register rt, uint16_t sa); 473 void srl(Register rd, Register rt, uint16_t sa);
428 void srlv(Register rd, Register rt, Register rs); 474 void srlv(Register rd, Register rt, Register rs);
429 void sra(Register rt, Register rd, uint16_t sa); 475 void sra(Register rt, Register rd, uint16_t sa);
430 void srav(Register rt, Register rd, Register rs); 476 void srav(Register rt, Register rd, Register rs);
431 477
432 478
433 //------------Memory-instructions------------- 479 //------------Memory-instructions-------------
434 480
435 void lb(Register rd, const MemOperand& rs); 481 void lb(Register rd, const MemOperand& rs);
436 void lbu(Register rd, const MemOperand& rs); 482 void lbu(Register rd, const MemOperand& rs);
483 void lh(Register rd, const MemOperand& rs);
484 void lhu(Register rd, const MemOperand& rs);
437 void lw(Register rd, const MemOperand& rs); 485 void lw(Register rd, const MemOperand& rs);
438 void sb(Register rd, const MemOperand& rs); 486 void sb(Register rd, const MemOperand& rs);
487 void sh(Register rd, const MemOperand& rs);
439 void sw(Register rd, const MemOperand& rs); 488 void sw(Register rd, const MemOperand& rs);
440 489
441 490
442 //-------------Misc-instructions-------------- 491 //-------------Misc-instructions--------------
443 492
444 // Break / Trap instructions. 493 // Break / Trap instructions.
445 void break_(uint32_t code); 494 void break_(uint32_t code);
446 void tge(Register rs, Register rt, uint16_t code); 495 void tge(Register rs, Register rt, uint16_t code);
447 void tgeu(Register rs, Register rt, uint16_t code); 496 void tgeu(Register rs, Register rt, uint16_t code);
448 void tlt(Register rs, Register rt, uint16_t code); 497 void tlt(Register rs, Register rt, uint16_t code);
449 void tltu(Register rs, Register rt, uint16_t code); 498 void tltu(Register rs, Register rt, uint16_t code);
450 void teq(Register rs, Register rt, uint16_t code); 499 void teq(Register rs, Register rt, uint16_t code);
451 void tne(Register rs, Register rt, uint16_t code); 500 void tne(Register rs, Register rt, uint16_t code);
452 501
453 // Move from HI/LO register. 502 // Move from HI/LO register.
454 void mfhi(Register rd); 503 void mfhi(Register rd);
455 void mflo(Register rd); 504 void mflo(Register rd);
456 505
457 // Set on less than. 506 // Set on less than.
458 void slt(Register rd, Register rs, Register rt); 507 void slt(Register rd, Register rs, Register rt);
459 void sltu(Register rd, Register rs, Register rt); 508 void sltu(Register rd, Register rs, Register rt);
460 void slti(Register rd, Register rs, int32_t j); 509 void slti(Register rd, Register rs, int32_t j);
461 void sltiu(Register rd, Register rs, int32_t j); 510 void sltiu(Register rd, Register rs, int32_t j);
462 511
512 // Conditional move.
513 void movz(Register rd, Register rs, Register rt);
514 void movn(Register rd, Register rs, Register rt);
515
516 // Bit twiddling.
517 void clz(Register rd, Register rs);
518 void ins(Register rt, Register rs, uint16_t pos, uint16_t size);
519 void ext(Register rt, Register rs, uint16_t pos, uint16_t size);
463 520
464 //--------Coprocessor-instructions---------------- 521 //--------Coprocessor-instructions----------------
465 522
466 // Load, store, and move. 523 // Load, store, and move.
467 void lwc1(FPURegister fd, const MemOperand& src); 524 void lwc1(FPURegister fd, const MemOperand& src);
468 void ldc1(FPURegister fd, const MemOperand& src); 525 void ldc1(FPURegister fd, const MemOperand& src);
469 526
470 void swc1(FPURegister fs, const MemOperand& dst); 527 void swc1(FPURegister fs, const MemOperand& dst);
471 void sdc1(FPURegister fs, const MemOperand& dst); 528 void sdc1(FPURegister fs, const MemOperand& dst);
472 529
473 // When paired with MTC1 to write a value to a 64-bit FPR, the MTC1 must be 530 void mtc1(Register rt, FPURegister fs);
474 // executed first, followed by the MTHC1. 531 void mfc1(Register rt, FPURegister fs);
475 void mtc1(FPURegister fs, Register rt); 532
476 void mthc1(FPURegister fs, Register rt); 533 // Arithmetic.
477 void mfc1(FPURegister fs, Register rt); 534 void add_d(FPURegister fd, FPURegister fs, FPURegister ft);
478 void mfhc1(FPURegister fs, Register rt); 535 void sub_d(FPURegister fd, FPURegister fs, FPURegister ft);
536 void mul_d(FPURegister fd, FPURegister fs, FPURegister ft);
537 void div_d(FPURegister fd, FPURegister fs, FPURegister ft);
538 void abs_d(FPURegister fd, FPURegister fs);
539 void mov_d(FPURegister fd, FPURegister fs);
540 void neg_d(FPURegister fd, FPURegister fs);
479 541
480 // Conversion. 542 // Conversion.
481 void cvt_w_s(FPURegister fd, FPURegister fs); 543 void cvt_w_s(FPURegister fd, FPURegister fs);
482 void cvt_w_d(FPURegister fd, FPURegister fs); 544 void cvt_w_d(FPURegister fd, FPURegister fs);
483 545
484 void cvt_l_s(FPURegister fd, FPURegister fs); 546 void cvt_l_s(FPURegister fd, FPURegister fs);
485 void cvt_l_d(FPURegister fd, FPURegister fs); 547 void cvt_l_d(FPURegister fd, FPURegister fs);
486 548
487 void cvt_s_w(FPURegister fd, FPURegister fs); 549 void cvt_s_w(FPURegister fd, FPURegister fs);
488 void cvt_s_l(FPURegister fd, FPURegister fs); 550 void cvt_s_l(FPURegister fd, FPURegister fs);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 // Anyway we could surely implement this differently. 670 // Anyway we could surely implement this differently.
609 671
610 void GenInstrRegister(Opcode opcode, 672 void GenInstrRegister(Opcode opcode,
611 Register rs, 673 Register rs,
612 Register rt, 674 Register rt,
613 Register rd, 675 Register rd,
614 uint16_t sa = 0, 676 uint16_t sa = 0,
615 SecondaryField func = NULLSF); 677 SecondaryField func = NULLSF);
616 678
617 void GenInstrRegister(Opcode opcode, 679 void GenInstrRegister(Opcode opcode,
680 Register rs,
681 Register rt,
682 uint16_t msb,
683 uint16_t lsb,
684 SecondaryField func);
685
686 void GenInstrRegister(Opcode opcode,
618 SecondaryField fmt, 687 SecondaryField fmt,
619 FPURegister ft, 688 FPURegister ft,
620 FPURegister fs, 689 FPURegister fs,
621 FPURegister fd, 690 FPURegister fd,
622 SecondaryField func = NULLSF); 691 SecondaryField func = NULLSF);
623 692
624 void GenInstrRegister(Opcode opcode, 693 void GenInstrRegister(Opcode opcode,
625 SecondaryField fmt, 694 SecondaryField fmt,
626 Register rt, 695 Register rt,
627 FPURegister fs, 696 FPURegister fs,
(...skipping 26 matching lines...) Expand all
654 void next(Label* L); 723 void next(Label* L);
655 724
656 friend class RegExpMacroAssemblerMIPS; 725 friend class RegExpMacroAssemblerMIPS;
657 friend class RelocInfo; 726 friend class RelocInfo;
658 }; 727 };
659 728
660 } } // namespace v8::internal 729 } } // namespace v8::internal
661 730
662 #endif // V8_ARM_ASSEMBLER_MIPS_H_ 731 #endif // V8_ARM_ASSEMBLER_MIPS_H_
663 732
OLDNEW
« no previous file with comments | « src/globals.h ('k') | src/mips/assembler-mips.cc » ('j') | src/mips/assembler-mips.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698