Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: src/IceInstMIPS32.cpp

Issue 1414383004: Lower a few basic MIPS binops for i{8,16,32,64}. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: patch 2 per change requests from stichnot Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/IceInstMIPS32.cpp
diff --git a/src/IceInstMIPS32.cpp b/src/IceInstMIPS32.cpp
index d3c9c187f1e02643d61d6470a7682a47ba8ac8fa..54224f7c4a442544b02cf362dd292119015ac2c6 100644
--- a/src/IceInstMIPS32.cpp
+++ b/src/IceInstMIPS32.cpp
@@ -51,8 +51,14 @@ const char *InstMIPS32::getWidthString(Type Ty) {
template <> const char *InstMIPS32Addiu::Opcode = "addiu";
template <> const char *InstMIPS32Lui::Opcode = "lui";
template <> const char *InstMIPS32La::Opcode = "la";
-
+// Three-addr ops
+template <> const char *InstMIPS32Add::Opcode = "add";
+template <> const char *InstMIPS32And::Opcode = "and";
+template <> const char *InstMIPS32Mul::Opcode = "mul";
+template <> const char *InstMIPS32Or::Opcode = "or";
template <> const char *InstMIPS32Ori::Opcode = "ori";
+template <> const char *InstMIPS32Sub::Opcode = "sub";
+template <> const char *InstMIPS32Xor::Opcode = "xor";
InstMIPS32Mov::InstMIPS32Mov(Cfg *Func, Variable *Dest, Operand *Src)
: InstMIPS32(Func, InstMIPS32::Mov, 2, Dest) {
@@ -104,13 +110,26 @@ void InstMIPS32::emitUnaryopGPR(const char *Opcode, const InstMIPS32 *Inst,
if (!BuildDefs::dump())
return;
Ostream &Str = Func->getContext()->getStrEmit();
- // Type SrcTy = Inst->getSrc(0)->getType();
Str << "\t" << Opcode << "\t";
Inst->getDest()->emit(Func);
Str << ", ";
Inst->getSrc(0)->emit(Func);
}
+void InstMIPS32::emitThreeAddr(const char *Opcode, const InstMIPS32 *Inst,
+ const Cfg *Func) {
+ if (!BuildDefs::dump())
+ return;
+ Ostream &Str = Func->getContext()->getStrEmit();
+ assert(Inst->getSrcSize() == 2);
+ Str << "\t" << Opcode << "\t";
+ Inst->getDest()->emit(Func);
+ Str << ", ";
+ Inst->getSrc(0)->emit(Func);
+ Str << ", ";
+ Inst->getSrc(1)->emit(Func);
+}
+
void InstMIPS32Ret::emit(const Cfg *Func) const {
if (!BuildDefs::dump())
return;
@@ -228,9 +247,28 @@ void InstMIPS32Mov::emitSingleDestSingleSource(const Cfg *Func) const {
Ostream &Str = Func->getContext()->getStrEmit();
// assert(Inst->getSrcSize() == 1);
// Type SrcTy = Inst->getSrc(0)->getType();
- Str << "\t"
- << "move"
- << "\t";
+ auto *Dest = getDest();
Jim Stichnoth 2015/11/05 05:21:28 Please use Variable* here and Operand* in the next
rkotlerimgtec 2015/11/05 22:12:27 Done.
+ auto *Src = getSrc(0);
+ auto *S = llvm::dyn_cast<Variable>(Src);
+ Str << "\t";
+ if (Dest->hasReg()) {
+ if (S && S->hasReg())
+ Str << "move";
+ else
+ Str << "lw";
+ } else {
+ if (S && S->hasReg()) {
+ Str << "sw";
+ Str << "\t";
+ getSrc(0)->emit(Func);
+ Str << ", ";
+ getDest()->emit(Func);
+ return;
+ } else
+ Str << "move";
+ }
+
+ Str << "\t";
getDest()->emit(Func);
Str << ", ";
getSrc(0)->emit(Func);

Powered by Google App Engine
This is Rietveld 408576698