LLVM: include/llvm/CodeGen/SwitchLoweringUtils.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9#ifndef LLVM_CODEGEN_SWITCHLOWERINGUTILS_H

10#define LLVM_CODEGEN_SWITCHLOWERINGUTILS_H

11

17#include

18

19namespace llvm {

20

28

30

40

41

45 union {

49 };

51

62

73

84};

85

88

89

91

103

105

106

107

108

110

116 union {

117

118

119

122 };

123

124

125

126

128

129

131

132

134

135

136

139

140

143

144

150 bool isunpredictable = false)

155

156

158 const Value *cmprhs, const Value *cmpmiddle,

163 bool isunpredictable = false)

168};

169

171

172

174

176

178

179

181

182

183 std::optional SL;

184

186 std::optional SL)

188};

203

214

216

239

240

242 unsigned Last);

243

244

247

257

259public:

261

264 TLI = &tli;

265 TM = &tm;

266 DL = &dl;

267 }

268

269

270

272

273

274

276

277

278

280

284

287 const std::optional &SL,

289

291

292

293

296

300

301

302

305

312

313

314

315

318

319private:

324};

325

326}

327}

328

329#endif

static constexpr unsigned long long mask(BlockVerifier::State S)

static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")

static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")

This file defines the SmallVector class.

Class for arbitrary precision integers.

BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...

static BranchProbability getUnknown()

Predicate

This enumeration lists the possible predicates for CmpInst subclasses.

This is the shared class of boolean and integer constants.

A parsed version of the target data layout string in and methods for querying it.

FunctionLoweringInfo - This contains information that is global to a function that is used when lower...

Analysis providing profile information.

Wrapper class representing virtual and physical registers.

Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...

This class consists of common code factored out of the SmallVector class to reduce code duplication b...

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

virtual ~SwitchLowering()=default

bool buildBitTests(CaseClusterVector &Clusters, unsigned First, unsigned Last, const SwitchInst *SI, CaseCluster &BTCluster)

Build a bit test cluster from Clusters[First..Last].

std::vector< CaseBlock > SwitchCases

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

Definition SwitchLoweringUtils.h:271

unsigned caseClusterRank(const CaseCluster &CC, CaseClusterIt First, CaseClusterIt Last)

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

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

virtual void addSuccessorWithProb(MachineBasicBlock *Src, MachineBasicBlock *Dst, BranchProbability Prob=BranchProbability::getUnknown())=0

void findBitTestClusters(CaseClusterVector &Clusters, const SwitchInst *SI)

std::vector< BitTestBlock > BitTestCases

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

Definition SwitchLoweringUtils.h:279

void init(const TargetLowering &tli, const TargetMachine &tm, const DataLayout &dl)

Definition SwitchLoweringUtils.h:262

SplitWorkItemInfo computeSplitWorkItemInfo(const SwitchWorkListItem &W)

