Skip to content

Commit 525da51

Browse files
Artem Gindinsonbader
authored andcommitted
[SYCL][Driver] Set triple correctly when compiling with -fintelfpga
Most improtantly, this fixes compilation in CL mode with -fintelfpga Signed-off-by: Artem Gindinson <[email protected]>
1 parent 5c39889 commit 525da51

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -851,21 +851,19 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
851851
// unless -fintelfpga is supplied, which uses SPIR-V with fpga AOT.
852852
if (HasValidSYCLRuntime) {
853853
llvm::Triple TT(TargetTriple);
854-
if (SYCLfpga) {
854+
// TODO: Use 'unknown' for OS as devices do not have any OS.
855+
TT.setOS(llvm::Triple(llvm::sys::getProcessTriple()).getOS());
856+
TT.setVendor(llvm::Triple::UnknownVendor);
857+
TT.setEnvironment(llvm::Triple::SYCLDevice);
858+
859+
if (IsCLMode())
860+
TT.setObjectFormat(llvm::Triple::COFF);
861+
if (SYCLfpga)
855862
// Triple for -fintelfpga is spir64_fpga-unknown-<os>-sycldevice.
856-
// TODO: Use 'unknown' for OS as devices do not have any OS.
857863
TT.setArchName("spir64_fpga");
858-
TT.setVendor(llvm::Triple::UnknownVendor);
859-
TT.setOS(llvm::Triple(llvm::sys::getProcessTriple()).getOS());
860-
TT.setEnvironment(llvm::Triple::SYCLDevice);
861-
} else {
864+
else
862865
TT.setArch(llvm::Triple::spir64);
863-
TT.setVendor(llvm::Triple::UnknownVendor);
864-
TT.setOS(llvm::Triple(llvm::sys::getProcessTriple()).getOS());
865-
TT.setEnvironment(llvm::Triple::SYCLDevice);
866-
if (IsCLMode())
867-
TT.setObjectFormat(llvm::Triple::COFF);
868-
}
866+
869867
UniqueSYCLTriplesVec.push_back(TT);
870868
}
871869
}

clang/test/Driver/sycl-offload-intelfpga.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,16 @@
8282
/// -fintelfpga -fsycl-link from source
8383
// RUN: touch %t.cpp
8484
// RUN: %clang++ -### -target x86_64-unknown-linux-gnu -fsycl -fintelfpga -fsycl-link=early %t.cpp -ccc-print-phases 2>&1 \
85-
// RUN: | FileCheck -check-prefixes=CHK-FPGA-LINK-SRC %s
85+
// RUN: | FileCheck -check-prefixes=CHK-FPGA-LINK-SRC,CHK-FPGA-LINK-SRC-DEFAULT %s
86+
// RUN: %clang_cl -### -target x86_64-unknown-linux-gnu -fsycl -fintelfpga -fsycl-link=early %t.cpp -ccc-print-phases 2>&1 \
87+
// RUN: | FileCheck -check-prefixes=CHK-FPGA-LINK-SRC,CHK-FPGA-LINK-SRC-CL %s
8688
// CHK-FPGA-LINK-SRC: 0: input, "[[INPUT:.+\.cpp]]", c++, (host-sycl)
8789
// CHK-FPGA-LINK-SRC: 1: preprocessor, {0}, c++-cpp-output, (host-sycl)
8890
// CHK-FPGA-LINK-SRC: 2: input, "[[INPUT]]", c++, (device-sycl)
8991
// CHK-FPGA-LINK-SRC: 3: preprocessor, {2}, c++-cpp-output, (device-sycl)
9092
// CHK-FPGA-LINK-SRC: 4: compiler, {3}, sycl-header, (device-sycl)
91-
// CHK-FPGA-LINK-SRC: 5: offload, "host-sycl (x86_64-unknown-linux-gnu)" {1}, "device-sycl (spir64_fpga-unknown-{{linux|windows}}-sycldevice)" {4}, c++-cpp-output
93+
// CHK-FPGA-LINK-SRC-DEFAULT: 5: offload, "host-sycl (x86_64-unknown-linux-gnu)" {1}, "device-sycl (spir64_fpga-unknown-{{linux|windows}}-sycldevice)" {4}, c++-cpp-output
94+
// CHK-FPGA-LINK-SRC-CL: 5: offload, "host-sycl (x86_64-pc-windows-msvc)" {1}, "device-sycl (spir64_fpga-unknown-{{linux|windows}}-sycldevice-coff)" {4}, c++-cpp-output
9295
// CHK-FPGA-LINK-SRC: 6: compiler, {5}, ir, (host-sycl)
9396
// CHK-FPGA-LINK-SRC: 7: backend, {6}, assembler, (host-sycl)
9497
// CHK-FPGA-LINK-SRC: 8: assembler, {7}, object, (host-sycl)
@@ -99,7 +102,8 @@
99102
// CHK-FPGA-LINK-SRC: 13: linker, {12}, spirv, (device-sycl)
100103
// CHK-FPGA-LINK-SRC: 14: backend-compiler, {13}, fpga-aocr, (device-sycl)
101104
// CHK-FPGA-LINK-SRC: 15: clang-offload-wrapper, {14}, object, (device-sycl)
102-
// CHK-FPGA-LINK-SRC: 16: offload, "host-sycl (x86_64-unknown-linux-gnu)" {9}, "device-sycl (spir64_fpga-unknown-{{linux|windows}}-sycldevice)" {15}, archive
105+
// CHK-FPGA-LINK-SRC-DEFAULT: 16: offload, "host-sycl (x86_64-unknown-linux-gnu)" {9}, "device-sycl (spir64_fpga-unknown-{{linux|windows}}-sycldevice)" {15}, archive
106+
// CHK-FPGA-LINK-SRC-CL: 16: offload, "host-sycl (x86_64-pc-windows-msvc)" {9}, "device-sycl (spir64_fpga-unknown-{{linux|windows}}-sycldevice-coff)" {15}, archive
103107

104108
/// -fintelfpga with -reuse-exe=
105109
// RUN: touch %t.cpp

0 commit comments

Comments
 (0)