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

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: Make changes per patch 3 stichnot review 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
« no previous file with comments | « src/IceInstMIPS32.h ('k') | src/IceTargetLoweringMIPS32.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceInstMIPS32.cpp
diff --git a/src/IceInstMIPS32.cpp b/src/IceInstMIPS32.cpp
index d3c9c187f1e02643d61d6470a7682a47ba8ac8fa..4f394d6ecc2a971c8ad065b0ccdb200e8aa22036 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;
@@ -225,12 +244,31 @@ void InstMIPS32Mov::emitSingleDestMultiSource(const Cfg *Func) const {
}
void InstMIPS32Mov::emitSingleDestSingleSource(const Cfg *Func) const {
+ if (!BuildDefs::dump())
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
- // assert(Inst->getSrcSize() == 1);
- // Type SrcTy = Inst->getSrc(0)->getType();
- Str << "\t"
- << "move"
- << "\t";
+ Variable *Dest = getDest();
+ Operand *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);
« no previous file with comments | « src/IceInstMIPS32.h ('k') | src/IceTargetLoweringMIPS32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698