Wed, 31 Dec 2014 07:16:47 +0100
Revert simplistic fix pending revisit of Mozilla integration attempt.
1 //
2 // Copyright (c) 2011 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
7 #ifndef ForLoopUnroll_h
8 #define ForLoopUnroll_h
10 #include "compiler/intermediate.h"
12 struct TLoopIndexInfo {
13 int id;
14 int initValue;
15 int stopValue;
16 int incrementValue;
17 TOperator op;
18 int currentValue;
19 };
21 class ForLoopUnroll {
22 public:
23 ForLoopUnroll() { }
25 void FillLoopIndexInfo(TIntermLoop* node, TLoopIndexInfo& info);
27 // Update the info.currentValue for the next loop iteration.
28 void Step();
30 // Return false if loop condition is no longer satisfied.
31 bool SatisfiesLoopCondition();
33 // Check if the symbol is the index of a loop that's unrolled.
34 bool NeedsToReplaceSymbolWithValue(TIntermSymbol* symbol);
36 // Return the current value of a given loop index symbol.
37 int GetLoopIndexValue(TIntermSymbol* symbol);
39 void Push(TLoopIndexInfo& info);
40 void Pop();
42 static void MarkForLoopsWithIntegerIndicesForUnrolling(TIntermNode* root);
44 private:
45 int getLoopIncrement(TIntermLoop* node);
47 int evaluateIntConstant(TIntermConstantUnion* node);
49 TVector<TLoopIndexInfo> mLoopIndexStack;
50 };
52 #endif