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 ordering block graphs.
16 :
17 : #ifndef SYZYGY_BLOCK_GRAPH_ORDERER_H_
18 : #define SYZYGY_BLOCK_GRAPH_ORDERER_H_
19 :
20 : #include "syzygy/block_graph/ordered_block_graph.h"
21 :
22 : namespace block_graph {
23 :
24 : // BlockGraphOrdererInterface is a pure virtual base class defining the orderer
25 : // API.
26 : class BlockGraphOrdererInterface {
27 : public:
28 E : virtual ~BlockGraphOrdererInterface() { }
29 :
30 : // Gets the name of this orderer.
31 : //
32 : // @returns the name of this orderer.
33 : virtual const char* name() const = 0;
34 :
35 : // Applies this orderer to the provided block graph.
36 : //
37 : // @param ordered_block_graph the block graph to order.
38 : // @param header_block The header block of the block graph to transform.
39 : // @returns true on success, false otherwise.
40 : virtual bool OrderBlockGraph(OrderedBlockGraph* ordered_block_graph,
41 : BlockGraph::Block* header_block) = 0;
42 : };
43 :
44 : // Applies a vector of BlockGraphOrderers.
45 : // @param orderers The vector of orderers.
46 : // @param ordered_block_graph The block graph to order.
47 : // @param header_block The header block of the block graph to transform.
48 : // @returns true on success, false otherwise.
49 : bool ApplyBlockGraphOrderers(
50 : const std::vector<BlockGraphOrdererInterface*>& orderers,
51 : OrderedBlockGraph* ordered_block_graph,
52 : BlockGraph::Block* header_block);
53 :
54 : } // namespace block_graph
55 :
56 : #endif // SYZYGY_BLOCK_GRAPH_ORDERER_H_
|