449 case NVPTX::BI__nvvm_atom_add_gen_i:
450 case NVPTX::BI__nvvm_atom_add_gen_l:
451 case NVPTX::BI__nvvm_atom_add_gen_ll:
453 AtomicOrdering::Monotonic);
455 case NVPTX::BI__nvvm_atom_sub_gen_i:
456 case NVPTX::BI__nvvm_atom_sub_gen_l:
457 case NVPTX::BI__nvvm_atom_sub_gen_ll:
459 AtomicOrdering::Monotonic);
461 case NVPTX::BI__nvvm_atom_and_gen_i:
462 case NVPTX::BI__nvvm_atom_and_gen_l:
463 case NVPTX::BI__nvvm_atom_and_gen_ll:
465 AtomicOrdering::Monotonic);
467 case NVPTX::BI__nvvm_atom_or_gen_i:
468 case NVPTX::BI__nvvm_atom_or_gen_l:
469 case NVPTX::BI__nvvm_atom_or_gen_ll:
471 AtomicOrdering::Monotonic);
473 case NVPTX::BI__nvvm_atom_xor_gen_i:
474 case NVPTX::BI__nvvm_atom_xor_gen_l:
475 case NVPTX::BI__nvvm_atom_xor_gen_ll:
477 AtomicOrdering::Monotonic);
479 case NVPTX::BI__nvvm_atom_xchg_gen_i:
480 case NVPTX::BI__nvvm_atom_xchg_gen_l:
481 case NVPTX::BI__nvvm_atom_xchg_gen_ll:
483 AtomicOrdering::Monotonic);
485 case NVPTX::BI__nvvm_atom_max_gen_i:
486 case NVPTX::BI__nvvm_atom_max_gen_l:
487 case NVPTX::BI__nvvm_atom_max_gen_ll:
489 AtomicOrdering::Monotonic);
491 case NVPTX::BI__nvvm_atom_max_gen_ui:
492 case NVPTX::BI__nvvm_atom_max_gen_ul:
493 case NVPTX::BI__nvvm_atom_max_gen_ull:
495 AtomicOrdering::Monotonic);
497 case NVPTX::BI__nvvm_atom_min_gen_i:
498 case NVPTX::BI__nvvm_atom_min_gen_l:
499 case NVPTX::BI__nvvm_atom_min_gen_ll:
501 AtomicOrdering::Monotonic);
503 case NVPTX::BI__nvvm_atom_min_gen_ui:
504 case NVPTX::BI__nvvm_atom_min_gen_ul:
505 case NVPTX::BI__nvvm_atom_min_gen_ull:
507 AtomicOrdering::Monotonic);
509 case NVPTX::BI__nvvm_atom_cas_gen_us:
510 case NVPTX::BI__nvvm_atom_cas_gen_i:
511 case NVPTX::BI__nvvm_atom_cas_gen_l:
512 case NVPTX::BI__nvvm_atom_cas_gen_ll:
516 AtomicOrdering::Monotonic,
517 AtomicOrdering::Monotonic);
519 case NVPTX::BI__nvvm_atom_add_gen_f:
520 case NVPTX::BI__nvvm_atom_add_gen_d: {
524 return Builder.CreateAtomicRMW(llvm::AtomicRMWInst::FAdd, DestAddr, Val,
525 AtomicOrdering::Monotonic);
528 case NVPTX::BI__nvvm_atom_inc_gen_ui:
530 AtomicOrdering::Monotonic);
532 case NVPTX::BI__nvvm_atom_dec_gen_ui:
534 AtomicOrdering::Monotonic);
536 case NVPTX::BI__nvvm_ldg_c:
537 case NVPTX::BI__nvvm_ldg_sc:
538 case NVPTX::BI__nvvm_ldg_c2:
539 case NVPTX::BI__nvvm_ldg_sc2:
540 case NVPTX::BI__nvvm_ldg_c4:
541 case NVPTX::BI__nvvm_ldg_sc4:
542 case NVPTX::BI__nvvm_ldg_s:
543 case NVPTX::BI__nvvm_ldg_s2:
544 case NVPTX::BI__nvvm_ldg_s4:
545 case NVPTX::BI__nvvm_ldg_i:
546 case NVPTX::BI__nvvm_ldg_i2:
547 case NVPTX::BI__nvvm_ldg_i4:
548 case NVPTX::BI__nvvm_ldg_l:
549 case NVPTX::BI__nvvm_ldg_l2:
550 case NVPTX::BI__nvvm_ldg_ll:
551 case NVPTX::BI__nvvm_ldg_ll2:
552 case NVPTX::BI__nvvm_ldg_uc:
553 case NVPTX::BI__nvvm_ldg_uc2:
554 case NVPTX::BI__nvvm_ldg_uc4:
555 case NVPTX::BI__nvvm_ldg_us:
556 case NVPTX::BI__nvvm_ldg_us2:
557 case NVPTX::BI__nvvm_ldg_us4:
558 case NVPTX::BI__nvvm_ldg_ui:
559 case NVPTX::BI__nvvm_ldg_ui2:
560 case NVPTX::BI__nvvm_ldg_ui4:
561 case NVPTX::BI__nvvm_ldg_ul:
562 case NVPTX::BI__nvvm_ldg_ul2:
563 case NVPTX::BI__nvvm_ldg_ull:
564 case NVPTX::BI__nvvm_ldg_ull2:
565 case NVPTX::BI__nvvm_ldg_f:
566 case NVPTX::BI__nvvm_ldg_f2:
567 case NVPTX::BI__nvvm_ldg_f4:
568 case NVPTX::BI__nvvm_ldg_d:
569 case NVPTX::BI__nvvm_ldg_d2:
573 return MakeLdg(*
this, E);
575 case NVPTX::BI__nvvm_ldu_c:
576 case NVPTX::BI__nvvm_ldu_sc:
577 case NVPTX::BI__nvvm_ldu_c2:
578 case NVPTX::BI__nvvm_ldu_sc2:
579 case NVPTX::BI__nvvm_ldu_c4:
580 case NVPTX::BI__nvvm_ldu_sc4:
581 case NVPTX::BI__nvvm_ldu_s:
582 case NVPTX::BI__nvvm_ldu_s2:
583 case NVPTX::BI__nvvm_ldu_s4:
584 case NVPTX::BI__nvvm_ldu_i:
585 case NVPTX::BI__nvvm_ldu_i2:
586 case NVPTX::BI__nvvm_ldu_i4:
587 case NVPTX::BI__nvvm_ldu_l:
588 case NVPTX::BI__nvvm_ldu_l2:
589 case NVPTX::BI__nvvm_ldu_ll:
590 case NVPTX::BI__nvvm_ldu_ll2:
591 case NVPTX::BI__nvvm_ldu_uc:
592 case NVPTX::BI__nvvm_ldu_uc2:
593 case NVPTX::BI__nvvm_ldu_uc4:
594 case NVPTX::BI__nvvm_ldu_us:
595 case NVPTX::BI__nvvm_ldu_us2:
596 case NVPTX::BI__nvvm_ldu_us4:
597 case NVPTX::BI__nvvm_ldu_ui:
598 case NVPTX::BI__nvvm_ldu_ui2:
599 case NVPTX::BI__nvvm_ldu_ui4:
600 case NVPTX::BI__nvvm_ldu_ul:
601 case NVPTX::BI__nvvm_ldu_ul2:
602 case NVPTX::BI__nvvm_ldu_ull:
603 case NVPTX::BI__nvvm_ldu_ull2:
604 return MakeLdu(Intrinsic::nvvm_ldu_global_i, *
this, E);
605 case NVPTX::BI__nvvm_ldu_f:
606 case NVPTX::BI__nvvm_ldu_f2:
607 case NVPTX::BI__nvvm_ldu_f4:
608 case NVPTX::BI__nvvm_ldu_d:
609 case NVPTX::BI__nvvm_ldu_d2:
610 return MakeLdu(Intrinsic::nvvm_ldu_global_f, *
this, E);
612 case NVPTX::BI__nvvm_atom_cta_add_gen_i:
613 case NVPTX::BI__nvvm_atom_cta_add_gen_l:
614 case NVPTX::BI__nvvm_atom_cta_add_gen_ll:
615 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Add,
616 llvm::AtomicScope::Workgroup);
617 case NVPTX::BI__nvvm_atom_sys_add_gen_i:
618 case NVPTX::BI__nvvm_atom_sys_add_gen_l:
619 case NVPTX::BI__nvvm_atom_sys_add_gen_ll:
620 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Add,
621 llvm::AtomicScope::System);
622 case NVPTX::BI__nvvm_atom_cta_add_gen_f:
623 case NVPTX::BI__nvvm_atom_cta_add_gen_d:
624 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::FAdd,
625 llvm::AtomicScope::Workgroup);
626 case NVPTX::BI__nvvm_atom_sys_add_gen_f:
627 case NVPTX::BI__nvvm_atom_sys_add_gen_d:
628 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::FAdd,
629 llvm::AtomicScope::System);
630 case NVPTX::BI__nvvm_atom_cta_xchg_gen_i:
631 case NVPTX::BI__nvvm_atom_cta_xchg_gen_l:
632 case NVPTX::BI__nvvm_atom_cta_xchg_gen_ll:
633 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Xchg,
634 llvm::AtomicScope::Workgroup);
635 case NVPTX::BI__nvvm_atom_sys_xchg_gen_i:
636 case NVPTX::BI__nvvm_atom_sys_xchg_gen_l:
637 case NVPTX::BI__nvvm_atom_sys_xchg_gen_ll:
638 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Xchg,
639 llvm::AtomicScope::System);
640 case NVPTX::BI__nvvm_atom_cta_max_gen_i:
641 case NVPTX::BI__nvvm_atom_cta_max_gen_l:
642 case NVPTX::BI__nvvm_atom_cta_max_gen_ll:
643 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Max,
644 llvm::AtomicScope::Workgroup);
645 case NVPTX::BI__nvvm_atom_cta_max_gen_ui:
646 case NVPTX::BI__nvvm_atom_cta_max_gen_ul:
647 case NVPTX::BI__nvvm_atom_cta_max_gen_ull:
648 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UMax,
649 llvm::AtomicScope::Workgroup);
650 case NVPTX::BI__nvvm_atom_sys_max_gen_i:
651 case NVPTX::BI__nvvm_atom_sys_max_gen_l:
652 case NVPTX::BI__nvvm_atom_sys_max_gen_ll:
653 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Max,
654 llvm::AtomicScope::System);
655 case NVPTX::BI__nvvm_atom_sys_max_gen_ui:
656 case NVPTX::BI__nvvm_atom_sys_max_gen_ul:
657 case NVPTX::BI__nvvm_atom_sys_max_gen_ull:
658 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UMax,
659 llvm::AtomicScope::System);
660 case NVPTX::BI__nvvm_atom_cta_min_gen_i:
661 case NVPTX::BI__nvvm_atom_cta_min_gen_l:
662 case NVPTX::BI__nvvm_atom_cta_min_gen_ll:
663 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Min,
664 llvm::AtomicScope::Workgroup);
665 case NVPTX::BI__nvvm_atom_cta_min_gen_ui:
666 case NVPTX::BI__nvvm_atom_cta_min_gen_ul:
667 case NVPTX::BI__nvvm_atom_cta_min_gen_ull:
668 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UMin,
669 llvm::AtomicScope::Workgroup);
670 case NVPTX::BI__nvvm_atom_sys_min_gen_i:
671 case NVPTX::BI__nvvm_atom_sys_min_gen_l:
672 case NVPTX::BI__nvvm_atom_sys_min_gen_ll:
673 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Min,
674 llvm::AtomicScope::System);
675 case NVPTX::BI__nvvm_atom_sys_min_gen_ui:
676 case NVPTX::BI__nvvm_atom_sys_min_gen_ul:
677 case NVPTX::BI__nvvm_atom_sys_min_gen_ull:
678 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UMin,
679 llvm::AtomicScope::System);
680 case NVPTX::BI__nvvm_atom_cta_inc_gen_ui:
681 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UIncWrap,
682 llvm::AtomicScope::Workgroup);
683 case NVPTX::BI__nvvm_atom_cta_dec_gen_ui:
684 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UDecWrap,
685 llvm::AtomicScope::Workgroup);
686 case NVPTX::BI__nvvm_atom_sys_inc_gen_ui:
687 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UIncWrap,
688 llvm::AtomicScope::System);
689 case NVPTX::BI__nvvm_atom_sys_dec_gen_ui:
690 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UDecWrap,
691 llvm::AtomicScope::System);
692 case NVPTX::BI__nvvm_atom_cta_and_gen_i:
693 case NVPTX::BI__nvvm_atom_cta_and_gen_l:
694 case NVPTX::BI__nvvm_atom_cta_and_gen_ll:
695 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::And,
696 llvm::AtomicScope::Workgroup);
697 case NVPTX::BI__nvvm_atom_sys_and_gen_i:
698 case NVPTX::BI__nvvm_atom_sys_and_gen_l:
699 case NVPTX::BI__nvvm_atom_sys_and_gen_ll:
700 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::And,
701 llvm::AtomicScope::System);
702 case NVPTX::BI__nvvm_atom_cta_or_gen_i:
703 case NVPTX::BI__nvvm_atom_cta_or_gen_l:
704 case NVPTX::BI__nvvm_atom_cta_or_gen_ll:
705 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Or,
706 llvm::AtomicScope::Workgroup);
707 case NVPTX::BI__nvvm_atom_sys_or_gen_i:
708 case NVPTX::BI__nvvm_atom_sys_or_gen_l:
709 case NVPTX::BI__nvvm_atom_sys_or_gen_ll:
710 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Or,
711 llvm::AtomicScope::System);
712 case NVPTX::BI__nvvm_atom_cta_xor_gen_i:
713 case NVPTX::BI__nvvm_atom_cta_xor_gen_l:
714 case NVPTX::BI__nvvm_atom_cta_xor_gen_ll:
715 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Xor,
716 llvm::AtomicScope::Workgroup);
717 case NVPTX::BI__nvvm_atom_sys_xor_gen_i:
718 case NVPTX::BI__nvvm_atom_sys_xor_gen_l:
719 case NVPTX::BI__nvvm_atom_sys_xor_gen_ll:
720 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Xor,
721 llvm::AtomicScope::System);
722 case NVPTX::BI__nvvm_atom_cta_cas_gen_us:
723 case NVPTX::BI__nvvm_atom_cta_cas_gen_i:
724 case NVPTX::BI__nvvm_atom_cta_cas_gen_l:
725 case NVPTX::BI__nvvm_atom_cta_cas_gen_ll:
726 return MakeScopedAtomicCAS(*
this, E, llvm::AtomicScope::Workgroup);
727 case NVPTX::BI__nvvm_atom_sys_cas_gen_us:
728 case NVPTX::BI__nvvm_atom_sys_cas_gen_i:
729 case NVPTX::BI__nvvm_atom_sys_cas_gen_l:
730 case NVPTX::BI__nvvm_atom_sys_cas_gen_ll:
731 return MakeScopedAtomicCAS(*
this, E, llvm::AtomicScope::System);
732 case NVPTX::BI__nvvm_match_all_sync_i32p:
733 case NVPTX::BI__nvvm_match_all_sync_i64p: {
738 CGM.getIntrinsic(BuiltinID == NVPTX::BI__nvvm_match_all_sync_i32p
739 ? Intrinsic::nvvm_match_all_sync_i32p
740 : Intrinsic::nvvm_match_all_sync_i64p),
744 Builder.CreateStore(Pred, PredOutPtr);
745 return Builder.CreateExtractValue(ResultPair, 0);
749 case NVPTX::BI__hmma_m16n16k16_ld_a:
750 case NVPTX::BI__hmma_m16n16k16_ld_b:
751 case NVPTX::BI__hmma_m16n16k16_ld_c_f16:
752 case NVPTX::BI__hmma_m16n16k16_ld_c_f32:
753 case NVPTX::BI__hmma_m32n8k16_ld_a:
754 case NVPTX::BI__hmma_m32n8k16_ld_b:
755 case NVPTX::BI__hmma_m32n8k16_ld_c_f16:
756 case NVPTX::BI__hmma_m32n8k16_ld_c_f32:
757 case NVPTX::BI__hmma_m8n32k16_ld_a:
758 case NVPTX::BI__hmma_m8n32k16_ld_b:
759 case NVPTX::BI__hmma_m8n32k16_ld_c_f16:
760 case NVPTX::BI__hmma_m8n32k16_ld_c_f32:
762 case NVPTX::BI__imma_m16n16k16_ld_a_s8:
763 case NVPTX::BI__imma_m16n16k16_ld_a_u8:
764 case NVPTX::BI__imma_m16n16k16_ld_b_s8:
765 case NVPTX::BI__imma_m16n16k16_ld_b_u8:
766 case NVPTX::BI__imma_m16n16k16_ld_c:
767 case NVPTX::BI__imma_m32n8k16_ld_a_s8:
768 case NVPTX::BI__imma_m32n8k16_ld_a_u8:
769 case NVPTX::BI__imma_m32n8k16_ld_b_s8:
770 case NVPTX::BI__imma_m32n8k16_ld_b_u8:
771 case NVPTX::BI__imma_m32n8k16_ld_c:
772 case NVPTX::BI__imma_m8n32k16_ld_a_s8:
773 case NVPTX::BI__imma_m8n32k16_ld_a_u8:
774 case NVPTX::BI__imma_m8n32k16_ld_b_s8:
775 case NVPTX::BI__imma_m8n32k16_ld_b_u8:
776 case NVPTX::BI__imma_m8n32k16_ld_c:
778 case NVPTX::BI__imma_m8n8k32_ld_a_s4:
779 case NVPTX::BI__imma_m8n8k32_ld_a_u4:
780 case NVPTX::BI__imma_m8n8k32_ld_b_s4:
781 case NVPTX::BI__imma_m8n8k32_ld_b_u4:
782 case NVPTX::BI__imma_m8n8k32_ld_c:
783 case NVPTX::BI__bmma_m8n8k128_ld_a_b1:
784 case NVPTX::BI__bmma_m8n8k128_ld_b_b1:
785 case NVPTX::BI__bmma_m8n8k128_ld_c:
787 case NVPTX::BI__dmma_m8n8k4_ld_a:
788 case NVPTX::BI__dmma_m8n8k4_ld_b:
789 case NVPTX::BI__dmma_m8n8k4_ld_c:
791 case NVPTX::BI__mma_bf16_m16n16k16_ld_a:
792 case NVPTX::BI__mma_bf16_m16n16k16_ld_b:
793 case NVPTX::BI__mma_bf16_m8n32k16_ld_a:
794 case NVPTX::BI__mma_bf16_m8n32k16_ld_b:
795 case NVPTX::BI__mma_bf16_m32n8k16_ld_a:
796 case NVPTX::BI__mma_bf16_m32n8k16_ld_b:
797 case NVPTX::BI__mma_tf32_m16n16k8_ld_a:
798 case NVPTX::BI__mma_tf32_m16n16k8_ld_b:
799 case NVPTX::BI__mma_tf32_m16n16k8_ld_c: {
803 std::optional<llvm::APSInt> isColMajorArg =
807 bool isColMajor = isColMajorArg->getSExtValue();
808 NVPTXMmaLdstInfo II = getNVPTXMmaLdstInfo(BuiltinID);
809 unsigned IID = isColMajor ? II.IID_col : II.IID_row;
817 assert(II.NumResults);
818 if (II.NumResults == 1) {
822 for (
unsigned i = 0; i < II.NumResults; ++i) {
827 llvm::ConstantInt::get(
IntTy, i)),
834 case NVPTX::BI__hmma_m16n16k16_st_c_f16:
835 case NVPTX::BI__hmma_m16n16k16_st_c_f32:
836 case NVPTX::BI__hmma_m32n8k16_st_c_f16:
837 case NVPTX::BI__hmma_m32n8k16_st_c_f32:
838 case NVPTX::BI__hmma_m8n32k16_st_c_f16:
839 case NVPTX::BI__hmma_m8n32k16_st_c_f32:
840 case NVPTX::BI__imma_m16n16k16_st_c_i32:
841 case NVPTX::BI__imma_m32n8k16_st_c_i32:
842 case NVPTX::BI__imma_m8n32k16_st_c_i32:
843 case NVPTX::BI__imma_m8n8k32_st_c_i32:
844 case NVPTX::BI__bmma_m8n8k128_st_c_i32:
845 case NVPTX::BI__dmma_m8n8k4_st_c_f64:
846 case NVPTX::BI__mma_m16n16k8_st_c_f32: {
850 std::optional<llvm::APSInt> isColMajorArg =
854 bool isColMajor = isColMajorArg->getSExtValue();
855 NVPTXMmaLdstInfo II = getNVPTXMmaLdstInfo(BuiltinID);
856 unsigned IID = isColMajor ? II.IID_col : II.IID_row;
861 llvm::Type *ParamType = Intrinsic->getFunctionType()->getParamType(1);
863 for (
unsigned i = 0; i < II.NumResults; ++i) {
867 llvm::ConstantInt::get(
IntTy, i)),
869 Values.push_back(
Builder.CreateBitCast(
V, ParamType));
871 Values.push_back(Ldm);
878 case NVPTX::BI__hmma_m16n16k16_mma_f16f16:
879 case NVPTX::BI__hmma_m16n16k16_mma_f32f16:
880 case NVPTX::BI__hmma_m16n16k16_mma_f32f32:
881 case NVPTX::BI__hmma_m16n16k16_mma_f16f32:
882 case NVPTX::BI__hmma_m32n8k16_mma_f16f16:
883 case NVPTX::BI__hmma_m32n8k16_mma_f32f16:
884 case NVPTX::BI__hmma_m32n8k16_mma_f32f32:
885 case NVPTX::BI__hmma_m32n8k16_mma_f16f32:
886 case NVPTX::BI__hmma_m8n32k16_mma_f16f16:
887 case NVPTX::BI__hmma_m8n32k16_mma_f32f16:
888 case NVPTX::BI__hmma_m8n32k16_mma_f32f32:
889 case NVPTX::BI__hmma_m8n32k16_mma_f16f32:
890 case NVPTX::BI__imma_m16n16k16_mma_s8:
891 case NVPTX::BI__imma_m16n16k16_mma_u8:
892 case NVPTX::BI__imma_m32n8k16_mma_s8:
893 case NVPTX::BI__imma_m32n8k16_mma_u8:
894 case NVPTX::BI__imma_m8n32k16_mma_s8:
895 case NVPTX::BI__imma_m8n32k16_mma_u8:
896 case NVPTX::BI__imma_m8n8k32_mma_s4:
897 case NVPTX::BI__imma_m8n8k32_mma_u4:
898 case NVPTX::BI__bmma_m8n8k128_mma_xor_popc_b1:
899 case NVPTX::BI__bmma_m8n8k128_mma_and_popc_b1:
900 case NVPTX::BI__dmma_m8n8k4_mma_f64:
901 case NVPTX::BI__mma_bf16_m16n16k16_mma_f32:
902 case NVPTX::BI__mma_bf16_m8n32k16_mma_f32:
903 case NVPTX::BI__mma_bf16_m32n8k16_mma_f32:
904 case NVPTX::BI__mma_tf32_m16n16k8_mma_f32: {
909 std::optional<llvm::APSInt> LayoutArg =
913 int Layout = LayoutArg->getSExtValue();
914 if (Layout < 0 || Layout > 3)
916 llvm::APSInt SatfArg;
917 if (BuiltinID == NVPTX::BI__bmma_m8n8k128_mma_xor_popc_b1 ||
918 BuiltinID == NVPTX::BI__bmma_m8n8k128_mma_and_popc_b1)
920 else if (std::optional<llvm::APSInt> OptSatfArg =
922 SatfArg = *OptSatfArg;
925 bool Satf = SatfArg.getSExtValue();
926 NVPTXMmaInfo MI = getNVPTXMmaInfo(BuiltinID);
927 unsigned IID = MI.getMMAIntrinsic(Layout, Satf);
933 llvm::Type *AType = Intrinsic->getFunctionType()->getParamType(0);
935 for (
unsigned i = 0; i < MI.NumEltsA; ++i) {
939 llvm::ConstantInt::get(
IntTy, i)),
941 Values.push_back(
Builder.CreateBitCast(
V, AType));
944 llvm::Type *BType = Intrinsic->getFunctionType()->getParamType(MI.NumEltsA);
945 for (
unsigned i = 0; i < MI.NumEltsB; ++i) {
949 llvm::ConstantInt::get(
IntTy, i)),
951 Values.push_back(
Builder.CreateBitCast(
V, BType));
955 Intrinsic->getFunctionType()->getParamType(MI.NumEltsA + MI.NumEltsB);
956 for (
unsigned i = 0; i < MI.NumEltsC; ++i) {
960 llvm::ConstantInt::get(
IntTy, i)),
962 Values.push_back(
Builder.CreateBitCast(
V, CType));
966 for (
unsigned i = 0; i < MI.NumEltsD; ++i)
970 llvm::ConstantInt::get(
IntTy, i)),
975 case NVPTX::BI__nvvm_ex2_approx_f16:
977 CGM.getIntrinsic(Intrinsic::nvvm_ex2_approx,
Builder.getHalfTy()),
978 BuiltinID, E, *
this);
979 case NVPTX::BI__nvvm_ex2_approx_f16x2:
981 CGM.getIntrinsic(Intrinsic::nvvm_ex2_approx,
982 FixedVectorType::get(
Builder.getHalfTy(), 2)),
983 BuiltinID, E, *
this);
984 case NVPTX::BI__nvvm_ff2f16x2_rn:
985 return MakeHalfType(Intrinsic::nvvm_ff2f16x2_rn, BuiltinID, E, *
this);
986 case NVPTX::BI__nvvm_ff2f16x2_rn_relu:
987 return MakeHalfType(Intrinsic::nvvm_ff2f16x2_rn_relu, BuiltinID, E, *
this);
988 case NVPTX::BI__nvvm_ff2f16x2_rz:
989 return MakeHalfType(Intrinsic::nvvm_ff2f16x2_rz, BuiltinID, E, *
this);
990 case NVPTX::BI__nvvm_ff2f16x2_rz_relu:
991 return MakeHalfType(Intrinsic::nvvm_ff2f16x2_rz_relu, BuiltinID, E, *
this);
993#define PZO_CVT(cvt) \
994 case NVPTX::BI__nvvm_##cvt##_pzo: \
995 return MakeHalfType(Intrinsic::nvvm_##cvt, BuiltinID, E, *this, \
1002 PZO_CVT(ff2f16x2_rn_satfinite);
1003 PZO_CVT(ff2f16x2_rn_relu_satfinite);
1004 PZO_CVT(ff2f16x2_rz_satfinite);
1005 PZO_CVT(ff2f16x2_rz_relu_satfinite);
1010 PZO_CVT(ff2bf16x2_rn_satfinite);
1011 PZO_CVT(ff2bf16x2_rn_relu_satfinite);
1012 PZO_CVT(ff2bf16x2_rz_satfinite);
1013 PZO_CVT(ff2bf16x2_rz_relu_satfinite);
1019 PZO_CVT(f2f16_rn_relu_satfinite);
1021 PZO_CVT(f2f16_rz_relu_satfinite);
1027 PZO_CVT(f2bf16_rn_relu_satfinite);
1029 PZO_CVT(f2bf16_rz_relu_satfinite);
1033 case NVPTX::BI__nvvm_fma_rn_f16:
1034 return MakeHalfType(Intrinsic::nvvm_fma_rn_f16, BuiltinID, E, *
this);
1035 case NVPTX::BI__nvvm_fma_rn_f16x2:
1036 return MakeHalfType(Intrinsic::nvvm_fma_rn_f16x2, BuiltinID, E, *
this);
1037 case NVPTX::BI__nvvm_fma_rn_ftz_f16:
1038 return MakeHalfType(Intrinsic::nvvm_fma_rn_ftz_f16, BuiltinID, E, *
this);
1039 case NVPTX::BI__nvvm_fma_rn_ftz_f16x2:
1040 return MakeHalfType(Intrinsic::nvvm_fma_rn_ftz_f16x2, BuiltinID, E, *
this);
1041 case NVPTX::BI__nvvm_fma_rn_ftz_relu_f16:
1042 return MakeHalfType(Intrinsic::nvvm_fma_rn_ftz_relu_f16, BuiltinID, E,
1044 case NVPTX::BI__nvvm_fma_rn_ftz_relu_f16x2:
1045 return MakeHalfType(Intrinsic::nvvm_fma_rn_ftz_relu_f16x2, BuiltinID, E,
1047 case NVPTX::BI__nvvm_fma_rn_ftz_sat_f16:
1048 return MakeHalfType(Intrinsic::nvvm_fma_rn_ftz_sat_f16, BuiltinID, E,
1050 case NVPTX::BI__nvvm_fma_rn_ftz_sat_f16x2:
1051 return MakeHalfType(Intrinsic::nvvm_fma_rn_ftz_sat_f16x2, BuiltinID, E,
1053 case NVPTX::BI__nvvm_fma_rn_relu_f16:
1054 return MakeHalfType(Intrinsic::nvvm_fma_rn_relu_f16, BuiltinID, E, *
this);
1055 case NVPTX::BI__nvvm_fma_rn_relu_f16x2:
1056 return MakeHalfType(Intrinsic::nvvm_fma_rn_relu_f16x2, BuiltinID, E, *
this);
1057 case NVPTX::BI__nvvm_fma_rn_sat_f16:
1058 return MakeHalfType(Intrinsic::nvvm_fma_rn_sat_f16, BuiltinID, E, *
this);
1059 case NVPTX::BI__nvvm_fma_rn_sat_f16x2:
1060 return MakeHalfType(Intrinsic::nvvm_fma_rn_sat_f16x2, BuiltinID, E, *
this);
1061 case NVPTX::BI__nvvm_fma_rn_oob_f16:
1062 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob,
Builder.getHalfTy(), E,
1064 case NVPTX::BI__nvvm_fma_rn_oob_f16x2:
1065 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob,
1066 llvm::FixedVectorType::get(
Builder.getHalfTy(), 2), E,
1068 case NVPTX::BI__nvvm_fma_rn_oob_bf16:
1069 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob,
Builder.getBFloatTy(), E,
1071 case NVPTX::BI__nvvm_fma_rn_oob_bf16x2:
1072 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob,
1073 llvm::FixedVectorType::get(
Builder.getBFloatTy(), 2), E,
1075 case NVPTX::BI__nvvm_fma_rn_oob_relu_f16:
1076 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob_relu,
Builder.getHalfTy(), E,
1078 case NVPTX::BI__nvvm_fma_rn_oob_relu_f16x2:
1079 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob_relu,
1080 llvm::FixedVectorType::get(
Builder.getHalfTy(), 2), E,
1082 case NVPTX::BI__nvvm_fma_rn_oob_relu_bf16:
1083 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob_relu,
Builder.getBFloatTy(), E,
1085 case NVPTX::BI__nvvm_fma_rn_oob_relu_bf16x2:
1086 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob_relu,
1087 llvm::FixedVectorType::get(
Builder.getBFloatTy(), 2), E,
1089 case NVPTX::BI__nvvm_fmax_f16:
1090 return MakeHalfType(Intrinsic::nvvm_fmax_f16, BuiltinID, E, *
this);
1091 case NVPTX::BI__nvvm_fmax_f16x2:
1092 return MakeHalfType(Intrinsic::nvvm_fmax_f16x2, BuiltinID, E, *
this);
1093 case NVPTX::BI__nvvm_fmax_ftz_f16:
1094 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_f16, BuiltinID, E, *
this);
1095 case NVPTX::BI__nvvm_fmax_ftz_f16x2:
1096 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_f16x2, BuiltinID, E, *
this);
1097 case NVPTX::BI__nvvm_fmax_ftz_nan_f16:
1098 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_nan_f16, BuiltinID, E, *
this);
1099 case NVPTX::BI__nvvm_fmax_ftz_nan_f16x2:
1100 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_nan_f16x2, BuiltinID, E,
1102 case NVPTX::BI__nvvm_fmax_ftz_nan_xorsign_abs_f16:
1103 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_nan_xorsign_abs_f16, BuiltinID,
1105 case NVPTX::BI__nvvm_fmax_ftz_nan_xorsign_abs_f16x2:
1106 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_nan_xorsign_abs_f16x2,
1107 BuiltinID, E, *
this);
1108 case NVPTX::BI__nvvm_fmax_ftz_xorsign_abs_f16:
1109 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_xorsign_abs_f16, BuiltinID, E,
1111 case NVPTX::BI__nvvm_fmax_ftz_xorsign_abs_f16x2:
1112 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_xorsign_abs_f16x2, BuiltinID,
1114 case NVPTX::BI__nvvm_fmax_nan_f16:
1115 return MakeHalfType(Intrinsic::nvvm_fmax_nan_f16, BuiltinID, E, *
this);
1116 case NVPTX::BI__nvvm_fmax_nan_f16x2:
1117 return MakeHalfType(Intrinsic::nvvm_fmax_nan_f16x2, BuiltinID, E, *
this);
1118 case NVPTX::BI__nvvm_fmax_nan_xorsign_abs_f16:
1119 return MakeHalfType(Intrinsic::nvvm_fmax_nan_xorsign_abs_f16, BuiltinID, E,
1121 case NVPTX::BI__nvvm_fmax_nan_xorsign_abs_f16x2:
1122 return MakeHalfType(Intrinsic::nvvm_fmax_nan_xorsign_abs_f16x2, BuiltinID,
1124 case NVPTX::BI__nvvm_fmax_xorsign_abs_f16:
1125 return MakeHalfType(Intrinsic::nvvm_fmax_xorsign_abs_f16, BuiltinID, E,
1127 case NVPTX::BI__nvvm_fmax_xorsign_abs_f16x2:
1128 return MakeHalfType(Intrinsic::nvvm_fmax_xorsign_abs_f16x2, BuiltinID, E,
1130 case NVPTX::BI__nvvm_fmin_f16:
1131 return MakeHalfType(Intrinsic::nvvm_fmin_f16, BuiltinID, E, *
this);
1132 case NVPTX::BI__nvvm_fmin_f16x2:
1133 return MakeHalfType(Intrinsic::nvvm_fmin_f16x2, BuiltinID, E, *
this);
1134 case NVPTX::BI__nvvm_fmin_ftz_f16:
1135 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_f16, BuiltinID, E, *
this);
1136 case NVPTX::BI__nvvm_fmin_ftz_f16x2:
1137 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_f16x2, BuiltinID, E, *
this);
1138 case NVPTX::BI__nvvm_fmin_ftz_nan_f16:
1139 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_nan_f16, BuiltinID, E, *
this);
1140 case NVPTX::BI__nvvm_fmin_ftz_nan_f16x2:
1141 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_nan_f16x2, BuiltinID, E,
1143 case NVPTX::BI__nvvm_fmin_ftz_nan_xorsign_abs_f16:
1144 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_nan_xorsign_abs_f16, BuiltinID,
1146 case NVPTX::BI__nvvm_fmin_ftz_nan_xorsign_abs_f16x2:
1147 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_nan_xorsign_abs_f16x2,
1148 BuiltinID, E, *
this);
1149 case NVPTX::BI__nvvm_fmin_ftz_xorsign_abs_f16:
1150 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_xorsign_abs_f16, BuiltinID, E,
1152 case NVPTX::BI__nvvm_fmin_ftz_xorsign_abs_f16x2:
1153 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_xorsign_abs_f16x2, BuiltinID,
1155 case NVPTX::BI__nvvm_fmin_nan_f16:
1156 return MakeHalfType(Intrinsic::nvvm_fmin_nan_f16, BuiltinID, E, *
this);
1157 case NVPTX::BI__nvvm_fmin_nan_f16x2:
1158 return MakeHalfType(Intrinsic::nvvm_fmin_nan_f16x2, BuiltinID, E, *
this);
1159 case NVPTX::BI__nvvm_fmin_nan_xorsign_abs_f16:
1160 return MakeHalfType(Intrinsic::nvvm_fmin_nan_xorsign_abs_f16, BuiltinID, E,
1162 case NVPTX::BI__nvvm_fmin_nan_xorsign_abs_f16x2:
1163 return MakeHalfType(Intrinsic::nvvm_fmin_nan_xorsign_abs_f16x2, BuiltinID,
1165 case NVPTX::BI__nvvm_fmin_xorsign_abs_f16:
1166 return MakeHalfType(Intrinsic::nvvm_fmin_xorsign_abs_f16, BuiltinID, E,
1168 case NVPTX::BI__nvvm_fmin_xorsign_abs_f16x2:
1169 return MakeHalfType(Intrinsic::nvvm_fmin_xorsign_abs_f16x2, BuiltinID, E,
1171 case NVPTX::BI__nvvm_fabs_f:
1172 case NVPTX::BI__nvvm_abs_bf16:
1173 case NVPTX::BI__nvvm_abs_bf16x2:
1174 case NVPTX::BI__nvvm_fabs_f16:
1175 case NVPTX::BI__nvvm_fabs_f16x2:
1176 return Builder.CreateUnaryIntrinsic(Intrinsic::nvvm_fabs,
1178 case NVPTX::BI__nvvm_fabs_ftz_f:
1179 case NVPTX::BI__nvvm_fabs_ftz_f16:
1180 case NVPTX::BI__nvvm_fabs_ftz_f16x2:
1181 return Builder.CreateUnaryIntrinsic(Intrinsic::nvvm_fabs_ftz,
1183 case NVPTX::BI__nvvm_fabs_d:
1185 case NVPTX::BI__nvvm_ex2_approx_d:
1186 case NVPTX::BI__nvvm_ex2_approx_f:
1187 return Builder.CreateUnaryIntrinsic(Intrinsic::nvvm_ex2_approx,
1189 case NVPTX::BI__nvvm_ex2_approx_ftz_f:
1190 return Builder.CreateUnaryIntrinsic(Intrinsic::nvvm_ex2_approx_ftz,
1192 case NVPTX::BI__nvvm_add_rn_f:
1193 case NVPTX::BI__nvvm_add_rn_d:
1194 return MakeFAdd(Intrinsic::nvvm_fadd, APFloat::rmNearestTiesToEven,
1195 BuiltinID, E, *
this);
1196 case NVPTX::BI__nvvm_add_rz_f:
1197 case NVPTX::BI__nvvm_add_rz_d:
1198 return MakeFAdd(Intrinsic::nvvm_fadd, APFloat::rmTowardZero, BuiltinID, E,
1200 case NVPTX::BI__nvvm_add_rm_f:
1201 case NVPTX::BI__nvvm_add_rm_d:
1202 return MakeFAdd(Intrinsic::nvvm_fadd, APFloat::rmTowardNegative, BuiltinID,
1204 case NVPTX::BI__nvvm_add_rp_f:
1205 case NVPTX::BI__nvvm_add_rp_d:
1206 return MakeFAdd(Intrinsic::nvvm_fadd, APFloat::rmTowardPositive, BuiltinID,
1208 case NVPTX::BI__nvvm_add_rn_ftz_f:
1209 return MakeFAdd(Intrinsic::nvvm_fadd_ftz, APFloat::rmNearestTiesToEven,
1210 BuiltinID, E, *
this);
1211 case NVPTX::BI__nvvm_add_rz_ftz_f:
1212 return MakeFAdd(Intrinsic::nvvm_fadd_ftz, APFloat::rmTowardZero, BuiltinID,
1214 case NVPTX::BI__nvvm_add_rm_ftz_f:
1215 return MakeFAdd(Intrinsic::nvvm_fadd_ftz, APFloat::rmTowardNegative,
1216 BuiltinID, E, *
this);
1217 case NVPTX::BI__nvvm_add_rp_ftz_f:
1218 return MakeFAdd(Intrinsic::nvvm_fadd_ftz, APFloat::rmTowardPositive,
1219 BuiltinID, E, *
this);
1220 case NVPTX::BI__nvvm_add_rn_sat_f:
1221 case NVPTX::BI__nvvm_add_rn_sat_f16:
1222 case NVPTX::BI__nvvm_add_rn_sat_v2f16:
1223 return MakeFAdd(Intrinsic::nvvm_fadd_sat, APFloat::rmNearestTiesToEven,
1224 BuiltinID, E, *
this);
1225 case NVPTX::BI__nvvm_add_rz_sat_f:
1226 return MakeFAdd(Intrinsic::nvvm_fadd_sat, APFloat::rmTowardZero, BuiltinID,
1228 case NVPTX::BI__nvvm_add_rm_sat_f:
1229 return MakeFAdd(Intrinsic::nvvm_fadd_sat, APFloat::rmTowardNegative,
1230 BuiltinID, E, *
this);
1231 case NVPTX::BI__nvvm_add_rp_sat_f:
1232 return MakeFAdd(Intrinsic::nvvm_fadd_sat, APFloat::rmTowardPositive,
1233 BuiltinID, E, *
this);
1234 case NVPTX::BI__nvvm_add_rn_ftz_sat_f:
1235 case NVPTX::BI__nvvm_add_rn_ftz_sat_f16:
1236 case NVPTX::BI__nvvm_add_rn_ftz_sat_v2f16:
1237 return MakeFAdd(Intrinsic::nvvm_fadd_ftz_sat, APFloat::rmNearestTiesToEven,
1238 BuiltinID, E, *
this);
1239 case NVPTX::BI__nvvm_add_rz_ftz_sat_f:
1240 return MakeFAdd(Intrinsic::nvvm_fadd_ftz_sat, APFloat::rmTowardZero,
1241 BuiltinID, E, *
this);
1242 case NVPTX::BI__nvvm_add_rm_ftz_sat_f:
1243 return MakeFAdd(Intrinsic::nvvm_fadd_ftz_sat, APFloat::rmTowardNegative,
1244 BuiltinID, E, *
this);
1245 case NVPTX::BI__nvvm_add_rp_ftz_sat_f:
1246 return MakeFAdd(Intrinsic::nvvm_fadd_ftz_sat, APFloat::rmTowardPositive,
1247 BuiltinID, E, *
this);
1248 case NVPTX::BI__nvvm_ldg_h:
1249 case NVPTX::BI__nvvm_ldg_h2:
1250 return MakeLdg(*
this, E);
1251 case NVPTX::BI__nvvm_ldu_h:
1252 case NVPTX::BI__nvvm_ldu_h2:
1253 return MakeLdu(Intrinsic::nvvm_ldu_global_f, *
this, E);
1254 case NVPTX::BI__nvvm_cp_async_ca_shared_global_4:
1255 return MakeCpAsync(Intrinsic::nvvm_cp_async_ca_shared_global_4,
1256 Intrinsic::nvvm_cp_async_ca_shared_global_4_s, *
this, E,
1258 case NVPTX::BI__nvvm_cp_async_ca_shared_global_8:
1259 return MakeCpAsync(Intrinsic::nvvm_cp_async_ca_shared_global_8,
1260 Intrinsic::nvvm_cp_async_ca_shared_global_8_s, *
this, E,
1262 case NVPTX::BI__nvvm_cp_async_ca_shared_global_16:
1263 return MakeCpAsync(Intrinsic::nvvm_cp_async_ca_shared_global_16,
1264 Intrinsic::nvvm_cp_async_ca_shared_global_16_s, *
this, E,
1266 case NVPTX::BI__nvvm_cp_async_cg_shared_global_16:
1267 return MakeCpAsync(Intrinsic::nvvm_cp_async_cg_shared_global_16,
1268 Intrinsic::nvvm_cp_async_cg_shared_global_16_s, *
this, E,
1270 case NVPTX::BI__nvvm_read_ptx_sreg_clusterid_x:
1272 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_clusterid_x));
1273 case NVPTX::BI__nvvm_read_ptx_sreg_clusterid_y:
1275 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_clusterid_y));
1276 case NVPTX::BI__nvvm_read_ptx_sreg_clusterid_z:
1278 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_clusterid_z));
1279 case NVPTX::BI__nvvm_read_ptx_sreg_clusterid_w:
1281 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_clusterid_w));
1282 case NVPTX::BI__nvvm_read_ptx_sreg_nclusterid_x:
1284 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_nclusterid_x));
1285 case NVPTX::BI__nvvm_read_ptx_sreg_nclusterid_y:
1287 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_nclusterid_y));
1288 case NVPTX::BI__nvvm_read_ptx_sreg_nclusterid_z:
1290 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_nclusterid_z));
1291 case NVPTX::BI__nvvm_read_ptx_sreg_nclusterid_w:
1293 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_nclusterid_w));
1294 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_ctaid_x:
1296 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_ctaid_x));
1297 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_ctaid_y:
1299 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_ctaid_y));
1300 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_ctaid_z:
1302 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_ctaid_z));
1303 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_ctaid_w:
1305 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_ctaid_w));
1306 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_nctaid_x:
1308 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_nctaid_x));
1309 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_nctaid_y:
1311 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_nctaid_y));
1312 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_nctaid_z:
1314 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_nctaid_z));
1315 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_nctaid_w:
1317 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_nctaid_w));
1318 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_ctarank:
1320 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_ctarank));
1321 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_nctarank:
1323 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_nctarank));
1324 case NVPTX::BI__nvvm_is_explicit_cluster:
1326 CGM.getIntrinsic(Intrinsic::nvvm_is_explicit_cluster));
1327 case NVPTX::BI__nvvm_isspacep_shared_cluster:
1329 CGM.getIntrinsic(Intrinsic::nvvm_isspacep_shared_cluster),
1331 case NVPTX::BI__nvvm_mapa:
1333 CGM.getIntrinsic(Intrinsic::nvvm_mapa),
1334 {EmitScalarExpr(E->getArg(0)), EmitScalarExpr(E->getArg(1))});
1335 case NVPTX::BI__nvvm_mapa_shared_cluster:
1337 CGM.getIntrinsic(Intrinsic::nvvm_mapa_shared_cluster),
1338 {EmitScalarExpr(E->getArg(0)), EmitScalarExpr(E->getArg(1))});
1339 case NVPTX::BI__nvvm_getctarank:
1341 CGM.getIntrinsic(Intrinsic::nvvm_getctarank),
1343 case NVPTX::BI__nvvm_getctarank_shared_cluster:
1345 CGM.getIntrinsic(Intrinsic::nvvm_getctarank_shared_cluster),
1347 case NVPTX::BI__nvvm_barrier_cluster_arrive:
1349 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cluster_arrive));
1350 case NVPTX::BI__nvvm_barrier_cluster_arrive_relaxed:
1352 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cluster_arrive_relaxed));
1353 case NVPTX::BI__nvvm_barrier_cluster_wait:
1355 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cluster_wait));
1356 case NVPTX::BI__nvvm_fence_sc_cluster:
1358 CGM.getIntrinsic(Intrinsic::nvvm_fence_sc_cluster));
1359 case NVPTX::BI__nvvm_bar_sync:
1361 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cta_sync_aligned_all),
1363 case NVPTX::BI__syncthreads:
1365 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cta_sync_aligned_all),
1367 case NVPTX::BI__nvvm_barrier_sync:
1369 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cta_sync_all),
1371 case NVPTX::BI__nvvm_barrier_sync_cnt:
1373 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cta_sync_count),
1374 {EmitScalarExpr(E->getArg(0)), EmitScalarExpr(E->getArg(1))});
1375 case NVPTX::BI__nvvm_bar0_and:
1378 Intrinsic::nvvm_barrier_cta_red_and_aligned_all, {},
1379 {Builder.getInt32(0),
1380 Builder.CreateICmpNE(EmitScalarExpr(E->getArg(0)),
1381 Builder.getInt32(0))}),
1383 case NVPTX::BI__nvvm_bar0_or:
1386 Intrinsic::nvvm_barrier_cta_red_or_aligned_all, {},
1387 {Builder.getInt32(0),
1388 Builder.CreateICmpNE(EmitScalarExpr(E->getArg(0)),
1389 Builder.getInt32(0))}),
1391 case NVPTX::BI__nvvm_bar0_popc:
1392 return Builder.CreateIntrinsic(
1393 Intrinsic::nvvm_barrier_cta_red_popc_aligned_all, {},
1396 case NVPTX::BI__nvvm_mbarrier_init:
1397 case NVPTX::BI__nvvm_mbarrier_init_shared: {
1401 return Builder.CreateIntrinsic(
1402 Intrinsic::nvvm_mbarrier_init, {Ptr->getType()},