gfx/angle/src/compiler/ForLoopUnroll.h

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:e0855c61efc6
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 //
6
7 #ifndef ForLoopUnroll_h
8 #define ForLoopUnroll_h
9
10 #include "compiler/intermediate.h"
11
12 struct TLoopIndexInfo {
13 int id;
14 int initValue;
15 int stopValue;
16 int incrementValue;
17 TOperator op;
18 int currentValue;
19 };
20
21 class ForLoopUnroll {
22 public:
23 ForLoopUnroll() { }
24
25 void FillLoopIndexInfo(TIntermLoop* node, TLoopIndexInfo& info);
26
27 // Update the info.currentValue for the next loop iteration.
28 void Step();
29
30 // Return false if loop condition is no longer satisfied.
31 bool SatisfiesLoopCondition();
32
33 // Check if the symbol is the index of a loop that's unrolled.
34 bool NeedsToReplaceSymbolWithValue(TIntermSymbol* symbol);
35
36 // Return the current value of a given loop index symbol.
37 int GetLoopIndexValue(TIntermSymbol* symbol);
38
39 void Push(TLoopIndexInfo& info);
40 void Pop();
41
42 static void MarkForLoopsWithIntegerIndicesForUnrolling(TIntermNode* root);
43
44 private:
45 int getLoopIncrement(TIntermLoop* node);
46
47 int evaluateIntConstant(TIntermConstantUnion* node);
48
49 TVector<TLoopIndexInfo> mLoopIndexStack;
50 };
51
52 #endif

mercurial