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

Unified Diff: src/IceTargetLoweringMIPS32.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/IceTargetLoweringMIPS32.cpp
diff --git a/src/IceTargetLoweringMIPS32.cpp b/src/IceTargetLoweringMIPS32.cpp
index 54c9267d976bcd1c25e66836fa8dc7a8d0bd6fae..65fb32718b7e102742c5e618d995dac5c3b1cf6b 100644
--- a/src/IceTargetLoweringMIPS32.cpp
+++ b/src/IceTargetLoweringMIPS32.cpp
@@ -318,7 +318,7 @@ void TargetMIPS32::emitVariable(const Variable *Var) const {
} else {
int32_t Offset = Var->getStackOffset();
Str << Offset;
- Str << "(" << getRegName(getFrameOrStackReg(), FrameSPTy);
+ Str << "($" << getRegName(getFrameOrStackReg(), FrameSPTy);
Str << ")";
}
UnimplementedError(Func->getContext()->getFlags());
@@ -517,75 +517,92 @@ void TargetMIPS32::lowerArithmetic(const InstArithmetic *Inst) {
Variable *Dest = Inst->getDest();
Operand *Src0 = legalizeUndef(Inst->getSrc(0));
Operand *Src1 = legalizeUndef(Inst->getSrc(1));
- (void)Src0;
- (void)Src1;
if (Dest->getType() == IceType_i64) {
+ // TODO(reed kotler): fakedef needed for now until all cases are implemented
+ Variable *DestLo = llvm::cast<Variable>(loOperand(Dest));
+ Variable *DestHi = llvm::cast<Variable>(hiOperand(Dest));
+ Context.insert(InstFakeDef::create(Func, DestLo));
+ Context.insert(InstFakeDef::create(Func, DestHi));
UnimplementedError(Func->getContext()->getFlags());
- } else if (isVectorType(Dest->getType())) {
+ return;
+ }
+ if (isVectorType(Dest->getType())) {
UnimplementedError(Func->getContext()->getFlags());
Jim Stichnoth 2015/11/05 05:21:28 You may want to add this for the future: Contex
rkotlerimgtec 2015/11/05 22:12:27 Done.
} else { // Dest->getType() is non-i64 scalar
Jim Stichnoth 2015/11/05 05:21:28 Here, I think you can do: if (isVectorType(Dest
rkotlerimgtec 2015/11/05 22:12:27 Done.
+ Variable *T = makeReg(Dest->getType());
+ Variable *Src0R = legalizeToReg(Src0);
+ Operand *Src1R_ = legalize(Src1, Legal_Reg);
Jim Stichnoth 2015/11/05 05:21:28 I think you can just do: Variable *Src1R = lega
rkotlerimgtec 2015/11/05 22:12:27 Done.
+ // TODO(reed kotler): need to allow for incompleteness of
+ // legalize at this time.
+ if (Src1R_ == Src1) {
+ Context.insert(InstFakeUse::create(Func, Src0R));
+ Context.insert(InstFakeDef::create(Func, Dest));
+ UnimplementedError(Func->getContext()->getFlags());
+ return;
+ }
+ Variable *Src1R = legalizeToReg(Src1R_);
switch (Inst->getOp()) {
case InstArithmetic::_num:
- UnimplementedError(Func->getContext()->getFlags());
break;
case InstArithmetic::Add:
- UnimplementedError(Func->getContext()->getFlags());
- // Variable *T = makeReg(Dest->getType());
- // _add(T, Src0, Src1);
- // _mov(Dest, T);
+ _add(T, Src0R, Src1R);
+ _mov(Dest, T);
return;
case InstArithmetic::And:
- UnimplementedError(Func->getContext()->getFlags());
- break;
+ _and(T, Src0R, Src1R);
+ _mov(Dest, T);
+ return;
case InstArithmetic::Or:
- UnimplementedError(Func->getContext()->getFlags());
- break;
+ _or(T, Src0R, Src1R);
+ _mov(Dest, T);
+ return;
case InstArithmetic::Xor:
- UnimplementedError(Func->getContext()->getFlags());
- break;
+ _xor(T, Src0R, Src1R);
+ _mov(Dest, T);
+ return;
case InstArithmetic::Sub:
- UnimplementedError(Func->getContext()->getFlags());
- break;
- case InstArithmetic::Mul:
- UnimplementedError(Func->getContext()->getFlags());
- break;
+ _sub(T, Src0R, Src1R);
+ _mov(Dest, T);
+ return;
+ case InstArithmetic::Mul: {
+ // Variable *Src1R_ = legalizeToReg(Src1R);
Jim Stichnoth 2015/11/05 05:21:28 remove comment
rkotlerimgtec 2015/11/05 22:12:27 Done.
+ _mul(T, Src0R, Src1R);
+ _mov(Dest, T);
+ return;
+ }
case InstArithmetic::Shl:
- UnimplementedError(Func->getContext()->getFlags());
break;
case InstArithmetic::Lshr:
- UnimplementedError(Func->getContext()->getFlags());
break;
case InstArithmetic::Ashr:
- UnimplementedError(Func->getContext()->getFlags());
break;
case InstArithmetic::Udiv:
- UnimplementedError(Func->getContext()->getFlags());
break;
case InstArithmetic::Sdiv:
- UnimplementedError(Func->getContext()->getFlags());
break;
case InstArithmetic::Urem:
- UnimplementedError(Func->getContext()->getFlags());
break;
case InstArithmetic::Srem:
- UnimplementedError(Func->getContext()->getFlags());
break;
case InstArithmetic::Fadd:
- UnimplementedError(Func->getContext()->getFlags());
break;
case InstArithmetic::Fsub:
- UnimplementedError(Func->getContext()->getFlags());
break;
case InstArithmetic::Fmul:
- UnimplementedError(Func->getContext()->getFlags());
break;
case InstArithmetic::Fdiv:
- UnimplementedError(Func->getContext()->getFlags());
break;
case InstArithmetic::Frem:
- UnimplementedError(Func->getContext()->getFlags());
break;
}
+ // TODO(reed kotler):
+ // fakedef and fakeuse needed for now until all cases are implemented
+ Context.insert(InstFakeUse::create(Func, Src0R));
+ if (auto *S1 = llvm::dyn_cast<Variable>(Src1R)) {
Jim Stichnoth 2015/11/05 05:21:28 After changing Src1R to be Variable* above, you sh
rkotlerimgtec 2015/11/05 22:12:27 Done.
+ Context.insert(InstFakeUse::create(Func, S1));
+ }
+ Context.insert(InstFakeDef::create(Func, Dest));
+ UnimplementedError(Func->getContext()->getFlags());
}
}
@@ -995,7 +1012,7 @@ Operand *TargetMIPS32::legalize(Operand *From, LegalMask Allowed,
// registers to the right type OperandMIPS32FlexReg as needed.
assert(Allowed & Legal_Reg);
// Go through the various types of operands:
- // OperandMIPS32Mem, OperandMIPS32Flex, Constant, and Variable.
+ // OperandMIPS32Mem, Constant, and Variable.
// Given the above assertion, if type of operand is not legal
// (e.g., OperandMIPS32Mem and !Legal_Mem), we can always copy
// to a register.

Powered by Google App Engine
This is Rietveld 408576698