Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit 27a31ad

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:3792b36234b6 into amd-gfx:b7007c9aaa9f
Local branch amd-gfx b7007c9 Merged main:cbff02b101c2 into amd-gfx:fd35e8e70c0b Remote branch main 3792b36 [lld][WebAssembly] Replace config-> with ctx.arg.
2 parents b7007c9 + 3792b36 commit 27a31ad

File tree

100 files changed

+2474
-480
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+2474
-480
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,6 +1493,8 @@ def libomptarget_amdgcn_bc_path_EQ : Joined<["--"], "libomptarget-amdgcn-bc-path
14931493
HelpText<"Path to libomptarget-amdgcn bitcode library">, Alias<libomptarget_amdgpu_bc_path_EQ>;
14941494
def libomptarget_nvptx_bc_path_EQ : Joined<["--"], "libomptarget-nvptx-bc-path=">, Group<i_Group>,
14951495
HelpText<"Path to libomptarget-nvptx bitcode library">;
1496+
def libomptarget_spirv_bc_path_EQ : Joined<["--"], "libomptarget-spirv-bc-path=">, Group<i_Group>,
1497+
HelpText<"Path to libomptarget-spirv bitcode library">;
14961498
def dD : Flag<["-"], "dD">, Group<d_Group>, Visibility<[ClangOption, CC1Option]>,
14971499
HelpText<"Print macro definitions in -E mode in addition to normal output">;
14981500
def dI : Flag<["-"], "dI">, Group<d_Group>, Visibility<[ClangOption, CC1Option]>,

clang/lib/Driver/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ add_clang_library(clangDriver
7777
ToolChains/RISCVToolchain.cpp
7878
ToolChains/Solaris.cpp
7979
ToolChains/SPIRV.cpp
80+
ToolChains/SPIRVOpenMP.cpp
8081
ToolChains/TCE.cpp
8182
ToolChains/UEFI.cpp
8283
ToolChains/VEToolchain.cpp

clang/lib/Driver/Driver.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "ToolChains/PS4CPU.h"
4444
#include "ToolChains/RISCVToolchain.h"
4545
#include "ToolChains/SPIRV.h"
46+
#include "ToolChains/SPIRVOpenMP.h"
4647
#include "ToolChains/Solaris.h"
4748
#include "ToolChains/TCE.h"
4849
#include "ToolChains/UEFI.h"
@@ -890,9 +891,9 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
890891
HostTC->getTriple());
891892

