clang 23.0.0git
ThreadSafetyCommon.h
Go to the documentation of this file.
1//===- ThreadSafetyCommon.h -------------------------------------*- 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// Parts of thread safety analysis that are not specific to thread safety
10// itself have been factored into classes here, where they can be potentially
11// used by other analyses. Currently these include:
12//
13// * Generalize clang CFG visitors.
14// * Conversion of the clang CFG to SSA form.
15// * Translation of clang Exprs to TIL SExprs
16//
17// UNDER CONSTRUCTION. USE AT YOUR OWN RISK.
18//
19//===----------------------------------------------------------------------===//
20
21#ifndef LLVM_CLANG_ANALYSIS_ANALYSES_THREADSAFETYCOMMON_H
22#define LLVM_CLANG_ANALYSIS_ANALYSES_THREADSAFETYCOMMON_H
23
24#include "clang/AST/Decl.h"
25#include "clang/AST/Type.h"
31#include "clang/Analysis/CFG.h"
32#include "clang/Basic/LLVM.h"
33#include "llvm/ADT/DenseMap.h"
34#include "llvm/ADT/PointerIntPair.h"
35#include "llvm/ADT/PointerUnion.h"
36#include "llvm/ADT/SmallVector.h"
37#include "llvm/Support/Casting.h"
38#include "llvm/Support/raw_ostream.h"
39#include <functional>
40#include <string>
41#include <utility>
42#include <vector>
43
44namespace clang {
45
48class BinaryOperator;
49class CallExpr;
50class CastExpr;
54class CXXThisExpr;
55class DeclRefExpr;
56class DeclStmt;
57class Expr;
58class MemberExpr;
59class Stmt;
60class UnaryOperator;
61
62namespace threadSafety {
63
64// Various helper functions on til::SExpr
65namespace sx {
66
67inline bool equals(const til::SExpr *E1, const til::SExpr *E2) {
69}
70
71inline bool matches(const til::SExpr *E1, const til::SExpr *E2) {
72 // We treat a top-level wildcard as the "univsersal" lock.
73 // It matches everything for the purpose of checking locks, but not
74 // for unlocking them.
75 if (isa<til::Wildcard>(E1))
76 return isa<til::Wildcard>(E2);
77 if (isa<til::Wildcard>(E2))
78 return isa<til::Wildcard>(E1);
79
81}
82
83inline bool partiallyMatches(const til::SExpr *E1, const til::SExpr *E2) {
84 const auto *PE1 = dyn_cast_or_null<til::Project>(E1);
85 if (!PE1)
86 return false;
87 const auto *PE2 = dyn_cast_or_null<til::Project>(E2);
88 if (!PE2)
89 return false;
90 return PE1->clangDecl() == PE2->clangDecl();
91}
92
93inline std::string toString(const til::SExpr *E) {
94 std::string s;
95 llvm::raw_string_ostream ss(s);
97 return s;
98}
99
100} // namespace sx
101
102// This class defines the interface of a clang CFG Visitor.
103// CFGWalker will invoke the following methods.
104// Note that methods are not virtual; the visitor is templatized.
106 // Enter the CFG for Decl D, and perform any initial setup operations.
107 void enterCFG(CFG *Cfg, const NamedDecl *D, const CFGBlock *First) {}
108
109 // Enter a CFGBlock.
110 void enterCFGBlock(const CFGBlock *B) {}
111
112 // Returns true if this visitor implements handlePredecessor
113 bool visitPredecessors() { return true; }
114
115 // Process a predecessor edge.
116 void handlePredecessor(const CFGBlock *Pred) {}
117
118 // Process a successor back edge to a previously visited block.
119 void handlePredecessorBackEdge(const CFGBlock *Pred) {}
120
121 // Called just before processing statements.
122 void enterCFGBlockBody(const CFGBlock *B) {}
123
124 // Process an ordinary statement.
125 void handleStatement(const Stmt *S) {}
126
127 // Process a destructor call
128 void handleDestructorCall(const VarDecl *VD, const CXXDestructorDecl *DD) {}
129
130 // Called after all statements have been handled.
131 void exitCFGBlockBody(const CFGBlock *B) {}
132
133 // Return true
134 bool visitSuccessors() { return true; }
135
136 // Process a successor edge.
137 void handleSuccessor(const CFGBlock *Succ) {}
138
139 // Process a successor back edge to a previously visited block.
140 void handleSuccessorBackEdge(const CFGBlock *Succ) {}
141
142 // Leave a CFGBlock.
143 void exitCFGBlock(const CFGBlock *B) {}
144
145 // Leave the CFG, and perform any final cleanup operations.
146 void exitCFG(const CFGBlock *Last) {}
147};
148
149// Walks the clang CFG, and invokes methods on a given CFGVisitor.
151public:
152 CFGWalker() = default;
153
154 // Initialize the CFGWalker. This setup only needs to be done once, even
155 // if there are multiple passes over the CFG.
157 ACtx = &AC;
158 CFGraph = AC.getCFG();
159 if (!CFGraph)
160 return false;
161
162 // Ignore anonymous functions.
163 if (!isa_and_nonnull<NamedDecl>(AC.getDecl()))
164 return false;
165
166 SortedGraph = AC.getAnalysis<PostOrderCFGView>();
167 if (!SortedGraph)
168 return false;
169
170 return true;
171 }
172
173 // Traverse the CFG, calling methods on V as appropriate.
174 template <class Visitor>
175 void walk(Visitor &V) {
176 PostOrderCFGView::CFGBlockSet VisitedBlocks(CFGraph);
177
178 V.enterCFG(CFGraph, getDecl(), &CFGraph->getEntry());
179
180 for (const auto *CurrBlock : *SortedGraph) {
181 VisitedBlocks.insert(CurrBlock);
182
183 V.enterCFGBlock(CurrBlock);
184
185 // Process predecessors, handling back edges last
186 if (V.visitPredecessors()) {
188 // Process successors
189 for (CFGBlock::const_pred_iterator SI = CurrBlock->pred_begin(),
190 SE = CurrBlock->pred_end();
191 SI != SE; ++SI) {
192 if (*SI == nullptr)
193 continue;
194
195 if (!VisitedBlocks.alreadySet(*SI)) {
196 BackEdges.push_back(*SI);
197 continue;
198 }
199 V.handlePredecessor(*SI);
200 }
201
202 for (auto *Blk : BackEdges)
203 V.handlePredecessorBackEdge(Blk);
204 }
205
206 V.enterCFGBlockBody(CurrBlock);
207
208 // Process statements
209 for (const auto &BI : *CurrBlock) {
210 switch (BI.getKind()) {
212 V.handleStatement(BI.castAs<CFGStmt>().getStmt());
213 break;
214
217 V.handleDestructorCall(AD.getVarDecl(),
218 AD.getDestructorDecl(ACtx->getASTContext()));
219 break;
220 }
221 default:
222 break;
223 }
224 }
225
226 V.exitCFGBlockBody(CurrBlock);
227
228 // Process successors, handling back edges first.
229 if (V.visitSuccessors()) {
230 SmallVector<CFGBlock*, 8> ForwardEdges;
231
232 // Process successors
233 for (CFGBlock::const_succ_iterator SI = CurrBlock->succ_begin(),
234 SE = CurrBlock->succ_end();
235 SI != SE; ++SI) {
236 if (*SI == nullptr)
237 continue;
238
239 if (!VisitedBlocks.alreadySet(*SI)) {
240 ForwardEdges.push_back(*SI);
241 continue;
242 }
243 V.handleSuccessorBackEdge(*SI);
244 }
245
246 for (auto *Blk : ForwardEdges)
247 V.handleSuccessor(Blk);
248 }
249
250 V.exitCFGBlock(CurrBlock);
251 }
252 V.exitCFG(&CFGraph->getExit());
253 }
254
255 const CFG *getGraph() const { return CFGraph; }
256 CFG *getGraph() { return CFGraph; }
257
258 const NamedDecl *getDecl() const {
259 return dyn_cast<NamedDecl>(ACtx->getDecl());
260 }
261
262 const PostOrderCFGView *getSortedGraph() const { return SortedGraph; }
263
264private:
265 CFG *CFGraph = nullptr;
266 AnalysisDeclContext *ACtx = nullptr;
267 PostOrderCFGView *SortedGraph = nullptr;
268};
269
270// TODO: move this back into ThreadSafety.cpp
271// This is specific to thread safety. It is here because
272// translateAttrExpr needs it, but that should be moved too.
274private:
275 static constexpr unsigned FlagNegative = 1u << 0;
276 static constexpr unsigned FlagReentrant = 1u << 1;
277
278 /// The capability expression and flags.
279 llvm::PointerIntPair<const til::SExpr *, 2, unsigned> CapExpr;
280
281 /// The kind of capability as specified by @ref CapabilityAttr::getName.
282 StringRef CapKind;
283
284public:
285 CapabilityExpr() : CapExpr(nullptr, 0) {}
286 CapabilityExpr(const til::SExpr *E, StringRef Kind, bool Neg, bool Reentrant)
287 : CapExpr(E, (Neg ? FlagNegative : 0) | (Reentrant ? FlagReentrant : 0)),
288 CapKind(Kind) {}
289 // Infers `Kind` and `Reentrant` from `QT`.
290 CapabilityExpr(const til::SExpr *E, QualType QT, bool Neg);
291
292 // Don't allow implicitly-constructed StringRefs since we'll capture them.
293 template <typename T>
294 CapabilityExpr(const til::SExpr *, T, bool, bool) = delete;
295
296 const til::SExpr *sexpr() const { return CapExpr.getPointer(); }
297 StringRef getKind() const { return CapKind; }
298 bool negative() const { return CapExpr.getInt() & FlagNegative; }
299 bool reentrant() const { return CapExpr.getInt() & FlagReentrant; }
300
302 return CapabilityExpr(CapExpr.getPointer(), CapKind, !negative(),
303 reentrant());
304 }
305
306 bool equals(const CapabilityExpr &other) const {
307 return (negative() == other.negative()) &&
308 sx::equals(sexpr(), other.sexpr());
309 }
310
311 bool matches(const CapabilityExpr &other) const {
312 return (negative() == other.negative()) &&
313 sx::matches(sexpr(), other.sexpr());
314 }
315
316 bool matchesUniv(const CapabilityExpr &CapE) const {
317 return isUniversal() || matches(CapE);
318 }
319
320 bool partiallyMatches(const CapabilityExpr &other) const {
321 return (negative() == other.negative()) &&
322 sx::partiallyMatches(sexpr(), other.sexpr());
323 }
324
325 const ValueDecl* valueDecl() const {
326 if (negative() || sexpr() == nullptr)
327 return nullptr;
328 if (const auto *P = dyn_cast<til::Project>(sexpr()))
329 return P->clangDecl();
330 if (const auto *P = dyn_cast<til::LiteralPtr>(sexpr()))
331 return P->clangDecl();
332 return nullptr;
333 }
334
335 std::string toString() const {
336 if (negative())
337 return "!" + sx::toString(sexpr());
338 return sx::toString(sexpr());
339 }
340
341 bool shouldIgnore() const { return sexpr() == nullptr; }
342
343 bool isInvalid() const { return isa_and_nonnull<til::Undefined>(sexpr()); }
344
345 bool isUniversal() const { return isa_and_nonnull<til::Wildcard>(sexpr()); }
346};
347
348// Translate clang::Expr to til::SExpr.
350public:
351 /// Encapsulates the lexical context of a function call. The lexical
352 /// context includes the arguments to the call, including the implicit object
353 /// argument. When an attribute containing a mutex expression is attached to
354 /// a method, the expression may refer to formal parameters of the method.
355 /// Actual arguments must be substituted for formal parameters to derive
356 /// the appropriate mutex expression in the lexical context where the function
357 /// is called. PrevCtx holds the context in which the arguments themselves
358 /// should be evaluated; multiple calling contexts can be chained together
359 /// by the lock_returned attribute.
361 // The previous context; or 0 if none.
363
364 // The decl to which the attr is attached.
366
367 // Implicit object argument -- e.g. 'this'
368 llvm::PointerUnion<const Expr *, til::SExpr *> SelfArg = nullptr;
369
370 // Number of funArgs
371 unsigned NumArgs = 0;
372
373 // Function arguments
374 llvm::PointerUnion<const Expr *const *, til::SExpr *> FunArgs = nullptr;
375
376 // is Self referred to with -> or .?
377 bool SelfArrow = false;
378
380 : Prev(P), AttrDecl(D) {}
381 };
382
384 // FIXME: we don't always have a self-variable.
385 SelfVar = new (Arena) til::Variable(nullptr);
386 SelfVar->setKind(til::Variable::VK_SFun);
387 }
388
389 // Create placeholder for this: we don't know the VarDecl on construction yet.
391 return new (Arena) til::LiteralPtr(nullptr);
392 }
393
394 // Translate a clang expression in an attribute to a til::SExpr.
395 // Constructs the context from D, DeclExp, and SelfDecl.
396 CapabilityExpr translateAttrExpr(const Expr *AttrExp, const NamedDecl *D,
397 const Expr *DeclExp,
398 til::SExpr *Self = nullptr);
399
401
402 // Translate a VarDecl to its canonical TIL expression.
404
405 // Translate a clang statement or expression to a TIL expression.
406 // Also performs substitution of variables; Ctx provides the context.
407 // Dispatches on the type of S.
408 til::SExpr *translate(const Stmt *S, CallingContext *Ctx);
409 til::SCFG *buildCFG(CFGWalker &Walker);
410
411 til::SExpr *lookupStmt(const Stmt *S);
412
414 return BlockMap[B->getBlockID()];
415 }
416
417 const til::SCFG *getCFG() const { return Scfg; }
418 til::SCFG *getCFG() { return Scfg; }
419
421 LookupLocalVarExpr = std::move(F);
422 }
423
424private:
425 // We implement the CFGVisitor API
426 friend class CFGWalker;
427
428 til::SExpr *translateDeclRefExpr(const DeclRefExpr *DRE,
429 CallingContext *Ctx) ;
430 til::SExpr *translateCXXThisExpr(const CXXThisExpr *TE, CallingContext *Ctx);
431 til::SExpr *translateMemberExpr(const MemberExpr *ME, CallingContext *Ctx);
432 til::SExpr *translateObjCIVarRefExpr(const ObjCIvarRefExpr *IVRE,
433 CallingContext *Ctx);
434 til::SExpr *translateCallExpr(const CallExpr *CE, CallingContext *Ctx,
435 const Expr *SelfE = nullptr);
436 til::SExpr *translateCXXMemberCallExpr(const CXXMemberCallExpr *ME,
437 CallingContext *Ctx);
438 til::SExpr *translateCXXOperatorCallExpr(const CXXOperatorCallExpr *OCE,
439 CallingContext *Ctx);
440 til::SExpr *translateUnaryOperator(const UnaryOperator *UO,
441 CallingContext *Ctx);
442 til::SExpr *translateBinOp(til::TIL_BinaryOpcode Op,
443 const BinaryOperator *BO,
444 CallingContext *Ctx, bool Reverse = false);
445 til::SExpr *translateBinAssign(til::TIL_BinaryOpcode Op,
446 const BinaryOperator *BO,
447 CallingContext *Ctx, bool Assign = false);
448 til::SExpr *translateBinaryOperator(const BinaryOperator *BO,
449 CallingContext *Ctx);
450 til::SExpr *translateCastExpr(const CastExpr *CE, CallingContext *Ctx);
451 til::SExpr *translateArraySubscriptExpr(const ArraySubscriptExpr *E,
452 CallingContext *Ctx);
453 til::SExpr *translateAbstractConditionalOperator(
455
456 til::SExpr *translateDeclStmt(const DeclStmt *S, CallingContext *Ctx);
457 til::SExpr *translateStmtExpr(const StmtExpr *SE, CallingContext *Ctx);
458
459 // Map from statements in the clang CFG to SExprs in the til::SCFG.
460 using StatementMap = llvm::DenseMap<const Stmt *, til::SExpr *>;
461
462 // Map from clang local variables to indices in a LVarDefinitionMap.
463 using LVarIndexMap = llvm::DenseMap<const ValueDecl *, unsigned>;
464
465 // Map from local variable indices to SSA variables (or constants).
466 using NameVarPair = std::pair<const ValueDecl *, til::SExpr *>;
467 using LVarDefinitionMap = CopyOnWriteVector<NameVarPair>;
468
469 struct BlockInfo {
470 LVarDefinitionMap ExitMap;
471 bool HasBackEdges = false;
472
473 // Successors yet to be processed
474 unsigned UnprocessedSuccessors = 0;
475
476 // Predecessors already processed
477 unsigned ProcessedPredecessors = 0;
478
479 BlockInfo() = default;
480 BlockInfo(BlockInfo &&) = default;
481 BlockInfo &operator=(BlockInfo &&) = default;
482 };
483
484 void enterCFG(CFG *Cfg, const NamedDecl *D, const CFGBlock *First);
485 void enterCFGBlock(const CFGBlock *B);
486 bool visitPredecessors() { return true; }
487 void handlePredecessor(const CFGBlock *Pred);
488 void handlePredecessorBackEdge(const CFGBlock *Pred);
489 void enterCFGBlockBody(const CFGBlock *B);
490 void handleStatement(const Stmt *S);
491 void handleDestructorCall(const VarDecl *VD, const CXXDestructorDecl *DD);
492 void exitCFGBlockBody(const CFGBlock *B);
493 bool visitSuccessors() { return true; }
494 void handleSuccessor(const CFGBlock *Succ);
495 void handleSuccessorBackEdge(const CFGBlock *Succ);
496 void exitCFGBlock(const CFGBlock *B);
497 void exitCFG(const CFGBlock *Last);
498
499 void insertStmt(const Stmt *S, til::SExpr *E) {
500 SMap.insert(std::make_pair(S, E));
501 }
502
503 til::SExpr *addStatement(til::SExpr *E, const Stmt *S,
504 const ValueDecl *VD = nullptr);
505 til::SExpr *lookupVarDecl(const ValueDecl *VD);
506 til::SExpr *addVarDecl(const ValueDecl *VD, til::SExpr *E);
507 til::SExpr *updateVarDecl(const ValueDecl *VD, til::SExpr *E);
508
509 void makePhiNodeVar(unsigned i, unsigned NPreds, til::SExpr *E);
510 void mergeEntryMap(LVarDefinitionMap Map);
511 void mergeEntryMapBackEdge();
512 void mergePhiNodesBackEdge(const CFGBlock *Blk);
513
514private:
515 // Set to true when parsing capability expressions, which get translated
516 // inaccurately in order to hack around smart pointers etc.
517 static const bool CapabilityExprMode = true;
518
519 til::MemRegionRef Arena;
520
521 // Variable to use for 'this'. May be null.
522 til::Variable *SelfVar = nullptr;
523
524 til::SCFG *Scfg = nullptr;
525
526 // Map from Stmt to TIL Variables
527 StatementMap SMap;
528
529 // Indices of clang local vars.
530 LVarIndexMap LVarIdxMap;
531
532 // Map from clang to til BBs.
533 std::vector<til::BasicBlock *> BlockMap;
534
535 // Extra information per BB. Indexed by clang BlockID.
536 std::vector<BlockInfo> BBInfo;
537
538 LVarDefinitionMap CurrentLVarMap;
539 std::vector<til::Phi *> CurrentArguments;
540 std::vector<til::SExpr *> CurrentInstructions;
541 std::vector<til::Phi *> IncompleteArgs;
542 til::BasicBlock *CurrentBB = nullptr;
543 BlockInfo *CurrentBlockInfo = nullptr;
544
545 // The closure that captures state required for the lookup; this may be
546 // mutable, so we have to save/restore before/after recursive lookups.
547 using LookupLocalVarExprClosure =
548 std::function<const Expr *(const NamedDecl *)>;
549 // Recursion guard.
550 llvm::DenseSet<const ValueDecl *> VarsBeingTranslated;
551 // Context-dependent lookup of currently valid definitions of local variables.
552 LookupLocalVarExprClosure LookupLocalVarExpr;
553};
554
555#ifndef NDEBUG
556// Dump an SCFG to llvm::errs().
557void printSCFG(CFGWalker &Walker);
558#endif // NDEBUG
559
560} // namespace threadSafety
561} // namespace clang
562
563#endif // LLVM_CLANG_ANALYSIS_ANALYSES_THREADSAFETYCOMMON_H
#define V(N, I)
This file defines AnalysisDeclContext, a class that manages the analysis context data for context sen...
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
SExprBuilder::CallingContext CallingContext
C Language Family Type Representation.
__device__ __2f16 float __ockl_bool s
AbstractConditionalOperator - An abstract base class for ConditionalOperator and BinaryConditionalOpe...
Definition Expr.h:4356
AnalysisDeclContext contains the context data for the function, method or block under analysis.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition Expr.h:2724
A builtin binary operation expression such as "x + y" or "x <= y".
Definition Expr.h:4041
Represents C++ object destructor implicitly generated for automatic object or temporary bound to cons...
Definition CFG.h:445
const VarDecl * getVarDecl() const
Definition CFG.h:450
Represents a single basic block in a source-level CFG.
Definition CFG.h:632
AdjacentBlocks::const_iterator const_pred_iterator
Definition CFG.h:986
unsigned getBlockID() const
Definition CFG.h:1134
AdjacentBlocks::const_iterator const_succ_iterator
Definition CFG.h:993
@ AutomaticObjectDtor
Definition CFG.h:73
T castAs() const
Convert to the specified CFGElement type, asserting that this CFGElement is of the desired type.
Definition CFG.h:100
const CXXDestructorDecl * getDestructorDecl(ASTContext &astContext) const
Definition CFG.cpp:5499
const Stmt * getStmt() const
Definition CFG.h:140
Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt.
Definition CFG.h:1250
Represents a C++ destructor within a class.
Definition DeclCXX.h:2876
Represents a call to a member function that may be written either with member call syntax (e....
Definition ExprCXX.h:180
A call to an overloaded operator written using operator syntax.
Definition ExprCXX.h:85
Represents the this expression in C++.
Definition ExprCXX.h:1155
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition Expr.h:2946
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition Expr.h:3679
A reference to a declared variable, function, enum, etc.
Definition Expr.h:1273
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition Stmt.h:1623
This represents one expression.
Definition Expr.h:112
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition Expr.h:3367
This represents a decl that may have a name.
Definition Decl.h:274
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition ExprObjC.h:546
Implements a set of CFGBlocks using a BitVector.
std::pair< std::nullopt_t, bool > insert(const CFGBlock *Block)
Set the bit associated with a particular CFGBlock.
bool alreadySet(const CFGBlock *Block)
Check if the bit for a CFGBlock has been already set.
A (possibly-)qualified type.
Definition TypeBase.h:937
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition Expr.h:4598
Stmt - This represents one statement.
Definition Stmt.h:86
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition Expr.h:2247
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:712
Represents a variable declaration or definition.
Definition Decl.h:926
const PostOrderCFGView * getSortedGraph() const
const NamedDecl * getDecl() const
bool init(AnalysisDeclContext &AC)
CapabilityExpr(const til::SExpr *E, StringRef Kind, bool Neg, bool Reentrant)
CapabilityExpr(const til::SExpr *, T, bool, bool)=delete
bool matches(const CapabilityExpr &other) const
bool partiallyMatches(const CapabilityExpr &other) const
bool equals(const CapabilityExpr &other) const
bool matchesUniv(const CapabilityExpr &CapE) const
CapabilityExpr translateAttrExpr(const Expr *AttrExp, const NamedDecl *D, const Expr *DeclExp, til::SExpr *Self=nullptr)
Translate a clang expression in an attribute to a til::SExpr.
void setLookupLocalVarExpr(std::function< const Expr *(const NamedDecl *)> F)
til::SExpr * translate(const Stmt *S, CallingContext *Ctx)
til::SExpr * lookupStmt(const Stmt *S)
til::SCFG * buildCFG(CFGWalker &Walker)
til::SExpr * translateVariable(const VarDecl *VD, CallingContext *Ctx)
til::BasicBlock * lookupBlock(const CFGBlock *B)
A basic block is part of an SCFG.
static bool compareExprs(const SExpr *E1, const SExpr *E2)
A Literal pointer to an object allocated in memory.
static bool compareExprs(const SExpr *E1, const SExpr *E2)
An SCFG is a control-flow graph.
Base class for AST nodes in the typed intermediate language.
@ VK_SFun
SFunction (self) parameter.
bool matches(const til::SExpr *E1, const til::SExpr *E2)
bool equals(const til::SExpr *E1, const til::SExpr *E2)
std::string toString(const til::SExpr *E)
bool partiallyMatches(const til::SExpr *E1, const til::SExpr *E2)
TIL_BinaryOpcode
Opcode for binary arithmetic operations.
void printSCFG(CFGWalker &Walker)
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
Definition Address.h:330
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
int const char * function
Definition c++config.h:31
Encapsulates the lexical context of a function call.
llvm::PointerUnion< const Expr *const *, til::SExpr * > FunArgs
CallingContext(CallingContext *P, const NamedDecl *D=nullptr)
llvm::PointerUnion< const Expr *, til::SExpr * > SelfArg