69 assert(F &&
"Illegal to upgrade a non-existent Function.");
103 Regex vldRegex(
"^arm\\.neon\\.vld([1234]|[234]lane)\\.v[a-z0-9]*$");
104 if (vldRegex.
match(Name)) {
111 "llvm." + Name +
".p0i8", F->
getParent());
114 Regex vstRegex(
"^arm\\.neon\\.vst([1234]|[234]lane)\\.v[a-z0-9]*$");
115 if (vstRegex.
match(Name)) {
116 static const Intrinsic::ID StoreInts[] = {Intrinsic::arm_neon_vst1,
117 Intrinsic::arm_neon_vst2,
118 Intrinsic::arm_neon_vst3,
119 Intrinsic::arm_neon_vst4};
122 Intrinsic::arm_neon_vst2lane, Intrinsic::arm_neon_vst3lane,
123 Intrinsic::arm_neon_vst4lane
127 Type *Tys[] = {fArgs[0], fArgs[1]};
130 StoreInts[fArgs.size() - 3], Tys);
133 StoreLaneInts[fArgs.size() - 5], Tys);
136 if (Name ==
"aarch64.thread.pointer" || Name ==
"arm.thread.pointer") {
166 F->
getParent(), Intrinsic::invariant_start, ObjectPtr);
177 Intrinsic::invariant_end, ObjectPtr);
189 Intrinsic::masked_load,
200 Intrinsic::masked_store,
216 Intrinsic::objectsize, Tys);
223 if (Name ==
"stackprotectorcheck") {
246 Name ==
"sse.add.ss" ||
247 Name ==
"sse2.add.sd" ||
248 Name ==
"sse.sub.ss" ||
249 Name ==
"sse2.sub.sd" ||
250 Name ==
"sse.mul.ss" ||
251 Name ==
"sse2.mul.sd" ||
252 Name ==
"sse.div.ss" ||
253 Name ==
"sse2.div.sd" ||
254 Name ==
"sse41.pmaxsb" ||
255 Name ==
"sse2.pmaxs.w" ||
256 Name ==
"sse41.pmaxsd" ||
257 Name ==
"sse2.pmaxu.b" ||
258 Name ==
"sse41.pmaxuw" ||
259 Name ==
"sse41.pmaxud" ||
260 Name ==
"sse41.pminsb" ||
261 Name ==
"sse2.pmins.w" ||
262 Name ==
"sse41.pminsd" ||
263 Name ==
"sse2.pminu.b" ||
264 Name ==
"sse41.pminuw" ||
265 Name ==
"sse41.pminud" ||
306 Name ==
"avx512.mask.add.pd.128" ||
307 Name ==
"avx512.mask.add.pd.256" ||
308 Name ==
"avx512.mask.add.ps.128" ||
309 Name ==
"avx512.mask.add.ps.256" ||
310 Name ==
"avx512.mask.div.pd.128" ||
311 Name ==
"avx512.mask.div.pd.256" ||
312 Name ==
"avx512.mask.div.ps.128" ||
313 Name ==
"avx512.mask.div.ps.256" ||
314 Name ==
"avx512.mask.mul.pd.128" ||
315 Name ==
"avx512.mask.mul.pd.256" ||
316 Name ==
"avx512.mask.mul.ps.128" ||
317 Name ==
"avx512.mask.mul.ps.256" ||
318 Name ==
"avx512.mask.sub.pd.128" ||
319 Name ==
"avx512.mask.sub.pd.256" ||
320 Name ==
"avx512.mask.sub.ps.128" ||
321 Name ==
"avx512.mask.sub.ps.256" ||
344 Name ==
"sse2.cvtdq2pd" ||
345 Name ==
"sse2.cvtps2pd" ||
346 Name ==
"avx.cvtdq2.pd.256" ||
347 Name ==
"avx.cvt.ps2.pd.256" ||
349 Name ==
"avx2.vinserti128" ||
352 Name ==
"avx2.vextracti128" ||
357 Name ==
"sse2.storel.dq" ||
369 Name ==
"sse42.crc32.64.8" ||
379 Name ==
"sse41.pblendw" ||
382 Name ==
"avx2.pblendw" ||
385 Name ==
"avx2.vbroadcasti128" ||
386 Name ==
"xop.vpcmov" ||
394 if (IsX86 && Name.
startswith(
"sse41.ptest")) {
395 if (Name.
substr(11) ==
"c")
397 if (Name.
substr(11) ==
"z")
399 if (Name.
substr(11) ==
"nzc")
404 if (IsX86 && Name ==
"sse41.insertps")
407 if (IsX86 && Name ==
"sse41.dppd")
410 if (IsX86 && Name ==
"sse41.dpps")
413 if (IsX86 && Name ==
"sse41.mpsadbw")
416 if (IsX86 && Name ==
"avx.dp.ps.256")
419 if (IsX86 && Name ==
"avx2.mpsadbw")
427 Intrinsic::x86_xop_vfrcz_ss);
433 Intrinsic::x86_xop_vfrcz_sd);
437 if (IsX86 && Name.
startswith(
"xop.vpermil2")) {
439 auto Idx = Params[2];
440 if (Idx->getScalarType()->isFloatingPointTy()) {
442 unsigned IdxSize = Idx->getPrimitiveSizeInBits();
443 unsigned EltSize = Idx->getScalarSizeInBits();
445 if (EltSize == 64 && IdxSize == 128)
446 Permil2ID = Intrinsic::x86_xop_vpermil2pd;
447 else if (EltSize == 32 && IdxSize == 128)
448 Permil2ID = Intrinsic::x86_xop_vpermil2ps;
449 else if (EltSize == 64 && IdxSize == 256)
450 Permil2ID = Intrinsic::x86_xop_vpermil2pd_256;
452 Permil2ID = Intrinsic::x86_xop_vpermil2ps_256;
471 assert(F != NewFn &&
"Intrinsic function upgraded to the same function");
505 for (
unsigned l = 0; l != NumElts; l += 16)
506 for (
unsigned i = 0;
i != 16; ++
i) {
507 unsigned Idx = NumElts +
i - Shift;
510 Idxs[l +
i] = Idx + l;
539 for (
unsigned l = 0; l != NumElts; l += 16)
540 for (
unsigned i = 0;
i != 16; ++
i) {
541 unsigned Idx =
i + Shift;
544 Idxs[l +
i] = Idx + l;
564 for (
unsigned i = 0;
i != NumElts; ++
i)
577 if (
const auto *
C = dyn_cast<Constant>(Mask))
578 if (
C->isAllOnesValue())
592 unsigned ShiftVal = cast<llvm::ConstantInt>(Shift)->getZExtValue();
595 assert((IsVALIGN || NumElts % 16 == 0) &&
"Illegal NumElts for PALIGNR!");
596 assert((!IsVALIGN || NumElts <= 16) &&
"NumElts too large for VALIGN!");
601 ShiftVal &= (NumElts - 1);
618 for (
unsigned l = 0; l < NumElts; l += 16) {
619 for (
unsigned i = 0;
i != 16; ++
i) {
620 unsigned Idx = ShiftVal +
i;
621 if (!IsVALIGN && Idx >= 16)
623 Indices[l +
i] = Idx + l;
644 if (
const auto *
C = dyn_cast<Constant>(Mask))
645 if (
C->isAllOnesValue())
664 if (
const auto *
C = dyn_cast<Constant>(Mask))
665 if (
C->isAllOnesValue())
695 if (!
C || !
C->isAllOnesValue())
700 for (
unsigned i = 0;
i != NumElts; ++
i)
702 for (
unsigned i = NumElts;
i != 8; ++
i)
703 Indices[
i] = NumElts +
i % NumElts;
709 std::max(NumElts, 8U)));
744 assert(F &&
"Intrinsic call is not direct?");
755 Name = Name.substr(4);
757 if (IsX86 && Name.startswith(
"sse4a.movnt.")) {
769 Type *SrcEltTy = cast<VectorType>(Arg1->
getType())->getElementType();
783 if (IsX86 && (Name.startswith(
"avx.movnt.") ||
784 Name.startswith(
"avx512.storent."))) {
808 if (IsX86 && Name ==
"sse2.storel.dq") {
825 if (IsX86 && (Name.startswith(
"sse.storeu.") ||
826 Name.startswith(
"sse2.storeu.") ||
827 Name.startswith(
"avx.storeu."))) {
841 if (IsX86 && (Name.startswith(
"avx512.mask.storeu."))) {
850 if (IsX86 && (Name.startswith(
"avx512.mask.store."))) {
861 if (IsX86 && (Name.startswith(
"sse2.pcmpeq.") ||
862 Name.startswith(
"avx2.pcmpeq."))) {
866 }
else if (IsX86 && (Name.startswith(
"sse2.pcmpgt.") ||
867 Name.startswith(
"avx2.pcmpgt."))) {
871 }
else if (IsX86 && (Name ==
"sse.add.ss" || Name ==
"sse2.add.sd")) {
880 }
else if (IsX86 && (Name ==
"sse.sub.ss" || Name ==
"sse2.sub.sd")) {
889 }
else if (IsX86 && (Name ==
"sse.mul.ss" || Name ==
"sse2.mul.sd")) {
898 }
else if (IsX86 && (Name ==
"sse.div.ss" || Name ==
"sse2.div.sd")) {
907 }
else if (IsX86 && Name.startswith(
"avx512.mask.pcmpeq.")) {
909 }
else if (IsX86 && Name.startswith(
"avx512.mask.pcmpgt.")) {
911 }
else if (IsX86 && (Name ==
"sse41.pmaxsb" ||
912 Name ==
"sse2.pmaxs.w" ||
913 Name ==
"sse41.pmaxsd" ||
914 Name.startswith(
"avx2.pmaxs") ||
915 Name.startswith(
"avx512.mask.pmaxs"))) {
917 }
else if (IsX86 && (Name ==
"sse2.pmaxu.b" ||
918 Name ==
"sse41.pmaxuw" ||
919 Name ==
"sse41.pmaxud" ||
920 Name.startswith(
"avx2.pmaxu") ||
921 Name.startswith(
"avx512.mask.pmaxu"))) {
923 }
else if (IsX86 && (Name ==
"sse41.pminsb" ||
924 Name ==
"sse2.pmins.w" ||
925 Name ==
"sse41.pminsd" ||
926 Name.startswith(
"avx2.pmins") ||
927 Name.startswith(
"avx512.mask.pmins"))) {
929 }
else if (IsX86 && (Name ==
"sse2.pminu.b" ||
930 Name ==
"sse41.pminuw" ||
931 Name ==
"sse41.pminud" ||
932 Name.startswith(
"avx2.pminu") ||
933 Name.startswith(
"avx512.mask.pminu"))) {
935 }
else if (IsX86 && (Name ==
"sse2.cvtdq2pd" ||
936 Name ==
"sse2.cvtps2pd" ||
937 Name ==
"avx.cvtdq2.pd.256" ||
938 Name ==
"avx.cvt.ps2.pd.256" ||
939 Name.startswith(
"avx512.mask.cvtdq2pd.") ||
940 Name.startswith(
"avx512.mask.cvtudq2pd."))) {
948 unsigned NumDstElts = DstTy->getNumElements();
949 if (NumDstElts < SrcTy->getNumElements()) {
950 assert(NumDstElts == 2 &&
"Unexpected vector size");
960 else if (UInt2Double)
968 }
else if (IsX86 && (Name.startswith(
"avx512.mask.loadu."))) {
972 }
else if (IsX86 && (Name.startswith(
"avx512.mask.load."))) {
976 }
else if (IsX86 && Name.startswith(
"xop.vpcom")) {
978 if (Name.endswith(
"ub"))
979 intID = Intrinsic::x86_xop_vpcomub;
980 else if (Name.endswith(
"uw"))
981 intID = Intrinsic::x86_xop_vpcomuw;
982 else if (Name.endswith(
"ud"))
983 intID = Intrinsic::x86_xop_vpcomud;
984 else if (Name.endswith(
"uq"))
985 intID = Intrinsic::x86_xop_vpcomuq;
986 else if (Name.endswith(
"b"))
987 intID = Intrinsic::x86_xop_vpcomb;
988 else if (Name.endswith(
"w"))
989 intID = Intrinsic::x86_xop_vpcomw;
990 else if (Name.endswith(
"d"))
991 intID = Intrinsic::x86_xop_vpcomd;
992 else if (Name.endswith(
"q"))
993 intID = Intrinsic::x86_xop_vpcomq;
997 Name = Name.substr(9);
999 if (Name.startswith(
"lt"))
1001 else if (Name.startswith(
"le"))
1003 else if (Name.startswith(
"gt"))
1005 else if (Name.startswith(
"ge"))
1007 else if (Name.startswith(
"eq"))
1009 else if (Name.startswith(
"ne"))
1011 else if (Name.startswith(
"false"))
1013 else if (Name.startswith(
"true"))
1022 }
else if (IsX86 && Name ==
"xop.vpcmov") {
1031 Rep = Builder.
CreateOr(Sel0, Sel1);
1032 }
else if (IsX86 && Name ==
"sse42.crc32.64.8") {
1034 Intrinsic::x86_sse42_crc32_32_8);
1038 }
else if (IsX86 && Name.startswith(
"avx.vbroadcast.s")) {
1048 for (
unsigned I = 0;
I < EltNum; ++
I)
1051 }
else if (IsX86 && (Name.startswith(
"sse41.pmovsx") ||
1052 Name.startswith(
"sse41.pmovzx") ||
1053 Name.startswith(
"avx2.pmovsx") ||
1054 Name.startswith(
"avx2.pmovzx") ||
1055 Name.startswith(
"avx512.mask.pmovsx") ||
1056 Name.startswith(
"avx512.mask.pmovzx"))) {
1063 for (
unsigned i = 0;
i != NumDstElts; ++
i)
1076 }
else if (IsX86 && (Name.startswith(
"avx.vbroadcastf128") ||
1077 Name ==
"avx2.vbroadcasti128")) {
1085 if (NumSrcElts == 2)
1090 { 0, 1, 2, 3, 0, 1, 2, 3 });
1091 }
else if (IsX86 && (Name.startswith(
"avx2.pbroadcast") ||
1092 Name.startswith(
"avx2.vbroadcast") ||
1093 Name.startswith(
"avx512.pbroadcast") ||
1094 Name.startswith(
"avx512.mask.broadcast.s"))) {
1105 }
else if (IsX86 && Name.startswith(
"avx512.mask.palignr.")) {
1112 }
else if (IsX86 && Name.startswith(
"avx512.mask.valign.")) {
1119 }
else if (IsX86 && (Name ==
"sse2.psll.dq" ||
1120 Name ==
"avx2.psll.dq")) {
1122 unsigned Shift = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
1125 }
else if (IsX86 && (Name ==
"sse2.psrl.dq" ||
1126 Name ==
"avx2.psrl.dq")) {
1128 unsigned Shift = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
1131 }
else if (IsX86 && (Name ==
"sse2.psll.dq.bs" ||
1132 Name ==
"avx2.psll.dq.bs" ||
1133 Name ==
"avx512.psll.dq.512")) {
1135 unsigned Shift = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
1137 }
else if (IsX86 && (Name ==
"sse2.psrl.dq.bs" ||
1138 Name ==
"avx2.psrl.dq.bs" ||
1139 Name ==
"avx512.psrl.dq.512")) {
1141 unsigned Shift = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
1143 }
else if (IsX86 && (Name ==
"sse41.pblendw" ||
1144 Name.startswith(
"sse41.blendp") ||
1145 Name.startswith(
"avx.blend.p") ||
1146 Name ==
"avx2.pblendw" ||
1147 Name.startswith(
"avx2.pblendd."))) {
1150 unsigned Imm = cast <ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
1155 for (
unsigned i = 0;
i != NumElts; ++
i)
1156 Idxs[
i] = ((Imm >> (
i%8)) & 1) ?
i + NumElts :
i;
1159 }
else if (IsX86 && (Name.startswith(
"avx.vinsertf128.") ||
1160 Name ==
"avx2.vinserti128" ||
1161 Name.startswith(
"avx512.mask.insert"))) {
1164 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
1167 unsigned Scale = DstNumElts / SrcNumElts;
1175 for (
unsigned i = 0;
i != SrcNumElts; ++
i)
1177 for (
unsigned i = SrcNumElts;
i != DstNumElts; ++
i)
1178 Idxs[
i] = SrcNumElts;
1193 for (
unsigned i = 0;
i != DstNumElts; ++
i)
1196 for (
unsigned i = 0;
i != SrcNumElts; ++
i)
1197 Idxs[
i + Imm * SrcNumElts] =
i + DstNumElts;
1204 }
else if (IsX86 && (Name.startswith(
"avx.vextractf128.") ||
1205 Name ==
"avx2.vextracti128" ||
1206 Name.startswith(
"avx512.mask.vextract"))) {
1208 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
1211 unsigned Scale = SrcNumElts / DstNumElts;
1218 for (
unsigned i = 0;
i != DstNumElts; ++
i) {
1219 Idxs[
i] =
i + (Imm * DstNumElts);
1227 }
else if (!IsX86 && Name ==
"stackprotectorcheck") {
1229 }
else if (IsX86 && (Name.startswith(
"avx512.mask.perm.df.") ||
1230 Name.startswith(
"avx512.mask.perm.di."))) {
1232 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
1237 for (
unsigned i = 0;
i != NumElts; ++
i)
1238 Idxs[
i] = (
i & ~0x3) + ((Imm >> (2 * (
i & 0x3))) & 3);
1245 }
else if (IsX86 && (Name.startswith(
"avx.vpermil.") ||
1246 Name ==
"sse2.pshuf.d" ||
1247 Name.startswith(
"avx512.mask.vpermil.p") ||
1248 Name.startswith(
"avx512.mask.pshuf.d."))) {
1250 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
1255 unsigned IdxMask = ((1 << IdxSize) - 1);
1261 for (
unsigned i = 0;
i != NumElts; ++
i)
1262 Idxs[
i] = ((Imm >> ((
i * IdxSize) % 8)) & IdxMask) | (
i & ~IdxMask);
1269 }
else if (IsX86 && (Name ==
"sse2.pshufl.w" ||
1270 Name.startswith(
"avx512.mask.pshufl.w."))) {
1272 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
1276 for (
unsigned l = 0; l != NumElts; l += 8) {
1277 for (
unsigned i = 0;
i != 4; ++
i)
1278 Idxs[
i + l] = ((Imm >> (2 *
i)) & 0x3) + l;
1279 for (
unsigned i = 4;
i != 8; ++
i)
1280 Idxs[
i + l] =
i + l;
1288 }
else if (IsX86 && (Name ==
"sse2.pshufh.w" ||
1289 Name.startswith(
"avx512.mask.pshufh.w."))) {
1291 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
1295 for (
unsigned l = 0; l != NumElts; l += 8) {
1296 for (
unsigned i = 0;
i != 4; ++
i)
1297 Idxs[
i + l] =
i + l;
1298 for (
unsigned i = 0;
i != 4; ++
i)
1299 Idxs[
i + l + 4] = ((Imm >> (2 *
i)) & 0x3) + 4 + l;
1307 }
else if (IsX86 && Name.startswith(
"avx512.mask.shuf.p")) {
1310 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
1314 unsigned HalfLaneElts = NumLaneElts / 2;
1317 for (
unsigned i = 0;
i != NumElts; ++
i) {
1319 Idxs[
i] =
i - (
i % NumLaneElts);
1321 if ((
i % NumLaneElts) >= HalfLaneElts)
1325 Idxs[
i] += (Imm >> ((
i * HalfLaneElts) % 8)) & ((1 << HalfLaneElts) - 1);
1332 }
else if (IsX86 && (Name.startswith(
"avx512.mask.movddup") ||
1333 Name.startswith(
"avx512.mask.movshdup") ||
1334 Name.startswith(
"avx512.mask.movsldup"))) {
1340 if (Name.startswith(
"avx512.mask.movshdup."))
1344 for (
unsigned l = 0; l != NumElts; l += NumLaneElts)
1345 for (
unsigned i = 0;
i != NumLaneElts;
i += 2) {
1354 }
else if (IsX86 && (Name.startswith(
"avx512.mask.punpckl") ||
1355 Name.startswith(
"avx512.mask.unpckl."))) {
1362 for (
int l = 0; l != NumElts; l += NumLaneElts)
1363 for (
int i = 0;
i != NumLaneElts; ++
i)
1364 Idxs[
i + l] = l + (
i / 2) + NumElts * (
i % 2);
1370 }
else if (IsX86 && (Name.startswith(
"avx512.mask.punpckh") ||
1371 Name.startswith(
"avx512.mask.unpckh."))) {
1378 for (
int l = 0; l != NumElts; l += NumLaneElts)
1379 for (
int i = 0;
i != NumLaneElts; ++
i)
1380 Idxs[
i + l] = (NumLaneElts / 2) + l + (
i / 2) + NumElts * (
i % 2);
1386 }
else if (IsX86 && Name.startswith(
"avx512.mask.pand.")) {
1390 }
else if (IsX86 && Name.startswith(
"avx512.mask.pandn.")) {
1395 }
else if (IsX86 && Name.startswith(
"avx512.mask.por.")) {
1399 }
else if (IsX86 && Name.startswith(
"avx512.mask.pxor.")) {
1403 }
else if (IsX86 && Name.startswith(
"avx512.mask.and.")) {
1411 }
else if (IsX86 && Name.startswith(
"avx512.mask.andn.")) {
1420 }
else if (IsX86 && Name.startswith(
"avx512.mask.or.")) {
1428 }
else if (IsX86 && Name.startswith(
"avx512.mask.xor.")) {
1436 }
else if (IsX86 && Name.startswith(
"avx512.mask.padd.")) {
1440 }
else if (IsX86 && Name.startswith(
"avx512.mask.psub.")) {
1444 }
else if (IsX86 && Name.startswith(
"avx512.mask.pmull.")) {
1448 }
else if (IsX86 && (Name.startswith(
"avx512.mask.add.p"))) {
1452 }
else if (IsX86 && Name.startswith(
"avx512.mask.div.p")) {
1456 }
else if (IsX86 && Name.startswith(
"avx512.mask.mul.p")) {
1460 }
else if (IsX86 && Name.startswith(
"avx512.mask.sub.p")) {
1464 }
else if (IsX86 && Name.startswith(
"avx512.mask.pshuf.b.")) {
1468 IID = Intrinsic::x86_ssse3_pshuf_b_128;
1470 IID = Intrinsic::x86_avx2_pshuf_b;
1472 IID = Intrinsic::x86_avx512_pshuf_b_512;
1480 }
else if (IsX86 && (Name.startswith(
"avx512.mask.pmul.dq.") ||
1481 Name.startswith(
"avx512.mask.pmulu.dq."))) {
1482 bool IsUnsigned = Name[16] ==
'u';
1486 IID = Intrinsic::x86_sse41_pmuldq;
1488 IID = Intrinsic::x86_avx2_pmul_dq;
1490 IID = Intrinsic::x86_avx512_pmul_dq_512;
1492 IID = Intrinsic::x86_sse2_pmulu_dq;
1494 IID = Intrinsic::x86_avx2_pmulu_dq;
1496 IID = Intrinsic::x86_avx512_pmulu_dq_512;
1504 }
else if (IsX86 && Name.startswith(
"avx512.mask.psll")) {
1505 bool IsImmediate = Name[16] ==
'i' ||
1506 (Name.size() > 18 && Name[18] ==
'i');
1507 bool IsVariable = Name[16] ==
'v';
1508 char Size = Name[16] ==
'.' ? Name[17] :
1509 Name[17] ==
'.' ? Name[18] :
1510 Name[18] ==
'.' ? Name[19] :
1514 if (IsVariable && Name[17] !=
'.') {
1515 if (Size ==
'd' && Name[17] ==
'2')
1516 IID = Intrinsic::x86_avx2_psllv_q;
1517 else if (Size ==
'd' && Name[17] ==
'4')
1518 IID = Intrinsic::x86_avx2_psllv_q_256;
1519 else if (Size ==
's' && Name[17] ==
'4')
1520 IID = Intrinsic::x86_avx2_psllv_d;
1521 else if (Size ==
's' && Name[17] ==
'8')
1522 IID = Intrinsic::x86_avx2_psllv_d_256;
1523 else if (Size ==
'h' && Name[17] ==
'8')
1524 IID = Intrinsic::x86_avx512_psllv_w_128;
1525 else if (Size ==
'h' && Name[17] ==
'1')
1526 IID = Intrinsic::x86_avx512_psllv_w_256;
1527 else if (Name[17] ==
'3' && Name[18] ==
'2')
1528 IID = Intrinsic::x86_avx512_psllv_w_512;
1531 }
else if (Name.endswith(
".128")) {
1533 IID = IsImmediate ? Intrinsic::x86_sse2_pslli_d
1534 : Intrinsic::x86_sse2_psll_d;
1535 else if (Size ==
'q')
1536 IID = IsImmediate ? Intrinsic::x86_sse2_pslli_q
1537 : Intrinsic::x86_sse2_psll_q;
1538 else if (Size ==
'w')
1539 IID = IsImmediate ? Intrinsic::x86_sse2_pslli_w
1540 : Intrinsic::x86_sse2_psll_w;
1543 }
else if (Name.endswith(
".256")) {
1545 IID = IsImmediate ? Intrinsic::x86_avx2_pslli_d
1546 : Intrinsic::x86_avx2_psll_d;
1547 else if (Size ==
'q')
1548 IID = IsImmediate ? Intrinsic::x86_avx2_pslli_q
1549 : Intrinsic::x86_avx2_psll_q;
1550 else if (Size ==
'w')
1551 IID = IsImmediate ? Intrinsic::x86_avx2_pslli_w
1552 : Intrinsic::x86_avx2_psll_w;
1557 IID = IsImmediate ? Intrinsic::x86_avx512_pslli_d_512 :
1558 IsVariable ? Intrinsic::x86_avx512_psllv_d_512 :
1559 Intrinsic::x86_avx512_psll_d_512;
1560 else if (Size ==
'q')
1561 IID = IsImmediate ? Intrinsic::x86_avx512_pslli_q_512 :
1562 IsVariable ? Intrinsic::x86_avx512_psllv_q_512 :
1563 Intrinsic::x86_avx512_psll_q_512;
1564 else if (Size ==
'w')
1565 IID = IsImmediate ? Intrinsic::x86_avx512_pslli_w_512
1566 : Intrinsic::x86_avx512_psll_w_512;
1572 }
else if (IsX86 && Name.startswith(
"avx512.mask.psrl")) {
1573 bool IsImmediate = Name[16] ==
'i' ||
1574 (Name.size() > 18 && Name[18] ==
'i');
1575 bool IsVariable = Name[16] ==
'v';
1576 char Size = Name[16] ==
'.' ? Name[17] :
1577 Name[17] ==
'.' ? Name[18] :
1578 Name[18] ==
'.' ? Name[19] :
1582 if (IsVariable && Name[17] !=
'.') {
1583 if (Size ==
'd' && Name[17] ==
'2')
1584 IID = Intrinsic::x86_avx2_psrlv_q;
1585 else if (Size ==
'd' && Name[17] ==
'4')
1586 IID = Intrinsic::x86_avx2_psrlv_q_256;
1587 else if (Size ==
's' && Name[17] ==
'4')
1588 IID = Intrinsic::x86_avx2_psrlv_d;
1589 else if (Size ==
's' && Name[17] ==
'8')
1590 IID = Intrinsic::x86_avx2_psrlv_d_256;
1591 else if (Size ==
'h' && Name[17] ==
'8')
1592 IID = Intrinsic::x86_avx512_psrlv_w_128;
1593 else if (Size ==
'h' && Name[17] ==
'1')
1594 IID = Intrinsic::x86_avx512_psrlv_w_256;
1595 else if (Name[17] ==
'3' && Name[18] ==
'2')
1596 IID = Intrinsic::x86_avx512_psrlv_w_512;
1599 }
else if (Name.endswith(
".128")) {
1601 IID = IsImmediate ? Intrinsic::x86_sse2_psrli_d
1602 : Intrinsic::x86_sse2_psrl_d;
1603 else if (Size ==
'q')
1604 IID = IsImmediate ? Intrinsic::x86_sse2_psrli_q
1605 : Intrinsic::x86_sse2_psrl_q;
1606 else if (Size ==
'w')
1607 IID = IsImmediate ? Intrinsic::x86_sse2_psrli_w
1608 : Intrinsic::x86_sse2_psrl_w;
1611 }
else if (Name.endswith(
".256")) {
1613 IID = IsImmediate ? Intrinsic::x86_avx2_psrli_d
1614 : Intrinsic::x86_avx2_psrl_d;
1615 else if (Size ==
'q')
1616 IID = IsImmediate ? Intrinsic::x86_avx2_psrli_q
1617 : Intrinsic::x86_avx2_psrl_q;
1618 else if (Size ==
'w')
1619 IID = IsImmediate ? Intrinsic::x86_avx2_psrli_w
1620 : Intrinsic::x86_avx2_psrl_w;
1625 IID = IsImmediate ? Intrinsic::x86_avx512_psrli_d_512 :
1626 IsVariable ? Intrinsic::x86_avx512_psrlv_d_512 :
1627 Intrinsic::x86_avx512_psrl_d_512;
1628 else if (Size ==
'q')
1629 IID = IsImmediate ? Intrinsic::x86_avx512_psrli_q_512 :
1630 IsVariable ? Intrinsic::x86_avx512_psrlv_q_512 :
1631 Intrinsic::x86_avx512_psrl_q_512;
1632 else if (Size ==
'w')
1633 IID = IsImmediate ? Intrinsic::x86_avx512_psrli_w_512
1634 : Intrinsic::x86_avx512_psrl_w_512;
1640 }
else if (IsX86 && Name.startswith(
"avx512.mask.psra")) {
1641 bool IsImmediate = Name[16] ==
'i' ||
1642 (Name.size() > 18 && Name[18] ==
'i');
1643 bool IsVariable = Name[16] ==
'v';
1644 char Size = Name[16] ==
'.' ? Name[17] :
1645 Name[17] ==
'.' ? Name[18] :
1646 Name[18] ==
'.' ? Name[19] :
1650 if (IsVariable && Name[17] !=
'.') {
1651 if (Size ==
's' && Name[17] ==
'4')
1652 IID = Intrinsic::x86_avx2_psrav_d;
1653 else if (Size ==
's' && Name[17] ==
'8')
1654 IID = Intrinsic::x86_avx2_psrav_d_256;
1655 else if (Size ==
'h' && Name[17] ==
'8')
1656 IID = Intrinsic::x86_avx512_psrav_w_128;
1657 else if (Size ==
'h' && Name[17] ==
'1')
1658 IID = Intrinsic::x86_avx512_psrav_w_256;
1659 else if (Name[17] ==
'3' && Name[18] ==
'2')
1660 IID = Intrinsic::x86_avx512_psrav_w_512;
1663 }
else if (Name.endswith(
".128")) {
1665 IID = IsImmediate ? Intrinsic::x86_sse2_psrai_d
1666 : Intrinsic::x86_sse2_psra_d;
1667 else if (Size ==
'q')
1668 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_q_128 :
1669 IsVariable ? Intrinsic::x86_avx512_psrav_q_128 :
1670 Intrinsic::x86_avx512_psra_q_128;
1671 else if (Size ==
'w')
1672 IID = IsImmediate ? Intrinsic::x86_sse2_psrai_w
1673 : Intrinsic::x86_sse2_psra_w;
1676 }
else if (Name.endswith(
".256")) {
1678 IID = IsImmediate ? Intrinsic::x86_avx2_psrai_d
1679 : Intrinsic::x86_avx2_psra_d;
1680 else if (Size ==
'q')
1681 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_q_256 :
1682 IsVariable ? Intrinsic::x86_avx512_psrav_q_256 :
1683 Intrinsic::x86_avx512_psra_q_256;
1684 else if (Size ==
'w')
1685 IID = IsImmediate ? Intrinsic::x86_avx2_psrai_w
1686 : Intrinsic::x86_avx2_psra_w;
1691 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_d_512 :
1692 IsVariable ? Intrinsic::x86_avx512_psrav_d_512 :
1693 Intrinsic::x86_avx512_psra_d_512;
1694 else if (Size ==
'q')
1695 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_q_512 :
1696 IsVariable ? Intrinsic::x86_avx512_psrav_q_512 :
1697 Intrinsic::x86_avx512_psra_q_512;
1698 else if (Size ==
'w')
1699 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_w_512
1700 : Intrinsic::x86_avx512_psra_w_512;
1706 }
else if (IsX86 && Name.startswith(
"avx512.mask.move.s")) {
1708 }
else if (IsX86 && Name.startswith(
"avx512.mask.vpermilvar.")) {
1710 if (Name.endswith(
"ps.128"))
1711 IID = Intrinsic::x86_avx_vpermilvar_ps;
1712 else if (Name.endswith(
"pd.128"))
1713 IID = Intrinsic::x86_avx_vpermilvar_pd;
1714 else if (Name.endswith(
"ps.256"))
1715 IID = Intrinsic::x86_avx_vpermilvar_ps_256;
1716 else if (Name.endswith(
"pd.256"))
1717 IID = Intrinsic::x86_avx_vpermilvar_pd_256;
1718 else if (Name.endswith(
"ps.512"))
1719 IID = Intrinsic::x86_avx512_vpermilvar_ps_512;
1720 else if (Name.endswith(
"pd.512"))
1721 IID = Intrinsic::x86_avx512_vpermilvar_pd_512;
1740 std::string Name = CI->
getName();
1748 case Intrinsic::arm_neon_vld1:
1749 case Intrinsic::arm_neon_vld2:
1750 case Intrinsic::arm_neon_vld3:
1751 case Intrinsic::arm_neon_vld4:
1752 case Intrinsic::arm_neon_vld2lane:
1753 case Intrinsic::arm_neon_vld3lane:
1754 case Intrinsic::arm_neon_vld4lane:
1755 case Intrinsic::arm_neon_vst1:
1756 case Intrinsic::arm_neon_vst2:
1757 case Intrinsic::arm_neon_vst3:
1758 case Intrinsic::arm_neon_vst4:
1759 case Intrinsic::arm_neon_vst2lane:
1760 case Intrinsic::arm_neon_vst3lane:
1761 case Intrinsic::arm_neon_vst4lane: {
1769 case Intrinsic::bitreverse:
1774 case Intrinsic::ctlz:
1775 case Intrinsic::cttz:
1777 "Mismatch between function args and call args");
1780 CI->eraseFromParent();
1783 case Intrinsic::objectsize:
1784 CI->replaceAllUsesWith(Builder.CreateCall(
1785 NewFn, {CI->getArgOperand(0), CI->getArgOperand(1)},
Name));
1786 CI->eraseFromParent();
1789 case Intrinsic::ctpop: {
1790 CI->replaceAllUsesWith(Builder.CreateCall(NewFn, {CI->getArgOperand(0)}));
1791 CI->eraseFromParent();
1795 case Intrinsic::x86_xop_vfrcz_ss:
1796 case Intrinsic::x86_xop_vfrcz_sd:
1797 CI->replaceAllUsesWith(
1798 Builder.CreateCall(NewFn, {CI->getArgOperand(1)},
Name));
1799 CI->eraseFromParent();
1802 case Intrinsic::x86_xop_vpermil2pd:
1803 case Intrinsic::x86_xop_vpermil2ps:
1804 case Intrinsic::x86_xop_vpermil2pd_256:
1805 case Intrinsic::x86_xop_vpermil2ps_256: {
1807 CI->arg_operands().end());
1809 VectorType *IntIdxTy = VectorType::getInteger(FltIdxTy);
1810 Args[2] = Builder.CreateBitCast(
Args[2], IntIdxTy);
1811 CI->replaceAllUsesWith(Builder.CreateCall(NewFn,
Args, Name));
1812 CI->eraseFromParent();
1816 case Intrinsic::x86_sse41_ptestc:
1817 case Intrinsic::x86_sse41_ptestz:
1818 case Intrinsic::x86_sse41_ptestnzc: {
1823 Value *Arg0 = CI->getArgOperand(0);
1824 if (Arg0->
getType() != VectorType::get(Type::getFloatTy(
C), 4))
1828 Value *Arg1 = CI->getArgOperand(1);
1830 Type *NewVecTy = VectorType::get(Type::getInt64Ty(
C), 2);
1832 Value *BC0 = Builder.CreateBitCast(Arg0, NewVecTy,
"cast");
1833 Value *BC1 = Builder.CreateBitCast(Arg1, NewVecTy,
"cast");
1835 CallInst *NewCall = Builder.CreateCall(NewFn, {BC0, BC1},
Name);
1837 CI->eraseFromParent();
1841 case Intrinsic::x86_sse41_insertps:
1842 case Intrinsic::x86_sse41_dppd:
1843 case Intrinsic::x86_sse41_dpps:
1844 case Intrinsic::x86_sse41_mpsadbw:
1845 case Intrinsic::x86_avx_dp_ps_256:
1846 case Intrinsic::x86_avx2_mpsadbw: {
1850 CI->arg_operands().end());
1853 Args.back() = Builder.CreateTrunc(
Args.back(), Type::getInt8Ty(
C),
"trunc");
1857 CI->eraseFromParent();
1861 case Intrinsic::thread_pointer: {
1862 CI->replaceAllUsesWith(Builder.CreateCall(NewFn, {}));
1863 CI->eraseFromParent();
1867 case Intrinsic::invariant_start:
1868 case Intrinsic::invariant_end:
1869 case Intrinsic::masked_load:
1870 case Intrinsic::masked_store: {
1872 CI->arg_operands().end());
1873 CI->replaceAllUsesWith(Builder.CreateCall(NewFn,
Args));
1874 CI->eraseFromParent();
1881 assert(F &&
"Illegal attempt to upgrade a non-existent intrinsic.");
1890 if (
CallInst *CI = dyn_cast<CallInst>(*UI++))
1908 Metadata *Elts2[] = {ScalarType, ScalarType,
1909 ConstantAsMetadata::get(
1910 Constant::getNullValue(Type::getInt64Ty(
Context))),
1912 return MDNode::get(
Context, Elts2);
1915 Metadata *Elts[] = {&MD, &MD, ConstantAsMetadata::get(Constant::getNullValue(
1917 return MDNode::get(
Context, Elts);
1922 if (Opc != Instruction::BitCast)
1933 Type *MidTy = Type::getInt64Ty(Context);
1934 Temp = CastInst::Create(Instruction::PtrToInt, V, MidTy);
1936 return CastInst::Create(Instruction::IntToPtr, Temp, DestTy);
1943 if (Opc != Instruction::BitCast)
1953 Type *MidTy = Type::getInt64Ty(Context);
1955 return ConstantExpr::getIntToPtr(ConstantExpr::getPtrToInt(C, MidTy),
1982 bool HasObjCFlag =
false, HasClassProperties =
false;
1990 if (ID->
getString() ==
"Objective-C Image Info Version")
1992 if (ID->
getString() ==
"Objective-C Class Properties")
1993 HasClassProperties =
true;
2000 if (HasObjCFlag && !HasClassProperties) {
2009 auto *
T = dyn_cast_or_null<MDTuple>(MD);
2012 if (
T->getNumOperands() < 1)
2014 auto *S = dyn_cast_or_null<MDString>(
T->getOperand(0));
2017 return S->getString().startswith(
"llvm.vectorizer.");
2021 StringRef OldPrefix =
"llvm.vectorizer.";
2024 if (OldTag ==
"llvm.vectorizer.unroll")
2025 return MDString::get(C,
"llvm.loop.interleave.count");
2027 return MDString::get(
2033 auto *
T = dyn_cast_or_null<MDTuple>(MD);
2036 if (
T->getNumOperands() < 1)
2038 auto *OldTag = dyn_cast_or_null<MDString>(
T->getOperand(0));
2041 if (!OldTag->getString().startswith(
"llvm.vectorizer."))
2048 for (
unsigned I = 1,
E =
T->getNumOperands();
I !=
E; ++
I)
2051 return MDTuple::get(
T->getContext(), Ops);
2067 return MDTuple::get(
T->getContext(), Ops);
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type (if unknown returns 0).
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn)
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
void push_back(const T &Elt)
LinkageTypes getLinkage() const
Value * CreateICmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="")
static IntegerType * getInt1Ty(LLVMContext &C)
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
Value * CreateIsNotNull(Value *Arg, const Twine &Name="")
Return an i1 value testing if Arg is not null.
Value * CreateXor(Value *LHS, Value *RHS, const Twine &Name="")
A Module instance is used to store all the information related to an LLVM module. ...
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
unsigned getNumOperands() const
Return number of MDNode operands.
This class represents a function call, abstracting a target machine's calling convention.
ArrayRef< Type * > params() const
unsigned getDebugMetadataVersionFromModule(const Module &M)
Return Debug Info Metadata Version by checking module flags.
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
Type * getReturnType() const
Returns the type of the ret val.
Value * CreateSExt(Value *V, Type *DestTy, const Twine &Name="")
static IntegerType * getInt64Ty(LLVMContext &C)
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)
static Value * upgradeIntMinMax(IRBuilder<> &Builder, CallInst &CI, ICmpInst::Predicate Pred)
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
StringRef getName() const
Return a constant reference to the value's name.
Value * CreateNot(Value *V, const Twine &Name="")
StoreInst * CreateAlignedStore(Value *Val, Value *Ptr, unsigned Align, bool isVolatile=false)
Value * CreateFSub(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
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)
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
unsigned getNumArgOperands() const
Return the number of call arguments.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
unsigned getBitWidth() const
Return the number of bits in the Vector type.
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly...
Value * CreateAdd(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
void setName(const Twine &Name)
Change the name of the value.
Type * getVectorElementType() const
Value * CreateICmpSGT(Value *LHS, Value *RHS, const Twine &Name="")
static Metadata * upgradeLoopArgument(Metadata *MD)
Class to represent function types.
Value * CreateBitCast(Value *V, Type *DestTy, const Twine &Name="")
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
static Value * upgradeMaskedCompare(IRBuilder<> &Builder, CallInst &CI, ICmpInst::Predicate Pred)
bool StripDebugInfo(Module &M)
Strip debug info in the module if it exists.
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
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.
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
Value * CreateSub(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Value * CreateSIToFP(Value *V, Type *DestTy, const Twine &Name="")
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
An instruction for storing to memory.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Value * CreateZExt(Value *V, Type *DestTy, const Twine &Name="")
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
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...
Class to represent pointers.
static Value * UpgradeX86PSLLDQIntrinsics(IRBuilder<> &Builder, Value *Op, unsigned Shift)
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
Value * CreateOr(Value *LHS, Value *RHS, const Twine &Name="")
bool UpgradeModuleFlags(Module &M)
This checks for module flags which should be upgraded.
static Value * UpgradeMaskedStore(IRBuilder<> &Builder, Value *Ptr, Value *Data, Value *Mask, bool Aligned)
LoadInst * CreateLoad(Value *Ptr, const char *Name)
Type * getParamType(unsigned i) const
Parameter type accessors.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t find(char C, size_t From=0) const
Search for the first character C in the string.
constexpr bool isPowerOf2_32(uint32_t Value)
isPowerOf2_32 - This function returns true if the argument is a power of two > 0. ...
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.
This is an important base class in LLVM.
void getModuleFlagsMetadata(SmallVectorImpl< ModuleFlagEntry > &Flags) const
Returns the module flags in the provided vector.
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)
bool UpgradeDebugInfo(Module &M)
Check the debug info version number, if it is out-dated, drop the debug info.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
static VectorType * getInteger(VectorType *VTy)
This static method gets a VectorType with the same number of elements as the input type...
void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, Metadata *Val)
Add a module-level flag to the module-level flags metadata.
static bool UpgradeX86IntrinsicsWith8BitMask(Function *F, Intrinsic::ID IID, Function *&NewFn)
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
MDNode * getOperand(unsigned i) const
uint64_t getNumElements() const
Value * CreateICmpEQ(Value *LHS, Value *RHS, const Twine &Name="")
self_iterator getIterator()
ConstantInt * getInt64(uint64_t C)
Get a constant 64-bit value.
Value * CreateExtractElement(Value *Vec, Value *Idx, const Twine &Name="")
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
LLVMContext & getContext() const
All values hold a context through their type.
#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="")
static bool UpgradeSSE41Function(Function *F, Intrinsic::ID IID, Function *&NewFn)
Value * CreateUIToFP(Value *V, Type *DestTy, const Twine &Name="")
static Value * getX86MaskVec(IRBuilder<> &Builder, Value *Mask, unsigned NumElts)
StringRef getString() const
static Constant * getSplat(unsigned NumElts, Constant *Elt)
Return a ConstantVector with the specified constant in each element.
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
const MDOperand & getOperand(unsigned I) const
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...
Value * CreateFAdd(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the generic address space (address sp...
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type...
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)
Module.h This file contains the declarations for the Module class.
Type * getType() const
All values are typed, get the type of this value.
bool UpgradeGlobalVariable(GlobalVariable *GV)
This checks for global variables which should be upgraded.
Value * CreateInsertElement(Value *Vec, Value *NewElt, Value *Idx, const Twine &Name="")
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="")
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.
Function * getCalledFunction() const
Return the function called, or null if this is an indirect function invocation.
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)
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
Uses the specified value, regardless of the behavior or value of the other module.
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th call argument.
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.
Class for arbitrary precision integers.
bool isIntegerTy() const
True if this is an instance of IntegerType.
IntegerType * getInt8Ty()
Fetch the type representing an 8-bit integer.
unsigned getVectorNumElements() const
void eraseFromParent() override
eraseFromParent - This method unlinks 'this' from the containing module and deletes it...
Value * CreatePointerCast(Value *V, Type *DestTy, const Twine &Name="")
void setAttributes(AttributeSet Attrs)
Set the attribute list for this Function.
ConstantInt * getFalse()
Get the constant value for i1 false.
IntegerType * getInt1Ty()
Fetch the type representing a single bit.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
static bool isOldLoopArgument(Metadata *MD)
static IntegerType * getInt32Ty(LLVMContext &C)
FunctionType * getFunctionType() const
Returns the FunctionType for me.
CallInst * CreateCall(Value *Callee, ArrayRef< Value * > Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)
static Value * upgradeMaskedMove(IRBuilder<> &Builder, CallInst &CI)
static void rename(GlobalValue *GV)
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
LLVMContext & getContext() const
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
AttributeSet getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
Value * CreateAnd(Value *LHS, Value *RHS, const Twine &Name="")
iterator_range< op_iterator > arg_operands()
Iteration adapter for range-for loops.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
user_iterator user_begin()
LoadInst * CreateAlignedLoad(Value *Ptr, unsigned Align, const char *Name)
unsigned getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
static VectorType * get(Type *ElementType, unsigned NumElements)
This static method is the primary way to construct an VectorType.
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.
unsigned getNumOperands() const
bool match(StringRef String, SmallVectorImpl< StringRef > *Matches=nullptr)
matches - Match the regex against a given String.
Value * CreateFDiv(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
ConstantInt * getInt8(uint8_t C)
Get a constant 8-bit value.
PointerType * getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
StringRef - Represent a constant reference to a string, i.e.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, const Twine &N="", Module *M=nullptr)
Value * UpgradeBitCastExpr(unsigned Opc, Constant *C, Type *DestTy)
This is an auto-upgrade for bitcast constant expression between pointers with different address space...
Value * CreateFMul(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
unsigned getMDKindID(StringRef Name) const
Return a unique non-zero ID for the specified metadata kind.
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
const BasicBlock * getParent() const
LLVMContext & getContext() const
Get the global data context.