892893
// Attempt to deduce the offloading triple from the set of architectures.
893-
// We can only correctly deduce NVPTX / AMDGPU triples currently. We need
894-
// to temporarily create these toolchains so that we can access tools for
895-
// inferring architectures.
894+
// We can only correctly deduce NVPTX / AMDGPU triples currently.
895+
// We need to temporarily create these toolchains so that we can access
896+
// tools for inferring architectures.
896897
llvm::DenseSet<StringRef> Archs;
897898
if (NVPTXTriple) {
898899
auto TempTC = std::make_unique<toolchains::CudaToolChain>(
@@ -962,7 +963,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
962963
const ToolChain *TC;
963964
// Device toolchains have to be selected differently. They pair host
964965
// and device in their implementation.
965-
if (TT.isNVPTX() || TT.isAMDGCN()) {
966+
if (TT.isNVPTX() || TT.isAMDGCN() || TT.isSPIRV()) {
966967
const ToolChain *HostTC =
967968
C.getSingleOffloadToolChain<Action::OFK_Host>();
968969
assert(HostTC && "Host toolchain should be always defined.");
@@ -975,6 +976,9 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
975976
else if (TT.isAMDGCN())
976977
DeviceTC = std::make_unique<toolchains::AMDGPUOpenMPToolChain>(
977978
*this, TT, *HostTC, C.getInputArgs());
979+
else if (TT.isSPIRV())
980+
DeviceTC = std::make_unique<toolchains::SPIRVOpenMPToolChain>(
981+
*this, TT, *HostTC, C.getInputArgs());
978982
else
979983
assert(DeviceTC && "Device toolchain not defined.");
980984
}

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2839,10 +2839,13 @@ void tools::addOpenMPDeviceRTL(const Driver &D,
28392839
LibraryPaths.emplace_back(LibPath);
28402840

28412841
OptSpecifier LibomptargetBCPathOpt =
2842-
Triple.isAMDGCN() ? options::OPT_libomptarget_amdgpu_bc_path_EQ
2843-
: options::OPT_libomptarget_nvptx_bc_path_EQ;
2842+
Triple.isAMDGCN() ? options::OPT_libomptarget_amdgpu_bc_path_EQ
2843+
: Triple.isNVPTX() ? options::OPT_libomptarget_nvptx_bc_path_EQ
2844+
: options::OPT_libomptarget_spirv_bc_path_EQ;
28442845

2845-
StringRef ArchPrefix = Triple.isAMDGCN() ? "amdgpu" : "nvptx";
2846+
StringRef ArchPrefix = Triple.isAMDGCN() ? "amdgpu"
2847+
: Triple.isNVPTX() ? "nvptx"
2848+
: "spirv64";
28462849
std::string LibOmpTargetName = ("libomptarget-" + ArchPrefix + ".bc").str();
28472850

28482851
// First check whether user specifies bc library

clang/lib/Driver/ToolChains/SPIRV.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class LLVM_LIBRARY_VISIBILITY Linker final : public Tool {
5252

5353
namespace toolchains {
5454

55-
class LLVM_LIBRARY_VISIBILITY SPIRVToolChain final : public ToolChain {
55+
class LLVM_LIBRARY_VISIBILITY SPIRVToolChain : public ToolChain {
5656
mutable std::unique_ptr<Tool> Translator;
5757

5858
public:
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//==- SPIRVOpenMP.cpp - SPIR-V OpenMP Tool Implementations --------*- C++ -*==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//==------------------------------------------------------------------------==//
8+
#include "SPIRVOpenMP.h"
9+
#include "CommonArgs.h"
10+
11+
using namespace clang::driver;
12+
using namespace clang::driver::toolchains;
13+
using namespace clang::driver::tools;
14+
using namespace llvm::opt;
15+
16+
namespace clang::driver::toolchains {
17+
SPIRVOpenMPToolChain::SPIRVOpenMPToolChain(const Driver &D,
18+
const llvm::Triple &Triple,
19+
const ToolChain &HostToolchain,
20+
const ArgList &Args)
21+
: SPIRVToolChain(D, Triple, Args), HostTC(HostToolchain) {}
22+
23+
void SPIRVOpenMPToolChain::addClangTargetOptions(
24+
const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
25+
Action::OffloadKind DeviceOffloadingKind) const {
26+
27+
if (DeviceOffloadingKind != Action::OFK_OpenMP)
28+
return;
29+
30+
if (DriverArgs.hasArg(options::OPT_nogpulib))
31+
return;
32+
addOpenMPDeviceRTL(getDriver(), DriverArgs, CC1Args, "", getTriple(), HostTC);
33+
}
34+
} // namespace clang::driver::toolchains
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//===--- SPIRVOpenMP.h - SPIR-V OpenMP Tool Implementations ------*- C++-*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_SPIRV_OPENMP_H
10+
#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_SPIRV_OPENMP_H
11+
12+
#include "SPIRV.h"
13+
#include "clang/Driver/Tool.h"
14+
#include "clang/Driver/ToolChain.h"
15+
16+
namespace clang::driver::toolchains {
17+
class LLVM_LIBRARY_VISIBILITY SPIRVOpenMPToolChain : public SPIRVToolChain {
18+
public:
19+
SPIRVOpenMPToolChain(const Driver &D, const llvm::Triple &Triple,
20+
const ToolChain &HostTC, const llvm::opt::ArgList &Args);
21+
22+
void addClangTargetOptions(
23+
const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
24+
Action::OffloadKind DeviceOffloadingKind) const override;
25+
26+
const ToolChain &HostTC;
27+
};
28+
} // namespace clang::driver::toolchains
29+
#endif

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4263,6 +4263,7 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
42634263

42644264
if (TT.getArch() == llvm::Triple::UnknownArch ||
42654265
!(TT.getArch() == llvm::Triple::aarch64 || TT.isPPC() ||
4266+
TT.getArch() == llvm::Triple::spirv64 ||
42664267
TT.getArch() == llvm::Triple::systemz ||
42674268
TT.getArch() == llvm::Triple::loongarch64 ||
42684269
TT.getArch() == llvm::Triple::nvptx ||

clang/test/Driver/Inputs/spirv-openmp/lib/libomptarget-spirv64.bc

Whitespace-only changes.

clang/test/Driver/print-supported-extensions-riscv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@
190190
// CHECK-NEXT: svukte 0.3 'Svukte' (Address-Independent Latency of User-Mode Faults to Supervisor Addresses)
191191
// CHECK-NEXT: xqcia 0.2 'Xqcia' (Qualcomm uC Arithmetic Extension)
192192
// CHECK-NEXT: xqciac 0.2 'Xqciac' (Qualcomm uC Load-Store Address Calculation Extension)
193+
// CHECK-NEXT: xqcicli 0.2 'Xqcicli' (Qualcomm uC Conditional Load Immediate Extension)
193194
// CHECK-NEXT: xqcics 0.2 'Xqcics' (Qualcomm uC Conditional Select Extension)
194195
// CHECK-NEXT: xqcicsr 0.2 'Xqcicsr' (Qualcomm uC CSR Extension)
195196
// CHECK-NEXT: xqcilsm 0.2 'Xqcilsm' (Qualcomm uC Load Store Multiple Extension)

0 commit comments

Comments
 (0)