25 #include "llvm/IR/IntrinsicsAArch64.h" 26 #include "llvm/IR/IntrinsicsARM.h" 27 #include "llvm/IR/IntrinsicsX86.h" 76 if (Name ==
"addcarryx.u32" ||
77 Name ==
"addcarryx.u64" ||
78 Name ==
"addcarry.u32" ||
79 Name ==
"addcarry.u64" ||
80 Name ==
"subborrow.u32" ||
81 Name ==
"subborrow.u64" ||
96 Name==
"ssse3.pabs.b.128" ||
97 Name==
"ssse3.pabs.w.128" ||
98 Name==
"ssse3.pabs.d.128" ||
123 Name ==
"sse.sqrt.ss" ||
124 Name ==
"sse2.sqrt.sd" ||
137 Name ==
"avx2.vperm2i128" ||
138 Name ==
"sse.add.ss" ||
139 Name ==
"sse2.add.sd" ||
140 Name ==
"sse.sub.ss" ||
141 Name ==
"sse2.sub.sd" ||
142 Name ==
"sse.mul.ss" ||
143 Name ==
"sse2.mul.sd" ||
144 Name ==
"sse.div.ss" ||
145 Name ==
"sse2.div.sd" ||
146 Name ==
"sse41.pmaxsb" ||
147 Name ==
"sse2.pmaxs.w" ||
148 Name ==
"sse41.pmaxsd" ||
149 Name ==
"sse2.pmaxu.b" ||
150 Name ==
"sse41.pmaxuw" ||
151 Name ==
"sse41.pmaxud" ||
152 Name ==
"sse41.pminsb" ||
153 Name ==
"sse2.pmins.w" ||
154 Name ==
"sse41.pminsd" ||
155 Name ==
"sse2.pminu.b" ||
156 Name ==
"sse41.pminuw" ||
157 Name ==
"sse41.pminud" ||
158 Name ==
"avx512.kand.w" ||
159 Name ==
"avx512.kandn.w" ||
160 Name ==
"avx512.knot.w" ||
161 Name ==
"avx512.kor.w" ||
162 Name ==
"avx512.kxor.w" ||
163 Name ==
"avx512.kxnor.w" ||
164 Name ==
"avx512.kortestc.w" ||
165 Name ==
"avx512.kortestz.w" ||
208 Name ==
"avx512.mask.cvtqq2ps.256" ||
209 Name ==
"avx512.mask.cvtqq2ps.512" ||
210 Name ==
"avx512.mask.cvtuqq2ps.256" ||
211 Name ==
"avx512.mask.cvtuqq2ps.512" ||
212 Name ==
"avx512.mask.cvtpd2dq.256" ||
213 Name ==
"avx512.mask.cvtpd2ps.256" ||
214 Name ==
"avx512.mask.cvttpd2dq.256" ||
215 Name ==
"avx512.mask.cvttps2dq.128" ||
216 Name ==
"avx512.mask.cvttps2dq.256" ||
217 Name ==
"avx512.mask.cvtps2pd.128" ||
218 Name ==
"avx512.mask.cvtps2pd.256" ||
219 Name ==
"avx512.cvtusi2sd" ||
221 Name ==
"sse2.pmulu.dq" ||
222 Name ==
"sse41.pmuldq" ||
223 Name ==
"avx2.pmulu.dq" ||
224 Name ==
"avx2.pmul.dq" ||
225 Name ==
"avx512.pmulu.dq.512" ||
226 Name ==
"avx512.pmul.dq.512" ||
277 Name.
startswith(
"avx512.maskz.vpermt2var.") ||
302 Name.
startswith(
"avx512.mask.vpshufbitqmb.") ||
303 Name.
startswith(
"avx512.mask.pmultishift.qb.") ||
305 Name ==
"avx512.mask.pmov.qd.256" ||
306 Name ==
"avx512.mask.pmov.qd.512" ||
307 Name ==
"avx512.mask.pmov.wb.256" ||
308 Name ==
"avx512.mask.pmov.wb.512" ||
309 Name ==
"sse.cvtsi2ss" ||
310 Name ==
"sse.cvtsi642ss" ||
311 Name ==
"sse2.cvtsi2sd" ||
312 Name ==
"sse2.cvtsi642sd" ||
313 Name ==
"sse2.cvtss2sd" ||
314 Name ==
"sse2.cvtdq2pd" ||
315 Name ==
"sse2.cvtdq2ps" ||
316 Name ==
"sse2.cvtps2pd" ||
317 Name ==
"avx.cvtdq2.pd.256" ||
318 Name ==
"avx.cvtdq2.ps.256" ||
319 Name ==
"avx.cvt.ps2.pd.256" ||
321 Name ==
"avx2.vinserti128" ||
324 Name ==
"avx2.vextracti128" ||
329 Name ==
"sse41.movntdqa" ||
330 Name ==
"avx2.movntdqa" ||
331 Name ==
"avx512.movntdqa" ||
332 Name ==
"sse2.storel.dq" ||
342 Name ==
"avx512.mask.store.ss" ||
345 Name.
startswith(
"avx512.mask.expand.load.") ||
346 Name.
startswith(
"avx512.mask.compress.store.") ||
357 Name ==
"sse42.crc32.64.8" ||
368 Name ==
"sse41.pblendw" ||
371 Name ==
"avx2.pblendw" ||
374 Name ==
"avx2.vbroadcasti128" ||
377 Name ==
"xop.vpcmov" ||
378 Name ==
"xop.vpcmov.256" ||
410 if (Name ==
"rdtscp") {
417 Intrinsic::x86_rdtscp);
423 if (Name.
substr(11) ==
"c")
425 if (Name.
substr(11) ==
"z")
427 if (Name.
substr(11) ==
"nzc")
432 if (Name ==
"sse41.insertps")
435 if (Name ==
"sse41.dppd")
438 if (Name ==
"sse41.dpps")
441 if (Name ==
"sse41.mpsadbw")
444 if (Name ==
"avx.dp.ps.256")
447 if (Name ==
"avx2.mpsadbw")
455 Intrinsic::x86_xop_vfrcz_ss);
461 Intrinsic::x86_xop_vfrcz_sd);
467 if (Idx->isFPOrFPVectorTy()) {
469 unsigned IdxSize = Idx->getPrimitiveSizeInBits();
470 unsigned EltSize = Idx->getScalarSizeInBits();
472 if (EltSize == 64 && IdxSize == 128)
473 Permil2ID = Intrinsic::x86_xop_vpermil2pd;
474 else if (EltSize == 32 && IdxSize == 128)
475 Permil2ID = Intrinsic::x86_xop_vpermil2ps;
476 else if (EltSize == 64 && IdxSize == 256)
477 Permil2ID = Intrinsic::x86_xop_vpermil2pd_256;
479 Permil2ID = Intrinsic::x86_xop_vpermil2ps_256;
485 if (Name ==
"seh.recoverfp") {
494 assert(F &&
"Illegal to upgrade a non-existent Function.");
528 static const Regex vldRegex(
"^arm\\.neon\\.vld([1234]|[234]lane)\\.v[a-z0-9]*$");
529 if (vldRegex.
match(Name)) {
536 "llvm." + Name +
".p0i8", F->
getParent());
539 static const Regex vstRegex(
"^arm\\.neon\\.vst([1234]|[234]lane)\\.v[a-z0-9]*$");
540 if (vstRegex.
match(Name)) {
541 static const Intrinsic::ID StoreInts[] = {Intrinsic::arm_neon_vst1,
542 Intrinsic::arm_neon_vst2,
543 Intrinsic::arm_neon_vst3,
544 Intrinsic::arm_neon_vst4};
547 Intrinsic::arm_neon_vst2lane, Intrinsic::arm_neon_vst3lane,
548 Intrinsic::arm_neon_vst4lane
552 Type *Tys[] = {fArgs[0], fArgs[1]};
555 StoreInts[fArgs.size() - 3], Tys);
558 StoreLaneInts[fArgs.size() - 5], Tys);
561 if (Name ==
"aarch64.thread.pointer" || Name ==
"arm.thread.pointer") {
591 Intrinsic::aarch64_neon_faddp, Ty);
614 if (Name ==
"dbg.value" && F->
arg_size() == 4) {
623 static const Regex R(
"^experimental.vector.reduce.([a-z]+)\\.[fi][0-9]+");
624 if (R.
match(Name, &Groups)) {
626 if (Groups[1] ==
"fadd")
627 ID = Intrinsic::experimental_vector_reduce_v2_fadd;
628 if (Groups[1] ==
"fmul")
629 ID = Intrinsic::experimental_vector_reduce_v2_fmul;
643 bool IsLifetimeStart = Name.
startswith(
"lifetime.start");
644 if (IsLifetimeStart || Name.
startswith(
"invariant.start")) {
646 Intrinsic::lifetime_start : Intrinsic::invariant_start;
656 bool IsLifetimeEnd = Name.
startswith(
"lifetime.end");
657 if (IsLifetimeEnd || Name.
startswith(
"invariant.end")) {
659 Intrinsic::lifetime_end : Intrinsic::invariant_end;
662 Type* ObjectPtr[1] = {
Args[IsLifetimeEnd ? 1 : 2]};
669 if (Name.
startswith(
"invariant.group.barrier")) {
675 Intrinsic::launder_invariant_group, ObjectPtr);
688 Intrinsic::masked_load,
699 Intrinsic::masked_store,
711 Intrinsic::masked_gather, Tys);
721 Intrinsic::masked_scatter, Tys);
748 Type *ParamTypes[2] = {
764 .Cases(
"brev32",
"brev64", Intrinsic::bitreverse)
765 .
Case(
"clz.i", Intrinsic::ctlz)
766 .
Case(
"popc.i", Intrinsic::ctpop)
779 .Cases(
"abs.i",
"abs.ll",
true)
780 .
Cases(
"clz.ll",
"popc.ll",
"h2f",
true)
781 .
Cases(
"max.i",
"max.ll",
"max.ui",
"max.ull",
true)
782 .
Cases(
"min.i",
"min.ll",
"min.ui",
"min.ull",
true)
809 if (Name ==
"prefetch") {
822 if (Name ==
"stackprotectorcheck") {
834 if (Result !=
None) {
835 NewFn = Result.getValue();
849 assert(F != NewFn &&
"Intrinsic function upgraded to the same function");
861 GV->
getName() ==
"llvm.global_dtors")) ||
876 unsigned N = Init->getNumOperands();
877 std::vector<Constant *> NewCtors(N);
878 for (
unsigned i = 0; i !=
N; ++i) {
879 auto Ctor = cast<Constant>(Init->getOperand(i));
881 EltTy, Ctor->getAggregateElement(0u), Ctor->getAggregateElement(1),
909 for (
unsigned l = 0; l != NumElts; l += 16)
910 for (
unsigned i = 0; i != 16; ++i) {
911 unsigned Idx = NumElts + i - Shift;
914 Idxs[l + i] = Idx + l;
943 for (
unsigned l = 0; l != NumElts; l += 16)
944 for (
unsigned i = 0; i != 16; ++i) {
945 unsigned Idx = i + Shift;
948 Idxs[l + i] = Idx + l;
968 for (
unsigned i = 0; i != NumElts; ++i)
981 if (
const auto *
C = dyn_cast<Constant>(Mask))
982 if (
C->isAllOnesValue())
992 if (
const auto *
C = dyn_cast<Constant>(Mask))
993 if (
C->isAllOnesValue())
1011 unsigned ShiftVal = cast<llvm::ConstantInt>(Shift)->getZExtValue();
1014 assert((IsVALIGN || NumElts % 16 == 0) &&
"Illegal NumElts for PALIGNR!");
1015 assert((!IsVALIGN || NumElts <= 16) &&
"NumElts too large for VALIGN!");
1020 ShiftVal &= (NumElts - 1);
1029 if (ShiftVal > 16) {
1037 for (
unsigned l = 0; l < NumElts; l += 16) {
1038 for (
unsigned i = 0; i != 16; ++i) {
1039 unsigned Idx = ShiftVal + i;
1040 if (!IsVALIGN && Idx >= 16)
1041 Idx += NumElts - 16;
1042 Indices[l + i] = Idx + l;
1054 bool ZeroMask,
bool IndexForm) {
1060 if (VecWidth == 128 && EltWidth == 32 && IsFloat)
1061 IID = Intrinsic::x86_avx512_vpermi2var_ps_128;
1062 else if (VecWidth == 128 && EltWidth == 32 && !IsFloat)
1063 IID = Intrinsic::x86_avx512_vpermi2var_d_128;
1064 else if (VecWidth == 128 && EltWidth == 64 && IsFloat)
1065 IID = Intrinsic::x86_avx512_vpermi2var_pd_128;
1066 else if (VecWidth == 128 && EltWidth == 64 && !IsFloat)
1067 IID = Intrinsic::x86_avx512_vpermi2var_q_128;
1068 else if (VecWidth == 256 && EltWidth == 32 && IsFloat)
1069 IID = Intrinsic::x86_avx512_vpermi2var_ps_256;
1070 else if (VecWidth == 256 && EltWidth == 32 && !IsFloat)
1071 IID = Intrinsic::x86_avx512_vpermi2var_d_256;
1072 else if (VecWidth == 256 && EltWidth == 64 && IsFloat)
1073 IID = Intrinsic::x86_avx512_vpermi2var_pd_256;
1074 else if (VecWidth == 256 && EltWidth == 64 && !IsFloat)
1075 IID = Intrinsic::x86_avx512_vpermi2var_q_256;
1076 else if (VecWidth == 512 && EltWidth == 32 && IsFloat)
1077 IID = Intrinsic::x86_avx512_vpermi2var_ps_512;
1078 else if (VecWidth == 512 && EltWidth == 32 && !IsFloat)
1079 IID = Intrinsic::x86_avx512_vpermi2var_d_512;
1080 else if (VecWidth == 512 && EltWidth == 64 && IsFloat)
1081 IID = Intrinsic::x86_avx512_vpermi2var_pd_512;
1082 else if (VecWidth == 512 && EltWidth == 64 && !IsFloat)
1083 IID = Intrinsic::x86_avx512_vpermi2var_q_512;
1084 else if (VecWidth == 128 && EltWidth == 16)
1085 IID = Intrinsic::x86_avx512_vpermi2var_hi_128;
1086 else if (VecWidth == 256 && EltWidth == 16)
1087 IID = Intrinsic::x86_avx512_vpermi2var_hi_256;
1088 else if (VecWidth == 512 && EltWidth == 16)
1089 IID = Intrinsic::x86_avx512_vpermi2var_hi_512;
1090 else if (VecWidth == 128 && EltWidth == 8)
1091 IID = Intrinsic::x86_avx512_vpermi2var_qi_128;
1092 else if (VecWidth == 256 && EltWidth == 8)
1093 IID = Intrinsic::x86_avx512_vpermi2var_qi_256;
1094 else if (VecWidth == 512 && EltWidth == 8)
1095 IID = Intrinsic::x86_avx512_vpermi2var_qi_512;
1115 bool IsSigned,
bool IsAddition) {
1121 IsSigned ? (IsAddition ? Intrinsic::sadd_sat : Intrinsic::ssub_sat)
1122 : (IsAddition ? Intrinsic::uadd_sat : Intrinsic::usub_sat);
1135 bool IsRotateRight) {
1149 Intrinsic::ID IID = IsRotateRight ? Intrinsic::fshr : Intrinsic::fshl;
1201 bool IsShiftRight,
bool ZeroMask) {
1219 Intrinsic::ID IID = IsShiftRight ? Intrinsic::fshr : Intrinsic::fshl;
1244 if (
const auto *
C = dyn_cast<Constant>(Mask))
1245 if (
C->isAllOnesValue())
1264 if (
const auto *
C = dyn_cast<Constant>(Mask))
1265 if (
C->isAllOnesValue())
1336 if (!
C || !
C->isAllOnesValue())
1342 for (
unsigned i = 0; i != NumElts; ++i)
1344 for (
unsigned i = NumElts; i != 8; ++i)
1345 Indices[i] = NumElts + i % NumElts;
1354 unsigned CC,
bool Signed) {
1361 }
else if (CC == 7) {
1411 return Builder.
CreateSExt(Mask, ReturnOp,
"vpmovm2");
1423 if (VecWidth == 128 && EltWidth == 32)
1424 IID = Intrinsic::x86_sse_max_ps;
1425 else if (VecWidth == 128 && EltWidth == 64)
1426 IID = Intrinsic::x86_sse2_max_pd;
1427 else if (VecWidth == 256 && EltWidth == 32)
1428 IID = Intrinsic::x86_avx_max_ps_256;
1429 else if (VecWidth == 256 && EltWidth == 64)
1430 IID = Intrinsic::x86_avx_max_pd_256;
1434 if (VecWidth == 128 && EltWidth == 32)
1435 IID = Intrinsic::x86_sse_min_ps;
1436 else if (VecWidth == 128 && EltWidth == 64)
1437 IID = Intrinsic::x86_sse2_min_pd;
1438 else if (VecWidth == 256 && EltWidth == 32)
1439 IID = Intrinsic::x86_avx_min_ps_256;
1440 else if (VecWidth == 256 && EltWidth == 64)
1441 IID = Intrinsic::x86_avx_min_pd_256;
1445 if (VecWidth == 128)
1446 IID = Intrinsic::x86_ssse3_pshuf_b_128;
1447 else if (VecWidth == 256)
1448 IID = Intrinsic::x86_avx2_pshuf_b;
1449 else if (VecWidth == 512)
1450 IID = Intrinsic::x86_avx512_pshuf_b_512;
1454 if (VecWidth == 128)
1455 IID = Intrinsic::x86_ssse3_pmul_hr_sw_128;
1456 else if (VecWidth == 256)
1457 IID = Intrinsic::x86_avx2_pmul_hr_sw;
1458 else if (VecWidth == 512)
1459 IID = Intrinsic::x86_avx512_pmul_hr_sw_512;
1463 if (VecWidth == 128)
1464 IID = Intrinsic::x86_sse2_pmulh_w;
1465 else if (VecWidth == 256)
1466 IID = Intrinsic::x86_avx2_pmulh_w;
1467 else if (VecWidth == 512)
1468 IID = Intrinsic::x86_avx512_pmulh_w_512;
1472 if (VecWidth == 128)
1473 IID = Intrinsic::x86_sse2_pmulhu_w;
1474 else if (VecWidth == 256)
1475 IID = Intrinsic::x86_avx2_pmulhu_w;
1476 else if (VecWidth == 512)
1477 IID = Intrinsic::x86_avx512_pmulhu_w_512;
1481 if (VecWidth == 128)
1482 IID = Intrinsic::x86_sse2_pmadd_wd;
1483 else if (VecWidth == 256)
1484 IID = Intrinsic::x86_avx2_pmadd_wd;
1485 else if (VecWidth == 512)
1486 IID = Intrinsic::x86_avx512_pmaddw_d_512;
1490 if (VecWidth == 128)
1491 IID = Intrinsic::x86_ssse3_pmadd_ub_sw_128;
1492 else if (VecWidth == 256)
1493 IID = Intrinsic::x86_avx2_pmadd_ub_sw;
1494 else if (VecWidth == 512)
1495 IID = Intrinsic::x86_avx512_pmaddubs_w_512;
1499 if (VecWidth == 128)
1500 IID = Intrinsic::x86_sse2_packsswb_128;
1501 else if (VecWidth == 256)
1502 IID = Intrinsic::x86_avx2_packsswb;
1503 else if (VecWidth == 512)
1504 IID = Intrinsic::x86_avx512_packsswb_512;
1508 if (VecWidth == 128)
1509 IID = Intrinsic::x86_sse2_packssdw_128;
1510 else if (VecWidth == 256)
1511 IID = Intrinsic::x86_avx2_packssdw;
1512 else if (VecWidth == 512)
1513 IID = Intrinsic::x86_avx512_packssdw_512;
1517 if (VecWidth == 128)
1518 IID = Intrinsic::x86_sse2_packuswb_128;
1519 else if (VecWidth == 256)
1520 IID = Intrinsic::x86_avx2_packuswb;
1521 else if (VecWidth == 512)
1522 IID = Intrinsic::x86_avx512_packuswb_512;
1526 if (VecWidth == 128)
1527 IID = Intrinsic::x86_sse41_packusdw;
1528 else if (VecWidth == 256)
1529 IID = Intrinsic::x86_avx2_packusdw;
1530 else if (VecWidth == 512)
1531 IID = Intrinsic::x86_avx512_packusdw_512;
1535 if (VecWidth == 128 && EltWidth == 32)
1536 IID = Intrinsic::x86_avx_vpermilvar_ps;
1537 else if (VecWidth == 128 && EltWidth == 64)
1538 IID = Intrinsic::x86_avx_vpermilvar_pd;
1539 else if (VecWidth == 256 && EltWidth == 32)
1540 IID = Intrinsic::x86_avx_vpermilvar_ps_256;
1541 else if (VecWidth == 256 && EltWidth == 64)
1542 IID = Intrinsic::x86_avx_vpermilvar_pd_256;
1543 else if (VecWidth == 512 && EltWidth == 32)
1544 IID = Intrinsic::x86_avx512_vpermilvar_ps_512;
1545 else if (VecWidth == 512 && EltWidth == 64)
1546 IID = Intrinsic::x86_avx512_vpermilvar_pd_512;
1549 }
else if (Name ==
"cvtpd2dq.256") {
1550 IID = Intrinsic::x86_avx_cvt_pd2dq_256;
1551 }
else if (Name ==
"cvtpd2ps.256") {
1552 IID = Intrinsic::x86_avx_cvt_pd2_ps_256;
1553 }
else if (Name ==
"cvttpd2dq.256") {
1554 IID = Intrinsic::x86_avx_cvtt_pd2dq_256;
1555 }
else if (Name ==
"cvttps2dq.128") {
1556 IID = Intrinsic::x86_sse2_cvttps2dq;
1557 }
else if (Name ==
"cvttps2dq.256") {
1558 IID = Intrinsic::x86_avx_cvtt_ps2dq_256;
1561 if (VecWidth == 256 && EltWidth == 32 && IsFloat)
1562 IID = Intrinsic::x86_avx2_permps;
1563 else if (VecWidth == 256 && EltWidth == 32 && !IsFloat)
1564 IID = Intrinsic::x86_avx2_permd;
1565 else if (VecWidth == 256 && EltWidth == 64 && IsFloat)
1566 IID = Intrinsic::x86_avx512_permvar_df_256;
1567 else if (VecWidth == 256 && EltWidth == 64 && !IsFloat)
1568 IID = Intrinsic::x86_avx512_permvar_di_256;
1569 else if (VecWidth == 512 && EltWidth == 32 && IsFloat)
1570 IID = Intrinsic::x86_avx512_permvar_sf_512;
1571 else if (VecWidth == 512 && EltWidth == 32 && !IsFloat)
1572 IID = Intrinsic::x86_avx512_permvar_si_512;
1573 else if (VecWidth == 512 && EltWidth == 64 && IsFloat)
1574 IID = Intrinsic::x86_avx512_permvar_df_512;
1575 else if (VecWidth == 512 && EltWidth == 64 && !IsFloat)
1576 IID = Intrinsic::x86_avx512_permvar_di_512;
1577 else if (VecWidth == 128 && EltWidth == 16)
1578 IID = Intrinsic::x86_avx512_permvar_hi_128;
1579 else if (VecWidth == 256 && EltWidth == 16)
1580 IID = Intrinsic::x86_avx512_permvar_hi_256;
1581 else if (VecWidth == 512 && EltWidth == 16)
1582 IID = Intrinsic::x86_avx512_permvar_hi_512;
1583 else if (VecWidth == 128 && EltWidth == 8)
1584 IID = Intrinsic::x86_avx512_permvar_qi_128;
1585 else if (VecWidth == 256 && EltWidth == 8)
1586 IID = Intrinsic::x86_avx512_permvar_qi_256;
1587 else if (VecWidth == 512 && EltWidth == 8)
1588 IID = Intrinsic::x86_avx512_permvar_qi_512;
1592 if (VecWidth == 128)
1593 IID = Intrinsic::x86_avx512_dbpsadbw_128;
1594 else if (VecWidth == 256)
1595 IID = Intrinsic::x86_avx512_dbpsadbw_256;
1596 else if (VecWidth == 512)
1597 IID = Intrinsic::x86_avx512_dbpsadbw_512;
1600 }
else if (Name.
startswith(
"pmultishift.qb.")) {
1601 if (VecWidth == 128)
1602 IID = Intrinsic::x86_avx512_pmultishift_qb_128;
1603 else if (VecWidth == 256)
1604 IID = Intrinsic::x86_avx512_pmultishift_qb_256;
1605 else if (VecWidth == 512)
1606 IID = Intrinsic::x86_avx512_pmultishift_qb_512;
1610 if (Name[9] ==
'd' && VecWidth == 128)
1611 IID = Intrinsic::x86_avx512_conflict_d_128;
1612 else if (Name[9] ==
'd' && VecWidth == 256)
1613 IID = Intrinsic::x86_avx512_conflict_d_256;
1614 else if (Name[9] ==
'd' && VecWidth == 512)
1615 IID = Intrinsic::x86_avx512_conflict_d_512;
1616 else if (Name[9] ==
'q' && VecWidth == 128)
1617 IID = Intrinsic::x86_avx512_conflict_q_128;
1618 else if (Name[9] ==
'q' && VecWidth == 256)
1619 IID = Intrinsic::x86_avx512_conflict_q_256;
1620 else if (Name[9] ==
'q' && VecWidth == 512)
1621 IID = Intrinsic::x86_avx512_conflict_q_512;
1625 if (Name[5] ==
'b' && VecWidth == 128)
1626 IID = Intrinsic::x86_sse2_pavg_b;
1627 else if (Name[5] ==
'b' && VecWidth == 256)
1628 IID = Intrinsic::x86_avx2_pavg_b;
1629 else if (Name[5] ==
'b' && VecWidth == 512)
1630 IID = Intrinsic::x86_avx512_pavg_b_512;
1631 else if (Name[5] ==
'w' && VecWidth == 128)
1632 IID = Intrinsic::x86_sse2_pavg_w;
1633 else if (Name[5] ==
'w' && VecWidth == 256)
1634 IID = Intrinsic::x86_avx2_pavg_w;
1635 else if (Name[5] ==
'w' && VecWidth == 512)
1636 IID = Intrinsic::x86_avx512_pavg_w_512;
1658 if (AsmStr->find(
"mov\tfp") == 0 &&
1659 AsmStr->find(
"objc_retainAutoreleaseReturnValue") != std::string::npos &&
1660 (Pos = AsmStr->find(
"# marker")) != std::string::npos) {
1661 AsmStr->replace(Pos, 1,
";");
1674 assert(F &&
"Intrinsic call is not direct?");
1680 assert(Name.
startswith(
"llvm.") &&
"Intrinsic doesn't start with 'llvm.'");
1685 Name = Name.substr(4);
1686 bool IsNVVM = Name.startswith(
"nvvm.");
1688 Name = Name.substr(5);
1690 if (IsX86 && Name.startswith(
"sse4a.movnt.")) {
1702 Type *SrcEltTy = cast<VectorType>(Arg1->
getType())->getElementType();
1716 if (IsX86 && (Name.startswith(
"avx.movnt.") ||
1717 Name.startswith(
"avx512.storent."))) {
1741 if (IsX86 && Name ==
"sse2.storel.dq") {
1758 if (IsX86 && (Name.startswith(
"sse.storeu.") ||
1759 Name.startswith(
"sse2.storeu.") ||
1760 Name.startswith(
"avx.storeu."))) {
1774 if (IsX86 && Name ==
"avx512.mask.store.ss") {
1784 if (IsX86 && (Name.startswith(
"avx512.mask.store"))) {
1786 bool Aligned = Name[17] !=
'u';
1797 if (IsX86 && (Name.startswith(
"sse2.pcmp") ||
1798 Name.startswith(
"avx2.pcmp"))) {
1800 bool CmpEq = Name[9] ==
'e';
1804 }
else if (IsX86 && (Name.startswith(
"avx512.broadcastm"))) {
1812 }
else if (IsX86 && (Name ==
"sse.sqrt.ss" ||
1813 Name ==
"sse2.sqrt.sd")) {
1817 Intrinsic::sqrt, Elt0->
getType());
1820 }
else if (IsX86 && (Name.startswith(
"avx.sqrt.p") ||
1821 Name.startswith(
"sse2.sqrt.p") ||
1822 Name.startswith(
"sse.sqrt.p"))) {
1827 }
else if (IsX86 && (Name.startswith(
"avx512.mask.sqrt.p"))) {
1830 cast<ConstantInt>(CI->
getArgOperand(3))->getZExtValue() != 4)) {
1831 Intrinsic::ID IID = Name[18] ==
's' ? Intrinsic::x86_avx512_sqrt_ps_512
1832 : Intrinsic::x86_avx512_sqrt_pd_512;
1845 }
else if (IsX86 && (Name.startswith(
"avx512.ptestm") ||
1846 Name.startswith(
"avx512.ptestnm"))) {
1857 }
else if (IsX86 && (Name.startswith(
"avx512.mask.pbroadcast"))){
1863 }
else if (IsX86 && (Name.startswith(
"avx512.kunpck"))) {
1868 for (
unsigned i = 0; i != NumElts; ++i)
1882 }
else if (IsX86 && Name ==
"avx512.kand.w") {
1887 }
else if (IsX86 && Name ==
"avx512.kandn.w") {
1893 }
else if (IsX86 && Name ==
"avx512.kor.w") {
1898 }
else if (IsX86 && Name ==
"avx512.kxor.w") {
1903 }
else if (IsX86 && Name ==
"avx512.kxnor.w") {
1909 }
else if (IsX86 && Name ==
"avx512.knot.w") {
1914 (Name ==
"avx512.kortestz.w" || Name ==
"avx512.kortestc.w")) {
1920 if (Name[14] ==
'c')
1926 }
else if (IsX86 && (Name ==
"sse.add.ss" || Name ==
"sse2.add.sd" ||
1927 Name ==
"sse.sub.ss" || Name ==
"sse2.sub.sd" ||
1928 Name ==
"sse.mul.ss" || Name ==
"sse2.mul.sd" ||
1929 Name ==
"sse.div.ss" || Name ==
"sse2.div.sd")) {
1936 if (Name.contains(
".add."))
1938 else if (Name.contains(
".sub."))
1940 else if (Name.contains(
".mul."))
1946 }
else if (IsX86 && Name.startswith(
"avx512.mask.pcmp")) {
1948 bool CmpEq = Name[16] ==
'e';
1950 }
else if (IsX86 && Name.startswith(
"avx512.mask.vpshufbitqmb.")) {
1956 case 128: IID = Intrinsic::x86_avx512_vpshufbitqmb_128;
break;
1957 case 256: IID = Intrinsic::x86_avx512_vpshufbitqmb_256;
break;
1958 case 512: IID = Intrinsic::x86_avx512_vpshufbitqmb_512;
break;
1964 }
else if (IsX86 && Name.startswith(
"avx512.mask.fpclass.p")) {
1969 if (VecWidth == 128 && EltWidth == 32)
1970 IID = Intrinsic::x86_avx512_fpclass_ps_128;
1971 else if (VecWidth == 256 && EltWidth == 32)
1972 IID = Intrinsic::x86_avx512_fpclass_ps_256;
1973 else if (VecWidth == 512 && EltWidth == 32)
1974 IID = Intrinsic::x86_avx512_fpclass_ps_512;
1975 else if (VecWidth == 128 && EltWidth == 64)
1976 IID = Intrinsic::x86_avx512_fpclass_pd_128;
1977 else if (VecWidth == 256 && EltWidth == 64)
1978 IID = Intrinsic::x86_avx512_fpclass_pd_256;
1979 else if (VecWidth == 512 && EltWidth == 64)
1980 IID = Intrinsic::x86_avx512_fpclass_pd_512;
1987 }
else if (IsX86 && Name.startswith(
"avx512.mask.cmp.p")) {
1992 if (VecWidth == 128 && EltWidth == 32)
1993 IID = Intrinsic::x86_avx512_cmp_ps_128;
1994 else if (VecWidth == 256 && EltWidth == 32)
1995 IID = Intrinsic::x86_avx512_cmp_ps_256;
1996 else if (VecWidth == 512 && EltWidth == 32)
1997 IID = Intrinsic::x86_avx512_cmp_ps_512;
1998 else if (VecWidth == 128 && EltWidth == 64)
1999 IID = Intrinsic::x86_avx512_cmp_pd_128;
2000 else if (VecWidth == 256 && EltWidth == 64)
2001 IID = Intrinsic::x86_avx512_cmp_pd_256;
2002 else if (VecWidth == 512 && EltWidth == 64)
2003 IID = Intrinsic::x86_avx512_cmp_pd_512;
2017 }
else if (IsX86 && Name.startswith(
"avx512.mask.cmp.") &&
2020 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
2022 }
else if (IsX86 && Name.startswith(
"avx512.mask.ucmp.")) {
2023 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
2025 }
else if (IsX86 && (Name.startswith(
"avx512.cvtb2mask.") ||
2026 Name.startswith(
"avx512.cvtw2mask.") ||
2027 Name.startswith(
"avx512.cvtd2mask.") ||
2028 Name.startswith(
"avx512.cvtq2mask."))) {
2033 }
else if(IsX86 && (Name ==
"ssse3.pabs.b.128" ||
2034 Name ==
"ssse3.pabs.w.128" ||
2035 Name ==
"ssse3.pabs.d.128" ||
2036 Name.startswith(
"avx2.pabs") ||
2037 Name.startswith(
"avx512.mask.pabs"))) {
2039 }
else if (IsX86 && (Name ==
"sse41.pmaxsb" ||
2040 Name ==
"sse2.pmaxs.w" ||
2041 Name ==
"sse41.pmaxsd" ||
2042 Name.startswith(
"avx2.pmaxs") ||
2043 Name.startswith(
"avx512.mask.pmaxs"))) {
2045 }
else if (IsX86 && (Name ==
"sse2.pmaxu.b" ||
2046 Name ==
"sse41.pmaxuw" ||
2047 Name ==
"sse41.pmaxud" ||
2048 Name.startswith(
"avx2.pmaxu") ||
2049 Name.startswith(
"avx512.mask.pmaxu"))) {
2051 }
else if (IsX86 && (Name ==
"sse41.pminsb" ||
2052 Name ==
"sse2.pmins.w" ||
2053 Name ==
"sse41.pminsd" ||
2054 Name.startswith(
"avx2.pmins") ||
2055 Name.startswith(
"avx512.mask.pmins"))) {
2057 }
else if (IsX86 && (Name ==
"sse2.pminu.b" ||
2058 Name ==
"sse41.pminuw" ||
2059 Name ==
"sse41.pminud" ||
2060 Name.startswith(
"avx2.pminu") ||
2061 Name.startswith(
"avx512.mask.pminu"))) {
2063 }
else if (IsX86 && (Name ==
"sse2.pmulu.dq" ||
2064 Name ==
"avx2.pmulu.dq" ||
2065 Name ==
"avx512.pmulu.dq.512" ||
2066 Name.startswith(
"avx512.mask.pmulu.dq."))) {
2068 }
else if (IsX86 && (Name ==
"sse41.pmuldq" ||
2069 Name ==
"avx2.pmul.dq" ||
2070 Name ==
"avx512.pmul.dq.512" ||
2071 Name.startswith(
"avx512.mask.pmul.dq."))) {
2073 }
else if (IsX86 && (Name ==
"sse.cvtsi2ss" ||
2074 Name ==
"sse2.cvtsi2sd" ||
2075 Name ==
"sse.cvtsi642ss" ||
2076 Name ==
"sse2.cvtsi642sd")) {
2080 }
else if (IsX86 && Name ==
"avx512.cvtusi2sd") {
2084 }
else if (IsX86 && Name ==
"sse2.cvtss2sd") {
2088 }
else if (IsX86 && (Name ==
"sse2.cvtdq2pd" ||
2089 Name ==
"sse2.cvtdq2ps" ||
2090 Name ==
"avx.cvtdq2.pd.256" ||
2091 Name ==
"avx.cvtdq2.ps.256" ||
2092 Name.startswith(
"avx512.mask.cvtdq2pd.") ||
2093 Name.startswith(
"avx512.mask.cvtudq2pd.") ||
2094 Name.startswith(
"avx512.mask.cvtdq2ps.") ||
2095 Name.startswith(
"avx512.mask.cvtudq2ps.") ||
2096 Name.startswith(
"avx512.mask.cvtqq2pd.") ||
2097 Name.startswith(
"avx512.mask.cvtuqq2pd.") ||
2098 Name ==
"avx512.mask.cvtqq2ps.256" ||
2099 Name ==
"avx512.mask.cvtqq2ps.512" ||
2100 Name ==
"avx512.mask.cvtuqq2ps.256" ||
2101 Name ==
"avx512.mask.cvtuqq2ps.512" ||
2102 Name ==
"sse2.cvtps2pd" ||
2103 Name ==
"avx.cvt.ps2.pd.256" ||
2104 Name ==
"avx512.mask.cvtps2pd.128" ||
2105 Name ==
"avx512.mask.cvtps2pd.256")) {
2111 if (NumDstElts < SrcTy->getVectorNumElements()) {
2112 assert(NumDstElts == 2 &&
"Unexpected vector size");
2113 uint32_t ShuffleMask[2] = { 0, 1 };
2120 Rep = Builder.
CreateFPExt(Rep, DstTy,
"cvtps2pd");
2123 cast<ConstantInt>(CI->
getArgOperand(3))->getZExtValue() != 4)) {
2124 Intrinsic::ID IID = IsUnsigned ? Intrinsic::x86_avx512_uitofp_round
2125 : Intrinsic::x86_avx512_sitofp_round;
2130 Rep = IsUnsigned ? Builder.
CreateUIToFP(Rep, DstTy,
"cvt")
2137 }
else if (IsX86 && (Name.startswith(
"avx512.mask.loadu."))) {
2141 }
else if (IsX86 && (Name.startswith(
"avx512.mask.load."))) {
2145 }
else if (IsX86 && Name.startswith(
"avx512.mask.expand.load.")) {
2157 Intrinsic::masked_expandload,
2160 }
else if (IsX86 && Name.startswith(
"avx512.mask.compress.store.")) {
2172 Intrinsic::masked_compressstore,
2175 }
else if (IsX86 && (Name.startswith(
"avx512.mask.compress.") ||
2176 Name.startswith(
"avx512.mask.expand."))) {
2182 bool IsCompress = Name[12] ==
'c';
2183 Intrinsic::ID IID = IsCompress ? Intrinsic::x86_avx512_mask_compress
2184 : Intrinsic::x86_avx512_mask_expand;
2188 }
else if (IsX86 && Name.startswith(
"xop.vpcom")) {
2190 if (Name.endswith(
"ub") || Name.endswith(
"uw") || Name.endswith(
"ud") ||
2191 Name.endswith(
"uq"))
2193 else if (Name.endswith(
"b") || Name.endswith(
"w") || Name.endswith(
"d") ||
2201 Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
2203 Name = Name.substr(9);
2204 if (Name.startswith(
"lt"))
2206 else if (Name.startswith(
"le"))
2208 else if (Name.startswith(
"gt"))
2210 else if (Name.startswith(
"ge"))
2212 else if (Name.startswith(
"eq"))
2214 else if (Name.startswith(
"ne"))
2216 else if (Name.startswith(
"false"))
2218 else if (Name.startswith(
"true"))
2225 }
else if (IsX86 && Name.startswith(
"xop.vpcmov")) {
2230 Rep = Builder.
CreateOr(Sel0, Sel1);
2231 }
else if (IsX86 && (Name.startswith(
"xop.vprot") ||
2232 Name.startswith(
"avx512.prol") ||
2233 Name.startswith(
"avx512.mask.prol"))) {
2235 }
else if (IsX86 && (Name.startswith(
"avx512.pror") ||
2236 Name.startswith(
"avx512.mask.pror"))) {
2238 }
else if (IsX86 && (Name.startswith(
"avx512.vpshld.") ||
2239 Name.startswith(
"avx512.mask.vpshld") ||
2240 Name.startswith(
"avx512.maskz.vpshld"))) {
2241 bool ZeroMask = Name[11] ==
'z';
2243 }
else if (IsX86 && (Name.startswith(
"avx512.vpshrd.") ||
2244 Name.startswith(
"avx512.mask.vpshrd") ||
2245 Name.startswith(
"avx512.maskz.vpshrd"))) {
2246 bool ZeroMask = Name[11] ==
'z';
2248 }
else if (IsX86 && Name ==
"sse42.crc32.64.8") {
2250 Intrinsic::x86_sse42_crc32_32_8);
2254 }
else if (IsX86 && (Name.startswith(
"avx.vbroadcast.s") ||
2255 Name.startswith(
"avx512.vbroadcast.s"))) {
2265 for (
unsigned I = 0;
I < EltNum; ++
I)
2268 }
else if (IsX86 && (Name.startswith(
"sse41.pmovsx") ||
2269 Name.startswith(
"sse41.pmovzx") ||
2270 Name.startswith(
"avx2.pmovsx") ||
2271 Name.startswith(
"avx2.pmovzx") ||
2272 Name.startswith(
"avx512.mask.pmovsx") ||
2273 Name.startswith(
"avx512.mask.pmovzx"))) {
2280 for (
unsigned i = 0; i != NumDstElts; ++i)
2293 }
else if (Name ==
"avx512.mask.pmov.qd.256" ||
2294 Name ==
"avx512.mask.pmov.qd.512" ||
2295 Name ==
"avx512.mask.pmov.wb.256" ||
2296 Name ==
"avx512.mask.pmov.wb.512") {
2301 }
else if (IsX86 && (Name.startswith(
"avx.vbroadcastf128") ||
2302 Name ==
"avx2.vbroadcasti128")) {
2310 if (NumSrcElts == 2)
2315 { 0, 1, 2, 3, 0, 1, 2, 3 });
2316 }
else if (IsX86 && (Name.startswith(
"avx512.mask.shuf.i") ||
2317 Name.startswith(
"avx512.mask.shuf.f"))) {
2318 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
2322 unsigned ControlBitsMask = NumLanes - 1;
2323 unsigned NumControlBits = NumLanes / 2;
2326 for (
unsigned l = 0; l != NumLanes; ++l) {
2327 unsigned LaneMask = (Imm >> (l * NumControlBits)) & ControlBitsMask;
2329 if (l >= NumLanes / 2)
2330 LaneMask += NumLanes;
2331 for (
unsigned i = 0; i != NumElementsInLane; ++i)
2332 ShuffleMask.
push_back(LaneMask * NumElementsInLane + i);
2338 }
else if (IsX86 && (Name.startswith(
"avx512.mask.broadcastf") ||
2339 Name.startswith(
"avx512.mask.broadcasti"))) {
2340 unsigned NumSrcElts =
2345 for (
unsigned i = 0; i != NumDstElts; ++i)
2346 ShuffleMask[i] = i % NumSrcElts;
2353 }
else if (IsX86 && (Name.startswith(
"avx2.pbroadcast") ||
2354 Name.startswith(
"avx2.vbroadcast") ||
2355 Name.startswith(
"avx512.pbroadcast") ||
2356 Name.startswith(
"avx512.mask.broadcast.s"))) {
2367 }
else if (IsX86 && (Name.startswith(
"sse2.padds.") ||
2368 Name.startswith(
"sse2.psubs.") ||
2369 Name.startswith(
"avx2.padds.") ||
2370 Name.startswith(
"avx2.psubs.") ||
2371 Name.startswith(
"avx512.padds.") ||
2372 Name.startswith(
"avx512.psubs.") ||
2373 Name.startswith(
"avx512.mask.padds.") ||
2374 Name.startswith(
"avx512.mask.psubs."))) {
2375 bool IsAdd = Name.contains(
".padds");
2377 }
else if (IsX86 && (Name.startswith(
"sse2.paddus.") ||
2378 Name.startswith(
"sse2.psubus.") ||
2379 Name.startswith(
"avx2.paddus.") ||
2380 Name.startswith(
"avx2.psubus.") ||
2381 Name.startswith(
"avx512.mask.paddus.") ||
2382 Name.startswith(
"avx512.mask.psubus."))) {
2383 bool IsAdd = Name.contains(
".paddus");
2385 }
else if (IsX86 && Name.startswith(
"avx512.mask.palignr.")) {
2392 }
else if (IsX86 && Name.startswith(
"avx512.mask.valign.")) {
2399 }
else if (IsX86 && (Name ==
"sse2.psll.dq" ||
2400 Name ==
"avx2.psll.dq")) {
2402 unsigned Shift = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
2405 }
else if (IsX86 && (Name ==
"sse2.psrl.dq" ||
2406 Name ==
"avx2.psrl.dq")) {
2408 unsigned Shift = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
2411 }
else if (IsX86 && (Name ==
"sse2.psll.dq.bs" ||
2412 Name ==
"avx2.psll.dq.bs" ||
2413 Name ==
"avx512.psll.dq.512")) {
2415 unsigned Shift = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
2417 }
else if (IsX86 && (Name ==
"sse2.psrl.dq.bs" ||
2418 Name ==
"avx2.psrl.dq.bs" ||
2419 Name ==
"avx512.psrl.dq.512")) {
2421 unsigned Shift = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
2423 }
else if (IsX86 && (Name ==
"sse41.pblendw" ||
2424 Name.startswith(
"sse41.blendp") ||
2425 Name.startswith(
"avx.blend.p") ||
2426 Name ==
"avx2.pblendw" ||
2427 Name.startswith(
"avx2.pblendd."))) {
2430 unsigned Imm = cast <ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
2435 for (
unsigned i = 0; i != NumElts; ++i)
2436 Idxs[i] = ((Imm >> (i%8)) & 1) ? i + NumElts : i;
2439 }
else if (IsX86 && (Name.startswith(
"avx.vinsertf128.") ||
2440 Name ==
"avx2.vinserti128" ||
2441 Name.startswith(
"avx512.mask.insert"))) {
2444 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
2447 unsigned Scale = DstNumElts / SrcNumElts;
2455 for (
unsigned i = 0; i != SrcNumElts; ++i)
2457 for (
unsigned i = SrcNumElts; i != DstNumElts; ++i)
2458 Idxs[i] = SrcNumElts;
2473 for (
unsigned i = 0; i != DstNumElts; ++i)
2476 for (
unsigned i = 0; i != SrcNumElts; ++i)
2477 Idxs[i + Imm * SrcNumElts] = i + DstNumElts;
2484 }
else if (IsX86 && (Name.startswith(
"avx.vextractf128.") ||
2485 Name ==
"avx2.vextracti128" ||
2486 Name.startswith(
"avx512.mask.vextract"))) {
2488 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
2491 unsigned Scale = SrcNumElts / DstNumElts;
2498 for (
unsigned i = 0; i != DstNumElts; ++i) {
2499 Idxs[i] = i + (Imm * DstNumElts);
2507 }
else if (!IsX86 && Name ==
"stackprotectorcheck") {
2509 }
else if (IsX86 && (Name.startswith(
"avx512.mask.perm.df.") ||
2510 Name.startswith(
"avx512.mask.perm.di."))) {
2512 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
2517 for (
unsigned i = 0; i != NumElts; ++i)
2518 Idxs[i] = (i & ~0x3) + ((Imm >> (2 * (i & 0x3))) & 3);
2525 }
else if (IsX86 && (Name.startswith(
"avx.vperm2f128.") ||
2526 Name ==
"avx2.vperm2i128")) {
2535 uint8_t Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
2538 unsigned HalfSize = NumElts / 2;
2550 unsigned StartIndex = (Imm & 0x01) ? HalfSize : 0;
2551 for (
unsigned i = 0; i < HalfSize; ++i)
2552 ShuffleMask[i] = StartIndex + i;
2555 StartIndex = (Imm & 0x10) ? HalfSize : 0;
2556 for (
unsigned i = 0; i < HalfSize; ++i)
2557 ShuffleMask[i + HalfSize] = NumElts + StartIndex + i;
2561 }
else if (IsX86 && (Name.startswith(
"avx.vpermil.") ||
2562 Name ==
"sse2.pshuf.d" ||
2563 Name.startswith(
"avx512.mask.vpermil.p") ||
2564 Name.startswith(
"avx512.mask.pshuf.d."))) {
2566 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
2571 unsigned IdxMask = ((1 << IdxSize) - 1);
2577 for (
unsigned i = 0; i != NumElts; ++i)
2578 Idxs[i] = ((Imm >> ((i * IdxSize) % 8)) & IdxMask) | (i & ~IdxMask);
2585 }
else if (IsX86 && (Name ==
"sse2.pshufl.w" ||
2586 Name.startswith(
"avx512.mask.pshufl.w."))) {
2588 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
2592 for (
unsigned l = 0; l != NumElts; l += 8) {
2593 for (
unsigned i = 0; i != 4; ++i)
2594 Idxs[i + l] = ((Imm >> (2 * i)) & 0x3) + l;
2595 for (
unsigned i = 4; i != 8; ++i)
2596 Idxs[i + l] = i + l;
2604 }
else if (IsX86 && (Name ==
"sse2.pshufh.w" ||
2605 Name.startswith(
"avx512.mask.pshufh.w."))) {
2607 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
2611 for (
unsigned l = 0; l != NumElts; l += 8) {
2612 for (
unsigned i = 0; i != 4; ++i)
2613 Idxs[i + l] = i + l;
2614 for (
unsigned i = 0; i != 4; ++i)
2615 Idxs[i + l + 4] = ((Imm >> (2 * i)) & 0x3) + 4 + l;
2623 }
else if (IsX86 && Name.startswith(
"avx512.mask.shuf.p")) {
2626 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
2630 unsigned HalfLaneElts = NumLaneElts / 2;
2633 for (
unsigned i = 0; i != NumElts; ++i) {
2635 Idxs[i] = i - (i % NumLaneElts);
2637 if ((i % NumLaneElts) >= HalfLaneElts)
2641 Idxs[i] += (Imm >> ((i * HalfLaneElts) % 8)) & ((1 << HalfLaneElts) - 1);
2648 }
else if (IsX86 && (Name.startswith(
"avx512.mask.movddup") ||
2649 Name.startswith(
"avx512.mask.movshdup") ||
2650 Name.startswith(
"avx512.mask.movsldup"))) {
2656 if (Name.startswith(
"avx512.mask.movshdup."))
2660 for (
unsigned l = 0; l != NumElts; l += NumLaneElts)
2661 for (
unsigned i = 0; i != NumLaneElts; i += 2) {
2662 Idxs[i + l + 0] = i + l +
Offset;
2663 Idxs[i + l + 1] = i + l +
Offset;
2670 }
else if (IsX86 && (Name.startswith(
"avx512.mask.punpckl") ||
2671 Name.startswith(
"avx512.mask.unpckl."))) {
2678 for (
int l = 0; l != NumElts; l += NumLaneElts)
2679 for (
int i = 0; i != NumLaneElts; ++i)
2680 Idxs[i + l] = l + (i / 2) + NumElts * (i % 2);
2686 }
else if (IsX86 && (Name.startswith(
"avx512.mask.punpckh") ||
2687 Name.startswith(
"avx512.mask.unpckh."))) {
2694 for (
int l = 0; l != NumElts; l += NumLaneElts)
2695 for (
int i = 0; i != NumLaneElts; ++i)
2696 Idxs[i + l] = (NumLaneElts / 2) + l + (i / 2) + NumElts * (i % 2);
2702 }
else if (IsX86 && (Name.startswith(
"avx512.mask.and.") ||
2703 Name.startswith(
"avx512.mask.pand."))) {
2711 }
else if (IsX86 && (Name.startswith(
"avx512.mask.andn.") ||
2712 Name.startswith(
"avx512.mask.pandn."))) {
2721 }
else if (IsX86 && (Name.startswith(
"avx512.mask.or.") ||
2722 Name.startswith(
"avx512.mask.por."))) {
2730 }
else if (IsX86 && (Name.startswith(
"avx512.mask.xor.") ||
2731 Name.startswith(
"avx512.mask.pxor."))) {
2739 }
else if (IsX86 && Name.startswith(
"avx512.mask.padd.")) {
2743 }
else if (IsX86 && Name.startswith(
"avx512.mask.psub.")) {
2747 }
else if (IsX86 && Name.startswith(
"avx512.mask.pmull.")) {
2751 }
else if (IsX86 && Name.startswith(
"avx512.mask.add.p")) {
2752 if (Name.endswith(
".512")) {
2754 if (Name[17] ==
's')
2755 IID = Intrinsic::x86_avx512_add_ps_512;
2757 IID = Intrinsic::x86_avx512_add_pd_512;
2767 }
else if (IsX86 && Name.startswith(
"avx512.mask.div.p")) {
2768 if (Name.endswith(
".512")) {
2770 if (Name[17] ==
's')
2771 IID = Intrinsic::x86_avx512_div_ps_512;
2773 IID = Intrinsic::x86_avx512_div_pd_512;
2783 }
else if (IsX86 && Name.startswith(
"avx512.mask.mul.p")) {
2784 if (Name.endswith(
".512")) {
2786 if (Name[17] ==
's')
2787 IID = Intrinsic::x86_avx512_mul_ps_512;
2789 IID = Intrinsic::x86_avx512_mul_pd_512;
2799 }
else if (IsX86 && Name.startswith(
"avx512.mask.sub.p")) {
2800 if (Name.endswith(
".512")) {
2802 if (Name[17] ==
's')
2803 IID = Intrinsic::x86_avx512_sub_ps_512;
2805 IID = Intrinsic::x86_avx512_sub_pd_512;
2815 }
else if (IsX86 && (Name.startswith(
"avx512.mask.max.p") ||
2816 Name.startswith(
"avx512.mask.min.p")) &&
2817 Name.drop_front(18) ==
".512") {
2818 bool IsDouble = Name[17] ==
'd';
2819 bool IsMin = Name[13] ==
'i';
2821 { Intrinsic::x86_avx512_max_ps_512, Intrinsic::x86_avx512_max_pd_512 },
2822 { Intrinsic::x86_avx512_min_ps_512, Intrinsic::x86_avx512_min_pd_512 }
2831 }
else if (IsX86 && Name.startswith(
"avx512.mask.lzcnt.")) {
2838 }
else if (IsX86 && Name.startswith(
"avx512.mask.psll")) {
2839 bool IsImmediate = Name[16] ==
'i' ||
2840 (Name.size() > 18 && Name[18] ==
'i');
2841 bool IsVariable = Name[16] ==
'v';
2842 char Size = Name[16] ==
'.' ? Name[17] :
2843 Name[17] ==
'.' ? Name[18] :
2844 Name[18] ==
'.' ? Name[19] :
2848 if (IsVariable && Name[17] !=
'.') {
2849 if (Size ==
'd' && Name[17] ==
'2')
2850 IID = Intrinsic::x86_avx2_psllv_q;
2851 else if (Size ==
'd' && Name[17] ==
'4')
2852 IID = Intrinsic::x86_avx2_psllv_q_256;
2853 else if (Size ==
's' && Name[17] ==
'4')
2854 IID = Intrinsic::x86_avx2_psllv_d;
2855 else if (Size ==
's' && Name[17] ==
'8')
2856 IID = Intrinsic::x86_avx2_psllv_d_256;
2857 else if (Size ==
'h' && Name[17] ==
'8')
2858 IID = Intrinsic::x86_avx512_psllv_w_128;
2859 else if (Size ==
'h' && Name[17] ==
'1')
2860 IID = Intrinsic::x86_avx512_psllv_w_256;
2861 else if (Name[17] ==
'3' && Name[18] ==
'2')
2862 IID = Intrinsic::x86_avx512_psllv_w_512;
2865 }
else if (Name.endswith(
".128")) {
2867 IID = IsImmediate ? Intrinsic::x86_sse2_pslli_d
2868 : Intrinsic::x86_sse2_psll_d;
2869 else if (Size ==
'q')
2870 IID = IsImmediate ? Intrinsic::x86_sse2_pslli_q
2871 : Intrinsic::x86_sse2_psll_q;
2872 else if (Size ==
'w')
2873 IID = IsImmediate ? Intrinsic::x86_sse2_pslli_w
2874 : Intrinsic::x86_sse2_psll_w;
2877 }
else if (Name.endswith(
".256")) {
2879 IID = IsImmediate ? Intrinsic::x86_avx2_pslli_d
2880 : Intrinsic::x86_avx2_psll_d;
2881 else if (Size ==
'q')
2882 IID = IsImmediate ? Intrinsic::x86_avx2_pslli_q
2883 : Intrinsic::x86_avx2_psll_q;
2884 else if (Size ==
'w')
2885 IID = IsImmediate ? Intrinsic::x86_avx2_pslli_w
2886 : Intrinsic::x86_avx2_psll_w;
2891 IID = IsImmediate ? Intrinsic::x86_avx512_pslli_d_512 :
2892 IsVariable ? Intrinsic::x86_avx512_psllv_d_512 :
2893 Intrinsic::x86_avx512_psll_d_512;
2894 else if (Size ==
'q')
2895 IID = IsImmediate ? Intrinsic::x86_avx512_pslli_q_512 :
2896 IsVariable ? Intrinsic::x86_avx512_psllv_q_512 :
2897 Intrinsic::x86_avx512_psll_q_512;
2898 else if (Size ==
'w')
2899 IID = IsImmediate ? Intrinsic::x86_avx512_pslli_w_512
2900 : Intrinsic::x86_avx512_psll_w_512;
2906 }
else if (IsX86 && Name.startswith(
"avx512.mask.psrl")) {
2907 bool IsImmediate = Name[16] ==
'i' ||
2908 (Name.size() > 18 && Name[18] ==
'i');
2909 bool IsVariable = Name[16] ==
'v';
2910 char Size = Name[16] ==
'.' ? Name[17] :
2911 Name[17] ==
'.' ? Name[18] :
2912 Name[18] ==
'.' ? Name[19] :
2916 if (IsVariable && Name[17] !=
'.') {
2917 if (Size ==
'd' && Name[17] ==
'2')
2918 IID = Intrinsic::x86_avx2_psrlv_q;
2919 else if (Size ==
'd' && Name[17] ==
'4')
2920 IID = Intrinsic::x86_avx2_psrlv_q_256;
2921 else if (Size ==
's' && Name[17] ==
'4')
2922 IID = Intrinsic::x86_avx2_psrlv_d;
2923 else if (Size ==
's' && Name[17] ==
'8')
2924 IID = Intrinsic::x86_avx2_psrlv_d_256;
2925 else if (Size ==
'h' && Name[17] ==
'8')
2926 IID = Intrinsic::x86_avx512_psrlv_w_128;
2927 else if (Size ==
'h' && Name[17] ==
'1')
2928 IID = Intrinsic::x86_avx512_psrlv_w_256;
2929 else if (Name[17] ==
'3' && Name[18] ==
'2')
2930 IID = Intrinsic::x86_avx512_psrlv_w_512;
2933 }
else if (Name.endswith(
".128")) {
2935 IID = IsImmediate ? Intrinsic::x86_sse2_psrli_d
2936 : Intrinsic::x86_sse2_psrl_d;
2937 else if (Size ==
'q')
2938 IID = IsImmediate ? Intrinsic::x86_sse2_psrli_q
2939 : Intrinsic::x86_sse2_psrl_q;
2940 else if (Size ==
'w')
2941 IID = IsImmediate ? Intrinsic::x86_sse2_psrli_w
2942 : Intrinsic::x86_sse2_psrl_w;
2945 }
else if (Name.endswith(
".256")) {
2947 IID = IsImmediate ? Intrinsic::x86_avx2_psrli_d
2948 : Intrinsic::x86_avx2_psrl_d;
2949 else if (Size ==
'q')
2950 IID = IsImmediate ? Intrinsic::x86_avx2_psrli_q
2951 : Intrinsic::x86_avx2_psrl_q;
2952 else if (Size ==
'w')
2953 IID = IsImmediate ? Intrinsic::x86_avx2_psrli_w
2954 : Intrinsic::x86_avx2_psrl_w;
2959 IID = IsImmediate ? Intrinsic::x86_avx512_psrli_d_512 :
2960 IsVariable ? Intrinsic::x86_avx512_psrlv_d_512 :
2961 Intrinsic::x86_avx512_psrl_d_512;
2962 else if (Size ==
'q')
2963 IID = IsImmediate ? Intrinsic::x86_avx512_psrli_q_512 :
2964 IsVariable ? Intrinsic::x86_avx512_psrlv_q_512 :
2965 Intrinsic::x86_avx512_psrl_q_512;
2966 else if (Size ==
'w')
2967 IID = IsImmediate ? Intrinsic::x86_avx512_psrli_w_512
2968 : Intrinsic::x86_avx512_psrl_w_512;
2974 }
else if (IsX86 && Name.startswith(
"avx512.mask.psra")) {
2975 bool IsImmediate = Name[16] ==
'i' ||
2976 (Name.size() > 18 && Name[18] ==
'i');
2977 bool IsVariable = Name[16] ==
'v';
2978 char Size = Name[16] ==
'.' ? Name[17] :
2979 Name[17] ==
'.' ? Name[18] :
2980 Name[18] ==
'.' ? Name[19] :
2984 if (IsVariable && Name[17] !=
'.') {
2985 if (Size ==
's' && Name[17] ==
'4')
2986 IID = Intrinsic::x86_avx2_psrav_d;
2987 else if (Size ==
's' && Name[17] ==
'8')
2988 IID = Intrinsic::x86_avx2_psrav_d_256;
2989 else if (Size ==
'h' && Name[17] ==
'8')
2990 IID = Intrinsic::x86_avx512_psrav_w_128;
2991 else if (Size ==
'h' && Name[17] ==
'1')
2992 IID = Intrinsic::x86_avx512_psrav_w_256;
2993 else if (Name[17] ==
'3' && Name[18] ==
'2')
2994 IID = Intrinsic::x86_avx512_psrav_w_512;
2997 }
else if (Name.endswith(
".128")) {
2999 IID = IsImmediate ? Intrinsic::x86_sse2_psrai_d
3000 : Intrinsic::x86_sse2_psra_d;
3001 else if (Size ==
'q')
3002 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_q_128 :
3003 IsVariable ? Intrinsic::x86_avx512_psrav_q_128 :
3004 Intrinsic::x86_avx512_psra_q_128;
3005 else if (Size ==
'w')
3006 IID = IsImmediate ? Intrinsic::x86_sse2_psrai_w
3007 : Intrinsic::x86_sse2_psra_w;
3010 }
else if (Name.endswith(
".256")) {
3012 IID = IsImmediate ? Intrinsic::x86_avx2_psrai_d
3013 : Intrinsic::x86_avx2_psra_d;
3014 else if (Size ==
'q')
3015 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_q_256 :
3016 IsVariable ? Intrinsic::x86_avx512_psrav_q_256 :
3017 Intrinsic::x86_avx512_psra_q_256;
3018 else if (Size ==
'w')
3019 IID = IsImmediate ? Intrinsic::x86_avx2_psrai_w
3020 : Intrinsic::x86_avx2_psra_w;
3025 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_d_512 :
3026 IsVariable ? Intrinsic::x86_avx512_psrav_d_512 :
3027 Intrinsic::x86_avx512_psra_d_512;
3028 else if (Size ==
'q')
3029 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_q_512 :
3030 IsVariable ? Intrinsic::x86_avx512_psrav_q_512 :
3031 Intrinsic::x86_avx512_psra_q_512;
3032 else if (Size ==
'w')
3033 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_w_512
3034 : Intrinsic::x86_avx512_psra_w_512;
3040 }
else if (IsX86 && Name.startswith(
"avx512.mask.move.s")) {
3042 }
else if (IsX86 && Name.startswith(
"avx512.cvtmask2")) {
3044 }
else if (IsX86 && Name.endswith(
".movntdqa")) {
3058 }
else if (IsX86 && (Name.startswith(
"fma.vfmadd.") ||
3059 Name.startswith(
"fma.vfmsub.") ||
3060 Name.startswith(
"fma.vfnmadd.") ||
3061 Name.startswith(
"fma.vfnmsub."))) {
3062 bool NegMul = Name[6] ==
'n';
3063 bool NegAcc = NegMul ? Name[8] ==
's' : Name[7] ==
's';
3064 bool IsScalar = NegMul ? Name[12] ==
's' : Name[11] ==
's';
3075 if (NegMul && !IsScalar)
3077 if (NegMul && IsScalar)
3090 }
else if (IsX86 && Name.startswith(
"fma4.vfmadd.s")) {
3105 }
else if (IsX86 && (Name.startswith(
"avx512.mask.vfmadd.s") ||
3106 Name.startswith(
"avx512.maskz.vfmadd.s") ||
3107 Name.startswith(
"avx512.mask3.vfmadd.s") ||
3108 Name.startswith(
"avx512.mask3.vfmsub.s") ||
3109 Name.startswith(
"avx512.mask3.vfnmsub.s"))) {
3110 bool IsMask3 = Name[11] ==
'3';
3111 bool IsMaskZ = Name[11] ==
'z';
3113 Name = Name.drop_front(IsMask3 || IsMaskZ ? 13 : 12);
3114 bool NegMul = Name[2] ==
'n';
3115 bool NegAcc = NegMul ? Name[4] ==
's' : Name[3] ==
's';
3121 if (NegMul && (IsMask3 || IsMaskZ))
3123 if (NegMul && !(IsMask3 || IsMaskZ))
3133 cast<ConstantInt>(CI->
getArgOperand(4))->getZExtValue() != 4) {
3137 if (Name.back() ==
'd')
3138 IID = Intrinsic::x86_avx512_vfmadd_f64;
3140 IID = Intrinsic::x86_avx512_vfmadd_f32;
3155 if (NegAcc && IsMask3)
3163 }
else if (IsX86 && (Name.startswith(
"avx512.mask.vfmadd.p") ||
3164 Name.startswith(
"avx512.mask.vfnmadd.p") ||
3165 Name.startswith(
"avx512.mask.vfnmsub.p") ||
3166 Name.startswith(
"avx512.mask3.vfmadd.p") ||
3167 Name.startswith(
"avx512.mask3.vfmsub.p") ||
3168 Name.startswith(
"avx512.mask3.vfnmsub.p") ||
3169 Name.startswith(
"avx512.maskz.vfmadd.p"))) {
3170 bool IsMask3 = Name[11] ==
'3';
3171 bool IsMaskZ = Name[11] ==
'z';
3173 Name = Name.drop_front(IsMask3 || IsMaskZ ? 13 : 12);
3174 bool NegMul = Name[2] ==
'n';
3175 bool NegAcc = NegMul ? Name[4] ==
's' : Name[3] ==
's';
3181 if (NegMul && (IsMask3 || IsMaskZ))
3183 if (NegMul && !(IsMask3 || IsMaskZ))
3190 cast<ConstantInt>(CI->
getArgOperand(4))->getZExtValue() != 4)) {
3193 if (Name[Name.size()-5] ==
's')
3194 IID = Intrinsic::x86_avx512_vfmadd_ps_512;
3196 IID = Intrinsic::x86_avx512_vfmadd_pd_512;
3212 }
else if (IsX86 && (Name.startswith(
"fma.vfmaddsub.p") ||
3213 Name.startswith(
"fma.vfmsubadd.p"))) {
3214 bool IsSubAdd = Name[7] ==
's';
3230 for (
int i = 0; i != NumElts; ++i)
3231 Idxs[i] = i + (i % 2) * NumElts;
3234 }
else if (IsX86 && (Name.startswith(
"avx512.mask.vfmaddsub.p") ||
3235 Name.startswith(
"avx512.mask3.vfmaddsub.p") ||
3236 Name.startswith(
"avx512.maskz.vfmaddsub.p") ||
3237 Name.startswith(
"avx512.mask3.vfmsubadd.p"))) {
3238 bool IsMask3 = Name[11] ==
'3';
3239 bool IsMaskZ = Name[11] ==
'z';
3241 Name = Name.drop_front(IsMask3 || IsMaskZ ? 13 : 12);
3242 bool IsSubAdd = Name[3] ==
's';
3245 cast<ConstantInt>(CI->
getArgOperand(4))->getZExtValue() != 4)) {
3248 if (Name[Name.size()-5] ==
's')
3249 IID = Intrinsic::x86_avx512_vfmaddsub_ps_512;
3251 IID = Intrinsic::x86_avx512_vfmaddsub_pd_512;
3277 for (
int i = 0; i != NumElts; ++i)
3278 Idxs[i] = i + (i % 2) * NumElts;
3288 }
else if (IsX86 && (Name.startswith(
"avx512.mask.pternlog.") ||
3289 Name.startswith(
"avx512.maskz.pternlog."))) {
3290 bool ZeroMask = Name[11] ==
'z';
3294 if (VecWidth == 128 && EltWidth == 32)
3295 IID = Intrinsic::x86_avx512_pternlog_d_128;
3296 else if (VecWidth == 256 && EltWidth == 32)
3297 IID = Intrinsic::x86_avx512_pternlog_d_256;
3298 else if (VecWidth == 512 && EltWidth == 32)
3299 IID = Intrinsic::x86_avx512_pternlog_d_512;
3300 else if (VecWidth == 128 && EltWidth == 64)
3301 IID = Intrinsic::x86_avx512_pternlog_q_128;
3302 else if (VecWidth == 256 && EltWidth == 64)
3303 IID = Intrinsic::x86_avx512_pternlog_q_256;
3304 else if (VecWidth == 512 && EltWidth == 64)
3305 IID = Intrinsic::x86_avx512_pternlog_q_512;
3316 }
else if (IsX86 && (Name.startswith(
"avx512.mask.vpmadd52") ||
3317 Name.startswith(
"avx512.maskz.vpmadd52"))) {
3318 bool ZeroMask = Name[11] ==
'z';
3319 bool High = Name[20] ==
'h' || Name[21] ==
'h';
3322 if (VecWidth == 128 && !High)
3323 IID = Intrinsic::x86_avx512_vpmadd52l_uq_128;
3324 else if (VecWidth == 256 && !High)
3325 IID = Intrinsic::x86_avx512_vpmadd52l_uq_256;
3326 else if (VecWidth == 512 && !High)
3327 IID = Intrinsic::x86_avx512_vpmadd52l_uq_512;
3328 else if (VecWidth == 128 && High)
3329 IID = Intrinsic::x86_avx512_vpmadd52h_uq_128;
3330 else if (VecWidth == 256 && High)
3331 IID = Intrinsic::x86_avx512_vpmadd52h_uq_256;
3332 else if (VecWidth == 512 && High)
3333 IID = Intrinsic::x86_avx512_vpmadd52h_uq_512;
3344 }
else if (IsX86 && (Name.startswith(
"avx512.mask.vpermi2var.") ||
3345 Name.startswith(
"avx512.mask.vpermt2var.") ||
3346 Name.startswith(
"avx512.maskz.vpermt2var."))) {
3347 bool ZeroMask = Name[11] ==
'z';
3348 bool IndexForm = Name[17] ==
'i';
3350 }
else if (IsX86 && (Name.startswith(
"avx512.mask.vpdpbusd.") ||
3351 Name.startswith(
"avx512.maskz.vpdpbusd.") ||
3352 Name.startswith(
"avx512.mask.vpdpbusds.") ||
3353 Name.startswith(
"avx512.maskz.vpdpbusds."))) {
3354 bool ZeroMask = Name[11] ==
'z';
3355 bool IsSaturating = Name[ZeroMask ? 21 : 20] ==
's';
3358 if (VecWidth == 128 && !IsSaturating)
3359 IID = Intrinsic::x86_avx512_vpdpbusd_128;
3360 else if (VecWidth == 256 && !IsSaturating)
3361 IID = Intrinsic::x86_avx512_vpdpbusd_256;
3362 else if (VecWidth == 512 && !IsSaturating)
3363 IID = Intrinsic::x86_avx512_vpdpbusd_512;
3364 else if (VecWidth == 128 && IsSaturating)
3365 IID = Intrinsic::x86_avx512_vpdpbusds_128;
3366 else if (VecWidth == 256 && IsSaturating)
3367 IID = Intrinsic::x86_avx512_vpdpbusds_256;
3368 else if (VecWidth == 512 && IsSaturating)
3369 IID = Intrinsic::x86_avx512_vpdpbusds_512;
3380 }
else if (IsX86 && (Name.startswith(
"avx512.mask.vpdpwssd.") ||
3381 Name.startswith(
"avx512.maskz.vpdpwssd.") ||
3382 Name.startswith(
"avx512.mask.vpdpwssds.") ||
3383 Name.startswith(
"avx512.maskz.vpdpwssds."))) {
3384 bool ZeroMask = Name[11] ==
'z';
3385 bool IsSaturating = Name[ZeroMask ? 21 : 20] ==
's';
3388 if (VecWidth == 128 && !IsSaturating)
3389 IID = Intrinsic::x86_avx512_vpdpwssd_128;
3390 else if (VecWidth == 256 && !IsSaturating)
3391 IID = Intrinsic::x86_avx512_vpdpwssd_256;
3392 else if (VecWidth == 512 && !IsSaturating)
3393 IID = Intrinsic::x86_avx512_vpdpwssd_512;
3394 else if (VecWidth == 128 && IsSaturating)
3395 IID = Intrinsic::x86_avx512_vpdpwssds_128;
3396 else if (VecWidth == 256 && IsSaturating)
3397 IID = Intrinsic::x86_avx512_vpdpwssds_256;
3398 else if (VecWidth == 512 && IsSaturating)
3399 IID = Intrinsic::x86_avx512_vpdpwssds_512;
3410 }
else if (IsX86 && (Name ==
"addcarryx.u32" || Name ==
"addcarryx.u64" ||
3411 Name ==
"addcarry.u32" || Name ==
"addcarry.u64" ||
3412 Name ==
"subborrow.u32" || Name ==
"subborrow.u64")) {
3414 if (Name[0] ==
'a' && Name.back() ==
'2')
3415 IID = Intrinsic::x86_addcarry_32;
3416 else if (Name[0] ==
'a' && Name.back() ==
'4')
3417 IID = Intrinsic::x86_addcarry_64;
3418 else if (Name[0] ==
's' && Name.back() ==
'2')
3419 IID = Intrinsic::x86_subborrow_32;
3420 else if (Name[0] ==
's' && Name.back() ==
'4')
3421 IID = Intrinsic::x86_subborrow_64;
3443 }
else if (IsX86 && Name.startswith(
"avx512.mask.") &&
3446 }
else if (IsNVVM && (Name ==
"abs.i" || Name ==
"abs.ll")) {
3452 }
else if (IsNVVM && (Name.startswith(
"atomic.load.add.f32.p") ||
3453 Name.startswith(
"atomic.load.add.f64.p"))) {
3458 }
else if (IsNVVM && (Name ==
"max.i" || Name ==
"max.ll" ||
3459 Name ==
"max.ui" || Name ==
"max.ull")) {
3462 Value *Cmp = Name.endswith(
".ui") || Name.endswith(
".ull")
3466 }
else if (IsNVVM && (Name ==
"min.i" || Name ==
"min.ll" ||
3467 Name ==
"min.ui" || Name ==
"min.ull")) {
3470 Value *Cmp = Name.endswith(
".ui") || Name.endswith(
".ull")
3474 }
else if (IsNVVM && Name ==
"clz.ll") {
3482 }
else if (IsNVVM && Name ==
"popc.ll") {
3491 }
else if (IsNVVM && Name ==
"h2f") {
3493 F->
getParent(), Intrinsic::convert_from_fp16,
3506 const auto &DefaultCase = [&NewFn, &CI]() ->
void {
3510 "Unknown function for CallInst upgrade and isn't just a name change");
3519 case Intrinsic::experimental_vector_reduce_v2_fmul: {
3527 cast<Instruction>(NewCall)->copyFastMathFlags(CI);
3530 case Intrinsic::experimental_vector_reduce_v2_fadd: {
3538 cast<Instruction>(NewCall)->copyFastMathFlags(CI);
3541 case Intrinsic::arm_neon_vld1:
3542 case Intrinsic::arm_neon_vld2:
3543 case Intrinsic::arm_neon_vld3:
3544 case Intrinsic::arm_neon_vld4:
3545 case Intrinsic::arm_neon_vld2lane:
3546 case Intrinsic::arm_neon_vld3lane:
3547 case Intrinsic::arm_neon_vld4lane:
3548 case Intrinsic::arm_neon_vst1:
3549 case Intrinsic::arm_neon_vst2:
3550 case Intrinsic::arm_neon_vst3:
3551 case Intrinsic::arm_neon_vst4:
3552 case Intrinsic::arm_neon_vst2lane:
3553 case Intrinsic::arm_neon_vst3lane:
3554 case Intrinsic::arm_neon_vst4lane: {
3561 case Intrinsic::bitreverse:
3565 case Intrinsic::ctlz:
3566 case Intrinsic::cttz:
3568 "Mismatch between function args and call args");
3573 case Intrinsic::objectsize: {
3584 case Intrinsic::ctpop:
3588 case Intrinsic::convert_from_fp16:
3592 case Intrinsic::dbg_value:
3597 if (
Offset->isZeroValue()) {
3606 case Intrinsic::x86_xop_vfrcz_ss:
3607 case Intrinsic::x86_xop_vfrcz_sd:
3611 case Intrinsic::x86_xop_vpermil2pd:
3612 case Intrinsic::x86_xop_vpermil2ps:
3613 case Intrinsic::x86_xop_vpermil2pd_256:
3614 case Intrinsic::x86_xop_vpermil2ps_256: {
3624 case Intrinsic::x86_sse41_ptestc:
3625 case Intrinsic::x86_sse41_ptestz:
3626 case Intrinsic::x86_sse41_ptestnzc: {
3643 NewCall = Builder.
CreateCall(NewFn, {BC0, BC1});
3647 case Intrinsic::x86_rdtscp: {
3664 if (!Name.empty()) {
3666 NewCall->setName(Name);
3673 case Intrinsic::x86_sse41_insertps:
3674 case Intrinsic::x86_sse41_dppd:
3675 case Intrinsic::x86_sse41_dpps:
3676 case Intrinsic::x86_sse41_mpsadbw:
3677 case Intrinsic::x86_avx_dp_ps_256:
3678 case Intrinsic::x86_avx2_mpsadbw: {
3690 case Intrinsic::thread_pointer: {
3695 case Intrinsic::invariant_start:
3696 case Intrinsic::invariant_end:
3697 case Intrinsic::masked_load:
3698 case Intrinsic::masked_store:
3699 case Intrinsic::masked_gather:
3700 case Intrinsic::masked_scatter: {
3707 case Intrinsic::memcpy:
3708 case Intrinsic::memmove:
3709 case Intrinsic::memset: {
3726 auto *MemCI = cast<MemIntrinsic>(NewCall);
3729 MemCI->setDestAlignment(Align->getZExtValue());
3731 if (
auto *MTI = dyn_cast<MemTransferInst>(MemCI))
3732 MTI->setSourceAlignment(Align->getZExtValue());
3736 assert(NewCall &&
"Should have either set this variable or returned through " 3737 "the default case");
3739 if (!Name.empty()) {
3748 assert(F &&
"Illegal attempt to upgrade a non-existent intrinsic.");
3757 if (
CallInst *CI = dyn_cast<CallInst>(*UI++))
3775 Metadata *Elts2[] = {ScalarType, ScalarType,
3789 if (Opc != Instruction::BitCast)
3810 if (Opc != Instruction::BitCast)
3834 bool BrokenDebugInfo =
false;
3837 if (!BrokenDebugInfo)
3858 bool Changed =
false;
3859 const char *MarkerKey =
"clang.arc.retainAutoreleasedReturnValueMarker";
3861 if (ModRetainReleaseMarker) {
3868 if (ValueComp.
size() == 2) {
3869 std::string NewValue = ValueComp[0].str() +
";" + ValueComp[1].str();
3884 auto UpgradeToIntrinsic = [&](
const char *OldFunc,
3904 if (NewFuncTy->getReturnType() != CI->
getType() &&
3906 NewFuncTy->getReturnType()))
3909 bool InvalidCast =
false;
3916 if (I < NewFuncTy->getNumParams()) {
3920 NewFuncTy->getParamType(
I))) {
3924 Arg = Builder.CreateBitCast(Arg, NewFuncTy->getParamType(
I));
3933 CallInst *NewCall = Builder.CreateCall(NewFuncTy, NewFn, Args);
3938 Value *NewRetVal = Builder.CreateBitCast(NewCall, CI->
getType());
3951 UpgradeToIntrinsic(
"clang.arc.use", llvm::Intrinsic::objc_clang_arc_use);
3959 std::pair<const char *, llvm::Intrinsic::ID> RuntimeFuncs[] = {
3960 {
"objc_autorelease", llvm::Intrinsic::objc_autorelease},
3961 {
"objc_autoreleasePoolPop", llvm::Intrinsic::objc_autoreleasePoolPop},
3962 {
"objc_autoreleasePoolPush", llvm::Intrinsic::objc_autoreleasePoolPush},
3963 {
"objc_autoreleaseReturnValue",
3964 llvm::Intrinsic::objc_autoreleaseReturnValue},
3965 {
"objc_copyWeak", llvm::Intrinsic::objc_copyWeak},
3966 {
"objc_destroyWeak", llvm::Intrinsic::objc_destroyWeak},
3967 {
"objc_initWeak", llvm::Intrinsic::objc_initWeak},
3968 {
"objc_loadWeak", llvm::Intrinsic::objc_loadWeak},
3969 {
"objc_loadWeakRetained", llvm::Intrinsic::objc_loadWeakRetained},
3970 {
"objc_moveWeak", llvm::Intrinsic::objc_moveWeak},
3971 {
"objc_release", llvm::Intrinsic::objc_release},
3972 {
"objc_retain", llvm::Intrinsic::objc_retain},
3973 {
"objc_retainAutorelease", llvm::Intrinsic::objc_retainAutorelease},
3974 {
"objc_retainAutoreleaseReturnValue",
3975 llvm::Intrinsic::objc_retainAutoreleaseReturnValue},
3976 {
"objc_retainAutoreleasedReturnValue",
3977 llvm::Intrinsic::objc_retainAutoreleasedReturnValue},
3978 {
"objc_retainBlock", llvm::Intrinsic::objc_retainBlock},
3979 {
"objc_storeStrong", llvm::Intrinsic::objc_storeStrong},
3980 {
"objc_storeWeak", llvm::Intrinsic::objc_storeWeak},
3981 {
"objc_unsafeClaimAutoreleasedReturnValue",
3982 llvm::Intrinsic::objc_unsafeClaimAutoreleasedReturnValue},
3983 {
"objc_retainedObject", llvm::Intrinsic::objc_retainedObject},
3984 {
"objc_unretainedObject", llvm::Intrinsic::objc_unretainedObject},
3985 {
"objc_unretainedPointer", llvm::Intrinsic::objc_unretainedPointer},
3986 {
"objc_retain_autorelease", llvm::Intrinsic::objc_retain_autorelease},
3987 {
"objc_sync_enter", llvm::Intrinsic::objc_sync_enter},
3988 {
"objc_sync_exit", llvm::Intrinsic::objc_sync_exit},
3989 {
"objc_arc_annotation_topdown_bbstart",
3990 llvm::Intrinsic::objc_arc_annotation_topdown_bbstart},
3991 {
"objc_arc_annotation_topdown_bbend",
3992 llvm::Intrinsic::objc_arc_annotation_topdown_bbend},
3993 {
"objc_arc_annotation_bottomup_bbstart",
3994 llvm::Intrinsic::objc_arc_annotation_bottomup_bbstart},
3995 {
"objc_arc_annotation_bottomup_bbend",
3996 llvm::Intrinsic::objc_arc_annotation_bottomup_bbend}};
3998 for (
auto &
I : RuntimeFuncs)
3999 UpgradeToIntrinsic(
I.first,
I.second);
4007 bool HasObjCFlag =
false, HasClassProperties =
false, Changed =
false;
4015 if (ID->
getString() ==
"Objective-C Image Info Version")
4017 if (ID->
getString() ==
"Objective-C Class Properties")
4018 HasClassProperties =
true;
4022 if (
auto *Behavior =
4023 mdconst::dyn_extract_or_null<ConstantInt>(Op->
getOperand(0))) {
4038 if (ID->
getString() ==
"Objective-C Image Info Section") {
4041 Value->getString().split(ValueComp,
" ");
4042 if (ValueComp.
size() != 1) {
4043 std::string NewValue;
4044 for (
auto &S : ValueComp)
4045 NewValue += S.str();
4060 if (HasObjCFlag && !HasClassProperties) {
4072 Section.split(Components,
',');
4077 for (
auto Component : Components)
4078 OS <<
',' << Component.trim();
4083 for (
auto &GV : M.
globals()) {
4084 if (!GV.hasSection())
4089 if (!Section.
startswith(
"__DATA, __objc_catlist"))
4094 GV.setSection(TrimSpaces(Section));
4099 auto *
T = dyn_cast_or_null<MDTuple>(MD);
4102 if (
T->getNumOperands() < 1)
4104 auto *S = dyn_cast_or_null<MDString>(
T->getOperand(0));
4107 return S->getString().startswith(
"llvm.vectorizer.");
4111 StringRef OldPrefix =
"llvm.vectorizer.";
4114 if (OldTag ==
"llvm.vectorizer.unroll")
4123 auto *
T = dyn_cast_or_null<MDTuple>(MD);
4126 if (
T->getNumOperands() < 1)
4128 auto *OldTag = dyn_cast_or_null<MDString>(
T->getOperand(0));
4131 if (!OldTag->getString().startswith(
"llvm.vectorizer."))
4138 for (
unsigned I = 1,
E =
T->getNumOperands();
I !=
E; ++
I)
4161 std::string AddrSpaces =
"-p270:32:32-p271:32:32-p272:64:64";
4169 Regex R(
"(e-m:[a-z](-p:32:32)?)(-[if]64:.*$)");
4170 if (!R.
match(DL, &Groups))
4174 std::string Res = (Groups[1] + AddrSpaces + Groups[3]).
toStringRef(Buf).
str();
4180 if (B.
contains(
"no-frame-pointer-elim")) {
4183 if (
I.first ==
"no-frame-pointer-elim")
4184 FramePointer =
I.second ==
"true" ?
"all" :
"none";
4187 if (B.
contains(
"no-frame-pointer-elim-non-leaf")) {
4189 if (FramePointer !=
"all")
4190 FramePointer =
"non-leaf";
4194 if (!FramePointer.
empty())
IntegerType * getInt16Ty()
Fetch the type representing a 16-bit integer.
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
Type * getVectorElementType() const
static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn)
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
Value * CreateICmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="")
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata *> MDs)
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
static IntegerType * getInt1Ty(LLVMContext &C)
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
Value * CreateIsNotNull(Value *Arg, const Twine &Name="")
Return an i1 value testing if Arg is not null.
void UpgradeSectionAttributes(Module &M)
Takes the max of the two values, which are required to be integers.
MDNode * getOperand(unsigned i) const
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
Type * getParamType(unsigned i) const
Parameter type accessors.
Type * getElementType(unsigned N) const
static Value * UpgradeX86VPERMT2Intrinsics(IRBuilder<> &Builder, CallInst &CI, bool ZeroMask, bool IndexForm)
LoadInst * CreateLoad(Type *Ty, Value *Ptr, const char *Name)
Provided to resolve 'CreateLoad(Ty, Ptr, "...")' correctly, instead of converting the string to 'bool...
Value * CreateXor(Value *LHS, Value *RHS, const Twine &Name="")
A Module instance is used to store all the information related to an LLVM module. ...
LoadInst * CreateAlignedLoad(Type *Ty, Value *Ptr, unsigned Align, const char *Name)
Provided to resolve 'CreateAlignedLoad(Ptr, Align, "...")' correctly, instead of converting the strin...
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
static MDString * get(LLVMContext &Context, StringRef Str)
LLVM_NODISCARD bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
unsigned getNumElements() const
Random access to the elements.
void push_back(const T &Elt)
static Value * upgradeAbs(IRBuilder<> &Builder, CallInst &CI)
static ConstantAggregateZero * get(Type *Ty)
static Value * ApplyX86MaskOn1BitsVec(IRBuilder<> &Builder, Value *Vec, Value *Mask)
static Value * upgradeX86ConcatShift(IRBuilder<> &Builder, CallInst &CI, bool IsShiftRight, bool ZeroMask)
This class represents a function call, abstracting a target machine's calling convention.
void UpgradeARCRuntime(Module &M)
Convert calls to ARC runtime functions to intrinsic calls and upgrade the old retain release marker t...
static Constant * getIntToPtr(Constant *C, Type *Ty, bool OnlyIfReduced=false)
void UpgradeInlineAsmString(std::string *AsmStr)
Upgrade comment in call to inline asm that represents an objc retain release marker.
unsigned getDebugMetadataVersionFromModule(const Module &M)
Return Debug Info Metadata Version by checking module flags.
LLVMContext & getContext() const
All values hold a context through their type.
A raw_ostream that writes to an SmallVector or SmallString.
Value * CreateSExt(Value *V, Type *DestTy, const Twine &Name="")
StringSwitch & StartsWith(StringLiteral S, T Value)
const MDOperand & getOperand(unsigned I) const
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
An instruction for reading from memory.
static IntegerType * getInt64Ty(LLVMContext &C)
AttrBuilder & addAttribute(Attribute::AttrKind Val)
Add an attribute to the builder.
Value * CreateICmpULE(Value *LHS, Value *RHS, const Twine &Name="")
void reserve(size_type N)
void UpgradeIntrinsicCall(CallInst *CI, Function *NewFn)
This is the complement to the above, replacing a specific call to an intrinsic function with a call t...
static Value * EmitX86Select(IRBuilder<> &Builder, Value *Mask, Value *Op0, Value *Op1)
void setOperand(unsigned I, MDNode *New)
static Value * upgradeIntMinMax(IRBuilder<> &Builder, CallInst &CI, ICmpInst::Predicate Pred)
StringSwitch & Case(StringLiteral S, T Value)
static Constant * get(ArrayType *T, ArrayRef< Constant *> V)
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
Value * CreateNot(Value *V, const Twine &Name="")
StoreInst * CreateAlignedStore(Value *Val, Value *Ptr, unsigned Align, bool isVolatile=false)
IntegerType * getInt32Ty()
Fetch the type representing a 32-bit integer.
Value * getArgOperand(unsigned i) const
unsigned getBitWidth() const
Return the minimum number of bits in the Vector type.
static bool castIsValid(Instruction::CastOps op, Value *S, Type *DstTy)
This method can be used to determine if a cast from S to DstTy using Opcode op is valid or not...
static Value * UpgradeX86PSRLDQIntrinsics(IRBuilder<> &Builder, Value *Op, unsigned Shift)
Value * CreateFPExt(Value *V, Type *DestTy, const Twine &Name="")
MDNode * upgradeInstructionLoopAttachment(MDNode &N)
Upgrade the loop attachment metadata node.
StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void UpgradeCallsToIntrinsic(Function *F)
This is an auto-upgrade hook for any old intrinsic function syntaxes which need to have both the func...
static Type * getFloatTy(LLVMContext &C)
void eraseNamedMetadata(NamedMDNode *NMD)
Remove the given NamedMDNode from this module and delete it.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
bool isFloatingPointTy() const
Return true if this is one of the six floating-point types.
LLVM_NODISCARD StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
Class to represent struct types.
LLVMContext & getContext() const
Get the global data context.
static bool ShouldUpgradeX86Intrinsic(Function *F, StringRef Name)
PointerType * getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
bool isIntegerTy() const
True if this is an instance of IntegerType.
LLVM_NODISCARD R Default(T Value)
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly...
unsigned getNumOperands() const
Value * CreateAdd(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
static Value * UpgradeMaskToInt(IRBuilder<> &Builder, CallInst &CI)
void setName(const Twine &Name)
Change the name of the value.
LLVM_NODISCARD StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
uint64_t getNumElements() const
For scalable vectors, this will return the minimum number of elements in the vector.
static Metadata * upgradeLoopArgument(Metadata *MD)
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
static StructType * get(LLVMContext &Context, ArrayRef< Type *> Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
AttributeList getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
llvm::Optional< Function * > remangleIntrinsicFunction(Function *F)
Class to represent function types.
Value * CreateBitCast(Value *V, Type *DestTy, const Twine &Name="")
bool match(StringRef String, SmallVectorImpl< StringRef > *Matches=nullptr, std::string *Error=nullptr) const
matches - Match the regex against a given String.
Type * getType() const
All values are typed, get the type of this value.
void setCalledFunction(Function *Fn)
Sets the function called, including updating the function type.
LLVMContext & getContext() const
Class to represent array types.
bool StripDebugInfo(Module &M)
Strip debug info in the module if it exists.
NamedMDNode * getNamedMetadata(const Twine &Name) const
Return the first NamedMDNode in the module with the specified name.
static Value * EmitX86ScalarSelect(IRBuilder<> &Builder, Value *Mask, Value *Op0, Value *Op1)
Value * CreateVectorSplat(unsigned NumElts, Value *V, const Twine &Name="")
Return a vector value that contains.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
LLVM_NODISCARD size_t size() const
size - Get the string size.
bool UpgradeIntrinsicFunction(Function *F, Function *&NewFn)
This is a more granular function that simply checks an intrinsic function for upgrading, and returns true if it requires upgrading.
iterator_range< User::op_iterator > arg_operands()
Value * CreateSub(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Value * CreateSIToFP(Value *V, Type *DestTy, const Twine &Name="")
An instruction for storing to memory.
LinkageTypes getLinkage() const
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Value * CreateZExt(Value *V, Type *DestTy, const Twine &Name="")
Function * getDeclaration(Module *M, ID id, ArrayRef< Type *> Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
static Value * UpgradeMaskedLoad(IRBuilder<> &Builder, Value *Ptr, Value *Passthru, Value *Mask, bool Aligned)
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block...
Value * getOperand(unsigned i) const
Class to represent pointers.
static Value * UpgradeX86PSLLDQIntrinsics(IRBuilder<> &Builder, Value *Op, unsigned Shift)
Value * CreateOr(Value *LHS, Value *RHS, const Twine &Name="")
bool UpgradeModuleFlags(Module &M)
This checks for module flags which should be upgraded.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
StringRef getString() const
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
static Value * UpgradeMaskedStore(IRBuilder<> &Builder, Value *Ptr, Value *Data, Value *Mask, bool Aligned)
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata *> MDs)
A switch()-like statement whose cases are string literals.
Type * getReturnType() const
Returns the type of the ret val.
void getModuleFlagsMetadata(SmallVectorImpl< ModuleFlagEntry > &Flags) const
Returns the module flags in the provided vector.
StringSwitch & Cases(StringLiteral S0, StringLiteral S1, T Value)
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
Emits an error if two values disagree, otherwise the resulting value is that of the operands...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Value * CreateFMul(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
Value * CreateAShr(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
ConstantInt * getInt1(bool V)
Get a constant value representing either true or false.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Value * CreateSelect(Value *C, Value *True, Value *False, const Twine &Name="", Instruction *MDFrom=nullptr)
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
bool UpgradeDebugInfo(Module &M)
Check the debug info version number, if it is out-dated, drop the debug info.
LLVM_NODISCARD size_t find(char C, size_t From=0) const
Search for the first character C in the string.
ArrayRef< Type * > params() const
GlobalVariable * UpgradeGlobalVariable(GlobalVariable *GV)
This checks for global variables which should be upgraded.
static VectorType * getInteger(VectorType *VTy)
This static method gets a VectorType with the same number of elements as the input type...
bool isFast() const
Determine whether all fast-math-flags are set.
void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, Metadata *Val)
Add a module-level flag to the module-level flags metadata.
Value * CreateNeg(Value *V, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
static bool UpgradeX86IntrinsicsWith8BitMask(Function *F, Intrinsic::ID IID, Function *&NewFn)
unsigned getAddressSpace() const
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
std::string UpgradeDataLayoutString(StringRef DL, StringRef Triple)
Upgrade the datalayout string by adding a section for address space pointers.
Value * CreateICmpSGE(Value *LHS, Value *RHS, const Twine &Name="")
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
static FunctionType * get(Type *Result, ArrayRef< Type *> Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
static Constant * get(StructType *T, ArrayRef< Constant *> V)
Value * CreateICmpEQ(Value *LHS, Value *RHS, const Twine &Name="")
self_iterator getIterator()
LLVM_NODISCARD bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
IntegerType * getIntNTy(unsigned N)
Fetch the type representing an N-bit integer.
Value * CreateExtractElement(Value *Vec, Value *Idx, const Twine &Name="")
static Value * UpgradeX86AddSubSatIntrinsics(IRBuilder<> &Builder, CallInst &CI, bool IsSigned, bool IsAddition)
void setTailCallKind(TailCallKind TCK)
static Constant * getAllOnesValue(Type *Ty)
AtomicRMWInst * CreateAtomicRMW(AtomicRMWInst::BinOp Op, Value *Ptr, Value *Val, AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System)
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
StringRef toStringRef(bool B)
Construct a string ref from a boolean.
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
static Value * upgradeX86vpcom(IRBuilder<> &Builder, CallInst &CI, unsigned Imm, bool IsSigned)
Value * CreateExtractValue(Value *Agg, ArrayRef< unsigned > Idxs, const Twine &Name="")
PointerType * getInt8PtrTy(unsigned AddrSpace=0)
Fetch the type representing a pointer to an 8-bit integer value.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
Value * CreateMul(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Value * CreateTrunc(Value *V, Type *DestTy, const Twine &Name="")
This struct is a compact representation of a valid (non-zero power of two) alignment.
static bool UpgradeX86IntrinsicFunction(Function *F, StringRef Name, Function *&NewFn)
Triple - Helper class for working with autoconf configuration names.
Value * CreateUIToFP(Value *V, Type *DestTy, const Twine &Name="")
static Value * getX86MaskVec(IRBuilder<> &Builder, Value *Mask, unsigned NumElts)
static const X86InstrFMA3Group Groups[]
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
static Value * UpgradeX86ALIGNIntrinsics(IRBuilder<> &Builder, Value *Op0, Value *Op1, Value *Shift, Value *Passthru, Value *Mask, bool IsVALIGN)
Instruction * UpgradeBitCastInst(unsigned Opc, Value *V, Type *DestTy, Instruction *&Temp)
This is an auto-upgrade for bitcast between pointers with different address spaces: the instruction i...
static bool upgradeAVX512MaskToSelect(StringRef Name, IRBuilder<> &Builder, CallInst &CI, Value *&Rep)
unsigned getNumOperands() const
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the generic address space (address sp...
This is the shared class of boolean and integer constants.
Align max(MaybeAlign Lhs, Align Rhs)
bool contains(Attribute::AttrKind A) const
Return true if the builder has the specified attribute.
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type...
AttrBuilder & removeAttribute(Attribute::AttrKind Val)
Remove an attribute from the builder.
Value * CreateIntCast(Value *V, Type *DestTy, bool isSigned, const Twine &Name="")
Value * CreateICmpUGE(Value *LHS, Value *RHS, const Twine &Name="")
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
static MDString * upgradeLoopTag(LLVMContext &C, StringRef OldTag)
static bool UpgradeRetainReleaseMarker(Module &M)
This checks for objc retain release marker which should be upgraded.
Module.h This file contains the declarations for the Module class.
Value * CreateInsertElement(Value *Vec, Value *NewElt, Value *Idx, const Twine &Name="")
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Type * getReturnType() const
CallInst * CreateMaskedStore(Value *Val, Value *Ptr, unsigned Align, Value *Mask)
Create a call to Masked Store intrinsic.
Value * CreateShuffleVector(Value *V1, Value *V2, Value *Mask, const Twine &Name="")
StringRef str()
Return a StringRef for the vector contents.
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
static Constant * get(Type *Ty, double V)
This returns a ConstantFP, or a vector containing a splat of a ConstantFP, for the specified value in...
CallInst * CreateMaskedLoad(Value *Ptr, unsigned Align, Value *Mask, Value *PassThru=nullptr, const Twine &Name="")
Create a call to Masked Load intrinsic.
static Value * UpgradeX86MaskedShift(IRBuilder<> &Builder, CallInst &CI, Intrinsic::ID IID)
void setAttributes(AttributeList Attrs)
Set the attribute list for this Function.
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
Uses the specified value, regardless of the behavior or value of the other module.
Function * getFunction(StringRef Name) const
Look up the specified function in the module symbol table.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
unsigned getVectorNumElements() const
FunctionType * getFunctionType() const
Returns the FunctionType for me.
MDNode * UpgradeTBAANode(MDNode &TBAANode)
If the given TBAA tag uses the scalar TBAA format, create a new node corresponding to the upgrade to ...
Class to represent vector types.
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
Class for arbitrary precision integers.
IntegerType * getInt8Ty()
Fetch the type representing an 8-bit integer.
Value * CreateShl(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Value * CreatePointerCast(Value *V, Type *DestTy, const Twine &Name="")
void UpgradeFramePointerAttributes(AttrBuilder &B)
Upgrade function attributes "no-frame-pointer-elim" and "no-frame-pointer-elim-non-leaf" to "frame-po...
bool verifyModule(const Module &M, raw_ostream *OS=nullptr, bool *BrokenDebugInfo=nullptr)
Check a module for errors.
ConstantInt * getFalse()
Get the constant value for i1 false.
IntegerType * getInt1Ty()
Fetch the type representing a single bit.
static CastInst * Create(Instruction::CastOps, Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Provides a way to construct any of the CastInst subclasses using an opcode instead of the subclass's ...
unsigned getNumArgOperands() const
static bool isOldLoopArgument(Metadata *MD)
static IntegerType * getInt32Ty(LLVMContext &C)
unsigned getIntegerBitWidth() const
unsigned greater or equal
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
StringRef getName() const
Return a constant reference to the value's name.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation.
static Constant * getPtrToInt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Value * CreateFSub(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static Value * upgradeMaskedMove(IRBuilder<> &Builder, CallInst &CI)
static void rename(GlobalValue *GV)
static ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
static Value * upgradeMaskedCompare(IRBuilder<> &Builder, CallInst &CI, unsigned CC, bool Signed)
Type * getValueType() const
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value *> Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it...
Type * getFloatTy()
Fetch the type representing a 32-bit floating point value.
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
Value * CreateFAdd(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
Value * CreateAnd(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateFDiv(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
static bool UpgradePTESTIntrinsic(Function *F, Intrinsic::ID IID, Function *&NewFn)
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
unsigned getMDKindID(StringRef Name) const
Return a unique non-zero ID for the specified metadata kind.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
user_iterator user_begin()
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
FMA - Perform a * b + c with no intermediate rounding step.
bool hasInitializer() const
Definitions have initializers, declarations don't.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
Type * getElementType() const
ConstantInt * getInt8(uint8_t C)
Get a constant 8-bit value.
iterator_range< global_iterator > globals()
StringRef - Represent a constant reference to a string, i.e.
static Value * upgradePMULDQ(IRBuilder<> &Builder, CallInst &CI, bool IsSigned)
Value * UpgradeBitCastExpr(unsigned Opc, Constant *C, Type *DestTy)
This is an auto-upgrade for bitcast constant expression between pointers with different address space...
unsigned getNumOperands() const
Return number of MDNode operands.
Value * CreateICmpSLE(Value *LHS, Value *RHS, const Twine &Name="")
static IntegerType * getInt8Ty(LLVMContext &C)
static Value * upgradeX86Rotate(IRBuilder<> &Builder, CallInst &CI, bool IsRotateRight)
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Value * CreateFNeg(Value *V, const Twine &Name="", MDNode *FPMathTag=nullptr)
const BasicBlock * getParent() const