Skip to content

Commit 9d6fe5f

Browse files
committed
[NVPTX] Add -march=general option to mirror default configuration
1 parent 34ba907 commit 9d6fe5f

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

clang/lib/Driver/ToolChains/Cuda.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,8 +750,8 @@ NVPTXToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args,
750750
if (!llvm::is_contained(*DAL, A))
751751
DAL->append(A);
752752

753-
// TODO: We should accept 'generic' as a valid architecture.
754-
if (!DAL->hasArg(options::OPT_march_EQ) && OffloadKind != Action::OFK_None) {
753+
if ((!DAL->hasArg(options::OPT_march_EQ) && OffloadKind != Action::OFK_None) ||
754+
(DAL->getLastArgValue(options::OPT_march_EQ) == "generic")) {
755755
DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_march_EQ),
756756
CudaArchToString(CudaArch::CudaDefault));
757757
} else if (DAL->getLastArgValue(options::OPT_march_EQ) == "native") {

clang/test/Driver/cuda-cross-compiling.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,15 @@
3232
//
3333
// RUN: %clang -target nvptx64-nvidia-cuda -march=sm_61 -### %s 2>&1 \
3434
// RUN: | FileCheck -check-prefix=ARGS %s
35+
// RUN: %clang -target nvptx64-nvidia-cuda -march=generic -### %s 2>&1 \
36+
// RUN: | FileCheck -check-prefix=GENERIC %s
3537

3638
// ARGS: -cc1" "-triple" "nvptx64-nvidia-cuda" "-S" {{.*}} "-target-cpu" "sm_61" "-target-feature" "+ptx{{[0-9]+}}" {{.*}} "-o" "[[PTX:.+]].s"
3739
// ARGS-NEXT: ptxas{{.*}}"-m64" "-O0" "--gpu-name" "sm_61" "--output-file" "[[CUBIN:.+]].cubin" "[[PTX]].s" "-c"
3840
// ARGS-NEXT: nvlink{{.*}}"-o" "a.out" "-arch" "sm_61" {{.*}} "[[CUBIN]].cubin"
41+
// GENERIC: -cc1" "-triple" "nvptx64-nvidia-cuda" "-S" {{.*}} "-target-cpu" "sm_52" "-target-feature" "+ptx{{[0-9]+}}" {{.*}} "-o" "[[PTX:.+]].s"
42+
// GENERIC-NEXT: ptxas{{.*}}"-m64" "-O0" "--gpu-name" "sm_52" "--output-file" "[[CUBIN:.+]].cubin" "[[PTX]].s" "-c"
43+
// GENERIC-NEXT: nvlink{{.*}}"-o" "a.out" "-arch" "sm_52" {{.*}} "[[CUBIN]].cubin"
3944

4045
//
4146
// Test the generated arguments to the CUDA binary utils when targeting NVPTX.
@@ -85,6 +90,6 @@
8590
// MISSING: error: Must pass in an explicit nvptx64 gpu architecture to 'nvlink'
8691

8792
// RUN: %clang -target nvptx64-nvidia-cuda -flto -c %s -### 2>&1 \
88-
// RUN: | FileCheck -check-prefix=GENERIC %s
93+
// RUN: | FileCheck -check-prefix=COMPILE %s
8994

90-
// GENERIC-NOT: -cc1" "-triple" "nvptx64-nvidia-cuda" {{.*}} "-target-cpu"
95+
// COMPILE-NOT: -cc1" "-triple" "nvptx64-nvidia-cuda" {{.*}} "-target-cpu"

0 commit comments

Comments
 (0)