FAUST compiler  0.9.9.6b8
loop.hh
Go to the documentation of this file.
1 /************************************************************************
2  ************************************************************************
3  FAUST compiler
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.
10 
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.
15 
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  ************************************************************************/
21 
22 
23 
24 #ifndef _LOOP_H
25 #define _LOOP_H
26 
27 /**********************************************************************
28  - loop.hh : loop C++ à remplir (projet FAUST) -
29 
30 
31  Historique :
32  -----------
33  21-01-2008 : implementation initiale (yo)
34 
35 ***********************************************************************/
36 namespace std{}
37 using namespace std;
38 
39 #include <string>
40 #include <list>
41 #include <stack>
42 #include <set>
43 #include <map>
44 #include "tlib.hh"
45 
46 #define kMaxCategory 32
47 
48 /*
49  * Loops are lines of code that correspond to a recursive expression or a vector expression.
50  */
51 
52 struct Loop
53 {
54  const bool fIsRecursive;
57  const string fSize;
58  // fields concerned by absorbsion
61  list<string> fPreCode;
62  list<string> fExecCode;
63  list<string> fPostCode;
64  // for topological sort
65  int fOrder;
66  int fIndex;
67  // new fields
68  int fUseCount;
69  list<Loop*> fExtraLoops;
70 
71  int fPrinted;
72 
73 public:
74  Loop(Tree recsymbol, Loop* encl, const string& size);
75  Loop(Loop* encl, const string& size);
76 
77  bool isEmpty();
78  bool hasRecDependencyIn(Tree S);
79 
80  void addPreCode (const string& str);
81  void addExecCode (const string& str);
82  void addPostCode (const string& str);
83  void println (int n, ostream& fout);
84  void printParLoopln(int n, ostream& fout);
85 
86  void printoneln (int n, ostream& fout);
87 
88  void absorb(Loop* l);
89  // new method
90  void concat(Loop* l);
91 };
92 
93 #endif
Loop *const fEnclosingLoop
Loop from which this one originated.
Definition: loop.hh:56
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
list< string > fPostCode
code to execute at the end of the loop
Definition: loop.hh:63
int fUseCount
how many loops depend on this one
Definition: loop.hh:68
const bool fIsRecursive
recursive loops can't be SIMDed
Definition: loop.hh:54
Tree fRecSymbolSet
recursive loops define a set of recursive symbol
Definition: loop.hh:55
int fPrinted
true when loop has been printed (to track multi-print errors)
Definition: loop.hh:71
list< string > fExecCode
code to execute in the loop
Definition: loop.hh:62
list< Loop * > fExtraLoops
extra loops that where in sequences
Definition: loop.hh:69
Tree concat(Tree l, Tree q)
Definition: list.cpp:216
int fOrder
used during topological sort
Definition: loop.hh:65
const string fSize
number of iterations of the loop
Definition: loop.hh:57
Definition: loop.hh:52
list< string > fPreCode
code to execute at the begin of the loop
Definition: loop.hh:61
int fIndex
used during scheduler mode code generation
Definition: loop.hh:66
set< Loop * > fBackwardLoopDependencies
Loops that must be computed before this one.
Definition: loop.hh:59
set< Loop * > fForwardLoopDependencies
Loops that will be computed after this one.
Definition: loop.hh:60