implement the null function for the Mips32 subzero compiler
BUG= https://code.google.com/p/nativeclient/issues/detail?id=4167
R=jvoung@chromium.org
Review URL: https://codereview.chromium.org/1176133004 .
Patch from Reed Kotler <reed.kotler@imgtec.com>.
diff --git a/src/IceInstMIPS32.h b/src/IceInstMIPS32.h
index 17c2583..d608a1c 100644
--- a/src/IceInstMIPS32.h
+++ b/src/IceInstMIPS32.h
@@ -18,11 +18,64 @@
#define SUBZERO_SRC_ICEINSTMIPS32_H
#include "IceDefs.h"
+#include "IceInst.h"
+#include "IceInstMIPS32.def"
+#include "IceOperand.h"
namespace Ice {
class TargetMIPS32;
-// Fill this in.
+
+/// Base class for Mips instructions.
+class InstMIPS32 : public InstTarget {
+ InstMIPS32() = delete;
+ InstMIPS32(const InstMIPS32 &) = delete;
+ InstMIPS32 &operator=(const InstMIPS32 &) = delete;
+
+public:
+ enum InstKindMIPS32 { k__Start = Inst::Target, Ret };
+
+ static const char *getWidthString(Type Ty);
+
+ void dump(const Cfg *Func) const override;
+
+protected:
+ InstMIPS32(Cfg *Func, InstKindMIPS32 Kind, SizeT Maxsrcs, Variable *Dest)
+ : InstTarget(Func, static_cast<InstKind>(Kind), Maxsrcs, Dest) {}
+ ~InstMIPS32() override {}
+ static bool isClassof(const Inst *Inst, InstKindMIPS32 MyKind) {
+ return Inst->getKind() == static_cast<InstKind>(MyKind);
+ }
+};
+
+/// Ret pseudo-instruction. This is actually a "jr" instruction with
+/// an "ra" register operand, but epilogue lowering will search for a Ret
+/// instead of a generic "jr". This instruction also takes a Source
+/// operand (for non-void returning functions) for liveness analysis, though
+/// a FakeUse before the ret would do just as well.
+/// TODO(reed kotler): This needs was take from the ARM port and needs to be
+/// scrubbed in the future.
+class InstMIPS32Ret : public InstMIPS32 {
+
+ InstMIPS32Ret() = delete;
+ InstMIPS32Ret(const InstMIPS32Ret &) = delete;
+ InstMIPS32Ret &operator=(const InstMIPS32Ret &) = delete;
+
+public:
+ static InstMIPS32Ret *create(Cfg *Func, Variable *RA,
+ Variable *Source = nullptr) {
+ return new (Func->allocate<InstMIPS32Ret>())
+ InstMIPS32Ret(Func, RA, Source);
+ }
+ void emit(const Cfg *Func) const override;
+ void emitIAS(const Cfg *Func) const override;
+ void dump(const Cfg *Func) const override;
+ static bool classof(const Inst *Inst) { return isClassof(Inst, Ret); }
+
+private:
+ InstMIPS32Ret(Cfg *Func, Variable *RA, Variable *Source);
+ ~InstMIPS32Ret() override {}
+};
} // end of namespace Ice