59 Stmt *body = fstmt->getBody();
63 int tx = 1, ty = 1, tz = 1, bx = 1, by = 1, bz = 1, gpu_time = 0,
64 cpu_time = 0, instanceNum = 0;
65 for (Stmt::child_iterator it = body->child_begin(), eit = body->child_end();
70 if (DeclStmt *ds = dyn_cast<DeclStmt>(s)) {
71 if (VarDecl *vd = dyn_cast<VarDecl>(ds->getSingleDecl())) {
72 string className = vd->getTypeSourceInfo()
74 .getBaseTypeIdentifier()
76 if (className ==
"profile_time") {
77 if (CXXConstructExpr *ce =
78 dyn_cast<CXXConstructExpr>(vd->getInit()->IgnoreImpCasts())) {
79 if (MaterializeTemporaryExpr *me =
80 dyn_cast<MaterializeTemporaryExpr>(
81 ce->getArg(0)->IgnoreImpCasts())) {
82 if (CXXTemporaryObjectExpr *co = dyn_cast<CXXTemporaryObjectExpr>(
83 me->GetTemporaryExpr()->IgnoreImpCasts())) {
85 IntegerLiteral *x = dyn_cast<IntegerLiteral>(co->getArg(0));
86 IntegerLiteral *y = dyn_cast<IntegerLiteral>(co->getArg(1));
87 IntegerLiteral *z = dyn_cast<IntegerLiteral>(co->getArg(2));
89 instanceNum = x->getValue().getSExtValue();
90 gpu_time = y->getValue().getSExtValue();
91 cpu_time = z->getValue().getSExtValue();
97 if (className ==
"sc_gpu_thread_hierarchy") {
98 if (CXXConstructExpr *ce =
99 dyn_cast<CXXConstructExpr>(vd->getInit()->IgnoreImpCasts())) {
100 if (MaterializeTemporaryExpr *me =
101 dyn_cast<MaterializeTemporaryExpr>(
102 ce->getArg(0)->IgnoreImpCasts())) {
103 if (CXXTemporaryObjectExpr *co = dyn_cast<CXXTemporaryObjectExpr>(
104 me->GetTemporaryExpr()->IgnoreImpCasts())) {
105 IntegerLiteral *x = dyn_cast<IntegerLiteral>(co->getArg(1));
106 IntegerLiteral *y = dyn_cast<IntegerLiteral>(co->getArg(2));
107 IntegerLiteral *z = dyn_cast<IntegerLiteral>(co->getArg(3));
108 IntegerLiteral *w = dyn_cast<IntegerLiteral>(co->getArg(4));
109 instanceNum = x->getValue().getSExtValue();
110 tx = x->getValue().getSExtValue();
111 ty = y->getValue().getSExtValue();
112 tz = z->getValue().getSExtValue();
117 if (className ==
"sc_gpu_block_hierarchy") {
118 if (CXXConstructExpr *ce =
119 dyn_cast<CXXConstructExpr>(vd->getInit()->IgnoreImpCasts())) {
120 if (MaterializeTemporaryExpr *me =
121 dyn_cast<MaterializeTemporaryExpr>(
122 ce->getArg(0)->IgnoreImpCasts())) {
123 if (CXXTemporaryObjectExpr *co = dyn_cast<CXXTemporaryObjectExpr>(
124 me->GetTemporaryExpr()->IgnoreImpCasts())) {
125 IntegerLiteral *x = dyn_cast<IntegerLiteral>(co->getArg(1));
126 IntegerLiteral *y = dyn_cast<IntegerLiteral>(co->getArg(2));
127 IntegerLiteral *z = dyn_cast<IntegerLiteral>(co->getArg(3));
128 IntegerLiteral *w = dyn_cast<IntegerLiteral>(co->getArg(4));
130 instanceNum = x->getValue().getSExtValue();
131 bx = y->getValue().getSExtValue();
132 by = z->getValue().getSExtValue();
133 bz = w->getValue().getSExtValue();
143 if (tx && ty && tz && bx && by && bz && gpu_time && cpu_time &&
192 if (CastExpr *cast = dyn_cast<CastExpr>(base)) {
193 Expr *subExpr = cast->getSubExpr();
195 if (DeclRefExpr *declRef = dyn_cast<DeclRefExpr>(subExpr)) {
204 }
else if (MemberExpr *member = dyn_cast<MemberExpr>(subExpr)) {
206 lhs_decls.insert(member->getMemberDecl());
209 rhs_decls.insert(member->getMemberDecl());
214 _os <<
"Type not a DeclRefExpr" << cast->getStmtClassName() <<
"\n";
217 _os <<
"Type not a CastExpr" << cast->getStmtClassName() <<
"\n";