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 an ordering that orders blocks as explicitly specified in an
16 : // Reorderer::Order object. The order will be preserved for any sections without
17 : // an explicitly specified order. Sections whose order is only partially
18 : // specified will see the unspecified blocks pushed to the tail of the section
19 : // in their original relative order.
20 :
21 : #ifndef SYZYGY_REORDER_ORDERERS_EXPLICIT_ORDERER_H_
22 : #define SYZYGY_REORDER_ORDERERS_EXPLICIT_ORDERER_H_
23 :
24 : #include "syzygy/block_graph/orderers/named_orderer.h"
25 : #include "syzygy/reorder/reorderer.h"
26 :
27 : namespace reorder {
28 : namespace orderers {
29 :
30 : class ExplicitOrderer
31 : : public block_graph::orderers::NamedOrdererImpl<ExplicitOrderer> {
32 : public:
33 : typedef block_graph::BlockGraph BlockGraph;
34 : typedef block_graph::OrderedBlockGraph OrderedBlockGraph;
35 :
36 : // Constructor.
37 : // @param order a pointer to the order to be applied. The order object must
38 : // outlive this orderer.
39 E : explicit ExplicitOrderer(const Reorderer::Order* order) : order_(order) {
40 E : DCHECK(order != NULL);
41 E : }
42 :
43 : // Applies this orderer to the provided block graph.
44 : //
45 : // @param ordered_block_graph the block graph to order.
46 : // @returns true on success, false otherwise.
47 : virtual bool OrderBlockGraph(OrderedBlockGraph* ordered_block_graph,
48 : BlockGraph::Block* header_block_unused) override;
49 :
50 : static const char kOrdererName[];
51 :
52 : private:
53 : const Reorderer::Order* order_;
54 :
55 : DISALLOW_COPY_AND_ASSIGN(ExplicitOrderer);
56 : };
57 :
58 : } // namespace orderers
59 : } // namespace reorder
60 :
61 : #endif // SYZYGY_REORDER_ORDERERS_EXPLICIT_ORDERER_H_
|