435 case NVPTX::BI__nvvm_atom_add_gen_i:
436 case NVPTX::BI__nvvm_atom_add_gen_l:
437 case NVPTX::BI__nvvm_atom_add_gen_ll:
439 AtomicOrdering::Monotonic);
441 case NVPTX::BI__nvvm_atom_sub_gen_i:
442 case NVPTX::BI__nvvm_atom_sub_gen_l:
443 case NVPTX::BI__nvvm_atom_sub_gen_ll:
445 AtomicOrdering::Monotonic);
447 case NVPTX::BI__nvvm_atom_and_gen_i:
448 case NVPTX::BI__nvvm_atom_and_gen_l:
449 case NVPTX::BI__nvvm_atom_and_gen_ll:
451 AtomicOrdering::Monotonic);
453 case NVPTX::BI__nvvm_atom_or_gen_i:
454 case NVPTX::BI__nvvm_atom_or_gen_l:
455 case NVPTX::BI__nvvm_atom_or_gen_ll:
457 AtomicOrdering::Monotonic);
459 case NVPTX::BI__nvvm_atom_xor_gen_i:
460 case NVPTX::BI__nvvm_atom_xor_gen_l:
461 case NVPTX::BI__nvvm_atom_xor_gen_ll:
463 AtomicOrdering::Monotonic);
465 case NVPTX::BI__nvvm_atom_xchg_gen_i:
466 case NVPTX::BI__nvvm_atom_xchg_gen_l:
467 case NVPTX::BI__nvvm_atom_xchg_gen_ll:
469 AtomicOrdering::Monotonic);
471 case NVPTX::BI__nvvm_atom_max_gen_i:
472 case NVPTX::BI__nvvm_atom_max_gen_l:
473 case NVPTX::BI__nvvm_atom_max_gen_ll:
475 AtomicOrdering::Monotonic);
477 case NVPTX::BI__nvvm_atom_max_gen_ui:
478 case NVPTX::BI__nvvm_atom_max_gen_ul:
479 case NVPTX::BI__nvvm_atom_max_gen_ull:
481 AtomicOrdering::Monotonic);
483 case NVPTX::BI__nvvm_atom_min_gen_i:
484 case NVPTX::BI__nvvm_atom_min_gen_l:
485 case NVPTX::BI__nvvm_atom_min_gen_ll:
487 AtomicOrdering::Monotonic);
489 case NVPTX::BI__nvvm_atom_min_gen_ui:
490 case NVPTX::BI__nvvm_atom_min_gen_ul:
491 case NVPTX::BI__nvvm_atom_min_gen_ull:
493 AtomicOrdering::Monotonic);
495 case NVPTX::BI__nvvm_atom_cas_gen_us:
496 case NVPTX::BI__nvvm_atom_cas_gen_i:
497 case NVPTX::BI__nvvm_atom_cas_gen_l:
498 case NVPTX::BI__nvvm_atom_cas_gen_ll:
502 AtomicOrdering::Monotonic,
503 AtomicOrdering::Monotonic);
505 case NVPTX::BI__nvvm_atom_add_gen_f:
506 case NVPTX::BI__nvvm_atom_add_gen_d: {
510 return Builder.CreateAtomicRMW(llvm::AtomicRMWInst::FAdd, DestAddr, Val,
511 AtomicOrdering::Monotonic);
514 case NVPTX::BI__nvvm_atom_inc_gen_ui:
516 AtomicOrdering::Monotonic);
518 case NVPTX::BI__nvvm_atom_dec_gen_ui:
520 AtomicOrdering::Monotonic);
522 case NVPTX::BI__nvvm_ldg_c:
523 case NVPTX::BI__nvvm_ldg_sc:
524 case NVPTX::BI__nvvm_ldg_c2:
525 case NVPTX::BI__nvvm_ldg_sc2:
526 case NVPTX::BI__nvvm_ldg_c4:
527 case NVPTX::BI__nvvm_ldg_sc4:
528 case NVPTX::BI__nvvm_ldg_s:
529 case NVPTX::BI__nvvm_ldg_s2:
530 case NVPTX::BI__nvvm_ldg_s4:
531 case NVPTX::BI__nvvm_ldg_i:
532 case NVPTX::BI__nvvm_ldg_i2:
533 case NVPTX::BI__nvvm_ldg_i4:
534 case NVPTX::BI__nvvm_ldg_l:
535 case NVPTX::BI__nvvm_ldg_l2:
536 case NVPTX::BI__nvvm_ldg_ll:
537 case NVPTX::BI__nvvm_ldg_ll2:
538 case NVPTX::BI__nvvm_ldg_uc:
539 case NVPTX::BI__nvvm_ldg_uc2:
540 case NVPTX::BI__nvvm_ldg_uc4:
541 case NVPTX::BI__nvvm_ldg_us:
542 case NVPTX::BI__nvvm_ldg_us2:
543 case NVPTX::BI__nvvm_ldg_us4:
544 case NVPTX::BI__nvvm_ldg_ui:
545 case NVPTX::BI__nvvm_ldg_ui2:
546 case NVPTX::BI__nvvm_ldg_ui4:
547 case NVPTX::BI__nvvm_ldg_ul:
548 case NVPTX::BI__nvvm_ldg_ul2:
549 case NVPTX::BI__nvvm_ldg_ull:
550 case NVPTX::BI__nvvm_ldg_ull2:
551 case NVPTX::BI__nvvm_ldg_f:
552 case NVPTX::BI__nvvm_ldg_f2:
553 case NVPTX::BI__nvvm_ldg_f4:
554 case NVPTX::BI__nvvm_ldg_d:
555 case NVPTX::BI__nvvm_ldg_d2:
559 return MakeLdg(*
this, E);
561 case NVPTX::BI__nvvm_ldu_c:
562 case NVPTX::BI__nvvm_ldu_sc:
563 case NVPTX::BI__nvvm_ldu_c2:
564 case NVPTX::BI__nvvm_ldu_sc2:
565 case NVPTX::BI__nvvm_ldu_c4:
566 case NVPTX::BI__nvvm_ldu_sc4:
567 case NVPTX::BI__nvvm_ldu_s:
568 case NVPTX::BI__nvvm_ldu_s2:
569 case NVPTX::BI__nvvm_ldu_s4:
570 case NVPTX::BI__nvvm_ldu_i:
571 case NVPTX::BI__nvvm_ldu_i2:
572 case NVPTX::BI__nvvm_ldu_i4:
573 case NVPTX::BI__nvvm_ldu_l:
574 case NVPTX::BI__nvvm_ldu_l2:
575 case NVPTX::BI__nvvm_ldu_ll:
576 case NVPTX::BI__nvvm_ldu_ll2:
577 case NVPTX::BI__nvvm_ldu_uc:
578 case NVPTX::BI__nvvm_ldu_uc2:
579 case NVPTX::BI__nvvm_ldu_uc4:
580 case NVPTX::BI__nvvm_ldu_us:
581 case NVPTX::BI__nvvm_ldu_us2:
582 case NVPTX::BI__nvvm_ldu_us4:
583 case NVPTX::BI__nvvm_ldu_ui:
584 case NVPTX::BI__nvvm_ldu_ui2:
585 case NVPTX::BI__nvvm_ldu_ui4:
586 case NVPTX::BI__nvvm_ldu_ul:
587 case NVPTX::BI__nvvm_ldu_ul2:
588 case NVPTX::BI__nvvm_ldu_ull:
589 case NVPTX::BI__nvvm_ldu_ull2:
590 return MakeLdu(Intrinsic::nvvm_ldu_global_i, *
this, E);
591 case NVPTX::BI__nvvm_ldu_f:
592 case NVPTX::BI__nvvm_ldu_f2:
593 case NVPTX::BI__nvvm_ldu_f4:
594 case NVPTX::BI__nvvm_ldu_d:
595 case NVPTX::BI__nvvm_ldu_d2:
596 return MakeLdu(Intrinsic::nvvm_ldu_global_f, *
this, E);
598 case NVPTX::BI__nvvm_atom_cta_add_gen_i:
599 case NVPTX::BI__nvvm_atom_cta_add_gen_l:
600 case NVPTX::BI__nvvm_atom_cta_add_gen_ll:
601 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Add,
602 llvm::AtomicScope::Workgroup);
603 case NVPTX::BI__nvvm_atom_sys_add_gen_i:
604 case NVPTX::BI__nvvm_atom_sys_add_gen_l:
605 case NVPTX::BI__nvvm_atom_sys_add_gen_ll:
606 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Add,
607 llvm::AtomicScope::System);
608 case NVPTX::BI__nvvm_atom_cta_add_gen_f:
609 case NVPTX::BI__nvvm_atom_cta_add_gen_d:
610 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::FAdd,
611 llvm::AtomicScope::Workgroup);
612 case NVPTX::BI__nvvm_atom_sys_add_gen_f:
613 case NVPTX::BI__nvvm_atom_sys_add_gen_d:
614 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::FAdd,
615 llvm::AtomicScope::System);
616 case NVPTX::BI__nvvm_atom_cta_xchg_gen_i:
617 case NVPTX::BI__nvvm_atom_cta_xchg_gen_l:
618 case NVPTX::BI__nvvm_atom_cta_xchg_gen_ll:
619 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Xchg,
620 llvm::AtomicScope::Workgroup);
621 case NVPTX::BI__nvvm_atom_sys_xchg_gen_i:
622 case NVPTX::BI__nvvm_atom_sys_xchg_gen_l:
623 case NVPTX::BI__nvvm_atom_sys_xchg_gen_ll:
624 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Xchg,
625 llvm::AtomicScope::System);
626 case NVPTX::BI__nvvm_atom_cta_max_gen_i:
627 case NVPTX::BI__nvvm_atom_cta_max_gen_l:
628 case NVPTX::BI__nvvm_atom_cta_max_gen_ll:
629 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Max,
630 llvm::AtomicScope::Workgroup);
631 case NVPTX::BI__nvvm_atom_cta_max_gen_ui:
632 case NVPTX::BI__nvvm_atom_cta_max_gen_ul:
633 case NVPTX::BI__nvvm_atom_cta_max_gen_ull:
634 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UMax,
635 llvm::AtomicScope::Workgroup);
636 case NVPTX::BI__nvvm_atom_sys_max_gen_i:
637 case NVPTX::BI__nvvm_atom_sys_max_gen_l:
638 case NVPTX::BI__nvvm_atom_sys_max_gen_ll:
639 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Max,
640 llvm::AtomicScope::System);
641 case NVPTX::BI__nvvm_atom_sys_max_gen_ui:
642 case NVPTX::BI__nvvm_atom_sys_max_gen_ul:
643 case NVPTX::BI__nvvm_atom_sys_max_gen_ull:
644 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UMax,
645 llvm::AtomicScope::System);
646 case NVPTX::BI__nvvm_atom_cta_min_gen_i:
647 case NVPTX::BI__nvvm_atom_cta_min_gen_l:
648 case NVPTX::BI__nvvm_atom_cta_min_gen_ll:
649 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Min,
650 llvm::AtomicScope::Workgroup);
651 case NVPTX::BI__nvvm_atom_cta_min_gen_ui:
652 case NVPTX::BI__nvvm_atom_cta_min_gen_ul:
653 case NVPTX::BI__nvvm_atom_cta_min_gen_ull:
654 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UMin,
655 llvm::AtomicScope::Workgroup);
656 case NVPTX::BI__nvvm_atom_sys_min_gen_i:
657 case NVPTX::BI__nvvm_atom_sys_min_gen_l:
658 case NVPTX::BI__nvvm_atom_sys_min_gen_ll:
659 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Min,
660 llvm::AtomicScope::System);
661 case NVPTX::BI__nvvm_atom_sys_min_gen_ui:
662 case NVPTX::BI__nvvm_atom_sys_min_gen_ul:
663 case NVPTX::BI__nvvm_atom_sys_min_gen_ull:
664 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UMin,
665 llvm::AtomicScope::System);
666 case NVPTX::BI__nvvm_atom_cta_inc_gen_ui:
667 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UIncWrap,
668 llvm::AtomicScope::Workgroup);
669 case NVPTX::BI__nvvm_atom_cta_dec_gen_ui:
670 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UDecWrap,
671 llvm::AtomicScope::Workgroup);
672 case NVPTX::BI__nvvm_atom_sys_inc_gen_ui:
673 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UIncWrap,
674 llvm::AtomicScope::System);
675 case NVPTX::BI__nvvm_atom_sys_dec_gen_ui:
676 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::UDecWrap,
677 llvm::AtomicScope::System);
678 case NVPTX::BI__nvvm_atom_cta_and_gen_i:
679 case NVPTX::BI__nvvm_atom_cta_and_gen_l:
680 case NVPTX::BI__nvvm_atom_cta_and_gen_ll:
681 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::And,
682 llvm::AtomicScope::Workgroup);
683 case NVPTX::BI__nvvm_atom_sys_and_gen_i:
684 case NVPTX::BI__nvvm_atom_sys_and_gen_l:
685 case NVPTX::BI__nvvm_atom_sys_and_gen_ll:
686 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::And,
687 llvm::AtomicScope::System);
688 case NVPTX::BI__nvvm_atom_cta_or_gen_i:
689 case NVPTX::BI__nvvm_atom_cta_or_gen_l:
690 case NVPTX::BI__nvvm_atom_cta_or_gen_ll:
691 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Or,
692 llvm::AtomicScope::Workgroup);
693 case NVPTX::BI__nvvm_atom_sys_or_gen_i:
694 case NVPTX::BI__nvvm_atom_sys_or_gen_l:
695 case NVPTX::BI__nvvm_atom_sys_or_gen_ll:
696 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Or,
697 llvm::AtomicScope::System);
698 case NVPTX::BI__nvvm_atom_cta_xor_gen_i:
699 case NVPTX::BI__nvvm_atom_cta_xor_gen_l:
700 case NVPTX::BI__nvvm_atom_cta_xor_gen_ll:
701 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Xor,
702 llvm::AtomicScope::Workgroup);
703 case NVPTX::BI__nvvm_atom_sys_xor_gen_i:
704 case NVPTX::BI__nvvm_atom_sys_xor_gen_l:
705 case NVPTX::BI__nvvm_atom_sys_xor_gen_ll:
706 return MakeScopedAtomicRMW(*
this, E, llvm::AtomicRMWInst::Xor,
707 llvm::AtomicScope::System);
708 case NVPTX::BI__nvvm_atom_cta_cas_gen_us:
709 case NVPTX::BI__nvvm_atom_cta_cas_gen_i:
710 case NVPTX::BI__nvvm_atom_cta_cas_gen_l:
711 case NVPTX::BI__nvvm_atom_cta_cas_gen_ll:
712 return MakeScopedAtomicCAS(*
this, E, llvm::AtomicScope::Workgroup);
713 case NVPTX::BI__nvvm_atom_sys_cas_gen_us:
714 case NVPTX::BI__nvvm_atom_sys_cas_gen_i:
715 case NVPTX::BI__nvvm_atom_sys_cas_gen_l:
716 case NVPTX::BI__nvvm_atom_sys_cas_gen_ll:
717 return MakeScopedAtomicCAS(*
this, E, llvm::AtomicScope::System);
718 case NVPTX::BI__nvvm_match_all_sync_i32p:
719 case NVPTX::BI__nvvm_match_all_sync_i64p: {
724 CGM.getIntrinsic(BuiltinID == NVPTX::BI__nvvm_match_all_sync_i32p
725 ? Intrinsic::nvvm_match_all_sync_i32p
726 : Intrinsic::nvvm_match_all_sync_i64p),
730 Builder.CreateStore(Pred, PredOutPtr);
731 return Builder.CreateExtractValue(ResultPair, 0);
735 case NVPTX::BI__hmma_m16n16k16_ld_a:
736 case NVPTX::BI__hmma_m16n16k16_ld_b:
737 case NVPTX::BI__hmma_m16n16k16_ld_c_f16:
738 case NVPTX::BI__hmma_m16n16k16_ld_c_f32:
739 case NVPTX::BI__hmma_m32n8k16_ld_a:
740 case NVPTX::BI__hmma_m32n8k16_ld_b:
741 case NVPTX::BI__hmma_m32n8k16_ld_c_f16:
742 case NVPTX::BI__hmma_m32n8k16_ld_c_f32:
743 case NVPTX::BI__hmma_m8n32k16_ld_a:
744 case NVPTX::BI__hmma_m8n32k16_ld_b:
745 case NVPTX::BI__hmma_m8n32k16_ld_c_f16:
746 case NVPTX::BI__hmma_m8n32k16_ld_c_f32:
748 case NVPTX::BI__imma_m16n16k16_ld_a_s8:
749 case NVPTX::BI__imma_m16n16k16_ld_a_u8:
750 case NVPTX::BI__imma_m16n16k16_ld_b_s8:
751 case NVPTX::BI__imma_m16n16k16_ld_b_u8:
752 case NVPTX::BI__imma_m16n16k16_ld_c:
753 case NVPTX::BI__imma_m32n8k16_ld_a_s8:
754 case NVPTX::BI__imma_m32n8k16_ld_a_u8:
755 case NVPTX::BI__imma_m32n8k16_ld_b_s8:
756 case NVPTX::BI__imma_m32n8k16_ld_b_u8:
757 case NVPTX::BI__imma_m32n8k16_ld_c:
758 case NVPTX::BI__imma_m8n32k16_ld_a_s8:
759 case NVPTX::BI__imma_m8n32k16_ld_a_u8:
760 case NVPTX::BI__imma_m8n32k16_ld_b_s8:
761 case NVPTX::BI__imma_m8n32k16_ld_b_u8:
762 case NVPTX::BI__imma_m8n32k16_ld_c:
764 case NVPTX::BI__imma_m8n8k32_ld_a_s4:
765 case NVPTX::BI__imma_m8n8k32_ld_a_u4:
766 case NVPTX::BI__imma_m8n8k32_ld_b_s4:
767 case NVPTX::BI__imma_m8n8k32_ld_b_u4:
768 case NVPTX::BI__imma_m8n8k32_ld_c:
769 case NVPTX::BI__bmma_m8n8k128_ld_a_b1:
770 case NVPTX::BI__bmma_m8n8k128_ld_b_b1:
771 case NVPTX::BI__bmma_m8n8k128_ld_c:
773 case NVPTX::BI__dmma_m8n8k4_ld_a:
774 case NVPTX::BI__dmma_m8n8k4_ld_b:
775 case NVPTX::BI__dmma_m8n8k4_ld_c:
777 case NVPTX::BI__mma_bf16_m16n16k16_ld_a:
778 case NVPTX::BI__mma_bf16_m16n16k16_ld_b:
779 case NVPTX::BI__mma_bf16_m8n32k16_ld_a:
780 case NVPTX::BI__mma_bf16_m8n32k16_ld_b:
781 case NVPTX::BI__mma_bf16_m32n8k16_ld_a:
782 case NVPTX::BI__mma_bf16_m32n8k16_ld_b:
783 case NVPTX::BI__mma_tf32_m16n16k8_ld_a:
784 case NVPTX::BI__mma_tf32_m16n16k8_ld_b:
785 case NVPTX::BI__mma_tf32_m16n16k8_ld_c: {
789 std::optional<llvm::APSInt> isColMajorArg =
793 bool isColMajor = isColMajorArg->getSExtValue();
794 NVPTXMmaLdstInfo II = getNVPTXMmaLdstInfo(BuiltinID);
795 unsigned IID = isColMajor ? II.IID_col : II.IID_row;
803 assert(II.NumResults);
804 if (II.NumResults == 1) {
808 for (
unsigned i = 0; i < II.NumResults; ++i) {
813 llvm::ConstantInt::get(
IntTy, i)),
820 case NVPTX::BI__hmma_m16n16k16_st_c_f16:
821 case NVPTX::BI__hmma_m16n16k16_st_c_f32:
822 case NVPTX::BI__hmma_m32n8k16_st_c_f16:
823 case NVPTX::BI__hmma_m32n8k16_st_c_f32:
824 case NVPTX::BI__hmma_m8n32k16_st_c_f16:
825 case NVPTX::BI__hmma_m8n32k16_st_c_f32:
826 case NVPTX::BI__imma_m16n16k16_st_c_i32:
827 case NVPTX::BI__imma_m32n8k16_st_c_i32:
828 case NVPTX::BI__imma_m8n32k16_st_c_i32:
829 case NVPTX::BI__imma_m8n8k32_st_c_i32:
830 case NVPTX::BI__bmma_m8n8k128_st_c_i32:
831 case NVPTX::BI__dmma_m8n8k4_st_c_f64:
832 case NVPTX::BI__mma_m16n16k8_st_c_f32: {
836 std::optional<llvm::APSInt> isColMajorArg =
840 bool isColMajor = isColMajorArg->getSExtValue();
841 NVPTXMmaLdstInfo II = getNVPTXMmaLdstInfo(BuiltinID);
842 unsigned IID = isColMajor ? II.IID_col : II.IID_row;
847 llvm::Type *ParamType = Intrinsic->getFunctionType()->getParamType(1);
849 for (
unsigned i = 0; i < II.NumResults; ++i) {
853 llvm::ConstantInt::get(
IntTy, i)),
855 Values.push_back(
Builder.CreateBitCast(
V, ParamType));
857 Values.push_back(Ldm);
864 case NVPTX::BI__hmma_m16n16k16_mma_f16f16:
865 case NVPTX::BI__hmma_m16n16k16_mma_f32f16:
866 case NVPTX::BI__hmma_m16n16k16_mma_f32f32:
867 case NVPTX::BI__hmma_m16n16k16_mma_f16f32:
868 case NVPTX::BI__hmma_m32n8k16_mma_f16f16:
869 case NVPTX::BI__hmma_m32n8k16_mma_f32f16:
870 case NVPTX::BI__hmma_m32n8k16_mma_f32f32:
871 case NVPTX::BI__hmma_m32n8k16_mma_f16f32:
872 case NVPTX::BI__hmma_m8n32k16_mma_f16f16:
873 case NVPTX::BI__hmma_m8n32k16_mma_f32f16:
874 case NVPTX::BI__hmma_m8n32k16_mma_f32f32:
875 case NVPTX::BI__hmma_m8n32k16_mma_f16f32:
876 case NVPTX::BI__imma_m16n16k16_mma_s8:
877 case NVPTX::BI__imma_m16n16k16_mma_u8:
878 case NVPTX::BI__imma_m32n8k16_mma_s8:
879 case NVPTX::BI__imma_m32n8k16_mma_u8:
880 case NVPTX::BI__imma_m8n32k16_mma_s8:
881 case NVPTX::BI__imma_m8n32k16_mma_u8:
882 case NVPTX::BI__imma_m8n8k32_mma_s4:
883 case NVPTX::BI__imma_m8n8k32_mma_u4:
884 case NVPTX::BI__bmma_m8n8k128_mma_xor_popc_b1:
885 case NVPTX::BI__bmma_m8n8k128_mma_and_popc_b1:
886 case NVPTX::BI__dmma_m8n8k4_mma_f64:
887 case NVPTX::BI__mma_bf16_m16n16k16_mma_f32:
888 case NVPTX::BI__mma_bf16_m8n32k16_mma_f32:
889 case NVPTX::BI__mma_bf16_m32n8k16_mma_f32:
890 case NVPTX::BI__mma_tf32_m16n16k8_mma_f32: {
895 std::optional<llvm::APSInt> LayoutArg =
899 int Layout = LayoutArg->getSExtValue();
900 if (Layout < 0 || Layout > 3)
902 llvm::APSInt SatfArg;
903 if (BuiltinID == NVPTX::BI__bmma_m8n8k128_mma_xor_popc_b1 ||
904 BuiltinID == NVPTX::BI__bmma_m8n8k128_mma_and_popc_b1)
906 else if (std::optional<llvm::APSInt> OptSatfArg =
908 SatfArg = *OptSatfArg;
911 bool Satf = SatfArg.getSExtValue();
912 NVPTXMmaInfo MI = getNVPTXMmaInfo(BuiltinID);
913 unsigned IID = MI.getMMAIntrinsic(Layout, Satf);
919 llvm::Type *AType = Intrinsic->getFunctionType()->getParamType(0);
921 for (
unsigned i = 0; i < MI.NumEltsA; ++i) {
925 llvm::ConstantInt::get(
IntTy, i)),
927 Values.push_back(
Builder.CreateBitCast(
V, AType));
930 llvm::Type *BType = Intrinsic->getFunctionType()->getParamType(MI.NumEltsA);
931 for (
unsigned i = 0; i < MI.NumEltsB; ++i) {
935 llvm::ConstantInt::get(
IntTy, i)),
937 Values.push_back(
Builder.CreateBitCast(
V, BType));
941 Intrinsic->getFunctionType()->getParamType(MI.NumEltsA + MI.NumEltsB);
942 for (
unsigned i = 0; i < MI.NumEltsC; ++i) {
946 llvm::ConstantInt::get(
IntTy, i)),
948 Values.push_back(
Builder.CreateBitCast(
V, CType));
952 for (
unsigned i = 0; i < MI.NumEltsD; ++i)
956 llvm::ConstantInt::get(
IntTy, i)),
961 case NVPTX::BI__nvvm_ex2_approx_f16:
963 CGM.getIntrinsic(Intrinsic::nvvm_ex2_approx,
Builder.getHalfTy()),
964 BuiltinID, E, *
this);
965 case NVPTX::BI__nvvm_ex2_approx_f16x2:
967 CGM.getIntrinsic(Intrinsic::nvvm_ex2_approx,
968 FixedVectorType::get(
Builder.getHalfTy(), 2)),
969 BuiltinID, E, *
this);
970 case NVPTX::BI__nvvm_ff2f16x2_rn:
971 return MakeHalfType(Intrinsic::nvvm_ff2f16x2_rn, BuiltinID, E, *
this);
972 case NVPTX::BI__nvvm_ff2f16x2_rn_relu:
973 return MakeHalfType(Intrinsic::nvvm_ff2f16x2_rn_relu, BuiltinID, E, *
this);
974 case NVPTX::BI__nvvm_ff2f16x2_rz:
975 return MakeHalfType(Intrinsic::nvvm_ff2f16x2_rz, BuiltinID, E, *
this);
976 case NVPTX::BI__nvvm_ff2f16x2_rz_relu:
977 return MakeHalfType(Intrinsic::nvvm_ff2f16x2_rz_relu, BuiltinID, E, *
this);
978 case NVPTX::BI__nvvm_fma_rn_f16:
979 return MakeHalfType(Intrinsic::nvvm_fma_rn_f16, BuiltinID, E, *
this);
980 case NVPTX::BI__nvvm_fma_rn_f16x2:
981 return MakeHalfType(Intrinsic::nvvm_fma_rn_f16x2, BuiltinID, E, *
this);
982 case NVPTX::BI__nvvm_fma_rn_ftz_f16:
983 return MakeHalfType(Intrinsic::nvvm_fma_rn_ftz_f16, BuiltinID, E, *
this);
984 case NVPTX::BI__nvvm_fma_rn_ftz_f16x2:
985 return MakeHalfType(Intrinsic::nvvm_fma_rn_ftz_f16x2, BuiltinID, E, *
this);
986 case NVPTX::BI__nvvm_fma_rn_ftz_relu_f16:
987 return MakeHalfType(Intrinsic::nvvm_fma_rn_ftz_relu_f16, BuiltinID, E,
989 case NVPTX::BI__nvvm_fma_rn_ftz_relu_f16x2:
990 return MakeHalfType(Intrinsic::nvvm_fma_rn_ftz_relu_f16x2, BuiltinID, E,
992 case NVPTX::BI__nvvm_fma_rn_ftz_sat_f16:
993 return MakeHalfType(Intrinsic::nvvm_fma_rn_ftz_sat_f16, BuiltinID, E,
995 case NVPTX::BI__nvvm_fma_rn_ftz_sat_f16x2:
996 return MakeHalfType(Intrinsic::nvvm_fma_rn_ftz_sat_f16x2, BuiltinID, E,
998 case NVPTX::BI__nvvm_fma_rn_relu_f16:
999 return MakeHalfType(Intrinsic::nvvm_fma_rn_relu_f16, BuiltinID, E, *
this);
1000 case NVPTX::BI__nvvm_fma_rn_relu_f16x2:
1001 return MakeHalfType(Intrinsic::nvvm_fma_rn_relu_f16x2, BuiltinID, E, *
this);
1002 case NVPTX::BI__nvvm_fma_rn_sat_f16:
1003 return MakeHalfType(Intrinsic::nvvm_fma_rn_sat_f16, BuiltinID, E, *
this);
1004 case NVPTX::BI__nvvm_fma_rn_sat_f16x2:
1005 return MakeHalfType(Intrinsic::nvvm_fma_rn_sat_f16x2, BuiltinID, E, *
this);
1006 case NVPTX::BI__nvvm_fma_rn_oob_f16:
1007 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob,
Builder.getHalfTy(), E,
1009 case NVPTX::BI__nvvm_fma_rn_oob_f16x2:
1010 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob,
1011 llvm::FixedVectorType::get(
Builder.getHalfTy(), 2), E,
1013 case NVPTX::BI__nvvm_fma_rn_oob_bf16:
1014 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob,
Builder.getBFloatTy(), E,
1016 case NVPTX::BI__nvvm_fma_rn_oob_bf16x2:
1017 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob,
1018 llvm::FixedVectorType::get(
Builder.getBFloatTy(), 2), E,
1020 case NVPTX::BI__nvvm_fma_rn_oob_relu_f16:
1021 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob_relu,
Builder.getHalfTy(), E,
1023 case NVPTX::BI__nvvm_fma_rn_oob_relu_f16x2:
1024 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob_relu,
1025 llvm::FixedVectorType::get(
Builder.getHalfTy(), 2), E,
1027 case NVPTX::BI__nvvm_fma_rn_oob_relu_bf16:
1028 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob_relu,
Builder.getBFloatTy(), E,
1030 case NVPTX::BI__nvvm_fma_rn_oob_relu_bf16x2:
1031 return MakeFMAOOB(Intrinsic::nvvm_fma_rn_oob_relu,
1032 llvm::FixedVectorType::get(
Builder.getBFloatTy(), 2), E,
1034 case NVPTX::BI__nvvm_fmax_f16:
1035 return MakeHalfType(Intrinsic::nvvm_fmax_f16, BuiltinID, E, *
this);
1036 case NVPTX::BI__nvvm_fmax_f16x2:
1037 return MakeHalfType(Intrinsic::nvvm_fmax_f16x2, BuiltinID, E, *
this);
1038 case NVPTX::BI__nvvm_fmax_ftz_f16:
1039 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_f16, BuiltinID, E, *
this);
1040 case NVPTX::BI__nvvm_fmax_ftz_f16x2:
1041 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_f16x2, BuiltinID, E, *
this);
1042 case NVPTX::BI__nvvm_fmax_ftz_nan_f16:
1043 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_nan_f16, BuiltinID, E, *
this);
1044 case NVPTX::BI__nvvm_fmax_ftz_nan_f16x2:
1045 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_nan_f16x2, BuiltinID, E,
1047 case NVPTX::BI__nvvm_fmax_ftz_nan_xorsign_abs_f16:
1048 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_nan_xorsign_abs_f16, BuiltinID,
1050 case NVPTX::BI__nvvm_fmax_ftz_nan_xorsign_abs_f16x2:
1051 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_nan_xorsign_abs_f16x2,
1052 BuiltinID, E, *
this);
1053 case NVPTX::BI__nvvm_fmax_ftz_xorsign_abs_f16:
1054 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_xorsign_abs_f16, BuiltinID, E,
1056 case NVPTX::BI__nvvm_fmax_ftz_xorsign_abs_f16x2:
1057 return MakeHalfType(Intrinsic::nvvm_fmax_ftz_xorsign_abs_f16x2, BuiltinID,
1059 case NVPTX::BI__nvvm_fmax_nan_f16:
1060 return MakeHalfType(Intrinsic::nvvm_fmax_nan_f16, BuiltinID, E, *
this);
1061 case NVPTX::BI__nvvm_fmax_nan_f16x2:
1062 return MakeHalfType(Intrinsic::nvvm_fmax_nan_f16x2, BuiltinID, E, *
this);
1063 case NVPTX::BI__nvvm_fmax_nan_xorsign_abs_f16:
1064 return MakeHalfType(Intrinsic::nvvm_fmax_nan_xorsign_abs_f16, BuiltinID, E,
1066 case NVPTX::BI__nvvm_fmax_nan_xorsign_abs_f16x2:
1067 return MakeHalfType(Intrinsic::nvvm_fmax_nan_xorsign_abs_f16x2, BuiltinID,
1069 case NVPTX::BI__nvvm_fmax_xorsign_abs_f16:
1070 return MakeHalfType(Intrinsic::nvvm_fmax_xorsign_abs_f16, BuiltinID, E,
1072 case NVPTX::BI__nvvm_fmax_xorsign_abs_f16x2:
1073 return MakeHalfType(Intrinsic::nvvm_fmax_xorsign_abs_f16x2, BuiltinID, E,
1075 case NVPTX::BI__nvvm_fmin_f16:
1076 return MakeHalfType(Intrinsic::nvvm_fmin_f16, BuiltinID, E, *
this);
1077 case NVPTX::BI__nvvm_fmin_f16x2:
1078 return MakeHalfType(Intrinsic::nvvm_fmin_f16x2, BuiltinID, E, *
this);
1079 case NVPTX::BI__nvvm_fmin_ftz_f16:
1080 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_f16, BuiltinID, E, *
this);
1081 case NVPTX::BI__nvvm_fmin_ftz_f16x2:
1082 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_f16x2, BuiltinID, E, *
this);
1083 case NVPTX::BI__nvvm_fmin_ftz_nan_f16:
1084 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_nan_f16, BuiltinID, E, *
this);
1085 case NVPTX::BI__nvvm_fmin_ftz_nan_f16x2:
1086 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_nan_f16x2, BuiltinID, E,
1088 case NVPTX::BI__nvvm_fmin_ftz_nan_xorsign_abs_f16:
1089 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_nan_xorsign_abs_f16, BuiltinID,
1091 case NVPTX::BI__nvvm_fmin_ftz_nan_xorsign_abs_f16x2:
1092 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_nan_xorsign_abs_f16x2,
1093 BuiltinID, E, *
this);
1094 case NVPTX::BI__nvvm_fmin_ftz_xorsign_abs_f16:
1095 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_xorsign_abs_f16, BuiltinID, E,
1097 case NVPTX::BI__nvvm_fmin_ftz_xorsign_abs_f16x2:
1098 return MakeHalfType(Intrinsic::nvvm_fmin_ftz_xorsign_abs_f16x2, BuiltinID,
1100 case NVPTX::BI__nvvm_fmin_nan_f16:
1101 return MakeHalfType(Intrinsic::nvvm_fmin_nan_f16, BuiltinID, E, *
this);
1102 case NVPTX::BI__nvvm_fmin_nan_f16x2:
1103 return MakeHalfType(Intrinsic::nvvm_fmin_nan_f16x2, BuiltinID, E, *
this);
1104 case NVPTX::BI__nvvm_fmin_nan_xorsign_abs_f16:
1105 return MakeHalfType(Intrinsic::nvvm_fmin_nan_xorsign_abs_f16, BuiltinID, E,
1107 case NVPTX::BI__nvvm_fmin_nan_xorsign_abs_f16x2:
1108 return MakeHalfType(Intrinsic::nvvm_fmin_nan_xorsign_abs_f16x2, BuiltinID,
1110 case NVPTX::BI__nvvm_fmin_xorsign_abs_f16:
1111 return MakeHalfType(Intrinsic::nvvm_fmin_xorsign_abs_f16, BuiltinID, E,
1113 case NVPTX::BI__nvvm_fmin_xorsign_abs_f16x2:
1114 return MakeHalfType(Intrinsic::nvvm_fmin_xorsign_abs_f16x2, BuiltinID, E,
1116 case NVPTX::BI__nvvm_fabs_f:
1117 case NVPTX::BI__nvvm_abs_bf16:
1118 case NVPTX::BI__nvvm_abs_bf16x2:
1119 case NVPTX::BI__nvvm_fabs_f16:
1120 case NVPTX::BI__nvvm_fabs_f16x2:
1121 return Builder.CreateUnaryIntrinsic(Intrinsic::nvvm_fabs,
1123 case NVPTX::BI__nvvm_fabs_ftz_f:
1124 case NVPTX::BI__nvvm_fabs_ftz_f16:
1125 case NVPTX::BI__nvvm_fabs_ftz_f16x2:
1126 return Builder.CreateUnaryIntrinsic(Intrinsic::nvvm_fabs_ftz,
1128 case NVPTX::BI__nvvm_fabs_d:
1130 case NVPTX::BI__nvvm_ex2_approx_d:
1131 case NVPTX::BI__nvvm_ex2_approx_f:
1132 return Builder.CreateUnaryIntrinsic(Intrinsic::nvvm_ex2_approx,
1134 case NVPTX::BI__nvvm_ex2_approx_ftz_f:
1135 return Builder.CreateUnaryIntrinsic(Intrinsic::nvvm_ex2_approx_ftz,
1137 case NVPTX::BI__nvvm_ldg_h:
1138 case NVPTX::BI__nvvm_ldg_h2:
1139 return MakeLdg(*
this, E);
1140 case NVPTX::BI__nvvm_ldu_h:
1141 case NVPTX::BI__nvvm_ldu_h2:
1142 return MakeLdu(Intrinsic::nvvm_ldu_global_f, *
this, E);
1143 case NVPTX::BI__nvvm_cp_async_ca_shared_global_4:
1144 return MakeCpAsync(Intrinsic::nvvm_cp_async_ca_shared_global_4,
1145 Intrinsic::nvvm_cp_async_ca_shared_global_4_s, *
this, E,
1147 case NVPTX::BI__nvvm_cp_async_ca_shared_global_8:
1148 return MakeCpAsync(Intrinsic::nvvm_cp_async_ca_shared_global_8,
1149 Intrinsic::nvvm_cp_async_ca_shared_global_8_s, *
this, E,
1151 case NVPTX::BI__nvvm_cp_async_ca_shared_global_16:
1152 return MakeCpAsync(Intrinsic::nvvm_cp_async_ca_shared_global_16,
1153 Intrinsic::nvvm_cp_async_ca_shared_global_16_s, *
this, E,
1155 case NVPTX::BI__nvvm_cp_async_cg_shared_global_16:
1156 return MakeCpAsync(Intrinsic::nvvm_cp_async_cg_shared_global_16,
1157 Intrinsic::nvvm_cp_async_cg_shared_global_16_s, *
this, E,
1159 case NVPTX::BI__nvvm_read_ptx_sreg_clusterid_x:
1161 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_clusterid_x));
1162 case NVPTX::BI__nvvm_read_ptx_sreg_clusterid_y:
1164 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_clusterid_y));
1165 case NVPTX::BI__nvvm_read_ptx_sreg_clusterid_z:
1167 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_clusterid_z));
1168 case NVPTX::BI__nvvm_read_ptx_sreg_clusterid_w:
1170 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_clusterid_w));
1171 case NVPTX::BI__nvvm_read_ptx_sreg_nclusterid_x:
1173 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_nclusterid_x));
1174 case NVPTX::BI__nvvm_read_ptx_sreg_nclusterid_y:
1176 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_nclusterid_y));
1177 case NVPTX::BI__nvvm_read_ptx_sreg_nclusterid_z:
1179 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_nclusterid_z));
1180 case NVPTX::BI__nvvm_read_ptx_sreg_nclusterid_w:
1182 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_nclusterid_w));
1183 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_ctaid_x:
1185 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_ctaid_x));
1186 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_ctaid_y:
1188 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_ctaid_y));
1189 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_ctaid_z:
1191 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_ctaid_z));
1192 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_ctaid_w:
1194 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_ctaid_w));
1195 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_nctaid_x:
1197 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_nctaid_x));
1198 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_nctaid_y:
1200 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_nctaid_y));
1201 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_nctaid_z:
1203 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_nctaid_z));
1204 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_nctaid_w:
1206 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_nctaid_w));
1207 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_ctarank:
1209 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_ctarank));
1210 case NVPTX::BI__nvvm_read_ptx_sreg_cluster_nctarank:
1212 CGM.getIntrinsic(Intrinsic::nvvm_read_ptx_sreg_cluster_nctarank));
1213 case NVPTX::BI__nvvm_is_explicit_cluster:
1215 CGM.getIntrinsic(Intrinsic::nvvm_is_explicit_cluster));
1216 case NVPTX::BI__nvvm_isspacep_shared_cluster:
1218 CGM.getIntrinsic(Intrinsic::nvvm_isspacep_shared_cluster),
1220 case NVPTX::BI__nvvm_mapa:
1222 CGM.getIntrinsic(Intrinsic::nvvm_mapa),
1223 {EmitScalarExpr(E->getArg(0)), EmitScalarExpr(E->getArg(1))});
1224 case NVPTX::BI__nvvm_mapa_shared_cluster:
1226 CGM.getIntrinsic(Intrinsic::nvvm_mapa_shared_cluster),
1227 {EmitScalarExpr(E->getArg(0)), EmitScalarExpr(E->getArg(1))});
1228 case NVPTX::BI__nvvm_getctarank:
1230 CGM.getIntrinsic(Intrinsic::nvvm_getctarank),
1232 case NVPTX::BI__nvvm_getctarank_shared_cluster:
1234 CGM.getIntrinsic(Intrinsic::nvvm_getctarank_shared_cluster),
1236 case NVPTX::BI__nvvm_barrier_cluster_arrive:
1238 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cluster_arrive));
1239 case NVPTX::BI__nvvm_barrier_cluster_arrive_relaxed:
1241 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cluster_arrive_relaxed));
1242 case NVPTX::BI__nvvm_barrier_cluster_wait:
1244 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cluster_wait));
1245 case NVPTX::BI__nvvm_fence_sc_cluster:
1247 CGM.getIntrinsic(Intrinsic::nvvm_fence_sc_cluster));
1248 case NVPTX::BI__nvvm_bar_sync:
1250 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cta_sync_aligned_all),
1252 case NVPTX::BI__syncthreads:
1254 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cta_sync_aligned_all),
1256 case NVPTX::BI__nvvm_barrier_sync:
1258 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cta_sync_all),
1260 case NVPTX::BI__nvvm_barrier_sync_cnt:
1262 CGM.getIntrinsic(Intrinsic::nvvm_barrier_cta_sync_count),
1263 {EmitScalarExpr(E->getArg(0)), EmitScalarExpr(E->getArg(1))});
1264 case NVPTX::BI__nvvm_bar0_and:
1267 Intrinsic::nvvm_barrier_cta_red_and_aligned_all, {},
1268 {Builder.getInt32(0),
1269 Builder.CreateICmpNE(EmitScalarExpr(E->getArg(0)),
1270 Builder.getInt32(0))}),
1272 case NVPTX::BI__nvvm_bar0_or:
1275 Intrinsic::nvvm_barrier_cta_red_or_aligned_all, {},
1276 {Builder.getInt32(0),
1277 Builder.CreateICmpNE(EmitScalarExpr(E->getArg(0)),
1278 Builder.getInt32(0))}),
1280 case NVPTX::BI__nvvm_bar0_popc:
1281 return Builder.CreateIntrinsic(
1282 Intrinsic::nvvm_barrier_cta_red_popc_aligned_all, {},