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

Side by Side Diff: src/IceTargetLoweringX8632.cpp

Issue 389653002: Lower vector floating point arithmetic operations. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Avoid _movp() trickery Created 6 years, 5 months 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 unified diff | Download patch
« no previous file with comments | « src/IceTargetLoweringX8632.h ('k') | tests_lit/llvm2ice_tests/vector-arith.ll » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===// 1 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file implements the TargetLoweringX8632 class, which 10 // This file implements the TargetLoweringX8632 class, which
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 lowerCall(Call); 1129 lowerCall(Call);
1130 } break; 1130 } break;
1131 case InstArithmetic::Fadd: 1131 case InstArithmetic::Fadd:
1132 case InstArithmetic::Fsub: 1132 case InstArithmetic::Fsub:
1133 case InstArithmetic::Fmul: 1133 case InstArithmetic::Fmul:
1134 case InstArithmetic::Fdiv: 1134 case InstArithmetic::Fdiv:
1135 case InstArithmetic::Frem: 1135 case InstArithmetic::Frem:
1136 llvm_unreachable("FP instruction with i64 type"); 1136 llvm_unreachable("FP instruction with i64 type");
1137 break; 1137 break;
1138 } 1138 }
1139 } else { // Dest->getType() != IceType_i64 1139 } else if (isVectorType(Dest->getType())) {
1140 switch (Inst->getOp()) {
1141 case InstArithmetic::_num:
1142 llvm_unreachable("Unknown arithmetic operator");
1143 break;
1144 case InstArithmetic::Add:
1145 case InstArithmetic::And:
1146 case InstArithmetic::Or:
1147 case InstArithmetic::Xor:
1148 case InstArithmetic::Sub:
1149 case InstArithmetic::Mul:
1150 case InstArithmetic::Shl:
1151 case InstArithmetic::Lshr:
1152 case InstArithmetic::Ashr:
1153 case InstArithmetic::Udiv:
1154 case InstArithmetic::Sdiv:
1155 case InstArithmetic::Urem:
1156 case InstArithmetic::Srem:
1157 // TODO(wala): Handle these.
1158 Func->setError("Unhandled instruction");
1159 break;
1160 case InstArithmetic::Fadd: {
1161 Variable *T = makeReg(Dest->getType());
Jim Stichnoth 2014/07/11 19:56:16 Since you're adding 4 new instances of this patter
1162 _movp(T, Src0);
1163 _addps(T, Src1);
1164 _movp(Dest, T);
1165 } break;
1166 case InstArithmetic::Fsub: {
1167 Variable *T = makeReg(Dest->getType());
1168 _movp(T, Src0);
1169 _subps(T, Src1);
1170 _movp(Dest, T);
1171 } break;
1172 case InstArithmetic::Fmul: {
1173 Variable *T = makeReg(Dest->getType());
1174 _movp(T, Src0);
1175 _mulps(T, Src1);
1176 _movp(Dest, T);
1177 } break;
1178 case InstArithmetic::Fdiv: {
1179 Variable *T = makeReg(Dest->getType());
1180 _movp(T, Src0);
1181 _divps(T, Src1);
1182 _movp(Dest, T);
1183 } break;
1184 case InstArithmetic::Frem: {
1185 const SizeT MaxSrcs = 1;
1186 InstCall *Call = makeHelperCall("__frem_v4f32", Dest, MaxSrcs);
1187 Call->addArg(Src0);
1188 lowerCall(Call);
1189 } break;
1190 }
1191 } else { // Dest->getType() is non-i64 scalar
1140 Variable *T_edx = NULL; 1192 Variable *T_edx = NULL;
1141 Variable *T = NULL; 1193 Variable *T = NULL;
1142 switch (Inst->getOp()) { 1194 switch (Inst->getOp()) {
1143 case InstArithmetic::_num: 1195 case InstArithmetic::_num:
1144 llvm_unreachable("Unknown arithmetic operator"); 1196 llvm_unreachable("Unknown arithmetic operator");
1145 break; 1197 break;
1146 case InstArithmetic::Add: 1198 case InstArithmetic::Add:
1147 _mov(T, Src0); 1199 _mov(T, Src0);
1148 _add(T, Src1); 1200 _add(T, Src1);
1149 _mov(Dest, T); 1201 _mov(Dest, T);
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1447 if (ScratchRegs[i]) 1499 if (ScratchRegs[i])
1448 KilledRegs.push_back(Func->getTarget()->getPhysicalRegister(i)); 1500 KilledRegs.push_back(Func->getTarget()->getPhysicalRegister(i));
1449 } 1501 }
1450 Context.insert(InstFakeKill::create(Func, KilledRegs, NewCall)); 1502 Context.insert(InstFakeKill::create(Func, KilledRegs, NewCall));
1451 1503
1452 // Generate a FakeUse to keep the call live if necessary. 1504 // Generate a FakeUse to keep the call live if necessary.
1453 if (Instr->hasSideEffects() && ReturnReg) { 1505 if (Instr->hasSideEffects() && ReturnReg) {
1454 Inst *FakeUse = InstFakeUse::create(Func, ReturnReg); 1506 Inst *FakeUse = InstFakeUse::create(Func, ReturnReg);
1455 Context.insert(FakeUse); 1507 Context.insert(FakeUse);
1456 } 1508 }
1457 1509
1458 if (!Dest) 1510 if (!Dest)
1459 return; 1511 return;
1460 1512
1461 // Assign the result of the call to Dest. 1513 // Assign the result of the call to Dest.
1462 if (ReturnReg) { 1514 if (ReturnReg) {
1463 if (ReturnRegHi) { 1515 if (ReturnRegHi) {
1464 assert(Dest->getType() == IceType_i64); 1516 assert(Dest->getType() == IceType_i64);
1465 split64(Dest); 1517 split64(Dest);
1466 Variable *DestLo = Dest->getLo(); 1518 Variable *DestLo = Dest->getLo();
1467 Variable *DestHi = Dest->getHi(); 1519 Variable *DestHi = Dest->getHi();
(...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after
2838 for (SizeT i = 0; i < Size; ++i) { 2890 for (SizeT i = 0; i < Size; ++i) {
2839 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n"; 2891 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n";
2840 } 2892 }
2841 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; 2893 Str << "\t.size\t" << MangledName << ", " << Size << "\n";
2842 } 2894 }
2843 Str << "\t" << (IsInternal ? ".local" : ".global") << "\t" << MangledName 2895 Str << "\t" << (IsInternal ? ".local" : ".global") << "\t" << MangledName
2844 << "\n"; 2896 << "\n";
2845 } 2897 }
2846 2898
2847 } // end of namespace Ice 2899 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceTargetLoweringX8632.h ('k') | tests_lit/llvm2ice_tests/vector-arith.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698