| OLD | NEW |
| 1 //===- subzero/src/IceInstARM32.cpp - ARM32 instruction implementation ----===// | 1 //===- subzero/src/IceInstARM32.cpp - ARM32 instruction implementation ----===// |
| 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 /// \file | 10 /// \file |
| (...skipping 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1247 Str << getPredicate() << WidthString; | 1247 Str << getPredicate() << WidthString; |
| 1248 } else { | 1248 } else { |
| 1249 Str << WidthString << getPredicate(); | 1249 Str << WidthString << getPredicate(); |
| 1250 } | 1250 } |
| 1251 Str << "\t"; | 1251 Str << "\t"; |
| 1252 Dest->emit(Func); | 1252 Dest->emit(Func); |
| 1253 Str << ", "; | 1253 Str << ", "; |
| 1254 Src0->emit(Func); | 1254 Src0->emit(Func); |
| 1255 } | 1255 } |
| 1256 | 1256 |
| 1257 void InstARM32Mov::emitIASScalarVFPMove(const Cfg *Func) const { | |
| 1258 auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>(); | |
| 1259 Operand *Src0 = getSrc(0); | |
| 1260 Variable *Dest = getDest(); | |
| 1261 switch (Dest->getType()) { | |
| 1262 default: | |
| 1263 assert(false && "Do not know how to emit scalar FP move for type."); | |
| 1264 break; | |
| 1265 case IceType_f32: | |
| 1266 if (const auto *Var = llvm::dyn_cast<Variable>(Src0)) { | |
| 1267 Asm->vmovss(Dest, Var, getPredicate()); | |
| 1268 return; | |
| 1269 } else if (const auto *FpImm = | |
| 1270 llvm::dyn_cast<OperandARM32FlexFpImm>(Src0)) { | |
| 1271 Asm->vmovs(Dest, FpImm, getPredicate()); | |
| 1272 return; | |
| 1273 } | |
| 1274 assert(!Asm->needsTextFixup()); | |
| 1275 return; | |
| 1276 case IceType_f64: | |
| 1277 if (const auto *Var = llvm::dyn_cast<Variable>(Src0)) { | |
| 1278 Asm->vmovdd(Dest, Var, getPredicate()); | |
| 1279 return; | |
| 1280 } else if (const auto *FpImm = | |
| 1281 llvm::dyn_cast<OperandARM32FlexFpImm>(Src0)) { | |
| 1282 Asm->vmovd(Dest, FpImm, getPredicate()); | |
| 1283 return; | |
| 1284 } | |
| 1285 assert(!Asm->needsTextFixup()); | |
| 1286 return; | |
| 1287 } | |
| 1288 // TODO(kschimpf) Handle register to register move. | |
| 1289 Asm->setNeedsTextFixup(); | |
| 1290 return; | |
| 1291 } | |
| 1292 | |
| 1293 void InstARM32Mov::emitIASCoreVFPMove(const Cfg *Func) const { | |
| 1294 auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>(); | |
| 1295 Operand *Src0 = getSrc(0); | |
| 1296 if (!llvm::isa<Variable>(Src0)) | |
| 1297 // TODO(kschimpf) Handle moving constants into registers. | |
| 1298 return Asm->setNeedsTextFixup(); | |
| 1299 | |
| 1300 // Move register to register. | |
| 1301 Variable *Dest = getDest(); | |
| 1302 // TODO(kschimpf) Consider merging methods emitIAS.. methods into | |
| 1303 // a single case statement. | |
| 1304 switch (Dest->getType()) { | |
| 1305 default: | |
| 1306 // TODO(kschimpf): Fill this out more. | |
| 1307 return Asm->setNeedsTextFixup(); | |
| 1308 case IceType_i1: | |
| 1309 case IceType_i8: | |
| 1310 case IceType_i16: | |
| 1311 case IceType_i32: | |
| 1312 assert(Src0->getType() == IceType_f32 && "Expected int to float move"); | |
| 1313 Asm->vmovrs(Dest, Src0, getPredicate()); | |
| 1314 return; | |
| 1315 case IceType_i64: | |
| 1316 assert(false && "i64 to float moves not handled here!"); | |
| 1317 return; | |
| 1318 case IceType_f32: | |
| 1319 switch (Src0->getType()) { | |
| 1320 default: | |
| 1321 assert(false && "Expected float to int move"); | |
| 1322 return; | |
| 1323 case IceType_i1: | |
| 1324 case IceType_i8: | |
| 1325 case IceType_i16: | |
| 1326 case IceType_i32: | |
| 1327 return Asm->vmovsr(Dest, Src0, getPredicate()); | |
| 1328 } | |
| 1329 } | |
| 1330 } | |
| 1331 | |
| 1332 void InstARM32Mov::emitIASSingleDestSingleSource(const Cfg *Func) const { | |
| 1333 Variable *Dest = getDest(); | |
| 1334 Operand *Src0 = getSrc(0); | |
| 1335 | |
| 1336 if (!Dest->hasReg()) { | |
| 1337 llvm::report_fatal_error("mov can't store."); | |
| 1338 } | |
| 1339 | |
| 1340 if (isMemoryAccess(Src0)) { | |
| 1341 llvm::report_fatal_error("mov can't load."); | |
| 1342 } | |
| 1343 | |
| 1344 if (isMoveBetweenCoreAndVFPRegisters(Dest, Src0)) | |
| 1345 return emitIASCoreVFPMove(Func); | |
| 1346 | |
| 1347 const Type DestTy = Dest->getType(); | |
| 1348 if (isScalarFloatingType(DestTy)) | |
| 1349 return emitIASScalarVFPMove(Func); | |
| 1350 | |
| 1351 auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>(); | |
| 1352 if (isVectorType(DestTy)) | |
| 1353 return Asm->setNeedsTextFixup(); | |
| 1354 | |
| 1355 return Asm->mov(Dest, Src0, getPredicate()); | |
| 1356 } | |
| 1357 | |
| 1358 void InstARM32Mov::emit(const Cfg *Func) const { | 1257 void InstARM32Mov::emit(const Cfg *Func) const { |
| 1359 if (!BuildDefs::dump()) | 1258 if (!BuildDefs::dump()) |
| 1360 return; | 1259 return; |
| 1361 assert(!(isMultiDest() && isMultiSource()) && "Invalid vmov type."); | 1260 assert(!(isMultiDest() && isMultiSource()) && "Invalid vmov type."); |
| 1362 if (isMultiDest()) { | 1261 if (isMultiDest()) { |
| 1363 emitMultiDestSingleSource(Func); | 1262 emitMultiDestSingleSource(Func); |
| 1364 return; | 1263 return; |
| 1365 } | 1264 } |
| 1366 | 1265 |
| 1367 if (isMultiSource()) { | 1266 if (isMultiSource()) { |
| 1368 emitSingleDestMultiSource(Func); | 1267 emitSingleDestMultiSource(Func); |
| 1369 return; | 1268 return; |
| 1370 } | 1269 } |
| 1371 | 1270 |
| 1372 emitSingleDestSingleSource(Func); | 1271 emitSingleDestSingleSource(Func); |
| 1373 } | 1272 } |
| 1374 | 1273 |
| 1375 void InstARM32Mov::emitIAS(const Cfg *Func) const { | 1274 void InstARM32Mov::emitIAS(const Cfg *Func) const { |
| 1376 // TODO(kschimpf) Flatten this to a switch statement of dest type. That is, | |
| 1377 // combine code of emitIASSingleDestSingleSource, emitIASCoreVFPMove, | |
| 1378 // emitIASScalarVFPMove, emitDoubleToI64Move, and emitI64ToDoubleMove. | |
| 1379 auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>(); | 1275 auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>(); |
| 1276 Variable *Dest = getDest(); |
| 1277 Operand *Src0 = getSrc(0); |
| 1278 if (!Dest->hasReg()) { |
| 1279 llvm::report_fatal_error("mov can't store."); |
| 1280 } |
| 1281 if (isMemoryAccess(Src0)) { |
| 1282 llvm::report_fatal_error("mov can't load."); |
| 1283 } |
| 1284 |
| 1380 assert(!(isMultiDest() && isMultiSource()) && "Invalid vmov type."); | 1285 assert(!(isMultiDest() && isMultiSource()) && "Invalid vmov type."); |
| 1381 if (isMultiDest()) | 1286 if (isMultiDest()) { |
| 1382 Asm->vmovrrd(getDest(), getDestHi(), getSrc(0), getPredicate()); | 1287 Asm->vmovrrd(Dest, getDestHi(), Src0, getPredicate()); |
| 1383 else if (isMultiSource()) | 1288 return; |
| 1384 Asm->vmovdrr(getDest(), getSrc(0), getSrc(1), getPredicate()); | 1289 } |
| 1385 else | 1290 if (isMultiSource()) { |
| 1386 emitIASSingleDestSingleSource(Func); | 1291 Asm->vmovdrr(Dest, Src0, getSrc(1), getPredicate()); |
| 1387 if (Asm->needsTextFixup()) | 1292 return; |
| 1293 } |
| 1294 |
| 1295 const Type DestTy = Dest->getType(); |
| 1296 const Type SrcTy = Src0->getType(); |
| 1297 switch (DestTy) { |
| 1298 default: |
| 1299 break; // Error |
| 1300 case IceType_i1: |
| 1301 case IceType_i8: |
| 1302 case IceType_i16: |
| 1303 case IceType_i32: |
| 1304 switch (SrcTy) { |
| 1305 default: |
| 1306 break; // Error |
| 1307 case IceType_i1: |
| 1308 case IceType_i8: |
| 1309 case IceType_i16: |
| 1310 case IceType_i32: |
| 1311 case IceType_i64: |
| 1312 Asm->mov(Dest, Src0, getPredicate()); |
| 1313 return; |
| 1314 case IceType_f32: |
| 1315 Asm->vmovrs(Dest, Src0, getPredicate()); |
| 1316 return; |
| 1317 } |
| 1318 break; // Error |
| 1319 case IceType_i64: |
| 1320 if (isScalarIntegerType(SrcTy)) { |
| 1321 Asm->mov(Dest, Src0, getPredicate()); |
| 1322 return; |
| 1323 } |
| 1324 if (SrcTy == IceType_f64) { |
| 1325 if (const auto *Var = llvm::dyn_cast<Variable>(Src0)) { |
| 1326 Asm->vmovdd(Dest, Var, getPredicate()); |
| 1327 return; |
| 1328 } |
| 1329 if (const auto *FpImm = llvm::dyn_cast<OperandARM32FlexFpImm>(Src0)) { |
| 1330 Asm->vmovd(Dest, FpImm, getPredicate()); |
| 1331 return; |
| 1332 } |
| 1333 } |
| 1334 break; // Error |
| 1335 case IceType_f32: |
| 1336 switch (SrcTy) { |
| 1337 default: |
| 1338 break; // Error |
| 1339 case IceType_i1: |
| 1340 case IceType_i8: |
| 1341 case IceType_i16: |
| 1342 case IceType_i32: |
| 1343 return Asm->vmovsr(Dest, Src0, getPredicate()); |
| 1344 case IceType_f32: |
| 1345 if (const auto *Var = llvm::dyn_cast<Variable>(Src0)) { |
| 1346 Asm->vmovss(Dest, Var, getPredicate()); |
| 1347 return; |
| 1348 } |
| 1349 if (const auto *FpImm = llvm::dyn_cast<OperandARM32FlexFpImm>(Src0)) { |
| 1350 Asm->vmovs(Dest, FpImm, getPredicate()); |
| 1351 return; |
| 1352 } |
| 1353 break; // Error |
| 1354 } |
| 1355 break; // Error |
| 1356 case IceType_f64: |
| 1357 if (SrcTy == IceType_f64) { |
| 1358 if (const auto *Var = llvm::dyn_cast<Variable>(Src0)) { |
| 1359 Asm->vmovdd(Dest, Var, getPredicate()); |
| 1360 return; |
| 1361 } |
| 1362 if (const auto *FpImm = llvm::dyn_cast<OperandARM32FlexFpImm>(Src0)) { |
| 1363 Asm->vmovd(Dest, FpImm, getPredicate()); |
| 1364 return; |
| 1365 } |
| 1366 } |
| 1367 break; // Error |
| 1368 case IceType_v4i1: |
| 1369 case IceType_v8i1: |
| 1370 case IceType_v16i1: |
| 1371 case IceType_v16i8: |
| 1372 case IceType_v8i16: |
| 1373 case IceType_v4i32: |
| 1374 case IceType_v4f32: |
| 1375 // TODO(kschimpf): Add vector moves. |
| 1388 emitUsingTextFixup(Func); | 1376 emitUsingTextFixup(Func); |
| 1377 return; |
| 1378 } |
| 1379 llvm::report_fatal_error("Mov: don't know how to move " + |
| 1380 typeIceString(SrcTy) + " to " + |
| 1381 typeIceString(DestTy)); |
| 1389 } | 1382 } |
| 1390 | 1383 |
| 1391 void InstARM32Mov::dump(const Cfg *Func) const { | 1384 void InstARM32Mov::dump(const Cfg *Func) const { |
| 1392 if (!BuildDefs::dump()) | 1385 if (!BuildDefs::dump()) |
| 1393 return; | 1386 return; |
| 1394 assert(getSrcSize() == 1 || getSrcSize() == 2); | 1387 assert(getSrcSize() == 1 || getSrcSize() == 2); |
| 1395 Ostream &Str = Func->getContext()->getStrDump(); | 1388 Ostream &Str = Func->getContext()->getStrDump(); |
| 1396 Variable *Dest = getDest(); | 1389 Variable *Dest = getDest(); |
| 1397 Variable *DestHi = getDestHi(); | 1390 Variable *DestHi = getDestHi(); |
| 1398 Dest->dump(Func); | 1391 Dest->dump(Func); |
| (...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2547 | 2540 |
| 2548 template class InstARM32FourAddrGPR<InstARM32::Mla>; | 2541 template class InstARM32FourAddrGPR<InstARM32::Mla>; |
| 2549 template class InstARM32FourAddrGPR<InstARM32::Mls>; | 2542 template class InstARM32FourAddrGPR<InstARM32::Mls>; |
| 2550 | 2543 |
| 2551 template class InstARM32CmpLike<InstARM32::Cmn>; | 2544 template class InstARM32CmpLike<InstARM32::Cmn>; |
| 2552 template class InstARM32CmpLike<InstARM32::Cmp>; | 2545 template class InstARM32CmpLike<InstARM32::Cmp>; |
| 2553 template class InstARM32CmpLike<InstARM32::Tst>; | 2546 template class InstARM32CmpLike<InstARM32::Tst>; |
| 2554 | 2547 |
| 2555 } // end of namespace ARM32 | 2548 } // end of namespace ARM32 |
| 2556 } // end of namespace Ice | 2549 } // end of namespace Ice |
| OLD | NEW |