LLVM  6.0.0svn
Macros | Functions | Variables
AMDGPUMachineCFGStructurizer.cpp File Reference
#include "AMDGPU.h"
#include "AMDGPUSubtarget.h"
#include "SIInstrInfo.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/PostOrderIterator.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineRegionInfo.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/Pass.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetOpcodes.h"
#include "llvm/Target/TargetRegisterInfo.h"
#include <cassert>
#include <tuple>
#include <utility>
Include dependency graph for AMDGPUMachineCFGStructurizer.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "amdgpucfgstructurizer"
 

Functions

static unsigned getPHINumInputs (MachineInstr &PHI)
 
static MachineBasicBlockgetPHIPred (MachineInstr &PHI, unsigned Index)
 
static void setPhiPred (MachineInstr &PHI, unsigned Index, MachineBasicBlock *NewPred)
 
static unsigned getPHISourceReg (MachineInstr &PHI, unsigned Index)
 
static unsigned getPHIDestReg (MachineInstr &PHI)
 
static unsigned createBBSelectReg (const SIInstrInfo *TII, MachineRegisterInfo *MRI)
 
static void fixMBBTerminator (MachineBasicBlock *MBB)
 
static void fixRegionTerminator (RegionMRT *Region)
 
bool regionIsSequence (RegionMRT *Region)
 
void fixupRegionExits (RegionMRT *Region)
 
static bool isPHIRegionIndex (SmallVector< unsigned, 2 > PHIRegionIndices, unsigned Index)
 
static void collectPHIs (MachineBasicBlock *MBB, SmallVector< MachineInstr *, 2 > &PHIs)
 
static MachineBasicBlockgetSingleExitNode (MachineFunction &MF)
 
static bool hasOneExitNode (MachineFunction &MF)
 
static void removeExternalCFGSuccessors (MachineBasicBlock *MBB)
 
static void removeExternalCFGEdges (MachineBasicBlock *StartMBB, MachineBasicBlock *EndMBB)
 
static bool isFunctionEntryBlock (MachineBasicBlock *MBB)
 
static MachineBasicBlocksplit (MachineBasicBlock::iterator I)
 
static void removeOldExitPreds (RegionMRT *Region)
 
static bool mbbHasBackEdge (MachineBasicBlock *MBB, SmallPtrSet< MachineBasicBlock *, 8 > &MBBs)
 
static bool containsNewBackedge (MRT *Tree, SmallPtrSet< MachineBasicBlock *, 8 > &MBBs)
 
static bool containsNewBackedge (RegionMRT *Region)
 
