LCOV - code coverage report
Current view: top level - gfx/angle/src/compiler/translator - CallDAG.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 1 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //
       2             : // Copyright (c) 2002-2015 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             : // CallDAG.h: Defines a call graph DAG of functions to be re-used accross
       8             : // analyses, allows to efficiently traverse the functions in topological
       9             : // order.
      10             : 
      11             : #ifndef COMPILER_TRANSLATOR_CALLDAG_H_
      12             : #define COMPILER_TRANSLATOR_CALLDAG_H_
      13             : 
      14             : #include <map>
      15             : 
      16             : #include "compiler/translator/IntermNode.h"
      17             : #include "compiler/translator/VariableInfo.h"
      18             : 
      19             : namespace sh
      20             : {
      21             : 
      22             : // The translator needs to analyze the the graph of the function calls
      23             : // to run checks and analyses; since in GLSL recursion is not allowed
      24             : // that graph is a DAG.
      25             : // This class is used to precompute that function call DAG so that it
      26             : // can be reused by multiple analyses.
      27             : //
      28             : // It stores a vector of function records, with one record per function.
      29             : // Records are accessed by index but a mangled function name can be converted
      30             : // to the index of the corresponding record. The records mostly contain the
      31             : // AST node of the function and the indices of the function's callees.
      32             : //
      33             : // In addition, records are in reverse topological order: a function F being
      34             : // called by a function G will have index index(F) < index(G), that way
      35             : // depth-first analysis becomes analysis in the order of indices.
      36             : 
      37             : class CallDAG : angle::NonCopyable
      38             : {
      39             :   public:
      40             :     CallDAG();
      41             :     ~CallDAG();
      42             : 
      43           0 :     struct Record
      44             :     {
      45             :         std::string name;
      46             :         TIntermFunctionDefinition *node;
      47             :         std::vector<int> callees;
      48             :     };
      49             : 
      50             :     enum InitResult
      51             :     {
      52             :         INITDAG_SUCCESS,
      53             :         INITDAG_RECURSION,
      54             :         INITDAG_UNDEFINED,
      55             :     };
      56             : 
      57             :     // Returns INITDAG_SUCCESS if it was able to create the DAG, otherwise prints
      58             :     // the initialization error in info, if present.
      59             :     InitResult init(TIntermNode *root, TInfoSinkBase *info);
      60             : 
      61             :     // Returns InvalidIndex if the function wasn't found
      62             :     size_t findIndex(const TFunctionSymbolInfo *functionInfo) const;
      63             : 
      64             :     const Record &getRecordFromIndex(size_t index) const;
      65             :     const Record &getRecord(const TIntermAggregate *function) const;
      66             :     size_t size() const;
      67             :     void clear();
      68             : 
      69             :     const static size_t InvalidIndex;
      70             :   private:
      71             :     std::vector<Record> mRecords;
      72             :     std::map<int, int> mFunctionIdToIndex;
      73             : 
      74             :     class CallDAGCreator;
      75             : };
      76             : 
      77             : }  // namespace sh
      78             : 
      79             : #endif  // COMPILER_TRANSLATOR_CALLDAG_H_

Generated by: LCOV version 1.13