class SwitchInst

Declaration

class SwitchInst : public Instruction { /* full declaration omitted */ };

Description

Multiway switch

Declared at: llvm/include/llvm/IR/Instructions.h:3243

Inherits from: Instruction

Member Variables

private unsigned int ReservedSpace
public static const unsigned int DefaultPseudoIndex = static_cast<unsigned int>(~0L - 1)

Inherited from Value:

protected SubclassOptionalData
protected NumUserOperands
protected IsUsedByMD
protected HasName
protected HasMetadata
protected HasHungOffUses
protected HasDescriptor
public static MaxAlignmentExponent = 32
public static MaximumAlignment = 1ULL << MaxAlignmentExponent

Method Overview

  • public static llvm::SwitchInst * Create(llvm::Value * Value, llvm::BasicBlock * Default, unsigned int NumCases, llvm::Instruction * InsertBefore = nullptr)
  • public static llvm::SwitchInst * Create(llvm::Value * Value, llvm::BasicBlock * Default, unsigned int NumCases, llvm::BasicBlock * InsertAtEnd)
  • private SwitchInst(llvm::Value * Value, llvm::BasicBlock * Default, unsigned int NumCases, llvm::Instruction * InsertBefore)
  • private SwitchInst(llvm::Value * Value, llvm::BasicBlock * Default, unsigned int NumCases, llvm::BasicBlock * InsertAtEnd)
  • private SwitchInst(const llvm::SwitchInst & SI)
  • public void addCase(llvm::ConstantInt * OnVal, llvm::BasicBlock * Dest)
  • public llvm::SwitchInst::ConstCaseIt case_begin() const
  • public llvm::SwitchInst::CaseIt case_begin()
  • public llvm::SwitchInst::ConstCaseIt case_default() const
  • public llvm::SwitchInst::CaseIt case_default()
  • public llvm::SwitchInst::CaseIt case_end()
  • public llvm::SwitchInst::ConstCaseIt case_end() const
  • public iterator_range<llvm::SwitchInst::CaseIt> cases()
  • public iterator_range<llvm::SwitchInst::ConstCaseIt> cases() const
  • public static bool classof(const llvm::Value * V)
  • public static bool classof(const llvm::Instruction * I)
  • protected llvm::SwitchInst * cloneImpl() const
  • public llvm::ConstantInt * findCaseDest(llvm::BasicBlock * BB)
  • public llvm::SwitchInst::CaseIt findCaseValue(const llvm::ConstantInt * C)
  • public llvm::SwitchInst::ConstCaseIt findCaseValue(const llvm::ConstantInt * C) const
  • public llvm::Value * getCondition() const
  • public llvm::BasicBlock * getDefaultDest() const
  • public unsigned int getNumCases() const
  • public unsigned int getNumSuccessors() const
  • public llvm::BasicBlock * getSuccessor(unsigned int idx) const
  • private void growOperands()
  • private void init(llvm::Value * Value, llvm::BasicBlock * Default, unsigned int NumReserved)
  • public llvm::SwitchInst::CaseIt removeCase(llvm::SwitchInst::CaseIt I)
  • public void setCondition(llvm::Value * V)
  • public void setDefaultDest(llvm::BasicBlock * DefaultCase)
  • public void setSuccessor(unsigned int idx, llvm::BasicBlock * NewSucc)

Inherited from Instruction:

Inherited from User:

Inherited from Value:

Methods

static llvm::SwitchInst* Create(
    llvm::Value* Value,
    llvm::BasicBlock* Default,
    unsigned int NumCases,
    llvm::Instruction* InsertBefore = nullptr)

Declared at: llvm/include/llvm/IR/Instructions.h:3432

Parameters

llvm::Value* Value
llvm::BasicBlock* Default
unsigned int NumCases
llvm::Instruction* InsertBefore = nullptr

static llvm::SwitchInst* Create(
    llvm::Value* Value,
    llvm::BasicBlock* Default,
    unsigned int NumCases,
    llvm::BasicBlock* InsertAtEnd)

Declared at: llvm/include/llvm/IR/Instructions.h:3438

Parameters

llvm::Value* Value
llvm::BasicBlock* Default
unsigned int NumCases
llvm::BasicBlock* InsertAtEnd

SwitchInst(llvm::Value* Value,
           llvm::BasicBlock* Default,
           unsigned int NumCases,
           llvm::Instruction* InsertBefore)

Description

Create a new switch instruction, specifying a value to switch on and a default destination. The number of additional cases can be specified here to make memory allocation more efficient. This constructor can also auto-insert before another instruction.

Declared at: llvm/include/llvm/IR/Instructions.h:3256

Parameters

llvm::Value* Value
llvm::BasicBlock* Default
unsigned int NumCases
llvm::Instruction* InsertBefore

SwitchInst(llvm::Value* Value,
           llvm::BasicBlock* Default,
           unsigned int NumCases,
           llvm::BasicBlock* InsertAtEnd)

Description

Create a new switch instruction, specifying a value to switch on and a default destination. The number of additional cases can be specified here to make memory allocation more efficient. This constructor also auto-inserts at the end of the specified BasicBlock.

Declared at: llvm/include/llvm/IR/Instructions.h:3263

Parameters

llvm::Value* Value
llvm::BasicBlock* Default
unsigned int NumCases
llvm::BasicBlock* InsertAtEnd

SwitchInst(const llvm::SwitchInst& SI)

Declared at: llvm/include/llvm/IR/Instructions.h:3250

Parameters

