%% $Revision: 1.5 $ $Date: 2000/06/15 20:37:37 $ %% %% March 5, 1998 %% Copyright 1995-2000 The MathWorks, Inc. %% Based on roller.tlc %% %% Abstract: use this to unroll short "for" loops %% %% IMPORTANT: Make sure to use distinct variable names for the %% roller loop variable and for "rollRegions" with nested loops. %implements InlineRoller "C" %function RollHeader(block) Output %assign ::CompiledModel.LoopControlIdx = ::CompiledModel.LoopControlIdx + 1 %assign loopVariable = "i%" { int_T %; %return loopVariable %endfunction %% Outputs %% %% LoopHeader %% %% %% C language: %% for(i = start; i < numIterations+start; i++) { %% %function LoopHeader(block, sigOffset, numIterations, rolledCount) Output %assign loopVariable = "i%" for (%=%; % < %; %++) { %endfunction %% %% LoopTrailer %% %% C language: %% } %% %function LoopTrailer(block, sigOffset, numIterations, rolledCount) Output } %endfunction %% %% RollTrailer %% %% C language: %% } %% %function RollTrailer(block) Output } %assign ::CompiledModel.LoopControlIdx = ::CompiledModel.LoopControlIdx - 1 %if LoopControlIdx < 0 %assign errTxt = "Something is wrong with loop rolling. " ... "LoopControlIdx = %" %exit RTW Assert: % %endif %endfunction