Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===- subzero/src/IceInstMIPS32.h - MIPS32 machine instrs --*- C++ -*-----===// | 1 //===- subzero/src/IceInstMIPS32.h - MIPS32 machine instrs --*- C++ -*-----===// |
| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 return Operand->getKind() == static_cast<OperandKind>(kMem); | 103 return Operand->getKind() == static_cast<OperandKind>(kMem); |
| 104 } | 104 } |
| 105 | 105 |
| 106 /// Return true if a load/store instruction for an element of type Ty | 106 /// Return true if a load/store instruction for an element of type Ty |
| 107 /// can encode the Offset directly in the immediate field of the 32-bit | 107 /// can encode the Offset directly in the immediate field of the 32-bit |
| 108 /// MIPS instruction. For some types, if the load is Sign extending, then | 108 /// MIPS instruction. For some types, if the load is Sign extending, then |
| 109 /// the range is reduced. | 109 /// the range is reduced. |
| 110 static bool canHoldOffset(Type Ty, bool SignExt, int32_t Offset); | 110 static bool canHoldOffset(Type Ty, bool SignExt, int32_t Offset); |
| 111 | 111 |
| 112 void dump(const Cfg *Func, Ostream &Str) const override { | 112 void dump(const Cfg *Func, Ostream &Str) const override { |
| 113 (void)Func; | 113 if (!BuildDefs::dump()) |
| 114 (void)Str; | 114 return; |
| 115 Str << "["; | |
| 116 if (Func) | |
| 117 getBase()->dump(Func); | |
| 118 else | |
| 119 getBase()->dump(Str); | |
| 120 Str << ", "; | |
| 121 getOffset()->dump(Func, Str); | |
| 122 Str << "] AddrMode=="; | |
| 123 if (getAddrMode() == Offset) { | |
| 124 Str << "Offset"; | |
| 125 } else { | |
| 126 Str << "Unknown"; | |
| 127 } | |
| 115 } | 128 } |
| 116 | 129 |
| 117 private: | 130 private: |
| 118 OperandMIPS32Mem(Cfg *Func, Type Ty, Variable *Base, Operand *ImmOffset, | 131 OperandMIPS32Mem(Cfg *Func, Type Ty, Variable *Base, Operand *ImmOffset, |
| 119 AddrMode Mode); | 132 AddrMode Mode); |
| 120 | 133 |
| 121 Variable *Base; | 134 Variable *Base; |
| 122 Operand *const ImmOffset; | 135 Operand *const ImmOffset; |
| 123 const AddrMode Mode; | 136 const AddrMode Mode; |
| 124 }; | 137 }; |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 508 static InstMIPS32Load *create(Cfg *Func, Variable *Value, | 521 static InstMIPS32Load *create(Cfg *Func, Variable *Value, |
| 509 OperandMIPS32Mem *Mem, RelocOp Reloc = RO_No) { | 522 OperandMIPS32Mem *Mem, RelocOp Reloc = RO_No) { |
| 510 return new (Func->allocate<InstMIPS32Load>()) | 523 return new (Func->allocate<InstMIPS32Load>()) |
| 511 InstMIPS32Load(Func, Value, Mem, Reloc); | 524 InstMIPS32Load(Func, Value, Mem, Reloc); |
| 512 } | 525 } |
| 513 | 526 |
| 514 void emit(const Cfg *Func) const override { | 527 void emit(const Cfg *Func) const override { |
| 515 if (!BuildDefs::dump()) | 528 if (!BuildDefs::dump()) |
| 516 return; | 529 return; |
| 517 Ostream &Str = Func->getContext()->getStrEmit(); | 530 Ostream &Str = Func->getContext()->getStrEmit(); |
| 518 assert(getSrcSize() == 1); | 531 const Type Ty = getDest()->getType(); |
| 519 Str << "\t" << Opcode << "\t"; | 532 switch (Ty) { |
| 533 case IceType_i1: | |
| 534 case IceType_i8: | |
| 535 Str << "\t" | |
|
Jim Stichnoth
2016/09/04 14:19:00
A few suggestions/possibilities for future CLs.
1
jaydeep.patil
2016/09/05 04:51:48
Acknowledged.
| |
| 536 << "lb" | |
| 537 << "\t"; | |
| 538 break; | |
| 539 case IceType_i16: | |
| 540 Str << "\t" | |
| 541 << "lh" | |
| 542 << "\t"; | |
| 543 break; | |
| 544 case IceType_i32: | |
| 545 Str << "\t" | |
| 546 << "lw" | |
| 547 << "\t"; | |
| 548 break; | |
| 549 case IceType_f32: | |
| 550 Str << "\t" | |
| 551 << "lwc1" | |
| 552 << "\t"; | |
| 553 break; | |
| 554 case IceType_f64: | |
| 555 Str << "\t" | |
| 556 << "ldc1" | |
| 557 << "\t"; | |
| 558 break; | |
| 559 default: | |
| 560 llvm_unreachable("InstMIPS32Load unknown type"); | |
| 561 } | |
| 520 getDest()->emit(Func); | 562 getDest()->emit(Func); |
| 521 Str << ", "; | 563 Str << ", "; |
| 522 emitRelocOp(Str, Reloc); | 564 emitRelocOp(Str, Reloc); |
| 523 getSrc(0)->emit(Func); | 565 getSrc(0)->emit(Func); |
| 524 } | 566 } |
| 525 | 567 |
| 526 void emitIAS(const Cfg *Func) const override { | 568 void emitIAS(const Cfg *Func) const override { |
| 527 (void)Func; | 569 (void)Func; |
| 528 llvm_unreachable("Not yet implemented"); | 570 llvm_unreachable("Not yet implemented"); |
| 529 } | 571 } |
| 530 | 572 |
| 531 void dump(const Cfg *Func) const override { | 573 void dump(const Cfg *Func) const override { |
| 532 if (!BuildDefs::dump()) | 574 if (!BuildDefs::dump()) |
| 533 return; | 575 return; |
| 534 Ostream &Str = Func->getContext()->getStrDump(); | 576 Ostream &Str = Func->getContext()->getStrDump(); |
| 535 Str << "\t" << Opcode << "\t"; | 577 dumpOpcode(Str, Opcode, getDest()->getType()); |
| 578 Str << " "; | |
| 536 getDest()->dump(Func); | 579 getDest()->dump(Func); |
| 537 Str << ", "; | 580 Str << ", "; |
| 538 emitRelocOp(Str, Reloc); | 581 emitRelocOp(Str, Reloc); |
| 539 Str << (Reloc ? "(" : ""); | |
| 540 getSrc(0)->dump(Func); | 582 getSrc(0)->dump(Func); |
| 541 Str << (Reloc ? ")" : ""); | |
| 542 } | 583 } |
| 543 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } | 584 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } |
| 544 | 585 |
| 545 private: | 586 private: |
| 546 InstMIPS32Load(Cfg *Func, Variable *Value, OperandMIPS32Mem *Mem, | 587 InstMIPS32Load(Cfg *Func, Variable *Value, OperandMIPS32Mem *Mem, |
| 547 RelocOp Reloc = RO_No) | 588 RelocOp Reloc = RO_No) |
| 548 : InstMIPS32(Func, K, 2, Value), Reloc(Reloc) { | 589 : InstMIPS32(Func, K, 2, Value), Reloc(Reloc) { |
| 549 addSource(Mem); | 590 addSource(Mem); |
| 550 } | 591 } |
| 551 static const char *Opcode; | 592 static const char *Opcode; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 565 OperandMIPS32Mem *Mem, RelocOp Reloc = RO_No) { | 606 OperandMIPS32Mem *Mem, RelocOp Reloc = RO_No) { |
| 566 return new (Func->allocate<InstMIPS32Store>()) | 607 return new (Func->allocate<InstMIPS32Store>()) |
| 567 InstMIPS32Store(Func, Value, Mem, Reloc); | 608 InstMIPS32Store(Func, Value, Mem, Reloc); |
| 568 } | 609 } |
| 569 | 610 |
| 570 void emit(const Cfg *Func) const override { | 611 void emit(const Cfg *Func) const override { |
| 571 if (!BuildDefs::dump()) | 612 if (!BuildDefs::dump()) |
| 572 return; | 613 return; |
| 573 Ostream &Str = Func->getContext()->getStrEmit(); | 614 Ostream &Str = Func->getContext()->getStrEmit(); |
| 574 assert(getSrcSize() == 2); | 615 assert(getSrcSize() == 2); |
| 575 Str << "\t" << Opcode << "\t"; | 616 const Type Ty = getSrc(0)->getType(); |
| 617 switch (Ty) { | |
| 618 case IceType_i1: | |
| 619 case IceType_i8: | |
| 620 Str << "\t" | |
| 621 << "sb" | |
| 622 << "\t"; | |
| 623 break; | |
| 624 case IceType_i16: | |
| 625 Str << "\t" | |
| 626 << "sh" | |
| 627 << "\t"; | |
| 628 break; | |
| 629 case IceType_i32: | |
| 630 Str << "\t" | |
| 631 << "sw" | |
| 632 << "\t"; | |
| 633 break; | |
| 634 case IceType_f32: | |
| 635 Str << "\t" | |
| 636 << "swc1" | |
| 637 << "\t"; | |
| 638 break; | |
| 639 case IceType_f64: | |
| 640 Str << "\t" | |
| 641 << "sdc1" | |
| 642 << "\t"; | |
| 643 break; | |
| 644 default: | |
| 645 llvm_unreachable("InstMIPS32Store unknown type"); | |
| 646 } | |
| 576 getSrc(0)->emit(Func); | 647 getSrc(0)->emit(Func); |
| 577 Str << ", "; | 648 Str << ", "; |
| 578 emitRelocOp(Str, Reloc); | 649 emitRelocOp(Str, Reloc); |
| 579 getSrc(1)->emit(Func); | 650 getSrc(1)->emit(Func); |
| 580 } | 651 } |
| 581 | 652 |
| 582 void emitIAS(const Cfg *Func) const override { | 653 void emitIAS(const Cfg *Func) const override { |
| 583 (void)Func; | 654 (void)Func; |
| 584 llvm_unreachable("Not yet implemented"); | 655 llvm_unreachable("InstMIPS32Store: Not yet implemented"); |
| 585 } | 656 } |
| 586 | 657 |
| 587 void dump(const Cfg *Func) const override { | 658 void dump(const Cfg *Func) const override { |
| 588 if (!BuildDefs::dump()) | 659 if (!BuildDefs::dump()) |
| 589 return; | 660 return; |
| 590 Ostream &Str = Func->getContext()->getStrDump(); | 661 Ostream &Str = Func->getContext()->getStrDump(); |
| 591 Str << "\t" << Opcode << "\t"; | 662 dumpOpcode(Str, Opcode, getSrc(0)->getType()); |
| 663 Str << " "; | |
| 592 getSrc(0)->dump(Func); | 664 getSrc(0)->dump(Func); |
| 593 Str << ", "; | 665 Str << ", "; |
| 594 emitRelocOp(Str, Reloc); | 666 emitRelocOp(Str, Reloc); |
| 595 Str << (Reloc ? "(" : ""); | |
| 596 getSrc(1)->dump(Func); | 667 getSrc(1)->dump(Func); |
| 597 Str << (Reloc ? ")" : ""); | |
| 598 } | 668 } |
| 599 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } | 669 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } |
| 600 | 670 |
| 601 private: | 671 private: |
| 602 InstMIPS32Store(Cfg *Func, Variable *Value, OperandMIPS32Mem *Mem, | 672 InstMIPS32Store(Cfg *Func, Variable *Value, OperandMIPS32Mem *Mem, |
| 603 RelocOp Reloc = RO_No) | 673 RelocOp Reloc = RO_No) |
| 604 : InstMIPS32(Func, K, 2, nullptr), Reloc(Reloc) { | 674 : InstMIPS32(Func, K, 2, nullptr), Reloc(Reloc) { |
| 605 addSource(Value); | 675 addSource(Value); |
| 606 addSource(Mem); | 676 addSource(Mem); |
| 607 } | 677 } |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 768 } | 838 } |
| 769 | 839 |
| 770 void emitIAS(const Cfg *Func) const override { | 840 void emitIAS(const Cfg *Func) const override { |
| 771 (void)Func; | 841 (void)Func; |
| 772 llvm_unreachable("Not yet implemented"); | 842 llvm_unreachable("Not yet implemented"); |
| 773 } | 843 } |
| 774 void dump(const Cfg *Func) const override { | 844 void dump(const Cfg *Func) const override { |
| 775 if (!BuildDefs::dump()) | 845 if (!BuildDefs::dump()) |
| 776 return; | 846 return; |
| 777 Ostream &Str = Func->getContext()->getStrDump(); | 847 Ostream &Str = Func->getContext()->getStrDump(); |
| 848 dumpOpcode(Str, Opcode, getDest()->getType()); | |
| 778 Str << " "; | 849 Str << " "; |
| 779 Str << "\t" << Opcode << "\t"; | |
| 780 dumpDest(Func); | 850 dumpDest(Func); |
| 781 Str << ", "; | 851 Str << ", "; |
| 782 dumpSources(Func); | 852 dumpSources(Func); |
| 853 Str << ", "; | |
| 783 if (Signed) | 854 if (Signed) |
| 784 Str << (int32_t)Imm; | 855 Str << (int32_t)Imm; |
| 785 else | 856 else |
| 786 Str << Imm; | 857 Str << Imm; |
| 787 } | 858 } |
| 788 | 859 |
| 789 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } | 860 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } |
| 790 | 861 |
| 791 private: | 862 private: |
| 792 InstMIPS32Imm16(Cfg *Func, Variable *Dest, Operand *Source, uint32_t Imm) | 863 InstMIPS32Imm16(Cfg *Func, Variable *Dest, Operand *Source, uint32_t Imm) |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 912 template <> void InstMIPS32Mtlo::emit(const Cfg *Func) const; | 983 template <> void InstMIPS32Mtlo::emit(const Cfg *Func) const; |
| 913 template <> void InstMIPS32Mthi::emit(const Cfg *Func) const; | 984 template <> void InstMIPS32Mthi::emit(const Cfg *Func) const; |
| 914 template <> void InstMIPS32Mult::emit(const Cfg *Func) const; | 985 template <> void InstMIPS32Mult::emit(const Cfg *Func) const; |
| 915 template <> void InstMIPS32Multu::emit(const Cfg *Func) const; | 986 template <> void InstMIPS32Multu::emit(const Cfg *Func) const; |
| 916 template <> void InstMIPS32Lui::emit(const Cfg *Func) const; | 987 template <> void InstMIPS32Lui::emit(const Cfg *Func) const; |
| 917 | 988 |
| 918 } // end of namespace MIPS32 | 989 } // end of namespace MIPS32 |
| 919 } // end of namespace Ice | 990 } // end of namespace Ice |
| 920 | 991 |
| 921 #endif // SUBZERO_SRC_ICEINSTMIPS32_H | 992 #endif // SUBZERO_SRC_ICEINSTMIPS32_H |
| OLD | NEW |