465 case NVPTX::BI__nvvm_mulhi_i:
466 case NVPTX::BI__nvvm_mulhi_ui:
467 case NVPTX::BI__nvvm_mulhi_ll:
468 case NVPTX::BI__nvvm_mulhi_ull:
469 return Builder.CreateBinaryIntrinsic(
473 case NVPTX::BI__nvvm_atom_add_gen_i:
474 case NVPTX::BI__nvvm_atom_add_gen_l:
475 case NVPTX::BI__nvvm_atom_add_gen_ll:
477 AtomicOrdering::Monotonic);
479 case NVPTX::BI__nvvm_atom_sub_gen_i:
480 case NVPTX::BI__nvvm_atom_sub_gen_l:
481 case NVPTX::BI__nvvm_atom_sub_gen_ll:
483 AtomicOrdering::Monotonic);
485 case NVPTX::BI__nvvm_atom_and_gen_i:
486 case NVPTX::BI__nvvm_atom_and_gen_l:
487 case NVPTX::BI__nvvm_atom_and_gen_ll:
489 AtomicOrdering::Monotonic);
491 case NVPTX::BI__nvvm_atom_or_gen_i:
492 case NVPTX::BI__nvvm_atom_or_gen_l:
493 case NVPTX::BI__nvvm_atom_or_gen_ll:
495 AtomicOrdering::Monotonic);
497 case NVPTX::BI__nvvm_atom_xor_gen_i:
498 case NVPTX::BI__nvvm_atom_xor_gen_l:
499 case NVPTX::BI__nvvm_atom_xor_gen_ll:
501 AtomicOrdering::Monotonic);
503 case NVPTX::BI__nvvm_atom_xchg_gen_i:
504 case NVPTX::BI__nvvm_atom_xchg_gen_l:
505 case NVPTX::BI__nvvm_atom_xchg_gen_ll:
507 AtomicOrdering::Monotonic);
509 case NVPTX::BI__nvvm_atom_max_gen_i:
510 case NVPTX::BI__nvvm_atom_max_gen_l:
511 case NVPTX::BI__nvvm_atom_max_gen_ll:
513 AtomicOrdering::Monotonic);
515 case NVPTX::BI__nvvm_atom_max_gen_ui:
516 case NVPTX::BI__nvvm_atom_max_gen_ul:
517 case NVPTX::BI__nvvm_atom_max_gen_ull:
519 AtomicOrdering::Monotonic);
521 case NVPTX::BI__nvvm_atom_min_gen_i:
522 case NVPTX::BI__nvvm_atom_min_gen_l:
523 case NVPTX::BI__nvvm_atom_min_gen_ll:
525 AtomicOrdering::Monotonic);
527 case NVPTX::BI__nvvm_atom_min_gen_ui:
528 case NVPTX::BI__nvvm_atom_min_gen_ul:
529 case NVPTX::BI__nvvm_atom_min_gen_ull:
531 AtomicOrdering::Monotonic);
533 case NVPTX::BI__nvvm_atom_cas_gen_us:
534 case NVPTX::BI__nvvm_atom_cas_gen_i:
535 case NVPTX::BI__nvvm_atom_cas_gen_l:
536 case NVPTX::BI__nvvm_atom_cas_gen_ll:
540 AtomicOrdering::Monotonic,
541 AtomicOrdering::Monotonic);
543 case NVPTX::BI__nvvm_atom_add_gen_f:
544 case NVPTX::BI__nvvm_atom_add_gen_d: {
548 llvm::AtomicRMWInst *RMW =
Builder.CreateAtomicRMW(
549 llvm::AtomicRMWInst::FAdd, DestAddr, Val, AtomicOrdering::Monotonic);
559 case NVPTX::BI__nvvm_atom_inc_gen_ui:
561 AtomicOrdering::Monotonic);
563 case NVPTX::BI__nvvm_atom_dec_gen_ui:
565 AtomicOrdering::Monotonic);
567 case NVPTX::BI__nvvm_ldg_c:
568 case NVPTX::BI__nvvm_ldg_sc:
569 case NVPTX::BI__nvvm_ldg_c2:
570 case NVPTX::BI__nvvm_ldg_sc2:
571 case NVPTX::BI__nvvm_ldg_c4:
572 case NVPTX::BI__nvvm_ldg_sc4:
573 case NVPTX::BI__nvvm_ldg_s:
574 case NVPTX::BI__nvvm_ldg_s2:
575 case NVPTX::BI__nvvm_ldg_s4:
576 case NVPTX::BI__nvvm_ldg_i:
577 case NVPTX::BI__nvvm_ldg_i2:
578 case NVPTX::BI__nvvm_ldg_i4:
579 case NVPTX::BI__nvvm_ldg_l:
580 case NVPTX::BI__nvvm_ldg_l2:
581 case NVPTX::BI__nvvm_ldg_ll:
582 case NVPTX::BI__nvvm_ldg_ll2:
583 case NVPTX::BI__nvvm_ldg_uc:
584 case NVPTX::BI__nvvm_ldg_uc2:
585 case NVPTX::BI__nvvm_ldg_uc4:
586 case NVPTX::BI__nvvm_ldg_us:
587 case NVPTX::BI__nvvm_ldg_us2:
588 case NVPTX::BI__nvvm_ldg_us4:
589 case NVPTX::BI__nvvm_ldg_ui:
590 case NVPTX::BI__nvvm_ldg_ui2:
591 case NVPTX::BI__nvvm_ldg_ui4:
592 case NVPTX::BI__nvvm_ldg_ul:
593 case NVPTX::BI__nvvm_ldg_ul2:
594 case NVPTX::BI__nvvm_ldg_ull:
595 case NVPTX::BI__nvvm_ldg_ull2:
596 case NVPTX::BI__nvvm_ldg_f:
597 case NVPTX::BI__nvvm_ldg_f2:
598 case NVPTX::BI__nvvm_ldg_f4:
599 case NVPTX::BI__nvvm_ldg_d:
600 case NVPTX::BI__nvvm_ldg_d2:
604 return MakeLdg(*
this, E);
606 case NVPTX::BI__nvvm_ldu_c:
607 case NVPTX::BI__nvvm_ldu_sc:
608 case NVPTX::BI__nvvm_ldu_c2:
609 case NVPTX::BI__nvvm_ldu_sc2:
610 case NVPTX::BI__nvvm_ldu_c4:
611 case NVPTX::BI__nvvm_ldu_sc4:
612 case NVPTX::BI__nvvm_ldu_s:
613 case NVPTX::BI__nvvm_ldu_s2:
614 case NVPTX::BI__nvvm_ldu_s4:
615 case NVPTX::BI__nvvm_ldu_i:
616 case NVPTX::BI__nvvm_ldu_i2:
617 case NVPTX::BI__nvvm_ldu_i4:
618 case NVPTX::BI__nvvm_ldu_l:
619 case NVPTX::BI__nvvm_ldu_l2:
620 case NVPTX::BI__nvvm_ldu_ll:
621 case NVPTX::BI__nvvm_ldu_ll2:
622 case NVPTX::BI__nvvm_ldu_uc:
623 case NVPTX::BI__nvvm_ldu_uc2:
624 case NVPTX::BI__nvvm_ldu_uc4:
625 case NVPTX::BI__nvvm_ldu_us:
626 case NVPTX::BI__nvvm_ldu_us2:
627 case NVPTX::BI__nvvm_ldu_us4:
628 case NVPTX::BI__nvvm_ldu_ui:
629 case NVPTX::BI__nvvm_ldu_ui2:
630 case NVPTX::BI__nvvm_ldu_ui4:
631 case NVPTX::BI__nvvm_ldu_ul:
632 case NVPTX::BI__nvvm_ldu_ul2:
633 case NVPTX::BI__nvvm_ldu_ull:
634 case NVPTX::BI__nvvm_ldu_ull2:
635 return MakeLdu(Intrinsic::nvvm_ldu_global_i, *
this, E);
636 case NVPTX::BI__nvvm_ldu_f:
637 case NVPTX::BI__nvvm_ldu_f2:
638 case NVPTX::BI__nvvm_ldu_f4:
639 case NVPTX::BI__nvvm_ldu_d:
640 case NVPTX::BI__nvvm_ldu_d2:
641 return MakeLdu(Intrinsic::nvvm_ldu_global_f, *
this, E);
643 case NVPTX::BI__nvvm_atom_cta_add_gen_i:
644 case NVPTX::BI__nvvm_atom_cta_add_gen_l:
645 case NVPTX::BI__nvvm_atom_cta_add_gen_ll:
646 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Add,
647 llvm::AtomicScope::Workgroup);
648 case NVPTX::BI__nvvm_atom_sys_add_gen_i:
649 case NVPTX::BI__nvvm_atom_sys_add_gen_l:
650 case NVPTX::BI__nvvm_atom_sys_add_gen_ll:
651 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Add,
652 llvm::AtomicScope::System);
653 case NVPTX::BI__nvvm_atom_cta_add_gen_f:
654 case NVPTX::BI__nvvm_atom_cta_add_gen_d:
655 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::FAdd,
656 llvm::AtomicScope::Workgroup);
657 case NVPTX::BI__nvvm_atom_sys_add_gen_f:
658 case NVPTX::BI__nvvm_atom_sys_add_gen_d:
659 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::FAdd,
660 llvm::AtomicScope::System);
661 case NVPTX::BI__nvvm_atom_cta_xchg_gen_i:
662 case NVPTX::BI__nvvm_atom_cta_xchg_gen_l:
663 case NVPTX::BI__nvvm_atom_cta_xchg_gen_ll:
664 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Xchg,
665 llvm::AtomicScope::Workgroup);
666 case NVPTX::BI__nvvm_atom_sys_xchg_gen_i:
667 case NVPTX::BI__nvvm_atom_sys_xchg_gen_l:
668 case NVPTX::BI__nvvm_atom_sys_xchg_gen_ll:
669 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Xchg,
670 llvm::AtomicScope::System);
671 case NVPTX::BI__nvvm_atom_cta_max_gen_i:
672 case NVPTX::BI__nvvm_atom_cta_max_gen_l:
673 case NVPTX::BI__nvvm_atom_cta_max_gen_ll:
674 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Max,
675 llvm::AtomicScope::Workgroup);
676 case NVPTX::BI__nvvm_atom_cta_max_gen_ui:
677 case NVPTX::BI__nvvm_atom_cta_max_gen_ul:
678 case NVPTX::BI__nvvm_atom_cta_max_gen_ull:
679 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UMax,
680 llvm::AtomicScope::Workgroup);
681 case NVPTX::BI__nvvm_atom_sys_max_gen_i:
682 case NVPTX::BI__nvvm_atom_sys_max_gen_l:
683 case NVPTX::BI__nvvm_atom_sys_max_gen_ll:
684 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Max,
685 llvm::AtomicScope::System);
686 case NVPTX::BI__nvvm_atom_sys_max_gen_ui:
687 case NVPTX::BI__nvvm_atom_sys_max_gen_ul:
688 case NVPTX::BI__nvvm_atom_sys_max_gen_ull:
689 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UMax,
690 llvm::AtomicScope::System);
691 case NVPTX::BI__nvvm_atom_cta_min_gen_i:
692 case NVPTX::BI__nvvm_atom_cta_min_gen_l:
693 case NVPTX::BI__nvvm_atom_cta_min_gen_ll:
694 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Min,
695 llvm::AtomicScope::Workgroup);
696 case NVPTX::BI__nvvm_atom_cta_min_gen_ui:
697 case NVPTX::BI__nvvm_atom_cta_min_gen_ul:
698 case NVPTX::BI__nvvm_atom_cta_min_gen_ull:
699 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UMin,
700 llvm::AtomicScope::Workgroup);
701 case NVPTX::BI__nvvm_atom_sys_min_gen_i:
702 case NVPTX::BI__nvvm_atom_sys_min_gen_l:
703 case NVPTX::BI__nvvm_atom_sys_min_gen_ll:
704 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Min,
705 llvm::AtomicScope::System);
706 case NVPTX::BI__nvvm_atom_sys_min_gen_ui:
707 case NVPTX::BI__nvvm_atom_sys_min_gen_ul:
708 case NVPTX::BI__nvvm_atom_sys_min_gen_ull:
709 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UMin,
710 llvm::AtomicScope::System);
711 case NVPTX::BI__nvvm_atom_cta_inc_gen_ui:
712 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UIncWrap,
713 llvm::AtomicScope::Workgroup);
714 case NVPTX::BI__nvvm_atom_cta_dec_gen_ui:
715 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UDecWrap,
716 llvm::AtomicScope::Workgroup);
717 case NVPTX::BI__nvvm_atom_sys_inc_gen_ui:
718 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UIncWrap,
719 llvm::AtomicScope::System);
720 case NVPTX::BI__nvvm_atom_sys_dec_gen_ui:
721 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UDecWrap,
722 llvm::AtomicScope::System);
723 case NVPTX::BI__nvvm_atom_cta_and_gen_i:
724 case NVPTX::BI__nvvm_atom_cta_and_gen_l:
725 case NVPTX::BI__nvvm_atom_cta_and_gen_ll:
726 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::And,
727 llvm::AtomicScope::Workgroup);
728 case NVPTX::BI__nvvm_atom_sys_and_gen_i:
729 case NVPTX::BI__nvvm_atom_sys_and_gen_l:
730 case NVPTX::BI__nvvm_atom_sys_and_gen_ll:
731 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::And,
732 llvm::AtomicScope::System);
733 case NVPTX::BI__nvvm_atom_cta_or_gen_i:
734 case NVPTX::BI__nvvm_atom_cta_or_gen_l:
735 case NVPTX::BI__nvvm_atom_cta_or_gen_ll:
736 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Or,
737 llvm::AtomicScope::Workgroup);
738 case NVPTX::BI__nvvm_atom_sys_or_gen_i:
739 case NVPTX::BI__nvvm_atom_sys_or_gen_l:
740 case NVPTX::BI__nvvm_atom_sys_or_gen_ll:
741 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Or,
742 llvm::AtomicScope::System);
743 case NVPTX::BI__nvvm_atom_cta_xor_gen_i:
744 case NVPTX::BI__nvvm_atom_cta_xor_gen_l:
745 case NVPTX::BI__nvvm_atom_cta_xor_gen_ll:
746 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Xor,
747 llvm::AtomicScope::Workgroup);
748 case NVPTX::BI__nvvm_atom_sys_xor_gen_i:
749 case NVPTX::BI__nvvm_atom_sys_xor_gen_l:
750 case NVPTX::BI__nvvm_atom_sys_xor_gen_ll:
751 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Xor,
752 llvm::AtomicScope::System);
753 case NVPTX::BI__nvvm_atom_cta_cas_gen_us:
754 case NVPTX::BI__nvvm_atom_cta_cas_gen_i:
755 case NVPTX::BI__nvvm_atom_cta_cas_gen_l:
756 case NVPTX::BI__nvvm_atom_cta_cas_gen_ll:
757 return MakeScopedAtomicCAS(*
this, E, llvm::AtomicScope::Workgroup);
758 case NVPTX::BI__nvvm_atom_sys_cas_gen_us:
759 case NVPTX::BI__nvvm_atom_sys_cas_gen_i:
760 case NVPTX::BI__nvvm_atom_sys_cas_gen_l:
761 case NVPTX::BI__nvvm_atom_sys_cas_gen_ll:
762 return MakeScopedAtomicCAS(*
this, E, llvm::AtomicScope::System);
763 case NVPTX::BI__nvvm_match_all_sync_i32p:
764 case NVPTX::BI__nvvm_match_all_sync_i64p: {
769 CGM.getIntrinsic(BuiltinID == NVPTX::BI__nvvm_match_all_sync_i32p
770 ? Intrinsic::nvvm_match_all_sync_i32p
771 : Intrinsic::nvvm_match_all_sync_i64p),
775 Builder.CreateStore(Pred, PredOutPtr);
776 return Builder.CreateExtractValue(ResultPair, 0);
780 case NVPTX::BI__hmma_m16n16k16_ld_a:
781 case NVPTX::BI__hmma_m16n16k16_ld_b:
782 case NVPTX::BI__hmma_m16n16k16_ld_c_f16:
783 case NVPTX::BI__hmma_m16n16k16_ld_c_f32:
784 case NVPTX::BI__hmma_m32n8k16_ld_a:
785 case NVPTX::BI__hmma_m32n8k16_ld_b:
786 case NVPTX::BI__hmma_m32n8k16_ld_c_f16:
787 case NVPTX::BI__hmma_m32n8k16_ld_c_f32:
788 case NVPTX::BI__hmma_m8n32k16_ld_a:
789 case NVPTX::BI__hmma_m8n32k16_ld_b:
790 case NVPTX::BI__hmma_m8n32k16_ld_c_f16:
791 case NVPTX::BI__hmma_m8n32k16_ld_c_f32:
793 case NVPTX::BI__imma_m16n16k16_ld_a_s8:
794 case NVPTX::BI__imma_m16n16k16_ld_a_u8:
795 case NVPTX::BI__imma_m16n16k16_ld_b_s8:
796 case NVPTX::BI__imma_m16n16k16_ld_b_u8:
797 case NVPTX::BI__imma_m16n16k16_ld_c:
798 case NVPTX::BI__imma_m32n8k16_ld_a_s8:
799 case NVPTX::BI__imma_m32n8k16_ld_a_u8:
800 case NVPTX::BI__imma_m32n8k16_ld_b_s8:
801 case NVPTX::BI__imma_m32n8k16_ld_b_u8:
802 case NVPTX::BI__imma_m32n8k16_ld_c:
803 case NVPTX::BI__imma_m8n32k16_ld_a_s8:
804 case NVPTX::BI__imma_m8n32k16_ld_a_u8:
805 case NVPTX::BI__imma_m8n32k16_ld_b_s8:
806 case NVPTX::BI__imma_m8n32k16_ld_b_u8:
807 case NVPTX::BI__imma_m8n32k16_ld_c:
809 case NVPTX::BI__imma_m8n8k32_ld_a_s4:
810 case NVPTX::BI__imma_m8n8k32_ld_a_u4:
811 case NVPTX::BI__imma_m8n8k32_ld_b_s4:
812 case NVPTX::BI__imma_m8n8k32_ld_b_u4:
813 case NVPTX::BI__imma_m8n8k32_ld_c:
814 case NVPTX::BI__bmma_m8n8k128_ld_a_b1:
815 case NVPTX::BI__bmma_m8n8k128_ld_b_b1:
816 case NVPTX::BI__bmma_m8n8k128_ld_c:
818 case NVPTX::BI__dmma_m8n8k4_ld_a:
819 case NVPTX::BI__dmma_m8n8k4_ld_b:
820 case NVPTX::BI__dmma_m8n8k4_ld_c:
822 case NVPTX::BI__mma_bf16_m16n16k16_ld_a:
823 case NVPTX::BI__mma_bf16_m16n16k16_ld_b:
824 case NVPTX::BI__mma_bf16_m8n32k16_ld_a:
825 case NVPTX::BI__mma_bf16_m8n32k16_ld_b:
826 case NVPTX::BI__mma_bf16_m32n8k16_ld_a:
827 case NVPTX::BI__mma_bf16_m32n8k16_ld_b:
828 case NVPTX::BI__mma_tf32_m16n16k8_ld_a:
829 case NVPTX::BI__mma_tf32_m16n16k8_ld_b:
830 case NVPTX::BI__mma_tf32_m16n16k8_ld_c: {
834 std::optional<llvm::APSInt> isColMajorArg =
838 bool isColMajor = isColMajorArg->getSExtValue();
839 NVPTXMmaLdstInfo II = getNVPTXMmaLdstInfo(BuiltinID);
840 unsigned IID = isColMajor ? II.IID_col : II.IID_row;
848 assert(II.NumResults);
849 if (II.NumResults == 1) {
853 for (
unsigned i = 0; i < II.NumResults; ++i) {
858 llvm::ConstantInt::get(
IntTy, i)),
865 case NVPTX::BI__hmma_m16n16k16_st_c_f16:
866 case NVPTX::BI__hmma_m16n16k16_st_c_f32:
867 case NVPTX::BI__hmma_m32n8k16_st_c_f16:
868 case NVPTX::BI__hmma_m32n8k16_st_c_f32:
869 case NVPTX::BI__hmma_m8n32k16_st_c_f16:
870 case NVPTX::BI__hmma_m8n32k16_st_c_f32:
871 case NVPTX::BI__imma_m16n16k16_st_c_i32:
872 case NVPTX::BI__imma_m32n8k16_st_c_i32:
873 case NVPTX::BI__imma_m8n32k16_st_c_i32:
874 case NVPTX::BI__imma_m8n8k32_st_c_i32:
875 case NVPTX::BI__bmma_m8n8k128_st_c_i32:
876 case NVPTX::BI__dmma_m8n8k4_st_c_f64:
877 case NVPTX::BI__mma_m16n16k8_st_c_f32: {
881 std::optional<llvm::APSInt> isColMajorArg =
885 bool isColMajor = isColMajorArg->getSExtValue();
886 NVPTXMmaLdstInfo II = getNVPTXMmaLdstInfo(BuiltinID);
887 unsigned IID = isColMajor ? II.IID_col : II.IID_row;
892 llvm::Type *ParamType = Intrinsic->getFunctionType()->getParamType(1);
894 for (
unsigned i = 0; i < II.NumResults; ++i) {
898 llvm::ConstantInt::get(
IntTy, i)),
900 Values.push_back(
Builder.CreateBitCast(
V, ParamType));
902 Values.push_back(Ldm);
909 case NVPTX::BI__hmma_m16n16k16_mma_f16f16:
910 case NVPTX::BI__hmma_m16n16k16_mma_f32f16:
911 case NVPTX::BI__hmma_m16n16k16_mma_f32f32:
912 case NVPTX::BI__hmma_m16n16k16_mma_f16f32:
913 case NVPTX::BI__hmma_m32n8k16_mma_f16f16:
914 case NVPTX::BI__hmma_m32n8k16_mma_f32f16:
915 case NVPTX::BI__hmma_m32n8k16_mma_f32f32:
916 case NVPTX::BI__hmma_m32n8k16_mma_f16f32:
917 case NVPTX::BI__hmma_m8n32k16_mma_f16f16:
918 case NVPTX::BI__hmma_m8n32k16_mma_f32f16:
919 case NVPTX::BI__hmma_m8n32k16_mma_f32f32:
920 case NVPTX::BI__hmma_m8n32k16_mma_f16f32:
921 case NVPTX::BI__imma_m16n16k16_mma_s8:
922 case NVPTX::BI__imma_m16n16k16_mma_u8:
923 case NVPTX::BI__imma_m32n8k16_mma_s8:
924 case NVPTX::BI__imma_m32n8k16_mma_u8:
925 case NVPTX::BI__imma_m8n32k16_mma_s8:
926 case NVPTX::BI__imma_m8n32k16_mma_u8:
927 case NVPTX::BI__imma_m8n8k32_mma_s4:
928 case NVPTX::BI__imma_m8n8k32_mma_u4:
929 case NVPTX::BI__bmma_m8n8k128_mma_xor_popc_b1:
930 case NVPTX::BI__bmma_m8n8k128_mma_and_popc_b1:
931 case NVPTX::BI__dmma_m8n8k4_mma_f64:
932 case NVPTX::BI__mma_bf16_m16n16k16_mma_f32:
933 case NVPTX::BI__mma_bf16_m8n32k16_mma_f32:
934 case NVPTX::BI__mma_bf16_m32n8k16_mma_f32:
935 case NVPTX::BI__mma_tf32_m16n16k8_mma_f32: {
940 std::optional<llvm::APSInt> LayoutArg =
944 int Layout = LayoutArg->getSExtValue();
945 if (Layout < 0 || Layout > 3)
947 llvm::APSInt SatfArg;
948 if (BuiltinID == NVPTX::BI__bmma_m8n8k128_mma_xor_popc_b1 ||
949 BuiltinID == NVPTX::BI__bmma_m8n8k128_mma_and_popc_b1)
951 else if (std::optional<llvm::APSInt> OptSatfArg =
953 SatfArg = *OptSatfArg;
956 bool Satf = SatfArg.getSExtValue();
957 NVPTXMmaInfo MI = getNVPTXMmaInfo(BuiltinID);
958 unsigned IID = MI.getMMAIntrinsic(Layout, Satf);
964 llvm::Type *AType = Intrinsic->getFunctionType()->getParamType(0);
966 for (
unsigned i = 0; i < MI.NumEltsA; ++i) {
970 llvm::ConstantInt::get(
IntTy, i)),
972 Values.push_back(
Builder.CreateBitCast(
V, AType));
975 llvm::Type *BType = Intrinsic->getFunctionType()->getParamType(MI.NumEltsA);
976 for (
unsigned i = 0; i < MI.NumEltsB; ++i) {
980 llvm::ConstantInt::get(
IntTy, i)),
982 Values.push_back(
Builder.CreateBitCast(
V, BType));
986 Intrinsic->getFunctionType()->getParamType(MI.NumEltsA + MI.NumEltsB);
987 for (
unsigned i = 0; i < MI.NumEltsC; ++i) {
991 llvm::ConstantInt::get(
IntTy, i)),
993 Values.push_back(
Builder.CreateBitCast(
V, CType));
997 for (
unsigned i = 0; i < MI.NumEltsD; ++i)
1001 llvm::ConstantInt::get(
IntTy, i)),
1006 case NVPTX::BI__nvvm_ex2_approx_f16:
1007 return MakeHalfType(
1008 CGM.getIntrinsic(Intrinsic::nvvm_ex2_approx,
Builder.getHalfTy()),
1009 BuiltinID, E, *
this);
1010 case NVPTX::BI__nvvm_ex2_approx_f16x2:
1011 return MakeHalfType(
1012 CGM.getIntrinsic(Intrinsic::nvvm_ex2_approx,
1013 FixedVectorType::get(
Builder.getHalfTy(), 2)),
1014 BuiltinID, E, *
this);
1015 case NVPTX::BI__nvvm_ff2f16x2_rn:
1016 return MakeHalfType(Intrinsic::nvvm_ff2f16x2_rn, BuiltinID, E, *
this);
1017 case NVPTX::BI__nvvm_ff2f16x2_rn_relu:
1018 return MakeHalfType(Intrinsic::nvvm_ff2f16x2_rn_relu, BuiltinID, E, *
this);
1019 case NVPTX::BI__nvvm_ff2f16x2_rz:
1020 return MakeHalfType(Intrinsic::nvvm_ff2f16x2_rz, BuiltinID, E, *
this);
1021 case NVPTX::BI__nvvm_ff2f16x2_rz_relu:
1022 return MakeHalfType(Intrinsic::nvvm_ff2f16x2_rz_relu, BuiltinID, E, *
this);
1024#define PZO_CVT(cvt) \
1025 case NVPTX::BI__nvvm_##cvt##_pzo: \
1026 return MakeHalfType(Intrinsic::nvvm_##cvt, BuiltinID, E, *this, \
1027 {Builder.getTrue()})
1033 PZO_CVT(ff2f16x2_rn_satfinite);
1034 PZO_CVT(ff2f16x2_rn_relu_satfinite);
1035 PZO_CVT(ff2f16x2_rz_satfinite);
1036 PZO_CVT(ff2f16x2_rz_relu_satfinite);
1041 PZO_CVT(ff2bf16x2_rn_satfinite);
1042 PZO_CVT(ff2bf16x2_rn_relu_satfinite);
1043 PZO_CVT(ff2bf16x2_rz_satfinite);
1044 PZO_CVT(ff2bf16x2_rz_relu_satfinite);
1050 PZO_CVT(f2f16_rn_relu_satfinite);
1052 PZO_CVT(f2f16_rz_relu_satfinite);
1058 PZO_CVT(f2bf16_rn_relu_satfinite);
1060 PZO_CVT(f2bf16_rz_relu_satfinite);
1063 PZO_CVT(ff_to_e4m3x2_rn_relu);
1065 PZO_CVT(ff_to_e4m3x2_rz_relu);
1067 PZO_CVT(ff_to_e5m2x2_rn_relu);
1069 PZO_CVT(ff_to_e5m2x2_rz_relu);
1071 PZO_CVT(f16x2_to_e4m3x2_rn_relu);
1073 PZO_CVT(f16x2_to_e4m3x2_rz_relu);
1075 PZO_CVT(f16x2_to_e5m2x2_rn_relu);
1077 PZO_CVT(f16x2_to_e5m2x2_rz_relu);
1078 PZO_CVT(bf16x2_to_e4m3x2_rn_satfinite);
1079 PZO_CVT(bf16x2_to_e4m3x2_rn_relu_satfinite);
1080 PZO_CVT(bf16x2_to_e4m3x2_rz_satfinite);
1081 PZO_CVT(bf16x2_to_e4m3x2_rz_relu_satfinite);
1082 PZO_CVT(bf16x2_to_e5m2x2_rn_satfinite);
1083 PZO_CVT(bf16x2_to_e5m2x2_rn_relu_satfinite);
1084 PZO_CVT(bf16x2_to_e5m2x2_rz_satfinite);
1085 PZO_CVT(bf16x2_to_e5m2x2_rz_relu_satfinite);
1087 PZO_CVT(ff_to_e4m3x2_rn_scale_n1_ue8m0);
1088 PZO_CVT(ff_to_e4m3x2_rn_relu_scale_n1_ue8m0);
1089 PZO_CVT(ff_to_e4m3x2_rz_scale_n1_ue8m0);
1090 PZO_CVT(ff_to_e4m3x2_rz_relu_scale_n1_ue8m0);
1091 PZO_CVT(ff_to_e5m2x2_rn_scale_n1_ue8m0);
1092 PZO_CVT(ff_to_e5m2x2_rn_relu_scale_n1_ue8m0);
1093 PZO_CVT(ff_to_e5m2x2_rz_scale_n1_ue8m0);
1094 PZO_CVT(ff_to_e5m2x2_rz_relu_scale_n1_ue8m0);
1095 PZO_CVT(f16x2_to_e4m3x2_rn_scale_n1_ue8m0);
1096 PZO_CVT(f16x2_to_e4m3x2_rn_relu_scale_n1_ue8m0);
1097 PZO_CVT(f16x2_to_e4m3x2_rz_scale_n1_ue8m0);
1098 PZO_CVT(f16x2_to_e4m3x2_rz_relu_scale_n1_ue8m0);
1099 PZO_CVT(f16x2_to_e5m2x2_rn_scale_n1_ue8m0);
1100 PZO_CVT(f16x2_to_e5m2x2_rn_relu_scale_n1_ue8m0);
1101 PZO_CVT(f16x2_to_e5m2x2_rz_scale_n1_ue8m0);
1102 PZO_CVT(f16x2_to_e5m2x2_rz_relu_scale_n1_ue8m0);
1103 PZO_CVT(bf16x2_to_e4m3x2_rn_satfinite_scale_n1_ue8m0);
1104 PZO_CVT(bf16x2_to_e4m3x2_rn_relu_satfinite_scale_n1_ue8m0);
1105 PZO_CVT(bf16x2_to_e4m3x2_rz_satfinite_scale_n1_ue8m0);
1106 PZO_CVT(bf16x2_to_e4m3x2_rz_relu_satfinite_scale_n1_ue8m0);
1107 PZO_CVT(bf16x2_to_e5m2x2_rn_satfinite_scale_n1_ue8m0);
1108 PZO_CVT(bf16x2_to_e5m2x2_rn_relu_satfinite_scale_n1_ue8m0);
1109 PZO_CVT(bf16x2_to_e5m2x2_rz_satfinite_scale_n1_ue8m0);
1110 PZO_CVT(bf16x2_to_e5m2x2_rz_relu_satfinite_scale_n1_ue8m0);
1112 PZO_CVT(ff_to_e2m3x2_rn_satfinite);
1113 PZO_CVT(ff_to_e2m3x2_rn_relu_satfinite);
1114 PZO_CVT(ff_to_e2m3x2_rz_satfinite);
1115 PZO_CVT(ff_to_e2m3x2_rz_relu_satfinite);
1116 PZO_CVT(ff_to_e3m2x2_rn_satfinite);
1117 PZO_CVT(ff_to_e3m2x2_rn_relu_satfinite);
1118 PZO_CVT(ff_to_e3m2x2_rz_satfinite);
1119 PZO_CVT(ff_to_e3m2x2_rz_relu_satfinite);
1120 PZO_CVT(f16x2_to_e2m3x2_rn_satfinite);
1121 PZO_CVT(f16x2_to_e2m3x2_rn_relu_satfinite);
1122 PZO_CVT(f16x2_to_e2m3x2_rz_satfinite);
1123 PZO_CVT(f16x2_to_e2m3x2_rz_relu_satfinite);
1124 PZO_CVT(f16x2_to_e3m2x2_rn_satfinite);
1125 PZO_CVT(f16x2_to_e3m2x2_rn_relu_satfinite);
1126 PZO_CVT(f16x2_to_e3m2x2_rz_satfinite);
1127 PZO_CVT(f16x2_to_e3m2x2_rz_relu_satfinite);
1128 PZO_CVT(bf16x2_to_e2m3x2_rn_satfinite);
1129 PZO_CVT(bf16x2_to_e2m3x2_rn_relu_satfinite);
1130 PZO_CVT(bf16x2_to_e2m3x2_rz_satfinite);
1131 PZO_CVT(bf16x2_to_e2m3x2_rz_relu_satfinite);
1132 PZO_CVT(bf16x2_to_e3m2x2_rn_satfinite);
1133 PZO_CVT(bf16x2_to_e3m2x2_rn_relu_satfinite);
1134 PZO_CVT(bf16x2_to_e3m2x2_rz_satfinite);
1135 PZO_CVT(bf16x2_to_e3m2x2_rz_relu_satfinite);
1137 PZO_CVT(ff_to_e2m3x2_rn_satfinite_scale_n1_ue8m0);
1138 PZO_CVT(ff_to_e2m3x2_rn_relu_satfinite_scale_n1_ue8m0);
1139 PZO_CVT(ff_to_e2m3x2_rz_satfinite_scale_n1_ue8m0);
1140 PZO_CVT(ff_to_e2m3x2_rz_relu_satfinite_scale_n1_ue8m0);
1141 PZO_CVT(ff_to_e3m2x2_rn_satfinite_scale_n1_ue8m0);
1142 PZO_CVT(ff_to_e3m2x2_rn_relu_satfinite_scale_n1_ue8m0);
1143 PZO_CVT(ff_to_e3m2x2_rz_satfinite_scale_n1_ue8m0);
1144 PZO_CVT(ff_to_e3m2x2_rz_relu_satfinite_scale_n1_ue8m0);
1145 PZO_CVT(f16x2_to_e2m3x2_rn_satfinite_scale_n1_ue8m0);
1146 PZO_CVT(f16x2_to_e2m3x2_rn_relu_satfinite_scale_n1_ue8m0);
1147 PZO_CVT(f16x2_to_e2m3x2_rz_satfinite_scale_n1_ue8m0);
1148 PZO_CVT(f16x2_to_e2m3x2_rz_relu_satfinite_scale_n1_ue8m0);
1149 PZO_CVT(f16x2_to_e3m2x2_rn_satfinite_scale_n1_ue8m0);
1150 PZO_CVT(f16x2_to_e3m2x2_rn_relu_satfinite_scale_n1_ue8m0);
1151 PZO_CVT(f16x2_to_e3m2x2_rz_satfinite_scale_n1_ue8m0);
1152 PZO_CVT(f16x2_to_e3m2x2_rz_relu_satfinite_scale_n1_ue8m0);
1153 PZO_CVT(bf16x2_to_e2m3x2_rn_satfinite_scale_n1_ue8m0);
1154 PZO_CVT(bf16x2_to_e2m3x2_rn_relu_satfinite_scale_n1_ue8m0);
1155 PZO_CVT(bf16x2_to_e2m3x2_rz_satfinite_scale_n1_ue8m0);
1156 PZO_CVT(bf16x2_to_e2m3x2_rz_relu_satfinite_scale_n1_ue8m0);
1157 PZO_CVT(bf16x2_to_e3m2x2_rn_satfinite_scale_n1_ue8m0);
1158 PZO_CVT(bf16x2_to_e3m2x2_rn_relu_satfinite_scale_n1_ue8m0);
1159 PZO_CVT(bf16x2_to_e3m2x2_rz_satfinite_scale_n1_ue8m0);
1160 PZO_CVT(bf16x2_to_e3m2x2_rz_relu_satfinite_scale_n1_ue8m0);
1162 PZO_CVT(ff_to_e2m1x2_rn_satfinite);
1163 PZO_CVT(ff_to_e2m1x2_rn_relu_satfinite);
1164 PZO_CVT(ff_to_e2m1x2_rz_satfinite);
1165 PZO_CVT(ff_to_e2m1x2_rz_relu_satfinite);
1166 PZO_CVT(f16x2_to_e2m1x2_rn_satfinite);
1167 PZO_CVT(f16x2_to_e2m1x2_rn_relu_satfinite);
1168 PZO_CVT(f16x2_to_e2m1x2_rz_satfinite);
1169 PZO_CVT(f16x2_to_e2m1x2_rz_relu_satfinite);
1170 PZO_CVT(bf16x2_to_e2m1x2_rn_satfinite);
1171 PZO_CVT(bf16x2_to_e2m1x2_rn_relu_satfinite);
1172 PZO_CVT(bf16x2_to_e2m1x2_rz_satfinite);
1173 PZO_CVT(bf16x2_to_e2m1x2_rz_relu_satfinite);
1175 PZO_CVT(ff_to_e2m1x2_rn_satfinite_scale_n1_ue8m0);
1176 PZO_CVT(ff_to_e2m1x2_rn_relu_satfinite_scale_n1_ue8m0);
1177 PZO_CVT(ff_to_e2m1x2_rz_satfinite_scale_n1_ue8m0);
1178 PZO_CVT(ff_to_e2m1x2_rz_relu_satfinite_scale_n1_ue8m0);
1179 PZO_CVT(f16x2_to_e2m1x2_rn_satfinite_scale_n1_ue8m0);
1180 PZO_CVT(f16x2_to_e2m1x2_rn_relu_satfinite_scale_n1_ue8m0);
1181 PZO_CVT(f16x2_to_e2m1x2_rz_satfinite_scale_n1_ue8m0);
1182 PZO_CVT(f16x2_to_e2m1x2_rz_relu_satfinite_scale_n1_ue8m0);
1183 PZO_CVT(bf16x2_to_e2m1x2_rn_satfinite_scale_n1_ue8m0);
1184 PZO_CVT(bf16x2_to_e2m1x2_rn_relu_satfinite_scale_n1_ue8m0);
1185 PZO_CVT(bf16x2_to_e2m1x2_rz_satfinite_scale_n1_ue8m0);
1186 PZO_CVT(bf16x2_to_e2m1x2_rz_relu_satfinite_scale_n1_ue8m0);
1190 case NVPTX::BI__nvvm_fma_rn_f16:
1191 return MakeHalfType(Intrinsic::nvvm_fma_rn_f16, BuiltinID, E, *
this);
1192 case NVPTX::BI__nvvm_fma_rn_f16x2:
1193 return MakeHalfType(Intrinsic::nvvm_fma_rn_f16x2, BuiltinID, E, *
this);
1194 case NVPTX::BI__nvvm_fma_rn_ftz_f16:
1195 return MakeHalfType(Intrinsic::nvvm_fma_rn_ftz_f16, BuiltinID, E, *
this);
1196 case NVPTX::BI__nvvm_fma_rn_ftz_f16x2:
1197 return MakeHalfType(Intrinsic::nvvm_fma_rn_ftz_f16x2, BuiltinID, E, *
this);
1198 case NVPTX::BI__nvvm_fma_rn_ftz_relu_f16:
1199 return MakeHalfType(Intrinsic::nvvm_fma_rn_ftz_relu_f16, BuiltinID, E,
1201 case NVPTX::BI__nvvm_fma_rn_ftz_relu_f16x2:
1202 return MakeHalfType(Intrinsic::nvvm_fma_rn_ftz_relu_f16x2, BuiltinID, E,
1204 case NVPTX::BI__nvvm_fma_rn_ftz_sat_f16:
1205 return MakeHalfType(Intrinsic::nvvm_fma_rn_ftz_sat_f16, BuiltinID, E,
1207 case NVPTX::BI__nvvm_fma_rn_ftz_sat_f16x2:
1208 return MakeHalfType(Intrinsic::nvvm_fma_rn_ftz_sat_f16x2, BuiltinID, E,
1210 case NVPTX::BI__nvvm_fma_rn_relu_f16:
1211 return MakeHalfType(Intrinsic::nvvm_fma_rn_relu_f16, BuiltinID, E, *
this);
1212 case NVPTX::BI__nvvm_fma_rn_relu_f16x2:
1213 return MakeHalfType(Intrinsic::nvvm_fma_rn_relu_f16x2, BuiltinID, E, *
this);
1214 case NVPTX::BI__nvvm_fma_rn_sat_f16:
1215 return MakeHalfType(Intrinsic::nvvm_fma_rn_sat_f16, BuiltinID, E, *
this);
1216 case NVPTX::BI__nvvm_fma_rn_sat_f16x2:
1217 return MakeHalfType(Intrinsic::nvvm_fma_rn_sat_f16x2, BuiltinID, E, *
this);
1218 case NVPTX::BI__nvvm_fma_rn_oob_f16:
1219 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob,
Builder.getHalfTy(), E,
1221 case NVPTX::BI__nvvm_fma_rn_oob_f16x2:
1222 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob,
1223 llvm::FixedVectorType::get(
Builder.getHalfTy(), 2), E,
1225 case NVPTX::BI__nvvm_fma_rn_oob_bf16:
1226 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob,
Builder.getBFloatTy(), E,
1228 case NVPTX::BI__nvvm_fma_rn_oob_bf16x2:
1229 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob,
1230 llvm::FixedVectorType::get(
Builder.getBFloatTy(), 2), E,
1232 case NVPTX::BI__nvvm_fma_rn_oob_relu_f16:
1233 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob_relu,
Builder.getHalfTy(), E,
1235 case NVPTX::BI__nvvm_fma_rn_oob_relu_f16x2:
1236 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob_relu,
1237 llvm::FixedVectorType::get(
Builder.getHalfTy(), 2), E,
1239 case NVPTX::BI__nvvm_fma_rn_oob_relu_bf16:
1240 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob_relu,
Builder.getBFloatTy(), E,
1242 case NVPTX::BI__nvvm_fma_rn_oob_relu_bf16x2:
1243 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob_relu,
1244 llvm::FixedVectorType::get(
Builder.getBFloatTy(), 2), E,
1246 case NVPTX::BI__nvvm_fmax_f16:
1247 return MakeHalfType(Intrinsic::nvvm_fmax_f16, BuiltinID, E, *
this);
1248 case NVPTX::BI__nvvm_fmax_f16x2:
1249 return MakeHalfType(Intrinsic::nvvm_fmax_f16x2, BuiltinID, E, *
this);
1250 case NVPTX::BI__nvvm_fmax_ftz_f16:
1251 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_f16, BuiltinID, E, *
this);
1252 case NVPTX::BI__nvvm_fmax_ftz_f16x2:
1253 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_f16x2, BuiltinID, E, *
this);
1254 case NVPTX::BI__nvvm_fmax_ftz_nan_f16:
1255 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_nan_f16, BuiltinID, E, *
this);
1256 case NVPTX::BI__nvvm_fmax_ftz_nan_f16x2:
1257 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_nan_f16x2, BuiltinID, E,
1259 case NVPTX::BI__nvvm_fmax_ftz_nan_xorsign_abs_f16:
1260 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_nan_xorsign_abs_f16, BuiltinID,
1262 case NVPTX::BI__nvvm_fmax_ftz_nan_xorsign_abs_f16x2:
1263 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_nan_xorsign_abs_f16x2,
1264 BuiltinID, E, *
this);
1265 case NVPTX::BI__nvvm_fmax_ftz_xorsign_abs_f16:
1266 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_xorsign_abs_f16, BuiltinID, E,
1268 case NVPTX::BI__nvvm_fmax_ftz_xorsign_abs_f16x2:
1269 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_xorsign_abs_f16x2, BuiltinID,
1271 case NVPTX::BI__nvvm_fmax_nan_f16:
1272 return MakeHalfType(Intrinsic::nvvm_fmax_nan_f16, BuiltinID, E, *
this);
1273 case NVPTX::BI__nvvm_fmax_nan_f16x2:
1274 return MakeHalfType(Intrinsic::nvvm_fmax_nan_f16x2, BuiltinID, E, *
this);
1275 case NVPTX::BI__nvvm_fmax_nan_xorsign_abs_f16:
1276 return MakeHalfType(Intrinsic::nvvm_fmax_nan_xorsign_abs_f16, BuiltinID, E,
1278 case NVPTX::BI__nvvm_fmax_nan_xorsign_abs_f16x2:
1279 return MakeHalfType(Intrinsic::nvvm_fmax_nan_xorsign_abs_f16x2, BuiltinID,
1281 case NVPTX::BI__nvvm_fmax_xorsign_abs_f16:
1282 return MakeHalfType(Intrinsic::nvvm_fmax_xorsign_abs_f16, BuiltinID, E,
1284 case NVPTX::BI__nvvm_fmax_xorsign_abs_f16x2:
1285 return MakeHalfType(Intrinsic::nvvm_fmax_xorsign_abs_f16x2, BuiltinID, E,
1287 case NVPTX::BI__nvvm_fmin_f16:
1288 return MakeHalfType(Intrinsic::nvvm_fmin_f16, BuiltinID, E, *
this);
1289 case NVPTX::BI__nvvm_fmin_f16x2:
1290 return MakeHalfType(Intrinsic::nvvm_fmin_f16x2, BuiltinID, E, *
this);
1291 case NVPTX::BI__nvvm_fmin_ftz_f16:
1292 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_f16, BuiltinID, E, *
this);
1293 case NVPTX::BI__nvvm_fmin_ftz_f16x2:
1294 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_f16x2, BuiltinID, E, *
this);
1295 case NVPTX::BI__nvvm_fmin_ftz_nan_f16:
1296 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_nan_f16, BuiltinID, E, *
this);
1297 case NVPTX::BI__nvvm_fmin_ftz_nan_f16x2:
1298 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_nan_f16x2, BuiltinID, E,
1300 case NVPTX::BI__nvvm_fmin_ftz_nan_xorsign_abs_f16:
1301 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_nan_xorsign_abs_f16, BuiltinID,
1303 case NVPTX::BI__nvvm_fmin_ftz_nan_xorsign_abs_f16x2:
1304 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_nan_xorsign_abs_f16x2,
1305 BuiltinID, E, *
this);
1306 case NVPTX::BI__nvvm_fmin_ftz_xorsign_abs_f16:
1307 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_xorsign_abs_f16, BuiltinID, E,
1309 case NVPTX::BI__nvvm_fmin_ftz_xorsign_abs_f16x2:
1310 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_xorsign_abs_f16x2, BuiltinID,
1312 case NVPTX::BI__nvvm_fmin_nan_f16:
1313 return MakeHalfType(Intrinsic::nvvm_fmin_nan_f16, BuiltinID, E, *
this);
1314 case NVPTX::BI__nvvm_fmin_nan_f16x2:
1315 return MakeHalfType(Intrinsic::nvvm_fmin_nan_f16x2, BuiltinID, E, *
this);
1316 case NVPTX::BI__nvvm_fmin_nan_xorsign_abs_f16:
1317 return MakeHalfType(Intrinsic::nvvm_fmin_nan_xorsign_abs_f16, BuiltinID, E,
1319 case NVPTX::BI__nvvm_fmin_nan_xorsign_abs_f16x2:
1320 return MakeHalfType(Intrinsic::nvvm_fmin_nan_xorsign_abs_f16x2, BuiltinID,
1322 case NVPTX::BI__nvvm_fmin_xorsign_abs_f16:
1323 return MakeHalfType(Intrinsic::nvvm_fmin_xorsign_abs_f16, BuiltinID, E,
1325 case NVPTX::BI__nvvm_fmin_xorsign_abs_f16x2:
1326 return MakeHalfType(Intrinsic::nvvm_fmin_xorsign_abs_f16x2, BuiltinID, E,
1328 case NVPTX::BI__nvvm_fabs_f:
1329 case NVPTX::BI__nvvm_abs_bf16:
1330 case NVPTX::BI__nvvm_abs_bf16x2:
1331 case NVPTX::BI__nvvm_fabs_f16:
1332 case NVPTX::BI__nvvm_fabs_f16x2:
1333 return Builder.CreateUnaryIntrinsic(Intrinsic::nvvm_fabs,
1335 case NVPTX::BI__nvvm_fabs_ftz_f:
1336 case NVPTX::BI__nvvm_fabs_ftz_f16:
1337 case NVPTX::BI__nvvm_fabs_ftz_f16x2:
1338 return Builder.CreateUnaryIntrinsic(Intrinsic::nvvm_fabs_ftz,
1340 case NVPTX::BI__nvvm_fabs_d:
1342 case NVPTX::BI__nvvm_ex2_approx_d:
1343 case NVPTX::BI__nvvm_ex2_approx_f:
1344 return Builder.CreateUnaryIntrinsic(Intrinsic::nvvm_ex2_approx,
1346 case NVPTX::BI__nvvm_ex2_approx_ftz_f:
1347 return Builder.CreateUnaryIntrinsic(Intrinsic::nvvm_ex2_approx_ftz,
1349 case NVPTX::BI__nvvm_add_rn_f:
1350 case NVPTX::BI__nvvm_add_rn_d:
1351 return MakeFPArith(Intrinsic::nvvm_fadd, APFloat::rmNearestTiesToEven,
1352 BuiltinID, E, *
this);
1353 case NVPTX::BI__nvvm_add_rz_f:
1354 case NVPTX::BI__nvvm_add_rz_d:
1355 return MakeFPArith(Intrinsic::nvvm_fadd, APFloat::rmTowardZero, BuiltinID,
1357 case NVPTX::BI__nvvm_add_rm_f:
1358 case NVPTX::BI__nvvm_add_rm_d:
1359 return MakeFPArith(Intrinsic::nvvm_fadd, APFloat::rmTowardNegative,
1360 BuiltinID, E, *
this);
1361 case NVPTX::BI__nvvm_add_rp_f:
1362 case NVPTX::BI__nvvm_add_rp_d:
1363 return MakeFPArith(Intrinsic::nvvm_fadd, APFloat::rmTowardPositive,
1364 BuiltinID, E, *
this);
1365 case NVPTX::BI__nvvm_add_rn_ftz_f:
1366 return MakeFPArith(Intrinsic::nvvm_fadd_ftz, APFloat::rmNearestTiesToEven,
1367 BuiltinID, E, *
this);
1368 case NVPTX::BI__nvvm_add_rz_ftz_f:
1369 return MakeFPArith(Intrinsic::nvvm_fadd_ftz, APFloat::rmTowardZero,
1370 BuiltinID, E, *
this);
1371 case NVPTX::BI__nvvm_add_rm_ftz_f:
1372 return MakeFPArith(Intrinsic::nvvm_fadd_ftz, APFloat::rmTowardNegative,
1373 BuiltinID, E, *
this);
1374 case NVPTX::BI__nvvm_add_rp_ftz_f:
1375 return MakeFPArith(Intrinsic::nvvm_fadd_ftz, APFloat::rmTowardPositive,
1376 BuiltinID, E, *
this);
1377 case NVPTX::BI__nvvm_add_rn_sat_f:
1378 case NVPTX::BI__nvvm_add_rn_sat_f16:
1379 case NVPTX::BI__nvvm_add_rn_sat_v2f16:
1380 return MakeFPArith(Intrinsic::nvvm_fadd_sat, APFloat::rmNearestTiesToEven,
1381 BuiltinID, E, *
this);
1382 case NVPTX::BI__nvvm_add_rz_sat_f:
1383 return MakeFPArith(Intrinsic::nvvm_fadd_sat, APFloat::rmTowardZero,
1384 BuiltinID, E, *
this);
1385 case NVPTX::BI__nvvm_add_rm_sat_f:
1386 return MakeFPArith(Intrinsic::nvvm_fadd_sat, APFloat::rmTowardNegative,
1387 BuiltinID, E, *
this);
1388 case NVPTX::BI__nvvm_add_rp_sat_f:
1389 return MakeFPArith(Intrinsic::nvvm_fadd_sat, APFloat::rmTowardPositive,
1390 BuiltinID, E, *
this);
1391 case NVPTX::BI__nvvm_add_rn_ftz_sat_f:
1392 case NVPTX::BI__nvvm_add_rn_ftz_sat_f16:
1393 case NVPTX::BI__nvvm_add_rn_ftz_sat_v2f16:
1394 return MakeFPArith(Intrinsic::nvvm_fadd_ftz_sat,
1395 APFloat::rmNearestTiesToEven, BuiltinID, E, *
this);
1396 case NVPTX::BI__nvvm_add_rz_ftz_sat_f:
1397 return MakeFPArith(Intrinsic::nvvm_fadd_ftz_sat, APFloat::rmTowardZero,
1398 BuiltinID, E, *
this);
1399 case NVPTX::BI__nvvm_add_rm_ftz_sat_f:
1400 return MakeFPArith(Intrinsic::nvvm_fadd_ftz_sat, APFloat::rmTowardNegative,
1401 BuiltinID, E, *
this);
1402 case NVPTX::BI__nvvm_add_rp_ftz_sat_f:
1403 return MakeFPArith(Intrinsic::nvvm_fadd_ftz_sat, APFloat::rmTowardPositive,
1404 BuiltinID, E, *
this);
1405 case NVPTX::BI__nvvm_mul_rn_f:
1406 case NVPTX::BI__nvvm_mul_rn_d:
1407 return MakeFPArith(Intrinsic::nvvm_fmul, APFloat::rmNearestTiesToEven,
1408 BuiltinID, E, *
this);
1409 case NVPTX::BI__nvvm_mul_rz_f:
1410 case NVPTX::BI__nvvm_mul_rz_d:
1411 return MakeFPArith(Intrinsic::nvvm_fmul, APFloat::rmTowardZero, BuiltinID,
1413 case NVPTX::BI__nvvm_mul_rm_f:
1414 case NVPTX::BI__nvvm_mul_rm_d:
1415 return MakeFPArith(Intrinsic::nvvm_fmul, APFloat::rmTowardNegative,
1416 BuiltinID, E, *
this);
1417 case NVPTX::BI__nvvm_mul_rp_f:
1418 case NVPTX::BI__nvvm_mul_rp_d:
1419 return MakeFPArith(Intrinsic::nvvm_fmul, APFloat::rmTowardPositive,
1420 BuiltinID, E, *
this);
1421 case NVPTX::BI__nvvm_mul_rn_ftz_f:
1422 return MakeFPArith(Intrinsic::nvvm_fmul_ftz, APFloat::rmNearestTiesToEven,
1423 BuiltinID, E, *
this);
1424 case NVPTX::BI__nvvm_mul_rz_ftz_f:
1425 return MakeFPArith(Intrinsic::nvvm_fmul_ftz, APFloat::rmTowardZero,
1426 BuiltinID, E, *
this);
1427 case NVPTX::BI__nvvm_mul_rm_ftz_f:
1428 return MakeFPArith(Intrinsic::nvvm_fmul_ftz, APFloat::rmTowardNegative,
1429 BuiltinID, E, *
this);
1430 case NVPTX::BI__nvvm_mul_rp_ftz_f:
1431 return MakeFPArith(Intrinsic::nvvm_fmul_ftz, APFloat::rmTowardPositive,
1432 BuiltinID, E, *
this);
1433 case NVPTX::BI__nvvm_mul_rn_sat_f16:
1434 case NVPTX::BI__nvvm_mul_rn_sat_v2f16:
1435 return MakeFPArith(Intrinsic::nvvm_fmul_sat, APFloat::rmNearestTiesToEven,
1436 BuiltinID, E, *
this);
1437 case NVPTX::BI__nvvm_mul_rn_ftz_sat_f16:
1438 case NVPTX::BI__nvvm_mul_rn_ftz_sat_v2f16:
1439 return MakeFPArith(Intrinsic::nvvm_fmul_ftz_sat,
1440 APFloat::rmNearestTiesToEven, BuiltinID, E, *
this);
1441 case NVPTX::BI__nvvm_ldg_h:
1442 case NVPTX::BI__nvvm_ldg_h2:
1443 return MakeLdg(*
this, E);
1444 case NVPTX::BI__nvvm_ldu_h:
1445 case NVPTX::BI__nvvm_ldu_h2:
1446 return MakeLdu(Intrinsic::nvvm_ldu_global_f, *
this, E);
1447 case NVPTX::BI__nvvm_cp_async_ca_shared_global_4:
1448 return MakeCpAsync(Intrinsic::nvvm_cp_async_ca_shared_global_4,
1449 Intrinsic::nvvm_cp_async_ca_shared_global_4_s, *
this, E,
1451 case NVPTX::BI__nvvm_cp_async_ca_shared_global_8:
1452 return MakeCpAsync(Intrinsic::nvvm_cp_async_ca_shared_global_8,
1453 Intrinsic::nvvm_cp_async_ca_shared_global_8_s, *
this, E,
1455 case NVPTX::BI__nvvm_cp_async_ca_shared_global_16:
1456 return MakeCpAsync(Intrinsic::nvvm_cp_async_ca_shared_global_16,
1457 Intrinsic::nvvm_cp_async_ca_shared_global_16_s, *
this, E,
1459 case NVPTX::BI__nvvm_cp_async_cg_shared_global_16:
1460 return MakeCpAsync(Intrinsic::nvvm_cp_async_cg_shared_global_16,
1461 Intrinsic::nvvm_cp_async_cg_shared_global_16_s, *
this, E,
1463 case NVPTX::BI__nvvm_read_ptx_sreg_clusterid_x:
1465 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_clusterid_x));
1466 case NVPTX::BI__nvvm_read_ptx_sreg_clusterid_y:
1468 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_clusterid_y));
1469 case NVPTX::BI__nvvm_read_ptx_sreg_clusterid_z:
1471 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_clusterid_z));
1472 case NVPTX::BI__nvvm_read_ptx_sreg_clusterid_w:
1474 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_clusterid_w));
1475 case NVPTX::BI__nvvm_read_ptx_sreg_nclusterid_x:
1477 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_nclusterid_x));
1478 case NVPTX::BI__nvvm_read_ptx_sreg_nclusterid_y:
1480 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_nclusterid_y));
1481 case NVPTX::BI__nvvm_read_ptx_sreg_nclusterid_z:
1483 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_nclusterid_z));
1484 case NVPTX::BI__nvvm_read_ptx_sreg_nclusterid_w:
1486 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_nclusterid_w));
1487 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_ctaid_x:
1489 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_ctaid_x));
1490 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_ctaid_y:
1492 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_ctaid_y));
1493 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_ctaid_z:
1495 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_ctaid_z));
1496 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_ctaid_w:
1498 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_ctaid_w));
1499 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_nctaid_x:
1501 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_nctaid_x));
1502 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_nctaid_y:
1504 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_nctaid_y));
1505 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_nctaid_z:
1507 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_nctaid_z));
1508 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_nctaid_w:
1510 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_nctaid_w));
1511 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_ctarank:
1513 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_ctarank));
1514 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_nctarank:
1516 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_nctarank));
1517 case NVPTX::BI__nvvm_is_explicit_cluster:
1519 CGM.getIntrinsic(Intrinsic::nvvm_is_explicit_cluster));
1520 case NVPTX::BI__nvvm_isspacep_shared_cluster:
1522 CGM.getIntrinsic(Intrinsic::nvvm_isspacep_shared_cluster),
1524 case NVPTX::BI__nvvm_mapa:
1526 CGM.getIntrinsic(Intrinsic::nvvm_mapa),
1527 {EmitScalarExpr(E->getArg(0)), EmitScalarExpr(E->getArg(1))});
1528 case NVPTX::BI__nvvm_mapa_shared_cluster:
1530 CGM.getIntrinsic(Intrinsic::nvvm_mapa_shared_cluster),
1531 {EmitScalarExpr(E->getArg(0)), EmitScalarExpr(E->getArg(1))});
1532 case NVPTX::BI__nvvm_getctarank:
1534 CGM.getIntrinsic(Intrinsic::nvvm_getctarank),
1536 case NVPTX::BI__nvvm_getctarank_shared_cluster:
1538 CGM.getIntrinsic(Intrinsic::nvvm_getctarank_shared_cluster),
1540 case NVPTX::BI__nvvm_barrier_cluster_arrive:
1542 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cluster_arrive));
1543 case NVPTX::BI__nvvm_barrier_cluster_arrive_relaxed:
1545 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cluster_arrive_relaxed));
1546 case NVPTX::BI__nvvm_barrier_cluster_wait:
1548 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cluster_wait));
1549 case NVPTX::BI__nvvm_fence_sc_cluster:
1551 CGM.getIntrinsic(Intrinsic::nvvm_fence_sc_cluster));
1552 case NVPTX::BI__nvvm_bar_sync:
1554 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cta_sync_aligned_all),
1556 case NVPTX::BI__syncthreads:
1558 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cta_sync_aligned_all),
1560 case NVPTX::BI__nvvm_barrier_sync:
1562 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cta_sync_all),
1564 case NVPTX::BI__nvvm_barrier_sync_cnt:
1566 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cta_sync_count),
1567 {EmitScalarExpr(E->getArg(0)), EmitScalarExpr(E->getArg(1))});
1568 case NVPTX::BI__nvvm_bar0_and:
1571 Intrinsic::nvvm_barrier_cta_red_and_aligned_all, {},
1572 {Builder.getInt32(0),
1573 Builder.CreateICmpNE(EmitScalarExpr(E->getArg(0)),
1574 Builder.getInt32(0))}),
1576 case NVPTX::BI__nvvm_bar0_or:
1579 Intrinsic::nvvm_barrier_cta_red_or_aligned_all, {},
1580 {Builder.getInt32(0),
1581 Builder.CreateICmpNE(EmitScalarExpr(E->getArg(0)),
1582 Builder.getInt32(0))}),
1584 case NVPTX::BI__nvvm_bar0_popc:
1585 return Builder.CreateIntrinsic(
1586 Intrinsic::nvvm_barrier_cta_red_popc_aligned_all, {},
1589 case NVPTX::BI__nvvm_mbarrier_init:
1590 case NVPTX::BI__nvvm_mbarrier_init_shared: {
1594 return Builder.CreateIntrinsic(
1595 Intrinsic::nvvm_mbarrier_init, {Ptr->getType()},
1598 case NVPTX::BI__nvvm_idp2a_lo_s_s:
1599 return MakeIdp2a(Intrinsic::nvvm_idp2a_s_s,
false, E, *
this);
1600 case NVPTX::BI__nvvm_idp2a_lo_s_u:
1601 return MakeIdp2a(Intrinsic::nvvm_idp2a_s_u,
false, E, *
this);
1602 case NVPTX::BI__nvvm_idp2a_lo_u_s:
1603 return MakeIdp2a(Intrinsic::nvvm_idp2a_u_s,
false, E, *
this);
1604 case NVPTX::BI__nvvm_idp2a_lo_u_u:
1605 return MakeIdp2a(Intrinsic::nvvm_idp2a_u_u,
false, E, *
this);
1606 case NVPTX::BI__nvvm_idp2a_hi_s_s:
1607 return MakeIdp2a(Intrinsic::nvvm_idp2a_s_s,
true, E, *
this);
1608 case NVPTX::BI__nvvm_idp2a_hi_s_u:
1609 return MakeIdp2a(Intrinsic::nvvm_idp2a_s_u,
true, E, *
this);
1610 case NVPTX::BI__nvvm_idp2a_hi_u_s:
1611 return MakeIdp2a(Intrinsic::nvvm_idp2a_u_s,
true, E, *
this);
1612 case NVPTX::BI__nvvm_idp2a_hi_u_u:
1613 return MakeIdp2a(Intrinsic::nvvm_idp2a_u_u,
true, E, *
this);