Skip to content

Commit 0e7142b

Browse files
committed
[LLVM 21] Update for CreateTargetInfo API change.
CreateTargetInfo no longer receives a shared_ptr, it receives a reference instead.
1 parent 6edfae8 commit 0e7142b

2 files changed

Lines changed: 61 additions & 3 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright (C) Codeplay Software Limited
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License") with LLVM
4+
// Exceptions; you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://github.com/codeplaysoftware/oneapi-construction-kit/blob/main/LICENSE.txt
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
// License for the specific language governing permissions and limitations
13+
// under the License.
14+
//
15+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
16+
17+
#ifndef MULTI_LLVM_TARGET_TARGETINFO_H_INCLUDED
18+
#define MULTI_LLVM_TARGET_TARGETINFO_H_INCLUDED
19+
20+
#include <clang/Basic/TargetInfo.h>
21+
#include <multi_llvm/llvm_version.h>
22+
23+
namespace multi_llvm {
24+
25+
namespace detail {
26+
27+
#if LLVM_VERSION_GREATER_EQUAL(21, 0)
28+
29+
template <typename TargetInfo = clang::TargetInfo>
30+
auto createTargetInfo(clang::DiagnosticsEngine &Diags,
31+
clang::TargetOptions &Opts)
32+
-> decltype(TargetInfo::CreateTargetInfo(Diags, Opts)) {
33+
return TargetInfo::CreateTargetInfo(Diags, Opts);
34+
}
35+
36+
#endif
37+
38+
template <typename TargetInfo = clang::TargetInfo>
39+
auto createTargetInfo(clang::DiagnosticsEngine &Diags,
40+
clang::TargetOptions &Opts)
41+
-> decltype(TargetInfo::CreateTargetInfo(
42+
Diags, std::make_shared<clang::TargetOptions>(Opts))) {
43+
return TargetInfo::CreateTargetInfo(
44+
Diags, std::make_shared<clang::TargetOptions>(Opts));
45+
}
46+
47+
} // namespace detail
48+
49+
struct TargetInfo {
50+
static clang::TargetInfo *CreateTargetInfo(clang::DiagnosticsEngine &Diags,
51+
clang::TargetOptions &Opts) {
52+
return multi_llvm::detail::createTargetInfo(Diags, Opts);
53+
}
54+
};
55+
56+
} // namespace multi_llvm
57+
58+
#endif // MULTI_LLVM_TARGET_TARGETINFO_H_INCLUDED

modules/compiler/source/base/source/module.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
#include <llvm/Transforms/Vectorize/SLPVectorizer.h>
9191
#include <multi_llvm/llvm_version.h>
9292
#include <multi_llvm/multi_llvm.h>
93+
#include <multi_llvm/targetinfo.h>
9394
#include <mux/mux.hpp>
9495
#include <spirv-ll/module.h>
9596

@@ -1253,9 +1254,8 @@ clang::FrontendInputFile BaseModule::prepareOpenCLInputFile(
12531254
clang::DisableValidationForModuleKind::All;
12541255
pp_opts.AllowPCHWithCompilerErrors = true;
12551256

1256-
instance.setTarget(clang::TargetInfo::CreateTargetInfo(
1257-
instance.getDiagnostics(),
1258-
std::make_shared<clang::TargetOptions>(instance.getTargetOpts())));
1257+
instance.setTarget(multi_llvm::TargetInfo::CreateTargetInfo(
1258+
instance.getDiagnostics(), instance.getTargetOpts()));
12591259

12601260
// We add the supported OpenCL opts now as we need an existing target before
12611261
// we can do so.

0 commit comments

Comments
 (0)