-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathextractor.h
More file actions
64 lines (48 loc) · 3.38 KB
/
extractor.h
File metadata and controls
64 lines (48 loc) · 3.38 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
55
56
57
58
59
60
61
62
63
64
#ifndef KSLICER_EXTRACTOR_H
#define KSLICER_EXTRACTOR_H
#include "kslicer.h"
#include "clang/Tooling/Tooling.h"
#include <string>
#include <vector>
#include <unordered_map>
#include <sstream>
#include <iostream>
namespace kslicer
{
using namespace llvm;
using namespace clang;
std::vector<kslicer::FuncData> ExtractUsedFunctions(MainClassInfo& a_codeInfo, const clang::CompilerInstance& a_compiler);
std::vector<kslicer::FuncData> ExtractUsedFromVFH(MainClassInfo& a_codeInfo, const clang::CompilerInstance& a_compiler, std::unordered_map<uint64_t, kslicer::FuncData>& usedFunctions);
std::vector<kslicer::DeclInClass> ExtractUsedTC(const std::vector<kslicer::DeclInClass>& a_listedNames, const clang::CXXRecordDecl* classAstNode, const clang::CompilerInstance& a_compiler);
std::vector<kslicer::DeclInClass> ExtractTCFromClass(const std::string& a_className, const clang::CXXRecordDecl* classAstNode,
const clang::CompilerInstance& compiler, clang::tooling::ClangTool& Tool);
std::unordered_map<std::string, kslicer::DataMemberInfo> ExtractUsedMemberData(kslicer::KernelInfo* pKernel, const kslicer::FuncData& a_funcData, const std::vector<kslicer::FuncData>& a_otherMambers,
std::unordered_map<std::string, kslicer::UsedContainerInfo>& a_auxContainers,
MainClassInfo& a_codeInfo, const clang::CompilerInstance& a_compiler);
std::vector< std::unordered_map<std::string, std::string> > ArgMatchTraversal(kslicer::KernelInfo* pKernel, const kslicer::FuncData& a_funcData, const std::vector<kslicer::FuncData>& a_otherMambers,
MainClassInfo& a_codeInfo, const clang::CompilerInstance& a_compiler);
std::vector<std::string> ExtractDefines(const clang::CompilerInstance& a_compiler);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////// NodesMarker //////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class NodesMarker : public RecursiveASTVisitor<NodesMarker> // mark all subsequent nodes to be rewritten, put their ash codes in 'rewrittenNodes'
{
public:
NodesMarker(std::unordered_set<uint64_t>& a_rewrittenNodes) : m_rewrittenNodes(a_rewrittenNodes){}
bool VisitStmt(Stmt* expr);
private:
std::unordered_set<uint64_t>& m_rewrittenNodes;
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////// NewKernelExtractor ///////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct KernelNodes
{
const clang::Stmt* loopStart = nullptr;
const clang::Expr* loopStride = nullptr;
const clang::Expr* loopSize = nullptr;
const clang::Stmt* loopBody = nullptr;
};
KernelNodes ExtractKernelForLoops(const clang::Stmt* kernelBody, int a_loopsNumber, const clang::CompilerInstance& a_compiler);
}
#endif