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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 Trunc_l_d, | 194 Trunc_l_d, |
195 Trunc_l_s, | 195 Trunc_l_s, |
196 Trunc_w_d, | 196 Trunc_w_d, |
197 Trunc_w_s, | 197 Trunc_w_s, |
198 Xor, | 198 Xor, |
199 Xori | 199 Xori |
200 }; | 200 }; |
201 | 201 |
202 static const char *getWidthString(Type Ty); | 202 static const char *getWidthString(Type Ty); |
203 | 203 |
| 204 CondMIPS32::Cond getOppositeCondition(CondMIPS32::Cond Cond); |
| 205 |
204 void dump(const Cfg *Func) const override; | 206 void dump(const Cfg *Func) const override; |
205 | 207 |
206 void dumpOpcode(Ostream &Str, const char *Opcode, Type Ty) const { | 208 void dumpOpcode(Ostream &Str, const char *Opcode, Type Ty) const { |
207 Str << Opcode << "." << Ty; | 209 Str << Opcode << "." << Ty; |
208 } | 210 } |
209 | 211 |
210 // TODO(rkotler): while branching is not implemented | 212 // TODO(rkotler): while branching is not implemented |
211 bool repointEdges(CfgNode *, CfgNode *) override { return true; } | 213 bool repointEdges(CfgNode *, CfgNode *) override { return true; } |
212 | 214 |
213 /// Shared emit routines for common forms of instructions. | 215 /// Shared emit routines for common forms of instructions. |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 static InstMIPS32Br *create(Cfg *Func, CfgNode *TargetTrue, | 664 static InstMIPS32Br *create(Cfg *Func, CfgNode *TargetTrue, |
663 CfgNode *TargetFalse, Operand *Src0, | 665 CfgNode *TargetFalse, Operand *Src0, |
664 CondMIPS32::Cond Cond) { | 666 CondMIPS32::Cond Cond) { |
665 constexpr InstMIPS32Label *NoLabel = nullptr; | 667 constexpr InstMIPS32Label *NoLabel = nullptr; |
666 return new (Func->allocate<InstMIPS32Br>()) | 668 return new (Func->allocate<InstMIPS32Br>()) |
667 InstMIPS32Br(Func, TargetTrue, TargetFalse, Src0, NoLabel, Cond); | 669 InstMIPS32Br(Func, TargetTrue, TargetFalse, Src0, NoLabel, Cond); |
668 } | 670 } |
669 | 671 |
670 const CfgNode *getTargetTrue() const { return TargetTrue; } | 672 const CfgNode *getTargetTrue() const { return TargetTrue; } |
671 const CfgNode *getTargetFalse() const { return TargetFalse; } | 673 const CfgNode *getTargetFalse() const { return TargetFalse; } |
672 | 674 CondMIPS32::Cond getPredicate() const { return Predicate; } |
| 675 void setPredicate(CondMIPS32::Cond Pred) { Predicate = Pred; } |
| 676 bool optimizeBranch(const CfgNode *NextNode); |
673 bool isUnconditionalBranch() const override { | 677 bool isUnconditionalBranch() const override { |
674 return Predicate == CondMIPS32::AL; | 678 return Predicate == CondMIPS32::AL; |
675 } | 679 } |
676 bool repointEdges(CfgNode *OldNode, CfgNode *NewNode) override; | 680 bool repointEdges(CfgNode *OldNode, CfgNode *NewNode) override; |
677 void emit(const Cfg *Func) const override; | 681 void emit(const Cfg *Func) const override; |
678 void emitIAS(const Cfg *Func) const override { (void)Func; }; | 682 void emitIAS(const Cfg *Func) const override { (void)Func; }; |
679 void dump(const Cfg *Func) const override; | 683 void dump(const Cfg *Func) const override; |
680 static bool classof(const Inst *Instr) { return isClassof(Instr, Br); } | 684 static bool classof(const Inst *Instr) { return isClassof(Instr, Br); } |
681 | 685 |
682 private: | 686 private: |
683 InstMIPS32Br(Cfg *Func, const CfgNode *TargetTrue, const CfgNode *TargetFalse, | 687 InstMIPS32Br(Cfg *Func, const CfgNode *TargetTrue, const CfgNode *TargetFalse, |
684 const InstMIPS32Label *Label, const CondMIPS32::Cond Cond); | 688 const InstMIPS32Label *Label, const CondMIPS32::Cond Cond); |
685 | 689 |
686 InstMIPS32Br(Cfg *Func, const CfgNode *TargetTrue, const CfgNode *TargetFalse, | 690 InstMIPS32Br(Cfg *Func, const CfgNode *TargetTrue, const CfgNode *TargetFalse, |
687 Operand *Src0, const InstMIPS32Label *Label, | 691 Operand *Src0, const InstMIPS32Label *Label, |
688 const CondMIPS32::Cond Cond); | 692 const CondMIPS32::Cond Cond); |
689 | 693 |
690 InstMIPS32Br(Cfg *Func, const CfgNode *TargetTrue, const CfgNode *TargetFalse, | 694 InstMIPS32Br(Cfg *Func, const CfgNode *TargetTrue, const CfgNode *TargetFalse, |
691 Operand *Src0, Operand *Src1, const InstMIPS32Label *Label, | 695 Operand *Src0, Operand *Src1, const InstMIPS32Label *Label, |
692 const CondMIPS32::Cond Cond); | 696 const CondMIPS32::Cond Cond); |
693 | 697 |
694 const CfgNode *TargetTrue; | 698 const CfgNode *TargetTrue; |
695 const CfgNode *TargetFalse; | 699 const CfgNode *TargetFalse; |
696 const InstMIPS32Label *Label; // Intra-block branch target | 700 const InstMIPS32Label *Label; // Intra-block branch target |
697 const CondMIPS32::Cond Predicate; | 701 CondMIPS32::Cond Predicate; |
698 }; | 702 }; |
699 | 703 |
700 class InstMIPS32Call : public InstMIPS32 { | 704 class InstMIPS32Call : public InstMIPS32 { |
701 InstMIPS32Call() = delete; | 705 InstMIPS32Call() = delete; |
702 InstMIPS32Call(const InstMIPS32Call &) = delete; | 706 InstMIPS32Call(const InstMIPS32Call &) = delete; |
703 InstMIPS32Call &operator=(const InstMIPS32Call &) = delete; | 707 InstMIPS32Call &operator=(const InstMIPS32Call &) = delete; |
704 | 708 |
705 public: | 709 public: |
706 static InstMIPS32Call *create(Cfg *Func, Variable *Dest, | 710 static InstMIPS32Call *create(Cfg *Func, Variable *Dest, |
707 Operand *CallTarget) { | 711 Operand *CallTarget) { |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 template <> void InstMIPS32Mtlo::emit(const Cfg *Func) const; | 904 template <> void InstMIPS32Mtlo::emit(const Cfg *Func) const; |
901 template <> void InstMIPS32Mthi::emit(const Cfg *Func) const; | 905 template <> void InstMIPS32Mthi::emit(const Cfg *Func) const; |
902 template <> void InstMIPS32Mult::emit(const Cfg *Func) const; | 906 template <> void InstMIPS32Mult::emit(const Cfg *Func) const; |
903 template <> void InstMIPS32Multu::emit(const Cfg *Func) const; | 907 template <> void InstMIPS32Multu::emit(const Cfg *Func) const; |
904 template <> void InstMIPS32Lui::emit(const Cfg *Func) const; | 908 template <> void InstMIPS32Lui::emit(const Cfg *Func) const; |
905 | 909 |
906 } // end of namespace MIPS32 | 910 } // end of namespace MIPS32 |
907 } // end of namespace Ice | 911 } // end of namespace Ice |
908 | 912 |
909 #endif // SUBZERO_SRC_ICEINSTMIPS32_H | 913 #endif // SUBZERO_SRC_ICEINSTMIPS32_H |
OLD | NEW |