Jim Stichnoth | 6da4cef | 2015-06-11 13:26:33 -0700 | [diff] [blame] | 1 | //===- subzero/src/IceInstMIPS32.h - MIPS32 machine instrs --*- C++ -*-=== // |
| 2 | // |
| 3 | // The Subzero Code Generator |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
Andrew Scull | 9612d32 | 2015-07-06 14:53:25 -0700 | [diff] [blame] | 9 | /// |
| 10 | /// \file |
| 11 | /// This file declares the InstMIPS32 and OperandMIPS32 classes and |
| 12 | /// their subclasses. This represents the machine instructions and |
| 13 | /// operands used for MIPS32 code selection. |
| 14 | /// |
Jim Stichnoth | 6da4cef | 2015-06-11 13:26:33 -0700 | [diff] [blame] | 15 | //===----------------------------------------------------------------------===// |
| 16 | |
| 17 | #ifndef SUBZERO_SRC_ICEINSTMIPS32_H |
| 18 | #define SUBZERO_SRC_ICEINSTMIPS32_H |
| 19 | |
| 20 | #include "IceDefs.h" |
Reed Kotler | d00d48d | 2015-07-08 09:49:07 -0700 | [diff] [blame^] | 21 | #include "IceInst.h" |
| 22 | #include "IceInstMIPS32.def" |
| 23 | #include "IceOperand.h" |
Jim Stichnoth | 6da4cef | 2015-06-11 13:26:33 -0700 | [diff] [blame] | 24 | |
| 25 | namespace Ice { |
| 26 | |
| 27 | class TargetMIPS32; |
Reed Kotler | d00d48d | 2015-07-08 09:49:07 -0700 | [diff] [blame^] | 28 | |
| 29 | /// Base class for Mips instructions. |
| 30 | class InstMIPS32 : public InstTarget { |
| 31 | InstMIPS32() = delete; |
| 32 | InstMIPS32(const InstMIPS32 &) = delete; |
| 33 | InstMIPS32 &operator=(const InstMIPS32 &) = delete; |
| 34 | |
| 35 | public: |
| 36 | enum InstKindMIPS32 { k__Start = Inst::Target, Ret }; |
| 37 | |
| 38 | static const char *getWidthString(Type Ty); |
| 39 | |
| 40 | void dump(const Cfg *Func) const override; |
| 41 | |
| 42 | protected: |
| 43 | InstMIPS32(Cfg *Func, InstKindMIPS32 Kind, SizeT Maxsrcs, Variable *Dest) |
| 44 | : InstTarget(Func, static_cast<InstKind>(Kind), Maxsrcs, Dest) {} |
| 45 | ~InstMIPS32() override {} |
| 46 | static bool isClassof(const Inst *Inst, InstKindMIPS32 MyKind) { |
| 47 | return Inst->getKind() == static_cast<InstKind>(MyKind); |
| 48 | } |
| 49 | }; |
| 50 | |
| 51 | /// Ret pseudo-instruction. This is actually a "jr" instruction with |
| 52 | /// an "ra" register operand, but epilogue lowering will search for a Ret |
| 53 | /// instead of a generic "jr". This instruction also takes a Source |
| 54 | /// operand (for non-void returning functions) for liveness analysis, though |
| 55 | /// a FakeUse before the ret would do just as well. |
| 56 | /// TODO(reed kotler): This needs was take from the ARM port and needs to be |
| 57 | /// scrubbed in the future. |
| 58 | class InstMIPS32Ret : public InstMIPS32 { |
| 59 | |
| 60 | InstMIPS32Ret() = delete; |
| 61 | InstMIPS32Ret(const InstMIPS32Ret &) = delete; |
| 62 | InstMIPS32Ret &operator=(const InstMIPS32Ret &) = delete; |
| 63 | |
| 64 | public: |
| 65 | static InstMIPS32Ret *create(Cfg *Func, Variable *RA, |
| 66 | Variable *Source = nullptr) { |
| 67 | return new (Func->allocate<InstMIPS32Ret>()) |
| 68 | InstMIPS32Ret(Func, RA, Source); |
| 69 | } |
| 70 | void emit(const Cfg *Func) const override; |
| 71 | void emitIAS(const Cfg *Func) const override; |
| 72 | void dump(const Cfg *Func) const override; |
| 73 | static bool classof(const Inst *Inst) { return isClassof(Inst, Ret); } |
| 74 | |
| 75 | private: |
| 76 | InstMIPS32Ret(Cfg *Func, Variable *RA, Variable *Source); |
| 77 | ~InstMIPS32Ret() override {} |
| 78 | }; |
Jim Stichnoth | 6da4cef | 2015-06-11 13:26:33 -0700 | [diff] [blame] | 79 | |
| 80 | } // end of namespace Ice |
| 81 | |
| 82 | #endif // SUBZERO_SRC_ICEINSTMIPS32_H |