1 : // Copyright 2013 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 : // This class implements the functions inlining transformation.
16 : //
17 : // The inlining expansion replaces a function call site with the body of the
18 : // callee. It is used to eliminate the time overhead when a function is called.
19 : //
20 : // TODO(etienneb): The actual implementation does not inline a sequence of
21 : // calls like Foo -> Bar -> Bat. This may be addressed by iterating this
22 : // function until no changes occurred or by changing the ordering the
23 : // blocks are traversed in the ChainedBasicBlockTransform.
24 :
25 : #ifndef SYZYGY_OPTIMIZE_TRANSFORMS_INLINING_TRANSFORM_H_
26 : #define SYZYGY_OPTIMIZE_TRANSFORMS_INLINING_TRANSFORM_H_
27 :
28 : #include "syzygy/block_graph/filterable.h"
29 : #include "syzygy/block_graph/transform_policy.h"
30 : #include "syzygy/optimize/application_profile.h"
31 : #include "syzygy/optimize/transforms/subgraph_transform.h"
32 :
33 : namespace optimize {
34 : namespace transforms {
35 :
36 : class InliningTransform : public SubGraphTransformInterface {
37 : public:
38 : typedef block_graph::BasicBlockSubGraph BasicBlockSubGraph;
39 : typedef block_graph::BlockGraph BlockGraph;
40 : typedef block_graph::TransformPolicyInterface TransformPolicyInterface;
41 : typedef std::map<BlockGraph::Block*, BasicBlockSubGraph> SubGraphCache;
42 :
43 : // Constructor.
44 E : InliningTransform() { }
45 :
46 : // @name SubGraphTransformInterface implementation.
47 : // @{
48 : virtual bool TransformBasicBlockSubGraph(
49 : const TransformPolicyInterface* policy,
50 : BlockGraph* block_graph,
51 : BasicBlockSubGraph* subgraph,
52 : ApplicationProfile* profile,
53 : SubGraphProfile* subgraph_profile) OVERRIDE;
54 : // @}
55 :
56 : protected:
57 : // A cache of decomposed subgraphs.
58 : SubGraphCache subgraph_cache_;
59 :
60 : private:
61 : DISALLOW_COPY_AND_ASSIGN(InliningTransform);
62 : };
63 :
64 : } // namespace transforms
65 : } // namespace optimize
66 :
67 : #endif // SYZYGY_OPTIMIZE_TRANSFORMS_INLINING_TRANSFORM_H_
|