diff options
Diffstat (limited to 'llvm/lib/Target/AMDGPU/AMDILCFGStructurizer.cpp')
-rw-r--r-- | llvm/lib/Target/AMDGPU/AMDILCFGStructurizer.cpp | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/llvm/lib/Target/AMDGPU/AMDILCFGStructurizer.cpp b/llvm/lib/Target/AMDGPU/AMDILCFGStructurizer.cpp index a5fa9f7cd87..223fdf77941 100644 --- a/llvm/lib/Target/AMDGPU/AMDILCFGStructurizer.cpp +++ b/llvm/lib/Target/AMDGPU/AMDILCFGStructurizer.cpp @@ -1,11 +1,10 @@ -//===-- AMDILCFGStructurizer.cpp - CFG Structurizer -----------------------===// +//===- AMDILCFGStructurizer.cpp - CFG Structurizer ------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // -/// \file //==-----------------------------------------------------------------------===// #include "AMDGPU.h" @@ -67,7 +66,7 @@ STATISTIC(numClonedInstr, "CFGStructurizer cloned instructions"); namespace llvm { - void initializeAMDGPUCFGStructurizerPass(PassRegistry&); +void initializeAMDGPUCFGStructurizerPass(PassRegistry &); } // end namespace llvm @@ -121,9 +120,9 @@ public: class AMDGPUCFGStructurizer : public MachineFunctionPass { public: - typedef SmallVector<MachineBasicBlock *, 32> MBBVector; - typedef std::map<MachineBasicBlock *, BlockInformation *> MBBInfoMap; - typedef std::map<MachineLoop *, MachineBasicBlock *> LoopLandInfoMap; + using MBBVector = SmallVector<MachineBasicBlock *, 32>; + using MBBInfoMap = std::map<MachineBasicBlock *, BlockInformation *>; + using LoopLandInfoMap = std::map<MachineLoop *, MachineBasicBlock *>; enum PathToKind { Not_SinglePath = 0, @@ -234,6 +233,7 @@ protected: void insertCondBranchBefore(MachineBasicBlock *MBB, MachineBasicBlock::iterator I, int NewOpcode, int RegNum, const DebugLoc &DL); + static int getBranchNzeroOpcode(int OldOpcode); static int getBranchZeroOpcode(int OldOpcode); static int getContinueNzeroOpcode(int OldOpcode); @@ -246,21 +246,25 @@ protected: static bool isUncondBranch(MachineInstr *MI); static DebugLoc getLastDebugLocInBB(MachineBasicBlock *MBB); static MachineInstr *getNormalBlockBranchInstr(MachineBasicBlock *MBB); + /// The correct naming for this is getPossibleLoopendBlockBranchInstr. /// /// BB with backward-edge could have move instructions after the branch /// instruction. Such move instruction "belong to" the loop backward-edge. MachineInstr *getLoopendBlockBranchInstr(MachineBasicBlock *MBB); + static MachineInstr *getReturnInstr(MachineBasicBlock *MBB); static bool isReturnBlock(MachineBasicBlock *MBB); static void cloneSuccessorList(MachineBasicBlock *DstMBB, - MachineBasicBlock *SrcMBB) ; + MachineBasicBlock *SrcMBB); static MachineBasicBlock *clone(MachineBasicBlock *MBB); + /// MachineBasicBlock::ReplaceUsesOfBlockWith doesn't serve the purpose /// because the AMDGPU instruction is not recognized as terminator fix this /// and retire this routine void replaceInstrUseOfBlockWith(MachineBasicBlock *SrcMBB, MachineBasicBlock *OldMBB, MachineBasicBlock *NewBlk); + static void wrapup(MachineBasicBlock *MBB); int patternMatch(MachineBasicBlock *MBB); @@ -299,6 +303,7 @@ protected: MachineBasicBlock *LandMBB); void settleLoopcontBlock(MachineBasicBlock *ContingMBB, MachineBasicBlock *ContMBB); + /// normalizeInfiniteLoopExit change /// B1: /// uncond_br LoopHeader @@ -309,6 +314,7 @@ protected: /// and return the newly added dummy exit block MachineBasicBlock *normalizeInfiniteLoopExit(MachineLoop *LoopRep); void removeUnconditionalBranch(MachineBasicBlock *MBB); + /// Remove duplicate branches instructions in a block. /// For instance /// B0: @@ -318,6 +324,7 @@ protected: /// B0: /// cond_br X B1 B2 void removeRedundantConditionalBranch(MachineBasicBlock *MBB); + void addDummyExitBlock(SmallVectorImpl<MachineBasicBlock *> &RetMBB); void removeSuccessor(MachineBasicBlock *MBB); MachineBasicBlock *cloneBlockForPredecessor(MachineBasicBlock *MBB, @@ -335,10 +342,10 @@ private: SmallVector<MachineBasicBlock *, DEFAULT_VEC_SLOTS> OrderedBlks; }; -char AMDGPUCFGStructurizer::ID = 0; - } // end anonymous namespace +char AMDGPUCFGStructurizer::ID = 0; + int AMDGPUCFGStructurizer::getSCCNum(MachineBasicBlock *MBB) const { MBBInfoMap::const_iterator It = BlockInfoMap.find(MBB); if (It == BlockInfoMap.end()) @@ -535,7 +542,7 @@ int AMDGPUCFGStructurizer::getContinueNzeroOpcode(int OldOpcode) { case AMDGPU::JUMP_COND: case AMDGPU::JUMP: return AMDGPU::CONTINUE_LOGICALNZ_i32; default: llvm_unreachable("internal error"); - }; + } return -1; } @@ -1597,7 +1604,7 @@ void AMDGPUCFGStructurizer::migrateInstruction(MachineBasicBlock *SrcMBB, MachineInstr *BranchMI = getNormalBlockBranchInstr(SrcMBB); if (!BranchMI) { DEBUG( - dbgs() << "migrateInstruction don't see branch instr\n" ; + dbgs() << "migrateInstruction don't see branch instr\n"; ); SpliceEnd = SrcMBB->end(); } else { |