-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathRulesLangGraph.cpp
More file actions
54 lines (46 loc) · 1.65 KB
/
RulesLangGraph.cpp
File metadata and controls
54 lines (46 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//===--------------- RulesLangGraph.cpp ----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "RuleInfra/ExprAnalysis.h"
#include "RuleInfra/MigrationStatistics.h"
#include "RulesLang.h"
#include "Utility.h"
#include "clang/AST/Expr.h"
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/Basic/Cuda.h"
using namespace clang;
using namespace clang::ast_matchers;
using namespace clang::dpct;
using namespace clang::tooling;
extern clang::tooling::UnifiedPath
DpctInstallPath; // Installation directory for this tool
extern DpctOption<opt, bool> ProcessAll;
extern DpctOption<opt, bool> AsyncHandler;
namespace clang {
namespace dpct {
void GraphRule::registerMatcher(MatchFinder &MF) {
auto functionName = [&]() {
return hasAnyName("cudaGraphInstantiate", "cudaGraphLaunch",
"cudaGraphExecDestroy", "cudaGraphAddEmptyNode",
"cudaGraphAddDependencies", "cudaGraphExecUpdate",
"cudaGraphDebugDotPrint");
};
MF.addMatcher(
callExpr(callee(functionDecl(functionName()))).bind("FunctionCall"),
this);
}
void GraphRule::runRule(const MatchFinder::MatchResult &Result) {
const CallExpr *CE = getNodeAsType<CallExpr>(Result, "FunctionCall");
if (!CE) {
return;
}
ExprAnalysis EA(CE);
emplaceTransformation(EA.getReplacement());
EA.applyAllSubExprRepl();
}
} // namespace dpct
} // namespace clang