clang: include/clang/Sema/SemaCUDA.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef LLVM_CLANG_SEMA_SEMACUDA_H
14#define LLVM_CLANG_SEMA_SEMACUDA_H
15
25#include "llvm/ADT/DenseMap.h"
26#include "llvm/ADT/DenseMapInfo.h"
27#include "llvm/ADT/DenseSet.h"
28#include "llvm/ADT/Hashing.h"
29#include "llvm/ADT/SmallVector.h"
30#include
31#include
32
34namespace sema {
36}
37
38class ASTReader;
39class ASTWriter;
42class ParsedAttributesView;
43class Scope;
44
46public:
48
49
50
51
53
54
55
56
58
62
63
64
68 };
69
70
71
72
74
75
76
77
78
79
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
102
103
104
105
106
108
109
110
111
112
113
115 bool IgnoreImplicitHDAttr = false);
117
123 };
124
126
127
128
132
133 };
134
135
136
142
149 };
150
151
154 }
155
157
158
159
163
164
167
169 };
170
171
172
173
174
175
176
177
180
181
182
183
184
185
188 }
189
190
191
193
194
195
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
213
215
216
217
218
219
220
222
223
224
226
227
228
229
233 &Matches);
234
235
236
237
238
239
240
241
242
243
244
245
249 bool ConstRHS, bool Diagnose);
250
251
252
255
256
257
258
259
260
261
262
263
265
266
267
269
271
272
273
274
276
277private:
278 unsigned ForceHostDeviceDepth = 0;
279
282};
283
284}
285
286namespace llvm {
287
288
289template <> struct DenseMapInfo<clang::SemaCUDA::FunctionDeclAndLoc> {
292 DenseMapInfo<clang::CanonicalDeclPtr>;
293
296 }
297
300 }
301
303 return hash_combine(FDBaseInfo::getHashValue(FDL.FD),
305 }
306
309 return LHS.FD == RHS.FD && LHS.Loc == RHS.Loc;
310 }
311};
312}
313
314#endif
Forward declaration of all AST node types.
const LambdaCapture * Capture
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
llvm::MachO::Target Target
Defines the clang::SourceLocation class and associated facilities.
Reads an AST files chain containing the contents of a translation unit.
Writes an AST file containing the contents of a translation unit.
Represents a C++ constructor within a class.
Represents a C++ destructor within a class.
Represents a static or instance method of a struct/union/class.
Represents a C++ struct/union/class.
A wrapper class around a pointer that always points to its canonical declaration.
Decl - This represents one declaration (or definition), e.g.
Represents a function declaration or definition.
Declaration of a template function.
Represents the results of name lookup.
Scope - A scope is a transient data structure that is used while parsing the program.
A generic diagnostic builder for errors which may or may not be deferred.
void PushForceHostDevice()
Increments our count of the number of times we've seen a pragma forcing functions to be host device.
void checkAllowedInitializer(VarDecl *VD)
bool IsAllowedCall(const FunctionDecl *Caller, const FunctionDecl *Callee)
Determines whether Caller may invoke Callee, based on their CUDA host/device attributes.
void RecordImplicitHostDeviceFuncUsedByDevice(const FunctionDecl *FD)
Record FD if it is a CUDA/HIP implicit host device function used on device side in device compilation...
std::string getConfigureFuncName() const
Returns the name of the launch configuration function.
bool PopForceHostDevice()
Decrements our count of the number of times we've seen a pragma forcing functions to be host device.
CUDAFunctionTarget IdentifyTarget(const FunctionDecl *D, bool IgnoreImplicitHDAttr=false)
Determines whether the given function is a CUDA device/host/kernel/etc.
void maybeAddHostDeviceAttrs(FunctionDecl *FD, const LookupResult &Previous)
May add implicit CUDAHostAttr and CUDADeviceAttr attributes to FD, depending on FD and the current co...
ExprResult ActOnExecConfigExpr(Scope *S, SourceLocation LLLLoc, MultiExprArg ExecConfig, SourceLocation GGGLoc)
bool isEmptyConstructor(SourceLocation Loc, CXXConstructorDecl *CD)
bool isEmptyDestructor(SourceLocation Loc, CXXDestructorDecl *CD)
void checkTargetOverload(FunctionDecl *NewFD, const LookupResult &Previous)
Check whether NewFD is a valid overload for CUDA.
CUDAFunctionTarget CurrentTarget()
Gets the CUDA target for the current context.
SemaDiagnosticBuilder DiagIfHostCode(SourceLocation Loc, unsigned DiagID)
Creates a SemaDiagnosticBuilder that emits the diagnostic if the current context is "used as host cod...
bool inferTargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl, CXXSpecialMemberKind CSM, CXXMethodDecl *MemberDecl, bool ConstRHS, bool Diagnose)
Given a implicit special member, infer its CUDA target from the calls it needs to make to underlying ...
struct clang::SemaCUDA::CUDATargetContext CurCUDATargetCtx
CUDATargetContextKind
Defines kinds of CUDA global host/device context where a function may be called.
@ CTCK_InitGlobalVar
Unknown context.
SemaDiagnosticBuilder DiagIfDeviceCode(SourceLocation Loc, unsigned DiagID)
Creates a SemaDiagnosticBuilder that emits the diagnostic if the current context is "used as device c...
llvm::DenseSet< FunctionDeclAndLoc > LocsWithCUDACallDiags
FunctionDecls and SourceLocations for which CheckCall has emitted a (maybe deferred) "bad call" diagn...
bool CheckCall(SourceLocation Loc, FunctionDecl *Callee)
Check whether we're allowed to call Callee from the current context.
void inheritTargetAttrs(FunctionDecl *FD, const FunctionTemplateDecl &TD)
Copies target attributes from the template TD to the function FD.
static bool isImplicitHostDeviceFunction(const FunctionDecl *D)
void CheckLambdaCapture(CXXMethodDecl *D, const sema::Capture &Capture)
void MaybeAddConstantAttr(VarDecl *VD)
May add implicit CUDAConstantAttr attribute to VD, depending on VD and current compilation settings.
void EraseUnwantedMatches(const FunctionDecl *Caller, llvm::SmallVectorImpl< std::pair< DeclAccessPair, FunctionDecl * > > &Matches)
Finds a function in Matches with highest calling priority from Caller context and erases all function...
llvm::DenseMap< CanonicalDeclPtr< const FunctionDecl >, FunctionDeclAndLoc > DeviceKnownEmittedFns
An inverse call graph, mapping known-emitted functions to one of their known-emitted callers (plus th...
void SetLambdaAttrs(CXXMethodDecl *Method)
Set device or host device attributes on the given lambda operator() method.
CUDAFunctionPreference IdentifyPreference(const FunctionDecl *Caller, const FunctionDecl *Callee)
Identifies relative preference of a given Caller/Callee combination, based on their host/device attri...
@ CVT_Host
Emitted on device side with a shadow variable on host side.
@ CVT_Both
Emitted on host side only.
@ CVT_Unified
Emitted on both sides with different addresses.
Sema - This implements semantic analysis and AST building for C.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Encodes a location in the source.
unsigned getHashValue() const
Represents a variable declaration or definition.
The JSON file list parser is used to communicate input to InstallAPI.
CXXSpecialMemberKind
Kinds of C++ special members.
Diagnostic wrappers for TextAPI types for error reporting.
Define the current global CUDA host/device context where a function may be called.
CUDATargetContextKind Kind
A pair of a canonical FunctionDecl and a SourceLocation.
CanonicalDeclPtr< const FunctionDecl > FD
static FunctionDeclAndLoc getEmptyKey()
static FunctionDeclAndLoc getTombstoneKey()
DenseMapInfo< clang::CanonicalDeclPtr< const clang::FunctionDecl > > FDBaseInfo
static unsigned getHashValue(const FunctionDeclAndLoc &FDL)
static bool isEqual(const FunctionDeclAndLoc &LHS, const FunctionDeclAndLoc &RHS)