471 case NVPTX::BI__nvvm_mulhi_i:
472 case NVPTX::BI__nvvm_mulhi_ui:
473 case NVPTX::BI__nvvm_mulhi_ll:
474 case NVPTX::BI__nvvm_mulhi_ull:
475 return Builder.CreateBinaryIntrinsic(
483 case NVPTX::BI__nvvm_atom_add_gen_i:
484 case NVPTX::BI__nvvm_atom_add_gen_l:
485 case NVPTX::BI__nvvm_atom_add_gen_ll:
487 AtomicOrdering::Monotonic,
490 case NVPTX::BI__nvvm_atom_sub_gen_i:
491 case NVPTX::BI__nvvm_atom_sub_gen_l:
492 case NVPTX::BI__nvvm_atom_sub_gen_ll:
494 AtomicOrdering::Monotonic,
497 case NVPTX::BI__nvvm_atom_and_gen_i:
498 case NVPTX::BI__nvvm_atom_and_gen_l:
499 case NVPTX::BI__nvvm_atom_and_gen_ll:
501 AtomicOrdering::Monotonic,
504 case NVPTX::BI__nvvm_atom_or_gen_i:
505 case NVPTX::BI__nvvm_atom_or_gen_l:
506 case NVPTX::BI__nvvm_atom_or_gen_ll:
508 AtomicOrdering::Monotonic,
511 case NVPTX::BI__nvvm_atom_xor_gen_i:
512 case NVPTX::BI__nvvm_atom_xor_gen_l:
513 case NVPTX::BI__nvvm_atom_xor_gen_ll:
515 AtomicOrdering::Monotonic,
518 case NVPTX::BI__nvvm_atom_xchg_gen_i:
519 case NVPTX::BI__nvvm_atom_xchg_gen_l:
520 case NVPTX::BI__nvvm_atom_xchg_gen_ll:
522 AtomicOrdering::Monotonic,
525 case NVPTX::BI__nvvm_atom_max_gen_i:
526 case NVPTX::BI__nvvm_atom_max_gen_l:
527 case NVPTX::BI__nvvm_atom_max_gen_ll:
529 AtomicOrdering::Monotonic,
532 case NVPTX::BI__nvvm_atom_max_gen_ui:
533 case NVPTX::BI__nvvm_atom_max_gen_ul:
534 case NVPTX::BI__nvvm_atom_max_gen_ull:
536 AtomicOrdering::Monotonic,
539 case NVPTX::BI__nvvm_atom_min_gen_i:
540 case NVPTX::BI__nvvm_atom_min_gen_l:
541 case NVPTX::BI__nvvm_atom_min_gen_ll:
543 AtomicOrdering::Monotonic,
546 case NVPTX::BI__nvvm_atom_min_gen_ui:
547 case NVPTX::BI__nvvm_atom_min_gen_ul:
548 case NVPTX::BI__nvvm_atom_min_gen_ull:
550 AtomicOrdering::Monotonic,
553 case NVPTX::BI__nvvm_atom_cas_gen_us:
554 case NVPTX::BI__nvvm_atom_cas_gen_i:
555 case NVPTX::BI__nvvm_atom_cas_gen_l:
556 case NVPTX::BI__nvvm_atom_cas_gen_ll:
560 *
this, E,
false, AtomicOrdering::Monotonic,
563 case NVPTX::BI__nvvm_atom_add_gen_f:
564 case NVPTX::BI__nvvm_atom_add_gen_d: {
568 llvm::AtomicRMWInst *RMW =
Builder.CreateAtomicRMW(
569 llvm::AtomicRMWInst::FAdd, DestAddr, Val, AtomicOrdering::Monotonic,
580 case NVPTX::BI__nvvm_atom_inc_gen_ui:
582 AtomicOrdering::Monotonic,
585 case NVPTX::BI__nvvm_atom_dec_gen_ui:
587 AtomicOrdering::Monotonic,
590 case NVPTX::BI__nvvm_ldg_c:
591 case NVPTX::BI__nvvm_ldg_sc:
592 case NVPTX::BI__nvvm_ldg_c2:
593 case NVPTX::BI__nvvm_ldg_sc2:
594 case NVPTX::BI__nvvm_ldg_c4:
595 case NVPTX::BI__nvvm_ldg_sc4:
596 case NVPTX::BI__nvvm_ldg_s:
597 case NVPTX::BI__nvvm_ldg_s2:
598 case NVPTX::BI__nvvm_ldg_s4:
599 case NVPTX::BI__nvvm_ldg_i:
600 case NVPTX::BI__nvvm_ldg_i2:
601 case NVPTX::BI__nvvm_ldg_i4:
602 case NVPTX::BI__nvvm_ldg_l:
603 case NVPTX::BI__nvvm_ldg_l2:
604 case NVPTX::BI__nvvm_ldg_ll:
605 case NVPTX::BI__nvvm_ldg_ll2:
606 case NVPTX::BI__nvvm_ldg_uc:
607 case NVPTX::BI__nvvm_ldg_uc2:
608 case NVPTX::BI__nvvm_ldg_uc4:
609 case NVPTX::BI__nvvm_ldg_us:
610 case NVPTX::BI__nvvm_ldg_us2:
611 case NVPTX::BI__nvvm_ldg_us4:
612 case NVPTX::BI__nvvm_ldg_ui:
613 case NVPTX::BI__nvvm_ldg_ui2:
614 case NVPTX::BI__nvvm_ldg_ui4:
615 case NVPTX::BI__nvvm_ldg_ul:
616 case NVPTX::BI__nvvm_ldg_ul2:
617 case NVPTX::BI__nvvm_ldg_ull:
618 case NVPTX::BI__nvvm_ldg_ull2:
619 case NVPTX::BI__nvvm_ldg_f:
620 case NVPTX::BI__nvvm_ldg_f2:
621 case NVPTX::BI__nvvm_ldg_f4:
622 case NVPTX::BI__nvvm_ldg_d:
623 case NVPTX::BI__nvvm_ldg_d2:
627 return MakeLdg(*
this, E);
629 case NVPTX::BI__nvvm_ldu_c:
630 case NVPTX::BI__nvvm_ldu_sc:
631 case NVPTX::BI__nvvm_ldu_c2:
632 case NVPTX::BI__nvvm_ldu_sc2:
633 case NVPTX::BI__nvvm_ldu_c4:
634 case NVPTX::BI__nvvm_ldu_sc4:
635 case NVPTX::BI__nvvm_ldu_s:
636 case NVPTX::BI__nvvm_ldu_s2:
637 case NVPTX::BI__nvvm_ldu_s4:
638 case NVPTX::BI__nvvm_ldu_i:
639 case NVPTX::BI__nvvm_ldu_i2:
640 case NVPTX::BI__nvvm_ldu_i4:
641 case NVPTX::BI__nvvm_ldu_l:
642 case NVPTX::BI__nvvm_ldu_l2:
643 case NVPTX::BI__nvvm_ldu_ll:
644 case NVPTX::BI__nvvm_ldu_ll2:
645 case NVPTX::BI__nvvm_ldu_uc:
646 case NVPTX::BI__nvvm_ldu_uc2:
647 case NVPTX::BI__nvvm_ldu_uc4:
648 case NVPTX::BI__nvvm_ldu_us:
649 case NVPTX::BI__nvvm_ldu_us2:
650 case NVPTX::BI__nvvm_ldu_us4:
651 case NVPTX::BI__nvvm_ldu_ui:
652 case NVPTX::BI__nvvm_ldu_ui2:
653 case NVPTX::BI__nvvm_ldu_ui4:
654 case NVPTX::BI__nvvm_ldu_ul:
655 case NVPTX::BI__nvvm_ldu_ul2:
656 case NVPTX::BI__nvvm_ldu_ull:
657 case NVPTX::BI__nvvm_ldu_ull2:
658 return MakeLdu(Intrinsic::nvvm_ldu_global_i, *
this, E);
659 case NVPTX::BI__nvvm_ldu_f:
660 case NVPTX::BI__nvvm_ldu_f2:
661 case NVPTX::BI__nvvm_ldu_f4:
662 case NVPTX::BI__nvvm_ldu_d:
663 case NVPTX::BI__nvvm_ldu_d2:
664 return MakeLdu(Intrinsic::nvvm_ldu_global_f, *
this, E);
666 case NVPTX::BI__nvvm_atom_cta_add_gen_i:
667 case NVPTX::BI__nvvm_atom_cta_add_gen_l:
668 case NVPTX::BI__nvvm_atom_cta_add_gen_ll:
669 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Add,
670 llvm::AtomicScope::Workgroup);
671 case NVPTX::BI__nvvm_atom_sys_add_gen_i:
672 case NVPTX::BI__nvvm_atom_sys_add_gen_l:
673 case NVPTX::BI__nvvm_atom_sys_add_gen_ll:
674 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Add,
675 llvm::AtomicScope::System);
676 case NVPTX::BI__nvvm_atom_cta_add_gen_f:
677 case NVPTX::BI__nvvm_atom_cta_add_gen_d:
678 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::FAdd,
679 llvm::AtomicScope::Workgroup);
680 case NVPTX::BI__nvvm_atom_sys_add_gen_f:
681 case NVPTX::BI__nvvm_atom_sys_add_gen_d:
682 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::FAdd,
683 llvm::AtomicScope::System);
684 case NVPTX::BI__nvvm_atom_cta_xchg_gen_i:
685 case NVPTX::BI__nvvm_atom_cta_xchg_gen_l:
686 case NVPTX::BI__nvvm_atom_cta_xchg_gen_ll:
687 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Xchg,
688 llvm::AtomicScope::Workgroup);
689 case NVPTX::BI__nvvm_atom_sys_xchg_gen_i:
690 case NVPTX::BI__nvvm_atom_sys_xchg_gen_l:
691 case NVPTX::BI__nvvm_atom_sys_xchg_gen_ll:
692 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Xchg,
693 llvm::AtomicScope::System);
694 case NVPTX::BI__nvvm_atom_cta_max_gen_i:
695 case NVPTX::BI__nvvm_atom_cta_max_gen_l:
696 case NVPTX::BI__nvvm_atom_cta_max_gen_ll:
697 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Max,
698 llvm::AtomicScope::Workgroup);
699 case NVPTX::BI__nvvm_atom_cta_max_gen_ui:
700 case NVPTX::BI__nvvm_atom_cta_max_gen_ul:
701 case NVPTX::BI__nvvm_atom_cta_max_gen_ull:
702 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UMax,
703 llvm::AtomicScope::Workgroup);
704 case NVPTX::BI__nvvm_atom_sys_max_gen_i:
705 case NVPTX::BI__nvvm_atom_sys_max_gen_l:
706 case NVPTX::BI__nvvm_atom_sys_max_gen_ll:
707 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Max,
708 llvm::AtomicScope::System);
709 case NVPTX::BI__nvvm_atom_sys_max_gen_ui:
710 case NVPTX::BI__nvvm_atom_sys_max_gen_ul:
711 case NVPTX::BI__nvvm_atom_sys_max_gen_ull:
712 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UMax,
713 llvm::AtomicScope::System);
714 case NVPTX::BI__nvvm_atom_cta_min_gen_i:
715 case NVPTX::BI__nvvm_atom_cta_min_gen_l:
716 case NVPTX::BI__nvvm_atom_cta_min_gen_ll:
717 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Min,
718 llvm::AtomicScope::Workgroup);
719 case NVPTX::BI__nvvm_atom_cta_min_gen_ui:
720 case NVPTX::BI__nvvm_atom_cta_min_gen_ul:
721 case NVPTX::BI__nvvm_atom_cta_min_gen_ull:
722 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UMin,
723 llvm::AtomicScope::Workgroup);
724 case NVPTX::BI__nvvm_atom_sys_min_gen_i:
725 case NVPTX::BI__nvvm_atom_sys_min_gen_l:
726 case NVPTX::BI__nvvm_atom_sys_min_gen_ll:
727 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Min,
728 llvm::AtomicScope::System);
729 case NVPTX::BI__nvvm_atom_sys_min_gen_ui:
730 case NVPTX::BI__nvvm_atom_sys_min_gen_ul:
731 case NVPTX::BI__nvvm_atom_sys_min_gen_ull:
732 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UMin,
733 llvm::AtomicScope::System);
734 case NVPTX::BI__nvvm_atom_cta_inc_gen_ui:
735 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UIncWrap,
736 llvm::AtomicScope::Workgroup);
737 case NVPTX::BI__nvvm_atom_cta_dec_gen_ui:
738 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UDecWrap,
739 llvm::AtomicScope::Workgroup);
740 case NVPTX::BI__nvvm_atom_sys_inc_gen_ui:
741 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UIncWrap,
742 llvm::AtomicScope::System);
743 case NVPTX::BI__nvvm_atom_sys_dec_gen_ui:
744 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UDecWrap,
745 llvm::AtomicScope::System);
746 case NVPTX::BI__nvvm_atom_cta_and_gen_i:
747 case NVPTX::BI__nvvm_atom_cta_and_gen_l:
748 case NVPTX::BI__nvvm_atom_cta_and_gen_ll:
749 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::And,
750 llvm::AtomicScope::Workgroup);
751 case NVPTX::BI__nvvm_atom_sys_and_gen_i:
752 case NVPTX::BI__nvvm_atom_sys_and_gen_l:
753 case NVPTX::BI__nvvm_atom_sys_and_gen_ll:
754 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::And,
755 llvm::AtomicScope::System);
756 case NVPTX::BI__nvvm_atom_cta_or_gen_i:
757 case NVPTX::BI__nvvm_atom_cta_or_gen_l:
758 case NVPTX::BI__nvvm_atom_cta_or_gen_ll:
759 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Or,
760 llvm::AtomicScope::Workgroup);
761 case NVPTX::BI__nvvm_atom_sys_or_gen_i:
762 case NVPTX::BI__nvvm_atom_sys_or_gen_l:
763 case NVPTX::BI__nvvm_atom_sys_or_gen_ll:
764 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Or,
765 llvm::AtomicScope::System);
766 case NVPTX::BI__nvvm_atom_cta_xor_gen_i:
767 case NVPTX::BI__nvvm_atom_cta_xor_gen_l:
768 case NVPTX::BI__nvvm_atom_cta_xor_gen_ll:
769 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Xor,
770 llvm::AtomicScope::Workgroup);
771 case NVPTX::BI__nvvm_atom_sys_xor_gen_i:
772 case NVPTX::BI__nvvm_atom_sys_xor_gen_l:
773 case NVPTX::BI__nvvm_atom_sys_xor_gen_ll:
774 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Xor,
775 llvm::AtomicScope::System);
776 case NVPTX::BI__nvvm_atom_cta_cas_gen_us:
777 case NVPTX::BI__nvvm_atom_cta_cas_gen_i:
778 case NVPTX::BI__nvvm_atom_cta_cas_gen_l:
779 case NVPTX::BI__nvvm_atom_cta_cas_gen_ll:
780 return MakeScopedAtomicCAS(*
this, E, llvm::AtomicScope::Workgroup);
781 case NVPTX::BI__nvvm_atom_sys_cas_gen_us:
782 case NVPTX::BI__nvvm_atom_sys_cas_gen_i:
783 case NVPTX::BI__nvvm_atom_sys_cas_gen_l:
784 case NVPTX::BI__nvvm_atom_sys_cas_gen_ll:
785 return MakeScopedAtomicCAS(*
this, E, llvm::AtomicScope::System);
786 case NVPTX::BI__nvvm_match_all_sync_i32p:
787 case NVPTX::BI__nvvm_match_all_sync_i64p: {
792 CGM.getIntrinsic(BuiltinID == NVPTX::BI__nvvm_match_all_sync_i32p
793 ? Intrinsic::nvvm_match_all_sync_i32p
794 : Intrinsic::nvvm_match_all_sync_i64p),
798 Builder.CreateStore(Pred, PredOutPtr);
799 return Builder.CreateExtractValue(ResultPair, 0);
803 case NVPTX::BI__hmma_m16n16k16_ld_a:
804 case NVPTX::BI__hmma_m16n16k16_ld_b:
805 case NVPTX::BI__hmma_m16n16k16_ld_c_f16:
806 case NVPTX::BI__hmma_m16n16k16_ld_c_f32:
807 case NVPTX::BI__hmma_m32n8k16_ld_a:
808 case NVPTX::BI__hmma_m32n8k16_ld_b:
809 case NVPTX::BI__hmma_m32n8k16_ld_c_f16:
810 case NVPTX::BI__hmma_m32n8k16_ld_c_f32:
811 case NVPTX::BI__hmma_m8n32k16_ld_a:
812 case NVPTX::BI__hmma_m8n32k16_ld_b:
813 case NVPTX::BI__hmma_m8n32k16_ld_c_f16:
814 case NVPTX::BI__hmma_m8n32k16_ld_c_f32:
816 case NVPTX::BI__imma_m16n16k16_ld_a_s8:
817 case NVPTX::BI__imma_m16n16k16_ld_a_u8:
818 case NVPTX::BI__imma_m16n16k16_ld_b_s8:
819 case NVPTX::BI__imma_m16n16k16_ld_b_u8:
820 case NVPTX::BI__imma_m16n16k16_ld_c:
821 case NVPTX::BI__imma_m32n8k16_ld_a_s8:
822 case NVPTX::BI__imma_m32n8k16_ld_a_u8:
823 case NVPTX::BI__imma_m32n8k16_ld_b_s8:
824 case NVPTX::BI__imma_m32n8k16_ld_b_u8:
825 case NVPTX::BI__imma_m32n8k16_ld_c:
826 case NVPTX::BI__imma_m8n32k16_ld_a_s8:
827 case NVPTX::BI__imma_m8n32k16_ld_a_u8:
828 case NVPTX::BI__imma_m8n32k16_ld_b_s8:
829 case NVPTX::BI__imma_m8n32k16_ld_b_u8:
830 case NVPTX::BI__imma_m8n32k16_ld_c:
832 case NVPTX::BI__imma_m8n8k32_ld_a_s4:
833 case NVPTX::BI__imma_m8n8k32_ld_a_u4:
834 case NVPTX::BI__imma_m8n8k32_ld_b_s4:
835 case NVPTX::BI__imma_m8n8k32_ld_b_u4:
836 case NVPTX::BI__imma_m8n8k32_ld_c:
837 case NVPTX::BI__bmma_m8n8k128_ld_a_b1:
838 case NVPTX::BI__bmma_m8n8k128_ld_b_b1:
839 case NVPTX::BI__bmma_m8n8k128_ld_c:
841 case NVPTX::BI__dmma_m8n8k4_ld_a:
842 case NVPTX::BI__dmma_m8n8k4_ld_b:
843 case NVPTX::BI__dmma_m8n8k4_ld_c:
845 case NVPTX::BI__mma_bf16_m16n16k16_ld_a:
846 case NVPTX::BI__mma_bf16_m16n16k16_ld_b:
847 case NVPTX::BI__mma_bf16_m8n32k16_ld_a:
848 case NVPTX::BI__mma_bf16_m8n32k16_ld_b:
849 case NVPTX::BI__mma_bf16_m32n8k16_ld_a:
850 case NVPTX::BI__mma_bf16_m32n8k16_ld_b:
851 case NVPTX::BI__mma_tf32_m16n16k8_ld_a:
852 case NVPTX::BI__mma_tf32_m16n16k8_ld_b:
853 case NVPTX::BI__mma_tf32_m16n16k8_ld_c: {
857 std::optional<llvm::APSInt> isColMajorArg =
861 bool isColMajor = isColMajorArg->getSExtValue();
862 NVPTXMmaLdstInfo II = getNVPTXMmaLdstInfo(BuiltinID);
863 unsigned IID = isColMajor ? II.IID_col : II.IID_row;
871 assert(II.NumResults);
872 if (II.NumResults == 1) {
876 for (
unsigned i = 0; i < II.NumResults; ++i) {
881 llvm::ConstantInt::get(
IntTy, i)),
888 case NVPTX::BI__hmma_m16n16k16_st_c_f16:
889 case NVPTX::BI__hmma_m16n16k16_st_c_f32:
890 case NVPTX::BI__hmma_m32n8k16_st_c_f16:
891 case NVPTX::BI__hmma_m32n8k16_st_c_f32:
892 case NVPTX::BI__hmma_m8n32k16_st_c_f16:
893 case NVPTX::BI__hmma_m8n32k16_st_c_f32:
894 case NVPTX::BI__imma_m16n16k16_st_c_i32:
895 case NVPTX::BI__imma_m32n8k16_st_c_i32:
896 case NVPTX::BI__imma_m8n32k16_st_c_i32:
897 case NVPTX::BI__imma_m8n8k32_st_c_i32:
898 case NVPTX::BI__bmma_m8n8k128_st_c_i32:
899 case NVPTX::BI__dmma_m8n8k4_st_c_f64:
900 case NVPTX::BI__mma_m16n16k8_st_c_f32: {
904 std::optional<llvm::APSInt> isColMajorArg =
908 bool isColMajor = isColMajorArg->getSExtValue();
909 NVPTXMmaLdstInfo II = getNVPTXMmaLdstInfo(BuiltinID);
910 unsigned IID = isColMajor ? II.IID_col : II.IID_row;
915 llvm::Type *ParamType = Intrinsic->getFunctionType()->getParamType(1);
917 for (
unsigned i = 0; i < II.NumResults; ++i) {
921 llvm::ConstantInt::get(
IntTy, i)),
923 Values.push_back(
Builder.CreateBitCast(
V, ParamType));
925 Values.push_back(Ldm);
932 case NVPTX::BI__hmma_m16n16k16_mma_f16f16:
933 case NVPTX::BI__hmma_m16n16k16_mma_f32f16:
934 case NVPTX::BI__hmma_m16n16k16_mma_f32f32:
935 case NVPTX::BI__hmma_m16n16k16_mma_f16f32:
936 case NVPTX::BI__hmma_m32n8k16_mma_f16f16:
937 case NVPTX::BI__hmma_m32n8k16_mma_f32f16:
938 case NVPTX::BI__hmma_m32n8k16_mma_f32f32:
939 case NVPTX::BI__hmma_m32n8k16_mma_f16f32:
940 case NVPTX::BI__hmma_m8n32k16_mma_f16f16:
941 case NVPTX::BI__hmma_m8n32k16_mma_f32f16:
942 case NVPTX::BI__hmma_m8n32k16_mma_f32f32:
943 case NVPTX::BI__hmma_m8n32k16_mma_f16f32:
944 case NVPTX::BI__imma_m16n16k16_mma_s8:
945 case NVPTX::BI__imma_m16n16k16_mma_u8:
946 case NVPTX::BI__imma_m32n8k16_mma_s8:
947 case NVPTX::BI__imma_m32n8k16_mma_u8:
948 case NVPTX::BI__imma_m8n32k16_mma_s8:
949 case NVPTX::BI__imma_m8n32k16_mma_u8:
950 case NVPTX::BI__imma_m8n8k32_mma_s4:
951 case NVPTX::BI__imma_m8n8k32_mma_u4:
952 case NVPTX::BI__bmma_m8n8k128_mma_xor_popc_b1:
953 case NVPTX::BI__bmma_m8n8k128_mma_and_popc_b1:
954 case NVPTX::BI__dmma_m8n8k4_mma_f64:
955 case NVPTX::BI__mma_bf16_m16n16k16_mma_f32:
956 case NVPTX::BI__mma_bf16_m8n32k16_mma_f32:
957 case NVPTX::BI__mma_bf16_m32n8k16_mma_f32:
958 case NVPTX::BI__mma_tf32_m16n16k8_mma_f32: {
963 std::optional<llvm::APSInt> LayoutArg =
967 int Layout = LayoutArg->getSExtValue();
968 if (Layout < 0 || Layout > 3)
970 llvm::APSInt SatfArg;
971 if (BuiltinID == NVPTX::BI__bmma_m8n8k128_mma_xor_popc_b1 ||
972 BuiltinID == NVPTX::BI__bmma_m8n8k128_mma_and_popc_b1)
974 else if (std::optional<llvm::APSInt> OptSatfArg =
976 SatfArg = *OptSatfArg;
979 bool Satf = SatfArg.getSExtValue();
980 NVPTXMmaInfo MI = getNVPTXMmaInfo(BuiltinID);
981 unsigned IID = MI.getMMAIntrinsic(Layout, Satf);
987 llvm::Type *AType = Intrinsic->getFunctionType()->getParamType(0);
989 for (
unsigned i = 0; i < MI.NumEltsA; ++i) {
993 llvm::ConstantInt::get(
IntTy, i)),
995 Values.push_back(
Builder.CreateBitCast(
V, AType));
998 llvm::Type *BType = Intrinsic->getFunctionType()->getParamType(MI.NumEltsA);
999 for (
unsigned i = 0; i < MI.NumEltsB; ++i) {
1003 llvm::ConstantInt::get(
IntTy, i)),
1005 Values.push_back(
Builder.CreateBitCast(
V, BType));
1009 Intrinsic->getFunctionType()->getParamType(MI.NumEltsA + MI.NumEltsB);
1010 for (
unsigned i = 0; i < MI.NumEltsC; ++i) {
1014 llvm::ConstantInt::get(
IntTy, i)),
1016 Values.push_back(
Builder.CreateBitCast(
V, CType));
1020 for (
unsigned i = 0; i < MI.NumEltsD; ++i)
1024 llvm::ConstantInt::get(
IntTy, i)),
1029 case NVPTX::BI__nvvm_ex2_approx_f16:
1030 return MakeHalfType(
1031 CGM.getIntrinsic(Intrinsic::nvvm_ex2_approx,
Builder.getHalfTy()),
1032 BuiltinID, E, *
this);
1033 case NVPTX::BI__nvvm_ex2_approx_f16x2:
1034 return MakeHalfType(
1035 CGM.getIntrinsic(Intrinsic::nvvm_ex2_approx,
1036 FixedVectorType::get(
Builder.getHalfTy(), 2)),
1037 BuiltinID, E, *
this);
1038 case NVPTX::BI__nvvm_ff2f16x2_rn:
1039 return MakeHalfType(Intrinsic::nvvm_ff2f16x2_rn, BuiltinID, E, *
this);
1040 case NVPTX::BI__nvvm_ff2f16x2_rn_relu:
1041 return MakeHalfType(Intrinsic::nvvm_ff2f16x2_rn_relu, BuiltinID, E, *
this);
1042 case NVPTX::BI__nvvm_ff2f16x2_rz:
1043 return MakeHalfType(Intrinsic::nvvm_ff2f16x2_rz, BuiltinID, E, *
this);
1044 case NVPTX::BI__nvvm_ff2f16x2_rz_relu:
1045 return MakeHalfType(Intrinsic::nvvm_ff2f16x2_rz_relu, BuiltinID, E, *
this);
1047#define PZO_CVT(cvt) \
1048 case NVPTX::BI__nvvm_##cvt##_pzo: \
1049 return MakeHalfType(Intrinsic::nvvm_##cvt, BuiltinID, E, *this, \
1050 {Builder.getTrue()})
1056 PZO_CVT(ff2f16x2_rn_satfinite);
1057 PZO_CVT(ff2f16x2_rn_relu_satfinite);
1058 PZO_CVT(ff2f16x2_rz_satfinite);
1059 PZO_CVT(ff2f16x2_rz_relu_satfinite);
1064 PZO_CVT(ff2bf16x2_rn_satfinite);
1065 PZO_CVT(ff2bf16x2_rn_relu_satfinite);
1066 PZO_CVT(ff2bf16x2_rz_satfinite);
1067 PZO_CVT(ff2bf16x2_rz_relu_satfinite);
1073 PZO_CVT(f2f16_rn_relu_satfinite);
1075 PZO_CVT(f2f16_rz_relu_satfinite);
1081 PZO_CVT(f2bf16_rn_relu_satfinite);
1083 PZO_CVT(f2bf16_rz_relu_satfinite);
1086 PZO_CVT(ff_to_e4m3x2_rn_relu);
1088 PZO_CVT(ff_to_e4m3x2_rz_relu);
1090 PZO_CVT(ff_to_e5m2x2_rn_relu);
1092 PZO_CVT(ff_to_e5m2x2_rz_relu);
1094 PZO_CVT(f16x2_to_e4m3x2_rn_relu);
1096 PZO_CVT(f16x2_to_e4m3x2_rz_relu);
1098 PZO_CVT(f16x2_to_e5m2x2_rn_relu);
1100 PZO_CVT(f16x2_to_e5m2x2_rz_relu);
1101 PZO_CVT(bf16x2_to_e4m3x2_rn_satfinite);
1102 PZO_CVT(bf16x2_to_e4m3x2_rn_relu_satfinite);
1103 PZO_CVT(bf16x2_to_e4m3x2_rz_satfinite);
1104 PZO_CVT(bf16x2_to_e4m3x2_rz_relu_satfinite);
1105 PZO_CVT(bf16x2_to_e5m2x2_rn_satfinite);
1106 PZO_CVT(bf16x2_to_e5m2x2_rn_relu_satfinite);
1107 PZO_CVT(bf16x2_to_e5m2x2_rz_satfinite);
1108 PZO_CVT(bf16x2_to_e5m2x2_rz_relu_satfinite);
1110 PZO_CVT(ff_to_e4m3x2_rn_scale_n1_ue8m0);
1111 PZO_CVT(ff_to_e4m3x2_rn_relu_scale_n1_ue8m0);
1112 PZO_CVT(ff_to_e4m3x2_rz_scale_n1_ue8m0);
1113 PZO_CVT(ff_to_e4m3x2_rz_relu_scale_n1_ue8m0);
1114 PZO_CVT(ff_to_e5m2x2_rn_scale_n1_ue8m0);
1115 PZO_CVT(ff_to_e5m2x2_rn_relu_scale_n1_ue8m0);
1116 PZO_CVT(ff_to_e5m2x2_rz_scale_n1_ue8m0);
1117 PZO_CVT(ff_to_e5m2x2_rz_relu_scale_n1_ue8m0);
1118 PZO_CVT(f16x2_to_e4m3x2_rn_scale_n1_ue8m0);
1119 PZO_CVT(f16x2_to_e4m3x2_rn_relu_scale_n1_ue8m0);
1120 PZO_CVT(f16x2_to_e4m3x2_rz_scale_n1_ue8m0);
1121 PZO_CVT(f16x2_to_e4m3x2_rz_relu_scale_n1_ue8m0);
1122 PZO_CVT(f16x2_to_e5m2x2_rn_scale_n1_ue8m0);
1123 PZO_CVT(f16x2_to_e5m2x2_rn_relu_scale_n1_ue8m0);
1124 PZO_CVT(f16x2_to_e5m2x2_rz_scale_n1_ue8m0);
1125 PZO_CVT(f16x2_to_e5m2x2_rz_relu_scale_n1_ue8m0);
1126 PZO_CVT(bf16x2_to_e4m3x2_rn_satfinite_scale_n1_ue8m0);
1127 PZO_CVT(bf16x2_to_e4m3x2_rn_relu_satfinite_scale_n1_ue8m0);
1128 PZO_CVT(bf16x2_to_e4m3x2_rz_satfinite_scale_n1_ue8m0);
1129 PZO_CVT(bf16x2_to_e4m3x2_rz_relu_satfinite_scale_n1_ue8m0);
1130 PZO_CVT(bf16x2_to_e5m2x2_rn_satfinite_scale_n1_ue8m0);
1131 PZO_CVT(bf16x2_to_e5m2x2_rn_relu_satfinite_scale_n1_ue8m0);
1132 PZO_CVT(bf16x2_to_e5m2x2_rz_satfinite_scale_n1_ue8m0);
1133 PZO_CVT(bf16x2_to_e5m2x2_rz_relu_satfinite_scale_n1_ue8m0);
1135 PZO_CVT(ff_to_e2m3x2_rn_satfinite);
1136 PZO_CVT(ff_to_e2m3x2_rn_relu_satfinite);
1137 PZO_CVT(ff_to_e2m3x2_rz_satfinite);
1138 PZO_CVT(ff_to_e2m3x2_rz_relu_satfinite);
1139 PZO_CVT(ff_to_e3m2x2_rn_satfinite);
1140 PZO_CVT(ff_to_e3m2x2_rn_relu_satfinite);
1141 PZO_CVT(ff_to_e3m2x2_rz_satfinite);
1142 PZO_CVT(ff_to_e3m2x2_rz_relu_satfinite);
1143 PZO_CVT(f16x2_to_e2m3x2_rn_satfinite);
1144 PZO_CVT(f16x2_to_e2m3x2_rn_relu_satfinite);
1145 PZO_CVT(f16x2_to_e2m3x2_rz_satfinite);
1146 PZO_CVT(f16x2_to_e2m3x2_rz_relu_satfinite);
1147 PZO_CVT(f16x2_to_e3m2x2_rn_satfinite);
1148 PZO_CVT(f16x2_to_e3m2x2_rn_relu_satfinite);
1149 PZO_CVT(f16x2_to_e3m2x2_rz_satfinite);
1150 PZO_CVT(f16x2_to_e3m2x2_rz_relu_satfinite);
1151 PZO_CVT(bf16x2_to_e2m3x2_rn_satfinite);
1152 PZO_CVT(bf16x2_to_e2m3x2_rn_relu_satfinite);
1153 PZO_CVT(bf16x2_to_e2m3x2_rz_satfinite);
1154 PZO_CVT(bf16x2_to_e2m3x2_rz_relu_satfinite);
1155 PZO_CVT(bf16x2_to_e3m2x2_rn_satfinite);
1156 PZO_CVT(bf16x2_to_e3m2x2_rn_relu_satfinite);
1157 PZO_CVT(bf16x2_to_e3m2x2_rz_satfinite);
1158 PZO_CVT(bf16x2_to_e3m2x2_rz_relu_satfinite);
1160 PZO_CVT(ff_to_e2m3x2_rn_satfinite_scale_n1_ue8m0);
1161 PZO_CVT(ff_to_e2m3x2_rn_relu_satfinite_scale_n1_ue8m0);
1162 PZO_CVT(ff_to_e2m3x2_rz_satfinite_scale_n1_ue8m0);
1163 PZO_CVT(ff_to_e2m3x2_rz_relu_satfinite_scale_n1_ue8m0);
1164 PZO_CVT(ff_to_e3m2x2_rn_satfinite_scale_n1_ue8m0);
1165 PZO_CVT(ff_to_e3m2x2_rn_relu_satfinite_scale_n1_ue8m0);
1166 PZO_CVT(ff_to_e3m2x2_rz_satfinite_scale_n1_ue8m0);
1167 PZO_CVT(ff_to_e3m2x2_rz_relu_satfinite_scale_n1_ue8m0);
1168 PZO_CVT(f16x2_to_e2m3x2_rn_satfinite_scale_n1_ue8m0);
1169 PZO_CVT(f16x2_to_e2m3x2_rn_relu_satfinite_scale_n1_ue8m0);
1170 PZO_CVT(f16x2_to_e2m3x2_rz_satfinite_scale_n1_ue8m0);
1171 PZO_CVT(f16x2_to_e2m3x2_rz_relu_satfinite_scale_n1_ue8m0);
1172 PZO_CVT(f16x2_to_e3m2x2_rn_satfinite_scale_n1_ue8m0);
1173 PZO_CVT(f16x2_to_e3m2x2_rn_relu_satfinite_scale_n1_ue8m0);
1174 PZO_CVT(f16x2_to_e3m2x2_rz_satfinite_scale_n1_ue8m0);
1175 PZO_CVT(f16x2_to_e3m2x2_rz_relu_satfinite_scale_n1_ue8m0);
1176 PZO_CVT(bf16x2_to_e2m3x2_rn_satfinite_scale_n1_ue8m0);
1177 PZO_CVT(bf16x2_to_e2m3x2_rn_relu_satfinite_scale_n1_ue8m0);
1178 PZO_CVT(bf16x2_to_e2m3x2_rz_satfinite_scale_n1_ue8m0);
1179 PZO_CVT(bf16x2_to_e2m3x2_rz_relu_satfinite_scale_n1_ue8m0);
1180 PZO_CVT(bf16x2_to_e3m2x2_rn_satfinite_scale_n1_ue8m0);
1181 PZO_CVT(bf16x2_to_e3m2x2_rn_relu_satfinite_scale_n1_ue8m0);
1182 PZO_CVT(bf16x2_to_e3m2x2_rz_satfinite_scale_n1_ue8m0);
1183 PZO_CVT(bf16x2_to_e3m2x2_rz_relu_satfinite_scale_n1_ue8m0);
1185 PZO_CVT(ff_to_e2m1x2_rn_satfinite);
1186 PZO_CVT(ff_to_e2m1x2_rn_relu_satfinite);
1187 PZO_CVT(ff_to_e2m1x2_rz_satfinite);
1188 PZO_CVT(ff_to_e2m1x2_rz_relu_satfinite);
1189 PZO_CVT(f16x2_to_e2m1x2_rn_satfinite);
1190 PZO_CVT(f16x2_to_e2m1x2_rn_relu_satfinite);
1191 PZO_CVT(f16x2_to_e2m1x2_rz_satfinite);
1192 PZO_CVT(f16x2_to_e2m1x2_rz_relu_satfinite);
1193 PZO_CVT(bf16x2_to_e2m1x2_rn_satfinite);
1194 PZO_CVT(bf16x2_to_e2m1x2_rn_relu_satfinite);
1195 PZO_CVT(bf16x2_to_e2m1x2_rz_satfinite);
1196 PZO_CVT(bf16x2_to_e2m1x2_rz_relu_satfinite);
1198 PZO_CVT(ff_to_e2m1x2_rn_satfinite_scale_n1_ue8m0);
1199 PZO_CVT(ff_to_e2m1x2_rn_relu_satfinite_scale_n1_ue8m0);
1200 PZO_CVT(ff_to_e2m1x2_rz_satfinite_scale_n1_ue8m0);
1201 PZO_CVT(ff_to_e2m1x2_rz_relu_satfinite_scale_n1_ue8m0);
1202 PZO_CVT(f16x2_to_e2m1x2_rn_satfinite_scale_n1_ue8m0);
1203 PZO_CVT(f16x2_to_e2m1x2_rn_relu_satfinite_scale_n1_ue8m0);
1204 PZO_CVT(f16x2_to_e2m1x2_rz_satfinite_scale_n1_ue8m0);
1205 PZO_CVT(f16x2_to_e2m1x2_rz_relu_satfinite_scale_n1_ue8m0);
1206 PZO_CVT(bf16x2_to_e2m1x2_rn_satfinite_scale_n1_ue8m0);
1207 PZO_CVT(bf16x2_to_e2m1x2_rn_relu_satfinite_scale_n1_ue8m0);
1208 PZO_CVT(bf16x2_to_e2m1x2_rz_satfinite_scale_n1_ue8m0);
1209 PZO_CVT(bf16x2_to_e2m1x2_rz_relu_satfinite_scale_n1_ue8m0);
1213 case NVPTX::BI__nvvm_fma_rn_f16:
1214 case NVPTX::BI__nvvm_fma_rn_f16x2:
1215 case NVPTX::BI__nvvm_fma_rn_bf16:
1216 case NVPTX::BI__nvvm_fma_rn_bf16x2:
1217 case NVPTX::BI__nvvm_fma_rn_f:
1218 case NVPTX::BI__nvvm_fma_rn_d:
1219 return MakeFPArith(Intrinsic::nvvm_fma, APFloat::rmNearestTiesToEven,
1220 BuiltinID, E, *
this);
1221 case NVPTX::BI__nvvm_fma_rz_f:
1222 case NVPTX::BI__nvvm_fma_rz_d:
1223 return MakeFPArith(Intrinsic::nvvm_fma, APFloat::rmTowardZero, BuiltinID, E,
1225 case NVPTX::BI__nvvm_fma_rm_f:
1226 case NVPTX::BI__nvvm_fma_rm_d:
1227 return MakeFPArith(Intrinsic::nvvm_fma, APFloat::rmTowardNegative,
1228 BuiltinID, E, *
this);
1229 case NVPTX::BI__nvvm_fma_rp_f:
1230 case NVPTX::BI__nvvm_fma_rp_d:
1231 return MakeFPArith(Intrinsic::nvvm_fma, APFloat::rmTowardPositive,
1232 BuiltinID, E, *
this);
1233 case NVPTX::BI__nvvm_fma_rn_ftz_f16:
1234 case NVPTX::BI__nvvm_fma_rn_ftz_f16x2:
1235 case NVPTX::BI__nvvm_fma_rn_ftz_f:
1236 return MakeFPArith(Intrinsic::nvvm_fma_ftz, APFloat::rmNearestTiesToEven,
1237 BuiltinID, E, *
this);
1238 case NVPTX::BI__nvvm_fma_rz_ftz_f:
1239 return MakeFPArith(Intrinsic::nvvm_fma_ftz, APFloat::rmTowardZero,
1240 BuiltinID, E, *
this);
1241 case NVPTX::BI__nvvm_fma_rm_ftz_f:
1242 return MakeFPArith(Intrinsic::nvvm_fma_ftz, APFloat::rmTowardNegative,
1243 BuiltinID, E, *
this);
1244 case NVPTX::BI__nvvm_fma_rp_ftz_f:
1245 return MakeFPArith(Intrinsic::nvvm_fma_ftz, APFloat::rmTowardPositive,
1246 BuiltinID, E, *
this);
1247 case NVPTX::BI__nvvm_fma_rn_sat_f16:
1248 case NVPTX::BI__nvvm_fma_rn_sat_f16x2:
1249 case NVPTX::BI__nvvm_fma_rn_sat_f:
1250 return MakeFPArith(Intrinsic::nvvm_fma_sat, APFloat::rmNearestTiesToEven,
1251 BuiltinID, E, *
this);
1252 case NVPTX::BI__nvvm_fma_rz_sat_f:
1253 return MakeFPArith(Intrinsic::nvvm_fma_sat, APFloat::rmTowardZero,
1254 BuiltinID, E, *
this);
1255 case NVPTX::BI__nvvm_fma_rm_sat_f:
1256 return MakeFPArith(Intrinsic::nvvm_fma_sat, APFloat::rmTowardNegative,
1257 BuiltinID, E, *
this);
1258 case NVPTX::BI__nvvm_fma_rp_sat_f:
1259 return MakeFPArith(Intrinsic::nvvm_fma_sat, APFloat::rmTowardPositive,
1260 BuiltinID, E, *
this);
1261 case NVPTX::BI__nvvm_fma_rn_ftz_sat_f16:
1262 case NVPTX::BI__nvvm_fma_rn_ftz_sat_f16x2:
1263 case NVPTX::BI__nvvm_fma_rn_ftz_sat_f:
1264 return MakeFPArith(Intrinsic::nvvm_fma_ftz_sat,
1265 APFloat::rmNearestTiesToEven, BuiltinID, E, *
this);
1266 case NVPTX::BI__nvvm_fma_rz_ftz_sat_f:
1267 return MakeFPArith(Intrinsic::nvvm_fma_ftz_sat, APFloat::rmTowardZero,
1268 BuiltinID, E, *
this);
1269 case NVPTX::BI__nvvm_fma_rm_ftz_sat_f:
1270 return MakeFPArith(Intrinsic::nvvm_fma_ftz_sat, APFloat::rmTowardNegative,
1271 BuiltinID, E, *
this);
1272 case NVPTX::BI__nvvm_fma_rp_ftz_sat_f:
1273 return MakeFPArith(Intrinsic::nvvm_fma_ftz_sat, APFloat::rmTowardPositive,
1274 BuiltinID, E, *
this);
1275 case NVPTX::BI__nvvm_fma_rn_relu_f16:
1276 case NVPTX::BI__nvvm_fma_rn_relu_f16x2:
1277 case NVPTX::BI__nvvm_fma_rn_relu_bf16:
1278 case NVPTX::BI__nvvm_fma_rn_relu_bf16x2:
1279 return MakeFPArith(Intrinsic::nvvm_fma_relu, APFloat::rmNearestTiesToEven,
1280 BuiltinID, E, *
this);
1281 case NVPTX::BI__nvvm_fma_rn_ftz_relu_f16:
1282 case NVPTX::BI__nvvm_fma_rn_ftz_relu_f16x2:
1283 return MakeFPArith(Intrinsic::nvvm_fma_ftz_relu,
1284 APFloat::rmNearestTiesToEven, BuiltinID, E, *
this);
1285 case NVPTX::BI__nvvm_fma_rn_oob_f16:
1286 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob,
Builder.getHalfTy(), E,
1288 case NVPTX::BI__nvvm_fma_rn_oob_f16x2:
1289 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob,
1290 llvm::FixedVectorType::get(
Builder.getHalfTy(), 2), E,
1292 case NVPTX::BI__nvvm_fma_rn_oob_bf16:
1293 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob,
Builder.getBFloatTy(), E,
1295 case NVPTX::BI__nvvm_fma_rn_oob_bf16x2:
1296 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob,
1297 llvm::FixedVectorType::get(
Builder.getBFloatTy(), 2), E,
1299 case NVPTX::BI__nvvm_fma_rn_oob_relu_f16:
1300 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob_relu,
Builder.getHalfTy(), E,
1302 case NVPTX::BI__nvvm_fma_rn_oob_relu_f16x2:
1303 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob_relu,
1304 llvm::FixedVectorType::get(
Builder.getHalfTy(), 2), E,
1306 case NVPTX::BI__nvvm_fma_rn_oob_relu_bf16:
1307 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob_relu,
Builder.getBFloatTy(), E,
1309 case NVPTX::BI__nvvm_fma_rn_oob_relu_bf16x2:
1310 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob_relu,
1311 llvm::FixedVectorType::get(
Builder.getBFloatTy(), 2), E,
1313 case NVPTX::BI__nvvm_fmax_f16:
1314 return MakeHalfType(Intrinsic::nvvm_fmax_f16, BuiltinID, E, *
this);
1315 case NVPTX::BI__nvvm_fmax_f16x2:
1316 return MakeHalfType(Intrinsic::nvvm_fmax_f16x2, BuiltinID, E, *
this);
1317 case NVPTX::BI__nvvm_fmax_ftz_f16:
1318 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_f16, BuiltinID, E, *
this);
1319 case NVPTX::BI__nvvm_fmax_ftz_f16x2:
1320 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_f16x2, BuiltinID, E, *
this);
1321 case NVPTX::BI__nvvm_fmax_ftz_nan_f16:
1322 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_nan_f16, BuiltinID, E, *
this);
1323 case NVPTX::BI__nvvm_fmax_ftz_nan_f16x2:
1324 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_nan_f16x2, BuiltinID, E,
1326 case NVPTX::BI__nvvm_fmax_ftz_nan_xorsign_abs_f16:
1327 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_nan_xorsign_abs_f16, BuiltinID,
1329 case NVPTX::BI__nvvm_fmax_ftz_nan_xorsign_abs_f16x2:
1330 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_nan_xorsign_abs_f16x2,
1331 BuiltinID, E, *
this);
1332 case NVPTX::BI__nvvm_fmax_ftz_xorsign_abs_f16:
1333 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_xorsign_abs_f16, BuiltinID, E,
1335 case NVPTX::BI__nvvm_fmax_ftz_xorsign_abs_f16x2:
1336 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_xorsign_abs_f16x2, BuiltinID,
1338 case NVPTX::BI__nvvm_fmax_nan_f16:
1339 return MakeHalfType(Intrinsic::nvvm_fmax_nan_f16, BuiltinID, E, *
this);
1340 case NVPTX::BI__nvvm_fmax_nan_f16x2:
1341 return MakeHalfType(Intrinsic::nvvm_fmax_nan_f16x2, BuiltinID, E, *
this);
1342 case NVPTX::BI__nvvm_fmax_nan_xorsign_abs_f16:
1343 return MakeHalfType(Intrinsic::nvvm_fmax_nan_xorsign_abs_f16, BuiltinID, E,
1345 case NVPTX::BI__nvvm_fmax_nan_xorsign_abs_f16x2:
1346 return MakeHalfType(Intrinsic::nvvm_fmax_nan_xorsign_abs_f16x2, BuiltinID,
1348 case NVPTX::BI__nvvm_fmax_xorsign_abs_f16:
1349 return MakeHalfType(Intrinsic::nvvm_fmax_xorsign_abs_f16, BuiltinID, E,
1351 case NVPTX::BI__nvvm_fmax_xorsign_abs_f16x2:
1352 return MakeHalfType(Intrinsic::nvvm_fmax_xorsign_abs_f16x2, BuiltinID, E,
1354 case NVPTX::BI__nvvm_fmin_f16:
1355 return MakeHalfType(Intrinsic::nvvm_fmin_f16, BuiltinID, E, *
this);
1356 case NVPTX::BI__nvvm_fmin_f16x2:
1357 return MakeHalfType(Intrinsic::nvvm_fmin_f16x2, BuiltinID, E, *
this);
1358 case NVPTX::BI__nvvm_fmin_ftz_f16:
1359 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_f16, BuiltinID, E, *
this);
1360 case NVPTX::BI__nvvm_fmin_ftz_f16x2:
1361 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_f16x2, BuiltinID, E, *
this);
1362 case NVPTX::BI__nvvm_fmin_ftz_nan_f16:
1363 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_nan_f16, BuiltinID, E, *
this);
1364 case NVPTX::BI__nvvm_fmin_ftz_nan_f16x2:
1365 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_nan_f16x2, BuiltinID, E,
1367 case NVPTX::BI__nvvm_fmin_ftz_nan_xorsign_abs_f16:
1368 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_nan_xorsign_abs_f16, BuiltinID,
1370 case NVPTX::BI__nvvm_fmin_ftz_nan_xorsign_abs_f16x2:
1371 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_nan_xorsign_abs_f16x2,
1372 BuiltinID, E, *
this);
1373 case NVPTX::BI__nvvm_fmin_ftz_xorsign_abs_f16:
1374 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_xorsign_abs_f16, BuiltinID, E,
1376 case NVPTX::BI__nvvm_fmin_ftz_xorsign_abs_f16x2:
1377 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_xorsign_abs_f16x2, BuiltinID,
1379 case NVPTX::BI__nvvm_fmin_nan_f16:
1380 return MakeHalfType(Intrinsic::nvvm_fmin_nan_f16, BuiltinID, E, *
this);
1381 case NVPTX::BI__nvvm_fmin_nan_f16x2:
1382 return MakeHalfType(Intrinsic::nvvm_fmin_nan_f16x2, BuiltinID, E, *
this);
1383 case NVPTX::BI__nvvm_fmin_nan_xorsign_abs_f16:
1384 return MakeHalfType(Intrinsic::nvvm_fmin_nan_xorsign_abs_f16, BuiltinID, E,
1386 case NVPTX::BI__nvvm_fmin_nan_xorsign_abs_f16x2:
1387 return MakeHalfType(Intrinsic::nvvm_fmin_nan_xorsign_abs_f16x2, BuiltinID,
1389 case NVPTX::BI__nvvm_fmin_xorsign_abs_f16:
1390 return MakeHalfType(Intrinsic::nvvm_fmin_xorsign_abs_f16, BuiltinID, E,
1392 case NVPTX::BI__nvvm_fmin_xorsign_abs_f16x2:
1393 return MakeHalfType(Intrinsic::nvvm_fmin_xorsign_abs_f16x2, BuiltinID, E,
1395 case NVPTX::BI__nvvm_fabs_f:
1396 case NVPTX::BI__nvvm_abs_bf16:
1397 case NVPTX::BI__nvvm_abs_bf16x2:
1398 case NVPTX::BI__nvvm_fabs_f16:
1399 case NVPTX::BI__nvvm_fabs_f16x2:
1400 return Builder.CreateUnaryIntrinsic(Intrinsic::nvvm_fabs,
1402 case NVPTX::BI__nvvm_fabs_ftz_f:
1403 case NVPTX::BI__nvvm_fabs_ftz_f16:
1404 case NVPTX::BI__nvvm_fabs_ftz_f16x2:
1405 return Builder.CreateUnaryIntrinsic(Intrinsic::nvvm_fabs_ftz,
1407 case NVPTX::BI__nvvm_fabs_d:
1409 case NVPTX::BI__nvvm_ex2_approx_d:
1410 case NVPTX::BI__nvvm_ex2_approx_f:
1411 return Builder.CreateUnaryIntrinsic(Intrinsic::nvvm_ex2_approx,
1413 case NVPTX::BI__nvvm_ex2_approx_ftz_f:
1414 return Builder.CreateUnaryIntrinsic(Intrinsic::nvvm_ex2_approx_ftz,
1416 case NVPTX::BI__nvvm_add_rn_f:
1417 case NVPTX::BI__nvvm_add_rn_d:
1418 return MakeFPArith(Intrinsic::nvvm_fadd, APFloat::rmNearestTiesToEven,
1419 BuiltinID, E, *
this);
1420 case NVPTX::BI__nvvm_add_rz_f:
1421 case NVPTX::BI__nvvm_add_rz_d:
1422 return MakeFPArith(Intrinsic::nvvm_fadd, APFloat::rmTowardZero, BuiltinID,
1424 case NVPTX::BI__nvvm_add_rm_f:
1425 case NVPTX::BI__nvvm_add_rm_d:
1426 return MakeFPArith(Intrinsic::nvvm_fadd, APFloat::rmTowardNegative,
1427 BuiltinID, E, *
this);
1428 case NVPTX::BI__nvvm_add_rp_f:
1429 case NVPTX::BI__nvvm_add_rp_d:
1430 return MakeFPArith(Intrinsic::nvvm_fadd, APFloat::rmTowardPositive,
1431 BuiltinID, E, *
this);
1432 case NVPTX::BI__nvvm_add_rn_ftz_f:
1433 return MakeFPArith(Intrinsic::nvvm_fadd_ftz, APFloat::rmNearestTiesToEven,
1434 BuiltinID, E, *
this);
1435 case NVPTX::BI__nvvm_add_rz_ftz_f:
1436 return MakeFPArith(Intrinsic::nvvm_fadd_ftz, APFloat::rmTowardZero,
1437 BuiltinID, E, *
this);
1438 case NVPTX::BI__nvvm_add_rm_ftz_f:
1439 return MakeFPArith(Intrinsic::nvvm_fadd_ftz, APFloat::rmTowardNegative,
1440 BuiltinID, E, *
this);
1441 case NVPTX::BI__nvvm_add_rp_ftz_f:
1442 return MakeFPArith(Intrinsic::nvvm_fadd_ftz, APFloat::rmTowardPositive,
1443 BuiltinID, E, *
this);
1444 case NVPTX::BI__nvvm_add_rn_sat_f:
1445 case NVPTX::BI__nvvm_add_rn_sat_f16:
1446 case NVPTX::BI__nvvm_add_rn_sat_v2f16:
1447 return MakeFPArith(Intrinsic::nvvm_fadd_sat, APFloat::rmNearestTiesToEven,
1448 BuiltinID, E, *
this);
1449 case NVPTX::BI__nvvm_add_rz_sat_f:
1450 return MakeFPArith(Intrinsic::nvvm_fadd_sat, APFloat::rmTowardZero,
1451 BuiltinID, E, *
this);
1452 case NVPTX::BI__nvvm_add_rm_sat_f:
1453 return MakeFPArith(Intrinsic::nvvm_fadd_sat, APFloat::rmTowardNegative,
1454 BuiltinID, E, *
this);
1455 case NVPTX::BI__nvvm_add_rp_sat_f:
1456 return MakeFPArith(Intrinsic::nvvm_fadd_sat, APFloat::rmTowardPositive,
1457 BuiltinID, E, *
this);
1458 case NVPTX::BI__nvvm_add_rn_ftz_sat_f:
1459 case NVPTX::BI__nvvm_add_rn_ftz_sat_f16:
1460 case NVPTX::BI__nvvm_add_rn_ftz_sat_v2f16:
1461 return MakeFPArith(Intrinsic::nvvm_fadd_ftz_sat,
1462 APFloat::rmNearestTiesToEven, BuiltinID, E, *
this);
1463 case NVPTX::BI__nvvm_add_rz_ftz_sat_f:
1464 return MakeFPArith(Intrinsic::nvvm_fadd_ftz_sat, APFloat::rmTowardZero,
1465 BuiltinID, E, *
this);
1466 case NVPTX::BI__nvvm_add_rm_ftz_sat_f:
1467 return MakeFPArith(Intrinsic::nvvm_fadd_ftz_sat, APFloat::rmTowardNegative,
1468 BuiltinID, E, *
this);
1469 case NVPTX::BI__nvvm_add_rp_ftz_sat_f:
1470 return MakeFPArith(Intrinsic::nvvm_fadd_ftz_sat, APFloat::rmTowardPositive,
1471 BuiltinID, E, *
this);
1472 case NVPTX::BI__nvvm_mul_rn_f:
1473 case NVPTX::BI__nvvm_mul_rn_d:
1474 return MakeFPArith(Intrinsic::nvvm_fmul, APFloat::rmNearestTiesToEven,
1475 BuiltinID, E, *
this);
1476 case NVPTX::BI__nvvm_mul_rz_f:
1477 case NVPTX::BI__nvvm_mul_rz_d:
1478 return MakeFPArith(Intrinsic::nvvm_fmul, APFloat::rmTowardZero, BuiltinID,
1480 case NVPTX::BI__nvvm_mul_rm_f:
1481 case NVPTX::BI__nvvm_mul_rm_d:
1482 return MakeFPArith(Intrinsic::nvvm_fmul, APFloat::rmTowardNegative,
1483 BuiltinID, E, *
this);
1484 case NVPTX::BI__nvvm_mul_rp_f:
1485 case NVPTX::BI__nvvm_mul_rp_d:
1486 return MakeFPArith(Intrinsic::nvvm_fmul, APFloat::rmTowardPositive,
1487 BuiltinID, E, *
this);
1488 case NVPTX::BI__nvvm_mul_rn_ftz_f:
1489 return MakeFPArith(Intrinsic::nvvm_fmul_ftz, APFloat::rmNearestTiesToEven,
1490 BuiltinID, E, *
this);
1491 case NVPTX::BI__nvvm_mul_rz_ftz_f:
1492 return MakeFPArith(Intrinsic::nvvm_fmul_ftz, APFloat::rmTowardZero,
1493 BuiltinID, E, *
this);
1494 case NVPTX::BI__nvvm_mul_rm_ftz_f:
1495 return MakeFPArith(Intrinsic::nvvm_fmul_ftz, APFloat::rmTowardNegative,
1496 BuiltinID, E, *
this);
1497 case NVPTX::BI__nvvm_mul_rp_ftz_f:
1498 return MakeFPArith(Intrinsic::nvvm_fmul_ftz, APFloat::rmTowardPositive,
1499 BuiltinID, E, *
this);
1500 case NVPTX::BI__nvvm_mul_rn_sat_f16:
1501 case NVPTX::BI__nvvm_mul_rn_sat_v2f16:
1502 return MakeFPArith(Intrinsic::nvvm_fmul_sat, APFloat::rmNearestTiesToEven,
1503 BuiltinID, E, *
this);
1504 case NVPTX::BI__nvvm_mul_rn_ftz_sat_f16:
1505 case NVPTX::BI__nvvm_mul_rn_ftz_sat_v2f16:
1506 return MakeFPArith(Intrinsic::nvvm_fmul_ftz_sat,
1507 APFloat::rmNearestTiesToEven, BuiltinID, E, *
this);
1508 case NVPTX::BI__nvvm_ldg_h:
1509 case NVPTX::BI__nvvm_ldg_h2:
1510 return MakeLdg(*
this, E);
1511 case NVPTX::BI__nvvm_ldu_h:
1512 case NVPTX::BI__nvvm_ldu_h2:
1513 return MakeLdu(Intrinsic::nvvm_ldu_global_f, *
this, E);
1514 case NVPTX::BI__nvvm_cp_async_ca_shared_global_4:
1515 return MakeCpAsync(Intrinsic::nvvm_cp_async_ca_shared_global_4,
1516 Intrinsic::nvvm_cp_async_ca_shared_global_4_s, *
this, E,
1518 case NVPTX::BI__nvvm_cp_async_ca_shared_global_8:
1519 return MakeCpAsync(Intrinsic::nvvm_cp_async_ca_shared_global_8,
1520 Intrinsic::nvvm_cp_async_ca_shared_global_8_s, *
this, E,
1522 case NVPTX::BI__nvvm_cp_async_ca_shared_global_16:
1523 return MakeCpAsync(Intrinsic::nvvm_cp_async_ca_shared_global_16,
1524 Intrinsic::nvvm_cp_async_ca_shared_global_16_s, *
this, E,
1526 case NVPTX::BI__nvvm_cp_async_cg_shared_global_16:
1527 return MakeCpAsync(Intrinsic::nvvm_cp_async_cg_shared_global_16,
1528 Intrinsic::nvvm_cp_async_cg_shared_global_16_s, *
this, E,
1530 case NVPTX::BI__nvvm_read_ptx_sreg_clusterid_x:
1532 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_clusterid_x));
1533 case NVPTX::BI__nvvm_read_ptx_sreg_clusterid_y:
1535 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_clusterid_y));
1536 case NVPTX::BI__nvvm_read_ptx_sreg_clusterid_z:
1538 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_clusterid_z));
1539 case NVPTX::BI__nvvm_read_ptx_sreg_clusterid_w:
1541 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_clusterid_w));
1542 case NVPTX::BI__nvvm_read_ptx_sreg_nclusterid_x:
1544 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_nclusterid_x));
1545 case NVPTX::BI__nvvm_read_ptx_sreg_nclusterid_y:
1547 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_nclusterid_y));
1548 case NVPTX::BI__nvvm_read_ptx_sreg_nclusterid_z:
1550 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_nclusterid_z));
1551 case NVPTX::BI__nvvm_read_ptx_sreg_nclusterid_w:
1553 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_nclusterid_w));
1554 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_ctaid_x:
1556 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_ctaid_x));
1557 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_ctaid_y:
1559 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_ctaid_y));
1560 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_ctaid_z:
1562 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_ctaid_z));
1563 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_ctaid_w:
1565 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_ctaid_w));
1566 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_nctaid_x:
1568 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_nctaid_x));
1569 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_nctaid_y:
1571 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_nctaid_y));
1572 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_nctaid_z:
1574 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_nctaid_z));
1575 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_nctaid_w:
1577 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_nctaid_w));
1578 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_ctarank:
1580 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_ctarank));
1581 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_nctarank:
1583 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_nctarank));
1584 case NVPTX::BI__nvvm_is_explicit_cluster:
1586 CGM.getIntrinsic(Intrinsic::nvvm_is_explicit_cluster));
1587 case NVPTX::BI__nvvm_isspacep_shared_cluster:
1589 CGM.getIntrinsic(Intrinsic::nvvm_isspacep_shared_cluster),
1591 case NVPTX::BI__nvvm_mapa:
1593 CGM.getIntrinsic(Intrinsic::nvvm_mapa),
1594 {EmitScalarExpr(E->getArg(0)), EmitScalarExpr(E->getArg(1))});
1595 case NVPTX::BI__nvvm_mapa_shared_cluster:
1597 CGM.getIntrinsic(Intrinsic::nvvm_mapa_shared_cluster),
1598 {EmitScalarExpr(E->getArg(0)), EmitScalarExpr(E->getArg(1))});
1599 case NVPTX::BI__nvvm_getctarank:
1601 CGM.getIntrinsic(Intrinsic::nvvm_getctarank),
1603 case NVPTX::BI__nvvm_getctarank_shared_cluster:
1605 CGM.getIntrinsic(Intrinsic::nvvm_getctarank_shared_cluster),
1607 case NVPTX::BI__nvvm_barrier_cluster_arrive:
1609 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cluster_arrive));
1610 case NVPTX::BI__nvvm_barrier_cluster_arrive_relaxed:
1612 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cluster_arrive_relaxed));
1613 case NVPTX::BI__nvvm_barrier_cluster_wait:
1615 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cluster_wait));
1616 case NVPTX::BI__nvvm_fence_sc_cluster:
1618 CGM.getIntrinsic(Intrinsic::nvvm_fence_sc_cluster));
1619 case NVPTX::BI__nvvm_bar_sync:
1621 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cta_sync_aligned_all),
1623 case NVPTX::BI__syncthreads:
1625 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cta_sync_aligned_all),
1627 case NVPTX::BI__nvvm_barrier_sync:
1629 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cta_sync_all),
1631 case NVPTX::BI__nvvm_barrier_sync_cnt:
1633 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cta_sync_count),
1634 {EmitScalarExpr(E->getArg(0)), EmitScalarExpr(E->getArg(1))});
1635 case NVPTX::BI__nvvm_bar0_and:
1638 Intrinsic::nvvm_barrier_cta_red_and_aligned_all, {},
1639 {Builder.getInt32(0),
1640 Builder.CreateICmpNE(EmitScalarExpr(E->getArg(0)),
1641 Builder.getInt32(0))}),
1643 case NVPTX::BI__nvvm_bar0_or:
1646 Intrinsic::nvvm_barrier_cta_red_or_aligned_all, {},
1647 {Builder.getInt32(0),
1648 Builder.CreateICmpNE(EmitScalarExpr(E->getArg(0)),
1649 Builder.getInt32(0))}),
1651 case NVPTX::BI__nvvm_bar0_popc:
1652 return Builder.CreateIntrinsic(
1653 Intrinsic::nvvm_barrier_cta_red_popc_aligned_all, {},
1656 case NVPTX::BI__nvvm_mbarrier_init:
1657 case NVPTX::BI__nvvm_mbarrier_init_shared: {
1661 return Builder.CreateIntrinsic(
1662 Intrinsic::nvvm_mbarrier_init, {Ptr->getType()},
1665 case NVPTX::BI__nvvm_idp2a_lo_s_s:
1666 return MakeIdp2a(Intrinsic::nvvm_idp2a_s_s,
false, E, *
this);
1667 case NVPTX::BI__nvvm_idp2a_lo_s_u:
1668 return MakeIdp2a(Intrinsic::nvvm_idp2a_s_u,
false, E, *
this);
1669 case NVPTX::BI__nvvm_idp2a_lo_u_s:
1670 return MakeIdp2a(Intrinsic::nvvm_idp2a_u_s,
false, E, *
this);
1671 case NVPTX::BI__nvvm_idp2a_lo_u_u:
1672 return MakeIdp2a(Intrinsic::nvvm_idp2a_u_u,
false, E, *
this);
1673 case NVPTX::BI__nvvm_idp2a_hi_s_s:
1674 return MakeIdp2a(Intrinsic::nvvm_idp2a_s_s,
true, E, *
this);
1675 case NVPTX::BI__nvvm_idp2a_hi_s_u:
1676 return MakeIdp2a(Intrinsic::nvvm_idp2a_s_u,
true, E, *
this);
1677 case NVPTX::BI__nvvm_idp2a_hi_u_s:
1678 return MakeIdp2a(Intrinsic::nvvm_idp2a_u_s,
true, E, *
this);
1679 case NVPTX::BI__nvvm_idp2a_hi_u_u:
1680 return MakeIdp2a(Intrinsic::nvvm_idp2a_u_u,
true, E, *
this);