1 /************************************************************************
2 ************************************************************************
4 Copyright (C) 2003-2004 GRAME, Centre National de Creation Musicale
5 ---------------------------------------------------------------------
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 ************************************************************************
20 ************************************************************************/
27 /**********************************************************************
28 - loop.hh : loop C++ à remplir (projet FAUST) -
33 21-01-2008 : implementation initiale (yo)
35 ***********************************************************************/
46 #define kMaxCategory 32
49 * Loops are lines of code that correspond to a recursive expression or a vector expression.
54 const bool fIsRecursive; ///< recursive loops can't be SIMDed
55 Tree fRecSymbolSet; ///< recursive loops define a set of recursive symbol
56 Loop* const fEnclosingLoop; ///< Loop from which this one originated
57 const string fSize; ///< number of iterations of the loop
58 // fields concerned by absorbsion
59 set<Loop*> fBackwardLoopDependencies; ///< Loops that must be computed before this one
60 set<Loop*> fForwardLoopDependencies; ///< Loops that will be computed after this one
61 list<string> fPreCode; ///< code to execute at the begin of the loop
62 list<string> fExecCode; ///< code to execute in the loop
63 list<string> fPostCode; ///< code to execute at the end of the loop
64 // for topological sort
65 int fOrder; ///< used during topological sort
66 int fIndex; ///< used during scheduler mode code generation
68 int fUseCount; ///< how many loops depend on this one
69 list<Loop*> fExtraLoops; ///< extra loops that where in sequences
71 int fPrinted; ///< true when loop has been printed (to track multi-print errors)
74 Loop(Tree recsymbol, Loop* encl, const string& size); ///< create a recursive loop
75 Loop(Loop* encl, const string& size); ///< create a non recursive loop
77 bool isEmpty(); ///< true when the loop doesn't contain any line of code
78 bool hasRecDependencyIn(Tree S); ///< returns true is this loop or its ancestors define a symbol in S
80 void addPreCode (const string& str); ///< add a line of C++ code pre code
81 void addExecCode (const string& str); ///< add a line of C++ code
82 void addPostCode (const string& str); ///< add a line of C++ post code
83 void println (int n, ostream& fout); ///< print the loop
84 void printParLoopln(int n, ostream& fout); ///< print the loop with a #pragma omp loop
86 void printoneln (int n, ostream& fout); ///< print the loop in scalar mode
88 void absorb(Loop* l); ///< absorb a loop inside this one