81 Name ==
"sse.add.ss" ||
82 Name ==
"sse2.add.sd" ||
83 Name ==
"sse.sub.ss" ||
84 Name ==
"sse2.sub.sd" ||
85 Name ==
"sse.mul.ss" ||
86 Name ==
"sse2.mul.sd" ||
87 Name ==
"sse.div.ss" ||
88 Name ==
"sse2.div.sd" ||
89 Name ==
"sse41.pmaxsb" ||
90 Name ==
"sse2.pmaxs.w" ||
91 Name ==
"sse41.pmaxsd" ||
92 Name ==
"sse2.pmaxu.b" ||
93 Name ==
"sse41.pmaxuw" ||
94 Name ==
"sse41.pmaxud" ||
95 Name ==
"sse41.pminsb" ||
96 Name ==
"sse2.pmins.w" ||
97 Name ==
"sse41.pminsd" ||
98 Name ==
"sse2.pminu.b" ||
99 Name ==
"sse41.pminuw" ||
100 Name ==
"sse41.pminud" ||
150 Name ==
"avx512.mask.add.pd.128" ||
151 Name ==
"avx512.mask.add.pd.256" ||
152 Name ==
"avx512.mask.add.ps.128" ||
153 Name ==
"avx512.mask.add.ps.256" ||
154 Name ==
"avx512.mask.div.pd.128" ||
155 Name ==
"avx512.mask.div.pd.256" ||
156 Name ==
"avx512.mask.div.ps.128" ||
157 Name ==
"avx512.mask.div.ps.256" ||
158 Name ==
"avx512.mask.mul.pd.128" ||
159 Name ==
"avx512.mask.mul.pd.256" ||
160 Name ==
"avx512.mask.mul.ps.128" ||
161 Name ==
"avx512.mask.mul.ps.256" ||
162 Name ==
"avx512.mask.sub.pd.128" ||
163 Name ==
"avx512.mask.sub.pd.256" ||
164 Name ==
"avx512.mask.sub.ps.128" ||
165 Name ==
"avx512.mask.sub.ps.256" ||
166 Name ==
"avx512.mask.max.pd.128" ||
167 Name ==
"avx512.mask.max.pd.256" ||
168 Name ==
"avx512.mask.max.ps.128" ||
169 Name ==
"avx512.mask.max.ps.256" ||
170 Name ==
"avx512.mask.min.pd.128" ||
171 Name ==
"avx512.mask.min.pd.256" ||
172 Name ==
"avx512.mask.min.ps.128" ||
173 Name ==
"avx512.mask.min.ps.256" ||
197 Name ==
"sse2.cvtdq2pd" ||
198 Name ==
"sse2.cvtps2pd" ||
199 Name ==
"avx.cvtdq2.pd.256" ||
200 Name ==
"avx.cvt.ps2.pd.256" ||
202 Name ==
"avx2.vinserti128" ||
205 Name ==
"avx2.vextracti128" ||
210 Name ==
"sse41.movntdqa" ||
211 Name ==
"avx2.movntdqa" ||
212 Name ==
"avx512.movntdqa" ||
213 Name ==
"sse2.storel.dq" ||
225 Name ==
"sse42.crc32.64.8" ||
235 Name ==
"sse41.pblendw" ||
238 Name ==
"avx2.pblendw" ||
241 Name ==
"avx2.vbroadcasti128" ||
242 Name ==
"xop.vpcmov" ||
243 Name ==
"xop.vpcmov.256" ||
268 if (Name.
substr(11) ==
"c")
270 if (Name.
substr(11) ==
"z")
272 if (Name.
substr(11) ==
"nzc")
277 if (Name ==
"sse41.insertps")
280 if (Name ==
"sse41.dppd")
283 if (Name ==
"sse41.dpps")
286 if (Name ==
"sse41.mpsadbw")
289 if (Name ==
"avx.dp.ps.256")
292 if (Name ==
"avx2.mpsadbw")
300 Intrinsic::x86_xop_vfrcz_ss);
306 Intrinsic::x86_xop_vfrcz_sd);
312 if (Idx->isFPOrFPVectorTy()) {
314 unsigned IdxSize = Idx->getPrimitiveSizeInBits();
315 unsigned EltSize = Idx->getScalarSizeInBits();
317 if (EltSize == 64 && IdxSize == 128)
318 Permil2ID = Intrinsic::x86_xop_vpermil2pd;
319 else if (EltSize == 32 && IdxSize == 128)
320 Permil2ID = Intrinsic::x86_xop_vpermil2ps;
321 else if (EltSize == 64 && IdxSize == 256)
322 Permil2ID = Intrinsic::x86_xop_vpermil2pd_256;
324 Permil2ID = Intrinsic::x86_xop_vpermil2ps_256;
334 assert(F &&
"Illegal to upgrade a non-existent Function.");
368 Regex vldRegex(
"^arm\\.neon\\.vld([1234]|[234]lane)\\.v[a-z0-9]*$");
369 if (vldRegex.
match(Name)) {
376 "llvm." + Name +
".p0i8", F->
getParent());
379 Regex vstRegex(
"^arm\\.neon\\.vst([1234]|[234]lane)\\.v[a-z0-9]*$");
380 if (vstRegex.
match(Name)) {
381 static const Intrinsic::ID StoreInts[] = {Intrinsic::arm_neon_vst1,
382 Intrinsic::arm_neon_vst2,
383 Intrinsic::arm_neon_vst3,
384 Intrinsic::arm_neon_vst4};
387 Intrinsic::arm_neon_vst2lane, Intrinsic::arm_neon_vst3lane,
388 Intrinsic::arm_neon_vst4lane
392 Type *Tys[] = {fArgs[0], fArgs[1]};
395 StoreInts[fArgs.size() - 3], Tys);
398 StoreLaneInts[fArgs.size() - 5], Tys);
401 if (Name ==
"aarch64.thread.pointer" || Name ==
"arm.thread.pointer") {
425 bool IsLifetimeStart = Name.
startswith(
"lifetime.start");
426 if (IsLifetimeStart || Name.
startswith(
"invariant.start")) {
428 Intrinsic::lifetime_start : Intrinsic::invariant_start;
438 bool IsLifetimeEnd = Name.
startswith(
"lifetime.end");
439 if (IsLifetimeEnd || Name.
startswith(
"invariant.end")) {
441 Intrinsic::lifetime_end : Intrinsic::invariant_end;
444 Type* ObjectPtr[1] = {
Args[IsLifetimeEnd ? 1 : 2]};
459 Intrinsic::masked_load,
470 Intrinsic::masked_store,
482 Intrinsic::masked_gather, Tys);
492 Intrinsic::masked_scatter, Tys);
504 .Cases(
"brev32",
"brev64", Intrinsic::bitreverse)
505 .
Case(
"clz.i", Intrinsic::ctlz)
506 .
Case(
"popc.i", Intrinsic::ctpop)
519 .Cases(
"abs.i",
"abs.ll",
true)
520 .
Cases(
"clz.ll",
"popc.ll",
"h2f",
true)
521 .
Cases(
"max.i",
"max.ll",
"max.ui",
"max.ull",
true)
522 .
Cases(
"min.i",
"min.ll",
"min.ui",
"min.ull",
true)
547 if (Name ==
"stackprotectorcheck") {
559 if (Result !=
None) {
560 NewFn = Result.getValue();
574 assert(F != NewFn &&
"Intrinsic function upgraded to the same function");
608 for (
unsigned l = 0; l != NumElts; l += 16)
609 for (
unsigned i = 0; i != 16; ++i) {
610 unsigned Idx = NumElts + i - Shift;
613 Idxs[l + i] = Idx + l;
642 for (
unsigned l = 0; l != NumElts; l += 16)
643 for (
unsigned i = 0; i != 16; ++i) {
644 unsigned Idx = i + Shift;
647 Idxs[l + i] = Idx + l;
667 for (
unsigned i = 0; i != NumElts; ++i)
680 if (
const auto *
C = dyn_cast<Constant>(Mask))
681 if (
C->isAllOnesValue())
695 unsigned ShiftVal = cast<llvm::ConstantInt>(Shift)->getZExtValue();
698 assert((IsVALIGN || NumElts % 16 == 0) &&
"Illegal NumElts for PALIGNR!");
699 assert((!IsVALIGN || NumElts <= 16) &&
"NumElts too large for VALIGN!");
704 ShiftVal &= (NumElts - 1);
721 for (
unsigned l = 0; l < NumElts; l += 16) {
722 for (
unsigned i = 0; i != 16; ++i) {
723 unsigned Idx = ShiftVal + i;
724 if (!IsVALIGN && Idx >= 16)
726 Indices[l + i] = Idx + l;
747 if (
const auto *
C = dyn_cast<Constant>(Mask))
748 if (
C->isAllOnesValue())
767 if (
const auto *
C = dyn_cast<Constant>(Mask))
768 if (
C->isAllOnesValue())
791 unsigned CC,
bool Signed) {
798 }
else if (CC == 7) {
816 if (!
C || !
C->isAllOnesValue())
821 for (
unsigned i = 0; i != NumElts; ++i)
823 for (
unsigned i = NumElts; i != 8; ++i)
824 Indices[i] = NumElts + i % NumElts;
863 return Builder.
CreateSExt(Mask, ReturnOp,
"vpmovm2");
874 assert(F &&
"Intrinsic call is not direct?");
885 Name = Name.substr(4);
886 bool IsNVVM = Name.startswith(
"nvvm.");
888 Name = Name.substr(5);
890 if (IsX86 && Name.startswith(
"sse4a.movnt.")) {
902 Type *SrcEltTy = cast<VectorType>(Arg1->
getType())->getElementType();
916 if (IsX86 && (Name.startswith(
"avx.movnt.") ||
917 Name.startswith(
"avx512.storent."))) {
941 if (IsX86 && Name ==
"sse2.storel.dq") {
958 if (IsX86 && (Name.startswith(
"sse.storeu.") ||
959 Name.startswith(
"sse2.storeu.") ||
960 Name.startswith(
"avx.storeu."))) {
974 if (IsX86 && (Name.startswith(
"avx512.mask.store"))) {
976 bool Aligned = Name[17] !=
'u';
987 if (IsX86 && (Name.startswith(
"sse2.pcmp") ||
988 Name.startswith(
"avx2.pcmp"))) {
990 bool CmpEq = Name[9] ==
'e';
994 }
else if (IsX86 && (Name ==
"sse.add.ss" || Name ==
"sse2.add.sd")) {
1003 }
else if (IsX86 && (Name ==
"sse.sub.ss" || Name ==
"sse2.sub.sd")) {
1012 }
else if (IsX86 && (Name ==
"sse.mul.ss" || Name ==
"sse2.mul.sd")) {
1021 }
else if (IsX86 && (Name ==
"sse.div.ss" || Name ==
"sse2.div.sd")) {
1030 }
else if (IsX86 && Name.startswith(
"avx512.mask.pcmp")) {
1032 bool CmpEq = Name[16] ==
'e';
1034 }
else if (IsX86 && Name.startswith(
"avx512.mask.cmp")) {
1035 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
1037 }
else if (IsX86 && Name.startswith(
"avx512.mask.ucmp")) {
1038 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
1040 }
else if (IsX86 && (Name ==
"sse41.pmaxsb" ||
1041 Name ==
"sse2.pmaxs.w" ||
1042 Name ==
"sse41.pmaxsd" ||
1043 Name.startswith(
"avx2.pmaxs") ||
1044 Name.startswith(
"avx512.mask.pmaxs"))) {
1046 }
else if (IsX86 && (Name ==
"sse2.pmaxu.b" ||
1047 Name ==
"sse41.pmaxuw" ||
1048 Name ==
"sse41.pmaxud" ||
1049 Name.startswith(
"avx2.pmaxu") ||
1050 Name.startswith(
"avx512.mask.pmaxu"))) {
1052 }
else if (IsX86 && (Name ==
"sse41.pminsb" ||
1053 Name ==
"sse2.pmins.w" ||
1054 Name ==
"sse41.pminsd" ||
1055 Name.startswith(
"avx2.pmins") ||
1056 Name.startswith(
"avx512.mask.pmins"))) {
1058 }
else if (IsX86 && (Name ==
"sse2.pminu.b" ||
1059 Name ==
"sse41.pminuw" ||
1060 Name ==
"sse41.pminud" ||
1061 Name.startswith(
"avx2.pminu") ||
1062 Name.startswith(
"avx512.mask.pminu"))) {
1064 }
else if (IsX86 && (Name ==
"sse2.cvtdq2pd" ||
1065 Name ==
"sse2.cvtps2pd" ||
1066 Name ==
"avx.cvtdq2.pd.256" ||
1067 Name ==
"avx.cvt.ps2.pd.256" ||
1068 Name.startswith(
"avx512.mask.cvtdq2pd.") ||
1069 Name.startswith(
"avx512.mask.cvtudq2pd."))) {
1077 unsigned NumDstElts = DstTy->getNumElements();
1078 if (NumDstElts < SrcTy->getNumElements()) {
1079 assert(NumDstElts == 2 &&
"Unexpected vector size");
1080 uint32_t ShuffleMask[2] = { 0, 1 };
1089 else if (UInt2Double)
1092 Rep = Builder.
CreateFPExt(Rep, DstTy,
"cvtps2pd");
1097 }
else if (IsX86 && (Name.startswith(
"avx512.mask.loadu."))) {
1101 }
else if (IsX86 && (Name.startswith(
"avx512.mask.load."))) {
1105 }
else if (IsX86 && Name.startswith(
"xop.vpcom")) {
1107 if (Name.endswith(
"ub"))
1108 intID = Intrinsic::x86_xop_vpcomub;
1109 else if (Name.endswith(
"uw"))
1110 intID = Intrinsic::x86_xop_vpcomuw;
1111 else if (Name.endswith(
"ud"))
1112 intID = Intrinsic::x86_xop_vpcomud;
1113 else if (Name.endswith(
"uq"))
1114 intID = Intrinsic::x86_xop_vpcomuq;
1115 else if (Name.endswith(
"b"))
1116 intID = Intrinsic::x86_xop_vpcomb;
1117 else if (Name.endswith(
"w"))
1118 intID = Intrinsic::x86_xop_vpcomw;
1119 else if (Name.endswith(
"d"))
1120 intID = Intrinsic::x86_xop_vpcomd;
1121 else if (Name.endswith(
"q"))
1122 intID = Intrinsic::x86_xop_vpcomq;
1126 Name = Name.substr(9);
1128 if (Name.startswith(
"lt"))
1130 else if (Name.startswith(
"le"))
1132 else if (Name.startswith(
"gt"))
1134 else if (Name.startswith(
"ge"))
1136 else if (Name.startswith(
"eq"))
1138 else if (Name.startswith(
"ne"))
1140 else if (Name.startswith(
"false"))
1142 else if (Name.startswith(
"true"))
1151 }
else if (IsX86 && Name.startswith(
"xop.vpcmov")) {
1156 Rep = Builder.
CreateOr(Sel0, Sel1);
1157 }
else if (IsX86 && Name ==
"sse42.crc32.64.8") {
1159 Intrinsic::x86_sse42_crc32_32_8);
1163 }
else if (IsX86 && Name.startswith(
"avx.vbroadcast.s")) {
1173 for (
unsigned I = 0;
I < EltNum; ++
I)
1176 }
else if (IsX86 && (Name.startswith(
"sse41.pmovsx") ||
1177 Name.startswith(
"sse41.pmovzx") ||
1178 Name.startswith(
"avx2.pmovsx") ||
1179 Name.startswith(
"avx2.pmovzx") ||
1180 Name.startswith(
"avx512.mask.pmovsx") ||
1181 Name.startswith(
"avx512.mask.pmovzx"))) {
1188 for (
unsigned i = 0; i != NumDstElts; ++i)
1201 }
else if (IsX86 && (Name.startswith(
"avx.vbroadcastf128") ||
1202 Name ==
"avx2.vbroadcasti128")) {
1210 if (NumSrcElts == 2)
1215 { 0, 1, 2, 3, 0, 1, 2, 3 });
1216 }
else if (IsX86 && (Name.startswith(
"avx2.pbroadcast") ||
1217 Name.startswith(
"avx2.vbroadcast") ||
1218 Name.startswith(
"avx512.pbroadcast") ||
1219 Name.startswith(
"avx512.mask.broadcast.s"))) {
1230 }
else if (IsX86 && Name.startswith(
"avx512.mask.palignr.")) {
1237 }
else if (IsX86 && Name.startswith(
"avx512.mask.valign.")) {
1244 }
else if (IsX86 && (Name ==
"sse2.psll.dq" ||
1245 Name ==
"avx2.psll.dq")) {
1247 unsigned Shift = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
1250 }
else if (IsX86 && (Name ==
"sse2.psrl.dq" ||
1251 Name ==
"avx2.psrl.dq")) {
1253 unsigned Shift = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
1256 }
else if (IsX86 && (Name ==
"sse2.psll.dq.bs" ||
1257 Name ==
"avx2.psll.dq.bs" ||
1258 Name ==
"avx512.psll.dq.512")) {
1260 unsigned Shift = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
1262 }
else if (IsX86 && (Name ==
"sse2.psrl.dq.bs" ||
1263 Name ==
"avx2.psrl.dq.bs" ||
1264 Name ==
"avx512.psrl.dq.512")) {
1266 unsigned Shift = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
1268 }
else if (IsX86 && (Name ==
"sse41.pblendw" ||
1269 Name.startswith(
"sse41.blendp") ||
1270 Name.startswith(
"avx.blend.p") ||
1271 Name ==
"avx2.pblendw" ||
1272 Name.startswith(
"avx2.pblendd."))) {
1275 unsigned Imm = cast <ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
1280 for (
unsigned i = 0; i != NumElts; ++i)
1281 Idxs[i] = ((Imm >> (i%8)) & 1) ? i + NumElts : i;
1284 }
else if (IsX86 && (Name.startswith(
"avx.vinsertf128.") ||
1285 Name ==
"avx2.vinserti128" ||
1286 Name.startswith(
"avx512.mask.insert"))) {
1289 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
1292 unsigned Scale = DstNumElts / SrcNumElts;
1300 for (
unsigned i = 0; i != SrcNumElts; ++i)
1302 for (
unsigned i = SrcNumElts; i != DstNumElts; ++i)
1303 Idxs[i] = SrcNumElts;
1318 for (
unsigned i = 0; i != DstNumElts; ++i)
1321 for (
unsigned i = 0; i != SrcNumElts; ++i)
1322 Idxs[i + Imm * SrcNumElts] = i + DstNumElts;
1329 }
else if (IsX86 && (Name.startswith(
"avx.vextractf128.") ||
1330 Name ==
"avx2.vextracti128" ||
1331 Name.startswith(
"avx512.mask.vextract"))) {
1333 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
1336 unsigned Scale = SrcNumElts / DstNumElts;
1343 for (
unsigned i = 0; i != DstNumElts; ++i) {
1344 Idxs[i] = i + (Imm * DstNumElts);
1352 }
else if (!IsX86 && Name ==
"stackprotectorcheck") {
1354 }
else if (IsX86 && (Name.startswith(
"avx512.mask.perm.df.") ||
1355 Name.startswith(
"avx512.mask.perm.di."))) {
1357 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
1362 for (
unsigned i = 0; i != NumElts; ++i)
1363 Idxs[i] = (i & ~0x3) + ((Imm >> (2 * (i & 0x3))) & 3);
1370 }
else if (IsX86 && (Name.startswith(
"avx.vpermil.") ||
1371 Name ==
"sse2.pshuf.d" ||
1372 Name.startswith(
"avx512.mask.vpermil.p") ||
1373 Name.startswith(
"avx512.mask.pshuf.d."))) {
1375 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
1380 unsigned IdxMask = ((1 << IdxSize) - 1);
1386 for (
unsigned i = 0; i != NumElts; ++i)
1387 Idxs[i] = ((Imm >> ((i * IdxSize) % 8)) & IdxMask) | (i & ~IdxMask);
1394 }
else if (IsX86 && (Name ==
"sse2.pshufl.w" ||
1395 Name.startswith(
"avx512.mask.pshufl.w."))) {
1397 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
1401 for (
unsigned l = 0; l != NumElts; l += 8) {
1402 for (
unsigned i = 0; i != 4; ++i)
1403 Idxs[i + l] = ((Imm >> (2 * i)) & 0x3) + l;
1404 for (
unsigned i = 4; i != 8; ++i)
1405 Idxs[i + l] = i + l;
1413 }
else if (IsX86 && (Name ==
"sse2.pshufh.w" ||
1414 Name.startswith(
"avx512.mask.pshufh.w."))) {
1416 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
1420 for (
unsigned l = 0; l != NumElts; l += 8) {
1421 for (
unsigned i = 0; i != 4; ++i)
1422 Idxs[i + l] = i + l;
1423 for (
unsigned i = 0; i != 4; ++i)
1424 Idxs[i + l + 4] = ((Imm >> (2 * i)) & 0x3) + 4 + l;
1432 }
else if (IsX86 && Name.startswith(
"avx512.mask.shuf.p")) {
1435 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
1439 unsigned HalfLaneElts = NumLaneElts / 2;
1442 for (
unsigned i = 0; i != NumElts; ++i) {
1444 Idxs[i] = i - (i % NumLaneElts);
1446 if ((i % NumLaneElts) >= HalfLaneElts)
1450 Idxs[i] += (Imm >> ((i * HalfLaneElts) % 8)) & ((1 << HalfLaneElts) - 1);
1457 }
else if (IsX86 && (Name.startswith(
"avx512.mask.movddup") ||
1458 Name.startswith(
"avx512.mask.movshdup") ||
1459 Name.startswith(
"avx512.mask.movsldup"))) {
1465 if (Name.startswith(
"avx512.mask.movshdup."))
1469 for (
unsigned l = 0; l != NumElts; l += NumLaneElts)
1470 for (
unsigned i = 0; i != NumLaneElts; i += 2) {
1471 Idxs[i + l + 0] = i + l +
Offset;
1472 Idxs[i + l + 1] = i + l +
Offset;
1479 }
else if (IsX86 && (Name.startswith(
"avx512.mask.punpckl") ||
1480 Name.startswith(
"avx512.mask.unpckl."))) {
1487 for (
int l = 0; l != NumElts; l += NumLaneElts)
1488 for (
int i = 0; i != NumLaneElts; ++i)
1489 Idxs[i + l] = l + (i / 2) + NumElts * (i % 2);
1495 }
else if (IsX86 && (Name.startswith(
"avx512.mask.punpckh") ||
1496 Name.startswith(
"avx512.mask.unpckh."))) {
1503 for (
int l = 0; l != NumElts; l += NumLaneElts)
1504 for (
int i = 0; i != NumLaneElts; ++i)
1505 Idxs[i + l] = (NumLaneElts / 2) + l + (i / 2) + NumElts * (i % 2);
1511 }
else if (IsX86 && Name.startswith(
"avx512.mask.pand.")) {
1515 }
else if (IsX86 && Name.startswith(
"avx512.mask.pandn.")) {
1520 }
else if (IsX86 && Name.startswith(
"avx512.mask.por.")) {
1524 }
else if (IsX86 && Name.startswith(
"avx512.mask.pxor.")) {
1528 }
else if (IsX86 && Name.startswith(
"avx512.mask.and.")) {
1536 }
else if (IsX86 && Name.startswith(
"avx512.mask.andn.")) {
1545 }
else if (IsX86 && Name.startswith(
"avx512.mask.or.")) {
1553 }
else if (IsX86 && Name.startswith(
"avx512.mask.xor.")) {
1561 }
else if (IsX86 && Name.startswith(
"avx512.mask.padd.")) {
1565 }
else if (IsX86 && Name.startswith(
"avx512.mask.psub.")) {
1569 }
else if (IsX86 && Name.startswith(
"avx512.mask.pmull.")) {
1573 }
else if (IsX86 && (Name.startswith(
"avx512.mask.add.p"))) {
1577 }
else if (IsX86 && Name.startswith(
"avx512.mask.div.p")) {
1581 }
else if (IsX86 && Name.startswith(
"avx512.mask.mul.p")) {
1585 }
else if (IsX86 && Name.startswith(
"avx512.mask.sub.p")) {
1589 }
else if (IsX86 && Name.startswith(
"avx512.mask.lzcnt.")) {
1596 }
else if (IsX86 && (Name.startswith(
"avx512.mask.max.p") ||
1597 Name.startswith(
"avx512.mask.min.p"))) {
1598 bool IsMin = Name[13] ==
'i';
1603 if (!IsMin && VecWidth == 128 && EltWidth == 32)
1604 IID = Intrinsic::x86_sse_max_ps;
1605 else if (!IsMin && VecWidth == 128 && EltWidth == 64)
1606 IID = Intrinsic::x86_sse2_max_pd;
1607 else if (!IsMin && VecWidth == 256 && EltWidth == 32)
1608 IID = Intrinsic::x86_avx_max_ps_256;
1609 else if (!IsMin && VecWidth == 256 && EltWidth == 64)
1610 IID = Intrinsic::x86_avx_max_pd_256;
1611 else if (IsMin && VecWidth == 128 && EltWidth == 32)
1612 IID = Intrinsic::x86_sse_min_ps;
1613 else if (IsMin && VecWidth == 128 && EltWidth == 64)
1614 IID = Intrinsic::x86_sse2_min_pd;
1615 else if (IsMin && VecWidth == 256 && EltWidth == 32)
1616 IID = Intrinsic::x86_avx_min_ps_256;
1617 else if (IsMin && VecWidth == 256 && EltWidth == 64)
1618 IID = Intrinsic::x86_avx_min_pd_256;
1626 }
else if (IsX86 && Name.startswith(
"avx512.mask.pshuf.b.")) {
1630 IID = Intrinsic::x86_ssse3_pshuf_b_128;
1632 IID = Intrinsic::x86_avx2_pshuf_b;
1634 IID = Intrinsic::x86_avx512_pshuf_b_512;
1642 }
else if (IsX86 && (Name.startswith(
"avx512.mask.pmul.dq.") ||
1643 Name.startswith(
"avx512.mask.pmulu.dq."))) {
1644 bool IsUnsigned = Name[16] ==
'u';
1648 IID = Intrinsic::x86_sse41_pmuldq;
1650 IID = Intrinsic::x86_avx2_pmul_dq;
1652 IID = Intrinsic::x86_avx512_pmul_dq_512;
1654 IID = Intrinsic::x86_sse2_pmulu_dq;
1656 IID = Intrinsic::x86_avx2_pmulu_dq;
1658 IID = Intrinsic::x86_avx512_pmulu_dq_512;
1666 }
else if (IsX86 && Name.startswith(
"avx512.mask.pack")) {
1667 bool IsUnsigned = Name[16] ==
'u';
1668 bool IsDW = Name[18] ==
'd';
1672 IID = Intrinsic::x86_sse2_packsswb_128;
1674 IID = Intrinsic::x86_avx2_packsswb;
1676 IID = Intrinsic::x86_avx512_packsswb_512;
1678 IID = Intrinsic::x86_sse2_packssdw_128;
1680 IID = Intrinsic::x86_avx2_packssdw;
1682 IID = Intrinsic::x86_avx512_packssdw_512;
1684 IID = Intrinsic::x86_sse2_packuswb_128;
1686 IID = Intrinsic::x86_avx2_packuswb;
1688 IID = Intrinsic::x86_avx512_packuswb_512;
1690 IID = Intrinsic::x86_sse41_packusdw;
1692 IID = Intrinsic::x86_avx2_packusdw;
1694 IID = Intrinsic::x86_avx512_packusdw_512;
1702 }
else if (IsX86 && Name.startswith(
"avx512.mask.psll")) {
1703 bool IsImmediate = Name[16] ==
'i' ||
1704 (Name.size() > 18 && Name[18] ==
'i');
1705 bool IsVariable = Name[16] ==
'v';
1706 char Size = Name[16] ==
'.' ? Name[17] :
1707 Name[17] ==
'.' ? Name[18] :
1708 Name[18] ==
'.' ? Name[19] :
1712 if (IsVariable && Name[17] !=
'.') {
1713 if (Size ==
'd' && Name[17] ==
'2')
1714 IID = Intrinsic::x86_avx2_psllv_q;
1715 else if (Size ==
'd' && Name[17] ==
'4')
1716 IID = Intrinsic::x86_avx2_psllv_q_256;
1717 else if (Size ==
's' && Name[17] ==
'4')
1718 IID = Intrinsic::x86_avx2_psllv_d;
1719 else if (Size ==
's' && Name[17] ==
'8')
1720 IID = Intrinsic::x86_avx2_psllv_d_256;
1721 else if (Size ==
'h' && Name[17] ==
'8')
1722 IID = Intrinsic::x86_avx512_psllv_w_128;
1723 else if (Size ==
'h' && Name[17] ==
'1')
1724 IID = Intrinsic::x86_avx512_psllv_w_256;
1725 else if (Name[17] ==
'3' && Name[18] ==
'2')
1726 IID = Intrinsic::x86_avx512_psllv_w_512;
1729 }
else if (Name.endswith(
".128")) {
1731 IID = IsImmediate ? Intrinsic::x86_sse2_pslli_d
1732 : Intrinsic::x86_sse2_psll_d;
1733 else if (Size ==
'q')
1734 IID = IsImmediate ? Intrinsic::x86_sse2_pslli_q
1735 : Intrinsic::x86_sse2_psll_q;
1736 else if (Size ==
'w')
1737 IID = IsImmediate ? Intrinsic::x86_sse2_pslli_w
1738 : Intrinsic::x86_sse2_psll_w;
1741 }
else if (Name.endswith(
".256")) {
1743 IID = IsImmediate ? Intrinsic::x86_avx2_pslli_d
1744 : Intrinsic::x86_avx2_psll_d;
1745 else if (Size ==
'q')
1746 IID = IsImmediate ? Intrinsic::x86_avx2_pslli_q
1747 : Intrinsic::x86_avx2_psll_q;
1748 else if (Size ==
'w')
1749 IID = IsImmediate ? Intrinsic::x86_avx2_pslli_w
1750 : Intrinsic::x86_avx2_psll_w;
1755 IID = IsImmediate ? Intrinsic::x86_avx512_pslli_d_512 :
1756 IsVariable ? Intrinsic::x86_avx512_psllv_d_512 :
1757 Intrinsic::x86_avx512_psll_d_512;
1758 else if (Size ==
'q')
1759 IID = IsImmediate ? Intrinsic::x86_avx512_pslli_q_512 :
1760 IsVariable ? Intrinsic::x86_avx512_psllv_q_512 :
1761 Intrinsic::x86_avx512_psll_q_512;
1762 else if (Size ==
'w')
1763 IID = IsImmediate ? Intrinsic::x86_avx512_pslli_w_512
1764 : Intrinsic::x86_avx512_psll_w_512;
1770 }
else if (IsX86 && Name.startswith(
"avx512.mask.psrl")) {
1771 bool IsImmediate = Name[16] ==
'i' ||
1772 (Name.size() > 18 && Name[18] ==
'i');
1773 bool IsVariable = Name[16] ==
'v';
1774 char Size = Name[16] ==
'.' ? Name[17] :
1775 Name[17] ==
'.' ? Name[18] :
1776 Name[18] ==
'.' ? Name[19] :
1780 if (IsVariable && Name[17] !=
'.') {
1781 if (Size ==
'd' && Name[17] ==
'2')
1782 IID = Intrinsic::x86_avx2_psrlv_q;
1783 else if (Size ==
'd' && Name[17] ==
'4')
1784 IID = Intrinsic::x86_avx2_psrlv_q_256;
1785 else if (Size ==
's' && Name[17] ==
'4')
1786 IID = Intrinsic::x86_avx2_psrlv_d;
1787 else if (Size ==
's' && Name[17] ==
'8')
1788 IID = Intrinsic::x86_avx2_psrlv_d_256;
1789 else if (Size ==
'h' && Name[17] ==
'8')
1790 IID = Intrinsic::x86_avx512_psrlv_w_128;
1791 else if (Size ==
'h' && Name[17] ==
'1')
1792 IID = Intrinsic::x86_avx512_psrlv_w_256;
1793 else if (Name[17] ==
'3' && Name[18] ==
'2')
1794 IID = Intrinsic::x86_avx512_psrlv_w_512;
1797 }
else if (Name.endswith(
".128")) {
1799 IID = IsImmediate ? Intrinsic::x86_sse2_psrli_d
1800 : Intrinsic::x86_sse2_psrl_d;
1801 else if (Size ==
'q')
1802 IID = IsImmediate ? Intrinsic::x86_sse2_psrli_q
1803 : Intrinsic::x86_sse2_psrl_q;
1804 else if (Size ==
'w')
1805 IID = IsImmediate ? Intrinsic::x86_sse2_psrli_w
1806 : Intrinsic::x86_sse2_psrl_w;
1809 }
else if (Name.endswith(
".256")) {
1811 IID = IsImmediate ? Intrinsic::x86_avx2_psrli_d
1812 : Intrinsic::x86_avx2_psrl_d;
1813 else if (Size ==
'q')
1814 IID = IsImmediate ? Intrinsic::x86_avx2_psrli_q
1815 : Intrinsic::x86_avx2_psrl_q;
1816 else if (Size ==
'w')
1817 IID = IsImmediate ? Intrinsic::x86_avx2_psrli_w
1818 : Intrinsic::x86_avx2_psrl_w;
1823 IID = IsImmediate ? Intrinsic::x86_avx512_psrli_d_512 :
1824 IsVariable ? Intrinsic::x86_avx512_psrlv_d_512 :
1825 Intrinsic::x86_avx512_psrl_d_512;
1826 else if (Size ==
'q')
1827 IID = IsImmediate ? Intrinsic::x86_avx512_psrli_q_512 :
1828 IsVariable ? Intrinsic::x86_avx512_psrlv_q_512 :
1829 Intrinsic::x86_avx512_psrl_q_512;
1830 else if (Size ==
'w')
1831 IID = IsImmediate ? Intrinsic::x86_avx512_psrli_w_512
1832 : Intrinsic::x86_avx512_psrl_w_512;
1838 }
else if (IsX86 && Name.startswith(
"avx512.mask.psra")) {
1839 bool IsImmediate = Name[16] ==
'i' ||
1840 (Name.size() > 18 && Name[18] ==
'i');
1841 bool IsVariable = Name[16] ==
'v';
1842 char Size = Name[16] ==
'.' ? Name[17] :
1843 Name[17] ==
'.' ? Name[18] :
1844 Name[18] ==
'.' ? Name[19] :
1848 if (IsVariable && Name[17] !=
'.') {
1849 if (Size ==
's' && Name[17] ==
'4')
1850 IID = Intrinsic::x86_avx2_psrav_d;
1851 else if (Size ==
's' && Name[17] ==
'8')
1852 IID = Intrinsic::x86_avx2_psrav_d_256;
1853 else if (Size ==
'h' && Name[17] ==
'8')
1854 IID = Intrinsic::x86_avx512_psrav_w_128;
1855 else if (Size ==
'h' && Name[17] ==
'1')
1856 IID = Intrinsic::x86_avx512_psrav_w_256;
1857 else if (Name[17] ==
'3' && Name[18] ==
'2')
1858 IID = Intrinsic::x86_avx512_psrav_w_512;
1861 }
else if (Name.endswith(
".128")) {
1863 IID = IsImmediate ? Intrinsic::x86_sse2_psrai_d
1864 : Intrinsic::x86_sse2_psra_d;
1865 else if (Size ==
'q')
1866 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_q_128 :
1867 IsVariable ? Intrinsic::x86_avx512_psrav_q_128 :
1868 Intrinsic::x86_avx512_psra_q_128;
1869 else if (Size ==
'w')
1870 IID = IsImmediate ? Intrinsic::x86_sse2_psrai_w
1871 : Intrinsic::x86_sse2_psra_w;
1874 }
else if (Name.endswith(
".256")) {
1876 IID = IsImmediate ? Intrinsic::x86_avx2_psrai_d
1877 : Intrinsic::x86_avx2_psra_d;
1878 else if (Size ==
'q')
1879 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_q_256 :
1880 IsVariable ? Intrinsic::x86_avx512_psrav_q_256 :
1881 Intrinsic::x86_avx512_psra_q_256;
1882 else if (Size ==
'w')
1883 IID = IsImmediate ? Intrinsic::x86_avx2_psrai_w
1884 : Intrinsic::x86_avx2_psra_w;
1889 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_d_512 :
1890 IsVariable ? Intrinsic::x86_avx512_psrav_d_512 :
1891 Intrinsic::x86_avx512_psra_d_512;
1892 else if (Size ==
'q')
1893 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_q_512 :
1894 IsVariable ? Intrinsic::x86_avx512_psrav_q_512 :
1895 Intrinsic::x86_avx512_psra_q_512;
1896 else if (Size ==
'w')
1897 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_w_512
1898 : Intrinsic::x86_avx512_psra_w_512;
1904 }
else if (IsX86 && Name.startswith(
"avx512.mask.move.s")) {
1906 }
else if (IsX86 && Name.startswith(
"avx512.cvtmask2")) {
1908 }
else if (IsX86 && Name.startswith(
"avx512.mask.vpermilvar.")) {
1910 if (Name.endswith(
"ps.128"))
1911 IID = Intrinsic::x86_avx_vpermilvar_ps;
1912 else if (Name.endswith(
"pd.128"))
1913 IID = Intrinsic::x86_avx_vpermilvar_pd;
1914 else if (Name.endswith(
"ps.256"))
1915 IID = Intrinsic::x86_avx_vpermilvar_ps_256;
1916 else if (Name.endswith(
"pd.256"))
1917 IID = Intrinsic::x86_avx_vpermilvar_pd_256;
1918 else if (Name.endswith(
"ps.512"))
1919 IID = Intrinsic::x86_avx512_vpermilvar_ps_512;
1920 else if (Name.endswith(
"pd.512"))
1921 IID = Intrinsic::x86_avx512_vpermilvar_pd_512;
1930 }
else if (IsX86 && Name.endswith(
".movntdqa")) {
1944 }
else if (IsNVVM && (Name ==
"abs.i" || Name ==
"abs.ll")) {
1950 }
else if (IsNVVM && (Name ==
"max.i" || Name ==
"max.ll" ||
1951 Name ==
"max.ui" || Name ==
"max.ull")) {
1954 Value *Cmp = Name.endswith(
".ui") || Name.endswith(
".ull")
1958 }
else if (IsNVVM && (Name ==
"min.i" || Name ==
"min.ll" ||
1959 Name ==
"min.ui" || Name ==
"min.ull")) {
1962 Value *Cmp = Name.endswith(
".ui") || Name.endswith(
".ull")
1966 }
else if (IsNVVM && Name ==
"clz.ll") {
1972 {Arg, Builder.
getFalse()},
"ctlz");
1974 }
else if (IsNVVM && Name ==
"popc.ll") {
1983 }
else if (IsNVVM && Name ==
"h2f") {
1985 F->
getParent(), Intrinsic::convert_from_fp16,
2004 "Unknown function for CallInst upgrade and isn't just a name change");
2009 case Intrinsic::arm_neon_vld1:
2010 case Intrinsic::arm_neon_vld2:
2011 case Intrinsic::arm_neon_vld3:
2012 case Intrinsic::arm_neon_vld4:
2013 case Intrinsic::arm_neon_vld2lane:
2014 case Intrinsic::arm_neon_vld3lane:
2015 case Intrinsic::arm_neon_vld4lane:
2016 case Intrinsic::arm_neon_vst1:
2017 case Intrinsic::arm_neon_vst2:
2018 case Intrinsic::arm_neon_vst3:
2019 case Intrinsic::arm_neon_vst4:
2020 case Intrinsic::arm_neon_vst2lane:
2021 case Intrinsic::arm_neon_vst3lane:
2022 case Intrinsic::arm_neon_vst4lane: {
2029 case Intrinsic::bitreverse:
2033 case Intrinsic::ctlz:
2034 case Intrinsic::cttz:
2036 "Mismatch between function args and call args");
2041 case Intrinsic::objectsize: {
2050 case Intrinsic::ctpop:
2054 case Intrinsic::convert_from_fp16:
2058 case Intrinsic::x86_xop_vfrcz_ss:
2059 case Intrinsic::x86_xop_vfrcz_sd:
2063 case Intrinsic::x86_xop_vpermil2pd:
2064 case Intrinsic::x86_xop_vpermil2ps:
2065 case Intrinsic::x86_xop_vpermil2pd_256:
2066 case Intrinsic::x86_xop_vpermil2ps_256: {
2076 case Intrinsic::x86_sse41_ptestc:
2077 case Intrinsic::x86_sse41_ptestz:
2078 case Intrinsic::x86_sse41_ptestnzc: {
2095 NewCall = Builder.
CreateCall(NewFn, {BC0, BC1});
2099 case Intrinsic::x86_sse41_insertps:
2100 case Intrinsic::x86_sse41_dppd:
2101 case Intrinsic::x86_sse41_dpps:
2102 case Intrinsic::x86_sse41_mpsadbw:
2103 case Intrinsic::x86_avx_dp_ps_256:
2104 case Intrinsic::x86_avx2_mpsadbw: {
2116 case Intrinsic::thread_pointer: {
2121 case Intrinsic::invariant_start:
2122 case Intrinsic::invariant_end:
2123 case Intrinsic::masked_load:
2124 case Intrinsic::masked_store:
2125 case Intrinsic::masked_gather:
2126 case Intrinsic::masked_scatter: {
2133 assert(NewCall &&
"Should have either set this variable or returned through "
2134 "the default case");
2135 std::string Name = CI->
getName();
2136 if (!Name.empty()) {
2145 assert(F &&
"Illegal attempt to upgrade a non-existent intrinsic.");
2154 if (
CallInst *CI = dyn_cast<CallInst>(*UI++))
2172 Metadata *Elts2[] = {ScalarType, ScalarType,
2186 if (Opc != Instruction::BitCast)
2207 if (Opc != Instruction::BitCast)
2246 bool HasObjCFlag =
false, HasClassProperties =
false, Changed =
false;
2254 if (ID->
getString() ==
"Objective-C Image Info Version")
2256 if (ID->
getString() ==
"Objective-C Class Properties")
2257 HasClassProperties =
true;
2261 if (
auto *Behavior =
2262 mdconst::dyn_extract_or_null<ConstantInt>(Op->
getOperand(0))) {
2281 if (HasObjCFlag && !HasClassProperties) {
2291 auto *
T = dyn_cast_or_null<MDTuple>(MD);
2294 if (
T->getNumOperands() < 1)
2296 auto *S = dyn_cast_or_null<MDString>(
T->getOperand(0));
2299 return S->getString().startswith(
"llvm.vectorizer.");
2303 StringRef OldPrefix =
"llvm.vectorizer.";
2306 if (OldTag ==
"llvm.vectorizer.unroll")
2315 auto *
T = dyn_cast_or_null<MDTuple>(MD);
2318 if (
T->getNumOperands() < 1)
2320 auto *OldTag = dyn_cast_or_null<MDString>(
T->getOperand(0));
2323 if (!OldTag->getString().startswith(
"llvm.vectorizer."))
2330 for (
unsigned I = 1,
E =
T->getNumOperands();
I !=
E; ++
I)
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
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. ...
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
Value * CreateIsNotNull(Value *Arg, const Twine &Name="")
Return an i1 value testing if Arg is not null.
Takes the max of the two values, which are required to be integers.
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.
static MDString * get(LLVMContext &Context, StringRef Str)
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
static Constant * getIntToPtr(Constant *C, Type *Ty, bool OnlyIfReduced=false)
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.
Value * CreateSExt(Value *V, Type *DestTy, const Twine &Name="")
An instruction for reading from memory.
static IntegerType * getInt64Ty(LLVMContext &C)
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)
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)
IntegerType * getInt32Ty()
Fetch the type representing a 32-bit integer.
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.
static bool ShouldUpgradeX86Intrinsic(Function *F, StringRef Name)
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.
LLVM_ATTRIBUTE_ALWAYS_INLINE R Default(const T &Value) const
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)
static Value * UpgradeMaskToInt(IRBuilder<> &Builder, CallInst &CI)
void setName(const Twine &Name)
Change the name of the value.
Type * getVectorElementType() const
static Metadata * upgradeLoopArgument(Metadata *MD)
AttributeList getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
llvm::Optional< Function * > remangleIntrinsicFunction(Function *F)
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & Case(const char(&S)[N], const T &Value)
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.
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="")
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)
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)
A switch()-like statement whose cases are string literals.
Type * getReturnType() const
Returns the type of the ret val.
Type * getParamType(unsigned i) const
Parameter type accessors.
Emits an error if two values disagree, otherwise the resulting value is that of the operands...
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)
Return 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.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
ConstantInt * getInt1(bool V)
Get a constant value representing either true or false.
This is an important base class in LLVM.
void getModuleFlagsMetadata(SmallVectorImpl< ModuleFlagEntry > &Flags) const
Returns the module flags in the provided vector.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
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.
Value * CreateNeg(Value *V, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
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
Value * CreateICmpSGE(Value *LHS, Value *RHS, const Twine &Name="")
uint64_t getNumElements() const
self_iterator getIterator()
Value * CreateExtractElement(Value *Vec, Value *Idx, const Twine &Name="")
static Constant * getAllOnesValue(Type *Ty)
Get the all ones value.
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.
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 UpgradeX86IntrinsicFunction(Function *F, StringRef Name, Function *&NewFn)
Value * CreateUIToFP(Value *V, Type *DestTy, const Twine &Name="")
static Value * getX86MaskVec(IRBuilder<> &Builder, Value *Mask, unsigned NumElts)
StringRef getString() const
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...
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)
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)
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.
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
Value * CreatePointerCast(Value *V, Type *DestTy, const Twine &Name="")
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
ConstantInt * getFalse()
Get the constant value for i1 false.
llvm_unreachable("Unknown RegBank!")
IntegerType * getInt1Ty()
Fetch the type representing a single bit.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
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 ...
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & Cases(const char(&S0)[N0], const char(&S1)[N1], const T &Value)
void setCalledFunction(Value *Fn)
Set the function called.
static bool isOldLoopArgument(Metadata *MD)
static IntegerType * getInt32Ty(LLVMContext &C)
unsigned greater or equal
static Constant * getPtrToInt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
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)
static Value * upgradeMaskedCompare(IRBuilder<> &Builder, CallInst &CI, unsigned CC, bool Signed)
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it...
LLVMContext & getContext() const
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 * CreateAnd(Value *LHS, Value *RHS, const Twine &Name="")
static bool UpgradePTESTIntrinsic(Function *F, Intrinsic::ID IID, Function *&NewFn)
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.
Value * CreateICmpSLE(Value *LHS, Value *RHS, const Twine &Name="")
static IntegerType * getInt8Ty(LLVMContext &C)
const BasicBlock * getParent() const
LLVMContext & getContext() const
Get the global data context.