31#include "llvm/IR/IntrinsicsAArch64.h"
32#include "llvm/IR/IntrinsicsARM.h"
33#include "llvm/IR/IntrinsicsNVPTX.h"
34#include "llvm/IR/IntrinsicsRISCV.h"
35#include "llvm/IR/IntrinsicsWebAssembly.h"
36#include "llvm/IR/IntrinsicsX86.h"
55 cl::desc(
"Disable autoupgrade of debug info"));
65 Type *Arg0Type =
F->getFunctionType()->getParamType(0);
80 Type *LastArgType =
F->getFunctionType()->getParamType(
81 F->getFunctionType()->getNumParams() - 1);
96 if (
F->getReturnType()->isVectorTy())
106 if (
F->getReturnType()->getScalarType()->isBFloatTy())
116 if (
F->getFunctionType()->getParamType(1)->getScalarType()->isBFloatTy())
130 if (
Name.consume_front(
"avx."))
131 return (
Name.starts_with(
"blend.p") ||
132 Name ==
"cvt.ps2.pd.256" ||
133 Name ==
"cvtdq2.pd.256" ||
134 Name ==
"cvtdq2.ps.256" ||
135 Name.starts_with(
"movnt.") ||
136 Name.starts_with(
"sqrt.p") ||
137 Name.starts_with(
"storeu.") ||
138 Name.starts_with(
"vbroadcast.s") ||
139 Name.starts_with(
"vbroadcastf128") ||
140 Name.starts_with(
"vextractf128.") ||
141 Name.starts_with(
"vinsertf128.") ||
142 Name.starts_with(
"vperm2f128.") ||
143 Name.starts_with(
"vpermil."));
145 if (
Name.consume_front(
"avx2."))
146 return (
Name ==
"movntdqa" ||
147 Name.starts_with(
"pabs.") ||
148 Name.starts_with(
"padds.") ||
149 Name.starts_with(
"paddus.") ||
150 Name.starts_with(
"pblendd.") ||
152 Name.starts_with(
"pbroadcast") ||
153 Name.starts_with(
"pcmpeq.") ||
154 Name.starts_with(
"pcmpgt.") ||
155 Name.starts_with(
"pmax") ||
156 Name.starts_with(
"pmin") ||
157 Name.starts_with(
"pmovsx") ||
158 Name.starts_with(
"pmovzx") ||
160 Name ==
"pmulu.dq" ||
161 Name.starts_with(
"psll.dq") ||
162 Name.starts_with(
"psrl.dq") ||
163 Name.starts_with(
"psubs.") ||
164 Name.starts_with(
"psubus.") ||
165 Name.starts_with(
"vbroadcast") ||
166 Name ==
"vbroadcasti128" ||
167 Name ==
"vextracti128" ||
168 Name ==
"vinserti128" ||
169 Name ==
"vperm2i128");
171 if (
Name.consume_front(
"avx512.")) {
172 if (
Name.consume_front(
"mask."))
174 return (
Name.starts_with(
"add.p") ||
175 Name.starts_with(
"and.") ||
176 Name.starts_with(
"andn.") ||
177 Name.starts_with(
"broadcast.s") ||
178 Name.starts_with(
"broadcastf32x4.") ||
179 Name.starts_with(
"broadcastf32x8.") ||
180 Name.starts_with(
"broadcastf64x2.") ||
181 Name.starts_with(
"broadcastf64x4.") ||
182 Name.starts_with(
"broadcasti32x4.") ||
183 Name.starts_with(
"broadcasti32x8.") ||
184 Name.starts_with(
"broadcasti64x2.") ||
185 Name.starts_with(
"broadcasti64x4.") ||
186 Name.starts_with(
"cmp.b") ||
187 Name.starts_with(
"cmp.d") ||
188 Name.starts_with(
"cmp.q") ||
189 Name.starts_with(
"cmp.w") ||
190 Name.starts_with(
"compress.b") ||
191 Name.starts_with(
"compress.d") ||
192 Name.starts_with(
"compress.p") ||
193 Name.starts_with(
"compress.q") ||
194 Name.starts_with(
"compress.store.") ||
195 Name.starts_with(
"compress.w") ||
196 Name.starts_with(
"conflict.") ||
197 Name.starts_with(
"cvtdq2pd.") ||
198 Name.starts_with(
"cvtdq2ps.") ||
199 Name ==
"cvtpd2dq.256" ||
200 Name ==
"cvtpd2ps.256" ||
201 Name ==
"cvtps2pd.128" ||
202 Name ==
"cvtps2pd.256" ||
203 Name.starts_with(
"cvtqq2pd.") ||
204 Name ==
"cvtqq2ps.256" ||
205 Name ==
"cvtqq2ps.512" ||
206 Name ==
"cvttpd2dq.256" ||
207 Name ==
"cvttps2dq.128" ||
208 Name ==
"cvttps2dq.256" ||
209 Name.starts_with(
"cvtudq2pd.") ||
210 Name.starts_with(
"cvtudq2ps.") ||
211 Name.starts_with(
"cvtuqq2pd.") ||
212 Name ==
"cvtuqq2ps.256" ||
213 Name ==
"cvtuqq2ps.512" ||
214 Name.starts_with(
"dbpsadbw.") ||
215 Name.starts_with(
"div.p") ||
216 Name.starts_with(
"expand.b") ||
217 Name.starts_with(
"expand.d") ||
218 Name.starts_with(
"expand.load.") ||
219 Name.starts_with(
"expand.p") ||
220 Name.starts_with(
"expand.q") ||
221 Name.starts_with(
"expand.w") ||
222 Name.starts_with(
"fpclass.p") ||
223 Name.starts_with(
"insert") ||
224 Name.starts_with(
"load.") ||
225 Name.starts_with(
"loadu.") ||
226 Name.starts_with(
"lzcnt.") ||
227 Name.starts_with(
"max.p") ||
228 Name.starts_with(
"min.p") ||
229 Name.starts_with(
"movddup") ||
230 Name.starts_with(
"move.s") ||
231 Name.starts_with(
"movshdup") ||
232 Name.starts_with(
"movsldup") ||
233 Name.starts_with(
"mul.p") ||
234 Name.starts_with(
"or.") ||
235 Name.starts_with(
"pabs.") ||
236 Name.starts_with(
"packssdw.") ||
237 Name.starts_with(
"packsswb.") ||
238 Name.starts_with(
"packusdw.") ||
239 Name.starts_with(
"packuswb.") ||
240 Name.starts_with(
"padd.") ||
241 Name.starts_with(
"padds.") ||
242 Name.starts_with(
"paddus.") ||
243 Name.starts_with(
"palignr.") ||
244 Name.starts_with(
"pand.") ||
245 Name.starts_with(
"pandn.") ||
246 Name.starts_with(
"pavg") ||
247 Name.starts_with(
"pbroadcast") ||
248 Name.starts_with(
"pcmpeq.") ||
249 Name.starts_with(
"pcmpgt.") ||
250 Name.starts_with(
"perm.df.") ||
251 Name.starts_with(
"perm.di.") ||
252 Name.starts_with(
"permvar.") ||
253 Name.starts_with(
"pmaddubs.w.") ||
254 Name.starts_with(
"pmaddw.d.") ||
255 Name.starts_with(
"pmax") ||
256 Name.starts_with(
"pmin") ||
257 Name ==
"pmov.qd.256" ||
258 Name ==
"pmov.qd.512" ||
259 Name ==
"pmov.wb.256" ||
260 Name ==
"pmov.wb.512" ||
261 Name.starts_with(
"pmovsx") ||
262 Name.starts_with(
"pmovzx") ||
263 Name.starts_with(
"pmul.dq.") ||
264 Name.starts_with(
"pmul.hr.sw.") ||
265 Name.starts_with(
"pmulh.w.") ||
266 Name.starts_with(
"pmulhu.w.") ||
267 Name.starts_with(
"pmull.") ||
268 Name.starts_with(
"pmultishift.qb.") ||
269 Name.starts_with(
"pmulu.dq.") ||
270 Name.starts_with(
"por.") ||
271 Name.starts_with(
"prol.") ||
272 Name.starts_with(
"prolv.") ||
273 Name.starts_with(
"pror.") ||
274 Name.starts_with(
"prorv.") ||
275 Name.starts_with(
"pshuf.b.") ||
276 Name.starts_with(
"pshuf.d.") ||
277 Name.starts_with(
"pshufh.w.") ||
278 Name.starts_with(
"pshufl.w.") ||
279 Name.starts_with(
"psll.d") ||
280 Name.starts_with(
"psll.q") ||
281 Name.starts_with(
"psll.w") ||
282 Name.starts_with(
"pslli") ||
283 Name.starts_with(
"psllv") ||
284 Name.starts_with(
"psra.d") ||
285 Name.starts_with(
"psra.q") ||
286 Name.starts_with(
"psra.w") ||
287 Name.starts_with(
"psrai") ||
288 Name.starts_with(
"psrav") ||
289 Name.starts_with(
"psrl.d") ||
290 Name.starts_with(
"psrl.q") ||
291 Name.starts_with(
"psrl.w") ||
292 Name.starts_with(
"psrli") ||
293 Name.starts_with(
"psrlv") ||
294 Name.starts_with(
"psub.") ||
295 Name.starts_with(
"psubs.") ||
296 Name.starts_with(
"psubus.") ||
297 Name.starts_with(
"pternlog.") ||
298 Name.starts_with(
"punpckh") ||
299 Name.starts_with(
"punpckl") ||
300 Name.starts_with(
"pxor.") ||
301 Name.starts_with(
"shuf.f") ||
302 Name.starts_with(
"shuf.i") ||
303 Name.starts_with(
"shuf.p") ||
304 Name.starts_with(
"sqrt.p") ||
305 Name.starts_with(
"store.b.") ||
306 Name.starts_with(
"store.d.") ||
307 Name.starts_with(
"store.p") ||
308 Name.starts_with(
"store.q.") ||
309 Name.starts_with(
"store.w.") ||
310 Name ==
"store.ss" ||
311 Name.starts_with(
"storeu.") ||
312 Name.starts_with(
"sub.p") ||
313 Name.starts_with(
"ucmp.") ||
314 Name.starts_with(
"unpckh.") ||
315 Name.starts_with(
"unpckl.") ||
316 Name.starts_with(
"valign.") ||
317 Name ==
"vcvtph2ps.128" ||
318 Name ==
"vcvtph2ps.256" ||
319 Name.starts_with(
"vextract") ||
320 Name.starts_with(
"vfmadd.") ||
321 Name.starts_with(
"vfmaddsub.") ||
322 Name.starts_with(
"vfnmadd.") ||
323 Name.starts_with(
"vfnmsub.") ||
324 Name.starts_with(
"vpdpbusd.") ||
325 Name.starts_with(
"vpdpbusds.") ||
326 Name.starts_with(
"vpdpwssd.") ||
327 Name.starts_with(
"vpdpwssds.") ||
328 Name.starts_with(
"vpermi2var.") ||
329 Name.starts_with(
"vpermil.p") ||
330 Name.starts_with(
"vpermilvar.") ||
331 Name.starts_with(
"vpermt2var.") ||
332 Name.starts_with(
"vpmadd52") ||
333 Name.starts_with(
"vpshld.") ||
334 Name.starts_with(
"vpshldv.") ||
335 Name.starts_with(
"vpshrd.") ||
336 Name.starts_with(
"vpshrdv.") ||
337 Name.starts_with(
"vpshufbitqmb.") ||
338 Name.starts_with(
"xor."));
340 if (
Name.consume_front(
"mask3."))
342 return (
Name.starts_with(
"vfmadd.") ||
343 Name.starts_with(
"vfmaddsub.") ||
344 Name.starts_with(
"vfmsub.") ||
345 Name.starts_with(
"vfmsubadd.") ||
346 Name.starts_with(
"vfnmsub."));
348 if (
Name.consume_front(
"maskz."))
350 return (
Name.starts_with(
"pternlog.") ||
351 Name.starts_with(
"vfmadd.") ||
352 Name.starts_with(
"vfmaddsub.") ||
353 Name.starts_with(
"vpdpbusd.") ||
354 Name.starts_with(
"vpdpbusds.") ||
355 Name.starts_with(
"vpdpwssd.") ||
356 Name.starts_with(
"vpdpwssds.") ||
357 Name.starts_with(
"vpermt2var.") ||
358 Name.starts_with(
"vpmadd52") ||
359 Name.starts_with(
"vpshldv.") ||
360 Name.starts_with(
"vpshrdv."));
363 return (
Name ==
"movntdqa" ||
364 Name ==
"pmul.dq.512" ||
365 Name ==
"pmulu.dq.512" ||
366 Name.starts_with(
"broadcastm") ||
367 Name.starts_with(
"cmp.p") ||
368 Name.starts_with(
"cvtb2mask.") ||
369 Name.starts_with(
"cvtd2mask.") ||
370 Name.starts_with(
"cvtmask2") ||
371 Name.starts_with(
"cvtq2mask.") ||
372 Name ==
"cvtusi2sd" ||
373 Name.starts_with(
"cvtw2mask.") ||
378 Name ==
"kortestc.w" ||
379 Name ==
"kortestz.w" ||
380 Name.starts_with(
"kunpck") ||
383 Name.starts_with(
"padds.") ||
384 Name.starts_with(
"pbroadcast") ||
385 Name.starts_with(
"prol") ||
386 Name.starts_with(
"pror") ||
387 Name.starts_with(
"psll.dq") ||
388 Name.starts_with(
"psrl.dq") ||
389 Name.starts_with(
"psubs.") ||
390 Name.starts_with(
"ptestm") ||
391 Name.starts_with(
"ptestnm") ||
392 Name.starts_with(
"storent.") ||
393 Name.starts_with(
"vbroadcast.s") ||
394 Name.starts_with(
"vpshld.") ||
395 Name.starts_with(
"vpshrd."));
398 if (
Name.consume_front(
"fma."))
399 return (
Name.starts_with(
"vfmadd.") ||
400 Name.starts_with(
"vfmsub.") ||
401 Name.starts_with(
"vfmsubadd.") ||
402 Name.starts_with(
"vfnmadd.") ||
403 Name.starts_with(
"vfnmsub."));
405 if (
Name.consume_front(
"fma4."))
406 return Name.starts_with(
"vfmadd.s");
408 if (
Name.consume_front(
"sse."))
409 return (
Name ==
"add.ss" ||
410 Name ==
"cvtsi2ss" ||
411 Name ==
"cvtsi642ss" ||
414 Name.starts_with(
"sqrt.p") ||
416 Name.starts_with(
"storeu.") ||
419 if (
Name.consume_front(
"sse2."))
420 return (
Name ==
"add.sd" ||
421 Name ==
"cvtdq2pd" ||
422 Name ==
"cvtdq2ps" ||
423 Name ==
"cvtps2pd" ||
424 Name ==
"cvtsi2sd" ||
425 Name ==
"cvtsi642sd" ||
426 Name ==
"cvtss2sd" ||
429 Name.starts_with(
"padds.") ||
430 Name.starts_with(
"paddus.") ||
431 Name.starts_with(
"pcmpeq.") ||
432 Name.starts_with(
"pcmpgt.") ||
437 Name ==
"pmulu.dq" ||
438 Name.starts_with(
"pshuf") ||
439 Name.starts_with(
"psll.dq") ||
440 Name.starts_with(
"psrl.dq") ||
441 Name.starts_with(
"psubs.") ||
442 Name.starts_with(
"psubus.") ||
443 Name.starts_with(
"sqrt.p") ||
445 Name ==
"storel.dq" ||
446 Name.starts_with(
"storeu.") ||
449 if (
Name.consume_front(
"sse41."))
450 return (
Name.starts_with(
"blendp") ||
451 Name ==
"movntdqa" ||
461 Name.starts_with(
"pmovsx") ||
462 Name.starts_with(
"pmovzx") ||
465 if (
Name.consume_front(
"sse42."))
466 return Name ==
"crc32.64.8";
468 if (
Name.consume_front(
"sse4a."))
469 return Name.starts_with(
"movnt.");
471 if (
Name.consume_front(
"ssse3."))
472 return (
Name ==
"pabs.b.128" ||
473 Name ==
"pabs.d.128" ||
474 Name ==
"pabs.w.128");
476 if (
Name.consume_front(
"xop."))
477 return (
Name ==
"vpcmov" ||
478 Name ==
"vpcmov.256" ||
479 Name.starts_with(
"vpcom") ||
480 Name.starts_with(
"vprot"));
482 return (
Name ==
"addcarry.u32" ||
483 Name ==
"addcarry.u64" ||
484 Name ==
"addcarryx.u32" ||
485 Name ==
"addcarryx.u64" ||
486 Name ==
"subborrow.u32" ||
487 Name ==
"subborrow.u64" ||
488 Name.starts_with(
"vcvtph2ps."));
494 if (!
Name.consume_front(
"x86."))
502 if (
Name ==
"rdtscp") {
504 if (
F->getFunctionType()->getNumParams() == 0)
509 Intrinsic::x86_rdtscp);
516 if (
Name.consume_front(
"sse41.ptest")) {
518 .
Case(
"c", Intrinsic::x86_sse41_ptestc)
519 .
Case(
"z", Intrinsic::x86_sse41_ptestz)
520 .
Case(
"nzc", Intrinsic::x86_sse41_ptestnzc)
533 .
Case(
"sse41.insertps", Intrinsic::x86_sse41_insertps)
534 .
Case(
"sse41.dppd", Intrinsic::x86_sse41_dppd)
535 .
Case(
"sse41.dpps", Intrinsic::x86_sse41_dpps)
536 .
Case(
"sse41.mpsadbw", Intrinsic::x86_sse41_mpsadbw)
537 .
Case(
"avx.dp.ps.256", Intrinsic::x86_avx_dp_ps_256)
538 .
Case(
"avx2.mpsadbw", Intrinsic::x86_avx2_mpsadbw)
543 if (
Name.consume_front(
"avx512.mask.cmp.")) {
546 .
Case(
"pd.128", Intrinsic::x86_avx512_mask_cmp_pd_128)
547 .
Case(
"pd.256", Intrinsic::x86_avx512_mask_cmp_pd_256)
548 .
Case(
"pd.512", Intrinsic::x86_avx512_mask_cmp_pd_512)
549 .
Case(
"ps.128", Intrinsic::x86_avx512_mask_cmp_ps_128)
550 .
Case(
"ps.256", Intrinsic::x86_avx512_mask_cmp_ps_256)
551 .
Case(
"ps.512", Intrinsic::x86_avx512_mask_cmp_ps_512)
558 if (
Name.consume_front(
"avx512bf16.")) {
561 .
Case(
"cvtne2ps2bf16.128",
562 Intrinsic::x86_avx512bf16_cvtne2ps2bf16_128)
563 .
Case(
"cvtne2ps2bf16.256",
564 Intrinsic::x86_avx512bf16_cvtne2ps2bf16_256)
565 .
Case(
"cvtne2ps2bf16.512",
566 Intrinsic::x86_avx512bf16_cvtne2ps2bf16_512)
567 .
Case(
"mask.cvtneps2bf16.128",
568 Intrinsic::x86_avx512bf16_mask_cvtneps2bf16_128)
569 .
Case(
"cvtneps2bf16.256",
570 Intrinsic::x86_avx512bf16_cvtneps2bf16_256)
571 .
Case(
"cvtneps2bf16.512",
572 Intrinsic::x86_avx512bf16_cvtneps2bf16_512)
579 .
Case(
"dpbf16ps.128", Intrinsic::x86_avx512bf16_dpbf16ps_128)
580 .
Case(
"dpbf16ps.256", Intrinsic::x86_avx512bf16_dpbf16ps_256)
581 .
Case(
"dpbf16ps.512", Intrinsic::x86_avx512bf16_dpbf16ps_512)
588 if (
Name.consume_front(
"xop.")) {
590 if (
Name.starts_with(
"vpermil2")) {
593 auto Idx =
F->getFunctionType()->getParamType(2);
594 if (
Idx->isFPOrFPVectorTy()) {
595 unsigned IdxSize =
Idx->getPrimitiveSizeInBits();
596 unsigned EltSize =
Idx->getScalarSizeInBits();
597 if (EltSize == 64 && IdxSize == 128)
598 ID = Intrinsic::x86_xop_vpermil2pd;
599 else if (EltSize == 32 && IdxSize == 128)
600 ID = Intrinsic::x86_xop_vpermil2ps;
601 else if (EltSize == 64 && IdxSize == 256)
602 ID = Intrinsic::x86_xop_vpermil2pd_256;
604 ID = Intrinsic::x86_xop_vpermil2ps_256;
606 }
else if (
F->arg_size() == 2)
609 .
Case(
"vfrcz.ss", Intrinsic::x86_xop_vfrcz_ss)
610 .
Case(
"vfrcz.sd", Intrinsic::x86_xop_vfrcz_sd)
621 if (
Name ==
"seh.recoverfp") {
623 Intrinsic::eh_recoverfp);
635 if (
Name.starts_with(
"rbit")) {
638 F->getParent(), Intrinsic::bitreverse,
F->arg_begin()->getType());
642 if (
Name ==
"thread.pointer") {
645 Intrinsic::thread_pointer);
649 bool Neon =
Name.consume_front(
"neon.");
654 if (
Name.consume_front(
"bfdot.")) {
658 .
Cases(
"v2f32.v8i8",
"v4f32.v16i8",
663 size_t OperandWidth =
F->getReturnType()->getPrimitiveSizeInBits();
664 assert((OperandWidth == 64 || OperandWidth == 128) &&
665 "Unexpected operand width");
667 std::array<Type *, 2> Tys{
678 if (
Name.consume_front(
"bfm")) {
680 if (
Name.consume_back(
".v4f32.v16i8")) {
720 F->arg_begin()->getType());
724 if (
Name.consume_front(
"vst")) {
726 static const Regex vstRegex(
"^([1234]|[234]lane)\\.v[a-z0-9]*$");
730 Intrinsic::arm_neon_vst1, Intrinsic::arm_neon_vst2,
731 Intrinsic::arm_neon_vst3, Intrinsic::arm_neon_vst4};
734 Intrinsic::arm_neon_vst2lane, Intrinsic::arm_neon_vst3lane,
735 Intrinsic::arm_neon_vst4lane};
737 auto fArgs =
F->getFunctionType()->params();
738 Type *Tys[] = {fArgs[0], fArgs[1]};
741 F->getParent(), StoreInts[fArgs.size() - 3], Tys);
744 F->getParent(), StoreLaneInts[fArgs.size() - 5], Tys);
753 if (
Name.consume_front(
"mve.")) {
755 if (
Name ==
"vctp64") {
756 if (cast<FixedVectorType>(
F->getReturnType())->getNumElements() == 4) {
766 if (
Name.consume_back(
".v4i1")) {
768 if (
Name.consume_back(
".predicated.v2i64.v4i32"))
770 return Name ==
"mull.int" ||
Name ==
"vqdmull";
772 if (
Name.consume_back(
".v2i64")) {
774 bool IsGather =
Name.consume_front(
"vldr.gather.");
775 if (IsGather ||
Name.consume_front(
"vstr.scatter.")) {
776 if (
Name.consume_front(
"base.")) {
778 Name.consume_front(
"wb.");
781 return Name ==
"predicated.v2i64";
784 if (
Name.consume_front(
"offset.predicated."))
785 return Name == (IsGather ?
"v2i64.p0i64" :
"p0i64.v2i64") ||
786 Name == (IsGather ?
"v2i64.p0" :
"p0.v2i64");
799 if (
Name.consume_front(
"cde.vcx")) {
801 if (
Name.consume_back(
".predicated.v2i64.v4i1"))
818 F->arg_begin()->getType());
822 if (
Name.starts_with(
"addp")) {
824 if (
F->arg_size() != 2)
826 VectorType *Ty = dyn_cast<VectorType>(
F->getReturnType());
827 if (Ty && Ty->getElementType()->isFloatingPointTy()) {
829 F->getParent(), Intrinsic::aarch64_neon_faddp, Ty);
835 if (
Name.starts_with(
"bfcvt")) {
842 if (
Name.consume_front(
"sve.")) {
844 if (
Name.consume_front(
"bf")) {
845 if (
Name.consume_back(
".lane")) {
849 .
Case(
"dot", Intrinsic::aarch64_sve_bfdot_lane_v2)
850 .
Case(
"mlalb", Intrinsic::aarch64_sve_bfmlalb_lane_v2)
851 .
Case(
"mlalt", Intrinsic::aarch64_sve_bfmlalt_lane_v2)
863 if (
Name ==
"fcvt.bf16f32" ||
Name ==
"fcvtnt.bf16f32") {
868 if (
Name.consume_front(
"addqv")) {
870 if (!
F->getReturnType()->isFPOrFPVectorTy())
873 auto Args =
F->getFunctionType()->params();
874 Type *Tys[] = {
F->getReturnType(), Args[1]};
876 F->getParent(), Intrinsic::aarch64_sve_faddqv, Tys);
880 if (
Name.consume_front(
"ld")) {
882 static const Regex LdRegex(
"^[234](.nxv[a-z0-9]+|$)");
885 cast<VectorType>(
F->getReturnType())->getElementType();
887 cast<VectorType>(
F->arg_begin()->getType())->getElementCount();
888 Type *Ty = VectorType::get(ScalarTy, EC);
890 Intrinsic::aarch64_sve_ld2_sret,
891 Intrinsic::aarch64_sve_ld3_sret,
892 Intrinsic::aarch64_sve_ld4_sret,
895 LoadIDs[
Name[0] -
'2'], Ty);
901 if (
Name.consume_front(
"tuple.")) {
903 if (
Name.starts_with(
"get")) {
905 Type *Tys[] = {
F->getReturnType(),
F->arg_begin()->getType()};
907 F->getParent(), Intrinsic::vector_extract, Tys);
911 if (
Name.starts_with(
"set")) {
913 auto Args =
F->getFunctionType()->params();
914 Type *Tys[] = {Args[0], Args[2], Args[1]};
916 F->getParent(), Intrinsic::vector_insert, Tys);
920 static const Regex CreateTupleRegex(
"^create[234](.nxv[a-z0-9]+|$)");
923 auto Args =
F->getFunctionType()->params();
924 Type *Tys[] = {
F->getReturnType(), Args[1]};
926 F->getParent(), Intrinsic::vector_insert, Tys);
938 if (
Name.consume_front(
"abs."))
940 .
Case(
"bf16", Intrinsic::nvvm_abs_bf16)
941 .
Case(
"bf16x2", Intrinsic::nvvm_abs_bf16x2)
944 if (
Name.consume_front(
"fma.rn."))
946 .
Case(
"bf16", Intrinsic::nvvm_fma_rn_bf16)
947 .
Case(
"bf16x2", Intrinsic::nvvm_fma_rn_bf16x2)
948 .
Case(
"ftz.bf16", Intrinsic::nvvm_fma_rn_ftz_bf16)
949 .
Case(
"ftz.bf16x2", Intrinsic::nvvm_fma_rn_ftz_bf16x2)
950 .
Case(
"ftz.relu.bf16", Intrinsic::nvvm_fma_rn_ftz_relu_bf16)
951 .
Case(
"ftz.relu.bf16x2", Intrinsic::nvvm_fma_rn_ftz_relu_bf16x2)
952 .
Case(
"ftz.sat.bf16", Intrinsic::nvvm_fma_rn_ftz_sat_bf16)
953 .
Case(
"ftz.sat.bf16x2", Intrinsic::nvvm_fma_rn_ftz_sat_bf16x2)
954 .
Case(
"relu.bf16", Intrinsic::nvvm_fma_rn_relu_bf16)
955 .
Case(
"relu.bf16x2", Intrinsic::nvvm_fma_rn_relu_bf16x2)
956 .
Case(
"sat.bf16", Intrinsic::nvvm_fma_rn_sat_bf16)
957 .
Case(
"sat.bf16x2", Intrinsic::nvvm_fma_rn_sat_bf16x2)
960 if (
Name.consume_front(
"fmax."))
962 .
Case(
"bf16", Intrinsic::nvvm_fmax_bf16)
963 .
Case(
"bf16x2", Intrinsic::nvvm_fmax_bf16x2)
964 .
Case(
"ftz.bf16", Intrinsic::nvvm_fmax_ftz_bf16)
965 .
Case(
"ftz.bf16x2", Intrinsic::nvvm_fmax_ftz_bf16x2)
966 .
Case(
"ftz.nan.bf16", Intrinsic::nvvm_fmax_ftz_nan_bf16)
967 .
Case(
"ftz.nan.bf16x2", Intrinsic::nvvm_fmax_ftz_nan_bf16x2)
968 .
Case(
"ftz.nan.xorsign.abs.bf16",
969 Intrinsic::nvvm_fmax_ftz_nan_xorsign_abs_bf16)
970 .
Case(
"ftz.nan.xorsign.abs.bf16x2",
971 Intrinsic::nvvm_fmax_ftz_nan_xorsign_abs_bf16x2)
972 .
Case(
"ftz.xorsign.abs.bf16", Intrinsic::nvvm_fmax_ftz_xorsign_abs_bf16)
973 .
Case(
"ftz.xorsign.abs.bf16x2",
974 Intrinsic::nvvm_fmax_ftz_xorsign_abs_bf16x2)
975 .
Case(
"nan.bf16", Intrinsic::nvvm_fmax_nan_bf16)
976 .
Case(
"nan.bf16x2", Intrinsic::nvvm_fmax_nan_bf16x2)
977 .
Case(
"nan.xorsign.abs.bf16", Intrinsic::nvvm_fmax_nan_xorsign_abs_bf16)
978 .
Case(
"nan.xorsign.abs.bf16x2",
979 Intrinsic::nvvm_fmax_nan_xorsign_abs_bf16x2)
980 .
Case(
"xorsign.abs.bf16", Intrinsic::nvvm_fmax_xorsign_abs_bf16)
981 .
Case(
"xorsign.abs.bf16x2", Intrinsic::nvvm_fmax_xorsign_abs_bf16x2)
984 if (
Name.consume_front(
"fmin."))
986 .
Case(
"bf16", Intrinsic::nvvm_fmin_bf16)
987 .
Case(
"bf16x2", Intrinsic::nvvm_fmin_bf16x2)
988 .
Case(
"ftz.bf16", Intrinsic::nvvm_fmin_ftz_bf16)
989 .
Case(
"ftz.bf16x2", Intrinsic::nvvm_fmin_ftz_bf16x2)
990 .
Case(
"ftz.nan.bf16", Intrinsic::nvvm_fmin_ftz_nan_bf16)
991 .
Case(
"ftz.nan.bf16x2", Intrinsic::nvvm_fmin_ftz_nan_bf16x2)
992 .
Case(
"ftz.nan.xorsign.abs.bf16",
993 Intrinsic::nvvm_fmin_ftz_nan_xorsign_abs_bf16)
994 .
Case(
"ftz.nan.xorsign.abs.bf16x2",
995 Intrinsic::nvvm_fmin_ftz_nan_xorsign_abs_bf16x2)
996 .
Case(
"ftz.xorsign.abs.bf16", Intrinsic::nvvm_fmin_ftz_xorsign_abs_bf16)
997 .
Case(
"ftz.xorsign.abs.bf16x2",
998 Intrinsic::nvvm_fmin_ftz_xorsign_abs_bf16x2)
999 .
Case(
"nan.bf16", Intrinsic::nvvm_fmin_nan_bf16)
1000 .
Case(
"nan.bf16x2", Intrinsic::nvvm_fmin_nan_bf16x2)
1001 .
Case(
"nan.xorsign.abs.bf16", Intrinsic::nvvm_fmin_nan_xorsign_abs_bf16)
1002 .
Case(
"nan.xorsign.abs.bf16x2",
1003 Intrinsic::nvvm_fmin_nan_xorsign_abs_bf16x2)
1004 .
Case(
"xorsign.abs.bf16", Intrinsic::nvvm_fmin_xorsign_abs_bf16)
1005 .
Case(
"xorsign.abs.bf16x2", Intrinsic::nvvm_fmin_xorsign_abs_bf16x2)
1008 if (
Name.consume_front(
"neg."))
1010 .
Case(
"bf16", Intrinsic::nvvm_neg_bf16)
1011 .
Case(
"bf16x2", Intrinsic::nvvm_neg_bf16x2)
1018 bool CanUpgradeDebugIntrinsicsToRecords) {
1019 assert(
F &&
"Illegal to upgrade a non-existent Function.");
1024 if (!
Name.consume_front(
"llvm.") ||
Name.empty())
1030 bool IsArm =
Name.consume_front(
"arm.");
1031 if (IsArm ||
Name.consume_front(
"aarch64.")) {
1037 if (
Name.consume_front(
"amdgcn.")) {
1038 if (
Name ==
"alignbit") {
1041 F->getParent(), Intrinsic::fshr, {F->getReturnType()});
1045 if (
Name.consume_front(
"atomic.")) {
1046 if (
Name.starts_with(
"inc") ||
Name.starts_with(
"dec")) {
1055 if (
Name.consume_front(
"ds.") ||
Name.consume_front(
"global.atomic.") ||
1056 Name.consume_front(
"flat.atomic.")) {
1057 if (
Name.starts_with(
"fadd") ||
1059 (
Name.starts_with(
"fmin") && !
Name.starts_with(
"fmin.num")) ||
1060 (
Name.starts_with(
"fmax") && !
Name.starts_with(
"fmax.num"))) {
1068 if (
Name.starts_with(
"ldexp.")) {
1071 F->getParent(), Intrinsic::ldexp,
1072 {F->getReturnType(), F->getArg(1)->getType()});
1081 if (
F->arg_size() == 1) {
1089 F->arg_begin()->getType());
1094 if (
F->arg_size() == 2 &&
Name ==
"coro.end") {
1097 Intrinsic::coro_end);
1104 if (
Name.consume_front(
"dbg.")) {
1106 if (CanUpgradeDebugIntrinsicsToRecords &&
1107 F->getParent()->IsNewDbgInfoFormat) {
1108 if (
Name ==
"addr" ||
Name ==
"value" ||
Name ==
"assign" ||
1109 Name ==
"declare" ||
Name ==
"label") {
1118 if (
Name ==
"addr" || (
Name ==
"value" &&
F->arg_size() == 4)) {
1121 Intrinsic::dbg_value);
1128 if (
Name.consume_front(
"experimental.vector.")) {
1134 .
StartsWith(
"extract.", Intrinsic::vector_extract)
1135 .
StartsWith(
"insert.", Intrinsic::vector_insert)
1136 .
StartsWith(
"splice.", Intrinsic::vector_splice)
1137 .
StartsWith(
"reverse.", Intrinsic::vector_reverse)
1138 .
StartsWith(
"interleave2.", Intrinsic::vector_interleave2)
1139 .
StartsWith(
"deinterleave2.", Intrinsic::vector_deinterleave2)
1142 const auto *FT =
F->getFunctionType();
1144 if (
ID == Intrinsic::vector_extract ||
1145 ID == Intrinsic::vector_interleave2)
1147 Tys.push_back(FT->getReturnType());
1148 if (
ID != Intrinsic::vector_interleave2)
1149 Tys.push_back(FT->getParamType(0));
1150 if (
ID == Intrinsic::vector_insert)
1152 Tys.push_back(FT->getParamType(1));
1158 if (
Name.consume_front(
"reduce.")) {
1160 static const Regex R(
"^([a-z]+)\\.[a-z][0-9]+");
1163 .
Case(
"add", Intrinsic::vector_reduce_add)
1164 .
Case(
"mul", Intrinsic::vector_reduce_mul)
1165 .
Case(
"and", Intrinsic::vector_reduce_and)
1166 .
Case(
"or", Intrinsic::vector_reduce_or)
1167 .
Case(
"xor", Intrinsic::vector_reduce_xor)
1168 .
Case(
"smax", Intrinsic::vector_reduce_smax)
1169 .
Case(
"smin", Intrinsic::vector_reduce_smin)
1170 .
Case(
"umax", Intrinsic::vector_reduce_umax)
1171 .
Case(
"umin", Intrinsic::vector_reduce_umin)
1172 .
Case(
"fmax", Intrinsic::vector_reduce_fmax)
1173 .
Case(
"fmin", Intrinsic::vector_reduce_fmin)
1178 static const Regex R2(
"^v2\\.([a-z]+)\\.[fi][0-9]+");
1183 .
Case(
"fadd", Intrinsic::vector_reduce_fadd)
1184 .
Case(
"fmul", Intrinsic::vector_reduce_fmul)
1189 auto Args =
F->getFunctionType()->params();
1191 {Args[V2 ? 1 : 0]});
1198 if (
Name.consume_front(
"experimental.stepvector.")) {
1202 F->getParent(),
ID,
F->getFunctionType()->getReturnType());
1207 if (
Name.starts_with(
"flt.rounds")) {
1210 Intrinsic::get_rounding);
1215 if (
Name.starts_with(
"invariant.group.barrier")) {
1217 auto Args =
F->getFunctionType()->params();
1218 Type* ObjectPtr[1] = {Args[0]};
1221 F->getParent(), Intrinsic::launder_invariant_group, ObjectPtr);
1230 .StartsWith(
"memcpy.", Intrinsic::memcpy)
1231 .StartsWith(
"memmove.", Intrinsic::memmove)
1233 if (
F->arg_size() == 5) {
1237 F->getFunctionType()->params().slice(0, 3);
1243 if (
Name.starts_with(
"memset.") &&
F->arg_size() == 5) {
1246 const auto *FT =
F->getFunctionType();
1247 Type *ParamTypes[2] = {
1248 FT->getParamType(0),
1252 Intrinsic::memset, ParamTypes);
1258 if (
Name.consume_front(
"nvvm.")) {
1260 if (
F->arg_size() == 1) {
1263 .
Cases(
"brev32",
"brev64", Intrinsic::bitreverse)
1264 .
Case(
"clz.i", Intrinsic::ctlz)
1265 .
Case(
"popc.i", Intrinsic::ctpop)
1269 {F->getReturnType()});
1275 if (!
F->getReturnType()->getScalarType()->isBFloatTy()) {
1287 bool Expand =
false;
1288 if (
Name.consume_front(
"abs."))
1290 Expand =
Name ==
"i" ||
Name ==
"ll";
1291 else if (
Name ==
"clz.ll" ||
Name ==
"popc.ll" ||
Name ==
"h2f")
1293 else if (
Name.consume_front(
"max.") ||
Name.consume_front(
"min."))
1297 else if (
Name.consume_front(
"atomic.load.add."))
1299 Expand =
Name.starts_with(
"f32.p") ||
Name.starts_with(
"f64.p");
1300 else if (
Name.consume_front(
"bitcast."))
1304 else if (
Name.consume_front(
"rotate."))
1306 Expand =
Name ==
"b32" ||
Name ==
"b64" ||
Name ==
"right.b64";
1307 else if (
Name.consume_front(
"ptr.gen.to."))
1309 Expand =
Name.starts_with(
"local") ||
Name.starts_with(
"shared") ||
1310 Name.starts_with(
"global") ||
Name.starts_with(
"constant");
1311 else if (
Name.consume_front(
"ptr."))
1314 (
Name.consume_front(
"local") ||
Name.consume_front(
"shared") ||
1315 Name.consume_front(
"global") ||
Name.consume_front(
"constant")) &&
1316 Name.starts_with(
".to.gen");
1317 else if (
Name.consume_front(
"ldg.global."))
1319 Expand = (
Name.starts_with(
"i.") ||
Name.starts_with(
"f.") ||
1320 Name.starts_with(
"p."));
1335 if (
Name.starts_with(
"objectsize.")) {
1336 Type *Tys[2] = {
F->getReturnType(),
F->arg_begin()->getType() };
1337 if (
F->arg_size() == 2 ||
F->arg_size() == 3 ||
1342 Intrinsic::objectsize, Tys);
1349 if (
Name.starts_with(
"ptr.annotation.") &&
F->arg_size() == 4) {
1352 F->getParent(), Intrinsic::ptr_annotation,
1353 {F->arg_begin()->getType(), F->getArg(1)->getType()});
1359 if (
Name.consume_front(
"riscv.")) {
1362 .
Case(
"aes32dsi", Intrinsic::riscv_aes32dsi)
1363 .
Case(
"aes32dsmi", Intrinsic::riscv_aes32dsmi)
1364 .
Case(
"aes32esi", Intrinsic::riscv_aes32esi)
1365 .
Case(
"aes32esmi", Intrinsic::riscv_aes32esmi)
1368 if (!
F->getFunctionType()->getParamType(2)->isIntegerTy(32)) {
1381 if (!
F->getFunctionType()->getParamType(2)->isIntegerTy(32) ||
1382 F->getFunctionType()->getReturnType()->isIntegerTy(64)) {
1391 .
StartsWith(
"sha256sig0", Intrinsic::riscv_sha256sig0)
1392 .
StartsWith(
"sha256sig1", Intrinsic::riscv_sha256sig1)
1393 .
StartsWith(
"sha256sum0", Intrinsic::riscv_sha256sum0)
1394 .
StartsWith(
"sha256sum1", Intrinsic::riscv_sha256sum1)
1399 if (
F->getFunctionType()->getReturnType()->isIntegerTy(64)) {
1411 if (
Name ==
"stackprotectorcheck") {
1418 if (
Name ==
"var.annotation" &&
F->arg_size() == 4) {
1421 F->getParent(), Intrinsic::var_annotation,
1422 {{F->arg_begin()->getType(), F->getArg(1)->getType()}});
1429 if (
Name.consume_front(
"wasm.")) {
1432 .
StartsWith(
"fma.", Intrinsic::wasm_relaxed_madd)
1433 .
StartsWith(
"fms.", Intrinsic::wasm_relaxed_nmadd)
1434 .
StartsWith(
"laneselect.", Intrinsic::wasm_relaxed_laneselect)
1439 F->getReturnType());
1443 if (
Name.consume_front(
"dot.i8x16.i7x16.")) {
1445 .
Case(
"signed", Intrinsic::wasm_relaxed_dot_i8x16_i7x16_signed)
1447 Intrinsic::wasm_relaxed_dot_i8x16_i7x16_add_signed)
1465 auto *
ST = dyn_cast<StructType>(
F->getReturnType());
1466 if (ST && (!
ST->isLiteral() ||
ST->isPacked()) &&
1475 auto *FT =
F->getFunctionType();
1477 auto *NewFT = FunctionType::get(NewST, FT->params(), FT->isVarArg());
1478 std::string
Name =
F->getName().str();
1481 Name,
F->getParent());
1492 if (Result != std::nullopt) {
1505 bool CanUpgradeDebugIntrinsicsToRecords) {
1509 assert(
F != NewFn &&
"Intrinsic function upgraded to the same function");
1521 GV->
getName() ==
"llvm.global_dtors")) ||
1536 unsigned N =
Init->getNumOperands();
1537 std::vector<Constant *> NewCtors(
N);
1538 for (
unsigned i = 0; i !=
N; ++i) {
1539 auto Ctor = cast<Constant>(
Init->getOperand(i));
1541 Ctor->getAggregateElement(1),
1554 auto *ResultTy = cast<FixedVectorType>(
Op->getType());
1555 unsigned NumElts = ResultTy->getNumElements() * 8;
1569 for (
unsigned l = 0; l != NumElts; l += 16)
1570 for (
unsigned i = 0; i != 16; ++i) {
1571 unsigned Idx = NumElts + i - Shift;
1573 Idx -= NumElts - 16;
1574 Idxs[l + i] =
Idx + l;
1588 auto *ResultTy = cast<FixedVectorType>(
Op->getType());
1589 unsigned NumElts = ResultTy->getNumElements() * 8;
1603 for (
unsigned l = 0; l != NumElts; l += 16)
1604 for (
unsigned i = 0; i != 16; ++i) {
1605 unsigned Idx = i + Shift;
1607 Idx += NumElts - 16;
1608 Idxs[l + i] =
Idx + l;
1629 for (
unsigned i = 0; i != NumElts; ++i)
1641 if (
const auto *
C = dyn_cast<Constant>(Mask))
1642 if (
C->isAllOnesValue())
1646 cast<FixedVectorType>(Op0->
getType())->getNumElements());
1653 if (
const auto *
C = dyn_cast<Constant>(Mask))
1654 if (
C->isAllOnesValue())
1658 Mask->getType()->getIntegerBitWidth());
1671 unsigned ShiftVal = cast<llvm::ConstantInt>(Shift)->getZExtValue();
1673 unsigned NumElts = cast<FixedVectorType>(Op0->
getType())->getNumElements();
1674 assert((IsVALIGN || NumElts % 16 == 0) &&
"Illegal NumElts for PALIGNR!");
1675 assert((!IsVALIGN || NumElts <= 16) &&
"NumElts too large for VALIGN!");
1680 ShiftVal &= (NumElts - 1);
1689 if (ShiftVal > 16) {
1697 for (
unsigned l = 0; l < NumElts; l += 16) {
1698 for (
unsigned i = 0; i != 16; ++i) {
1699 unsigned Idx = ShiftVal + i;
1700 if (!IsVALIGN &&
Idx >= 16)
1701 Idx += NumElts - 16;
1702 Indices[l + i] =
Idx + l;
1707 Op1, Op0,
ArrayRef(Indices, NumElts),
"palignr");
1713 bool ZeroMask,
bool IndexForm) {
1719 if (VecWidth == 128 && EltWidth == 32 && IsFloat)
1720 IID = Intrinsic::x86_avx512_vpermi2var_ps_128;
1721 else if (VecWidth == 128 && EltWidth == 32 && !IsFloat)
1722 IID = Intrinsic::x86_avx512_vpermi2var_d_128;
1723 else if (VecWidth == 128 && EltWidth == 64 && IsFloat)
1724 IID = Intrinsic::x86_avx512_vpermi2var_pd_128;
1725 else if (VecWidth == 128 && EltWidth == 64 && !IsFloat)
1726 IID = Intrinsic::x86_avx512_vpermi2var_q_128;
1727 else if (VecWidth == 256 && EltWidth == 32 && IsFloat)
1728 IID = Intrinsic::x86_avx512_vpermi2var_ps_256;
1729 else if (VecWidth == 256 && EltWidth == 32 && !IsFloat)
1730 IID = Intrinsic::x86_avx512_vpermi2var_d_256;
1731 else if (VecWidth == 256 && EltWidth == 64 && IsFloat)
1732 IID = Intrinsic::x86_avx512_vpermi2var_pd_256;
1733 else if (VecWidth == 256 && EltWidth == 64 && !IsFloat)
1734 IID = Intrinsic::x86_avx512_vpermi2var_q_256;
1735 else if (VecWidth == 512 && EltWidth == 32 && IsFloat)
1736 IID = Intrinsic::x86_avx512_vpermi2var_ps_512;
1737 else if (VecWidth == 512 && EltWidth == 32 && !IsFloat)
1738 IID = Intrinsic::x86_avx512_vpermi2var_d_512;
1739 else if (VecWidth == 512 && EltWidth == 64 && IsFloat)
1740 IID = Intrinsic::x86_avx512_vpermi2var_pd_512;
1741 else if (VecWidth == 512 && EltWidth == 64 && !IsFloat)
1742 IID = Intrinsic::x86_avx512_vpermi2var_q_512;
1743 else if (VecWidth == 128 && EltWidth == 16)
1744 IID = Intrinsic::x86_avx512_vpermi2var_hi_128;
1745 else if (VecWidth == 256 && EltWidth == 16)
1746 IID = Intrinsic::x86_avx512_vpermi2var_hi_256;
1747 else if (VecWidth == 512 && EltWidth == 16)
1748 IID = Intrinsic::x86_avx512_vpermi2var_hi_512;
1749 else if (VecWidth == 128 && EltWidth == 8)
1750 IID = Intrinsic::x86_avx512_vpermi2var_qi_128;
1751 else if (VecWidth == 256 && EltWidth == 8)
1752 IID = Intrinsic::x86_avx512_vpermi2var_qi_256;
1753 else if (VecWidth == 512 && EltWidth == 8)
1754 IID = Intrinsic::x86_avx512_vpermi2var_qi_512;
1788 bool IsRotateRight) {
1797 unsigned NumElts = cast<FixedVectorType>(Ty)->getNumElements();
1802 Intrinsic::ID IID = IsRotateRight ? Intrinsic::fshr : Intrinsic::fshl;
1822 Pred = IsSigned ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT;
1825 Pred = IsSigned ? ICmpInst::ICMP_SLE : ICmpInst::ICMP_ULE;
1828 Pred = IsSigned ? ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT;
1831 Pred = IsSigned ? ICmpInst::ICMP_SGE : ICmpInst::ICMP_UGE;
1834 Pred = ICmpInst::ICMP_EQ;
1837 Pred = ICmpInst::ICMP_NE;
1853 bool IsShiftRight,
bool ZeroMask) {
1866 unsigned NumElts = cast<FixedVectorType>(Ty)->getNumElements();
1871 Intrinsic::ID IID = IsShiftRight ? Intrinsic::fshr : Intrinsic::fshl;
1887 const Align Alignment =
1889 ?
Align(Data->getType()->getPrimitiveSizeInBits().getFixedValue() / 8)
1893 if (
const auto *
C = dyn_cast<Constant>(Mask))
1894 if (
C->isAllOnesValue())
1898 unsigned NumElts = cast<FixedVectorType>(Data->getType())->getNumElements();
1906 const Align Alignment =
1914 if (
const auto *
C = dyn_cast<Constant>(Mask))
1915 if (
C->isAllOnesValue())
1919 unsigned NumElts = cast<FixedVectorType>(ValTy)->getNumElements();
1928 {Op0, Builder.
getInt1(
false)});
1943 Constant *ShiftAmt = ConstantInt::get(Ty, 32);
1950 Constant *Mask = ConstantInt::get(Ty, 0xffffffff);
1966 unsigned NumElts = cast<FixedVectorType>(Vec->
getType())->getNumElements();
1968 const auto *
C = dyn_cast<Constant>(Mask);
1969 if (!
C || !
C->isAllOnesValue())
1975 for (
unsigned i = 0; i != NumElts; ++i)
1977 for (
unsigned i = NumElts; i != 8; ++i)
1978 Indices[i] = NumElts + i % NumElts;
1989 unsigned NumElts = cast<FixedVectorType>(Op0->
getType())->getNumElements();
1995 }
else if (
CC == 7) {
2002 case 0: Pred = ICmpInst::ICMP_EQ;
break;
2003 case 1: Pred =
Signed ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT;
break;
2004 case 2: Pred =
Signed ? ICmpInst::ICMP_SLE : ICmpInst::ICMP_ULE;
break;
2005 case 4: Pred = ICmpInst::ICMP_NE;
break;
2006 case 5: Pred =
Signed ? ICmpInst::ICMP_SGE : ICmpInst::ICMP_UGE;
break;
2007 case 6: Pred =
Signed ? ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT;
break;
2042 unsigned NumElts = cast<FixedVectorType>(CI.
getType())->getNumElements();
2044 return Builder.
CreateSExt(Mask, ReturnOp,
"vpmovm2");
2055 if (
Name.starts_with(
"max.p")) {
2056 if (VecWidth == 128 && EltWidth == 32)
2057 IID = Intrinsic::x86_sse_max_ps;
2058 else if (VecWidth == 128 && EltWidth == 64)
2059 IID = Intrinsic::x86_sse2_max_pd;
2060 else if (VecWidth == 256 && EltWidth == 32)
2061 IID = Intrinsic::x86_avx_max_ps_256;
2062 else if (VecWidth == 256 && EltWidth == 64)
2063 IID = Intrinsic::x86_avx_max_pd_256;
2066 }
else if (
Name.starts_with(
"min.p")) {
2067 if (VecWidth == 128 && EltWidth == 32)
2068 IID = Intrinsic::x86_sse_min_ps;
2069 else if (VecWidth == 128 && EltWidth == 64)
2070 IID = Intrinsic::x86_sse2_min_pd;
2071 else if (VecWidth == 256 && EltWidth == 32)
2072 IID = Intrinsic::x86_avx_min_ps_256;
2073 else if (VecWidth == 256 && EltWidth == 64)
2074 IID = Intrinsic::x86_avx_min_pd_256;
2077 }
else if (
Name.starts_with(
"pshuf.b.")) {
2078 if (VecWidth == 128)
2079 IID = Intrinsic::x86_ssse3_pshuf_b_128;
2080 else if (VecWidth == 256)
2081 IID = Intrinsic::x86_avx2_pshuf_b;
2082 else if (VecWidth == 512)
2083 IID = Intrinsic::x86_avx512_pshuf_b_512;
2086 }
else if (
Name.starts_with(
"pmul.hr.sw.")) {
2087 if (VecWidth == 128)
2088 IID = Intrinsic::x86_ssse3_pmul_hr_sw_128;
2089 else if (VecWidth == 256)
2090 IID = Intrinsic::x86_avx2_pmul_hr_sw;
2091 else if (VecWidth == 512)
2092 IID = Intrinsic::x86_avx512_pmul_hr_sw_512;
2095 }
else if (
Name.starts_with(
"pmulh.w.")) {
2096 if (VecWidth == 128)
2097 IID = Intrinsic::x86_sse2_pmulh_w;
2098 else if (VecWidth == 256)
2099 IID = Intrinsic::x86_avx2_pmulh_w;
2100 else if (VecWidth == 512)
2101 IID = Intrinsic::x86_avx512_pmulh_w_512;
2104 }
else if (
Name.starts_with(
"pmulhu.w.")) {
2105 if (VecWidth == 128)
2106 IID = Intrinsic::x86_sse2_pmulhu_w;
2107 else if (VecWidth == 256)
2108 IID = Intrinsic::x86_avx2_pmulhu_w;
2109 else if (VecWidth == 512)
2110 IID = Intrinsic::x86_avx512_pmulhu_w_512;
2113 }
else if (
Name.starts_with(
"pmaddw.d.")) {
2114 if (VecWidth == 128)
2115 IID = Intrinsic::x86_sse2_pmadd_wd;
2116 else if (VecWidth == 256)
2117 IID = Intrinsic::x86_avx2_pmadd_wd;
2118 else if (VecWidth == 512)
2119 IID = Intrinsic::x86_avx512_pmaddw_d_512;
2122 }
else if (
Name.starts_with(
"pmaddubs.w.")) {
2123 if (VecWidth == 128)
2124 IID = Intrinsic::x86_ssse3_pmadd_ub_sw_128;
2125 else if (VecWidth == 256)
2126 IID = Intrinsic::x86_avx2_pmadd_ub_sw;
2127 else if (VecWidth == 512)
2128 IID = Intrinsic::x86_avx512_pmaddubs_w_512;
2131 }
else if (
Name.starts_with(
"packsswb.")) {
2132 if (VecWidth == 128)
2133 IID = Intrinsic::x86_sse2_packsswb_128;
2134 else if (VecWidth == 256)
2135 IID = Intrinsic::x86_avx2_packsswb;
2136 else if (VecWidth == 512)
2137 IID = Intrinsic::x86_avx512_packsswb_512;
2140 }
else if (
Name.starts_with(
"packssdw.")) {
2141 if (VecWidth == 128)
2142 IID = Intrinsic::x86_sse2_packssdw_128;
2143 else if (VecWidth == 256)
2144 IID = Intrinsic::x86_avx2_packssdw;
2145 else if (VecWidth == 512)
2146 IID = Intrinsic::x86_avx512_packssdw_512;
2149 }
else if (
Name.starts_with(
"packuswb.")) {
2150 if (VecWidth == 128)
2151 IID = Intrinsic::x86_sse2_packuswb_128;
2152 else if (VecWidth == 256)
2153 IID = Intrinsic::x86_avx2_packuswb;
2154 else if (VecWidth == 512)
2155 IID = Intrinsic::x86_avx512_packuswb_512;
2158 }
else if (
Name.starts_with(
"packusdw.")) {
2159 if (VecWidth == 128)
2160 IID = Intrinsic::x86_sse41_packusdw;
2161 else if (VecWidth == 256)
2162 IID = Intrinsic::x86_avx2_packusdw;
2163 else if (VecWidth == 512)
2164 IID = Intrinsic::x86_avx512_packusdw_512;
2167 }
else if (
Name.starts_with(
"vpermilvar.")) {
2168 if (VecWidth == 128 && EltWidth == 32)
2169 IID = Intrinsic::x86_avx_vpermilvar_ps;
2170 else if (VecWidth == 128 && EltWidth == 64)
2171 IID = Intrinsic::x86_avx_vpermilvar_pd;
2172 else if (VecWidth == 256 && EltWidth == 32)
2173 IID = Intrinsic::x86_avx_vpermilvar_ps_256;
2174 else if (VecWidth == 256 && EltWidth == 64)
2175 IID = Intrinsic::x86_avx_vpermilvar_pd_256;
2176 else if (VecWidth == 512 && EltWidth == 32)
2177 IID = Intrinsic::x86_avx512_vpermilvar_ps_512;
2178 else if (VecWidth == 512 && EltWidth == 64)
2179 IID = Intrinsic::x86_avx512_vpermilvar_pd_512;
2182 }
else if (
Name ==
"cvtpd2dq.256") {
2183 IID = Intrinsic::x86_avx_cvt_pd2dq_256;
2184 }
else if (
Name ==
"cvtpd2ps.256") {
2185 IID = Intrinsic::x86_avx_cvt_pd2_ps_256;
2186 }
else if (
Name ==
"cvttpd2dq.256") {
2187 IID = Intrinsic::x86_avx_cvtt_pd2dq_256;
2188 }
else if (
Name ==
"cvttps2dq.128") {
2189 IID = Intrinsic::x86_sse2_cvttps2dq;
2190 }
else if (
Name ==
"cvttps2dq.256") {
2191 IID = Intrinsic::x86_avx_cvtt_ps2dq_256;
2192 }
else if (
Name.starts_with(
"permvar.")) {
2194 if (VecWidth == 256 && EltWidth == 32 && IsFloat)
2195 IID = Intrinsic::x86_avx2_permps;
2196 else if (VecWidth == 256 && EltWidth == 32 && !IsFloat)
2197 IID = Intrinsic::x86_avx2_permd;
2198 else if (VecWidth == 256 && EltWidth == 64 && IsFloat)
2199 IID = Intrinsic::x86_avx512_permvar_df_256;
2200 else if (VecWidth == 256 && EltWidth == 64 && !IsFloat)
2201 IID = Intrinsic::x86_avx512_permvar_di_256;
2202 else if (VecWidth == 512 && EltWidth == 32 && IsFloat)
2203 IID = Intrinsic::x86_avx512_permvar_sf_512;
2204 else if (VecWidth == 512 && EltWidth == 32 && !IsFloat)
2205 IID = Intrinsic::x86_avx512_permvar_si_512;
2206 else if (VecWidth == 512 && EltWidth == 64 && IsFloat)
2207 IID = Intrinsic::x86_avx512_permvar_df_512;
2208 else if (VecWidth == 512 && EltWidth == 64 && !IsFloat)
2209 IID = Intrinsic::x86_avx512_permvar_di_512;
2210 else if (VecWidth == 128 && EltWidth == 16)
2211 IID = Intrinsic::x86_avx512_permvar_hi_128;
2212 else if (VecWidth == 256 && EltWidth == 16)
2213 IID = Intrinsic::x86_avx512_permvar_hi_256;
2214 else if (VecWidth == 512 && EltWidth == 16)
2215 IID = Intrinsic::x86_avx512_permvar_hi_512;
2216 else if (VecWidth == 128 && EltWidth == 8)
2217 IID = Intrinsic::x86_avx512_permvar_qi_128;
2218 else if (VecWidth == 256 && EltWidth == 8)
2219 IID = Intrinsic::x86_avx512_permvar_qi_256;
2220 else if (VecWidth == 512 && EltWidth == 8)
2221 IID = Intrinsic::x86_avx512_permvar_qi_512;
2224 }
else if (
Name.starts_with(
"dbpsadbw.")) {
2225 if (VecWidth == 128)
2226 IID = Intrinsic::x86_avx512_dbpsadbw_128;
2227 else if (VecWidth == 256)
2228 IID = Intrinsic::x86_avx512_dbpsadbw_256;
2229 else if (VecWidth == 512)
2230 IID = Intrinsic::x86_avx512_dbpsadbw_512;
2233 }
else if (
Name.starts_with(
"pmultishift.qb.")) {
2234 if (VecWidth == 128)
2235 IID = Intrinsic::x86_avx512_pmultishift_qb_128;
2236 else if (VecWidth == 256)
2237 IID = Intrinsic::x86_avx512_pmultishift_qb_256;
2238 else if (VecWidth == 512)
2239 IID = Intrinsic::x86_avx512_pmultishift_qb_512;
2242 }
else if (
Name.starts_with(
"conflict.")) {
2243 if (
Name[9] ==
'd' && VecWidth == 128)
2244 IID = Intrinsic::x86_avx512_conflict_d_128;
2245 else if (
Name[9] ==
'd' && VecWidth == 256)
2246 IID = Intrinsic::x86_avx512_conflict_d_256;
2247 else if (
Name[9] ==
'd' && VecWidth == 512)
2248 IID = Intrinsic::x86_avx512_conflict_d_512;
2249 else if (
Name[9] ==
'q' && VecWidth == 128)
2250 IID = Intrinsic::x86_avx512_conflict_q_128;
2251 else if (
Name[9] ==
'q' && VecWidth == 256)
2252 IID = Intrinsic::x86_avx512_conflict_q_256;
2253 else if (
Name[9] ==
'q' && VecWidth == 512)
2254 IID = Intrinsic::x86_avx512_conflict_q_512;
2257 }
else if (
Name.starts_with(
"pavg.")) {
2258 if (
Name[5] ==
'b' && VecWidth == 128)
2259 IID = Intrinsic::x86_sse2_pavg_b;
2260 else if (
Name[5] ==
'b' && VecWidth == 256)
2261 IID = Intrinsic::x86_avx2_pavg_b;
2262 else if (
Name[5] ==
'b' && VecWidth == 512)
2263 IID = Intrinsic::x86_avx512_pavg_b_512;
2264 else if (
Name[5] ==
'w' && VecWidth == 128)
2265 IID = Intrinsic::x86_sse2_pavg_w;
2266 else if (
Name[5] ==
'w' && VecWidth == 256)
2267 IID = Intrinsic::x86_avx2_pavg_w;
2268 else if (
Name[5] ==
'w' && VecWidth == 512)
2269 IID = Intrinsic::x86_avx512_pavg_w_512;
2289 if (AsmStr->find(
"mov\tfp") == 0 &&
2290 AsmStr->find(
"objc_retainAutoreleaseReturnValue") != std::string::npos &&
2291 (Pos = AsmStr->find(
"# marker")) != std::string::npos) {
2292 AsmStr->replace(Pos, 1,
";");
2298 Value *Rep =
nullptr;
2300 if (
Name ==
"abs.i" ||
Name ==
"abs.ll") {
2306 }
else if (
Name.starts_with(
"atomic.load.add.f32.p") ||
2307 Name.starts_with(
"atomic.load.add.f64.p")) {
2311 AtomicOrdering::SequentiallyConsistent);
2312 }
else if (
Name.consume_front(
"max.") &&
2321 }
else if (
Name.consume_front(
"min.") &&
2330 }
else if (
Name ==
"clz.ll") {
2337 }
else if (
Name ==
"popc.ll") {
2342 Arg,
nullptr,
"ctpop");
2344 }
else if (
Name ==
"h2f") {
2348 }
else if (
Name.consume_front(
"bitcast.") &&
2352 }
else if (
Name ==
"rotate.b32") {
2356 {Arg, Arg, ShiftAmt});
2357 }
else if (
Name ==
"rotate.b64") {
2362 {Arg, Arg, ZExtShiftAmt});
2363 }
else if (
Name ==
"rotate.right.b64") {
2368 {Arg, Arg, ZExtShiftAmt});
2369 }
else if ((
Name.consume_front(
"ptr.gen.to.") &&
2370 (
Name.starts_with(
"local") ||
Name.starts_with(
"shared") ||
2371 Name.starts_with(
"global") ||
Name.starts_with(
"constant"))) ||
2372 (
Name.consume_front(
"ptr.") &&
2373 (
Name.consume_front(
"local") ||
Name.consume_front(
"shared") ||
2374 Name.consume_front(
"global") ||
2375 Name.consume_front(
"constant")) &&
2376 Name.starts_with(
".to.gen"))) {
2378 }
else if (
Name.consume_front(
"ldg.global")) {
2385 LD->setMetadata(LLVMContext::MD_invariant_load, MD);
2390 !
F->getReturnType()->getScalarType()->isBFloatTy()) {
2404 if (
F->getReturnType()->isIntegerTy())
2415 Value *Rep =
nullptr;
2417 if (
Name.starts_with(
"sse4a.movnt.")) {
2432 SI->setMetadata(LLVMContext::MD_nontemporal,
Node);
2433 }
else if (
Name.starts_with(
"avx.movnt.") ||
2434 Name.starts_with(
"avx512.storent.")) {
2446 SI->setMetadata(LLVMContext::MD_nontemporal,
Node);
2447 }
else if (
Name ==
"sse2.storel.dq") {
2455 }
else if (
Name.starts_with(
"sse.storeu.") ||
2456 Name.starts_with(
"sse2.storeu.") ||
2457 Name.starts_with(
"avx.storeu.")) {
2461 }
else if (
Name ==
"avx512.mask.store.ss") {
2465 }
else if (
Name.starts_with(
"avx512.mask.store")) {
2470 }
else if (
Name.starts_with(
"sse2.pcmp") ||
Name.starts_with(
"avx2.pcmp")) {
2473 bool CmpEq =
Name[9] ==
'e';
2474 Rep = Builder.
CreateICmp(CmpEq ? ICmpInst::ICMP_EQ : ICmpInst::ICMP_SGT,
2477 }
else if (
Name.starts_with(
"avx512.broadcastm")) {
2485 }
else if (
Name ==
"sse.sqrt.ss" ||
Name ==
"sse2.sqrt.sd") {
2490 }
else if (
Name.starts_with(
"avx.sqrt.p") ||
2491 Name.starts_with(
"sse2.sqrt.p") ||
2492 Name.starts_with(
"sse.sqrt.p")) {
2494 {CI->getArgOperand(0)});
2495 }
else if (
Name.starts_with(
"avx512.mask.sqrt.p")) {
2498 cast<ConstantInt>(CI->
getArgOperand(3))->getZExtValue() != 4)) {
2500 : Intrinsic::x86_avx512_sqrt_pd_512;
2506 {CI->getArgOperand(0)});
2510 }
else if (
Name.starts_with(
"avx512.ptestm") ||
2511 Name.starts_with(
"avx512.ptestnm")) {
2520 : ICmpInst::ICMP_EQ;
2523 }
else if (
Name.starts_with(
"avx512.mask.pbroadcast")) {
2529 }
else if (
Name.starts_with(
"avx512.kunpck")) {
2534 for (
unsigned i = 0; i != NumElts; ++i)
2545 }
else if (
Name ==
"avx512.kand.w") {
2550 }
else if (
Name ==
"avx512.kandn.w") {
2556 }
else if (
Name ==
"avx512.kor.w") {
2561 }
else if (
Name ==
"avx512.kxor.w") {
2566 }
else if (
Name ==
"avx512.kxnor.w") {
2572 }
else if (
Name ==
"avx512.knot.w") {
2576 }
else if (
Name ==
"avx512.kortestz.w" ||
Name ==
"avx512.kortestc.w") {
2582 if (
Name[14] ==
'c')
2583 C = ConstantInt::getAllOnesValue(Builder.
getInt16Ty());
2585 C = ConstantInt::getNullValue(Builder.
getInt16Ty());
2588 }
else if (
Name ==
"sse.add.ss" ||
Name ==
"sse2.add.sd" ||
2589 Name ==
"sse.sub.ss" ||
Name ==
"sse2.sub.sd" ||
2590 Name ==
"sse.mul.ss" ||
Name ==
"sse2.mul.sd" ||
2591 Name ==
"sse.div.ss" ||
Name ==
"sse2.div.sd") {
2594 ConstantInt::get(I32Ty, 0));
2596 ConstantInt::get(I32Ty, 0));
2598 if (
Name.contains(
".add."))
2600 else if (
Name.contains(
".sub."))
2602 else if (
Name.contains(
".mul."))
2607 ConstantInt::get(I32Ty, 0));
2608 }
else if (
Name.starts_with(
"avx512.mask.pcmp")) {
2610 bool CmpEq =
Name[16] ==
'e';
2612 }
else if (
Name.starts_with(
"avx512.mask.vpshufbitqmb.")) {
2620 IID = Intrinsic::x86_avx512_vpshufbitqmb_128;
2623 IID = Intrinsic::x86_avx512_vpshufbitqmb_256;
2626 IID = Intrinsic::x86_avx512_vpshufbitqmb_512;
2633 }
else if (
Name.starts_with(
"avx512.mask.fpclass.p")) {
2638 if (VecWidth == 128 && EltWidth == 32)
2639 IID = Intrinsic::x86_avx512_fpclass_ps_128;
2640 else if (VecWidth == 256 && EltWidth == 32)
2641 IID = Intrinsic::x86_avx512_fpclass_ps_256;
2642 else if (VecWidth == 512 && EltWidth == 32)
2643 IID = Intrinsic::x86_avx512_fpclass_ps_512;
2644 else if (VecWidth == 128 && EltWidth == 64)
2645 IID = Intrinsic::x86_avx512_fpclass_pd_128;
2646 else if (VecWidth == 256 && EltWidth == 64)
2647 IID = Intrinsic::x86_avx512_fpclass_pd_256;
2648 else if (VecWidth == 512 && EltWidth == 64)
2649 IID = Intrinsic::x86_avx512_fpclass_pd_512;
2656 }
else if (
Name.starts_with(
"avx512.cmp.p")) {
2658 Type *OpTy = Args[0]->getType();
2662 if (VecWidth == 128 && EltWidth == 32)
2663 IID = Intrinsic::x86_avx512_mask_cmp_ps_128;
2664 else if (VecWidth == 256 && EltWidth == 32)
2665 IID = Intrinsic::x86_avx512_mask_cmp_ps_256;
2666 else if (VecWidth == 512 && EltWidth == 32)
2667 IID = Intrinsic::x86_avx512_mask_cmp_ps_512;
2668 else if (VecWidth == 128 && EltWidth == 64)
2669 IID = Intrinsic::x86_avx512_mask_cmp_pd_128;
2670 else if (VecWidth == 256 && EltWidth == 64)
2671 IID = Intrinsic::x86_avx512_mask_cmp_pd_256;
2672 else if (VecWidth == 512 && EltWidth == 64)
2673 IID = Intrinsic::x86_avx512_mask_cmp_pd_512;
2678 if (VecWidth == 512)
2680 Args.push_back(Mask);
2683 }
else if (
Name.starts_with(
"avx512.mask.cmp.")) {
2685 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
2687 }
else if (
Name.starts_with(
"avx512.mask.ucmp.")) {
2688 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
2690 }
else if (
Name.starts_with(
"avx512.cvtb2mask.") ||
2691 Name.starts_with(
"avx512.cvtw2mask.") ||
2692 Name.starts_with(
"avx512.cvtd2mask.") ||
2693 Name.starts_with(
"avx512.cvtq2mask.")) {
2696 Rep = Builder.
CreateICmp(ICmpInst::ICMP_SLT,
Op, Zero);
2698 }
else if (
Name ==
"ssse3.pabs.b.128" ||
Name ==
"ssse3.pabs.w.128" ||
2699 Name ==
"ssse3.pabs.d.128" ||
Name.starts_with(
"avx2.pabs") ||
2700 Name.starts_with(
"avx512.mask.pabs")) {
2702 }
else if (
Name ==
"sse41.pmaxsb" ||
Name ==
"sse2.pmaxs.w" ||
2703 Name ==
"sse41.pmaxsd" ||
Name.starts_with(
"avx2.pmaxs") ||
2704 Name.starts_with(
"avx512.mask.pmaxs")) {
2706 }
else if (
Name ==
"sse2.pmaxu.b" ||
Name ==
"sse41.pmaxuw" ||
2707 Name ==
"sse41.pmaxud" ||
Name.starts_with(
"avx2.pmaxu") ||
2708 Name.starts_with(
"avx512.mask.pmaxu")) {
2710 }
else if (
Name ==
"sse41.pminsb" ||
Name ==
"sse2.pmins.w" ||
2711 Name ==
"sse41.pminsd" ||
Name.starts_with(
"avx2.pmins") ||
2712 Name.starts_with(
"avx512.mask.pmins")) {
2714 }
else if (
Name ==
"sse2.pminu.b" ||
Name ==
"sse41.pminuw" ||
2715 Name ==
"sse41.pminud" ||
Name.starts_with(
"avx2.pminu") ||
2716 Name.starts_with(
"avx512.mask.pminu")) {
2718 }
else if (
Name ==
"sse2.pmulu.dq" ||
Name ==
"avx2.pmulu.dq" ||
2719 Name ==
"avx512.pmulu.dq.512" ||
2720 Name.starts_with(
"avx512.mask.pmulu.dq.")) {
2722 }
else if (
Name ==
"sse41.pmuldq" ||
Name ==
"avx2.pmul.dq" ||
2723 Name ==
"avx512.pmul.dq.512" ||
2724 Name.starts_with(
"avx512.mask.pmul.dq.")) {
2726 }
else if (
Name ==
"sse.cvtsi2ss" ||
Name ==
"sse2.cvtsi2sd" ||
2727 Name ==
"sse.cvtsi642ss" ||
Name ==
"sse2.cvtsi642sd") {
2730 cast<VectorType>(CI->
getType())->getElementType());
2732 }
else if (
Name ==
"avx512.cvtusi2sd") {
2735 cast<VectorType>(CI->
getType())->getElementType());
2737 }
else if (
Name ==
"sse2.cvtss2sd") {
2740 Rep, cast<VectorType>(CI->
getType())->getElementType());
2742 }
else if (
Name ==
"sse2.cvtdq2pd" ||
Name ==
"sse2.cvtdq2ps" ||
2743 Name ==
"avx.cvtdq2.pd.256" ||
Name ==
"avx.cvtdq2.ps.256" ||
2744 Name.starts_with(
"avx512.mask.cvtdq2pd.") ||
2745 Name.starts_with(
"avx512.mask.cvtudq2pd.") ||
2746 Name.starts_with(
"avx512.mask.cvtdq2ps.") ||
2747 Name.starts_with(
"avx512.mask.cvtudq2ps.") ||
2748 Name.starts_with(
"avx512.mask.cvtqq2pd.") ||
2749 Name.starts_with(
"avx512.mask.cvtuqq2pd.") ||
2750 Name ==
"avx512.mask.cvtqq2ps.256" ||
2751 Name ==
"avx512.mask.cvtqq2ps.512" ||
2752 Name ==
"avx512.mask.cvtuqq2ps.256" ||
2753 Name ==
"avx512.mask.cvtuqq2ps.512" ||
Name ==
"sse2.cvtps2pd" ||
2754 Name ==
"avx.cvt.ps2.pd.256" ||
2755 Name ==
"avx512.mask.cvtps2pd.128" ||
2756 Name ==
"avx512.mask.cvtps2pd.256") {
2757 auto *DstTy = cast<FixedVectorType>(CI->
getType());
2759 auto *SrcTy = cast<FixedVectorType>(Rep->
getType());
2761 unsigned NumDstElts = DstTy->getNumElements();
2763 assert(NumDstElts == 2 &&
"Unexpected vector size");
2767 bool IsPS2PD = SrcTy->getElementType()->isFloatTy();
2768 bool IsUnsigned =
Name.contains(
"cvtu");
2770 Rep = Builder.
CreateFPExt(Rep, DstTy,
"cvtps2pd");
2773 cast<ConstantInt>(CI->
getArgOperand(3))->getZExtValue() != 4)) {
2774 Intrinsic::ID IID = IsUnsigned ? Intrinsic::x86_avx512_uitofp_round
2775 : Intrinsic::x86_avx512_sitofp_round;
2779 Rep = IsUnsigned ? Builder.
CreateUIToFP(Rep, DstTy,
"cvt")
2786 }
else if (
Name.starts_with(
"avx512.mask.vcvtph2ps.") ||
2787 Name.starts_with(
"vcvtph2ps.")) {
2788 auto *DstTy = cast<FixedVectorType>(CI->
getType());
2790 auto *SrcTy = cast<FixedVectorType>(Rep->
getType());
2791 unsigned NumDstElts = DstTy->getNumElements();
2792 if (NumDstElts != SrcTy->getNumElements()) {
2793 assert(NumDstElts == 4 &&
"Unexpected vector size");
2798 Rep = Builder.
CreateFPExt(Rep, DstTy,
"cvtph2ps");
2802 }
else if (
Name.starts_with(
"avx512.mask.load")) {
2807 }
else if (
Name.starts_with(
"avx512.mask.expand.load.")) {
2808 auto *ResultTy = cast<FixedVectorType>(CI->
getType());
2810 ResultTy->getNumElements());
2813 Intrinsic::masked_expandload, ResultTy,
2815 }
else if (
Name.starts_with(
"avx512.mask.compress.store.")) {
2819 cast<FixedVectorType>(ResultTy)->getNumElements());
2822 Intrinsic::masked_compressstore, ResultTy,
2824 }
else if (
Name.starts_with(
"avx512.mask.compress.") ||
2825 Name.starts_with(
"avx512.mask.expand.")) {
2826 auto *ResultTy = cast<FixedVectorType>(CI->
getType());
2829 ResultTy->getNumElements());
2831 bool IsCompress =
Name[12] ==
'c';
2832 Intrinsic::ID IID = IsCompress ? Intrinsic::x86_avx512_mask_compress
2833 : Intrinsic::x86_avx512_mask_expand;
2836 }
else if (
Name.starts_with(
"xop.vpcom")) {
2838 if (
Name.ends_with(
"ub") ||
Name.ends_with(
"uw") ||
Name.ends_with(
"ud") ||
2839 Name.ends_with(
"uq"))
2841 else if (
Name.ends_with(
"b") ||
Name.ends_with(
"w") ||
2842 Name.ends_with(
"d") ||
Name.ends_with(
"q"))
2849 Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
2852 if (
Name.starts_with(
"lt"))
2854 else if (
Name.starts_with(
"le"))
2856 else if (
Name.starts_with(
"gt"))
2858 else if (
Name.starts_with(
"ge"))
2860 else if (
Name.starts_with(
"eq"))
2862 else if (
Name.starts_with(
"ne"))
2864 else if (
Name.starts_with(
"false"))
2866 else if (
Name.starts_with(
"true"))
2873 }
else if (
Name.starts_with(
"xop.vpcmov")) {
2878 Rep = Builder.
CreateOr(Sel0, Sel1);
2879 }
else if (
Name.starts_with(
"xop.vprot") ||
Name.starts_with(
"avx512.prol") ||
2880 Name.starts_with(
"avx512.mask.prol")) {
2882 }
else if (
Name.starts_with(
"avx512.pror") ||
2883 Name.starts_with(
"avx512.mask.pror")) {
2885 }
else if (
Name.starts_with(
"avx512.vpshld.") ||
2886 Name.starts_with(
"avx512.mask.vpshld") ||
2887 Name.starts_with(
"avx512.maskz.vpshld")) {
2888 bool ZeroMask =
Name[11] ==
'z';
2890 }
else if (
Name.starts_with(
"avx512.vpshrd.") ||
2891 Name.starts_with(
"avx512.mask.vpshrd") ||
2892 Name.starts_with(
"avx512.maskz.vpshrd")) {
2893 bool ZeroMask =
Name[11] ==
'z';
2895 }
else if (
Name ==
"sse42.crc32.64.8") {
2901 }
else if (
Name.starts_with(
"avx.vbroadcast.s") ||
2902 Name.starts_with(
"avx512.vbroadcast.s")) {
2904 auto *VecTy = cast<FixedVectorType>(CI->
getType());
2905 Type *EltTy = VecTy->getElementType();
2906 unsigned EltNum = VecTy->getNumElements();
2910 for (
unsigned I = 0;
I < EltNum; ++
I)
2912 }
else if (
Name.starts_with(
"sse41.pmovsx") ||
2913 Name.starts_with(
"sse41.pmovzx") ||
2914 Name.starts_with(
"avx2.pmovsx") ||
2915 Name.starts_with(
"avx2.pmovzx") ||
2916 Name.starts_with(
"avx512.mask.pmovsx") ||
2917 Name.starts_with(
"avx512.mask.pmovzx")) {
2918 auto *DstTy = cast<FixedVectorType>(CI->
getType());
2919 unsigned NumDstElts = DstTy->getNumElements();
2923 for (
unsigned i = 0; i != NumDstElts; ++i)
2928 bool DoSext =
Name.contains(
"pmovsx");
2935 }
else if (
Name ==
"avx512.mask.pmov.qd.256" ||
2936 Name ==
"avx512.mask.pmov.qd.512" ||
2937 Name ==
"avx512.mask.pmov.wb.256" ||
2938 Name ==
"avx512.mask.pmov.wb.512") {
2943 }
else if (
Name.starts_with(
"avx.vbroadcastf128") ||
2944 Name ==
"avx2.vbroadcasti128") {
2946 Type *EltTy = cast<VectorType>(CI->
getType())->getElementType();
2950 if (NumSrcElts == 2)
2955 }
else if (
Name.starts_with(
"avx512.mask.shuf.i") ||
2956 Name.starts_with(
"avx512.mask.shuf.f")) {
2957 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
2961 unsigned ControlBitsMask = NumLanes - 1;
2962 unsigned NumControlBits = NumLanes / 2;
2965 for (
unsigned l = 0; l != NumLanes; ++l) {
2966 unsigned LaneMask = (Imm >> (l * NumControlBits)) & ControlBitsMask;
2968 if (l >= NumLanes / 2)
2969 LaneMask += NumLanes;
2970 for (
unsigned i = 0; i != NumElementsInLane; ++i)
2971 ShuffleMask.
push_back(LaneMask * NumElementsInLane + i);
2977 }
else if (
Name.starts_with(
"avx512.mask.broadcastf") ||
2978 Name.starts_with(
"avx512.mask.broadcasti")) {
2981 unsigned NumDstElts =
2982 cast<FixedVectorType>(CI->
getType())->getNumElements();
2985 for (
unsigned i = 0; i != NumDstElts; ++i)
2986 ShuffleMask[i] = i % NumSrcElts;
2992 }
else if (
Name.starts_with(
"avx2.pbroadcast") ||
2993 Name.starts_with(
"avx2.vbroadcast") ||
2994 Name.starts_with(
"avx512.pbroadcast") ||
2995 Name.starts_with(
"avx512.mask.broadcast.s")) {
3007 }
else if (
Name.starts_with(
"sse2.padds.") ||
3008 Name.starts_with(
"avx2.padds.") ||
3009 Name.starts_with(
"avx512.padds.") ||
3010 Name.starts_with(
"avx512.mask.padds.")) {
3012 }
else if (
Name.starts_with(
"sse2.psubs.") ||
3013 Name.starts_with(
"avx2.psubs.") ||
3014 Name.starts_with(
"avx512.psubs.") ||
3015 Name.starts_with(
"avx512.mask.psubs.")) {
3017 }
else if (
Name.starts_with(
"sse2.paddus.") ||
3018 Name.starts_with(
"avx2.paddus.") ||
3019 Name.starts_with(
"avx512.mask.paddus.")) {
3021 }
else if (
Name.starts_with(
"sse2.psubus.") ||
3022 Name.starts_with(
"avx2.psubus.") ||
3023 Name.starts_with(
"avx512.mask.psubus.")) {
3025 }
else if (
Name.starts_with(
"avx512.mask.palignr.")) {
3030 }
else if (
Name.starts_with(
"avx512.mask.valign.")) {
3034 }
else if (
Name ==
"sse2.psll.dq" ||
Name ==
"avx2.psll.dq") {
3036 unsigned Shift = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
3039 }
else if (
Name ==
"sse2.psrl.dq" ||
Name ==
"avx2.psrl.dq") {
3041 unsigned Shift = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
3044 }
else if (
Name ==
"sse2.psll.dq.bs" ||
Name ==
"avx2.psll.dq.bs" ||
3045 Name ==
"avx512.psll.dq.512") {
3047 unsigned Shift = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
3049 }
else if (
Name ==
"sse2.psrl.dq.bs" ||
Name ==
"avx2.psrl.dq.bs" ||
3050 Name ==
"avx512.psrl.dq.512") {
3052 unsigned Shift = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
3054 }
else if (
Name ==
"sse41.pblendw" ||
Name.starts_with(
"sse41.blendp") ||
3055 Name.starts_with(
"avx.blend.p") ||
Name ==
"avx2.pblendw" ||
3056 Name.starts_with(
"avx2.pblendd.")) {
3059 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
3060 auto *VecTy = cast<FixedVectorType>(CI->
getType());
3061 unsigned NumElts = VecTy->getNumElements();
3064 for (
unsigned i = 0; i != NumElts; ++i)
3065 Idxs[i] = ((Imm >> (i % 8)) & 1) ? i + NumElts : i;
3068 }
else if (
Name.starts_with(
"avx.vinsertf128.") ||
3069 Name ==
"avx2.vinserti128" ||
3070 Name.starts_with(
"avx512.mask.insert")) {
3073 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
3074 unsigned DstNumElts =
3075 cast<FixedVectorType>(CI->
getType())->getNumElements();
3076 unsigned SrcNumElts =
3077 cast<FixedVectorType>(Op1->
getType())->getNumElements();
3078 unsigned Scale = DstNumElts / SrcNumElts;
3085 for (
unsigned i = 0; i != SrcNumElts; ++i)
3087 for (
unsigned i = SrcNumElts; i != DstNumElts; ++i)
3088 Idxs[i] = SrcNumElts;
3103 for (
unsigned i = 0; i != DstNumElts; ++i)
3106 for (
unsigned i = 0; i != SrcNumElts; ++i)
3107 Idxs[i + Imm * SrcNumElts] = i + DstNumElts;
3114 }
else if (
Name.starts_with(
"avx.vextractf128.") ||
3115 Name ==
"avx2.vextracti128" ||
3116 Name.starts_with(
"avx512.mask.vextract")) {
3118 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
3119 unsigned DstNumElts =
3120 cast<FixedVectorType>(CI->
getType())->getNumElements();
3121 unsigned SrcNumElts =
3122 cast<FixedVectorType>(Op0->
getType())->getNumElements();
3123 unsigned Scale = SrcNumElts / DstNumElts;
3130 for (
unsigned i = 0; i != DstNumElts; ++i) {
3131 Idxs[i] = i + (Imm * DstNumElts);
3139 }
else if (
Name.starts_with(
"avx512.mask.perm.df.") ||
3140 Name.starts_with(
"avx512.mask.perm.di.")) {
3142 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
3143 auto *VecTy = cast<FixedVectorType>(CI->
getType());
3144 unsigned NumElts = VecTy->getNumElements();
3147 for (
unsigned i = 0; i != NumElts; ++i)
3148 Idxs[i] = (i & ~0x3) + ((Imm >> (2 * (i & 0x3))) & 3);
3155 }
else if (
Name.starts_with(
"avx.vperm2f128.") ||
Name ==
"avx2.vperm2i128") {
3166 unsigned NumElts = cast<FixedVectorType>(CI->
getType())->getNumElements();
3167 unsigned HalfSize = NumElts / 2;
3179 unsigned StartIndex = (Imm & 0x01) ? HalfSize : 0;
3180 for (
unsigned i = 0; i < HalfSize; ++i)
3181 ShuffleMask[i] = StartIndex + i;
3184 StartIndex = (Imm & 0x10) ? HalfSize : 0;
3185 for (
unsigned i = 0; i < HalfSize; ++i)
3186 ShuffleMask[i + HalfSize] = NumElts + StartIndex + i;
3190 }
else if (
Name.starts_with(
"avx.vpermil.") ||
Name ==
"sse2.pshuf.d" ||
3191 Name.starts_with(
"avx512.mask.vpermil.p") ||
3192 Name.starts_with(
"avx512.mask.pshuf.d.")) {
3194 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
3195 auto *VecTy = cast<FixedVectorType>(CI->
getType());
3196 unsigned NumElts = VecTy->getNumElements();
3198 unsigned IdxSize = 64 / VecTy->getScalarSizeInBits();
3199 unsigned IdxMask = ((1 << IdxSize) - 1);
3205 for (
unsigned i = 0; i != NumElts; ++i)
3206 Idxs[i] = ((Imm >> ((i * IdxSize) % 8)) & IdxMask) | (i & ~IdxMask);
3213 }
else if (
Name ==
"sse2.pshufl.w" ||
3214 Name.starts_with(
"avx512.mask.pshufl.w.")) {
3216 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
3217 unsigned NumElts = cast<FixedVectorType>(CI->
getType())->getNumElements();
3220 for (
unsigned l = 0; l != NumElts; l += 8) {
3221 for (
unsigned i = 0; i != 4; ++i)
3222 Idxs[i + l] = ((Imm >> (2 * i)) & 0x3) + l;
3223 for (
unsigned i = 4; i != 8; ++i)
3224 Idxs[i + l] = i + l;
3232 }
else if (
Name ==
"sse2.pshufh.w" ||
3233 Name.starts_with(
"avx512.mask.pshufh.w.")) {
3235 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
3236 unsigned NumElts = cast<FixedVectorType>(CI->
getType())->getNumElements();
3239 for (
unsigned l = 0; l != NumElts; l += 8) {
3240 for (
unsigned i = 0; i != 4; ++i)
3241 Idxs[i + l] = i + l;
3242 for (
unsigned i = 0; i != 4; ++i)
3243 Idxs[i + l + 4] = ((Imm >> (2 * i)) & 0x3) + 4 + l;
3251 }
else if (
Name.starts_with(
"avx512.mask.shuf.p")) {
3254 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
3255 unsigned NumElts = cast<FixedVectorType>(CI->
getType())->getNumElements();
3258 unsigned HalfLaneElts = NumLaneElts / 2;
3261 for (
unsigned i = 0; i != NumElts; ++i) {
3263 Idxs[i] = i - (i % NumLaneElts);
3265 if ((i % NumLaneElts) >= HalfLaneElts)
3269 Idxs[i] += (Imm >> ((i * HalfLaneElts) % 8)) & ((1 << HalfLaneElts) - 1);
3276 }
else if (
Name.starts_with(
"avx512.mask.movddup") ||
3277 Name.starts_with(
"avx512.mask.movshdup") ||
3278 Name.starts_with(
"avx512.mask.movsldup")) {
3280 unsigned NumElts = cast<FixedVectorType>(CI->
getType())->getNumElements();
3284 if (
Name.starts_with(
"avx512.mask.movshdup."))
3288 for (
unsigned l = 0; l != NumElts; l += NumLaneElts)
3289 for (
unsigned i = 0; i != NumLaneElts; i += 2) {
3290 Idxs[i + l + 0] = i + l +
Offset;
3291 Idxs[i + l + 1] = i + l +
Offset;
3298 }
else if (
Name.starts_with(
"avx512.mask.punpckl") ||
3299 Name.starts_with(
"avx512.mask.unpckl.")) {
3302 int NumElts = cast<FixedVectorType>(CI->
getType())->getNumElements();
3306 for (
int l = 0; l != NumElts; l += NumLaneElts)
3307 for (
int i = 0; i != NumLaneElts; ++i)
3308 Idxs[i + l] = l + (i / 2) + NumElts * (i % 2);
3314 }
else if (
Name.starts_with(
"avx512.mask.punpckh") ||
3315 Name.starts_with(
"avx512.mask.unpckh.")) {
3318 int NumElts = cast<FixedVectorType>(CI->
getType())->getNumElements();
3322 for (
int l = 0; l != NumElts; l += NumLaneElts)
3323 for (
int i = 0; i != NumLaneElts; ++i)
3324 Idxs[i + l] = (NumLaneElts / 2) + l + (i / 2) + NumElts * (i % 2);
3330 }
else if (
Name.starts_with(
"avx512.mask.and.") ||
3331 Name.starts_with(
"avx512.mask.pand.")) {
3333 VectorType *ITy = VectorType::getInteger(FTy);
3339 }
else if (
Name.starts_with(
"avx512.mask.andn.") ||
3340 Name.starts_with(
"avx512.mask.pandn.")) {
3342 VectorType *ITy = VectorType::getInteger(FTy);
3349 }
else if (
Name.starts_with(
"avx512.mask.or.") ||
3350 Name.starts_with(
"avx512.mask.por.")) {
3352 VectorType *ITy = VectorType::getInteger(FTy);
3358 }
else if (
Name.starts_with(
"avx512.mask.xor.") ||
3359 Name.starts_with(
"avx512.mask.pxor.")) {
3361 VectorType *ITy = VectorType::getInteger(FTy);
3367 }
else if (
Name.starts_with(
"avx512.mask.padd.")) {
3371 }
else if (
Name.starts_with(
"avx512.mask.psub.")) {
3375 }
else if (
Name.starts_with(
"avx512.mask.pmull.")) {
3379 }
else if (
Name.starts_with(
"avx512.mask.add.p")) {
3380 if (
Name.ends_with(
".512")) {
3382 if (
Name[17] ==
's')
3383 IID = Intrinsic::x86_avx512_add_ps_512;
3385 IID = Intrinsic::x86_avx512_add_pd_512;
3395 }
else if (
Name.starts_with(
"avx512.mask.div.p")) {
3396 if (
Name.ends_with(
".512")) {
3398 if (
Name[17] ==
's')
3399 IID = Intrinsic::x86_avx512_div_ps_512;
3401 IID = Intrinsic::x86_avx512_div_pd_512;
3411 }
else if (
Name.starts_with(
"avx512.mask.mul.p")) {
3412 if (
Name.ends_with(
".512")) {
3414 if (
Name[17] ==
's')
3415 IID = Intrinsic::x86_avx512_mul_ps_512;
3417 IID = Intrinsic::x86_avx512_mul_pd_512;
3427 }
else if (
Name.starts_with(
"avx512.mask.sub.p")) {
3428 if (
Name.ends_with(
".512")) {
3430 if (
Name[17] ==
's')
3431 IID = Intrinsic::x86_avx512_sub_ps_512;
3433 IID = Intrinsic::x86_avx512_sub_pd_512;
3443 }
else if ((
Name.starts_with(
"avx512.mask.max.p") ||
3444 Name.starts_with(
"avx512.mask.min.p")) &&
3445 Name.drop_front(18) ==
".512") {
3446 bool IsDouble =
Name[17] ==
'd';
3447 bool IsMin =
Name[13] ==
'i';
3449 {Intrinsic::x86_avx512_max_ps_512, Intrinsic::x86_avx512_max_pd_512},
3450 {Intrinsic::x86_avx512_min_ps_512, Intrinsic::x86_avx512_min_pd_512}};
3458 }
else if (
Name.starts_with(
"avx512.mask.lzcnt.")) {
3461 {CI->getArgOperand(0), Builder.getInt1(false)});
3464 }
else if (
Name.starts_with(
"avx512.mask.psll")) {
3465 bool IsImmediate =
Name[16] ==
'i' || (
Name.size() > 18 &&
Name[18] ==
'i');
3466 bool IsVariable =
Name[16] ==
'v';
3473 if (IsVariable &&
Name[17] !=
'.') {
3474 if (
Size ==
'd' &&
Name[17] ==
'2')
3475 IID = Intrinsic::x86_avx2_psllv_q;
3476 else if (
Size ==
'd' &&
Name[17] ==
'4')
3477 IID = Intrinsic::x86_avx2_psllv_q_256;
3478 else if (
Size ==
's' &&
Name[17] ==
'4')
3479 IID = Intrinsic::x86_avx2_psllv_d;
3480 else if (
Size ==
's' &&
Name[17] ==
'8')
3481 IID = Intrinsic::x86_avx2_psllv_d_256;
3482 else if (
Size ==
'h' &&
Name[17] ==
'8')
3483 IID = Intrinsic::x86_avx512_psllv_w_128;
3484 else if (
Size ==
'h' &&
Name[17] ==
'1')
3485 IID = Intrinsic::x86_avx512_psllv_w_256;
3486 else if (
Name[17] ==
'3' &&
Name[18] ==
'2')
3487 IID = Intrinsic::x86_avx512_psllv_w_512;
3490 }
else if (
Name.ends_with(
".128")) {
3492 IID = IsImmediate ? Intrinsic::x86_sse2_pslli_d
3493 : Intrinsic::x86_sse2_psll_d;
3494 else if (
Size ==
'q')
3495 IID = IsImmediate ? Intrinsic::x86_sse2_pslli_q
3496 : Intrinsic::x86_sse2_psll_q;
3497 else if (
Size ==
'w')
3498 IID = IsImmediate ? Intrinsic::x86_sse2_pslli_w
3499 : Intrinsic::x86_sse2_psll_w;
3502 }
else if (
Name.ends_with(
".256")) {
3504 IID = IsImmediate ? Intrinsic::x86_avx2_pslli_d
3505 : Intrinsic::x86_avx2_psll_d;
3506 else if (
Size ==
'q')
3507 IID = IsImmediate ? Intrinsic::x86_avx2_pslli_q
3508 : Intrinsic::x86_avx2_psll_q;
3509 else if (
Size ==
'w')
3510 IID = IsImmediate ? Intrinsic::x86_avx2_pslli_w
3511 : Intrinsic::x86_avx2_psll_w;
3516 IID = IsImmediate ? Intrinsic::x86_avx512_pslli_d_512
3517 : IsVariable ? Intrinsic::x86_avx512_psllv_d_512
3518 : Intrinsic::x86_avx512_psll_d_512;
3519 else if (
Size ==
'q')
3520 IID = IsImmediate ? Intrinsic::x86_avx512_pslli_q_512
3521 : IsVariable ? Intrinsic::x86_avx512_psllv_q_512
3522 : Intrinsic::x86_avx512_psll_q_512;
3523 else if (
Size ==
'w')
3524 IID = IsImmediate ? Intrinsic::x86_avx512_pslli_w_512
3525 : Intrinsic::x86_avx512_psll_w_512;
3531 }
else if (
Name.starts_with(
"avx512.mask.psrl")) {
3532 bool IsImmediate =
Name[16] ==
'i' || (
Name.size() > 18 &&
Name[18] ==
'i');
3533 bool IsVariable =
Name[16] ==
'v';
3540 if (IsVariable &&
Name[17] !=
'.') {
3541 if (
Size ==
'd' &&
Name[17] ==
'2')
3542 IID = Intrinsic::x86_avx2_psrlv_q;
3543 else if (
Size ==
'd' &&
Name[17] ==
'4')
3544 IID = Intrinsic::x86_avx2_psrlv_q_256;
3545 else if (
Size ==
's' &&
Name[17] ==
'4')
3546 IID = Intrinsic::x86_avx2_psrlv_d;
3547 else if (
Size ==
's' &&
Name[17] ==
'8')
3548 IID = Intrinsic::x86_avx2_psrlv_d_256;
3549 else if (
Size ==
'h' &&
Name[17] ==
'8')
3550 IID = Intrinsic::x86_avx512_psrlv_w_128;
3551 else if (
Size ==
'h' &&
Name[17] ==
'1')
3552 IID = Intrinsic::x86_avx512_psrlv_w_256;
3553 else if (
Name[17] ==
'3' &&
Name[18] ==
'2')
3554 IID = Intrinsic::x86_avx512_psrlv_w_512;
3557 }
else if (
Name.ends_with(
".128")) {
3559 IID = IsImmediate ? Intrinsic::x86_sse2_psrli_d
3560 : Intrinsic::x86_sse2_psrl_d;
3561 else if (
Size ==
'q')
3562 IID = IsImmediate ? Intrinsic::x86_sse2_psrli_q
3563 : Intrinsic::x86_sse2_psrl_q;
3564 else if (
Size ==
'w')
3565 IID = IsImmediate ? Intrinsic::x86_sse2_psrli_w
3566 : Intrinsic::x86_sse2_psrl_w;
3569 }
else if (
Name.ends_with(
".256")) {
3571 IID = IsImmediate ? Intrinsic::x86_avx2_psrli_d
3572 : Intrinsic::x86_avx2_psrl_d;
3573 else if (
Size ==
'q')
3574 IID = IsImmediate ? Intrinsic::x86_avx2_psrli_q
3575 : Intrinsic::x86_avx2_psrl_q;
3576 else if (
Size ==
'w')
3577 IID = IsImmediate ? Intrinsic::x86_avx2_psrli_w
3578 : Intrinsic::x86_avx2_psrl_w;
3583 IID = IsImmediate ? Intrinsic::x86_avx512_psrli_d_512
3584 : IsVariable ? Intrinsic::x86_avx512_psrlv_d_512
3585 : Intrinsic::x86_avx512_psrl_d_512;
3586 else if (
Size ==
'q')
3587 IID = IsImmediate ? Intrinsic::x86_avx512_psrli_q_512
3588 : IsVariable ? Intrinsic::x86_avx512_psrlv_q_512
3589 : Intrinsic::x86_avx512_psrl_q_512;
3590 else if (
Size ==
'w')
3591 IID = IsImmediate ? Intrinsic::x86_avx512_psrli_w_512
3592 : Intrinsic::x86_avx512_psrl_w_512;
3598 }
else if (
Name.starts_with(
"avx512.mask.psra")) {
3599 bool IsImmediate =
Name[16] ==
'i' || (
Name.size() > 18 &&
Name[18] ==
'i');
3600 bool IsVariable =
Name[16] ==
'v';
3607 if (IsVariable &&
Name[17] !=
'.') {
3608 if (
Size ==
's' &&
Name[17] ==
'4')
3609 IID = Intrinsic::x86_avx2_psrav_d;
3610 else if (
Size ==
's' &&
Name[17] ==
'8')
3611 IID = Intrinsic::x86_avx2_psrav_d_256;
3612 else if (
Size ==
'h' &&
Name[17] ==
'8')
3613 IID = Intrinsic::x86_avx512_psrav_w_128;
3614 else if (
Size ==
'h' &&
Name[17] ==
'1')
3615 IID = Intrinsic::x86_avx512_psrav_w_256;
3616 else if (
Name[17] ==
'3' &&
Name[18] ==
'2')
3617 IID = Intrinsic::x86_avx512_psrav_w_512;
3620 }
else if (
Name.ends_with(
".128")) {
3622 IID = IsImmediate ? Intrinsic::x86_sse2_psrai_d
3623 : Intrinsic::x86_sse2_psra_d;
3624 else if (
Size ==
'q')
3625 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_q_128
3626 : IsVariable ? Intrinsic::x86_avx512_psrav_q_128
3627 : Intrinsic::x86_avx512_psra_q_128;
3628 else if (
Size ==
'w')
3629 IID = IsImmediate ? Intrinsic::x86_sse2_psrai_w
3630 : Intrinsic::x86_sse2_psra_w;
3633 }
else if (
Name.ends_with(
".256")) {
3635 IID = IsImmediate ? Intrinsic::x86_avx2_psrai_d
3636 : Intrinsic::x86_avx2_psra_d;
3637 else if (
Size ==
'q')
3638 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_q_256
3639 : IsVariable ? Intrinsic::x86_avx512_psrav_q_256
3640 : Intrinsic::x86_avx512_psra_q_256;
3641 else if (
Size ==
'w')
3642 IID = IsImmediate ? Intrinsic::x86_avx2_psrai_w
3643 : Intrinsic::x86_avx2_psra_w;
3648 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_d_512
3649 : IsVariable ? Intrinsic::x86_avx512_psrav_d_512
3650 : Intrinsic::x86_avx512_psra_d_512;
3651 else if (
Size ==
'q')
3652 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_q_512
3653 : IsVariable ? Intrinsic::x86_avx512_psrav_q_512
3654 : Intrinsic::x86_avx512_psra_q_512;
3655 else if (
Size ==
'w')
3656 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_w_512
3657 : Intrinsic::x86_avx512_psra_w_512;
3663 }
else if (
Name.starts_with(
"avx512.mask.move.s")) {
3665 }
else if (
Name.starts_with(
"avx512.cvtmask2")) {
3667 }
else if (
Name.ends_with(
".movntdqa")) {
3676 }
else if (
Name.starts_with(
"fma.vfmadd.") ||
3677 Name.starts_with(
"fma.vfmsub.") ||
3678 Name.starts_with(
"fma.vfnmadd.") ||
3679 Name.starts_with(
"fma.vfnmsub.")) {
3680 bool NegMul =
Name[6] ==
'n';
3681 bool NegAcc = NegMul ?
Name[8] ==
's' :
Name[7] ==
's';
3682 bool IsScalar = NegMul ?
Name[12] ==
's' :
Name[11] ==
's';
3693 if (NegMul && !IsScalar)
3695 if (NegMul && IsScalar)
3704 }
else if (
Name.starts_with(
"fma4.vfmadd.s")) {
3716 }
else if (
Name.starts_with(
"avx512.mask.vfmadd.s") ||
3717 Name.starts_with(
"avx512.maskz.vfmadd.s") ||
3718 Name.starts_with(
"avx512.mask3.vfmadd.s") ||
3719 Name.starts_with(
"avx512.mask3.vfmsub.s") ||
3720 Name.starts_with(
"avx512.mask3.vfnmsub.s")) {
3721 bool IsMask3 =
Name[11] ==
'3';
3722 bool IsMaskZ =
Name[11] ==
'z';
3724 Name =
Name.drop_front(IsMask3 || IsMaskZ ? 13 : 12);
3725 bool NegMul =
Name[2] ==
'n';
3726 bool NegAcc = NegMul ?
Name[4] ==
's' :
Name[3] ==
's';
3732 if (NegMul && (IsMask3 || IsMaskZ))
3734 if (NegMul && !(IsMask3 || IsMaskZ))
3744 cast<ConstantInt>(CI->
getArgOperand(4))->getZExtValue() != 4) {
3748 if (
Name.back() ==
'd')
3749 IID = Intrinsic::x86_avx512_vfmadd_f64;
3751 IID = Intrinsic::x86_avx512_vfmadd_f32;
3763 if (NegAcc && IsMask3)
3770 }
else if (
Name.starts_with(
"avx512.mask.vfmadd.p") ||
3771 Name.starts_with(
"avx512.mask.vfnmadd.p") ||
3772 Name.starts_with(
"avx512.mask.vfnmsub.p") ||
3773 Name.starts_with(
"avx512.mask3.vfmadd.p") ||
3774 Name.starts_with(
"avx512.mask3.vfmsub.p") ||
3775 Name.starts_with(
"avx512.mask3.vfnmsub.p") ||
3776 Name.starts_with(
"avx512.maskz.vfmadd.p")) {
3777 bool IsMask3 =
Name[11] ==
'3';
3778 bool IsMaskZ =
Name[11] ==
'z';
3780 Name =
Name.drop_front(IsMask3 || IsMaskZ ? 13 : 12);
3781 bool NegMul =
Name[2] ==
'n';
3782 bool NegAcc = NegMul ?
Name[4] ==
's' :
Name[3] ==
's';
3788 if (NegMul && (IsMask3 || IsMaskZ))
3790 if (NegMul && !(IsMask3 || IsMaskZ))
3797 cast<ConstantInt>(CI->
getArgOperand(4))->getZExtValue() != 4)) {
3801 IID = Intrinsic::x86_avx512_vfmadd_ps_512;
3803 IID = Intrinsic::x86_avx512_vfmadd_pd_512;
3815 }
else if (
Name.starts_with(
"fma.vfmsubadd.p")) {
3819 if (VecWidth == 128 && EltWidth == 32)
3820 IID = Intrinsic::x86_fma_vfmaddsub_ps;
3821 else if (VecWidth == 256 && EltWidth == 32)
3822 IID = Intrinsic::x86_fma_vfmaddsub_ps_256;
3823 else if (VecWidth == 128 && EltWidth == 64)
3824 IID = Intrinsic::x86_fma_vfmaddsub_pd;
3825 else if (VecWidth == 256 && EltWidth == 64)
3826 IID = Intrinsic::x86_fma_vfmaddsub_pd_256;
3834 }
else if (
Name.starts_with(
"avx512.mask.vfmaddsub.p") ||
3835 Name.starts_with(
"avx512.mask3.vfmaddsub.p") ||
3836 Name.starts_with(
"avx512.maskz.vfmaddsub.p") ||
3837 Name.starts_with(
"avx512.mask3.vfmsubadd.p")) {
3838 bool IsMask3 =
Name[11] ==
'3';
3839 bool IsMaskZ =
Name[11] ==
'z';
3841 Name =
Name.drop_front(IsMask3 || IsMaskZ ? 13 : 12);
3842 bool IsSubAdd =
Name[3] ==
's';
3847 IID = Intrinsic::x86_avx512_vfmaddsub_ps_512;
3849 IID = Intrinsic::x86_avx512_vfmaddsub_pd_512;
3858 int NumElts = cast<FixedVectorType>(CI->
getType())->getNumElements();
3873 for (
int i = 0; i != NumElts; ++i)
3874 Idxs[i] = i + (i % 2) * NumElts;
3884 }
else if (
Name.starts_with(
"avx512.mask.pternlog.") ||
3885 Name.starts_with(
"avx512.maskz.pternlog.")) {
3886 bool ZeroMask =
Name[11] ==
'z';
3890 if (VecWidth == 128 && EltWidth == 32)
3891 IID = Intrinsic::x86_avx512_pternlog_d_128;
3892 else if (VecWidth == 256 && EltWidth == 32)
3893 IID = Intrinsic::x86_avx512_pternlog_d_256;
3894 else if (VecWidth == 512 && EltWidth == 32)
3895 IID = Intrinsic::x86_avx512_pternlog_d_512;
3896 else if (VecWidth == 128 && EltWidth == 64)
3897 IID = Intrinsic::x86_avx512_pternlog_q_128;
3898 else if (VecWidth == 256 && EltWidth == 64)
3899 IID = Intrinsic::x86_avx512_pternlog_q_256;
3900 else if (VecWidth == 512 && EltWidth == 64)
3901 IID = Intrinsic::x86_avx512_pternlog_q_512;
3911 }
else if (
Name.starts_with(
"avx512.mask.vpmadd52") ||
3912 Name.starts_with(
"avx512.maskz.vpmadd52")) {
3913 bool ZeroMask =
Name[11] ==
'z';
3917 if (VecWidth == 128 && !
High)
3918 IID = Intrinsic::x86_avx512_vpmadd52l_uq_128;
3919 else if (VecWidth == 256 && !
High)
3920 IID = Intrinsic::x86_avx512_vpmadd52l_uq_256;
3921 else if (VecWidth == 512 && !
High)
3922 IID = Intrinsic::x86_avx512_vpmadd52l_uq_512;
3923 else if (VecWidth == 128 &&
High)
3924 IID = Intrinsic::x86_avx512_vpmadd52h_uq_128;
3925 else if (VecWidth == 256 &&
High)
3926 IID = Intrinsic::x86_avx512_vpmadd52h_uq_256;
3927 else if (VecWidth == 512 &&
High)
3928 IID = Intrinsic::x86_avx512_vpmadd52h_uq_512;
3938 }
else if (
Name.starts_with(
"avx512.mask.vpermi2var.") ||
3939 Name.starts_with(
"avx512.mask.vpermt2var.") ||
3940 Name.starts_with(
"avx512.maskz.vpermt2var.")) {
3941 bool ZeroMask =
Name[11] ==
'z';
3942 bool IndexForm =
Name[17] ==
'i';
3944 }
else if (
Name.starts_with(
"avx512.mask.vpdpbusd.") ||
3945 Name.starts_with(
"avx512.maskz.vpdpbusd.") ||
3946 Name.starts_with(
"avx512.mask.vpdpbusds.") ||
3947 Name.starts_with(
"avx512.maskz.vpdpbusds.")) {
3948 bool ZeroMask =
Name[11] ==
'z';
3949 bool IsSaturating =
Name[ZeroMask ? 21 : 20] ==
's';
3952 if (VecWidth == 128 && !IsSaturating)
3953 IID = Intrinsic::x86_avx512_vpdpbusd_128;
3954 else if (VecWidth == 256 && !IsSaturating)
3955 IID = Intrinsic::x86_avx512_vpdpbusd_256;
3956 else if (VecWidth == 512 && !IsSaturating)
3957 IID = Intrinsic::x86_avx512_vpdpbusd_512;
3958 else if (VecWidth == 128 && IsSaturating)
3959 IID = Intrinsic::x86_avx512_vpdpbusds_128;
3960 else if (VecWidth == 256 && IsSaturating)
3961 IID = Intrinsic::x86_avx512_vpdpbusds_256;
3962 else if (VecWidth == 512 && IsSaturating)
3963 IID = Intrinsic::x86_avx512_vpdpbusds_512;
3973 }
else if (
Name.starts_with(
"avx512.mask.vpdpwssd.") ||
3974 Name.starts_with(
"avx512.maskz.vpdpwssd.") ||
3975 Name.starts_with(
"avx512.mask.vpdpwssds.") ||
3976 Name.starts_with(
"avx512.maskz.vpdpwssds.")) {
3977 bool ZeroMask =
Name[11] ==
'z';
3978 bool IsSaturating =
Name[ZeroMask ? 21 : 20] ==
's';
3981 if (VecWidth == 128 && !IsSaturating)
3982 IID = Intrinsic::x86_avx512_vpdpwssd_128;
3983 else if (VecWidth == 256 && !IsSaturating)
3984 IID = Intrinsic::x86_avx512_vpdpwssd_256;
3985 else if (VecWidth == 512 && !IsSaturating)
3986 IID = Intrinsic::x86_avx512_vpdpwssd_512;
3987 else if (VecWidth == 128 && IsSaturating)
3988 IID = Intrinsic::x86_avx512_vpdpwssds_128;
3989 else if (VecWidth == 256 && IsSaturating)
3990 IID = Intrinsic::x86_avx512_vpdpwssds_256;
3991 else if (VecWidth == 512 && IsSaturating)
3992 IID = Intrinsic::x86_avx512_vpdpwssds_512;
4002 }
else if (
Name ==
"addcarryx.u32" ||
Name ==
"addcarryx.u64" ||
4003 Name ==
"addcarry.u32" ||
Name ==
"addcarry.u64" ||
4004 Name ==
"subborrow.u32" ||
Name ==
"subborrow.u64") {
4006 if (
Name[0] ==
'a' &&
Name.back() ==
'2')
4007 IID = Intrinsic::x86_addcarry_32;
4008 else if (
Name[0] ==
'a' &&
Name.back() ==
'4')
4009 IID = Intrinsic::x86_addcarry_64;
4010 else if (
Name[0] ==
's' &&
Name.back() ==
'2')
4011 IID = Intrinsic::x86_subborrow_32;
4012 else if (
Name[0] ==
's' &&
Name.back() ==
'4')
4013 IID = Intrinsic::x86_subborrow_64;
4030 }
else if (
Name.starts_with(
"avx512.mask.") &&
4040 if (
Name.starts_with(
"neon.bfcvt")) {
4041 if (
Name.starts_with(
"neon.bfcvtn2")) {
4043 std::iota(LoMask.
begin(), LoMask.
end(), 0);
4045 std::iota(ConcatMask.
begin(), ConcatMask.
end(), 0);
4050 }
else if (
Name.starts_with(
"neon.bfcvtn")) {
4052 std::iota(ConcatMask.
begin(), ConcatMask.
end(), 0);
4056 dbgs() <<
"Trunc: " << *Trunc <<
"\n";
4063 }
else if (
Name.starts_with(
"sve.fcvt")) {
4066 .
Case(
"sve.fcvt.bf16f32", Intrinsic::aarch64_sve_fcvt_bf16f32_v2)
4067 .
Case(
"sve.fcvtnt.bf16f32",
4068 Intrinsic::aarch64_sve_fcvtnt_bf16f32_v2)
4080 if (Args[1]->
getType() != BadPredTy)
4083 Args[1] = Builder.
CreateIntrinsic(Intrinsic::aarch64_sve_convert_to_svbool,
4084 BadPredTy, Args[1]);
4086 Intrinsic::aarch64_sve_convert_from_svbool, GoodPredTy, Args[1]);
4097 if (
Name ==
"mve.vctp64.old") {
4104 Intrinsic::arm_mve_pred_v2i,
4105 {VectorType::get(Builder.
getInt1Ty(), 2,
false)}, VCTP);
4107 Intrinsic::arm_mve_pred_i2v,
4108 {VectorType::get(Builder.
getInt1Ty(), 4,
false)}, C1);
4109 }
else if (
Name ==
"mve.mull.int.predicated.v2i64.v4i32.v4i1" ||
4110 Name ==
"mve.vqdmull.predicated.v2i64.v4i32.v4i1" ||
4111 Name ==
"mve.vldr.gather.base.predicated.v2i64.v2i64.v4i1" ||
4112 Name ==
"mve.vldr.gather.base.wb.predicated.v2i64.v2i64.v4i1" ||
4114 "mve.vldr.gather.offset.predicated.v2i64.p0i64.v2i64.v4i1" ||
4115 Name ==
"mve.vldr.gather.offset.predicated.v2i64.p0.v2i64.v4i1" ||
4116 Name ==
"mve.vstr.scatter.base.predicated.v2i64.v2i64.v4i1" ||
4117 Name ==
"mve.vstr.scatter.base.wb.predicated.v2i64.v2i64.v4i1" ||
4119 "mve.vstr.scatter.offset.predicated.p0i64.v2i64.v2i64.v4i1" ||
4120 Name ==
"mve.vstr.scatter.offset.predicated.p0.v2i64.v2i64.v4i1" ||
4121 Name ==
"cde.vcx1q.predicated.v2i64.v4i1" ||
4122 Name ==
"cde.vcx1qa.predicated.v2i64.v4i1" ||
4123 Name ==
"cde.vcx2q.predicated.v2i64.v4i1" ||
4124 Name ==
"cde.vcx2qa.predicated.v2i64.v4i1" ||
4125 Name ==
"cde.vcx3q.predicated.v2i64.v4i1" ||
4126 Name ==
"cde.vcx3qa.predicated.v2i64.v4i1") {
4127 std::vector<Type *> Tys;
4131 case Intrinsic::arm_mve_mull_int_predicated:
4132 case Intrinsic::arm_mve_vqdmull_predicated:
4133 case Intrinsic::arm_mve_vldr_gather_base_predicated:
4136 case Intrinsic::arm_mve_vldr_gather_base_wb_predicated:
4137 case Intrinsic::arm_mve_vstr_scatter_base_predicated:
4138 case Intrinsic::arm_mve_vstr_scatter_base_wb_predicated:
4142 case Intrinsic::arm_mve_vldr_gather_offset_predicated:
4146 case Intrinsic::arm_mve_vstr_scatter_offset_predicated:
4150 case Intrinsic::arm_cde_vcx1q_predicated:
4151 case Intrinsic::arm_cde_vcx1qa_predicated:
4152 case Intrinsic::arm_cde_vcx2q_predicated:
4153 case Intrinsic::arm_cde_vcx2qa_predicated:
4154 case Intrinsic::arm_cde_vcx3q_predicated:
4155 case Intrinsic::arm_cde_vcx3qa_predicated:
4162 std::vector<Value *> Ops;
4164 Type *Ty =
Op->getType();
4167 Intrinsic::arm_mve_pred_v2i,
4168 {VectorType::get(Builder.
getInt1Ty(), 4,
false)},
Op);
4202 if (NumOperands < 3)
4215 bool IsVolatile =
false;
4219 if (NumOperands > 3)
4224 if (NumOperands > 5) {
4226 IsVolatile = !VolatileArg || !VolatileArg->
isZero();
4232 if (Order == AtomicOrdering::NotAtomic || Order == AtomicOrdering::Unordered)
4233 Order = AtomicOrdering::SequentiallyConsistent;
4240 if (VT->getElementType()->isIntegerTy(16)) {
4253 unsigned AddrSpace = PtrTy->getAddressSpace();
4256 RMW->
setMetadata(
"amdgpu.no.fine.grained.memory", EmptyMD);
4258 RMW->
setMetadata(
"amdgpu.ignore.denormal.mode", EmptyMD);
4263 MDNode *RangeNotPrivate =
4266 RMW->
setMetadata(LLVMContext::MD_noalias_addrspace, RangeNotPrivate);
4276template <
typename MDType>
4279 return dyn_cast<MDType>(MAV->getMetadata());
4288 if (
Name ==
"label") {
4290 }
else if (
Name ==
"assign") {
4292 unwrapMAVOp<Metadata>(CI, 0), unwrapMAVOp<DILocalVariable>(CI, 1),
4293 unwrapMAVOp<DIExpression>(CI, 2), unwrapMAVOp<DIAssignID>(CI, 3),
4294 unwrapMAVOp<Metadata>(CI, 4), unwrapMAVOp<DIExpression>(CI, 5),
4296 }
else if (
Name ==
"declare") {
4298 unwrapMAVOp<Metadata>(CI, 0), unwrapMAVOp<DILocalVariable>(CI, 1),
4299 unwrapMAVOp<DIExpression>(CI, 2), CI->
getDebugLoc(),
4300 DbgVariableRecord::LocationType::Declare);
4301 }
else if (
Name ==
"addr") {
4306 unwrapMAVOp<DILocalVariable>(CI, 1), Expr,
4308 }
else if (
Name ==
"value") {
4311 unsigned ExprOp = 2;
4321 unwrapMAVOp<Metadata>(CI, 0), unwrapMAVOp<DILocalVariable>(CI, VarOp),
4322 unwrapMAVOp<DIExpression>(CI, ExprOp), CI->
getDebugLoc());
4324 assert(DR &&
"Unhandled intrinsic kind in upgrade to DbgRecord");
4343 bool FallthroughToDefaultUpgrade =
false;
4347 assert(
Name.starts_with(
"llvm.") &&
"Intrinsic doesn't start with 'llvm.'");
4350 bool IsX86 =
Name.consume_front(
"x86.");
4351 bool IsNVVM =
Name.consume_front(
"nvvm.");
4352 bool IsAArch64 =
Name.consume_front(
"aarch64.");
4353 bool IsARM =
Name.consume_front(
"arm.");
4354 bool IsAMDGCN =
Name.consume_front(
"amdgcn.");
4355 bool IsDbg =
Name.consume_front(
"dbg.");
4356 Value *Rep =
nullptr;
4358 if (!IsX86 &&
Name ==
"stackprotectorcheck") {
4360 }
else if (IsNVVM) {
4364 }
else if (IsAArch64) {
4368 }
else if (IsAMDGCN) {
4380 FallthroughToDefaultUpgrade =
true;
4388 if (!FallthroughToDefaultUpgrade) {
4396 const auto &DefaultCase = [&]() ->
void {
4401 "Unknown function for CallBase upgrade and isn't just a name change");
4407 if (
auto *OldST = dyn_cast<StructType>(CI->
getType())) {
4409 "Return type must have changed");
4410 assert(OldST->getNumElements() ==
4411 cast<StructType>(NewFn->
getReturnType())->getNumElements() &&
4412 "Must have same number of elements");
4418 for (
unsigned Idx = 0;
Idx < OldST->getNumElements(); ++
Idx) {
4439 case Intrinsic::arm_neon_vst1:
4440 case Intrinsic::arm_neon_vst2:
4441 case Intrinsic::arm_neon_vst3:
4442 case Intrinsic::arm_neon_vst4:
4443 case Intrinsic::arm_neon_vst2lane:
4444 case Intrinsic::arm_neon_vst3lane:
4445 case Intrinsic::arm_neon_vst4lane: {
4450 case Intrinsic::aarch64_sve_bfmlalb_lane_v2:
4451 case Intrinsic::aarch64_sve_bfmlalt_lane_v2:
4452 case Intrinsic::aarch64_sve_bfdot_lane_v2: {
4456 cast<ConstantInt>(Args[3])->getZExtValue());
4460 case Intrinsic::aarch64_sve_ld3_sret:
4461 case Intrinsic::aarch64_sve_ld4_sret:
4462 case Intrinsic::aarch64_sve_ld2_sret: {
4470 auto *
RetTy = cast<ScalableVectorType>(
F->getReturnType());
4471 unsigned MinElts =
RetTy->getMinNumElements() /
N;
4475 for (
unsigned I = 0;
I <
N;
I++) {
4480 NewCall = dyn_cast<CallInst>(Ret);
4484 case Intrinsic::coro_end: {
4491 case Intrinsic::vector_extract: {
4494 if (!
Name.starts_with(
"aarch64.sve.tuple.get")) {
4498 auto *
RetTy = cast<ScalableVectorType>(
F->getReturnType());
4499 unsigned MinElts =
RetTy->getMinNumElements();
4500 unsigned I = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
4506 case Intrinsic::vector_insert: {
4509 if (!
Name.starts_with(
"aarch64.sve.tuple")) {
4513 if (
Name.starts_with(
"aarch64.sve.tuple.set")) {
4514 unsigned I = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
4522 if (
Name.starts_with(
"aarch64.sve.tuple.create")) {
4528 assert(
N > 1 &&
"Create is expected to be between 2-4");
4529 auto *
RetTy = cast<ScalableVectorType>(
F->getReturnType());
4531 unsigned MinElts =
RetTy->getMinNumElements() /
N;
4532 for (
unsigned I = 0;
I <
N;
I++) {
4537 NewCall = dyn_cast<CallInst>(Ret);
4542 case Intrinsic::arm_neon_bfdot:
4543 case Intrinsic::arm_neon_bfmmla:
4544 case Intrinsic::arm_neon_bfmlalb:
4545 case Intrinsic::arm_neon_bfmlalt:
4546 case Intrinsic::aarch64_neon_bfdot:
4547 case Intrinsic::aarch64_neon_bfmmla:
4548 case Intrinsic::aarch64_neon_bfmlalb:
4549 case Intrinsic::aarch64_neon_bfmlalt: {
4552 "Mismatch between function args and call args");
4553 size_t OperandWidth =
4555 assert((OperandWidth == 64 || OperandWidth == 128) &&
4556 "Unexpected operand width");
4558 auto Iter = CI->
args().begin();
4559 Args.push_back(*Iter++);
4566 case Intrinsic::bitreverse:
4570 case Intrinsic::ctlz:
4571 case Intrinsic::cttz:
4573 "Mismatch between function args and call args");
4578 case Intrinsic::objectsize: {
4579 Value *NullIsUnknownSize =
4588 case Intrinsic::ctpop:
4592 case Intrinsic::convert_from_fp16:
4596 case Intrinsic::dbg_value: {
4600 if (
Name.starts_with(
"dbg.addr")) {
4602 cast<MetadataAsValue>(CI->
getArgOperand(2))->getMetadata());
4614 if (
Offset->isZeroValue()) {
4624 case Intrinsic::ptr_annotation:
4641 case Intrinsic::var_annotation:
4657 case Intrinsic::riscv_aes32dsi:
4658 case Intrinsic::riscv_aes32dsmi:
4659 case Intrinsic::riscv_aes32esi:
4660 case Intrinsic::riscv_aes32esmi:
4661 case Intrinsic::riscv_sm4ks:
4662 case Intrinsic::riscv_sm4ed: {
4677 cast<ConstantInt>(Arg2)->getZExtValue());
4679 NewCall = Builder.
CreateCall(NewFn, {Arg0, Arg1, Arg2});
4680 Value *Res = NewCall;
4688 case Intrinsic::riscv_sha256sig0:
4689 case Intrinsic::riscv_sha256sig1:
4690 case Intrinsic::riscv_sha256sum0:
4691 case Intrinsic::riscv_sha256sum1:
4692 case Intrinsic::riscv_sm3p0:
4693 case Intrinsic::riscv_sm3p1: {
4711 case Intrinsic::x86_xop_vfrcz_ss:
4712 case Intrinsic::x86_xop_vfrcz_sd:
4716 case Intrinsic::x86_xop_vpermil2pd:
4717 case Intrinsic::x86_xop_vpermil2ps:
4718 case Intrinsic::x86_xop_vpermil2pd_256:
4719 case Intrinsic::x86_xop_vpermil2ps_256: {
4722 VectorType *IntIdxTy = VectorType::getInteger(FltIdxTy);
4728 case Intrinsic::x86_sse41_ptestc:
4729 case Intrinsic::x86_sse41_ptestz:
4730 case Intrinsic::x86_sse41_ptestnzc: {
4747 NewCall = Builder.
CreateCall(NewFn, {BC0, BC1});
4751 case Intrinsic::x86_rdtscp: {
4770 case Intrinsic::x86_sse41_insertps:
4771 case Intrinsic::x86_sse41_dppd:
4772 case Intrinsic::x86_sse41_dpps:
4773 case Intrinsic::x86_sse41_mpsadbw:
4774 case Intrinsic::x86_avx_dp_ps_256:
4775 case Intrinsic::x86_avx2_mpsadbw: {
4786 case Intrinsic::x86_avx512_mask_cmp_pd_128:
4787 case Intrinsic::x86_avx512_mask_cmp_pd_256:
4788 case Intrinsic::x86_avx512_mask_cmp_pd_512:
4789 case Intrinsic::x86_avx512_mask_cmp_ps_128:
4790 case Intrinsic::x86_avx512_mask_cmp_ps_256:
4791 case Intrinsic::x86_avx512_mask_cmp_ps_512: {
4794 cast<FixedVectorType>(Args[0]->
getType())->getNumElements();
4806 case Intrinsic::x86_avx512bf16_cvtne2ps2bf16_128:
4807 case Intrinsic::x86_avx512bf16_cvtne2ps2bf16_256:
4808 case Intrinsic::x86_avx512bf16_cvtne2ps2bf16_512:
4809 case Intrinsic::x86_avx512bf16_mask_cvtneps2bf16_128:
4810 case Intrinsic::x86_avx512bf16_cvtneps2bf16_256:
4811 case Intrinsic::x86_avx512bf16_cvtneps2bf16_512: {
4813 unsigned NumElts = cast<FixedVectorType>(CI->
getType())->getNumElements();
4815 Intrinsic::x86_avx512bf16_mask_cvtneps2bf16_128)
4828 case Intrinsic::x86_avx512bf16_dpbf16ps_128:
4829 case Intrinsic::x86_avx512bf16_dpbf16ps_256:
4830 case Intrinsic::x86_avx512bf16_dpbf16ps_512:{
4833 cast<FixedVectorType>(CI->
getType())->getNumElements() * 2;
4843 case Intrinsic::thread_pointer: {
4848 case Intrinsic::memcpy:
4849 case Intrinsic::memmove:
4850 case Intrinsic::memset: {
4870 {OldAttrs.getParamAttrs(0), OldAttrs.getParamAttrs(1),
4871 OldAttrs.getParamAttrs(2), OldAttrs.getParamAttrs(4)});
4873 auto *MemCI = cast<MemIntrinsic>(NewCall);
4876 MemCI->setDestAlignment(
Align->getMaybeAlignValue());
4878 if (
auto *MTI = dyn_cast<MemTransferInst>(MemCI))
4879 MTI->setSourceAlignment(
Align->getMaybeAlignValue());
4883 assert(NewCall &&
"Should have either set this variable or returned through "
4884 "the default case");
4891 assert(
F &&
"Illegal attempt to upgrade a non-existent intrinsic.");
4900 if (
CallBase *CB = dyn_cast<CallBase>(U))
4904 F->eraseFromParent();
4910 if (NumOperands == 0)
4914 if (isa<MDNode>(MD.
getOperand(0)) && NumOperands >= 3)
4918 if (NumOperands == 3) {
4922 Metadata *Elts2[] = {ScalarType, ScalarType,
4936 if (Opc != Instruction::BitCast)
4940 Type *SrcTy = V->getType();
4957 if (Opc != Instruction::BitCast)
4960 Type *SrcTy =
C->getType();
4985 unsigned Version = 0;
4986 if (
NamedMDNode *ModFlags = M.getModuleFlagsMetadata()) {
4987 auto OpIt =
find_if(ModFlags->operands(), [](
const MDNode *Flag) {
4988 if (Flag->getNumOperands() < 3)
4990 if (MDString *K = dyn_cast_or_null<MDString>(Flag->getOperand(1)))
4991 return K->getString() ==
"Debug Info Version";
4994 if (OpIt != ModFlags->op_end()) {
4995 const MDOperand &ValOp = (*OpIt)->getOperand(2);
4996 if (
auto *CI = mdconst::dyn_extract_or_null<ConstantInt>(ValOp))
4997 Version = CI->getZExtValue();
5002 bool BrokenDebugInfo =
false;
5005 if (!BrokenDebugInfo)
5011 M.getContext().diagnose(Diag);
5018 M.getContext().diagnose(DiagVersion);
5025 if (K ==
"kernel") {
5026 if (!mdconst::extract<ConstantInt>(V)->
isZero())
5036 mdconst::extract<ConstantInt>(V)->getZExtValue();
5037 const unsigned Idx = (AlignIdxValuePair >> 16);
5038 const Align StackAlign =
Align(AlignIdxValuePair & 0xFFFF);
5042 cast<Function>(GV)->addAttributeAtIndex(
5051 NamedMDNode *NamedMD = M.getNamedMetadata(
"nvvm.annotations");
5058 if (!SeenNodes.
insert(MD).second)
5061 auto *GV = mdconst::dyn_extract_or_null<GlobalValue>(MD->getOperand(0));
5065 assert((MD->getNumOperands() % 2) == 1 &&
"Invalid number of operands");
5072 for (
unsigned j = 1, je = MD->getNumOperands(); j < je; j += 2) {
5073 MDString *K = cast<MDString>(MD->getOperand(j));
5074 const MDOperand &V = MD->getOperand(j + 1);
5077 NewOperands.append({K, V});
5080 if (NewOperands.size() > 1)
5092 bool Changed =
false;
5093 const char *MarkerKey =
"clang.arc.retainAutoreleasedReturnValueMarker";
5094 NamedMDNode *ModRetainReleaseMarker = M.getNamedMetadata(MarkerKey);
5095 if (ModRetainReleaseMarker) {
5098 MDString *
ID = dyn_cast_or_null<MDString>(
Op->getOperand(0));
5101 ID->getString().split(ValueComp,
"#");
5102 if (ValueComp.
size() == 2) {
5103 std::string NewValue = ValueComp[0].str() +
";" + ValueComp[1].str();
5107 M.eraseNamedMetadata(ModRetainReleaseMarker);
5118 auto UpgradeToIntrinsic = [&](
const char *OldFunc,
5120 Function *Fn = M.getFunction(OldFunc);
5129 CallInst *CI = dyn_cast<CallInst>(U);
5144 bool InvalidCast =
false;
5146 for (
unsigned I = 0, E = CI->
arg_size();
I != E; ++
I) {
5151 if (I < NewFuncTy->getNumParams()) {
5161 Args.push_back(Arg);
5186 UpgradeToIntrinsic(
"clang.arc.use", llvm::Intrinsic::objc_clang_arc_use);
5194 std::pair<const char *, llvm::Intrinsic::ID> RuntimeFuncs[] = {
5195 {
"objc_autorelease", llvm::Intrinsic::objc_autorelease},
5196 {
"objc_autoreleasePoolPop", llvm::Intrinsic::objc_autoreleasePoolPop},
5197 {
"objc_autoreleasePoolPush", llvm::Intrinsic::objc_autoreleasePoolPush},
5198 {
"objc_autoreleaseReturnValue",
5199 llvm::Intrinsic::objc_autoreleaseReturnValue},
5200 {
"objc_copyWeak", llvm::Intrinsic::objc_copyWeak},
5201 {
"objc_destroyWeak", llvm::Intrinsic::objc_destroyWeak},
5202 {
"objc_initWeak", llvm::Intrinsic::objc_initWeak},
5203 {
"objc_loadWeak", llvm::Intrinsic::objc_loadWeak},
5204 {
"objc_loadWeakRetained", llvm::Intrinsic::objc_loadWeakRetained},
5205 {
"objc_moveWeak", llvm::Intrinsic::objc_moveWeak},
5206 {
"objc_release", llvm::Intrinsic::objc_release},
5207 {
"objc_retain", llvm::Intrinsic::objc_retain},
5208 {
"objc_retainAutorelease", llvm::Intrinsic::objc_retainAutorelease},
5209 {
"objc_retainAutoreleaseReturnValue",
5210 llvm::Intrinsic::objc_retainAutoreleaseReturnValue},
5211 {
"objc_retainAutoreleasedReturnValue",
5212 llvm::Intrinsic::objc_retainAutoreleasedReturnValue},
5213 {
"objc_retainBlock", llvm::Intrinsic::objc_retainBlock},
5214 {
"objc_storeStrong", llvm::Intrinsic::objc_storeStrong},
5215 {
"objc_storeWeak", llvm::Intrinsic::objc_storeWeak},
5216 {
"objc_unsafeClaimAutoreleasedReturnValue",
5217 llvm::Intrinsic::objc_unsafeClaimAutoreleasedReturnValue},
5218 {
"objc_retainedObject", llvm::Intrinsic::objc_retainedObject},
5219 {
"objc_unretainedObject", llvm::Intrinsic::objc_unretainedObject},
5220 {
"objc_unretainedPointer", llvm::Intrinsic::objc_unretainedPointer},
5221 {
"objc_retain_autorelease", llvm::Intrinsic::objc_retain_autorelease},
5222 {
"objc_sync_enter", llvm::Intrinsic::objc_sync_enter},
5223 {
"objc_sync_exit", llvm::Intrinsic::objc_sync_exit},
5224 {
"objc_arc_annotation_topdown_bbstart",
5225 llvm::Intrinsic::objc_arc_annotation_topdown_bbstart},
5226 {
"objc_arc_annotation_topdown_bbend",
5227 llvm::Intrinsic::objc_arc_annotation_topdown_bbend},
5228 {
"objc_arc_annotation_bottomup_bbstart",
5229 llvm::Intrinsic::objc_arc_annotation_bottomup_bbstart},
5230 {
"objc_arc_annotation_bottomup_bbend",
5231 llvm::Intrinsic::objc_arc_annotation_bottomup_bbend}};
5233 for (
auto &
I : RuntimeFuncs)
5234 UpgradeToIntrinsic(
I.first,
I.second);
5238 NamedMDNode *ModFlags = M.getModuleFlagsMetadata();
5242 bool HasObjCFlag =
false, HasClassProperties =
false, Changed =
false;
5243 bool HasSwiftVersionFlag =
false;
5244 uint8_t SwiftMajorVersion, SwiftMinorVersion;
5253 MDString *
ID = dyn_cast_or_null<MDString>(
Op->getOperand(1));
5265 if (
ID->getString() ==
"Objective-C Image Info Version")
5267 if (
ID->getString() ==
"Objective-C Class Properties")
5268 HasClassProperties =
true;
5270 if (
ID->getString() ==
"PIC Level") {
5271 if (
auto *Behavior =
5272 mdconst::dyn_extract_or_null<ConstantInt>(
Op->getOperand(0))) {
5273 uint64_t V = Behavior->getLimitedValue();
5279 if (
ID->getString() ==
"PIE Level")
5280 if (
auto *Behavior =
5281 mdconst::dyn_extract_or_null<ConstantInt>(
Op->getOperand(0)))
5287 if (
ID->getString() ==
"branch-target-enforcement" ||
5288 ID->getString().starts_with(
"sign-return-address")) {
5289 if (
auto *Behavior =
5290 mdconst::dyn_extract_or_null<ConstantInt>(
Op->getOperand(0))) {
5295 Op->getOperand(1),
Op->getOperand(2)};
5305 if (
ID->getString() ==
"Objective-C Image Info Section") {
5306 if (
auto *
Value = dyn_cast_or_null<MDString>(
Op->getOperand(2))) {
5308 Value->getString().split(ValueComp,
" ");
5309 if (ValueComp.
size() != 1) {
5310 std::string NewValue;
5311 for (
auto &S : ValueComp)
5312 NewValue += S.str();
5313 Metadata *Ops[3] = {
Op->getOperand(0),
Op->getOperand(1),
5323 if (
ID->getString() ==
"Objective-C Garbage Collection") {
5324 auto Md = dyn_cast<ConstantAsMetadata>(
Op->getOperand(2));
5326 assert(Md->getValue() &&
"Expected non-empty metadata");
5327 auto Type = Md->getValue()->getType();
5330 unsigned Val = Md->getValue()->getUniqueInteger().getZExtValue();
5331 if ((Val & 0xff) != Val) {
5332 HasSwiftVersionFlag =
true;
5333 SwiftABIVersion = (Val & 0xff00) >> 8;
5334 SwiftMajorVersion = (Val & 0xff000000) >> 24;
5335 SwiftMinorVersion = (Val & 0xff0000) >> 16;
5346 if (
ID->getString() ==
"amdgpu_code_object_version") {
5349 MDString::get(M.getContext(),
"amdhsa_code_object_version"),
5361 if (HasObjCFlag && !HasClassProperties) {
5367 if (HasSwiftVersionFlag) {
5371 ConstantInt::get(Int8Ty, SwiftMajorVersion));
5373 ConstantInt::get(Int8Ty, SwiftMinorVersion));
5381 auto TrimSpaces = [](
StringRef Section) -> std::string {
5383 Section.split(Components,
',');
5388 for (
auto Component : Components)
5389 OS <<
',' << Component.trim();
5391 return std::string(
OS.str().substr(1));
5394 for (
auto &GV : M.globals()) {
5395 if (!GV.hasSection())
5400 if (!Section.starts_with(
"__DATA, __objc_catlist"))
5405 GV.setSection(TrimSpaces(Section));
5421struct StrictFPUpgradeVisitor :
public InstVisitor<StrictFPUpgradeVisitor> {
5422 StrictFPUpgradeVisitor() =
default;
5425 if (!Call.isStrictFP())
5427 if (isa<ConstrainedFPIntrinsic>(&Call))
5431 Call.removeFnAttr(Attribute::StrictFP);
5432 Call.addFnAttr(Attribute::NoBuiltin);
5437struct AMDGPUUnsafeFPAtomicsUpgradeVisitor
5438 :
public InstVisitor<AMDGPUUnsafeFPAtomicsUpgradeVisitor> {
5439 AMDGPUUnsafeFPAtomicsUpgradeVisitor() =
default;
5446 RMW.
setMetadata(
"amdgpu.no.fine.grained.host.memory", Empty);
5447 RMW.
setMetadata(
"amdgpu.no.remote.memory.access", Empty);
5448 RMW.
setMetadata(
"amdgpu.ignore.denormal.mode", Empty);
5456 if (!
F.isDeclaration() && !
F.hasFnAttribute(Attribute::StrictFP)) {
5457 StrictFPUpgradeVisitor SFPV;
5463 F.getReturnType(),
F.getAttributes().getRetAttrs()));
5464 for (
auto &Arg :
F.args())
5470 if (
Attribute A =
F.getFnAttribute(
"implicit-section-name");
5471 A.isValid() &&
A.isStringAttribute()) {
5472 F.setSection(
A.getValueAsString());
5473 F.removeFnAttr(
"implicit-section-name");
5480 if (
Attribute A =
F.getFnAttribute(
"amdgpu-unsafe-fp-atomics");
5483 if (
A.getValueAsBool()) {
5484 AMDGPUUnsafeFPAtomicsUpgradeVisitor Visitor;
5490 F.removeFnAttr(
"amdgpu-unsafe-fp-atomics");
5496 auto *
T = dyn_cast_or_null<MDTuple>(MD);
5499 if (
T->getNumOperands() < 1)
5501 auto *S = dyn_cast_or_null<MDString>(
T->getOperand(0));
5504 return S->getString().starts_with(
"llvm.vectorizer.");
5508 StringRef OldPrefix =
"llvm.vectorizer.";
5511 if (OldTag ==
"llvm.vectorizer.unroll")
5520 auto *
T = dyn_cast_or_null<MDTuple>(MD);
5523 if (
T->getNumOperands() < 1)
5525 auto *OldTag = dyn_cast_or_null<MDString>(
T->getOperand(0));
5528 if (!OldTag->getString().starts_with(
"llvm.vectorizer."))
5535 for (
unsigned I = 1, E =
T->getNumOperands();
I != E; ++
I)
5542 auto *
T = dyn_cast<MDTuple>(&
N);
5561 if (((
T.isAMDGPU() && !
T.isAMDGCN()) ||
5562 (
T.isSPIR() || (
T.isSPIRV() && !
T.isSPIRVLogical()))) &&
5563 !
DL.contains(
"-G") && !
DL.starts_with(
"G")) {
5564 return DL.
empty() ? std::string(
"G1") : (
DL +
"-G1").str();
5567 if (
T.isLoongArch64() ||
T.isRISCV64()) {
5569 auto I =
DL.find(
"-n64-");
5571 return (
DL.take_front(
I) +
"-n32:64-" +
DL.drop_front(
I + 5)).str();
5575 std::string Res =
DL.str();
5579 if (!
DL.contains(
"-G") && !
DL.starts_with(
"G"))
5580 Res.append(Res.empty() ?
"G1" :
"-G1");
5585 if (!
DL.contains(
"-ni") && !
DL.starts_with(
"ni"))
5586 Res.append(
"-ni:7:8:9");
5588 if (
DL.ends_with(
"ni:7"))
5590 if (
DL.ends_with(
"ni:7:8"))
5595 if (!
DL.contains(
"-p7") && !
DL.starts_with(
"p7"))
5596 Res.append(
"-p7:160:256:256:32");
5597 if (!
DL.contains(
"-p8") && !
DL.starts_with(
"p8"))
5598 Res.append(
"-p8:128:128");
5599 if (!
DL.contains(
"-p9") && !
DL.starts_with(
"p9"))
5600 Res.append(
"-p9:192:256:256:32");
5605 auto AddPtr32Ptr64AddrSpaces = [&
DL, &Res]() {
5608 StringRef AddrSpaces{
"-p270:32:32-p271:32:32-p272:64:64"};
5609 if (!
DL.contains(AddrSpaces)) {
5611 Regex R(
"^([Ee]-m:[a-z](-p:32:32)?)(-.*)$");
5612 if (R.match(Res, &
Groups))
5618 if (
T.isAArch64()) {
5620 if (!
DL.
empty() && !
DL.contains(
"-Fn32"))
5621 Res.append(
"-Fn32");
5622 AddPtr32Ptr64AddrSpaces();
5626 if (
T.isSPARC() || (
T.isMIPS64() && !
DL.contains(
"m:m")) ||
T.isPPC64() ||
5630 std::string I64 =
"-i64:64";
5631 std::string I128 =
"-i128:128";
5633 size_t Pos = Res.find(I64);
5634 if (Pos !=
size_t(-1))
5635 Res.insert(Pos + I64.size(), I128);
5643 AddPtr32Ptr64AddrSpaces();
5651 if (!
T.isOSIAMCU()) {
5652 std::string I128 =
"-i128:128";
5655 Regex R(
"^(e(-[mpi][^-]*)*)((-[^mpi][^-]*)*)$");
5656 if (R.match(Res, &
Groups))
5664 if (
T.isWindowsMSVCEnvironment() && !
T.isArch64Bit()) {
5666 auto I =
Ref.find(
"-f80:32-");
5668 Res = (
Ref.take_front(
I) +
"-f80:128-" +
Ref.drop_front(
I + 8)).str();
5676 Attribute A =
B.getAttribute(
"no-frame-pointer-elim");
5679 FramePointer =
A.getValueAsString() ==
"true" ?
"all" :
"none";
5680 B.removeAttribute(
"no-frame-pointer-elim");
5682 if (
B.contains(
"no-frame-pointer-elim-non-leaf")) {
5684 if (FramePointer !=
"all")
5685 FramePointer =
"non-leaf";
5686 B.removeAttribute(
"no-frame-pointer-elim-non-leaf");
5688 if (!FramePointer.
empty())
5689 B.addAttribute(
"frame-pointer", FramePointer);
5691 A =
B.getAttribute(
"null-pointer-is-valid");
5694 bool NullPointerIsValid =
A.getValueAsString() ==
"true";
5695 B.removeAttribute(
"null-pointer-is-valid");
5696 if (NullPointerIsValid)
5697 B.addAttribute(Attribute::NullPointerIsValid);
5707 return OBD.
getTag() ==
"clang.arc.attachedcall" &&
AMDGPU address space definition.
AMDGPU Register Bank Select
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static Value * upgradeX86VPERMT2Intrinsics(IRBuilder<> &Builder, CallBase &CI, bool ZeroMask, bool IndexForm)
static Metadata * upgradeLoopArgument(Metadata *MD)
static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn, bool CanUpgradeDebugIntrinsicsToRecords)
static Value * upgradeX86PSLLDQIntrinsics(IRBuilder<> &Builder, Value *Op, unsigned Shift)
static bool upgradeRetainReleaseMarker(Module &M)
This checks for objc retain release marker which should be upgraded.
static Value * upgradeX86vpcom(IRBuilder<> &Builder, CallBase &CI, unsigned Imm, bool IsSigned)
static Value * upgradeMaskToInt(IRBuilder<> &Builder, CallBase &CI)
static Value * upgradeX86Rotate(IRBuilder<> &Builder, CallBase &CI, bool IsRotateRight)
static Intrinsic::ID shouldUpgradeNVPTXBF16Intrinsic(StringRef Name)
static bool upgradeSingleNVVMAnnotation(GlobalValue *GV, StringRef K, const Metadata *V)
static MDString * upgradeLoopTag(LLVMContext &C, StringRef OldTag)
static bool upgradeX86MaskedFPCompare(Function *F, Intrinsic::ID IID, Function *&NewFn)
static Value * upgradeX86ALIGNIntrinsics(IRBuilder<> &Builder, Value *Op0, Value *Op1, Value *Shift, Value *Passthru, Value *Mask, bool IsVALIGN)
static Value * upgradeAbs(IRBuilder<> &Builder, CallBase &CI)
static Value * emitX86Select(IRBuilder<> &Builder, Value *Mask, Value *Op0, Value *Op1)
static Value * upgradeAArch64IntrinsicCall(StringRef Name, CallBase *CI, Function *F, IRBuilder<> &Builder)
static Value * upgradeMaskedMove(IRBuilder<> &Builder, CallBase &CI)
static bool upgradeX86IntrinsicFunction(Function *F, StringRef Name, Function *&NewFn)
static Value * applyX86MaskOn1BitsVec(IRBuilder<> &Builder, Value *Vec, Value *Mask)
static bool shouldUpgradeX86Intrinsic(Function *F, StringRef Name)
static Value * upgradeX86PSRLDQIntrinsics(IRBuilder<> &Builder, Value *Op, unsigned Shift)
static bool isOldLoopArgument(Metadata *MD)
static Value * upgradeARMIntrinsicCall(StringRef Name, CallBase *CI, Function *F, IRBuilder<> &Builder)
static bool upgradeX86IntrinsicsWith8BitMask(Function *F, Intrinsic::ID IID, Function *&NewFn)
static Value * upgradeAMDGCNIntrinsicCall(StringRef Name, CallBase *CI, Function *F, IRBuilder<> &Builder)
static Value * upgradeMaskedLoad(IRBuilder<> &Builder, Value *Ptr, Value *Passthru, Value *Mask, bool Aligned)
static bool upgradeX86BF16Intrinsic(Function *F, Intrinsic::ID IID, Function *&NewFn)
static MDType * unwrapMAVOp(CallBase *CI, unsigned Op)
Helper to unwrap intrinsic call MetadataAsValue operands.
static bool upgradeArmOrAarch64IntrinsicFunction(bool IsArm, Function *F, StringRef Name, Function *&NewFn)
static Value * getX86MaskVec(IRBuilder<> &Builder, Value *Mask, unsigned NumElts)
static Value * emitX86ScalarSelect(IRBuilder<> &Builder, Value *Mask, Value *Op0, Value *Op1)
static Value * upgradeX86ConcatShift(IRBuilder<> &Builder, CallBase &CI, bool IsShiftRight, bool ZeroMask)
static void rename(GlobalValue *GV)
static bool upgradePTESTIntrinsic(Function *F, Intrinsic::ID IID, Function *&NewFn)
static bool upgradeX86BF16DPIntrinsic(Function *F, Intrinsic::ID IID, Function *&NewFn)
static cl::opt< bool > DisableAutoUpgradeDebugInfo("disable-auto-upgrade-debug-info", cl::desc("Disable autoupgrade of debug info"))
static Value * upgradeMaskedCompare(IRBuilder<> &Builder, CallBase &CI, unsigned CC, bool Signed)
static Value * upgradeX86BinaryIntrinsics(IRBuilder<> &Builder, CallBase &CI, Intrinsic::ID IID)
static Value * upgradeNVVMIntrinsicCall(StringRef Name, CallBase *CI, Function *F, IRBuilder<> &Builder)
static Value * upgradeX86MaskedShift(IRBuilder<> &Builder, CallBase &CI, Intrinsic::ID IID)
static bool upgradeAVX512MaskToSelect(StringRef Name, IRBuilder<> &Builder, CallBase &CI, Value *&Rep)
static void upgradeDbgIntrinsicToDbgRecord(StringRef Name, CallBase *CI)
Convert debug intrinsic calls to non-instruction debug records.
static Value * upgradePMULDQ(IRBuilder<> &Builder, CallBase &CI, bool IsSigned)
static Value * upgradeMaskedStore(IRBuilder<> &Builder, Value *Ptr, Value *Data, Value *Mask, bool Aligned)
static Value * upgradeX86IntrinsicCall(StringRef Name, CallBase *CI, Function *F, IRBuilder<> &Builder)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
This file contains constants used for implementing Dwarf debug support.
Module.h This file contains the declarations for the Module class.
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static unsigned getNumElements(Type *Ty)
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
static SymbolRef::Type getType(const Symbol *Sym)
static const X86InstrFMA3Group Groups[]
Class for arbitrary precision integers.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Class to represent array types.
Type * getElementType() const
an instruction that atomically reads a memory location, combines it with another value,...
void setVolatile(bool V)
Specify whether this is a volatile RMW or not.
BinOp
This enumeration lists the possible modifications atomicrmw can make.
@ UIncWrap
Increment one up to a maximum value.
@ FMin
*p = minnum(old, v) minnum matches the behavior of llvm.minnum.
@ FMax
*p = maxnum(old, v) maxnum matches the behavior of llvm.maxnum.
@ UDecWrap
Decrement one until a minimum value or zero.
bool isFloatingPointOperation() const
AttributeSet getFnAttrs() const
The function attributes are returned.
static AttributeList get(LLVMContext &C, ArrayRef< std::pair< unsigned, Attribute > > Attrs)
Create an AttributeList with the specified parameters in it.
AttributeSet getRetAttrs() const
The attributes for the ret value are returned.
static Attribute getWithStackAlignment(LLVMContext &Context, Align Alignment)
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
Value * getCalledOperand() const
void setAttributes(AttributeList A)
Set the attributes for this call.
Value * getArgOperand(unsigned i) const
FunctionType * getFunctionType() const
Intrinsic::ID getIntrinsicID() const
Returns the intrinsic ID of the intrinsic called or Intrinsic::not_intrinsic if the called function i...
iterator_range< User::op_iterator > args()
Iteration adapter for range-for loops.
void setCalledOperand(Value *V)
unsigned arg_size() const
AttributeList getAttributes() const
Return the attributes for this call.
void setCalledFunction(Function *Fn)
Sets the function called, including updating the function type.
This class represents a function call, abstracting a target machine's calling convention.
void setTailCallKind(TailCallKind TCK)
static CastInst * Create(Instruction::CastOps, Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Provides a way to construct any of the CastInst subclasses using an opcode instead of the subclass's ...
static bool castIsValid(Instruction::CastOps op, Type *SrcTy, Type *DstTy)
This method can be used to determine if a cast from SrcTy to DstTy using Opcode op is valid or not.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
static ConstantAggregateZero * get(Type *Ty)
static Constant * get(ArrayType *T, ArrayRef< Constant * > V)
static Constant * getIntToPtr(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static Constant * getPointerCast(Constant *C, Type *Ty)
Create a BitCast, AddrSpaceCast, or a PtrToInt cast constant expression.
static Constant * getPtrToInt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
This is the shared class of boolean and integer constants.
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
static Constant * get(StructType *T, ArrayRef< Constant * > V)
static ConstantTokenNone * get(LLVMContext &Context)
Return the ConstantTokenNone.
This is an important base class in LLVM.
static Constant * getAllOnesValue(Type *Ty)
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
static DIExpression * append(const DIExpression *Expr, ArrayRef< uint64_t > Ops)
Append the opcodes Ops to DIExpr.
This class represents an Operation in the Expression.
uint64_t getNumOperands() const
Records a position in IR for a source label (DILabel).
Base class for non-instruction debug metadata records that have positions within IR.
Record of a variable value-assignment, aka a non instruction representation of the dbg....
static FixedVectorType * get(Type *ElementType, unsigned NumElts)
Class to represent function types.
Type * getParamType(unsigned i) const
Parameter type accessors.
Type * getReturnType() const
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
Type * getReturnType() const
Returns the type of the ret val.
Argument * getArg(unsigned i) const
LinkageTypes getLinkage() const
Type * getValueType() const
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
bool hasInitializer() const
Definitions have initializers, declarations don't.
ConstantInt * getInt1(bool V)
Get a constant value representing either true or false.
Value * CreateFSub(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
Value * CreateInsertElement(Type *VecTy, Value *NewElt, Value *Idx, const Twine &Name="")
IntegerType * getInt1Ty()
Fetch the type representing a single bit.
Value * CreateInsertValue(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &Name="")
Value * CreateFDiv(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
CallInst * CreateInsertVector(Type *DstType, Value *SrcVec, Value *SubVec, Value *Idx, const Twine &Name="")
Create a call to the vector.insert intrinsic.
Value * CreateSIToFP(Value *V, Type *DestTy, const Twine &Name="")
Value * CreateExtractElement(Value *Vec, Value *Idx, const Twine &Name="")
IntegerType * getIntNTy(unsigned N)
Fetch the type representing an N-bit integer.
LoadInst * CreateAlignedLoad(Type *Ty, Value *Ptr, MaybeAlign Align, const char *Name)
Value * CreateFAdd(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
Value * CreateFPTrunc(Value *V, Type *DestTy, const Twine &Name="", MDNode *FPMathTag=nullptr)
Value * CreateVectorSplat(unsigned NumElts, Value *V, const Twine &Name="")
Return a vector value that contains.
Value * CreateExtractValue(Value *Agg, ArrayRef< unsigned > Idxs, const Twine &Name="")
CallInst * CreateMaskedLoad(Type *Ty, Value *Ptr, Align Alignment, Value *Mask, Value *PassThru=nullptr, const Twine &Name="")
Create a call to Masked Load intrinsic.
Value * CreateICmpSGE(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateSelect(Value *C, Value *True, Value *False, const Twine &Name="", Instruction *MDFrom=nullptr)
Value * CreateSExt(Value *V, Type *DestTy, const Twine &Name="")
IntegerType * getInt32Ty()
Fetch the type representing a 32-bit integer.
ConstantInt * getInt8(uint8_t C)
Get a constant 8-bit value.
Value * CreateUIToFP(Value *V, Type *DestTy, const Twine &Name="", bool IsNonNeg=false)
IntegerType * getInt64Ty()
Fetch the type representing a 64-bit integer.
IntegerType * getInt16Ty()
Fetch the type representing a 16-bit integer.
Value * CreateNeg(Value *V, const Twine &Name="", bool HasNSW=false)
CallInst * CreateIntrinsic(Intrinsic::ID ID, ArrayRef< Type * > Types, ArrayRef< Value * > Args, FMFSource FMFSource={}, const Twine &Name="")
Create a call to intrinsic ID with Args, mangled using Types.
Value * CreateICmpSLE(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateNot(Value *V, const Twine &Name="")
Value * CreateICmpEQ(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateSub(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Value * CreateBitCast(Value *V, Type *DestTy, const Twine &Name="")
LoadInst * CreateLoad(Type *Ty, Value *Ptr, const char *Name)
Provided to resolve 'CreateLoad(Ty, Ptr, "...")' correctly, instead of converting the string to 'bool...
Value * CreateShl(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Value * CreateZExt(Value *V, Type *DestTy, const Twine &Name="", bool IsNonNeg=false)
Value * CreateShuffleVector(Value *V1, Value *V2, Value *Mask, const Twine &Name="")
LLVMContext & getContext() const
Value * CreateAnd(Value *LHS, Value *RHS, const Twine &Name="")
CallInst * CreateMaskedStore(Value *Val, Value *Ptr, Align Alignment, Value *Mask)
Create a call to Masked Store intrinsic.
Value * CreateAdd(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
ConstantInt * getFalse()
Get the constant value for i1 false.
Type * getFloatTy()
Fetch the type representing a 32-bit floating point value.
Value * CreateIsNotNull(Value *Arg, const Twine &Name="")
Return a boolean value testing if Arg != 0.
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args={}, const Twine &Name="", MDNode *FPMathTag=nullptr)
AtomicRMWInst * CreateAtomicRMW(AtomicRMWInst::BinOp Op, Value *Ptr, Value *Val, MaybeAlign Align, AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System)
Value * CreateTrunc(Value *V, Type *DestTy, const Twine &Name="", bool IsNUW=false, bool IsNSW=false)
Value * CreateOr(Value *LHS, Value *RHS, const Twine &Name="")
PointerType * getPtrTy(unsigned AddrSpace=0)
Fetch the type representing a pointer.
Value * CreateICmpUGE(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateIntCast(Value *V, Type *DestTy, bool isSigned, const Twine &Name="")
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block.
StoreInst * CreateAlignedStore(Value *Val, Value *Ptr, MaybeAlign Align, bool isVolatile=false)
Value * CreateFPExt(Value *V, Type *DestTy, const Twine &Name="", MDNode *FPMathTag=nullptr)
Value * CreateAShr(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
Value * CreateXor(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateICmpULE(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateICmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateFMul(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
Value * CreateFNeg(Value *V, const Twine &Name="", MDNode *FPMathTag=nullptr)
IntegerType * getInt8Ty()
Fetch the type representing an 8-bit integer.
Value * CreateAddrSpaceCast(Value *V, Type *DestTy, const Twine &Name="")
Type * getBFloatTy()
Fetch the type representing a 16-bit brain floating point value.
Value * CreateMul(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Base class for instruction visitors.
RetTy visitCallBase(CallBase &I)
RetTy visitAtomicRMWInst(AtomicRMWInst &I)
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
This is an important class for using LLVM in a threaded context.
SyncScope::ID getOrInsertSyncScopeID(StringRef SSN)
getOrInsertSyncScopeID - Maps synchronization scope name to synchronization scope ID.
An instruction for reading from memory.
MDNode * createRange(const APInt &Lo, const APInt &Hi)
Return metadata describing the range [Lo, Hi).
const MDOperand & getOperand(unsigned I) const
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
unsigned getNumOperands() const
Return number of MDNode operands.
LLVMContext & getContext() const
Tracking metadata reference owned by Metadata.
static MDString * get(LLVMContext &Context, StringRef Str)
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
A Module instance is used to store all the information related to an LLVM module.
ModFlagBehavior
This enumeration defines the supported behaviors of module flags.
@ Override
Uses the specified value, regardless of the behavior or value of the other module.
@ Error
Emits an error if two values disagree, otherwise the resulting value is that of the operands.
@ Min
Takes the min of the two values, which are required to be integers.
@ Max
Takes the max of the two values, which are required to be integers.
bool IsNewDbgInfoFormat
Is this Module using intrinsics to record the position of debugging information, or non-intrinsic rec...
void setOperand(unsigned I, MDNode *New)
MDNode * getOperand(unsigned i) const
unsigned getNumOperands() const
void clearOperands()
Drop all references to this node's operands.
iterator_range< op_iterator > operands()
void addOperand(MDNode *M)
A container for an operand bundle being viewed as a set of values rather than a set of uses.
ArrayRef< InputTy > inputs() const
static PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
bool match(StringRef String, SmallVectorImpl< StringRef > *Matches=nullptr, std::string *Error=nullptr) const
matches - Match the regex against a given String.
static ScalableVectorType * get(Type *ElementType, unsigned MinNumElts)
ArrayRef< int > getShuffleMask() const
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
void reserve(size_type N)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
StringRef - Represent a constant reference to a string, i.e.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr bool empty() const
empty - Check if the string is empty.
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
constexpr size_t size() const
size - Get the string size.
static constexpr size_t npos
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
StringSwitch & StartsWith(StringLiteral S, T Value)
StringSwitch & Cases(StringLiteral S0, StringLiteral S1, T Value)
Class to represent struct types.
static StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
unsigned getNumElements() const
Random access to the elements.
Type * getElementType(unsigned N) const
Triple - Helper class for working with autoconf configuration names.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
static Type * getHalfTy(LLVMContext &C)
static Type * getBFloatTy(LLVMContext &C)
bool isBFloatTy() const
Return true if this is 'bfloat', a 16-bit bfloat type.
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
static IntegerType * getInt8Ty(LLVMContext &C)
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
static IntegerType * getInt32Ty(LLVMContext &C)
static IntegerType * getInt64Ty(LLVMContext &C)
static Type * getFloatTy(LLVMContext &C)
bool isIntegerTy() const
True if this is an instance of IntegerType.
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
Value * getOperand(unsigned i) const
unsigned getNumOperands() const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
void setName(const Twine &Name)
Change the name of the value.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
iterator_range< user_iterator > users()
LLVMContext & getContext() const
All values hold a context through their type.
StringRef getName() const
Return a constant reference to the value's name.
void takeName(Value *V)
Transfer the name from V to this value.
Base class of all SIMD vector types.
constexpr ScalarTy getFixedValue() const
const ParentTy * getParent() const
self_iterator getIterator()
A raw_ostream that writes to an SmallVector or SmallString.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ LOCAL_ADDRESS
Address space for local memory.
@ FLAT_ADDRESS
Address space for flat memory.
@ PRIVATE_ADDRESS
Address space for private memory.
AttributeMask typeIncompatible(Type *Ty, AttributeSet AS, AttributeSafetyKind ASK=ASK_ALL)
Which attributes cannot be applied to a type.
@ PTX_Kernel
Call to a PTX kernel. Passes all arguments in parameter space.
@ C
The default llvm calling convention, compatible with C.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Function * getOrInsertDeclaration(Module *M, ID id, ArrayRef< Type * > Tys={})
Look up the Function declaration of the intrinsic id in the Module M.
void getIntrinsicInfoTableEntries(ID id, SmallVectorImpl< IITDescriptor > &T)
Return the IIT table descriptor for the specified intrinsic into an array of IITDescriptors.
std::optional< Function * > remangleIntrinsicFunction(Function *F)
StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
AttributeList getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
This is an optimization pass for GlobalISel generic memory operations.
void UpgradeIntrinsicCall(CallBase *CB, Function *NewFn)
This is the complement to the above, replacing a specific call to an intrinsic function with a call t...
void UpgradeSectionAttributes(Module &M)
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
void UpgradeInlineAsmString(std::string *AsmStr)
Upgrade comment in call to inline asm that represents an objc retain release marker.
bool isValidAtomicOrdering(Int I)
bool UpgradeIntrinsicFunction(Function *F, Function *&NewFn, bool CanUpgradeDebugIntrinsicsToRecords=true)
This is a more granular function that simply checks an intrinsic function for upgrading,...
MDNode * upgradeInstructionLoopAttachment(MDNode &N)
Upgrade the loop attachment metadata node.
void UpgradeAttributes(AttrBuilder &B)
Upgrade attributes that changed format or kind.
void UpgradeCallsToIntrinsic(Function *F)
This is an auto-upgrade hook for any old intrinsic function syntaxes which need to have both the func...
void UpgradeNVVMAnnotations(Module &M)
Convert legacy nvvm.annotations metadata to appropriate function attributes.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
bool UpgradeModuleFlags(Module &M)
This checks for module flags which should be upgraded.
void UpgradeOperandBundles(std::vector< OperandBundleDef > &OperandBundles)
Upgrade operand bundles (without knowing about their user instruction).
Constant * UpgradeBitCastExpr(unsigned Opc, Constant *C, Type *DestTy)
This is an auto-upgrade for bitcast constant expression between pointers with different address space...
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
std::string UpgradeDataLayoutString(StringRef DL, StringRef Triple)
Upgrade the datalayout string by adding a section for address space pointers.
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
GlobalVariable * UpgradeGlobalVariable(GlobalVariable *GV)
This checks for global variables which should be upgraded.
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
bool StripDebugInfo(Module &M)
Strip debug info in the module if it exists.
AtomicOrdering
Atomic ordering for LLVM's memory model.
@ Ref
The access may reference the value stored in memory.
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...
DWARFExpression::Operation Op
@ Dynamic
Denotes mode unknown at compile time.
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
void erase_if(Container &C, UnaryPredicate P)
Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...
bool UpgradeDebugInfo(Module &M)
Check the debug info version number, if it is out-dated, drop the debug info.
void UpgradeFunctionAttributes(Function &F)
Correct any IR that is relying on old function attribute behavior.
MDNode * UpgradeTBAANode(MDNode &TBAANode)
If the given TBAA tag uses the scalar TBAA format, create a new node corresponding to the upgrade to ...
void UpgradeARCRuntime(Module &M)
Convert calls to ARC runtime functions to intrinsic calls and upgrade the old retain release marker t...
bool verifyModule(const Module &M, raw_ostream *OS=nullptr, bool *BrokenDebugInfo=nullptr)
Check a module for errors.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Description of the encoding of one expression Op.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.