Compute information to balance the tree based on branch probabilities to create a near-optimal (in te...

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

SwitchLowering(FunctionLoweringInfo &funcinfo)

Definition SwitchLoweringUtils.h:260

std::vector< JumpTableBlock > JTCases

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

Definition SwitchLoweringUtils.h:275

This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...

Primary interface to the complete machine description for the target machine.

LLVM Value Representation.

@ C

The default llvm calling convention, compatible with C.

CondCode

ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...

std::pair< JumpTableHeader, JumpTable > JumpTableBlock

Definition SwitchLoweringUtils.h:202

std::vector< CaseBits > CaseBitsVector

Definition SwitchLoweringUtils.h:104

uint64_t getJumpTableNumCases(const SmallVectorImpl< unsigned > &TotalCases, unsigned First, unsigned Last)

Return the number of cases within a range.

void sortAndRangeify(CaseClusterVector &Clusters)

Sort Clusters and merge adjacent cases.

std::vector< CaseCluster > CaseClusterVector

Definition SwitchLoweringUtils.h:86

uint64_t getJumpTableRange(const CaseClusterVector &Clusters, unsigned First, unsigned Last)

Return the range of values within a range.

CaseClusterKind

Definition SwitchLoweringUtils.h:31

@ CC_Range

A cluster of adjacent case labels with the same destination, or just one case.

Definition SwitchLoweringUtils.h:34

@ CC_JumpTable

A cluster of cases suitable for jump table lowering.

Definition SwitchLoweringUtils.h:36

@ CC_BitTests

A cluster of cases suitable for bit test lowering.

Definition SwitchLoweringUtils.h:38

SmallVector< SwitchWorkListItem, 4 > SwitchWorkList

Definition SwitchLoweringUtils.h:256

SmallVector< BitTestCase, 3 > BitTestInfo

Definition SwitchLoweringUtils.h:215

CaseClusterVector::iterator CaseClusterIt

Definition SwitchLoweringUtils.h:87

This is an optimization pass for GlobalISel generic memory operations.

@ First

Helpers to iterate all locations in the MemoryEffectsBase class.

OutputIt move(R &&Range, OutputIt Out)

Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.

Implement std::hash so that hash_code can be used in STL containers.

MachineBasicBlock * Default

Definition SwitchLoweringUtils.h:226

BranchProbability Prob

Definition SwitchLoweringUtils.h:228

BitTestBlock(APInt F, APInt R, const Value *SV, Register Rg, MVT RgVT, bool E, bool CR, MachineBasicBlock *P, MachineBasicBlock *D, BitTestInfo C, BranchProbability Pr)

Definition SwitchLoweringUtils.h:232

bool ContiguousRange

Definition SwitchLoweringUtils.h:224

MVT RegVT

Definition SwitchLoweringUtils.h:222

Register Reg

Definition SwitchLoweringUtils.h:221

BranchProbability DefaultProb

Definition SwitchLoweringUtils.h:229

MachineBasicBlock * Parent

Definition SwitchLoweringUtils.h:225

APInt First

Definition SwitchLoweringUtils.h:218

BitTestInfo Cases

Definition SwitchLoweringUtils.h:227

bool FallthroughUnreachable

Definition SwitchLoweringUtils.h:230

bool Emitted

Definition SwitchLoweringUtils.h:223

const Value * SValue

Definition SwitchLoweringUtils.h:220

APInt Range

Definition SwitchLoweringUtils.h:219

MachineBasicBlock * ThisBB

Definition SwitchLoweringUtils.h:206

BranchProbability ExtraProb

Definition SwitchLoweringUtils.h:208

uint64_t Mask

Definition SwitchLoweringUtils.h:205

MachineBasicBlock * TargetBB

Definition SwitchLoweringUtils.h:207

BitTestCase(uint64_t M, MachineBasicBlock *T, MachineBasicBlock *Tr, BranchProbability Prob)

Definition SwitchLoweringUtils.h:210

CaseBits(uint64_t mask, MachineBasicBlock *bb, unsigned bits, BranchProbability Prob)

Definition SwitchLoweringUtils.h:99

uint64_t Mask

Definition SwitchLoweringUtils.h:93

MachineBasicBlock * BB

Definition SwitchLoweringUtils.h:94

unsigned Bits

Definition SwitchLoweringUtils.h:95

BranchProbability ExtraProb

Definition SwitchLoweringUtils.h:96

bool NoCmp

Definition SwitchLoweringUtils.h:114

CmpInst::Predicate Pred

Definition SwitchLoweringUtils.h:112

BranchProbability TrueProb

Definition SwitchLoweringUtils.h:141

MachineBasicBlock * ThisBB

Definition SwitchLoweringUtils.h:133

struct PredInfoPair PredInfo

Definition SwitchLoweringUtils.h:121

const Value * CmpRHS

Definition SwitchLoweringUtils.h:127

BranchProbability FalseProb

Definition SwitchLoweringUtils.h:141

DebugLoc DbgLoc

Definition SwitchLoweringUtils.h:138

CaseBlock(ISD::CondCode cc, const Value *cmplhs, const Value *cmprhs, const Value *cmpmiddle, MachineBasicBlock *truebb, MachineBasicBlock *falsebb, MachineBasicBlock *me, SDLoc dl, BranchProbability trueprob=BranchProbability::getUnknown(), BranchProbability falseprob=BranchProbability::getUnknown(), bool isunpredictable=false)

Definition SwitchLoweringUtils.h:145

MachineBasicBlock * TrueBB

Definition SwitchLoweringUtils.h:130

MachineBasicBlock * FalseBB

Definition SwitchLoweringUtils.h:130

const Value * CmpLHS

Definition SwitchLoweringUtils.h:127

bool IsUnpredictable

Definition SwitchLoweringUtils.h:142

const Value * CmpMHS

Definition SwitchLoweringUtils.h:127

ISD::CondCode CC

Definition SwitchLoweringUtils.h:120

SDLoc DL

The debug location of the instruction this CaseBlock was produced from.

Definition SwitchLoweringUtils.h:137

CaseBlock(CmpInst::Predicate pred, bool nocmp, const Value *cmplhs, const Value *cmprhs, const Value *cmpmiddle, MachineBasicBlock *truebb, MachineBasicBlock *falsebb, MachineBasicBlock *me, DebugLoc dl, BranchProbability trueprob=BranchProbability::getUnknown(), BranchProbability falseprob=BranchProbability::getUnknown(), bool isunpredictable=false)

Definition SwitchLoweringUtils.h:157

A cluster of case labels.

Definition SwitchLoweringUtils.h:42

const ConstantInt * High

Definition SwitchLoweringUtils.h:44

CaseClusterKind Kind

Definition SwitchLoweringUtils.h:43

BranchProbability Prob

Definition SwitchLoweringUtils.h:50

static CaseCluster range(const ConstantInt *Low, const ConstantInt *High, MachineBasicBlock *MBB, BranchProbability Prob)

Definition SwitchLoweringUtils.h:52

unsigned BTCasesIndex

Definition SwitchLoweringUtils.h:48

static CaseCluster jumpTable(const ConstantInt *Low, const ConstantInt *High, unsigned JTCasesIndex, BranchProbability Prob)

Definition SwitchLoweringUtils.h:63

const ConstantInt * Low

Definition SwitchLoweringUtils.h:44

MachineBasicBlock * MBB

Definition SwitchLoweringUtils.h:46

unsigned JTCasesIndex

Definition SwitchLoweringUtils.h:47

static CaseCluster bitTests(const ConstantInt *Low, const ConstantInt *High, unsigned BTCasesIndex, BranchProbability Prob)

Definition SwitchLoweringUtils.h:74

Register Reg

The virtual register containing the index of the jump table entry to jump to.

Definition SwitchLoweringUtils.h:173

MachineBasicBlock * Default

The MBB of the default bb, which is a successor of the range check MBB.

Definition SwitchLoweringUtils.h:180

unsigned JTI

The JumpTableIndex for this jump table in the function.

Definition SwitchLoweringUtils.h:175

MachineBasicBlock * MBB

The MBB into which to emit the code for the indirect jump.

Definition SwitchLoweringUtils.h:177

JumpTable(Register R, unsigned J, MachineBasicBlock *M, MachineBasicBlock *D, std::optional< SDLoc > SL)

Definition SwitchLoweringUtils.h:185

std::optional< SDLoc > SL

The debug location of the instruction this JumpTable was produced from.

Definition SwitchLoweringUtils.h:183

BranchProbability RightProb

Definition SwitchLoweringUtils.h:310

BranchProbability LeftProb

Definition SwitchLoweringUtils.h:309

CaseClusterIt FirstRight

Definition SwitchLoweringUtils.h:308

CaseClusterIt LastLeft

Definition SwitchLoweringUtils.h:307

CaseClusterIt FirstCluster

Definition SwitchLoweringUtils.h:250

const ConstantInt * LT

Definition SwitchLoweringUtils.h:253

const ConstantInt * GE

Definition SwitchLoweringUtils.h:252

BranchProbability DefaultProb

Definition SwitchLoweringUtils.h:254

CaseClusterIt LastCluster

Definition SwitchLoweringUtils.h:251

MachineBasicBlock * MBB

Definition SwitchLoweringUtils.h:249