Chisel
GlobalReduction.h
Go to the documentation of this file.
1 #ifndef GLOBAL_REDUCTION_H
2 #define GLOBAL_REDUCTION_H
3 
4 #include <vector>
5 
6 #include "clang/AST/RecursiveASTVisitor.h"
7 
8 #include "Reduction.h"
9 
11 
15 class GlobalReduction : public Reduction {
17 
18 public:
19  GlobalReduction() : CollectionVisitor(NULL) {}
20  ~GlobalReduction() { delete CollectionVisitor; }
21 
22 private:
23  void Initialize(clang::ASTContext &Ctx);
24  bool HandleTopLevelDecl(clang::DeclGroupRef D);
25  void HandleTranslationUnit(clang::ASTContext &Ctx);
26 
27  static DDElement CastElement(clang::Decl *D);
28 
29  bool callOracle();
30  bool test(DDElementVector &ToBeRemoved);
31  bool isInvalidChunk(DDElementVector &Chunk);
32  void filterElements(DDElementVector &Vec);
33 
34  std::vector<clang::Decl *> Decls;
35  std::map<clang::Decl *, bool> UseInfo;
36  GlobalElementCollectionVisitor *CollectionVisitor;
37 };
38 
40  : public clang::RecursiveASTVisitor<GlobalElementCollectionVisitor> {
41 public:
43 
44  bool VisitDeclRefExpr(clang::DeclRefExpr *DRE);
45  bool VisitFunctionDecl(clang::FunctionDecl *FD);
46  bool VisitVarDecl(clang::VarDecl *VD);
47  bool VisitEmptyDecl(clang::EmptyDecl *ED);
48 
49 private:
50  GlobalReduction *Consumer;
51 };
52 
53 #endif // GLOBAL_REDUCTION_H
Represents a general reduction step.
Definition: Reduction.h:14
clang::DeclGroupRef DeclGroupRef
Definition: LocalReduction.cpp:16
Represents a global reduction phase.
Definition: GlobalReduction.h:15
std::vector< DDElement > DDElementVector
Definition: ProbabilisticModel.h:12
clang::VarDecl VarDecl
Definition: LocalReduction.cpp:28
Definition: GlobalReduction.h:39
clang::FunctionDecl FunctionDecl
Definition: LocalReduction.cpp:18
clang::DeclRefExpr DeclRefExpr
Definition: LocalReduction.cpp:32
~GlobalReduction()
Definition: GlobalReduction.h:20
clang::Decl Decl
Definition: LocalReduction.cpp:29
GlobalElementCollectionVisitor(GlobalReduction *R)
Definition: GlobalReduction.h:42
GlobalReduction()
Definition: GlobalReduction.h:19
llvm::PointerUnion< clang::Decl *, clang::Stmt * > DDElement
Definition: ProbabilisticModel.h:11