@@ -630,6 +630,43 @@ void NVPTX::OpenMPLinker::ConstructJob(Compilation &C, const JobAction &JA,
630
630
Exec, CmdArgs, Inputs, Output));
631
631
}
632
632
633
+ void NVPTX::getNVPTXTargetFeatures (const Driver &D, const llvm::Triple &Triple,
634
+ const llvm::opt::ArgList &Args,
635
+ std::vector<StringRef> &Features,
636
+ Optional<clang::CudaVersion> CudaVersion) {
637
+ if (!CudaVersion) {
638
+ CudaInstallationDetector CudaInstallation (D, Triple, Args);
639
+ CudaVersion = CudaInstallation.version ();
640
+ }
641
+
642
+ // New CUDA versions often introduce new instructions that are only supported
643
+ // by new PTX version, so we need to raise PTX level to enable them in NVPTX
644
+ // back-end.
645
+ const char *PtxFeature = nullptr ;
646
+ switch (*CudaVersion) {
647
+ #define CASE_CUDA_VERSION (CUDA_VER, PTX_VER ) \
648
+ case CudaVersion::CUDA_##CUDA_VER: \
649
+ PtxFeature = " +ptx" #PTX_VER; \
650
+ break ;
651
+ CASE_CUDA_VERSION (115 , 75 );
652
+ CASE_CUDA_VERSION (114 , 74 );
653
+ CASE_CUDA_VERSION (113 , 73 );
654
+ CASE_CUDA_VERSION (112 , 72 );
655
+ CASE_CUDA_VERSION (111 , 71 );
656
+ CASE_CUDA_VERSION (110 , 70 );
657
+ CASE_CUDA_VERSION (102 , 65 );
658
+ CASE_CUDA_VERSION (101 , 64 );
659
+ CASE_CUDA_VERSION (100 , 63 );
660
+ CASE_CUDA_VERSION (92 , 61 );
661
+ CASE_CUDA_VERSION (91 , 61 );
662
+ CASE_CUDA_VERSION (90 , 60 );
663
+ #undef CASE_CUDA_VERSION
664
+ default :
665
+ PtxFeature = " +ptx42" ;
666
+ }
667
+ Features.push_back (PtxFeature);
668
+ }
669
+
633
670
// / CUDA toolchain. Our assembler is ptxas, and our "linker" is fatbinary,
634
671
// / which isn't properly a linker but nonetheless performs the step of stitching
635
672
// / together object files from the assembler into a single blob.
@@ -701,32 +738,11 @@ void CudaToolChain::addClangTargetOptions(
701
738
702
739
clang::CudaVersion CudaInstallationVersion = CudaInstallation.version ();
703
740
704
- // New CUDA versions often introduce new instructions that are only supported
705
- // by new PTX version, so we need to raise PTX level to enable them in NVPTX
706
- // back-end.
707
- const char *PtxFeature = nullptr ;
708
- switch (CudaInstallationVersion) {
709
- #define CASE_CUDA_VERSION (CUDA_VER, PTX_VER ) \
710
- case CudaVersion::CUDA_##CUDA_VER: \
711
- PtxFeature = " +ptx" #PTX_VER; \
712
- break ;
713
- CASE_CUDA_VERSION (115 , 75 );
714
- CASE_CUDA_VERSION (114 , 74 );
715
- CASE_CUDA_VERSION (113 , 73 );
716
- CASE_CUDA_VERSION (112 , 72 );
717
- CASE_CUDA_VERSION (111 , 71 );
718
- CASE_CUDA_VERSION (110 , 70 );
719
- CASE_CUDA_VERSION (102 , 65 );
720
- CASE_CUDA_VERSION (101 , 64 );
721
- CASE_CUDA_VERSION (100 , 63 );
722
- CASE_CUDA_VERSION (92 , 61 );
723
- CASE_CUDA_VERSION (91 , 61 );
724
- CASE_CUDA_VERSION (90 , 60 );
725
- #undef CASE_CUDA_VERSION
726
- default :
727
- PtxFeature = " +ptx42" ;
728
- }
729
- CC1Args.append ({" -target-feature" , PtxFeature});
741
+ std::vector<StringRef> Features;
742
+ NVPTX::getNVPTXTargetFeatures (getDriver (), getTriple (), DriverArgs, Features,
743
+ CudaInstallationVersion);
744
+ for (StringRef PtxFeature : Features)
745
+ CC1Args.append ({" -target-feature" , DriverArgs.MakeArgString (PtxFeature)});
730
746
if (DriverArgs.hasFlag (options::OPT_fcuda_short_ptr,
731
747
options::OPT_fno_cuda_short_ptr, false ))
732
748
CC1Args.append ({" -mllvm" , " --nvptx-short-ptr" });
0 commit comments