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

Side by Side Diff: src/IceTargetLoweringMIPS32.cpp

Issue 2027773002: Subzero, MIPS32: Handling floating point instructions fadd, fsub, fmul, fdiv (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: RC changes Created 4 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 | « no previous file | tests_lit/llvm2ice_tests/fp.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 // 1 //
2 // The Subzero Code Generator 2 // The Subzero Code Generator
3 // 3 //
4 // This file is distributed under the University of Illinois Open Source 4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details. 5 // License. See LICENSE.TXT for details.
6 // 6 //
7 //===----------------------------------------------------------------------===// 7 //===----------------------------------------------------------------------===//
8 /// 8 ///
9 /// \file 9 /// \file
10 /// \brief Implements the TargetLoweringMIPS32 class, which consists almost 10 /// \brief Implements the TargetLoweringMIPS32 class, which consists almost
(...skipping 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 lowerInt64Arithmetic(Instr, Instr->getDest(), Src0, Src1); 1247 lowerInt64Arithmetic(Instr, Instr->getDest(), Src0, Src1);
1248 return; 1248 return;
1249 } 1249 }
1250 if (isVectorType(Dest->getType())) { 1250 if (isVectorType(Dest->getType())) {
1251 UnimplementedLoweringError(this, Instr); 1251 UnimplementedLoweringError(this, Instr);
1252 return; 1252 return;
1253 } 1253 }
1254 switch (Instr->getOp()) { 1254 switch (Instr->getOp()) {
1255 default: 1255 default:
1256 break; 1256 break;
1257 case InstArithmetic::Fadd:
1258 case InstArithmetic::Fsub:
1259 case InstArithmetic::Fmul:
1260 case InstArithmetic::Fdiv:
1261 case InstArithmetic::Frem: 1257 case InstArithmetic::Frem:
1262 UnimplementedLoweringError(this, Instr); 1258 UnimplementedLoweringError(this, Instr);
1263 return; 1259 return;
1264 } 1260 }
1265 1261
1266 // At this point Dest->getType() is non-i64 scalar 1262 // At this point Dest->getType() is non-i64 scalar
1267 1263
1268 Variable *T = makeReg(Dest->getType()); 1264 Variable *T = makeReg(Dest->getType());
1269 Variable *Src0R = legalizeToReg(Src0); 1265 Variable *Src0R = legalizeToReg(Src0);
1270 Variable *Src1R = legalizeToReg(Src1); 1266 Variable *Src1R = legalizeToReg(Src1);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 _mov(Dest, T); 1329 _mov(Dest, T);
1334 return; 1330 return;
1335 } 1331 }
1336 case InstArithmetic::Srem: { 1332 case InstArithmetic::Srem: {
1337 auto *T_Zero = I32Reg(RegMIPS32::Reg_ZERO); 1333 auto *T_Zero = I32Reg(RegMIPS32::Reg_ZERO);
1338 _div(T_Zero, Src0R, Src1R); 1334 _div(T_Zero, Src0R, Src1R);
1339 _mfhi(T, T_Zero); 1335 _mfhi(T, T_Zero);
1340 _mov(Dest, T); 1336 _mov(Dest, T);
1341 return; 1337 return;
1342 } 1338 }
1343 case InstArithmetic::Fadd: 1339 case InstArithmetic::Fadd: {
1340 if (DestTy == IceType_f32) {
1341 _add_s(T, Src0R, Src1R);
1342 _mov(Dest, T);
1343 return;
1344 }
1345 if (DestTy == IceType_f64) {
1346 _add_d(T, Src0R, Src1R);
1347 _mov(Dest, T);
1348 return;
1349 }
1344 break; 1350 break;
1351 }
1345 case InstArithmetic::Fsub: 1352 case InstArithmetic::Fsub:
1353 if (DestTy == IceType_f32) {
1354 _sub_s(T, Src0R, Src1R);
1355 _mov(Dest, T);
1356 return;
1357 }
1358 if (DestTy == IceType_f64) {
1359 _sub_d(T, Src0R, Src1R);
1360 _mov(Dest, T);
1361 return;
1362 }
1346 break; 1363 break;
1347 case InstArithmetic::Fmul: 1364 case InstArithmetic::Fmul:
1365 if (DestTy == IceType_f32) {
1366 _mul_s(T, Src0R, Src1R);
1367 _mov(Dest, T);
1368 return;
1369 }
1370 if (DestTy == IceType_f64) {
1371 _mul_d(T, Src0R, Src1R);
1372 _mov(Dest, T);
1373 return;
1374 }
1348 break; 1375 break;
1349 case InstArithmetic::Fdiv: 1376 case InstArithmetic::Fdiv:
1377 if (DestTy == IceType_f32) {
1378 _div_s(T, Src0R, Src1R);
1379 _mov(Dest, T);
1380 return;
1381 }
1382 if (DestTy == IceType_f64) {
1383 _div_d(T, Src0R, Src1R);
1384 _mov(Dest, T);
1385 return;
1386 }
1350 break; 1387 break;
1351 case InstArithmetic::Frem: 1388 case InstArithmetic::Frem:
1352 break; 1389 break;
1353 } 1390 }
1354 UnimplementedLoweringError(this, Instr); 1391 UnimplementedLoweringError(this, Instr);
1355 } 1392 }
1356 1393
1357 void TargetMIPS32::lowerAssign(const InstAssign *Instr) { 1394 void TargetMIPS32::lowerAssign(const InstAssign *Instr) {
1358 Variable *Dest = Instr->getDest(); 1395 Variable *Dest = Instr->getDest();
1359 Operand *Src0 = Instr->getSrc(0); 1396 Operand *Src0 = Instr->getSrc(0);
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
2061 break; 2098 break;
2062 } 2099 }
2063 case IceType_i64: { 2100 case IceType_i64: {
2064 Src0 = legalizeUndef(Src0); 2101 Src0 = legalizeUndef(Src0);
2065 Variable *R0 = legalizeToReg(loOperand(Src0), RegMIPS32::Reg_V0); 2102 Variable *R0 = legalizeToReg(loOperand(Src0), RegMIPS32::Reg_V0);
2066 Variable *R1 = legalizeToReg(hiOperand(Src0), RegMIPS32::Reg_V1); 2103 Variable *R1 = legalizeToReg(hiOperand(Src0), RegMIPS32::Reg_V1);
2067 Reg = R0; 2104 Reg = R0;
2068 Context.insert<InstFakeUse>(R1); 2105 Context.insert<InstFakeUse>(R1);
2069 break; 2106 break;
2070 } 2107 }
2071
2072 default: 2108 default:
2073 UnimplementedLoweringError(this, Instr); 2109 UnimplementedLoweringError(this, Instr);
2074 } 2110 }
2075 } 2111 }
2076 _ret(getPhysicalRegister(RegMIPS32::Reg_RA), Reg); 2112 _ret(getPhysicalRegister(RegMIPS32::Reg_RA), Reg);
2077 } 2113 }
2078 2114
2079 void TargetMIPS32::lowerSelect(const InstSelect *Instr) { 2115 void TargetMIPS32::lowerSelect(const InstSelect *Instr) {
2080 UnimplementedLoweringError(this, Instr); 2116 UnimplementedLoweringError(this, Instr);
2081 } 2117 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2184 return; 2220 return;
2185 } 2221 }
2186 2222
2187 // Helper for legalize() to emit the right code to lower an operand to a 2223 // Helper for legalize() to emit the right code to lower an operand to a
2188 // register of the appropriate type. 2224 // register of the appropriate type.
2189 Variable *TargetMIPS32::copyToReg(Operand *Src, RegNumT RegNum) { 2225 Variable *TargetMIPS32::copyToReg(Operand *Src, RegNumT RegNum) {
2190 Type Ty = Src->getType(); 2226 Type Ty = Src->getType();
2191 Variable *Reg = makeReg(Ty, RegNum); 2227 Variable *Reg = makeReg(Ty, RegNum);
2192 if (isVectorType(Ty)) { 2228 if (isVectorType(Ty)) {
2193 UnimplementedError(getFlags()); 2229 UnimplementedError(getFlags());
2194 } else if (isFloatingType(Ty)) {
2195 (Ty == IceType_f32) ? _mov_s(Reg, llvm::dyn_cast<Variable>(Src))
2196 : _mov_d(Reg, llvm::dyn_cast<Variable>(Src));
2197 } else { 2230 } else {
2198 // Mov's Src operand can really only be the flexible second operand type 2231 // Mov's Src operand can really only be the flexible second operand type
2199 // or a register. Users should guarantee that. 2232 // or a register. Users should guarantee that.
2200 _mov(Reg, Src); 2233 _mov(Reg, Src);
2201 } 2234 }
2202 return Reg; 2235 return Reg;
2203 } 2236 }
2204 2237
2205 Operand *TargetMIPS32::legalize(Operand *From, LegalMask Allowed, 2238 Operand *TargetMIPS32::legalize(Operand *From, LegalMask Allowed,
2206 RegNumT RegNum) { 2239 RegNumT RegNum) {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
2360 Str << "\t.set\t" 2393 Str << "\t.set\t"
2361 << "nomips16\n"; 2394 << "nomips16\n";
2362 } 2395 }
2363 2396
2364 SmallBitVector TargetMIPS32::TypeToRegisterSet[RCMIPS32_NUM]; 2397 SmallBitVector TargetMIPS32::TypeToRegisterSet[RCMIPS32_NUM];
2365 SmallBitVector TargetMIPS32::TypeToRegisterSetUnfiltered[RCMIPS32_NUM]; 2398 SmallBitVector TargetMIPS32::TypeToRegisterSetUnfiltered[RCMIPS32_NUM];
2366 SmallBitVector TargetMIPS32::RegisterAliases[RegMIPS32::Reg_NUM]; 2399 SmallBitVector TargetMIPS32::RegisterAliases[RegMIPS32::Reg_NUM];
2367 2400
2368 } // end of namespace MIPS32 2401 } // end of namespace MIPS32
2369 } // end of namespace Ice 2402 } // end of namespace Ice
OLDNEW
« no previous file with comments | « no previous file | tests_lit/llvm2ice_tests/fp.arith.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698