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::BlockGraph::BlockId BlockId;
41 : typedef block_graph::TransformPolicyInterface TransformPolicyInterface;
42 : typedef std::map<BlockId, size_t> SubGraphCache;
43 :
44 : // Constructor.
45 E : InliningTransform() { }
46 :
47 : // @name SubGraphTransformInterface implementation.
48 : // @{
49 : virtual bool TransformBasicBlockSubGraph(
50 : const TransformPolicyInterface* policy,
51 : BlockGraph* block_graph,
52 : BasicBlockSubGraph* subgraph,
53 : ApplicationProfile* profile,
54 : SubGraphProfile* subgraph_profile) override;
55 : // @}
56 :
57 : protected:
58 : // A cache of decomposed subgraph sizes.
59 : SubGraphCache subgraph_cache_;
60 :
61 : private:
62 : DISALLOW_COPY_AND_ASSIGN(InliningTransform);
63 : };
64 :
65 : } // namespace transforms
66 : } // namespace optimize
67 :
68 : #endif // SYZYGY_OPTIMIZE_TRANSFORMS_INLINING_TRANSFORM_H_
|