Mercurial > hg > CbC > CbC_llvm
comparison lib/Target/R600/AMDILCFGStructurizer.cpp @ 33:e4204d083e25 LLVM3.5
LLVM 3.5
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 12 Dec 2013 14:32:10 +0900 |
parents | 95c75e76d11b |
children | 54457678186b |
comparison
equal
deleted
inserted
replaced
1:f783a2dd24b1 | 33:e4204d083e25 |
---|---|
52 STATISTIC(numLoopcontPatternMatch, "CFGStructurizer number of loop-continue " | 52 STATISTIC(numLoopcontPatternMatch, "CFGStructurizer number of loop-continue " |
53 "pattern matched"); | 53 "pattern matched"); |
54 STATISTIC(numClonedBlock, "CFGStructurizer cloned blocks"); | 54 STATISTIC(numClonedBlock, "CFGStructurizer cloned blocks"); |
55 STATISTIC(numClonedInstr, "CFGStructurizer cloned instructions"); | 55 STATISTIC(numClonedInstr, "CFGStructurizer cloned instructions"); |
56 | 56 |
57 namespace llvm { | |
58 void initializeAMDGPUCFGStructurizerPass(PassRegistry&); | |
59 } | |
60 | |
57 //===----------------------------------------------------------------------===// | 61 //===----------------------------------------------------------------------===// |
58 // | 62 // |
59 // Miscellaneous utility for CFGStructurizer. | 63 // Miscellaneous utility for CFGStructurizer. |
60 // | 64 // |
61 //===----------------------------------------------------------------------===// | 65 //===----------------------------------------------------------------------===// |
129 SinglePath_NotInPath = 2 | 133 SinglePath_NotInPath = 2 |
130 }; | 134 }; |
131 | 135 |
132 static char ID; | 136 static char ID; |
133 | 137 |
134 AMDGPUCFGStructurizer(TargetMachine &tm) : | 138 AMDGPUCFGStructurizer() : |
135 MachineFunctionPass(ID), TM(tm), | 139 MachineFunctionPass(ID), TII(NULL), TRI(NULL) { |
136 TII(static_cast<const R600InstrInfo *>(tm.getInstrInfo())), | 140 initializeAMDGPUCFGStructurizerPass(*PassRegistry::getPassRegistry()); |
137 TRI(&TII->getRegisterInfo()) { } | 141 } |
138 | 142 |
139 const char *getPassName() const { | 143 const char *getPassName() const { |
140 return "AMD IL Control Flow Graph structurizer Pass"; | 144 return "AMDGPU Control Flow Graph structurizer Pass"; |
141 } | 145 } |
142 | 146 |
143 void getAnalysisUsage(AnalysisUsage &AU) const { | 147 void getAnalysisUsage(AnalysisUsage &AU) const { |
144 AU.addPreserved<MachineFunctionAnalysis>(); | 148 AU.addPreserved<MachineFunctionAnalysis>(); |
145 AU.addRequired<MachineFunctionAnalysis>(); | 149 AU.addRequired<MachineFunctionAnalysis>(); |
155 /// This step will remove every unconditionnal/dead jump instructions and make | 159 /// This step will remove every unconditionnal/dead jump instructions and make |
156 /// sure all loops have an exit block | 160 /// sure all loops have an exit block |
157 bool prepare(); | 161 bool prepare(); |
158 | 162 |
159 bool runOnMachineFunction(MachineFunction &MF) { | 163 bool runOnMachineFunction(MachineFunction &MF) { |
164 TII = static_cast<const R600InstrInfo *>(MF.getTarget().getInstrInfo()); | |
165 TRI = &TII->getRegisterInfo(); | |
160 DEBUG(MF.dump();); | 166 DEBUG(MF.dump();); |
161 OrderedBlks.clear(); | 167 OrderedBlks.clear(); |
162 FuncRep = &MF; | 168 FuncRep = &MF; |
163 MLI = &getAnalysis<MachineLoopInfo>(); | 169 MLI = &getAnalysis<MachineLoopInfo>(); |
164 DEBUG(dbgs() << "LoopInfo:\n"; PrintLoopinfo(*MLI);); | 170 DEBUG(dbgs() << "LoopInfo:\n"; PrintLoopinfo(*MLI);); |
171 DEBUG(MF.dump();); | 177 DEBUG(MF.dump();); |
172 return true; | 178 return true; |
173 } | 179 } |
174 | 180 |
175 protected: | 181 protected: |
176 TargetMachine &TM; | |
177 MachineDominatorTree *MDT; | 182 MachineDominatorTree *MDT; |
178 MachinePostDominatorTree *PDT; | 183 MachinePostDominatorTree *PDT; |
179 MachineLoopInfo *MLI; | 184 MachineLoopInfo *MLI; |
180 const R600InstrInfo *TII; | 185 const R600InstrInfo *TII; |
181 const AMDGPURegisterInfo *TRI; | 186 const AMDGPURegisterInfo *TRI; |
1897 char AMDGPUCFGStructurizer::ID = 0; | 1902 char AMDGPUCFGStructurizer::ID = 0; |
1898 | 1903 |
1899 } // end anonymous namespace | 1904 } // end anonymous namespace |
1900 | 1905 |
1901 | 1906 |
1902 FunctionPass *llvm::createAMDGPUCFGStructurizerPass(TargetMachine &tm) { | 1907 INITIALIZE_PASS_BEGIN(AMDGPUCFGStructurizer, "amdgpustructurizer", |
1903 return new AMDGPUCFGStructurizer(tm); | 1908 "AMDGPU CFG Structurizer", false, false) |
1904 } | 1909 INITIALIZE_PASS_DEPENDENCY(MachineDominatorTree) |
1910 INITIALIZE_PASS_DEPENDENCY(MachinePostDominatorTree) | |
1911 INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo) | |
1912 INITIALIZE_PASS_END(AMDGPUCFGStructurizer, "amdgpustructurizer", | |
1913 "AMDGPU CFG Structurizer", false, false) | |
1914 | |
1915 FunctionPass *llvm::createAMDGPUCFGStructurizerPass() { | |
1916 return new AMDGPUCFGStructurizer(); | |
1917 } |