Skip to content

Commit 10fb587

Browse files
Merge branch 'main' into uint_to_fp
2 parents 75e77f2 + b6960e2 commit 10fb587

File tree

81 files changed

+1191
-3136
lines changed

Some content is hidden

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

81 files changed

+1191
-3136
lines changed

.github/new-prs-labeler.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,11 @@ backend:DirectX:
661661

662662
backend:SPIR-V:
663663
- clang/lib/Driver/ToolChains/SPIRV.*
664+
- clang/lib/Sema/SemaSPIRV.cpp
665+
- clang/include/clang/Sema/SemaSPIRV.h
666+
- clang/include/clang/Basic/BuiltinsSPIRV.td
667+
- clang/test/CodeGenSPIRV/**
668+
- clang/test/SemaSPIRV/**
664669
- llvm/lib/Target/SPIRV/**
665670
- llvm/test/CodeGen/SPIRV/**
666671
- llvm/test/Frontend/HLSL/**
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//===--- BuiltinsSPIRV.td - SPIRV Builtin function database ---------*- 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+
include "clang/Basic/BuiltinsBase.td"
10+
11+
def HLSLDistance : Builtin {
12+
let Spellings = ["__builtin_spirv_distance"];
13+
let Attributes = [NoThrow, Const];
14+
let Prototype = "void(...)";
15+
}

clang/include/clang/Basic/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ clang_tablegen(BuiltinsRISCV.inc -gen-clang-builtins
6060
SOURCE BuiltinsRISCV.td
6161
TARGET ClangBuiltinsRISCV)
6262

63+
clang_tablegen(BuiltinsSPIRV.inc -gen-clang-builtins
64+
SOURCE BuiltinsSPIRV.td
65+
TARGET ClangBuiltinsSPIRV)
66+
6367
clang_tablegen(BuiltinsX86.inc -gen-clang-builtins
6468
SOURCE BuiltinsX86.td
6569
TARGET ClangBuiltinsX86)

clang/include/clang/Basic/TargetBuiltins.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ namespace clang {
119119
};
120120
}
121121

122+
/// SPIRV builtins
123+
namespace SPIRV {
124+
enum {
125+
LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
126+
#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
127+
#include "clang/Basic/BuiltinsSPIRV.inc"
128+
LastTSBuiltin
129+
};
130+
} // namespace SPIRV
131+
122132
/// X86 builtins
123133
namespace X86 {
124134
enum {

clang/include/clang/Driver/Action.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class Action {
9494
OFK_Cuda = 0x02,
9595
OFK_OpenMP = 0x04,
9696
OFK_HIP = 0x08,
97+
OFK_SYCL = 0x10,
9798
};
9899

99100
static const char *getClassName(ActionClass AC);

clang/include/clang/Driver/Options.td

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ def opencl_Group : OptionGroup<"<opencl group>">, Group<f_Group>,
182182
DocName<"OpenCL options">;
183183

184184
def sycl_Group : OptionGroup<"<SYCL group>">, Group<f_Group>,
185-
DocName<"SYCL options">;
185+
DocName<"SYCL options">,
186+
Visibility<[ClangOption, CLOption]>;
186187

187188
def cuda_Group : OptionGroup<"<CUDA group>">, Group<f_Group>,
188189
DocName<"CUDA options">,
@@ -6839,16 +6840,21 @@ defm : FlangIgnoredDiagOpt<"frontend-loop-interchange">;
68396840
defm : FlangIgnoredDiagOpt<"target-lifetime">;
68406841

68416842
// C++ SYCL options
6843+
let Group = sycl_Group in {
68426844
def fsycl : Flag<["-"], "fsycl">,
6843-
Visibility<[ClangOption, CLOption]>,
6844-
Group<sycl_Group>, HelpText<"Enables SYCL kernels compilation for device">;
6845+
HelpText<"Enable SYCL C++ extensions">;
68456846
def fno_sycl : Flag<["-"], "fno-sycl">,
6846-
Visibility<[ClangOption, CLOption]>,
6847-
Group<sycl_Group>, HelpText<"Disables SYCL kernels compilation for device">;
6847+
HelpText<"Disable SYCL C++ extensions">;
6848+
def fsycl_device_only : Flag<["-"], "fsycl-device-only">,
6849+
Alias<offload_device_only>, HelpText<"Compile SYCL code for device only">;
6850+
def fsycl_host_only : Flag<["-"], "fsycl-host-only">,
6851+
Alias<offload_host_only>, HelpText<"Compile SYCL code for host only. Has no "
6852+
"effect on non-SYCL compilations">;
68486853
def sycl_link : Flag<["--"], "sycl-link">, Flags<[HelpHidden]>,
6849-
Visibility<[ClangOption, CLOption]>,
6850-
Group<sycl_Group>, HelpText<"Perform link through clang-sycl-linker via the target "
6854+
HelpText<"Perform link through clang-sycl-linker via the target "
68516855
"offloading toolchain.">;
6856+
} // let Group = sycl_Group
6857+
68526858
// OS-specific options
68536859
let Flags = [TargetSpecific] in {
68546860
defm android_pad_segment : BooleanFFlag<"android-pad-segment">, Group<f_Group>;

clang/include/clang/Driver/ToolChain.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,10 @@ class ToolChain {
762762
virtual void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
763763
llvm::opt::ArgStringList &CC1Args) const;
764764

765+
/// Add arguments to use system-specific SYCL includes.
766+
virtual void addSYCLIncludeArgs(const llvm::opt::ArgList &DriverArgs,
767+
llvm::opt::ArgStringList &CC1Args) const;
768+
765769
/// Add arguments to use MCU GCC toolchain includes.
766770
virtual void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
767771
llvm::opt::ArgStringList &CC1Args) const;

clang/include/clang/Sema/Sema.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ class SemaOpenMP;
173173
class SemaPPC;
174174
class SemaPseudoObject;
175175
class SemaRISCV;
176+
class SemaSPIRV;
176177
class SemaSYCL;
177178
class SemaSwift;
178179
class SemaSystemZ;
@@ -1142,6 +1143,11 @@ class Sema final : public SemaBase {
11421143
return *RISCVPtr;
11431144
}
11441145

1146+
SemaSPIRV &SPIRV() {
1147+
assert(SPIRVPtr);
1148+
return *SPIRVPtr;
1149+
}
1150+
11451151
SemaSYCL &SYCL() {
11461152
assert(SYCLPtr);
11471153
return *SYCLPtr;
@@ -1219,6 +1225,7 @@ class Sema final : public SemaBase {
12191225
std::unique_ptr<SemaPPC> PPCPtr;
12201226
std::unique_ptr<SemaPseudoObject> PseudoObjectPtr;
12211227
std::unique_ptr<SemaRISCV> RISCVPtr;
1228+
std::unique_ptr<SemaSPIRV> SPIRVPtr;
12221229
std::unique_ptr<SemaSYCL> SYCLPtr;
12231230
std::unique_ptr<SemaSwift> SwiftPtr;
12241231
std::unique_ptr<SemaSystemZ> SystemZPtr;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//===----- SemaSPIRV.h ----- Semantic Analysis for SPIRV constructs--------===//
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+
/// \file
9+
/// This file declares semantic analysis for SPIRV constructs.
10+
///
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef LLVM_CLANG_SEMA_SEMASPIRV_H
14+
#define LLVM_CLANG_SEMA_SEMASPIRV_H
15+
16+
#include "clang/AST/ASTFwd.h"
17+
#include "clang/Sema/SemaBase.h"
18+
19+
namespace clang {
20+
class SemaSPIRV : public SemaBase {
21+
public:
22+
SemaSPIRV(Sema &S);
23+
24+
bool CheckSPIRVBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
25+
};
26+
} // namespace clang
27+
28+
#endif // LLVM_CLANG_SEMA_SEMASPIRV_H

clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#ifndef LLVM_ADT_STRINGREF_H
13+
#ifndef LLVM_CLANG_STATICANALYZER_CORE_ANALYZEROPTIONS_H
1414
#error This .def file is expected to be included in translation units where \
15-
"llvm/ADT/StringRef.h" is already included!
15+
"clang/StaticAnalyzer/Core/AnalyzerOptions.h" is already included!
1616
#endif
1717

1818
#ifdef ANALYZER_OPTION
@@ -193,6 +193,8 @@ ANALYZER_OPTION(
193193
"with \"crosscheck-with-z3-timeout-threshold\" of 300 ms, would nicely "
194194
"guarantee that no bug report equivalence class can take longer than "
195195
"1 second, effectively mitigating Z3 hangs during refutation. "
196+
"If there were Z3 retries, only the minimum query time is considered "
197+
"when accumulating query times within a report equivalence class. "
196198
"Set 0 for no timeout.", 0)
197199

198200
ANALYZER_OPTION(
@@ -213,6 +215,15 @@ ANALYZER_OPTION(
213215
"400'000 should on average make Z3 queries run for up to 100ms on modern "
214216
"hardware. Set 0 for unlimited.", 0)
215217

218+
ANALYZER_OPTION(
219+
PositiveAnalyzerOption, Z3CrosscheckMaxAttemptsPerQuery,
220+
"crosscheck-with-z3-max-attempts-per-query",
221+
"Set how many times the oracle is allowed to run a Z3 query. "
222+
"This must be a positive value. Set 1 to not allow any retry attempts. "
223+
"Increasing the number of attempts is often more effective at reducing "
224+
"the number of nondeterministic diagnostics than "
225+
"\"crosscheck-with-z3-timeout-threshold\" in practice.", 3)
226+
216227
ANALYZER_OPTION(bool, ShouldReportIssuesInMainSourceFile,
217228
"report-in-main-source-file",
218229
"Whether or not the diagnostic report should be always "

0 commit comments

Comments
 (0)