initial import
[vuplus_webkit] / Source / ThirdParty / ANGLE / src / compiler / ForLoopUnroll.h
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 #include "compiler/intermediate.h"
8
9 struct TLoopIndexInfo {
10     int id;
11     int initValue;
12     int stopValue;
13     int incrementValue;
14     TOperator op;
15     int currentValue;
16 };
17
18 class ForLoopUnroll {
19 public:
20     ForLoopUnroll() { }
21
22     void FillLoopIndexInfo(TIntermLoop* node, TLoopIndexInfo& info);
23
24     // Update the info.currentValue for the next loop iteration.
25     void Step();
26
27     // Return false if loop condition is no longer satisfied.
28     bool SatisfiesLoopCondition();
29
30     // Check if the symbol is the index of a loop that's unrolled.
31     bool NeedsToReplaceSymbolWithValue(TIntermSymbol* symbol);
32
33     // Return the current value of a given loop index symbol.
34     int GetLoopIndexValue(TIntermSymbol* symbol);
35
36     void Push(TLoopIndexInfo& info);
37     void Pop();
38
39 private:
40     int getLoopIncrement(TIntermLoop* node);
41
42     int evaluateIntConstant(TIntermConstantUnion* node);
43
44     TVector<TLoopIndexInfo> mLoopIndexStack;
45 };
46