<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>FAUST compiler: loop.hh Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.3 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <h1>loop.hh</h1><a href="loop_8hh.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/************************************************************************</span> <a name="l00002"></a>00002 <span class="comment"> ************************************************************************</span> <a name="l00003"></a>00003 <span class="comment"> FAUST compiler</span> <a name="l00004"></a>00004 <span class="comment"> Copyright (C) 2003-2004 GRAME, Centre National de Creation Musicale</span> <a name="l00005"></a>00005 <span class="comment"> ---------------------------------------------------------------------</span> <a name="l00006"></a>00006 <span class="comment"> This program is free software; you can redistribute it and/or modify</span> <a name="l00007"></a>00007 <span class="comment"> it under the terms of the GNU General Public License as published by</span> <a name="l00008"></a>00008 <span class="comment"> the Free Software Foundation; either version 2 of the License, or</span> <a name="l00009"></a>00009 <span class="comment"> (at your option) any later version.</span> <a name="l00010"></a>00010 <span class="comment"> </span> <a name="l00011"></a>00011 <span class="comment"> This program is distributed in the hope that it will be useful,</span> <a name="l00012"></a>00012 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00013"></a>00013 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span> <a name="l00014"></a>00014 <span class="comment"> GNU General Public License for more details.</span> <a name="l00015"></a>00015 <span class="comment"> </span> <a name="l00016"></a>00016 <span class="comment"> You should have received a copy of the GNU General Public License</span> <a name="l00017"></a>00017 <span class="comment"> along with this program; if not, write to the Free Software</span> <a name="l00018"></a>00018 <span class="comment"> Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.</span> <a name="l00019"></a>00019 <span class="comment"> ************************************************************************</span> <a name="l00020"></a>00020 <span class="comment"> ************************************************************************/</span> <a name="l00021"></a>00021 <a name="l00022"></a>00022 <a name="l00023"></a>00023 <a name="l00024"></a>00024 <span class="preprocessor">#ifndef _LOOP_H</span> <a name="l00025"></a>00025 <span class="preprocessor"></span><span class="preprocessor">#define _LOOP_H</span> <a name="l00026"></a>00026 <span class="preprocessor"></span> <a name="l00027"></a>00027 <span class="comment">/**********************************************************************</span> <a name="l00028"></a>00028 <span class="comment"> - loop.hh : loop C++ à remplir (projet FAUST) -</span> <a name="l00029"></a>00029 <span class="comment"> </span> <a name="l00030"></a>00030 <span class="comment"> </span> <a name="l00031"></a>00031 <span class="comment"> Historique :</span> <a name="l00032"></a>00032 <span class="comment"> -----------</span> <a name="l00033"></a>00033 <span class="comment"> 21-01-2008 : implementation initiale (yo)</span> <a name="l00034"></a>00034 <span class="comment"> </span> <a name="l00035"></a>00035 <span class="comment">***********************************************************************/</span> <a name="l00036"></a>00036 <span class="keyword">using namespace </span>std; <a name="l00037"></a>00037 <a name="l00038"></a>00038 <span class="preprocessor">#include <string></span> <a name="l00039"></a>00039 <span class="preprocessor">#include <list></span> <a name="l00040"></a>00040 <span class="preprocessor">#include <stack></span> <a name="l00041"></a>00041 <span class="preprocessor">#include <set></span> <a name="l00042"></a>00042 <span class="preprocessor">#include <map></span> <a name="l00043"></a>00043 <span class="preprocessor">#include "<a class="code" href="tlib_8hh.html">tlib.hh</a>"</span> <a name="l00044"></a>00044 <a name="l00045"></a><a class="code" href="loop_8hh.html#abfe797f193be3dd377dbbd7eb7475ef3">00045</a> <span class="preprocessor">#define kMaxCategory 32</span> <a name="l00046"></a>00046 <span class="preprocessor"></span> <a name="l00047"></a>00047 <span class="comment">/*</span> <a name="l00048"></a>00048 <span class="comment"> * Loops are lines of code that correspond to a recursive expression or a vector expression.</span> <a name="l00049"></a>00049 <span class="comment"> */</span> <a name="l00050"></a>00050 <a name="l00051"></a><a class="code" href="structLoop.html">00051</a> <span class="keyword">struct </span><a class="code" href="structLoop.html">Loop</a> <a name="l00052"></a>00052 { <a name="l00053"></a><a class="code" href="structLoop.html#a349cd08fc792c1b6b83d5860e6f1bbec">00053</a> <span class="keyword">const</span> <span class="keywordtype">bool</span> <a class="code" href="structLoop.html#a349cd08fc792c1b6b83d5860e6f1bbec" title="recursive loops can&#39;t be SIMDed">fIsRecursive</a>; <a name="l00054"></a><a class="code" href="structLoop.html#a7631d42eb807fd5d04e596e3f12c19b9">00054</a> <span class="keyword">const</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="structLoop.html#a7631d42eb807fd5d04e596e3f12c19b9" title="recursive loops define a recursive symbol">fRecSymbol</a>; <a name="l00055"></a><a class="code" href="structLoop.html#a73875fc1b6b91e2cbabeda68a8bd42f1">00055</a> <a class="code" href="structLoop.html">Loop</a>* <span class="keyword">const</span> <a class="code" href="structLoop.html#a73875fc1b6b91e2cbabeda68a8bd42f1" title="Loop from which this one originated.">fEnclosingLoop</a>; <a name="l00056"></a><a class="code" href="structLoop.html#a76e2fde1559abc10da909c83d008534e">00056</a> <span class="keyword">const</span> <span class="keywordtype">string</span> <a class="code" href="structLoop.html#a76e2fde1559abc10da909c83d008534e" title="number of iterations of the loop">fSize</a>; <a name="l00057"></a>00057 <span class="comment">// fields concerned by absorbsion</span> <a name="l00058"></a><a class="code" href="structLoop.html#adeb7ee47fa446e3c4b737d245c495c74">00058</a> set<Tree> <a class="code" href="structLoop.html#adeb7ee47fa446e3c4b737d245c495c74" title="Loops having recursive dependencies must be merged.">fRecDependencies</a>; <a name="l00059"></a><a class="code" href="structLoop.html#a73f599daabab6c3669355713ca914e83">00059</a> set<Loop*> <a class="code" href="structLoop.html#a73f599daabab6c3669355713ca914e83" title="Loops that must be computed before this one.">fBackwardLoopDependencies</a>; <a name="l00060"></a><a class="code" href="structLoop.html#ae071c221031c1f1573a43ee72d512d73">00060</a> set<Loop*> <a class="code" href="structLoop.html#ae071c221031c1f1573a43ee72d512d73" title="Loops that will be computed after this one.">fForwardLoopDependencies</a>; <a name="l00061"></a><a class="code" href="structLoop.html#a6d076c9fe43125a148ba65d28baf657a">00061</a> list<string> <a class="code" href="structLoop.html#a6d076c9fe43125a148ba65d28baf657a" title="code to execute at the begin of the loop">fPreCode</a>; <a name="l00062"></a><a class="code" href="structLoop.html#a613199ed3e3ee441d1a0be6038c0bae4">00062</a> list<string> <a class="code" href="structLoop.html#a613199ed3e3ee441d1a0be6038c0bae4" title="code to execute in the loop">fExecCode</a>; <a name="l00063"></a><a class="code" href="structLoop.html#a845bf5afe7d9e0b364bda797fcd11ca5">00063</a> list<string> <a class="code" href="structLoop.html#a845bf5afe7d9e0b364bda797fcd11ca5" title="code to execute at the end of the loop">fPostCode</a>; <a name="l00064"></a>00064 <span class="comment">// for topological sort</span> <a name="l00065"></a><a class="code" href="structLoop.html#a5fdf3e2e7d63e1ae6b0718c34021f5da">00065</a> <span class="keywordtype">int</span> <a class="code" href="structLoop.html#a5fdf3e2e7d63e1ae6b0718c34021f5da" title="used during topological sort">fOrder</a>; <a name="l00066"></a><a class="code" href="structLoop.html#a96a59acb30654a19fd06bc4e1967e169">00066</a> <span class="keywordtype">int</span> <a class="code" href="structLoop.html#a96a59acb30654a19fd06bc4e1967e169" title="used during scheduler mode code generation">fIndex</a>; <a name="l00067"></a>00067 <span class="comment">// new fields</span> <a name="l00068"></a><a class="code" href="structLoop.html#a5237f580c9e6f25693da26d00fda7798">00068</a> <span class="keywordtype">int</span> <a class="code" href="structLoop.html#a5237f580c9e6f25693da26d00fda7798" title="how many loops depend on this one">fUseCount</a>; <a name="l00069"></a><a class="code" href="structLoop.html#a51772f4f8d92fc8824addec1fe412068">00069</a> list<Loop*> <a class="code" href="structLoop.html#a51772f4f8d92fc8824addec1fe412068" title="extra loops that where in sequences">fExtraLoops</a>; <a name="l00070"></a>00070 <a name="l00071"></a>00071 <span class="keyword">public</span>: <a name="l00072"></a>00072 <a class="code" href="structLoop.html#a2ce80444f783fe1bbc854b1e84a06e78" title="create a recursive loop">Loop</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> recsymbol, <a class="code" href="structLoop.html">Loop</a>* encl, <span class="keyword">const</span> <span class="keywordtype">string</span>& size); <a name="l00073"></a>00073 <a class="code" href="structLoop.html#a2ce80444f783fe1bbc854b1e84a06e78" title="create a recursive loop">Loop</a>(<a class="code" href="structLoop.html">Loop</a>* encl, <span class="keyword">const</span> <span class="keywordtype">string</span>& size); <a name="l00074"></a>00074 <a name="l00075"></a>00075 <span class="keywordtype">bool</span> <a class="code" href="structLoop.html#a575146a1b845596fd33b7c0a2f7d48ec" title="true when the loop doesn&#39;t contain any line of code">isEmpty</a>(); <a name="l00076"></a>00076 <span class="keywordtype">bool</span> <a class="code" href="structLoop.html#a8ab807704888fd372172c3be3ddada01" title="returns true is this loop has recursive dependencies">hasRecDependencies</a>(); <a name="l00077"></a>00077 <span class="keywordtype">void</span> <a class="code" href="structLoop.html#a9412652d16b9aaa7ca21541cc0aa0229" title="Check for a recursive dependecy and add it if needed.">addRecDependency</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> t); <a name="l00078"></a>00078 <span class="keywordtype">bool</span> <a class="code" href="structLoop.html#a9e74faad0e7d3bb55619d3d90203219b" title="indicates a dependency with an enclosing loop">findRecDefinition</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> t); <a name="l00079"></a>00079 <a name="l00080"></a>00080 <span class="keywordtype">void</span> <a class="code" href="structLoop.html#adf2970f3a2f46dbcc880e9a7528c7256" title="add a line of C++ code pre code">addPreCode</a> (<span class="keyword">const</span> <span class="keywordtype">string</span>& str); <a name="l00081"></a>00081 <span class="keywordtype">void</span> <a class="code" href="structLoop.html#a1cd71f3283e7a5a2c944fb134c3dced7" title="add a line of C++ code">addExecCode</a> (<span class="keyword">const</span> <span class="keywordtype">string</span>& str); <a name="l00082"></a>00082 <span class="keywordtype">void</span> <a class="code" href="structLoop.html#a9945d29a8a375ec6c422a9327dbfa937" title="add a line of C++ post code">addPostCode</a> (<span class="keyword">const</span> <span class="keywordtype">string</span>& str); <a name="l00083"></a>00083 <span class="keywordtype">void</span> <a class="code" href="structLoop.html#ae50f255d2f1622ffca999f5f755be494" title="print the loop">println</a> (<span class="keywordtype">int</span> n, ostream& fout); <a name="l00084"></a>00084 <span class="keywordtype">void</span> <a class="code" href="structLoop.html#ac289865e495156b736961cea11651710" title="print the loop in scalar mode">printoneln</a> (<span class="keywordtype">int</span> n, ostream& fout); <a name="l00085"></a>00085 <a name="l00086"></a>00086 <span class="keywordtype">void</span> <a class="code" href="structLoop.html#a1774fc6f54824e4a8c9bc2eb9bc34c24" title="absorb a loop inside this one">absorb</a>(<a class="code" href="structLoop.html">Loop</a>* l); <a name="l00087"></a>00087 <span class="comment">// new method</span> <a name="l00088"></a>00088 <span class="keywordtype">void</span> <a class="code" href="structLoop.html#a11c5adcd88f4c8fabbaa9f6feae5a8f7">concat</a>(<a class="code" href="structLoop.html">Loop</a>* l); <a name="l00089"></a>00089 }; <a name="l00090"></a>00090 <a name="l00091"></a>00091 <span class="preprocessor">#endif</span> </pre></div></div> <hr class="footer"/><address style="text-align: right;"><small>Generated on Wed Apr 28 23:59:59 2010 for FAUST compiler by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address> </body> </html>