zenilib: zenilib/jni/external/angle/src/compiler/depgraph/DependencyGraph.cpp Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DependencyGraph.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2012 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 #pragma warning(disable: 4718)
8
9 #include "compiler/depgraph/DependencyGraph.h"
10 #include "compiler/depgraph/DependencyGraphBuilder.h"
11
12 TDependencyGraph::TDependencyGraph(TIntermNode* intermNode)
13 {
14 TDependencyGraphBuilder::build(intermNode, this);
15 }
16
17 TDependencyGraph::~TDependencyGraph()
18 {
19 for (TGraphNodeVector::const_iterator iter = mAllNodes.begin(); iter != mAllNodes.end(); ++iter)
20 {
21 TGraphNode* node = *iter;
22 delete node;
23 }
24 }
25
26 TGraphArgument* TDependencyGraph::createArgument(TIntermAggregate* intermFunctionCall,
27 int argumentNumber)
28 {
29 TGraphArgument* argument = new TGraphArgument(intermFunctionCall, argumentNumber);
30 mAllNodes.push_back(argument);
31 return argument;
32 }
33
34 TGraphFunctionCall* TDependencyGraph::createFunctionCall(TIntermAggregate* intermFunctionCall)
35 {
36 TGraphFunctionCall* functionCall = new TGraphFunctionCall(intermFunctionCall);
37 mAllNodes.push_back(functionCall);
38 if (functionCall->getIntermFunctionCall()->isUserDefined())
39 mUserDefinedFunctionCalls.push_back(functionCall);
40 return functionCall;
41 }
42
43 TGraphSymbol* TDependencyGraph::getOrCreateSymbol(TIntermSymbol* intermSymbol)
44 {
45 TSymbolIdMap::const_iterator iter = mSymbolIdMap.find(intermSymbol->getId());
46
47 TGraphSymbol* symbol = NULL;
48
49 if (iter != mSymbolIdMap.end()) {
50 TSymbolIdPair pair = *iter;
51 symbol = pair.second;
52 } else {
53 symbol = new TGraphSymbol(intermSymbol);
54 mAllNodes.push_back(symbol);
55
56 TSymbolIdPair pair(intermSymbol->getId(), symbol);
57 mSymbolIdMap.insert(pair);
58
59 // We save all sampler symbols in a collection, so we can start graph traversals from them quickly.
60 if (IsSampler(intermSymbol->getBasicType()))
61 mSamplerSymbols.push_back(symbol);
62 }
63
64 return symbol;
65 }
66
67 TGraphSelection* TDependencyGraph::createSelection(TIntermSelection* intermSelection)
68 {
69 TGraphSelection* selection = new TGraphSelection(intermSelection);
70 mAllNodes.push_back(selection);
71 return selection;
72 }
73
74 TGraphLoop* TDependencyGraph::createLoop(TIntermLoop* intermLoop)
75 {
76 TGraphLoop* loop = new TGraphLoop(intermLoop);
77 mAllNodes.push_back(loop);
78 return loop;
79 }
80
81 TGraphLogicalOp* TDependencyGraph::createLogicalOp(TIntermBinary* intermLogicalOp)
82 {
83 TGraphLogicalOp* logicalOp = new TGraphLogicalOp(intermLogicalOp);
84 mAllNodes.push_back(logicalOp);
85 return logicalOp;
86 }
87
88 const char* TGraphLogicalOp::getOpString() const
89 {
90 const char* opString = NULL;
91 switch (getIntermLogicalOp()->getOp()) {
92 case EOpLogicalAnd: opString = "and"; break;
93 case EOpLogicalOr: opString = "or"; break;
94 default: opString = "unknown"; break;
95 }
96 return opString;
97 }
TIntermAggregate::isUserDefined
bool isUserDefined() const
Definition: intermediate.h:475
EOpLogicalOr
Definition: intermediate.h:82
TIntermSymbol::getId
int getId() const
Definition: intermediate.h:348
NULL
#define NULL
Definition: ftobjs.h:61
IsSampler
bool IsSampler(TBasicType type)
Definition: BaseTypes.h:70
TGraphArgument
Definition: DependencyGraph.h:59
TIntermTyped::getBasicType
TBasicType getBasicType() const
Definition: intermediate.h:254
TDependencyGraph::getOrCreateSymbol
TGraphSymbol * getOrCreateSymbol(TIntermSymbol *intermSymbol)
Definition: DependencyGraph.cpp:43
TDependencyGraph::createArgument
TGraphArgument * createArgument(TIntermAggregate *intermFunctionCall, int argumentNumber)
Definition: DependencyGraph.cpp:26
TIntermAggregate
Definition: intermediate.h:460
TIntermBinary
Definition: intermediate.h:404
TGraphSelection
Definition: DependencyGraph.h:98
TIntermSelection
Definition: intermediate.h:503
TGraphSymbol
Definition: DependencyGraph.h:87
TDependencyGraph::TDependencyGraph
TDependencyGraph(TIntermNode *intermNode)
Definition: DependencyGraph.cpp:12
DependencyGraph.h
TGraphLogicalOp
Definition: DependencyGraph.h:120
TGraphLoop
Definition: DependencyGraph.h:109
TGraphNode
Definition: DependencyGraph.h:34
TDependencyGraph::createLoop
TGraphLoop * createLoop(TIntermLoop *intermLoop)
Definition: DependencyGraph.cpp:74
DependencyGraphBuilder.h
TDependencyGraph::~TDependencyGraph
~TDependencyGraph()
Definition: DependencyGraph.cpp:17
TGraphFunctionCall
Definition: DependencyGraph.h:75
TIntermSymbol
Definition: intermediate.h:340
TGraphLogicalOp::getIntermLogicalOp
const TIntermBinary * getIntermLogicalOp() const
Definition: DependencyGraph.h:124
TIntermLoop
Definition: intermediate.h:284
EOpLogicalAnd
Definition: intermediate.h:84
TDependencyGraph::createFunctionCall
TGraphFunctionCall * createFunctionCall(TIntermAggregate *intermFunctionCall)
Definition: DependencyGraph.cpp:34
TGraphFunctionCall::getIntermFunctionCall
const TIntermAggregate * getIntermFunctionCall() const
Definition: DependencyGraph.h:80
TIntermNode
Definition: intermediate.h:206
TDependencyGraph::createSelection
TGraphSelection * createSelection(TIntermSelection *intermSelection)
Definition: DependencyGraph.cpp:67
TDependencyGraphBuilder::build
static void build(TIntermNode *node, TDependencyGraph *graph)
Definition: DependencyGraphBuilder.cpp:9
TGraphLogicalOp::getOpString
const char * getOpString() const
Definition: DependencyGraph.cpp:88
TDependencyGraph::createLogicalOp
TGraphLogicalOp * createLogicalOp(TIntermBinary *intermLogicalOp)
Definition: DependencyGraph.cpp:81