Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===- subzero/src/IceInstMips32.cpp - Mips32 instruction implementation --===// | 1 //===- subzero/src/IceInstMips32.cpp - Mips32 instruction implementation --===// |
| 2 // | 2 // |
| 3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 // |
| 10 /// \file | 10 /// \file |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 546 Str << ", "; | 546 Str << ", "; |
| 547 SrcHi->emit(Func); | 547 SrcHi->emit(Func); |
| 548 } | 548 } |
| 549 | 549 |
| 550 void InstMIPS32Mov::emitSingleDestSingleSource(const Cfg *Func) const { | 550 void InstMIPS32Mov::emitSingleDestSingleSource(const Cfg *Func) const { |
| 551 if (!BuildDefs::dump()) | 551 if (!BuildDefs::dump()) |
| 552 return; | 552 return; |
| 553 Ostream &Str = Func->getContext()->getStrEmit(); | 553 Ostream &Str = Func->getContext()->getStrEmit(); |
| 554 Variable *Dest = getDest(); | 554 Variable *Dest = getDest(); |
| 555 Operand *Src = getSrc(0); | 555 Operand *Src = getSrc(0); |
| 556 auto *S = llvm::dyn_cast<Variable>(Src); | 556 auto *SrcV = llvm::dyn_cast<Variable>(Src); |
| 557 Str << "\t"; | 557 |
| 558 if (Dest->hasReg()) { | 558 assert(!llvm::isa<Constant>(Src)); |
| 559 if (S && S->hasReg()) | 559 |
| 560 Str << "move"; | 560 const char *ActualOpcode = nullptr; |
| 561 else | 561 const bool DestIsReg = Dest->hasReg(); |
| 562 Str << "lw"; | 562 const bool DestIsMem = !Dest->hasReg(); |
| 563 } else { | 563 const bool SrcIsReg = (SrcV && SrcV->hasReg()); |
| 564 if (S && S->hasReg()) { | 564 const bool SrcIsMem = !(SrcV && SrcV->hasReg()); |
| 565 Str << "sw" | 565 |
| 566 // reg to reg | |
| 567 if (DestIsReg && SrcIsReg) { | |
| 568 switch (Dest->getType()) { | |
| 569 case IceType_f32: | |
| 570 ActualOpcode = "mov.s"; | |
| 571 break; | |
| 572 case IceType_f64: | |
| 573 ActualOpcode = "mov.d"; | |
| 574 break; | |
| 575 case IceType_i1: | |
| 576 case IceType_i8: | |
| 577 case IceType_i16: | |
| 578 case IceType_i32: | |
| 579 Str << "\t" | |
| 580 "add" | |
| 566 "\t"; | 581 "\t"; |
|
obucinac
2016/07/06 13:41:58
This is done by format tool
| |
| 582 getDest()->emit(Func); | |
| 583 Str << ", $zero, "; | |
| 567 getSrc(0)->emit(Func); | 584 getSrc(0)->emit(Func); |
| 568 Str << ", "; | |
| 569 getDest()->emit(Func); | |
| 570 return; | 585 return; |
| 571 } else | 586 default: |
| 572 Str << "move"; | 587 UnimplementedError(getFlags()); |
| 588 return; | |
| 589 } | |
| 590 | |
| 591 assert(ActualOpcode); | |
| 592 Str << "\t" << ActualOpcode << "\t"; | |
| 593 getDest()->emit(Func); | |
| 594 Str << ", "; | |
| 595 getSrc(0)->emit(Func); | |
| 596 return; | |
| 573 } | 597 } |
| 574 | 598 |
| 575 Str << "\t"; | 599 // reg to stack |
| 576 getDest()->emit(Func); | 600 if (DestIsMem && SrcIsReg) { |
| 577 Str << ", "; | 601 switch (Dest->getType()) { |
| 578 getSrc(0)->emit(Func); | 602 case IceType_f32: |
| 603 ActualOpcode = "swc1"; | |
| 604 break; | |
| 605 case IceType_f64: | |
| 606 ActualOpcode = "sdc1"; | |
| 607 break; | |
| 608 case IceType_i1: | |
| 609 case IceType_i8: | |
| 610 case IceType_i16: | |
| 611 case IceType_i32: | |
| 612 ActualOpcode = "sw"; | |
| 613 break; | |
| 614 default: | |
| 615 UnimplementedError(getFlags()); | |
| 616 return; | |
| 617 } | |
| 618 | |
| 619 assert(ActualOpcode); | |
| 620 Str << "\t" << ActualOpcode << "\t"; | |
| 621 getSrc(0)->emit(Func); | |
| 622 Str << ", "; | |
| 623 getDest()->emit(Func); | |
| 624 return; | |
| 625 } | |
| 626 | |
| 627 // stack to reg | |
| 628 if (DestIsReg && SrcIsMem) { | |
| 629 switch (Dest->getType()) { | |
| 630 case IceType_f32: | |
| 631 ActualOpcode = "lwc1"; | |
| 632 break; | |
| 633 case IceType_f64: | |
| 634 ActualOpcode = "ldc1"; | |
| 635 break; | |
| 636 case IceType_i1: | |
| 637 case IceType_i8: | |
| 638 case IceType_i16: | |
| 639 case IceType_i32: | |
| 640 ActualOpcode = "lw"; | |
| 641 break; | |
| 642 default: | |
| 643 UnimplementedError(getFlags()); | |
| 644 return; | |
| 645 } | |
| 646 | |
| 647 assert(ActualOpcode); | |
| 648 Str << "\t" << ActualOpcode << "\t"; | |
| 649 getDest()->emit(Func); | |
| 650 Str << ", "; | |
| 651 getSrc(0)->emit(Func); | |
| 652 return; | |
| 653 } | |
| 654 | |
| 655 // stack to stack | |
| 656 llvm::report_fatal_error("mov cant copy stack to stack."); | |
| 579 } | 657 } |
| 580 | 658 |
| 581 } // end of namespace MIPS32 | 659 } // end of namespace MIPS32 |
| 582 } // end of namespace Ice | 660 } // end of namespace Ice |
| OLD | NEW |