|
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 _COMPILE_SCAL_ 00025 #define _COMPILE_SCAL_ 00026 00027 #include <utility> 00028 #include "compile.hh" 00029 #include "sigtyperules.hh" 00030 #include "sigtyperules.hh" 00031 #include "occurences.hh" 00032 #include "property.hh" 00033 00035 00038 00039 00040 class ScalarCompiler : public Compiler 00041 { 00042 protected: 00043 property<string> fCompileProperty; 00044 property<string> fVectorProperty; 00045 property<pair<string,string> > fStaticInitProperty; // property added to solve 20101208 kjetil bug 00046 property<pair<string,string> > fInstanceInitProperty; // property added to solve 20101208 kjetil bug 00047 00048 static map<string, int> fIDCounters; 00049 Tree fSharingKey; 00050 OccMarkup fOccMarkup; 00051 bool fHasIota; 00052 00053 00054 public: 00055 00056 ScalarCompiler ( const string& name, const string& super, int numInputs, int numOutputs) : 00057 Compiler(name,super,numInputs,numOutputs,false), 00058 fHasIota(false) 00059 {} 00060 00061 ScalarCompiler ( Klass* k) : 00062 Compiler(k), 00063 fHasIota(false) 00064 {} 00065 00066 virtual void compileMultiSignal (Tree lsig); 00067 virtual void compileSingleSignal (Tree lsig); 00068 00069 00070 protected: 00071 00072 virtual string CS (Tree sig); 00073 virtual string generateCode (Tree sig); 00074 virtual string generateCacheCode(Tree sig, const string& exp) ; 00075 00076 virtual string generateVariableStore(Tree sig, const string& exp); 00077 00078 string getFreshID (const string& prefix); 00079 00080 void compilePreparedSignalList (Tree lsig); 00081 Tree prepare(Tree L0); 00082 Tree prepare2 (Tree L0); 00083 00084 00085 bool getCompiledExpression(Tree sig, string& name); 00086 string setCompiledExpression(Tree sig, const string& name); 00087 00088 void setVectorNameProperty(Tree sig, const string& vecname); 00089 bool getVectorNameProperty(Tree sig, string& vecname); 00090 00091 int getSharingCount(Tree t); 00092 void setSharingCount(Tree t, int count); 00093 void sharingAnalysis(Tree t); 00094 void sharingAnnotation(int vctxt, Tree t); 00095 00096 00097 // generation du code 00098 00099 string generateXtended (Tree sig); 00100 virtual string generateFixDelay (Tree sig, Tree arg, Tree size); 00101 string generatePrefix (Tree sig, Tree x, Tree e); 00102 string generateIota (Tree sig, Tree arg); 00103 string generateBinOp (Tree sig, int opcode, Tree arg1, Tree arg2); 00104 00105 string generateFFun (Tree sig, Tree ff, Tree largs); 00106 00107 string generateInput (Tree sig, const string& idx); 00108 string generateOutput (Tree sig, const string& idx, const string& arg1); 00109 00110 string generateTable (Tree sig, Tree tsize, Tree content); 00111 string generateStaticTable (Tree sig, Tree tsize, Tree content); 00112 string generateWRTbl (Tree sig, Tree tbl, Tree idx, Tree data); 00113 string generateRDTbl (Tree sig, Tree tbl, Tree idx); 00114 string generateSigGen (Tree sig, Tree content); 00115 string generateStaticSigGen(Tree sig, Tree content); 00116 00117 string generateSelect2 (Tree sig, Tree sel, Tree s1, Tree s2); 00118 string generateSelect3 (Tree sig, Tree sel, Tree s1, Tree s2, Tree s3); 00119 00120 string generateRecProj (Tree sig, Tree exp, int i); 00121 void generateRec (Tree sig, Tree var, Tree le); 00122 00123 string generateIntCast (Tree sig, Tree x); 00124 string generateFloatCast (Tree sig, Tree x); 00125 00126 string generateButton (Tree sig, Tree label); 00127 string generateCheckbox (Tree sig, Tree label); 00128 string generateVSlider (Tree sig, Tree label, Tree cur, Tree min, Tree max, Tree step); 00129 string generateHSlider (Tree sig, Tree label, Tree cur, Tree min, Tree max, Tree step); 00130 string generateNumEntry (Tree sig, Tree label, Tree cur, Tree min, Tree max, Tree step); 00131 00132 string generateVBargraph (Tree sig, Tree label, Tree min, Tree max, const string& exp); 00133 string generateHBargraph (Tree sig, Tree label, Tree min, Tree max, const string& exp); 00134 00135 string generateNumber(Tree sig, const string& exp); 00136 string generateFConst (Tree sig, const string& file, const string& name); 00137 string generateFVar (Tree sig, const string& file, const string& name); 00138 00139 virtual string generateDelayVec(Tree sig, const string& exp, const string& ctype, const string& vname, int mxd); 00140 string generateDelayVecNoTemp(Tree sig, const string& exp, const string& ctype, const string& vname, int mxd); 00141 //string generateDelayVecWithTemp(Tree sig, const string& exp, const string& ctype, const string& vname, int mxd); 00142 virtual void generateDelayLine(const string& ctype, const string& vname, int mxd, const string& exp); 00143 00144 void getTypedNames(Type t, const string& prefix, string& ctype, string& vname); 00145 void ensureIotaCode(); 00146 int pow2limit(int x); 00147 00148 00149 00150 }; 00151 00152 #endif
1.8.0