gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
kernel_cfg.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2015 Advanced Micro Devices, Inc.
3  * All rights reserved.
4  *
5  * For use for simulation and test purposes only
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice,
11  * this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright notice,
14  * this list of conditions and the following disclaimer in the documentation
15  * and/or other materials provided with the distribution.
16  *
17  * 3. Neither the name of the copyright holder nor the names of its contributors
18  * may be used to endorse or promote products derived from this software
19  * without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  *
33  * Author: Steve Reinhardt
34  */
35 
36 #ifndef __KERNEL_CFG_HH__
37 #define __KERNEL_CFG_HH__
38 
39 #include <cstddef>
40 #include <cstdint>
41 #include <memory>
42 #include <set>
43 #include <vector>
44 
45 
46 class GPUStaticInst;
47 class HsailCode;
48 
49 struct BasicBlock
50 {
51  BasicBlock(uint32_t num, GPUStaticInst* begin) :
52  id(num), size(0), firstInstruction(begin)
53  {
54  }
55 
56  bool
57  isEntry() const
58  {
59  return !id;
60  }
61 
62  bool
63  isExit() const
64  {
65  return !size;
66  }
67 
71  const uint32_t id;
72 
76  size_t size;
77 
82 
86  std::set<uint32_t> successorIds;
87 
91  std::set<uint32_t> postDominatorIds;
92 };
93 
95 {
96 public:
97 
101  static void assignImmediatePostDominators(
103 
104 private:
105  ControlFlowInfo(const std::vector<GPUStaticInst*>& instructions);
106 
107  GPUStaticInst* lastInstruction(const BasicBlock* block) const;
108 
109  BasicBlock* basicBlock(int inst_addr) const;
110 
111  BasicBlock* postDominator(const BasicBlock* block) const;
112 
113  void createBasicBlocks();
114 
115  void connectBasicBlocks();
116 
117  void findPostDominators();
118 
120 
121  void printBasicBlocks() const;
122 
123  void printBasicBlockDot() const;
124 
125  void printPostDominators() const;
126 
127  void printImmediatePostDominators() const;
128 
131 };
132 
133 #endif // __KERNEL_CFG_HH__
std::set< uint32_t > successorIds
Identifiers of the blocks that follow (are reachable from) this block.
Definition: kernel_cfg.hh:86
void printPostDominators() const
Definition: kernel_cfg.cc:246
BasicBlock * basicBlock(int inst_addr) const
Definition: kernel_cfg.cc:66
std::vector< std::unique_ptr< BasicBlock > > basicBlocks
Definition: kernel_cfg.hh:129
bool isEntry() const
Definition: kernel_cfg.hh:57
std::vector< GPUStaticInst * > instructions
Definition: kernel_cfg.hh:130
static void assignImmediatePostDominators(const std::vector< GPUStaticInst * > &instructions)
Compute immediate post-dominator instruction for kernel instructions.
Definition: kernel_cfg.cc:50
void findPostDominators()
Definition: kernel_cfg.cc:170
GPUStaticInst * firstInstruction
Pointer to first instruction of the block.
Definition: kernel_cfg.hh:81
bool isExit() const
Definition: kernel_cfg.hh:63
void findImmediatePostDominators()
Definition: kernel_cfg.cc:214
void connectBasicBlocks()
Definition: kernel_cfg.cc:131
BasicBlock(uint32_t num, GPUStaticInst *begin)
Definition: kernel_cfg.hh:51
const uint32_t id
Unique identifier for the block within a given kernel.
Definition: kernel_cfg.hh:71
size_t size
Number of instructions contained in the block.
Definition: kernel_cfg.hh:76
void printBasicBlocks() const
Definition: kernel_cfg.cc:270
void createBasicBlocks()
Definition: kernel_cfg.cc:99
std::set< uint32_t > postDominatorIds
Identifiers of the blocks that will be visited from this block.
Definition: kernel_cfg.hh:91
void printImmediatePostDominators() const
Definition: kernel_cfg.cc:258
GPUStaticInst * lastInstruction(const BasicBlock *block) const
Definition: kernel_cfg.cc:79
void printBasicBlockDot() const
Definition: kernel_cfg.cc:284
BasicBlock * postDominator(const BasicBlock *block) const
Definition: kernel_cfg.cc:90
ControlFlowInfo(const std::vector< GPUStaticInst * > &instructions)
Definition: kernel_cfg.cc:58

Generated on Fri Jun 9 2017 13:03:48 for gem5 by doxygen 1.8.6