434 case NVPTX::BI__nvvm_atom_add_gen_i:
435 case NVPTX::BI__nvvm_atom_add_gen_l:
436 case NVPTX::BI__nvvm_atom_add_gen_ll:
438 AtomicOrdering::Monotonic);
440 case NVPTX::BI__nvvm_atom_sub_gen_i:
441 case NVPTX::BI__nvvm_atom_sub_gen_l:
442 case NVPTX::BI__nvvm_atom_sub_gen_ll:
444 AtomicOrdering::Monotonic);
446 case NVPTX::BI__nvvm_atom_and_gen_i:
447 case NVPTX::BI__nvvm_atom_and_gen_l:
448 case NVPTX::BI__nvvm_atom_and_gen_ll:
450 AtomicOrdering::Monotonic);
452 case NVPTX::BI__nvvm_atom_or_gen_i:
453 case NVPTX::BI__nvvm_atom_or_gen_l:
454 case NVPTX::BI__nvvm_atom_or_gen_ll:
456 AtomicOrdering::Monotonic);
458 case NVPTX::BI__nvvm_atom_xor_gen_i:
459 case NVPTX::BI__nvvm_atom_xor_gen_l:
460 case NVPTX::BI__nvvm_atom_xor_gen_ll:
462 AtomicOrdering::Monotonic);
464 case NVPTX::BI__nvvm_atom_xchg_gen_i:
465 case NVPTX::BI__nvvm_atom_xchg_gen_l:
466 case NVPTX::BI__nvvm_atom_xchg_gen_ll:
468 AtomicOrdering::Monotonic);
470 case NVPTX::BI__nvvm_atom_max_gen_i:
471 case NVPTX::BI__nvvm_atom_max_gen_l:
472 case NVPTX::BI__nvvm_atom_max_gen_ll:
474 AtomicOrdering::Monotonic);
476 case NVPTX::BI__nvvm_atom_max_gen_ui:
477 case NVPTX::BI__nvvm_atom_max_gen_ul:
478 case NVPTX::BI__nvvm_atom_max_gen_ull:
480 AtomicOrdering::Monotonic);
482 case NVPTX::BI__nvvm_atom_min_gen_i:
483 case NVPTX::BI__nvvm_atom_min_gen_l:
484 case NVPTX::BI__nvvm_atom_min_gen_ll:
486 AtomicOrdering::Monotonic);
488 case NVPTX::BI__nvvm_atom_min_gen_ui:
489 case NVPTX::BI__nvvm_atom_min_gen_ul:
490 case NVPTX::BI__nvvm_atom_min_gen_ull:
492 AtomicOrdering::Monotonic);
494 case NVPTX::BI__nvvm_atom_cas_gen_us:
495 case NVPTX::BI__nvvm_atom_cas_gen_i:
496 case NVPTX::BI__nvvm_atom_cas_gen_l:
497 case NVPTX::BI__nvvm_atom_cas_gen_ll:
501 AtomicOrdering::Monotonic,
502 AtomicOrdering::Monotonic);
504 case NVPTX::BI__nvvm_atom_add_gen_f:
505 case NVPTX::BI__nvvm_atom_add_gen_d: {
509 return Builder.CreateAtomicRMW(llvm::AtomicRMWInst::FAdd, DestAddr, Val,
510 AtomicOrdering::Monotonic);
513 case NVPTX::BI__nvvm_atom_inc_gen_ui:
515 AtomicOrdering::Monotonic);
517 case NVPTX::BI__nvvm_atom_dec_gen_ui:
519 AtomicOrdering::Monotonic);
521 case NVPTX::BI__nvvm_ldg_c:
522 case NVPTX::BI__nvvm_ldg_sc:
523 case NVPTX::BI__nvvm_ldg_c2:
524 case NVPTX::BI__nvvm_ldg_sc2:
525 case NVPTX::BI__nvvm_ldg_c4:
526 case NVPTX::BI__nvvm_ldg_sc4:
527 case NVPTX::BI__nvvm_ldg_s:
528 case NVPTX::BI__nvvm_ldg_s2:
529 case NVPTX::BI__nvvm_ldg_s4:
530 case NVPTX::BI__nvvm_ldg_i:
531 case NVPTX::BI__nvvm_ldg_i2:
532 case NVPTX::BI__nvvm_ldg_i4:
533 case NVPTX::BI__nvvm_ldg_l:
534 case NVPTX::BI__nvvm_ldg_l2:
535 case NVPTX::BI__nvvm_ldg_ll:
536 case NVPTX::BI__nvvm_ldg_ll2:
537 case NVPTX::BI__nvvm_ldg_uc:
538 case NVPTX::BI__nvvm_ldg_uc2:
539 case NVPTX::BI__nvvm_ldg_uc4:
540 case NVPTX::BI__nvvm_ldg_us:
541 case NVPTX::BI__nvvm_ldg_us2:
542 case NVPTX::BI__nvvm_ldg_us4:
543 case NVPTX::BI__nvvm_ldg_ui:
544 case NVPTX::BI__nvvm_ldg_ui2:
545 case NVPTX::BI__nvvm_ldg_ui4:
546 case NVPTX::BI__nvvm_ldg_ul:
547 case NVPTX::BI__nvvm_ldg_ul2:
548 case NVPTX::BI__nvvm_ldg_ull:
549 case NVPTX::BI__nvvm_ldg_ull2:
550 case NVPTX::BI__nvvm_ldg_f:
551 case NVPTX::BI__nvvm_ldg_f2:
552 case NVPTX::BI__nvvm_ldg_f4:
553 case NVPTX::BI__nvvm_ldg_d:
554 case NVPTX::BI__nvvm_ldg_d2:
558 return MakeLdg(*
this, E);
560 case NVPTX::BI__nvvm_ldu_c:
561 case NVPTX::BI__nvvm_ldu_sc:
562 case NVPTX::BI__nvvm_ldu_c2:
563 case NVPTX::BI__nvvm_ldu_sc2:
564 case NVPTX::BI__nvvm_ldu_c4:
565 case NVPTX::BI__nvvm_ldu_sc4:
566 case NVPTX::BI__nvvm_ldu_s:
567 case NVPTX::BI__nvvm_ldu_s2:
568 case NVPTX::BI__nvvm_ldu_s4:
569 case NVPTX::BI__nvvm_ldu_i:
570 case NVPTX::BI__nvvm_ldu_i2:
571 case NVPTX::BI__nvvm_ldu_i4:
572 case NVPTX::BI__nvvm_ldu_l:
573 case NVPTX::BI__nvvm_ldu_l2:
574 case NVPTX::BI__nvvm_ldu_ll:
575 case NVPTX::BI__nvvm_ldu_ll2:
576 case NVPTX::BI__nvvm_ldu_uc:
577 case NVPTX::BI__nvvm_ldu_uc2:
578 case NVPTX::BI__nvvm_ldu_uc4:
579 case NVPTX::BI__nvvm_ldu_us:
580 case NVPTX::BI__nvvm_ldu_us2:
581 case NVPTX::BI__nvvm_ldu_us4:
582 case NVPTX::BI__nvvm_ldu_ui:
583 case NVPTX::BI__nvvm_ldu_ui2:
584 case NVPTX::BI__nvvm_ldu_ui4:
585 case NVPTX::BI__nvvm_ldu_ul:
586 case NVPTX::BI__nvvm_ldu_ul2:
587 case NVPTX::BI__nvvm_ldu_ull:
588 case NVPTX::BI__nvvm_ldu_ull2:
589 return MakeLdu(Intrinsic::nvvm_ldu_global_i, *
this, E);
590 case NVPTX::BI__nvvm_ldu_f:
591 case NVPTX::BI__nvvm_ldu_f2:
592 case NVPTX::BI__nvvm_ldu_f4:
593 case NVPTX::BI__nvvm_ldu_d:
594 case NVPTX::BI__nvvm_ldu_d2:
595 return MakeLdu(Intrinsic::nvvm_ldu_global_f, *
this, E);
597 case NVPTX::BI__nvvm_atom_cta_add_gen_i:
598 case NVPTX::BI__nvvm_atom_cta_add_gen_l:
599 case NVPTX::BI__nvvm_atom_cta_add_gen_ll:
600 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Add,
"block");
601 case NVPTX::BI__nvvm_atom_sys_add_gen_i:
602 case NVPTX::BI__nvvm_atom_sys_add_gen_l:
603 case NVPTX::BI__nvvm_atom_sys_add_gen_ll:
604 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Add,
"");
605 case NVPTX::BI__nvvm_atom_cta_add_gen_f:
606 case NVPTX::BI__nvvm_atom_cta_add_gen_d:
607 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::FAdd,
"block");
608 case NVPTX::BI__nvvm_atom_sys_add_gen_f:
609 case NVPTX::BI__nvvm_atom_sys_add_gen_d:
610 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::FAdd,
"");
611 case NVPTX::BI__nvvm_atom_cta_xchg_gen_i:
612 case NVPTX::BI__nvvm_atom_cta_xchg_gen_l:
613 case NVPTX::BI__nvvm_atom_cta_xchg_gen_ll:
614 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Xchg,
"block");
615 case NVPTX::BI__nvvm_atom_sys_xchg_gen_i:
616 case NVPTX::BI__nvvm_atom_sys_xchg_gen_l:
617 case NVPTX::BI__nvvm_atom_sys_xchg_gen_ll:
618 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Xchg,
"");
619 case NVPTX::BI__nvvm_atom_cta_max_gen_i:
620 case NVPTX::BI__nvvm_atom_cta_max_gen_l:
621 case NVPTX::BI__nvvm_atom_cta_max_gen_ll:
622 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Max,
"block");
623 case NVPTX::BI__nvvm_atom_cta_max_gen_ui:
624 case NVPTX::BI__nvvm_atom_cta_max_gen_ul:
625 case NVPTX::BI__nvvm_atom_cta_max_gen_ull:
626 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UMax,
"block");
627 case NVPTX::BI__nvvm_atom_sys_max_gen_i:
628 case NVPTX::BI__nvvm_atom_sys_max_gen_l:
629 case NVPTX::BI__nvvm_atom_sys_max_gen_ll:
630 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Max,
"");
631 case NVPTX::BI__nvvm_atom_sys_max_gen_ui:
632 case NVPTX::BI__nvvm_atom_sys_max_gen_ul:
633 case NVPTX::BI__nvvm_atom_sys_max_gen_ull:
634 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UMax,
"");
635 case NVPTX::BI__nvvm_atom_cta_min_gen_i:
636 case NVPTX::BI__nvvm_atom_cta_min_gen_l:
637 case NVPTX::BI__nvvm_atom_cta_min_gen_ll:
638 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Min,
"block");
639 case NVPTX::BI__nvvm_atom_cta_min_gen_ui:
640 case NVPTX::BI__nvvm_atom_cta_min_gen_ul:
641 case NVPTX::BI__nvvm_atom_cta_min_gen_ull:
642 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UMin,
"block");
643 case NVPTX::BI__nvvm_atom_sys_min_gen_i:
644 case NVPTX::BI__nvvm_atom_sys_min_gen_l:
645 case NVPTX::BI__nvvm_atom_sys_min_gen_ll:
646 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Min,
"");
647 case NVPTX::BI__nvvm_atom_sys_min_gen_ui:
648 case NVPTX::BI__nvvm_atom_sys_min_gen_ul:
649 case NVPTX::BI__nvvm_atom_sys_min_gen_ull:
650 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UMin,
"");
651 case NVPTX::BI__nvvm_atom_cta_inc_gen_ui:
652 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UIncWrap,
654 case NVPTX::BI__nvvm_atom_cta_dec_gen_ui:
655 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UDecWrap,
657 case NVPTX::BI__nvvm_atom_sys_inc_gen_ui:
658 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UIncWrap,
"");
659 case NVPTX::BI__nvvm_atom_sys_dec_gen_ui:
660 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UDecWrap,
"");
661 case NVPTX::BI__nvvm_atom_cta_and_gen_i:
662 case NVPTX::BI__nvvm_atom_cta_and_gen_l:
663 case NVPTX::BI__nvvm_atom_cta_and_gen_ll:
664 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::And,
"block");
665 case NVPTX::BI__nvvm_atom_sys_and_gen_i:
666 case NVPTX::BI__nvvm_atom_sys_and_gen_l:
667 case NVPTX::BI__nvvm_atom_sys_and_gen_ll:
668 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::And,
"");
669 case NVPTX::BI__nvvm_atom_cta_or_gen_i:
670 case NVPTX::BI__nvvm_atom_cta_or_gen_l:
671 case NVPTX::BI__nvvm_atom_cta_or_gen_ll:
672 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Or,
"block");
673 case NVPTX::BI__nvvm_atom_sys_or_gen_i:
674 case NVPTX::BI__nvvm_atom_sys_or_gen_l:
675 case NVPTX::BI__nvvm_atom_sys_or_gen_ll:
676 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Or,
"");
677 case NVPTX::BI__nvvm_atom_cta_xor_gen_i:
678 case NVPTX::BI__nvvm_atom_cta_xor_gen_l:
679 case NVPTX::BI__nvvm_atom_cta_xor_gen_ll:
680 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Xor,
"block");
681 case NVPTX::BI__nvvm_atom_sys_xor_gen_i:
682 case NVPTX::BI__nvvm_atom_sys_xor_gen_l:
683 case NVPTX::BI__nvvm_atom_sys_xor_gen_ll:
684 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Xor,
"");
685 case NVPTX::BI__nvvm_atom_cta_cas_gen_us:
686 case NVPTX::BI__nvvm_atom_cta_cas_gen_i:
687 case NVPTX::BI__nvvm_atom_cta_cas_gen_l:
688 case NVPTX::BI__nvvm_atom_cta_cas_gen_ll:
689 return MakeScopedAtomicCAS(*
this, E,
"block");
690 case NVPTX::BI__nvvm_atom_sys_cas_gen_us:
691 case NVPTX::BI__nvvm_atom_sys_cas_gen_i:
692 case NVPTX::BI__nvvm_atom_sys_cas_gen_l:
693 case NVPTX::BI__nvvm_atom_sys_cas_gen_ll:
694 return MakeScopedAtomicCAS(*
this, E,
"");
695 case NVPTX::BI__nvvm_match_all_sync_i32p:
696 case NVPTX::BI__nvvm_match_all_sync_i64p: {
701 CGM.getIntrinsic(BuiltinID == NVPTX::BI__nvvm_match_all_sync_i32p
702 ? Intrinsic::nvvm_match_all_sync_i32p
703 : Intrinsic::nvvm_match_all_sync_i64p),
707 Builder.CreateStore(Pred, PredOutPtr);
708 return Builder.CreateExtractValue(ResultPair, 0);
712 case NVPTX::BI__hmma_m16n16k16_ld_a:
713 case NVPTX::BI__hmma_m16n16k16_ld_b:
714 case NVPTX::BI__hmma_m16n16k16_ld_c_f16:
715 case NVPTX::BI__hmma_m16n16k16_ld_c_f32:
716 case NVPTX::BI__hmma_m32n8k16_ld_a:
717 case NVPTX::BI__hmma_m32n8k16_ld_b:
718 case NVPTX::BI__hmma_m32n8k16_ld_c_f16:
719 case NVPTX::BI__hmma_m32n8k16_ld_c_f32:
720 case NVPTX::BI__hmma_m8n32k16_ld_a:
721 case NVPTX::BI__hmma_m8n32k16_ld_b:
722 case NVPTX::BI__hmma_m8n32k16_ld_c_f16:
723 case NVPTX::BI__hmma_m8n32k16_ld_c_f32:
725 case NVPTX::BI__imma_m16n16k16_ld_a_s8:
726 case NVPTX::BI__imma_m16n16k16_ld_a_u8:
727 case NVPTX::BI__imma_m16n16k16_ld_b_s8:
728 case NVPTX::BI__imma_m16n16k16_ld_b_u8:
729 case NVPTX::BI__imma_m16n16k16_ld_c:
730 case NVPTX::BI__imma_m32n8k16_ld_a_s8:
731 case NVPTX::BI__imma_m32n8k16_ld_a_u8:
732 case NVPTX::BI__imma_m32n8k16_ld_b_s8:
733 case NVPTX::BI__imma_m32n8k16_ld_b_u8:
734 case NVPTX::BI__imma_m32n8k16_ld_c:
735 case NVPTX::BI__imma_m8n32k16_ld_a_s8:
736 case NVPTX::BI__imma_m8n32k16_ld_a_u8:
737 case NVPTX::BI__imma_m8n32k16_ld_b_s8:
738 case NVPTX::BI__imma_m8n32k16_ld_b_u8:
739 case NVPTX::BI__imma_m8n32k16_ld_c:
741 case NVPTX::BI__imma_m8n8k32_ld_a_s4:
742 case NVPTX::BI__imma_m8n8k32_ld_a_u4:
743 case NVPTX::BI__imma_m8n8k32_ld_b_s4:
744 case NVPTX::BI__imma_m8n8k32_ld_b_u4:
745 case NVPTX::BI__imma_m8n8k32_ld_c:
746 case NVPTX::BI__bmma_m8n8k128_ld_a_b1:
747 case NVPTX::BI__bmma_m8n8k128_ld_b_b1:
748 case NVPTX::BI__bmma_m8n8k128_ld_c:
750 case NVPTX::BI__dmma_m8n8k4_ld_a:
751 case NVPTX::BI__dmma_m8n8k4_ld_b:
752 case NVPTX::BI__dmma_m8n8k4_ld_c:
754 case NVPTX::BI__mma_bf16_m16n16k16_ld_a:
755 case NVPTX::BI__mma_bf16_m16n16k16_ld_b:
756 case NVPTX::BI__mma_bf16_m8n32k16_ld_a:
757 case NVPTX::BI__mma_bf16_m8n32k16_ld_b:
758 case NVPTX::BI__mma_bf16_m32n8k16_ld_a:
759 case NVPTX::BI__mma_bf16_m32n8k16_ld_b:
760 case NVPTX::BI__mma_tf32_m16n16k8_ld_a:
761 case NVPTX::BI__mma_tf32_m16n16k8_ld_b:
762 case NVPTX::BI__mma_tf32_m16n16k8_ld_c: {
766 std::optional<llvm::APSInt> isColMajorArg =
770 bool isColMajor = isColMajorArg->getSExtValue();
771 NVPTXMmaLdstInfo II = getNVPTXMmaLdstInfo(BuiltinID);
772 unsigned IID = isColMajor ? II.IID_col : II.IID_row;
780 assert(II.NumResults);
781 if (II.NumResults == 1) {
785 for (
unsigned i = 0; i < II.NumResults; ++i) {
790 llvm::ConstantInt::get(
IntTy, i)),
797 case NVPTX::BI__hmma_m16n16k16_st_c_f16:
798 case NVPTX::BI__hmma_m16n16k16_st_c_f32:
799 case NVPTX::BI__hmma_m32n8k16_st_c_f16:
800 case NVPTX::BI__hmma_m32n8k16_st_c_f32:
801 case NVPTX::BI__hmma_m8n32k16_st_c_f16:
802 case NVPTX::BI__hmma_m8n32k16_st_c_f32:
803 case NVPTX::BI__imma_m16n16k16_st_c_i32:
804 case NVPTX::BI__imma_m32n8k16_st_c_i32:
805 case NVPTX::BI__imma_m8n32k16_st_c_i32:
806 case NVPTX::BI__imma_m8n8k32_st_c_i32:
807 case NVPTX::BI__bmma_m8n8k128_st_c_i32:
808 case NVPTX::BI__dmma_m8n8k4_st_c_f64:
809 case NVPTX::BI__mma_m16n16k8_st_c_f32: {
813 std::optional<llvm::APSInt> isColMajorArg =
817 bool isColMajor = isColMajorArg->getSExtValue();
818 NVPTXMmaLdstInfo II = getNVPTXMmaLdstInfo(BuiltinID);
819 unsigned IID = isColMajor ? II.IID_col : II.IID_row;
824 llvm::Type *ParamType = Intrinsic->getFunctionType()->getParamType(1);
826 for (
unsigned i = 0; i < II.NumResults; ++i) {
830 llvm::ConstantInt::get(
IntTy, i)),
832 Values.push_back(
Builder.CreateBitCast(
V, ParamType));
834 Values.push_back(Ldm);
841 case NVPTX::BI__hmma_m16n16k16_mma_f16f16:
842 case NVPTX::BI__hmma_m16n16k16_mma_f32f16:
843 case NVPTX::BI__hmma_m16n16k16_mma_f32f32:
844 case NVPTX::BI__hmma_m16n16k16_mma_f16f32:
845 case NVPTX::BI__hmma_m32n8k16_mma_f16f16:
846 case NVPTX::BI__hmma_m32n8k16_mma_f32f16:
847 case NVPTX::BI__hmma_m32n8k16_mma_f32f32:
848 case NVPTX::BI__hmma_m32n8k16_mma_f16f32:
849 case NVPTX::BI__hmma_m8n32k16_mma_f16f16:
850 case NVPTX::BI__hmma_m8n32k16_mma_f32f16:
851 case NVPTX::BI__hmma_m8n32k16_mma_f32f32:
852 case NVPTX::BI__hmma_m8n32k16_mma_f16f32:
853 case NVPTX::BI__imma_m16n16k16_mma_s8:
854 case NVPTX::BI__imma_m16n16k16_mma_u8:
855 case NVPTX::BI__imma_m32n8k16_mma_s8:
856 case NVPTX::BI__imma_m32n8k16_mma_u8:
857 case NVPTX::BI__imma_m8n32k16_mma_s8:
858 case NVPTX::BI__imma_m8n32k16_mma_u8:
859 case NVPTX::BI__imma_m8n8k32_mma_s4:
860 case NVPTX::BI__imma_m8n8k32_mma_u4:
861 case NVPTX::BI__bmma_m8n8k128_mma_xor_popc_b1:
862 case NVPTX::BI__bmma_m8n8k128_mma_and_popc_b1:
863 case NVPTX::BI__dmma_m8n8k4_mma_f64:
864 case NVPTX::BI__mma_bf16_m16n16k16_mma_f32:
865 case NVPTX::BI__mma_bf16_m8n32k16_mma_f32:
866 case NVPTX::BI__mma_bf16_m32n8k16_mma_f32:
867 case NVPTX::BI__mma_tf32_m16n16k8_mma_f32: {
872 std::optional<llvm::APSInt> LayoutArg =
876 int Layout = LayoutArg->getSExtValue();
877 if (Layout < 0 || Layout > 3)
879 llvm::APSInt SatfArg;
880 if (BuiltinID == NVPTX::BI__bmma_m8n8k128_mma_xor_popc_b1 ||
881 BuiltinID == NVPTX::BI__bmma_m8n8k128_mma_and_popc_b1)
883 else if (std::optional<llvm::APSInt> OptSatfArg =
885 SatfArg = *OptSatfArg;
888 bool Satf = SatfArg.getSExtValue();
889 NVPTXMmaInfo MI = getNVPTXMmaInfo(BuiltinID);
890 unsigned IID = MI.getMMAIntrinsic(Layout, Satf);
896 llvm::Type *AType = Intrinsic->getFunctionType()->getParamType(0);
898 for (
unsigned i = 0; i < MI.NumEltsA; ++i) {
902 llvm::ConstantInt::get(
IntTy, i)),
904 Values.push_back(
Builder.CreateBitCast(
V, AType));
907 llvm::Type *BType = Intrinsic->getFunctionType()->getParamType(MI.NumEltsA);
908 for (
unsigned i = 0; i < MI.NumEltsB; ++i) {
912 llvm::ConstantInt::get(
IntTy, i)),
914 Values.push_back(
Builder.CreateBitCast(
V, BType));
918 Intrinsic->getFunctionType()->getParamType(MI.NumEltsA + MI.NumEltsB);
919 for (
unsigned i = 0; i < MI.NumEltsC; ++i) {
923 llvm::ConstantInt::get(
IntTy, i)),
925 Values.push_back(
Builder.CreateBitCast(
V, CType));
929 for (
unsigned i = 0; i < MI.NumEltsD; ++i)
933 llvm::ConstantInt::get(
IntTy, i)),
938 case NVPTX::BI__nvvm_ex2_approx_f16:
940 CGM.getIntrinsic(Intrinsic::nvvm_ex2_approx,
Builder.getHalfTy()),
941 BuiltinID, E, *
this);
942 case NVPTX::BI__nvvm_ex2_approx_f16x2:
944 CGM.getIntrinsic(Intrinsic::nvvm_ex2_approx,
945 FixedVectorType::get(
Builder.getHalfTy(), 2)),
946 BuiltinID, E, *
this);
947 case NVPTX::BI__nvvm_ff2f16x2_rn:
948 return MakeHalfType(Intrinsic::nvvm_ff2f16x2_rn, BuiltinID, E, *
this);
949 case NVPTX::BI__nvvm_ff2f16x2_rn_relu:
950 return MakeHalfType(Intrinsic::nvvm_ff2f16x2_rn_relu, BuiltinID, E, *
this);
951 case NVPTX::BI__nvvm_ff2f16x2_rz:
952 return MakeHalfType(Intrinsic::nvvm_ff2f16x2_rz, BuiltinID, E, *
this);
953 case NVPTX::BI__nvvm_ff2f16x2_rz_relu:
954 return MakeHalfType(Intrinsic::nvvm_ff2f16x2_rz_relu, BuiltinID, E, *
this);
955 case NVPTX::BI__nvvm_fma_rn_f16:
956 return MakeHalfType(Intrinsic::nvvm_fma_rn_f16, BuiltinID, E, *
this);
957 case NVPTX::BI__nvvm_fma_rn_f16x2:
958 return MakeHalfType(Intrinsic::nvvm_fma_rn_f16x2, BuiltinID, E, *
this);
959 case NVPTX::BI__nvvm_fma_rn_ftz_f16:
960 return MakeHalfType(Intrinsic::nvvm_fma_rn_ftz_f16, BuiltinID, E, *
this);
961 case NVPTX::BI__nvvm_fma_rn_ftz_f16x2:
962 return MakeHalfType(Intrinsic::nvvm_fma_rn_ftz_f16x2, BuiltinID, E, *
this);
963 case NVPTX::BI__nvvm_fma_rn_ftz_relu_f16:
964 return MakeHalfType(Intrinsic::nvvm_fma_rn_ftz_relu_f16, BuiltinID, E,
966 case NVPTX::BI__nvvm_fma_rn_ftz_relu_f16x2:
967 return MakeHalfType(Intrinsic::nvvm_fma_rn_ftz_relu_f16x2, BuiltinID, E,
969 case NVPTX::BI__nvvm_fma_rn_ftz_sat_f16:
970 return MakeHalfType(Intrinsic::nvvm_fma_rn_ftz_sat_f16, BuiltinID, E,
972 case NVPTX::BI__nvvm_fma_rn_ftz_sat_f16x2:
973 return MakeHalfType(Intrinsic::nvvm_fma_rn_ftz_sat_f16x2, BuiltinID, E,
975 case NVPTX::BI__nvvm_fma_rn_relu_f16:
976 return MakeHalfType(Intrinsic::nvvm_fma_rn_relu_f16, BuiltinID, E, *
this);
977 case NVPTX::BI__nvvm_fma_rn_relu_f16x2:
978 return MakeHalfType(Intrinsic::nvvm_fma_rn_relu_f16x2, BuiltinID, E, *
this);
979 case NVPTX::BI__nvvm_fma_rn_sat_f16:
980 return MakeHalfType(Intrinsic::nvvm_fma_rn_sat_f16, BuiltinID, E, *
this);
981 case NVPTX::BI__nvvm_fma_rn_sat_f16x2:
982 return MakeHalfType(Intrinsic::nvvm_fma_rn_sat_f16x2, BuiltinID, E, *
this);
983 case NVPTX::BI__nvvm_fma_rn_oob_f16:
984 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob,
Builder.getHalfTy(), E,
986 case NVPTX::BI__nvvm_fma_rn_oob_f16x2:
987 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob,
988 llvm::FixedVectorType::get(
Builder.getHalfTy(), 2), E,
990 case NVPTX::BI__nvvm_fma_rn_oob_bf16:
991 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob,
Builder.getBFloatTy(), E,
993 case NVPTX::BI__nvvm_fma_rn_oob_bf16x2:
994 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob,
995 llvm::FixedVectorType::get(
Builder.getBFloatTy(), 2), E,
997 case NVPTX::BI__nvvm_fma_rn_oob_relu_f16:
998 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob_relu,
Builder.getHalfTy(), E,
1000 case NVPTX::BI__nvvm_fma_rn_oob_relu_f16x2:
1001 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob_relu,
1002 llvm::FixedVectorType::get(
Builder.getHalfTy(), 2), E,
1004 case NVPTX::BI__nvvm_fma_rn_oob_relu_bf16:
1005 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob_relu,
Builder.getBFloatTy(), E,
1007 case NVPTX::BI__nvvm_fma_rn_oob_relu_bf16x2:
1008 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob_relu,
1009 llvm::FixedVectorType::get(
Builder.getBFloatTy(), 2), E,
1011 case NVPTX::BI__nvvm_fmax_f16:
1012 return MakeHalfType(Intrinsic::nvvm_fmax_f16, BuiltinID, E, *
this);
1013 case NVPTX::BI__nvvm_fmax_f16x2:
1014 return MakeHalfType(Intrinsic::nvvm_fmax_f16x2, BuiltinID, E, *
this);
1015 case NVPTX::BI__nvvm_fmax_ftz_f16:
1016 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_f16, BuiltinID, E, *
this);
1017 case NVPTX::BI__nvvm_fmax_ftz_f16x2:
1018 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_f16x2, BuiltinID, E, *
this);
1019 case NVPTX::BI__nvvm_fmax_ftz_nan_f16:
1020 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_nan_f16, BuiltinID, E, *
this);
1021 case NVPTX::BI__nvvm_fmax_ftz_nan_f16x2:
1022 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_nan_f16x2, BuiltinID, E,
1024 case NVPTX::BI__nvvm_fmax_ftz_nan_xorsign_abs_f16:
1025 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_nan_xorsign_abs_f16, BuiltinID,
1027 case NVPTX::BI__nvvm_fmax_ftz_nan_xorsign_abs_f16x2:
1028 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_nan_xorsign_abs_f16x2,
1029 BuiltinID, E, *
this);
1030 case NVPTX::BI__nvvm_fmax_ftz_xorsign_abs_f16:
1031 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_xorsign_abs_f16, BuiltinID, E,
1033 case NVPTX::BI__nvvm_fmax_ftz_xorsign_abs_f16x2:
1034 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_xorsign_abs_f16x2, BuiltinID,
1036 case NVPTX::BI__nvvm_fmax_nan_f16:
1037 return MakeHalfType(Intrinsic::nvvm_fmax_nan_f16, BuiltinID, E, *
this);
1038 case NVPTX::BI__nvvm_fmax_nan_f16x2:
1039 return MakeHalfType(Intrinsic::nvvm_fmax_nan_f16x2, BuiltinID, E, *
this);
1040 case NVPTX::BI__nvvm_fmax_nan_xorsign_abs_f16:
1041 return MakeHalfType(Intrinsic::nvvm_fmax_nan_xorsign_abs_f16, BuiltinID, E,
1043 case NVPTX::BI__nvvm_fmax_nan_xorsign_abs_f16x2:
1044 return MakeHalfType(Intrinsic::nvvm_fmax_nan_xorsign_abs_f16x2, BuiltinID,
1046 case NVPTX::BI__nvvm_fmax_xorsign_abs_f16:
1047 return MakeHalfType(Intrinsic::nvvm_fmax_xorsign_abs_f16, BuiltinID, E,
1049 case NVPTX::BI__nvvm_fmax_xorsign_abs_f16x2:
1050 return MakeHalfType(Intrinsic::nvvm_fmax_xorsign_abs_f16x2, BuiltinID, E,
1052 case NVPTX::BI__nvvm_fmin_f16:
1053 return MakeHalfType(Intrinsic::nvvm_fmin_f16, BuiltinID, E, *
this);
1054 case NVPTX::BI__nvvm_fmin_f16x2:
1055 return MakeHalfType(Intrinsic::nvvm_fmin_f16x2, BuiltinID, E, *
this);
1056 case NVPTX::BI__nvvm_fmin_ftz_f16:
1057 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_f16, BuiltinID, E, *
this);
1058 case NVPTX::BI__nvvm_fmin_ftz_f16x2:
1059 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_f16x2, BuiltinID, E, *
this);
1060 case NVPTX::BI__nvvm_fmin_ftz_nan_f16:
1061 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_nan_f16, BuiltinID, E, *
this);
1062 case NVPTX::BI__nvvm_fmin_ftz_nan_f16x2:
1063 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_nan_f16x2, BuiltinID, E,
1065 case NVPTX::BI__nvvm_fmin_ftz_nan_xorsign_abs_f16:
1066 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_nan_xorsign_abs_f16, BuiltinID,
1068 case NVPTX::BI__nvvm_fmin_ftz_nan_xorsign_abs_f16x2:
1069 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_nan_xorsign_abs_f16x2,
1070 BuiltinID, E, *
this);
1071 case NVPTX::BI__nvvm_fmin_ftz_xorsign_abs_f16:
1072 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_xorsign_abs_f16, BuiltinID, E,
1074 case NVPTX::BI__nvvm_fmin_ftz_xorsign_abs_f16x2:
1075 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_xorsign_abs_f16x2, BuiltinID,
1077 case NVPTX::BI__nvvm_fmin_nan_f16:
1078 return MakeHalfType(Intrinsic::nvvm_fmin_nan_f16, BuiltinID, E, *
this);
1079 case NVPTX::BI__nvvm_fmin_nan_f16x2:
1080 return MakeHalfType(Intrinsic::nvvm_fmin_nan_f16x2, BuiltinID, E, *
this);
1081 case NVPTX::BI__nvvm_fmin_nan_xorsign_abs_f16:
1082 return MakeHalfType(Intrinsic::nvvm_fmin_nan_xorsign_abs_f16, BuiltinID, E,
1084 case NVPTX::BI__nvvm_fmin_nan_xorsign_abs_f16x2:
1085 return MakeHalfType(Intrinsic::nvvm_fmin_nan_xorsign_abs_f16x2, BuiltinID,
1087 case NVPTX::BI__nvvm_fmin_xorsign_abs_f16:
1088 return MakeHalfType(Intrinsic::nvvm_fmin_xorsign_abs_f16, BuiltinID, E,
1090 case NVPTX::BI__nvvm_fmin_xorsign_abs_f16x2:
1091 return MakeHalfType(Intrinsic::nvvm_fmin_xorsign_abs_f16x2, BuiltinID, E,
1093 case NVPTX::BI__nvvm_fabs_f:
1094 case NVPTX::BI__nvvm_abs_bf16:
1095 case NVPTX::BI__nvvm_abs_bf16x2:
1096 case NVPTX::BI__nvvm_fabs_f16:
1097 case NVPTX::BI__nvvm_fabs_f16x2:
1098 return Builder.CreateUnaryIntrinsic(Intrinsic::nvvm_fabs,
1100 case NVPTX::BI__nvvm_fabs_ftz_f:
1101 case NVPTX::BI__nvvm_fabs_ftz_f16:
1102 case NVPTX::BI__nvvm_fabs_ftz_f16x2:
1103 return Builder.CreateUnaryIntrinsic(Intrinsic::nvvm_fabs_ftz,
1105 case NVPTX::BI__nvvm_fabs_d:
1107 case NVPTX::BI__nvvm_ex2_approx_d:
1108 case NVPTX::BI__nvvm_ex2_approx_f:
1109 return Builder.CreateUnaryIntrinsic(Intrinsic::nvvm_ex2_approx,
1111 case NVPTX::BI__nvvm_ex2_approx_ftz_f:
1112 return Builder.CreateUnaryIntrinsic(Intrinsic::nvvm_ex2_approx_ftz,
1114 case NVPTX::BI__nvvm_ldg_h:
1115 case NVPTX::BI__nvvm_ldg_h2:
1116 return MakeLdg(*
this, E);
1117 case NVPTX::BI__nvvm_ldu_h:
1118 case NVPTX::BI__nvvm_ldu_h2:
1119 return MakeLdu(Intrinsic::nvvm_ldu_global_f, *
this, E);
1120 case NVPTX::BI__nvvm_cp_async_ca_shared_global_4:
1121 return MakeCpAsync(Intrinsic::nvvm_cp_async_ca_shared_global_4,
1122 Intrinsic::nvvm_cp_async_ca_shared_global_4_s, *
this, E,
1124 case NVPTX::BI__nvvm_cp_async_ca_shared_global_8:
1125 return MakeCpAsync(Intrinsic::nvvm_cp_async_ca_shared_global_8,
1126 Intrinsic::nvvm_cp_async_ca_shared_global_8_s, *
this, E,
1128 case NVPTX::BI__nvvm_cp_async_ca_shared_global_16:
1129 return MakeCpAsync(Intrinsic::nvvm_cp_async_ca_shared_global_16,
1130 Intrinsic::nvvm_cp_async_ca_shared_global_16_s, *
this, E,
1132 case NVPTX::BI__nvvm_cp_async_cg_shared_global_16:
1133 return MakeCpAsync(Intrinsic::nvvm_cp_async_cg_shared_global_16,
1134 Intrinsic::nvvm_cp_async_cg_shared_global_16_s, *
this, E,
1136 case NVPTX::BI__nvvm_read_ptx_sreg_clusterid_x:
1138 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_clusterid_x));
1139 case NVPTX::BI__nvvm_read_ptx_sreg_clusterid_y:
1141 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_clusterid_y));
1142 case NVPTX::BI__nvvm_read_ptx_sreg_clusterid_z:
1144 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_clusterid_z));
1145 case NVPTX::BI__nvvm_read_ptx_sreg_clusterid_w:
1147 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_clusterid_w));
1148 case NVPTX::BI__nvvm_read_ptx_sreg_nclusterid_x:
1150 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_nclusterid_x));
1151 case NVPTX::BI__nvvm_read_ptx_sreg_nclusterid_y:
1153 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_nclusterid_y));
1154 case NVPTX::BI__nvvm_read_ptx_sreg_nclusterid_z:
1156 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_nclusterid_z));
1157 case NVPTX::BI__nvvm_read_ptx_sreg_nclusterid_w:
1159 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_nclusterid_w));
1160 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_ctaid_x:
1162 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_ctaid_x));
1163 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_ctaid_y:
1165 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_ctaid_y));
1166 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_ctaid_z:
1168 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_ctaid_z));
1169 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_ctaid_w:
1171 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_ctaid_w));
1172 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_nctaid_x:
1174 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_nctaid_x));
1175 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_nctaid_y:
1177 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_nctaid_y));
1178 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_nctaid_z:
1180 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_nctaid_z));
1181 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_nctaid_w:
1183 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_nctaid_w));
1184 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_ctarank:
1186 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_ctarank));
1187 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_nctarank:
1189 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_nctarank));
1190 case NVPTX::BI__nvvm_is_explicit_cluster:
1192 CGM.getIntrinsic(Intrinsic::nvvm_is_explicit_cluster));
1193 case NVPTX::BI__nvvm_isspacep_shared_cluster:
1195 CGM.getIntrinsic(Intrinsic::nvvm_isspacep_shared_cluster),
1197 case NVPTX::BI__nvvm_mapa:
1199 CGM.getIntrinsic(Intrinsic::nvvm_mapa),
1200 {EmitScalarExpr(E->getArg(0)), EmitScalarExpr(E->getArg(1))});
1201 case NVPTX::BI__nvvm_mapa_shared_cluster:
1203 CGM.getIntrinsic(Intrinsic::nvvm_mapa_shared_cluster),
1204 {EmitScalarExpr(E->getArg(0)), EmitScalarExpr(E->getArg(1))});
1205 case NVPTX::BI__nvvm_getctarank:
1207 CGM.getIntrinsic(Intrinsic::nvvm_getctarank),
1209 case NVPTX::BI__nvvm_getctarank_shared_cluster:
1211 CGM.getIntrinsic(Intrinsic::nvvm_getctarank_shared_cluster),
1213 case NVPTX::BI__nvvm_barrier_cluster_arrive:
1215 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cluster_arrive));
1216 case NVPTX::BI__nvvm_barrier_cluster_arrive_relaxed:
1218 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cluster_arrive_relaxed));
1219 case NVPTX::BI__nvvm_barrier_cluster_wait:
1221 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cluster_wait));
1222 case NVPTX::BI__nvvm_fence_sc_cluster:
1224 CGM.getIntrinsic(Intrinsic::nvvm_fence_sc_cluster));
1225 case NVPTX::BI__nvvm_bar_sync:
1227 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cta_sync_aligned_all),
1229 case NVPTX::BI__syncthreads:
1231 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cta_sync_aligned_all),
1233 case NVPTX::BI__nvvm_barrier_sync:
1235 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cta_sync_all),
1237 case NVPTX::BI__nvvm_barrier_sync_cnt:
1239 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cta_sync_count),
1240 {EmitScalarExpr(E->getArg(0)), EmitScalarExpr(E->getArg(1))});
1241 case NVPTX::BI__nvvm_bar0_and:
1244 Intrinsic::nvvm_barrier_cta_red_and_aligned_all, {},
1245 {Builder.getInt32(0),
1246 Builder.CreateICmpNE(EmitScalarExpr(E->getArg(0)),
1247 Builder.getInt32(0))}),
1249 case NVPTX::BI__nvvm_bar0_or:
1252 Intrinsic::nvvm_barrier_cta_red_or_aligned_all, {},
1253 {Builder.getInt32(0),
1254 Builder.CreateICmpNE(EmitScalarExpr(E->getArg(0)),
1255 Builder.getInt32(0))}),
1257 case NVPTX::BI__nvvm_bar0_popc:
1258 return Builder.CreateIntrinsic(
1259 Intrinsic::nvvm_barrier_cta_red_popc_aligned_all, {},