1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/angle/src/compiler/ForLoopUnroll.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,52 @@ 1.4 +// 1.5 +// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. 1.6 +// Use of this source code is governed by a BSD-style license that can be 1.7 +// found in the LICENSE file. 1.8 +// 1.9 + 1.10 +#ifndef ForLoopUnroll_h 1.11 +#define ForLoopUnroll_h 1.12 + 1.13 +#include "compiler/intermediate.h" 1.14 + 1.15 +struct TLoopIndexInfo { 1.16 + int id; 1.17 + int initValue; 1.18 + int stopValue; 1.19 + int incrementValue; 1.20 + TOperator op; 1.21 + int currentValue; 1.22 +}; 1.23 + 1.24 +class ForLoopUnroll { 1.25 +public: 1.26 + ForLoopUnroll() { } 1.27 + 1.28 + void FillLoopIndexInfo(TIntermLoop* node, TLoopIndexInfo& info); 1.29 + 1.30 + // Update the info.currentValue for the next loop iteration. 1.31 + void Step(); 1.32 + 1.33 + // Return false if loop condition is no longer satisfied. 1.34 + bool SatisfiesLoopCondition(); 1.35 + 1.36 + // Check if the symbol is the index of a loop that's unrolled. 1.37 + bool NeedsToReplaceSymbolWithValue(TIntermSymbol* symbol); 1.38 + 1.39 + // Return the current value of a given loop index symbol. 1.40 + int GetLoopIndexValue(TIntermSymbol* symbol); 1.41 + 1.42 + void Push(TLoopIndexInfo& info); 1.43 + void Pop(); 1.44 + 1.45 + static void MarkForLoopsWithIntegerIndicesForUnrolling(TIntermNode* root); 1.46 + 1.47 +private: 1.48 + int getLoopIncrement(TIntermLoop* node); 1.49 + 1.50 + int evaluateIntConstant(TIntermConstantUnion* node); 1.51 + 1.52 + TVector<TLoopIndexInfo> mLoopIndexStack; 1.53 +}; 1.54 + 1.55 +#endif