1 // Copyright (C) 2009 Free Software Foundation, Inc.
2 // Contributed by Jan Sjodin <jan.sjodin@amd.com>.
4 // This file is part of the Polyhedral Compilation Package Library (libpcp).
6 // Libpcp is free software; you can redistribute it and/or modify it
7 // under the terms of the GNU Lesser General Public License as published by
8 // the Free Software Foundation; either version 2.1 of the License, or
9 // (at your option) any later version.
11 // Libpcp is distributed in the hope that it will be useful, but WITHOUT ANY
12 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with libpcp; see the file COPYING.LIB. If not, write to the
18 // Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 // MA 02110-1301, USA.
21 // As a special exception, if you link this library with other files, some
22 // of which are compiled with GCC, to produce an executable, this library
23 // does not by itself cause the resulting executable to be covered by the
24 // GNU General Public License. This exception does not however invalidate
25 // any other reasons why the executable file might be covered by the GNU
26 // General Public License.
29 #include "pcp_visitor.h"
32 PcpVisitor::visitChildren(PcpArrayType
* arrayType
)
34 PcpIterator
<PcpExpr
*>* iter
= arrayType
->getDimensionsIterator();
35 for(;iter
->hasNext(); iter
->next())
37 iter
->get()->accept(this);
43 PcpVisitor::visitChildren(PcpArith
* arith
)
45 PcpIterator
<PcpExpr
*>* iter
= arith
->getOperandsIterator();
46 for(;iter
->hasNext(); iter
->next())
48 iter
->get()->accept(this);
54 PcpVisitor::visitChildren(PcpArrayAccess
* arrayAccess
)
56 PcpIterator
<PcpExpr
*>* iter
= arrayAccess
->getSubscriptsIterator();
57 for(;iter
->hasNext(); iter
->next())
59 iter
->get()->accept(this);
65 PcpVisitor::visitChildren(PcpCopy
* copy
)
67 copy
->getDest()->accept(this);
68 copy
->getSrc()->accept(this);
72 PcpVisitor::visitChildren(PcpUserStmt
* userStmt
)
74 PcpIterator
<PcpArrayAccess
*>* iter
= userStmt
->getArrayAccessesIterator();
75 for(;iter
->hasNext(); iter
->next())
77 iter
->get()->accept(this);
83 PcpVisitor::visitChildren(PcpSequence
* sequence
)
85 PcpIterator
<PcpStmt
*>* iter
= sequence
->getStmtsIterator();
86 for(;iter
->hasNext(); iter
->next())
88 iter
->get()->accept(this);
94 PcpVisitor::visitChildren(PcpGuard
* guard
)
96 guard
->getCondition()->accept(this);
97 guard
->getBody()->accept(this);
101 PcpVisitor::visitChildren(PcpLoop
* loop
)
103 loop
->getIv()->accept(this);
104 loop
->getStart()->accept(this);
105 loop
->getCondition()->accept(this);
106 loop
->getStride()->accept(this);
107 loop
->getBody()->accept(this);
111 PcpVisitor::visitChildren(PcpScop
* scop
)
113 PcpIterator
<PcpVariable
*>* varIter
= scop
->getVariablesIterator();
114 for(;varIter
->hasNext(); varIter
->next())
116 varIter
->get()->accept(this);
120 PcpIterator
<PcpParameter
*>* paramIter
= scop
->getParametersIterator();
121 for(;paramIter
->hasNext(); paramIter
->next())
123 paramIter
->get()->accept(this);
127 scop
->getBody()->accept(this);
131 PcpVisitor::visitChildren(PcpCompare
* compare
)
133 this->visit(compare
->getLhs());
134 this->visit(compare
->getRhs());
139 PcpVisitor::visit(PcpObject
* object
)
141 // Do nothing since this is the top level.
145 PcpVisitor::visit(PcpArrayType
* arrayType
)
147 this->visit((PcpObject
*)arrayType
);
151 PcpVisitor::visit(PcpArith
* arith
)
153 this->visit((PcpExpr
*) arith
);
157 PcpVisitor::visit(PcpConstant
* constant
)
159 this->visit((PcpExpr
*) constant
);
163 PcpVisitor::visit(PcpIv
* iv
)
165 this->visit((PcpExpr
*) iv
);
169 PcpVisitor::visit(PcpParameter
* parameter
)
171 this->visit((PcpExpr
*) parameter
);
175 PcpVisitor::visit(PcpCompare
* compare
)
177 this->visit((PcpBoolExpr
*) compare
);
181 PcpVisitor::visit(PcpBoolArith
* boolArith
)
183 this->visit((PcpBoolExpr
*) boolArith
);
187 PcpVisitor::visit(PcpVariable
* variable
)
189 this->visit((PcpObject
*) variable
);
193 PcpVisitor::visit(PcpArrayAccess
* arrayAccess
)
195 this->visit((PcpObject
*) arrayAccess
);
199 PcpVisitor::visit(PcpCopy
* copy
)
201 this->visit((PcpStmt
*) copy
);
205 PcpVisitor::visit(PcpUserStmt
* userStmt
)
207 this->visit((PcpStmt
*) userStmt
);
211 PcpVisitor::visit(PcpSequence
* sequence
)
213 this->visit((PcpStmt
*) sequence
);
217 PcpVisitor::visit(PcpGuard
* guard
)
219 this->visit((PcpStmt
*) guard
);
223 PcpVisitor::visit(PcpLoop
* loop
)
225 this->visit((PcpStmt
*) loop
);
229 PcpVisitor::visit(PcpScop
* scop
)
231 this->visit((PcpObject
*) scop
);
235 PcpVisitor::visit(PcpExpr
* expr
)
237 this->visit((PcpObject
*) expr
);
241 PcpVisitor::visit(PcpBoolExpr
* boolExpr
)
243 this->visit((PcpObject
*) boolExpr
);
247 PcpVisitor::visit(PcpStmt
* stmt
)
249 this->visit((PcpObject
*) stmt
);
253 PcpVisitor::visit(PcpAnnot
* annot
)
255 // Do nothing. Top level.
259 PcpVisitor::visit(PcpAnnotSet
* annot
)
261 // Do nothing. Top level.
265 PcpVisitor::visit(PcpAnnotInt
* annotInt
)
267 this->visit((PcpAnnot
*) annotInt
);
271 PcpVisitor::visit(PcpAnnotTerm
* annotTerm
)
273 this->visit((PcpAnnot
*) annotTerm
);
277 PcpVisitor::visit(PcpAnnotString
* annotString
)
279 this->visit((PcpAnnot
*) annotString
);
283 PcpVisitor::visit(PcpAnnotObject
* annotObject
)
285 this->visit((PcpAnnot
*) annotObject
);
288 PcpVisitor::PcpVisitor()