|
FAUST compiler
0.9.9.6b8
|
00001 /************************************************************************ 00002 ************************************************************************ 00003 FAUST compiler 00004 Copyright (C) 2003-2004 GRAME, Centre National de Creation Musicale 00005 --------------------------------------------------------------------- 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00019 ************************************************************************ 00020 ************************************************************************/ 00021 00022 00023 00024 #ifndef _KLASS_H 00025 #define _KLASS_H 00026 00027 /********************************************************************** 00028 - klass.h : class C++ � remplir (projet FAUST) - 00029 00030 00031 Historique : 00032 ----------- 00033 17-10-2001 : implementation initiale (yo) 00034 18-10-2001 : Ajout de getFreshID (yo) 00035 02-11-2001 : Ajout de sous classes (yo) 00036 00037 ***********************************************************************/ 00038 using namespace std; 00039 00040 #include <string> 00041 #include <list> 00042 #include <set> 00043 #include <map> 00044 #include "sigtype.hh" 00045 #include "smartpointer.hh" 00046 #include "tlib.hh" 00047 #include "uitree.hh" 00048 #include "property.hh" 00049 00050 #define kMaxCategory 32 00051 00052 #include "loop.hh" 00053 #include "graphSorting.hh" 00054 00055 class Klass //: public Target 00056 { 00057 00058 protected: 00059 // we make it global because several classes may need 00060 // power def but we want the code to be generated only once 00061 static bool fNeedPowerDef; 00062 00063 00064 protected: 00065 00066 string fKlassName; 00067 string fSuperKlassName; 00068 int fNumInputs; 00069 int fNumOutputs; 00070 int fNumActives; 00071 int fNumPassives; 00072 00073 set<string> fIncludeFileSet; 00074 set<string> fLibrarySet; 00075 00076 list<Klass* > fSubClassList; 00077 00078 list<string> fDeclCode; 00079 list<string> fStaticInitCode; 00080 list<string> fStaticFields; 00081 list<string> fInitCode; 00082 list<string> fUICode; 00083 list<string> fUIMacro; 00084 00085 #if 0 00086 list<string> fSlowDecl; 00087 list<string> fSharedDecl; 00088 list<string> fCommonCode; 00089 list<string> fSlowCode; 00090 list<string> fEndCode; 00091 #endif 00092 list<string> fSharedDecl; 00093 list<string> fFirstPrivateDecl; 00094 00095 list<string> fZone1Code; 00096 list<string> fZone2Code; 00097 list<string> fZone2bCode; 00098 list<string> fZone2cCode; 00099 list<string> fZone3Code; 00100 00101 Loop* fTopLoop; 00102 property<Loop*> fLoopProperty; 00103 00104 bool fVec; 00105 00106 public: 00107 00108 Klass (const string& name, const string& super, int numInputs, int numOutputs, bool __vec = false) 00109 : fKlassName(name), fSuperKlassName(super), fNumInputs(numInputs), fNumOutputs(numOutputs), 00110 fNumActives(0), fNumPassives(0), 00111 fTopLoop(new Loop(0, "count")), fVec(__vec) 00112 {} 00113 00114 virtual ~Klass() {} 00115 00116 void openLoop(const string& size); 00117 void openLoop(Tree recsymbol, const string& size); 00118 void closeLoop(Tree sig); 00119 00120 void setLoopProperty(Tree sig, Loop* l); 00121 bool getLoopProperty(Tree sig, Loop*& l); 00122 const string& getClassName() const { return fKlassName; } 00123 00124 Loop* topLoop() { return fTopLoop; } 00125 00126 void buildTasksList(); 00127 00128 void addIncludeFile (const string& str) { fIncludeFileSet.insert(str); } 00129 00130 void addLibrary (const string& str) { fLibrarySet.insert(str); } 00131 00132 void rememberNeedPowerDef () { fNeedPowerDef = true; } 00133 00134 void collectIncludeFile(set<string>& S); 00135 00136 void collectLibrary(set<string>& S); 00137 00138 void addSubKlass (Klass* son) { fSubClassList.push_back(son); } 00139 00140 void addDeclCode (const string& str) { fDeclCode.push_back(str); } 00141 00142 void addInitCode (const string& str) { fInitCode.push_back(str); } 00143 00144 void addStaticInitCode (const string& str) { fStaticInitCode.push_back(str); } 00145 00146 void addStaticFields (const string& str) { fStaticFields.push_back(str); } 00147 00148 void addUICode (const string& str) { fUICode.push_back(str); } 00149 00150 void addUIMacro (const string& str) { fUIMacro.push_back(str); } 00151 00152 void incUIActiveCount () { fNumActives++; } 00153 void incUIPassiveCount () { fNumPassives++; } 00154 00155 00156 void addSharedDecl (const string& str) { fSharedDecl.push_back(str); } 00157 void addFirstPrivateDecl (const string& str) { fFirstPrivateDecl.push_back(str); } 00158 00159 void addZone1 (const string& str) { fZone1Code.push_back(str); } 00160 void addZone2 (const string& str) { fZone2Code.push_back(str); } 00161 void addZone2b (const string& str) { fZone2bCode.push_back(str); } 00162 void addZone2c (const string& str) { fZone2cCode.push_back(str); } 00163 void addZone3 (const string& str) { fZone3Code.push_back(str); } 00164 00165 void addPreCode ( const string& str) { fTopLoop->addPreCode(str); } 00166 void addExecCode ( const string& str) { fTopLoop->addExecCode(str); } 00167 void addPostCode (const string& str) { fTopLoop->addPostCode(str); } 00168 00169 virtual void println(int n, ostream& fout); 00170 00171 virtual void printComputeMethod (int n, ostream& fout); 00172 virtual void printComputeMethodScalar (int n, ostream& fout); 00173 virtual void printComputeMethodVectorFaster (int n, ostream& fout); 00174 virtual void printComputeMethodVectorSimple (int n, ostream& fout); 00175 virtual void printComputeMethodOpenMP (int n, ostream& fout); 00176 virtual void printComputeMethodScheduler (int n, ostream& fout); 00177 00178 virtual void printLoopGraphScalar(int n, ostream& fout); 00179 virtual void printLoopGraphVector(int n, ostream& fout); 00180 virtual void printLoopGraphOpenMP(int n, ostream& fout); 00181 virtual void printLoopGraphScheduler(int n, ostream& fout); 00182 virtual void printLoopGraphInternal(int n, ostream& fout); 00183 virtual void printGraphDotFormat(ostream& fout); 00184 00185 // experimental 00186 virtual void printLoopDeepFirst(int n, ostream& fout, Loop* l, set<Loop*>& visited); 00187 00188 virtual void printLastLoopLevelScheduler(int n, int lnum, const lset& L, ostream& fout); 00189 virtual void printLoopLevelScheduler(int n, int lnum, const lset& L, ostream& fout); 00190 virtual void printOneLoopScheduler(lset::const_iterator p, int n, ostream& fout); 00191 virtual void printLoopLevelOpenMP(int n, int lnum, const lset& L, ostream& fout); 00192 00193 virtual void printMetadata(int n, const map<Tree, set<Tree> >& S, ostream& fout); 00194 00195 virtual void printIncludeFile(ostream& fout); 00196 00197 virtual void printLibrary(ostream& fout); 00198 virtual void printAdditionalCode(ostream& fout); 00199 00200 int inputs() { return fNumInputs; } 00201 int outputs() { return fNumOutputs; } 00202 }; 00203 00204 class SigIntGenKlass : public Klass { 00205 00206 public: 00207 00208 SigIntGenKlass (const string& name) : Klass(name, "", 0, 1, false) {} 00209 00210 virtual void println(int n, ostream& fout); 00211 }; 00212 00213 class SigFloatGenKlass : public Klass { 00214 00215 public: 00216 00217 SigFloatGenKlass (const string& name) : Klass(name, "", 0, 1, false) {} 00218 00219 virtual void println(int n, ostream& fout); 00220 }; 00221 00222 00223 #endif
1.8.0