static void checkRegOnlyPHIInputs (MachineFunction &MF)
 
 INITIALIZE_PASS_BEGIN (AMDGPUMachineCFGStructurizer, "amdgpu-machine-cfg-structurizer", "AMDGPU Machine CFG Structurizer", false, false) INITIALIZE_PASS_END(AMDGPUMachineCFGStructurizer
 

Variables

static int structurize_once = 0
 
char AMDGPUMachineCFGStructurizerID = AMDGPUMachineCFGStructurizer::ID
 
amdgpu machine cfg structurizer
 
amdgpu machine cfg AMDGPU Machine CFG Structurizer
 
amdgpu machine cfg AMDGPU Machine CFG false
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "amdgpucfgstructurizer"

Definition at line 46 of file AMDGPUMachineCFGStructurizer.cpp.

Function Documentation

◆ checkRegOnlyPHIInputs()

static void checkRegOnlyPHIInputs ( MachineFunction MF)
static

◆ collectPHIs()

static void collectPHIs ( MachineBasicBlock MBB,
SmallVector< MachineInstr *, 2 > &  PHIs 
)
static

◆ containsNewBackedge() [1/2]

static bool containsNewBackedge ( MRT *  Tree,
SmallPtrSet< MachineBasicBlock *, 8 > &  MBBs 
)
static

◆ containsNewBackedge() [2/2]

static bool containsNewBackedge ( RegionMRT *  Region)
static

◆ createBBSelectReg()

static unsigned createBBSelectReg ( const SIInstrInfo TII,
MachineRegisterInfo MRI 
)
static

Definition at line 617 of file AMDGPUMachineCFGStructurizer.cpp.

References llvm::AnalysisUsage::addRequired(), assert(), contains(), llvm::SIInstrInfo::convertNonUniformIfRegion(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::count(), llvm::MachineRegisterInfo::createVirtualRegister(), llvm::dbgs(), DEBUG, llvm::tgtok::Def, llvm::MachineRegisterInfo::def_begin(), llvm::MachineRegisterInfo::def_end(), llvm::dump(), E, llvm::MachineFunction::front(), llvm::MachineFunctionPass::getAnalysisUsage(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::MachineBasicBlock::getNumber(), llvm::MachineInstr::getParent(), llvm::MachineOperand::getParent(), llvm::RegionBase< Tr >::getParent(), getParent(), llvm::PassRegistry::getPassRegistry(), getPHINumInputs(), getPHIPred(), getPHISourceReg(), llvm::SIInstrInfo::getPreferredSelectRegClass(), llvm::RegionInfoBase< Tr >::getRegionFor(), llvm::MachineRegisterInfo::getTargetRegisterInfo(), llvm::RegionInfoBase< Tr >::getTopLevelRegion(), llvm::MachineRegisterInfo::hasOneDef(), I, llvm::initializeAMDGPUMachineCFGStructurizerPass(), llvm::MachineBasicBlock::insert(), llvm::MachineBasicBlock::instr_end(), llvm::MachineOperand::isDef(), llvm::MachineOperand::isKill(), isLiveOut(), llvm::MachineInstr::isPHI(), llvm::TargetRegisterInfo::isPhysicalRegister(), llvm::TargetRegisterInfo::isVirtualRegister(), llvm_unreachable, MRI, llvm::RISCVFenceField::O, llvm::post_order(), llvm::PrintReg(), llvm::MachineRegisterInfo::reg_begin(), llvm::MachineRegisterInfo::reg_end(), Register, llvm::MachineOperand::setIsKill(), llvm::MachineOperand::setReg(), SI, llvm::MachineBasicBlock::succ_begin(), llvm::MachineBasicBlock::succ_end(), llvm::MachineBasicBlock::succ_size(), TII, and llvm::MachineRegisterInfo::use_operands().

◆ fixMBBTerminator()

static void fixMBBTerminator ( MachineBasicBlock MBB)
static

◆ fixRegionTerminator()

static void fixRegionTerminator ( RegionMRT *  Region)
static

Definition at line 1286 of file AMDGPUMachineCFGStructurizer.cpp.

References assert(), and SI.

Referenced by fixupRegionExits().

◆ fixupRegionExits()

void fixupRegionExits ( RegionMRT *  Region)

◆ getPHIDestReg()

static unsigned getPHIDestReg ( MachineInstr PHI)
static

◆ getPHINumInputs()

static unsigned getPHINumInputs ( MachineInstr PHI)
static

◆ getPHIPred()

static MachineBasicBlock* getPHIPred ( MachineInstr PHI,
unsigned  Index 
)
static

◆ getPHISourceReg()

static unsigned getPHISourceReg ( MachineInstr PHI,
unsigned  Index 
)
static

◆ getSingleExitNode()

static MachineBasicBlock* getSingleExitNode ( MachineFunction MF)
static

Definition at line 1698 of file AMDGPUMachineCFGStructurizer.cpp.

Referenced by containsNewBackedge(), and hasOneExitNode().

◆ hasOneExitNode()

static bool hasOneExitNode ( MachineFunction MF)
static

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( AMDGPUMachineCFGStructurizer  ,
"amdgpu-machine-cfg-structurizer ,
"AMDGPU Machine CFG Structurizer ,
false  ,
false   
)

◆ isFunctionEntryBlock()

static bool isFunctionEntryBlock ( MachineBasicBlock MBB)
static

◆ isPHIRegionIndex()

static bool isPHIRegionIndex ( SmallVector< unsigned, 2 >  PHIRegionIndices,
unsigned  Index 
)
static

◆ mbbHasBackEdge()

static bool mbbHasBackEdge ( MachineBasicBlock MBB,
SmallPtrSet< MachineBasicBlock *, 8 > &  MBBs 
)
static

◆ regionIsSequence()

bool regionIsSequence ( RegionMRT *  Region)

Definition at line 1323 of file AMDGPUMachineCFGStructurizer.cpp.

Referenced by containsNewBackedge().

◆ removeExternalCFGEdges()

static void removeExternalCFGEdges ( MachineBasicBlock StartMBB,
MachineBasicBlock EndMBB 
)
static

Definition at line 1780 of file AMDGPUMachineCFGStructurizer.cpp.

References llvm::MachineInstrBuilder::addMBB(), llvm::MachineInstrBuilder::addReg(), llvm::MachineBasicBlock::addSuccessor(), llvm::SIInstrInfo::analyzeBranch(), assert(), llvm::MachineBasicBlock::begin(), llvm::MachineFunction::begin(), llvm::BuildMI(), llvm::MachineFunction::CreateMachineBasicBlock(), llvm::MachineOperand::CreateReg(), llvm::MachineRegisterInfo::createVirtualRegister(), llvm::dbgs(), DEBUG, llvm::tgtok::Def, llvm::MachineRegisterInfo::def_begin(), llvm::MachineRegisterInfo::def_end(), E, llvm::MachineInstr::eraseFromParent(), llvm::MachineBasicBlock::findDebugLoc(), llvm::MachineBasicBlock::getFirstTerminator(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::MachineBasicBlock::getNumber(), llvm::MachineInstr::getParent(), llvm::MachineBasicBlock::getParent(), llvm::MachineOperand::getParent(), getParent(), getPHIPred(), getPHISourceReg(), llvm::MachineRegisterInfo::getRegClass(), llvm::MachineRegisterInfo::getTargetRegisterInfo(), llvm::MachineRegisterInfo::hasOneDef(), I, llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, ValueInfoT, detail::DenseSetPair< ValueT > >, ValueInfoT >::insert(), llvm::MachineFunction::insert(), llvm::SIInstrInfo::insertBranch(), llvm::SIInstrInfo::insertEQ(), llvm::SIInstrInfo::insertVectorSelect(), llvm::MachineBasicBlock::instr_begin(), llvm::MachineInstr::isPHI(), llvm::TargetRegisterInfo::isPhysicalRegister(), isReg(), llvm::MachineBasicBlock::isSuccessor(), llvm_unreachable, llvm::SIInstrInfo::materializeImmediate(), llvm::RISCVFenceField::O, llvm::MachineBasicBlock::pred_begin(), llvm::MachineBasicBlock::pred_end(), llvm::MachineBasicBlock::pred_size(), llvm::PrintReg(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::MachineRegisterInfo::reg_begin(), llvm::MachineRegisterInfo::reg_end(), llvm::MachineOperand::setReg(), SI, llvm::SmallVectorTemplateCommon< T >::size(), llvm::Sched::Source, llvm::MachineFunction::splice(), llvm::MachineBasicBlock::succ_begin(), llvm::MachineBasicBlock::succ_end(), llvm::MachineBasicBlock::succ_size(), llvm::MachineRegisterInfo::use_begin(), and llvm::MachineRegisterInfo::use_end().

◆ removeExternalCFGSuccessors()

static void removeExternalCFGSuccessors ( MachineBasicBlock MBB)
static

◆ removeOldExitPreds()

static void removeOldExitPreds ( RegionMRT *  Region)
static

◆ setPhiPred()

static void setPhiPred ( MachineInstr PHI,
unsigned  Index,
MachineBasicBlock NewPred 
)
static

◆ split()

static MachineBasicBlock* split ( MachineBasicBlock::iterator  I)
static

Variable Documentation

◆ AMDGPUMachineCFGStructurizerID

char AMDGPUMachineCFGStructurizerID = AMDGPUMachineCFGStructurizer::ID

Definition at line 2883 of file AMDGPUMachineCFGStructurizer.cpp.

◆ false

amdgpu machine cfg AMDGPU Machine CFG false

Definition at line 2888 of file AMDGPUMachineCFGStructurizer.cpp.

◆ structurize_once

int structurize_once = 0
static

Definition at line 2766 of file AMDGPUMachineCFGStructurizer.cpp.

◆ structurizer

amdgpu machine cfg structurizer

Definition at line 2888 of file AMDGPUMachineCFGStructurizer.cpp.

◆ Structurizer

amdgpu machine cfg AMDGPU Machine CFG Structurizer

Definition at line 2888 of file AMDGPUMachineCFGStructurizer.cpp.