Skip to content

Commit 7fa0569

Browse files
authored
[Driver][SYCL] Allow -Xsycl-target-frontend= to accept triple aliases (#4862)
-Xsycl-target-backend= is allowed to use triple aliases, e.g. spir64_x86_64 -> spir64_x86_64-unknown-unknown. Allow -Xsycl-target-frontend= to accept triple aliases too. Signed-off-by: Qichao Gu qichao.gu@intel.com
1 parent 657baee commit 7fa0569

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

clang/lib/Driver/ToolChain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1219,7 +1219,7 @@ llvm::opt::DerivedArgList *ToolChain::TranslateOffloadTargetArgs(
12191219
A->getOption().matches(options::OPT_Xsycl_frontend);
12201220
if (A->getOption().matches(options::OPT_Xsycl_frontend_EQ)) {
12211221
// Passing device args: -Xsycl-target-frontend=<triple> -opt=val.
1222-
if (A->getValue(0) == getTripleString())
1222+
if (getDriver().MakeSYCLDeviceTriple(A->getValue(0)) == getTriple())
12231223
Index = Args.getBaseArgs().MakeIndex(A->getValue(1));
12241224
else
12251225
continue;

clang/test/Driver/sycl-offload.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,21 @@
171171

172172
/// ###########################################################################
173173

174+
/// Check -Xsycl-target-frontend= accepts triple aliases
175+
// RUN: %clang -### -fsycl -fsycl-targets=spir64 -Xsycl-target-frontend=spir64 -DFOO %s 2>&1 \
176+
// RUN: | FileCheck -DARCH=spir64 -check-prefixes=CHK-UNUSED-ARG-WARNING,CHK-TARGET %s
177+
// RUN: %clang -### -fsycl -fsycl-targets=spir64_x86_64 -Xsycl-target-frontend=spir64_x86_64 -DFOO %s 2>&1 \
178+
// RUN: | FileCheck -DARCH=spir64_x86_64 -check-prefixes=CHK-UNUSED-ARG-WARNING,CHK-TARGET %s
179+
// RUN: %clang -### -fsycl -fsycl-targets=spir64_gen -Xsycl-target-frontend=spir64_gen -DFOO %s 2>&1 \
180+
// RUN: | FileCheck -DARCH=spir64_gen -check-prefixes=CHK-UNUSED-ARG-WARNING,CHK-TARGET %s
181+
// RUN: %clang -### -fsycl -fsycl-targets=spir64_fpga -Xsycl-target-frontend=spir64_fpga -DFOO %s 2>&1 \
182+
// RUN: | FileCheck -DARCH=spir64_fpga -check-prefixes=CHK-UNUSED-ARG-WARNING,CHK-TARGET %s
183+
// CHK-UNUSED-ARG-WARNING-NOT: clang{{.*}} warning: argument unused during compilation: '-Xsycl-target-frontend={{.*}} -DFOO'
184+
// CHK-TARGET: clang{{.*}} "-cc1" "-triple" "[[ARCH]]-unknown-unknown"{{.*}} "-D" "FOO"
185+
// CHK-TARGET: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-[[ARCH]]-unknown-unknown"
186+
187+
/// ###########################################################################
188+
174189
/// Check the phases graph when using a single target, different from the host.
175190
/// We should have an offload action joining the host compile and device
176191
/// preprocessor and another one joining the device linking outputs to the host

0 commit comments

Comments
 (0)