const llvm::SwitchInst& SI

void addCase(llvm::ConstantInt* OnVal,
             llvm::BasicBlock* Dest)

Description

Add an entry to the switch instruction. Note: This action invalidates case_end(). Old case_end() iterator will point to the added case.

Declared at: llvm/include/llvm/IR/Instructions.h:3553

Parameters

llvm::ConstantInt* OnVal
llvm::BasicBlock* Dest

llvm::SwitchInst::ConstCaseIt case_begin() const

Description

Returns a read-only iterator that points to the first case in the SwitchInst.

Declared at: llvm/include/llvm/IR/Instructions.h:3472

llvm::SwitchInst::CaseIt case_begin()

Description

Returns a read/write iterator that points to the first case in the SwitchInst.

Declared at: llvm/include/llvm/IR/Instructions.h:3466

llvm::SwitchInst::ConstCaseIt case_default() const

Declared at: llvm/include/llvm/IR/Instructions.h:3506

llvm::SwitchInst::CaseIt case_default()

Description

Returns an iterator that points to the default case. Note: this iterator allows to resolve successor only. Attempt to resolve case value causes an assertion. Also note, that increment and decrement also causes an assertion and makes iterator invalid.

Declared at: llvm/include/llvm/IR/Instructions.h:3503

llvm::SwitchInst::CaseIt case_end()

Description

Returns a read/write iterator that points one past the last in the SwitchInst.

Declared at: llvm/include/llvm/IR/Instructions.h:3478

llvm::SwitchInst::ConstCaseIt case_end() const

Description

Returns a read-only iterator that points one past the last in the SwitchInst.

Declared at: llvm/include/llvm/IR/Instructions.h:3484

iterator_range<llvm::SwitchInst::CaseIt> cases()

Description

Iteration adapter for range-for loops.

Declared at: llvm/include/llvm/IR/Instructions.h:3489

iterator_range<llvm::SwitchInst::ConstCaseIt>
cases() const

Description

Constant iteration adapter for range-for loops.

Declared at: llvm/include/llvm/IR/Instructions.h:3494

static bool classof(const llvm::Value* V)

Declared at: llvm/include/llvm/IR/Instructions.h:3578

Parameters

const llvm::Value* V

static bool classof(const llvm::Instruction* I)

Declared at: llvm/include/llvm/IR/Instructions.h:3575

Parameters

const llvm::Instruction* I

llvm::SwitchInst* cloneImpl() const

Declared at: llvm/include/llvm/IR/Instructions.h:3276

llvm::ConstantInt* findCaseDest(
    llvm::BasicBlock* BB)

Description

Finds the unique case value for a given successor. Returns null if the successor is not found, not unique, or is the default case.

Declared at: llvm/include/llvm/IR/Instructions.h:3531

Parameters

llvm::BasicBlock* BB

llvm::SwitchInst::CaseIt findCaseValue(
    const llvm::ConstantInt* C)

Description

Search all of the case values for the specified constant. If it is explicitly handled, return the case iterator of it, otherwise return default case iterator to indicate that it is handled by the default handler.

Declared at: llvm/include/llvm/IR/Instructions.h:3514

Parameters

const llvm::ConstantInt* C

llvm::SwitchInst::ConstCaseIt findCaseValue(
    const llvm::ConstantInt* C) const

Declared at: llvm/include/llvm/IR/Instructions.h:3519

Parameters

const llvm::ConstantInt* C

llvm::Value* getCondition() const

Declared at: llvm/include/llvm/IR/Instructions.h:3447

llvm::BasicBlock* getDefaultDest() const

Declared at: llvm/include/llvm/IR/Instructions.h:3450

unsigned int getNumCases() const

Description

Return the number of 'cases' in this switch instruction, excluding the default case.

Declared at: llvm/include/llvm/IR/Instructions.h:3460

unsigned int getNumSuccessors() const

Declared at: llvm/include/llvm/IR/Instructions.h:3564

llvm::BasicBlock* getSuccessor(
    unsigned int idx) const

Declared at: llvm/include/llvm/IR/Instructions.h:3565

Parameters

unsigned int idx

void growOperands()

Declared at: llvm/include/llvm/IR/Instructions.h:3270

void init(llvm::Value* Value,
          llvm::BasicBlock* Default,
          unsigned int NumReserved)

Declared at: llvm/include/llvm/IR/Instructions.h:3269

Parameters

llvm::Value* Value
llvm::BasicBlock* Default
unsigned int NumReserved

llvm::SwitchInst::CaseIt removeCase(
    llvm::SwitchInst::CaseIt I)

Description

This method removes the specified case and its successor from the switch instruction. Note that this operation may reorder the remaining cases at index idx and above. Note: This action invalidates iterators for all cases following the one removed, including the case_end() iterator. It returns an iterator for the next case.

Declared at: llvm/include/llvm/IR/Instructions.h:3562

Parameters

llvm::SwitchInst::CaseIt I

void setCondition(llvm::Value* V)

Declared at: llvm/include/llvm/IR/Instructions.h:3448

Parameters

llvm::Value* V

void setDefaultDest(llvm::BasicBlock* DefaultCase)

Declared at: llvm/include/llvm/IR/Instructions.h:3454

Parameters

llvm::BasicBlock* DefaultCase

void setSuccessor(unsigned int idx,
                  llvm::BasicBlock* NewSucc)

Declared at: llvm/include/llvm/IR/Instructions.h:3569

Parameters

unsigned int idx
llvm::BasicBlock* NewSucc