Coverage for /Syzygy/block_graph/transform.h

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
100.0%220.C++source

Line-by-line coverage:

   1    :  // Copyright 2012 Google Inc. All Rights Reserved.
   2    :  //
   3    :  // Licensed under the Apache License, Version 2.0 (the "License");
   4    :  // you may not use this file except in compliance with the License.
   5    :  // You may obtain a copy of the License at
   6    :  //
   7    :  //     http://www.apache.org/licenses/LICENSE-2.0
   8    :  //
   9    :  // Unless required by applicable law or agreed to in writing, software
  10    :  // distributed under the License is distributed on an "AS IS" BASIS,
  11    :  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12    :  // See the License for the specific language governing permissions and
  13    :  // limitations under the License.
  14    :  //
  15    :  // Declares a simple API for transforming BlockGraphs in situ.
  16    :  
  17    :  #ifndef SYZYGY_BLOCK_GRAPH_TRANSFORM_H_
  18    :  #define SYZYGY_BLOCK_GRAPH_TRANSFORM_H_
  19    :  
  20    :  #include "syzygy/block_graph/basic_block_subgraph.h"
  21    :  #include "syzygy/block_graph/block_graph.h"
  22    :  #include "syzygy/block_graph/transform_policy.h"
  23    :  
  24    :  namespace block_graph {
  25    :  
  26    :  // A BlockGraphTransform is a pure virtual base class defining the transform
  27    :  // API.
  28    :  class BlockGraphTransformInterface {
  29    :   public:
  30  E :    virtual ~BlockGraphTransformInterface() { }
  31    :  
  32    :    // Gets the name of this transform.
  33    :    //
  34    :    // @returns the name of this transform.
  35    :    virtual const char* name() const = 0;
  36    :  
  37    :    // Applies this transform to the provided block graph.
  38    :    //
  39    :    // @param policy The policy object restricting how the transform is applied.
  40    :    // @param block_graph The block graph to transform.
  41    :    // @param header_block The header block of the block graph to transform.
  42    :    // @returns true on success, false otherwise.
  43    :    virtual bool TransformBlockGraph(const TransformPolicyInterface* policy,
  44    :                                     BlockGraph* block_graph,
  45    :                                     BlockGraph::Block* header_block) = 0;
  46    :  };
  47    :  
  48    :  // This applies the provided BlockGraphTransform and checks that invariant has
  49    :  // been satisfied; namely, that the header block has not been deleted from the
  50    :  // block graph.
  51    :  //
  52    :  // @param transform The transform to apply.
  53    :  // @param policy The policy object restricting how the transform is applied.
  54    :  // @param block_graph The block graph to transform.
  55    :  // @param header_block The header block from block_graph.
  56    :  // @returns true on success, false otherwise.
  57    :  bool ApplyBlockGraphTransform(BlockGraphTransformInterface* transform,
  58    :                                const TransformPolicyInterface* policy,
  59    :                                BlockGraph* block_graph,
  60    :                                BlockGraph::Block* header_block);
  61    :  
  62    :  // This applies the provided BlockGraphTransforms in series and checks that
  63    :  // the invariant has been satisfied; namely, that the header block has not been
  64    :  // deleted from the block graph.
  65    :  //
  66    :  // @param transforms The transforms to apply.
  67    :  // @param policy The policy object restricting how the transform is applied.
  68    :  // @param block_graph The block graph to transform.
  69    :  // @param header_block The header block from block_graph.
  70    :  // @returns true on success, false otherwise.
  71    :  bool ApplyBlockGraphTransforms(
  72    :      const std::vector<BlockGraphTransformInterface*>& transforms,
  73    :      const TransformPolicyInterface* policy,
  74    :      BlockGraph* block_graph,
  75    :      BlockGraph::Block* header_block);
  76    :  
  77    :  // A BasicBlockSubGraphTransform is a pure virtual base class defining the
  78    :  // basic-block transform API.
  79    :  class BasicBlockSubGraphTransformInterface {
  80    :   public:
  81  E :    virtual ~BasicBlockSubGraphTransformInterface() { }
  82    :  
  83    :    // Gets the name of this transform.
  84    :    //
  85    :    // @returns the name of this transform.
  86    :    virtual const char* name() const = 0;
  87    :  
  88    :    // Applies this transform to the provided block.
  89    :    //
  90    :    // @param policy The policy object restricting how the transform is applied.
  91    :    // @param block_graph the block-graph of which the basic block subgraph
  92    :    //     is a part.
  93    :    // @param basic_block_subgraph the basic block subgraph to be transformed.
  94    :    // @returns true on success, false otherwise.
  95    :    virtual bool TransformBasicBlockSubGraph(
  96    :        const TransformPolicyInterface* policy,
  97    :        BlockGraph* block_graph,
  98    :        BasicBlockSubGraph* basic_block_subgraph) = 0;
  99    :  };
 100    :  
 101    :  // Applies the provided BasicBlockSubGraphTransform to a single block. Takes
 102    :  // care of basic-block decomposing the block, passes it to the transform, and
 103    :  // recomposes the block.
 104    :  //
 105    :  // @param transform the transform to apply.
 106    :  // @param policy The policy object restricting how the transform is applied.
 107    :  // @param block_graph the block containing the block to be transformed.
 108    :  // @param block the block to be transformed.
 109    :  // @param new_blocks On success, any newly created blocks will be returned
 110    :  //     here. Note that this parameter may be NULL if you are not interested
 111    :  //     in retrieving the set of new blocks.
 112    :  // @pre block must be a code block.
 113    :  // @returns true on success, false otherwise.
 114    :  bool ApplyBasicBlockSubGraphTransform(
 115    :      BasicBlockSubGraphTransformInterface* transform,
 116    :      const TransformPolicyInterface* policy,
 117    :      BlockGraph* block_graph,
 118    :      BlockGraph::Block* block,
 119    :      BlockVector* new_blocks);
 120    :  
 121    :  // Applies a series of BasicBlockSubGraphTransform to a single block. Takes
 122    :  // care of basic-block decomposing the block, passes it to the transform, and
 123    :  // recomposes the block.
 124    :  //
 125    :  // @param transforms the series of transform to apply.
 126    :  // @param policy The policy object restricting how the transform is applied.
 127    :  // @param block_graph the block containing the block to be transformed.
 128    :  // @param block the block to be transformed.
 129    :  // @param new_blocks On success, any newly created blocks will be returned
 130    :  //     here. Note that this parameter may be NULL if you are not interested
 131    :  //     in retrieving the set of new blocks.
 132    :  // @pre block must be a code block.
 133    :  // @returns true on success, false otherwise.
 134    :  bool ApplyBasicBlockSubGraphTransforms(
 135    :      const std::vector<BasicBlockSubGraphTransformInterface*>& transforms,
 136    :      const TransformPolicyInterface* policy,
 137    :      BlockGraph* block_graph,
 138    :      BlockGraph::Block* block,
 139    :      BlockVector* new_blocks);
 140    :  
 141    :  }  // namespace block_graph
 142    :  
 143    :  #endif  // SYZYGY_BLOCK_GRAPH_TRANSFORM_H_

Coverage information generated Thu Jan 14 17:40:38 2016.