LLVM 19.0.0git
Classes | Public Member Functions | Public Attributes | List of all members
llvm::SwitchCG::SwitchLowering Class Referenceabstract

#include "llvm/CodeGen/SwitchLoweringUtils.h"

Inheritance diagram for llvm::SwitchCG::SwitchLowering:
Inheritance graph
[legend]

Classes

struct  SplitWorkItemInfo
 

Public Member Functions

 SwitchLowering (FunctionLoweringInfo &funcinfo)
 
void init (const TargetLowering &tli, const TargetMachine &tm, const DataLayout &dl)
 
void findJumpTables (CaseClusterVector &Clusters, const SwitchInst *SI, std::optional< SDLoc > SL, MachineBasicBlock *DefaultMBB, ProfileSummaryInfo *PSI, BlockFrequencyInfo *BFI)
 
bool buildJumpTable (const CaseClusterVector &Clusters, unsigned First, unsigned Last, const SwitchInst *SI, const std::optional< SDLoc > &SL, MachineBasicBlock *DefaultMBB, CaseCluster &JTCluster)
 
void findBitTestClusters (CaseClusterVector &Clusters, const SwitchInst *SI)
 
bool buildBitTests (CaseClusterVector &Clusters, unsigned First, unsigned Last, const SwitchInst *SI, CaseCluster &BTCluster)
 Build a bit test cluster from Clusters[First..Last].
 
virtual void addSuccessorWithProb (MachineBasicBlock *Src, MachineBasicBlock *Dst, BranchProbability Prob=BranchProbability::getUnknown())=0
 
unsigned caseClusterRank (const CaseCluster &CC, CaseClusterIt First, CaseClusterIt Last)
 Determine the rank by weight of CC in [First,Last].
 
SplitWorkItemInfo computeSplitWorkItemInfo (const SwitchWorkListItem &W)
 Compute information to balance the tree based on branch probabilities to create a near-optimal (in terms of search time given key frequency) binary search tree.
 
virtual ~SwitchLowering ()=default
 

Public Attributes

std::vector< CaseBlockSwitchCases
 Vector of CaseBlock structures used to communicate SwitchInst code generation information.
 
std::vector< JumpTableBlockJTCases
 Vector of JumpTable structures used to communicate SwitchInst code generation information.
 
std::vector< BitTestBlockBitTestCases
 Vector of BitTestBlock structures used to communicate SwitchInst code generation information.
 

Detailed Description

Definition at line 253 of file SwitchLoweringUtils.h.

Constructor & Destructor Documentation

◆ SwitchLowering()

llvm::SwitchCG::SwitchLowering::SwitchLowering ( FunctionLoweringInfo funcinfo)
inline

Definition at line 255 of file SwitchLoweringUtils.h.

◆ ~SwitchLowering()

virtual llvm::SwitchCG::SwitchLowering::~SwitchLowering ( )
virtualdefault

References DL.

Member Function Documentation

◆ addSuccessorWithProb()

virtual void llvm::SwitchCG::SwitchLowering::addSuccessorWithProb ( MachineBasicBlock Src,
MachineBasicBlock Dst,
BranchProbability  Prob = BranchProbability::getUnknown() 
)
pure virtual

◆ buildBitTests()

bool SwitchCG::SwitchLowering::buildBitTests ( CaseClusterVector Clusters,
unsigned  First,
unsigned  Last,
const SwitchInst SI,
CaseCluster BTCluster 
)

◆ buildJumpTable()

bool SwitchCG::SwitchLowering::buildJumpTable ( const CaseClusterVector Clusters,
unsigned  First,
unsigned  Last,
const SwitchInst SI,
const std::optional< SDLoc > &  SL,
MachineBasicBlock DefaultMBB,
CaseCluster JTCluster 
)

◆ caseClusterRank()

unsigned SwitchCG::SwitchLowering::caseClusterRank ( const CaseCluster CC,
CaseClusterIt  First,
CaseClusterIt  Last 
)

Determine the rank by weight of CC in [First,Last].

If CC has more weight than each cluster in the range, its rank is 0.

Definition at line 499 of file SwitchLoweringUtils.cpp.

References CC, llvm::First, llvm::Last, and X.

◆ computeSplitWorkItemInfo()

llvm::SwitchCG::SwitchLowering::SplitWorkItemInfo SwitchCG::SwitchLowering::computeSplitWorkItemInfo ( const SwitchWorkListItem W)

Compute information to balance the tree based on branch probabilities to create a near-optimal (in terms of search time given key frequency) binary search tree.

See e.g. Kurt Mehlhorn "Nearly Optimal Binary Search Trees" (1975).

Definition at line 512 of file SwitchLoweringUtils.cpp.

References assert(), CC, and I.

◆ findBitTestClusters()

void SwitchCG::SwitchLowering::findBitTestClusters ( CaseClusterVector Clusters,
const SwitchInst SI 
)

◆ findJumpTables()

void SwitchCG::SwitchLowering::findJumpTables ( CaseClusterVector Clusters,
const SwitchInst SI,
std::optional< SDLoc SL,
MachineBasicBlock DefaultMBB,
ProfileSummaryInfo PSI,
BlockFrequencyInfo BFI 
)

◆ init()

void llvm::SwitchCG::SwitchLowering::init ( const TargetLowering tli,
const TargetMachine tm,
const DataLayout dl 
)
inline

Definition at line 257 of file SwitchLoweringUtils.h.

References DL.

Member Data Documentation

◆ BitTestCases

std::vector<BitTestBlock> llvm::SwitchCG::SwitchLowering::BitTestCases

Vector of BitTestBlock structures used to communicate SwitchInst code generation information.

Definition at line 274 of file SwitchLoweringUtils.h.

◆ JTCases

std::vector<JumpTableBlock> llvm::SwitchCG::SwitchLowering::JTCases

Vector of JumpTable structures used to communicate SwitchInst code generation information.

Definition at line 270 of file SwitchLoweringUtils.h.

◆ SwitchCases

std::vector<CaseBlock> llvm::SwitchCG::SwitchLowering::SwitchCases

Vector of CaseBlock structures used to communicate SwitchInst code generation information.

Definition at line 266 of file SwitchLoweringUtils.h.


The documentation for this class was generated from the following files: