systemc-clang 2.0.0
Parsing SystemC constructs
Loading...
Searching...
No Matches
SuspensionAutomata.h
Go to the documentation of this file.
1#ifndef _SUSPENSION_AUTOMATA_H_
2#define _SUSPENSION_AUTOMATA_H_
3
4#include "Automata.h"
5#include "Utility.h"
6#include "WaitContainer.h"
7#include "clang/AST/DeclCXX.h"
8#include "clang/AST/ParentMap.h"
9#include "clang/Analysis/CFG.h"
10#include "clang/Analysis/CFGStmtMap.h"
11#include "llvm/Support/raw_ostream.h"
12#include <map>
13namespace systemc_clang {
14
15using namespace clang;
16using namespace std;
17
18class SusCFG {
19public:
20 SusCFG(CFGBlock *);
21 ~SusCFG();
22 void addPredBlocks(SusCFG *);
23 void addSuccBlocks(SusCFG *);
24 void addParentBlock(CFGBlock *);
25 void addParentBlock(SusCFG *);
26 void setWaitBlock();
27 void setWaitStmt(Stmt *);
28 void setParentBlock();
30 void addChildBlockList(vector<SusCFG *>);
31 void addGPUFit();
32 void denyGPUFit();
33
34 bool isWaitBlock();
35 bool isParentBlock();
37 bool isGPUFit();
38
39 unsigned int getBlockID();
40 unsigned int getParentBlockID();
41 vector<SusCFG *> getChildBlockList();
42 vector<SusCFG *> getPredBlocks();
43 vector<SusCFG *> getSuccBlocks();
44 CFGBlock *getBlock();
45 CFGBlock *getParentCFGBlock();
47 Stmt *getWaitStmt();
48
49private:
50 CFGBlock *_block;
51 CFGBlock *_parentCFGBlock;
53 vector<SusCFG *> _predBlocks;
54 vector<SusCFG *> _succBlocks;
55 // need to add a isTranslateCUDA field here
59 Stmt *_waitStmt;
60 vector<SusCFG *> _childBlockList;
61};
63class State {
64public:
65 State(SusCFG *, bool, bool, bool, bool);
66 ~State();
67
68 bool isTimed();
69 bool isDelta();
70 bool isInitial();
71 bool isEvent();
72 void addEventName(string);
73 void addSimTime(float);
74 void setTimed();
75 void setDelta();
76 void setEvent();
77 void setInitial();
78
79 string getEventName();
80 float getSimTime();
82
83private:
89 string _eventName;
90 float _timeInNS;
91};
94public:
95 Transition();
97
98 void addInitialState(State *);
99 void addFinalState(State *);
100 void addCodeBlocks(SusCFG *);
101 void addCodeBlocks(vector<SusCFG *>);
102 void addInstanceId(int);
103
106 vector<SusCFG *> returnCodeBlocks();
107 int returnInstanceId();
108
109 void dump(raw_ostream &);
110
111private:
113 vector<SusCFG *> _codeBlockVector;
116};
117
119
121public:
122 typedef vector<SusCFG *> susCFGVectorType;
123 typedef vector<Transition *> transitionVectorType;
124
125 typedef pair<SusCFG *, int> susCFGSuccIDPairType;
126 typedef map<SusCFG *, int> susCFGSuccIDMapType;
127
128 typedef pair<SusCFG *, State *> susCFGStatePairType;
129 typedef map<SusCFG *, State *> susCFGStateMapType;
130
131 typedef pair<State *, vector<SusCFG *>> stateCommonCodeBlockPairType;
132 typedef map<State *, vector<SusCFG *>> stateCommonCodeBlockMapType;
133
134 SuspensionAutomata(vector<WaitContainer *>, CXXMethodDecl *, ASTContext *,
135 llvm::raw_ostream &);
137 void addRemainingBlocks(State *, vector<SusCFG *> &);
138 void checkInsert(vector<SusCFG *>, vector<SusCFG *> &);
139 bool isFound(vector<SusCFG *>, SusCFG *);
140 bool isFound(vector<Transition *>, Transition *);
141 bool initialize();
142 void genSusCFG();
143 void genSauto();
144 vector<SusCFG *> modifDFS(SusCFG *, State *);
145 bool isWaitCall(const CFGStmt *cs);
146 bool isTimedWait(Stmt *stmt);
147 bool isDeltaWait(Stmt *stmt);
148 bool isEventWait(Stmt *stmt);
149 float getTime(Stmt *stmt);
150 string getEvent(Stmt *stmt);
151 string getArgumentName(Expr * arg);
152 void addEvent(string);
153 void addSimTime(float);
156
157 void dumpSusCFG();
158 void dumpSauto();
159
160private:
161 CXXMethodDecl *_d;
162 vector<CallExpr *> _waitCalls;
165 unique_ptr<CFG> _cfg;
166 ASTContext *_a;
167 raw_ostream &_os;
171}; // End class SplitWaitBlocks
172} // End namespace systemc_clang
173#endif
A set of utility functions in the Utility class.
State(SusCFG *, bool, bool, bool, bool)
vector< SusCFG * > getSuccBlocks()
void addParentBlock(CFGBlock *)
vector< SusCFG * > getChildBlockList()
vector< SusCFG * > getPredBlocks()
vector< SusCFG * > _childBlockList
vector< SusCFG * > _predBlocks
vector< SusCFG * > _succBlocks
SuspensionAutomata(vector< WaitContainer * >, CXXMethodDecl *, ASTContext *, llvm::raw_ostream &)
stateCommonCodeBlockMapType _stateCommonCodeBlockMap
pair< SusCFG *, int > susCFGSuccIDPairType
void addRemainingBlocks(State *, vector< SusCFG * > &)
pair< State *, vector< SusCFG * > > stateCommonCodeBlockPairType
vector< SusCFG * > modifDFS(SusCFG *, State *)
pair< SusCFG *, State * > susCFGStatePairType
map< SusCFG *, State * > susCFGStateMapType
vector< Transition * > transitionVectorType
bool isFound(vector< SusCFG * >, SusCFG *)
void checkInsert(vector< SusCFG * >, vector< SusCFG * > &)
map< State *, vector< SusCFG * > > stateCommonCodeBlockMapType
vector< SusCFG * > _codeBlockVector
vector< SusCFG * > returnCodeBlocks()
Clang forward declarations.
Definition FindArgument.h:6