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 : // Declaration of the BlockBuilder class.
16 :
17 : #ifndef SYZYGY_BLOCK_GRAPH_BLOCK_BUILDER_H_
18 : #define SYZYGY_BLOCK_GRAPH_BLOCK_BUILDER_H_
19 :
20 : #include "syzygy/block_graph/basic_block_subgraph.h"
21 : #include "syzygy/block_graph/block_graph.h"
22 :
23 : namespace block_graph {
24 :
25 : // This class incorporates a BasicBlockSubGraph into a BlockGraph.
26 : class BlockBuilder {
27 : public:
28 : explicit BlockBuilder(BlockGraph* block_graph);
29 :
30 : // Merge the @p subgraph into the block graph. This will create all blocks
31 : // and block relationships described by the subgraph and remove the
32 : // original block (if any) from which the subgraph was derived.
33 : bool Merge(BasicBlockSubGraph* subgraph);
34 :
35 : // Returns the set of new blocks created upon merging in one or more
36 : // subgraphs.
37 E : const BlockVector& new_blocks() const { return new_blocks_; }
38 :
39 : private:
40 : // The block-graph that subgraphs will be merged into.
41 : BlockGraph* const block_graph_;
42 :
43 : // The set of blocks created so far.
44 : BlockVector new_blocks_;
45 :
46 : DISALLOW_COPY_AND_ASSIGN(BlockBuilder);
47 : };
48 :
49 : } // namespace block_graph
50 :
51 : #endif // SYZYGY_BLOCK_GRAPH_BLOCK_BUILDER_H_
|