llvm.org GIT mirror llvm / 5ac319a
Add support for 128 bit multiplicative operations. Lack of these caused a bootstrap failure with Fortran on x86-64 with LegalizeTypes turned on. While there, be nice to 16 bit machines and support expansion of i32 too. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53408 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan Sands 12 years ago
3 changed file(s) with 67 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
3434 SRA_I64,
3535 MUL_I32,
3636 MUL_I64,
37 MUL_I128,
3738 SDIV_I32,
3839 SDIV_I64,
40 SDIV_I128,
3941 UDIV_I32,
4042 UDIV_I64,
43 UDIV_I128,
4144 SREM_I32,
4245 SREM_I64,
46 SREM_I128,
4347 UREM_I32,
4448 UREM_I64,
49 UREM_I128,
4550 NEG_I32,
4651 NEG_I64,
4752
10761076
10771077 MVT VT = N->getValueType(0);
10781078 MVT NVT = TLI.getTypeToTransformTo(VT);
1079 SDOperand Ch = N->getChain(); // Legalize the chain.
1080 SDOperand Ptr = N->getBasePtr(); // Legalize the pointer.
1079 SDOperand Ch = N->getChain();
1080 SDOperand Ptr = N->getBasePtr();
10811081 ISD::LoadExtType ExtType = N->getExtensionType();
10821082 int SVOffset = N->getSrcValueOffset();
10831083 unsigned Alignment = N->getAlignment();
13291329 }
13301330
13311331 // If nothing else, we can make a libcall.
1332 RTLIB::Libcall LC;
1333 switch (VT.getSimpleVT()) {
1334 default:
1335 assert(false && "Unsupported MUL!");
1336 case MVT::i64:
1332 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
1333 if (VT == MVT::i32)
1334 LC = RTLIB::MUL_I32;
1335 else if (VT == MVT::i64)
13371336 LC = RTLIB::MUL_I64;
1338 break;
1339 }
1337 else if (VT == MVT::i128)
1338 LC = RTLIB::MUL_I128;
1339 assert(LC != RTLIB::UNKNOWN_LIBCALL && "Unsupported MUL!");
13401340
13411341 SDOperand Ops[2] = { N->getOperand(0), N->getOperand(1) };
13421342 SplitInteger(MakeLibCall(LC, VT, Ops, 2, true/*sign irrelevant*/), Lo, Hi);
13441344
13451345 void DAGTypeLegalizer::ExpandIntRes_SDIV(SDNode *N,
13461346 SDOperand &Lo, SDOperand &Hi) {
1347 assert(N->getValueType(0) == MVT::i64 && "Unsupported sdiv!");
1347 MVT VT = N->getValueType(0);
1348
1349 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
1350 if (VT == MVT::i32)
1351 LC = RTLIB::SDIV_I32;
1352 else if (VT == MVT::i64)
1353 LC = RTLIB::SDIV_I64;
1354 else if (VT == MVT::i128)
1355 LC = RTLIB::SDIV_I128;
1356 assert(LC != RTLIB::UNKNOWN_LIBCALL && "Unsupported SDIV!");
1357
13481358 SDOperand Ops[2] = { N->getOperand(0), N->getOperand(1) };
1349 SplitInteger(MakeLibCall(RTLIB::SDIV_I64, N->getValueType(0), Ops, 2, true),
1350 Lo, Hi);
1359 SplitInteger(MakeLibCall(LC, VT, Ops, 2, true), Lo, Hi);
13511360 }
13521361
13531362 void DAGTypeLegalizer::ExpandIntRes_SREM(SDNode *N,
13541363 SDOperand &Lo, SDOperand &Hi) {
1355 assert(N->getValueType(0) == MVT::i64 && "Unsupported srem!");
1364 MVT VT = N->getValueType(0);
1365
1366 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
1367 if (VT == MVT::i32)
1368 LC = RTLIB::SREM_I32;
1369 else if (VT == MVT::i64)
1370 LC = RTLIB::SREM_I64;
1371 else if (VT == MVT::i128)
1372 LC = RTLIB::SREM_I128;
1373 assert(LC != RTLIB::UNKNOWN_LIBCALL && "Unsupported SREM!");
1374
13561375 SDOperand Ops[2] = { N->getOperand(0), N->getOperand(1) };
1357 SplitInteger(MakeLibCall(RTLIB::SREM_I64, N->getValueType(0), Ops, 2, true),
1358 Lo, Hi);
1376 SplitInteger(MakeLibCall(LC, VT, Ops, 2, true), Lo, Hi);
13591377 }
13601378
13611379 void DAGTypeLegalizer::ExpandIntRes_UDIV(SDNode *N,
13621380 SDOperand &Lo, SDOperand &Hi) {
1363 assert(N->getValueType(0) == MVT::i64 && "Unsupported udiv!");
1381 MVT VT = N->getValueType(0);
1382
1383 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
1384 if (VT == MVT::i32)
1385 LC = RTLIB::UDIV_I32;
1386 else if (VT == MVT::i64)
1387 LC = RTLIB::UDIV_I64;
1388 else if (VT == MVT::i128)
1389 LC = RTLIB::UDIV_I128;
1390 assert(LC != RTLIB::UNKNOWN_LIBCALL && "Unsupported UDIV!");
1391
13641392 SDOperand Ops[2] = { N->getOperand(0), N->getOperand(1) };
1365 SplitInteger(MakeLibCall(RTLIB::UDIV_I64, N->getValueType(0), Ops, 2, false),
1366 Lo, Hi);
1393 SplitInteger(MakeLibCall(LC, VT, Ops, 2, false), Lo, Hi);
13671394 }
13681395
13691396 void DAGTypeLegalizer::ExpandIntRes_UREM(SDNode *N,
13701397 SDOperand &Lo, SDOperand &Hi) {
1371 assert(N->getValueType(0) == MVT::i64 && "Unsupported urem!");
1398 MVT VT = N->getValueType(0);
1399
1400 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
1401 if (VT == MVT::i32)
1402 LC = RTLIB::UREM_I32;
1403 else if (VT == MVT::i64)
1404 LC = RTLIB::UREM_I64;
1405 else if (VT == MVT::i128)
1406 LC = RTLIB::UREM_I128;
1407 assert(LC != RTLIB::UNKNOWN_LIBCALL && "Unsupported UREM!");
1408
13721409 SDOperand Ops[2] = { N->getOperand(0), N->getOperand(1) };
1373 SplitInteger(MakeLibCall(RTLIB::UREM_I64, N->getValueType(0), Ops, 2, false),
1374 Lo, Hi);
1410 SplitInteger(MakeLibCall(LC, VT, Ops, 2, false), Lo, Hi);
13751411 }
13761412
13771413 void DAGTypeLegalizer::ExpandIntRes_Shift(SDNode *N,
3636 Names[RTLIB::SRA_I64] = "__ashrdi3";
3737 Names[RTLIB::MUL_I32] = "__mulsi3";
3838 Names[RTLIB::MUL_I64] = "__muldi3";
39 Names[RTLIB::MUL_I128] = "__multi3";
3940 Names[RTLIB::SDIV_I32] = "__divsi3";
4041 Names[RTLIB::SDIV_I64] = "__divdi3";
42 Names[RTLIB::SDIV_I128] = "__divti3";
4143 Names[RTLIB::UDIV_I32] = "__udivsi3";
4244 Names[RTLIB::UDIV_I64] = "__udivdi3";
45 Names[RTLIB::UDIV_I128] = "__udivti3";
4346 Names[RTLIB::SREM_I32] = "__modsi3";
4447 Names[RTLIB::SREM_I64] = "__moddi3";
48 Names[RTLIB::SREM_I128] = "__modti3";
4549 Names[RTLIB::UREM_I32] = "__umodsi3";
4650 Names[RTLIB::UREM_I64] = "__umoddi3";
51 Names[RTLIB::UREM_I128] = "__umodti3";
4752 Names[RTLIB::NEG_I32] = "__negsi2";
4853 Names[RTLIB::NEG_I64] = "__negdi2";
4954 Names[RTLIB::ADD_F32] = "__addsf3";