LLVM  mainline
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Friends
llvm::SwitchInst Class Reference

SwitchInst - Multiway switch. More...

#include <Instructions.h>

Inheritance diagram for llvm::SwitchInst:
Inheritance graph
[legend]
Collaboration diagram for llvm::SwitchInst:
Collaboration graph
[legend]

List of all members.

Classes

class  CaseIt
class  CaseIteratorT

Public Types

typedef CaseIteratorT< const
SwitchInst, const ConstantInt,
const BasicBlock
ConstCaseIt

Public Member Functions

 DECLARE_TRANSPARENT_OPERAND_ACCESSORS (Value)
 Provide fast operand accessors.
ValuegetCondition () const
void setCondition (Value *V)
BasicBlockgetDefaultDest () const
void setDefaultDest (BasicBlock *DefaultCase)
unsigned getNumCases () const
 getNumCases - return the number of 'cases' in this switch instruction, except the default case
CaseIt case_begin ()
 Returns a read/write iterator that points to the first case in SwitchInst.
ConstCaseIt case_begin () const
 Returns a read-only iterator that points to the first case in the SwitchInst.
CaseIt case_end ()
 Returns a read/write iterator that points one past the last in the SwitchInst.
ConstCaseIt case_end () const
 Returns a read-only iterator that points one past the last in the SwitchInst.
iterator_range< CaseItcases ()
 cases - iteration adapter for range-for loops.
iterator_range< ConstCaseItcases () const
 cases - iteration adapter for range-for loops.
CaseIt case_default ()
 Returns an iterator that points to the default case.
ConstCaseIt case_default () const
CaseIt findCaseValue (const ConstantInt *C)
 findCaseValue - Search all of the case values for the specified constant.
ConstCaseIt findCaseValue (const ConstantInt *C) const
ConstantIntfindCaseDest (BasicBlock *BB)
 findCaseDest - Finds the unique case value for a given successor.
void addCase (ConstantInt *OnVal, BasicBlock *Dest)
 addCase - Add an entry to the switch instruction...
void removeCase (CaseIt i)
 removeCase - This method removes the specified case and its successor from the switch instruction.
unsigned getNumSuccessors () const
 Return the number of successors that this terminator has.
BasicBlockgetSuccessor (unsigned idx) const
 Return the specified successor.
void setSuccessor (unsigned idx, BasicBlock *NewSucc)
 Update the specified successor to point at the provided block.

Static Public Member Functions

static SwitchInstCreate (Value *Value, BasicBlock *Default, unsigned NumCases, Instruction *InsertBefore=nullptr)
static SwitchInstCreate (Value *Value, BasicBlock *Default, unsigned NumCases, BasicBlock *InsertAtEnd)
static bool classof (const Instruction *I)
static bool classof (const Value *V)
 Methods for support type inquiry through isa, cast, and dyn_cast:

Static Public Attributes

static const unsigned DefaultPseudoIndex = static_cast<unsigned>(~0L-1)

Protected Member Functions

SwitchInstcloneImpl () const
 Create a copy of this instruction.

Friends

class Instruction

Detailed Description

SwitchInst - Multiway switch.

Definition at line 2925 of file Instructions.h.


Member Typedef Documentation

Definition at line 3052 of file Instructions.h.


Member Function Documentation

void SwitchInst::addCase ( ConstantInt OnVal,
BasicBlock Dest 
)

addCase - Add an entry to the switch instruction...

Note: This action invalidates case_end(). Old case_end() iterator will point to the added case.

Definition at line 3633 of file Instructions.cpp.

References getNumCases(), llvm::User::getNumOperands(), llvm::User::setNumHungOffUseOperands(), llvm::SwitchInst::CaseIt::setSuccessor(), and llvm::SwitchInst::CaseIt::setValue().

Referenced by SimplifyBranchOnICmpChain(), and TryToSimplifyUncondBranchWithICmpInIt().

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

Definition at line 3107 of file Instructions.h.

Referenced by EliminateDeadSwitchCases(), ForwardSwitchConditionToPHI(), SwitchToLookupTable(), llvm::Interpreter::visitSwitchInst(), and llvm::InstCombiner::visitSwitchInst().

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

Definition at line 3112 of file Instructions.h.

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.

Definition at line 3142 of file Instructions.h.

Referenced by EliminateDeadSwitchCases(), handleSwitchExpect(), and TryToSimplifyUncondBranchWithICmpInIt().

Definition at line 3145 of file Instructions.h.

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

Definition at line 3118 of file Instructions.h.

Referenced by EliminateDeadSwitchCases(), ForwardSwitchConditionToPHI(), SwitchToLookupTable(), llvm::Interpreter::visitSwitchInst(), and llvm::InstCombiner::visitSwitchInst().

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

Definition at line 3123 of file Instructions.h.

cases - iteration adapter for range-for loops.

Definition at line 3128 of file Instructions.h.

References llvm::make_range().

Referenced by InitializeUniqueCases(), TurnSwitchRangeIntoICmp(), llvm::InstCombiner::visitSwitchInst(), and WriteInstruction().

cases - iteration adapter for range-for loops.

Definition at line 3133 of file Instructions.h.

References llvm::make_range().

static bool llvm::SwitchInst::classof ( const Instruction I) [inline, static]

Reimplemented from llvm::TerminatorInst.

Definition at line 3206 of file Instructions.h.

References llvm::Instruction::getOpcode(), and Switch().

static bool llvm::SwitchInst::classof ( const Value V) [inline, static]

Methods for support type inquiry through isa, cast, and dyn_cast:

Reimplemented from llvm::TerminatorInst.

Definition at line 3209 of file Instructions.h.

SwitchInst * SwitchInst::cloneImpl ( ) const [protected]

Create a copy of this instruction.

Reimplemented from llvm::Instruction.

Definition at line 3944 of file Instructions.cpp.

static SwitchInst* llvm::SwitchInst::Create ( Value Value,
BasicBlock Default,
unsigned  NumCases,
Instruction InsertBefore = nullptr 
) [inline, static]
static SwitchInst* llvm::SwitchInst::Create ( Value Value,
BasicBlock Default,
unsigned  NumCases,
BasicBlock InsertAtEnd 
) [inline, static]

Definition at line 3079 of file Instructions.h.

Provide fast operand accessors.

findCaseDest - Finds the unique case value for a given successor.

Returns null if the successor is not found, not unique, or is the default case.

Definition at line 3168 of file Instructions.h.

Referenced by TryToSimplifyUncondBranchWithICmpInIt().

findCaseValue - 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.

Definition at line 3153 of file Instructions.h.

References C.

Referenced by EliminateDeadSwitchCases(), handleSwitchExpect(), SimplifySwitchOnSelect(), and TryToSimplifyUncondBranchWithICmpInIt().

Definition at line 3159 of file Instructions.h.

References C.

Return the number of successors that this terminator has.

Reimplemented from llvm::TerminatorInst.

Definition at line 3195 of file Instructions.h.

Referenced by RemoveSwitchAfterSelectConversion(), and SwitchToLookupTable().

removeCase - 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.

Definition at line 3648 of file Instructions.cpp.

References llvm::SwitchInst::CaseIteratorT< SwitchInstTy, ConstantIntTy, BasicBlockTy >::getCaseIndex(), llvm::User::getNumOperands(), llvm::User::getOperandList(), llvm::Use::set(), and llvm::User::setNumHungOffUseOperands().

Referenced by EliminateDeadSwitchCases().

void llvm::SwitchInst::setCondition ( Value V) [inline]

Definition at line 3089 of file Instructions.h.

Referenced by handleSwitchExpect(), and llvm::InstCombiner::visitSwitchInst().

void llvm::SwitchInst::setDefaultDest ( BasicBlock DefaultCase) [inline]

Definition at line 3095 of file Instructions.h.

Referenced by EliminateDeadSwitchCases().

void llvm::SwitchInst::setSuccessor ( unsigned  idx,
BasicBlock B 
) [inline]

Update the specified successor to point at the provided block.

Reimplemented from llvm::TerminatorInst.

Definition at line 3200 of file Instructions.h.

Referenced by llvm::SwitchInst::CaseIt::setSuccessor().


Friends And Related Function Documentation

friend class Instruction [friend]

Definition at line 2955 of file Instructions.h.


Member Data Documentation

Definition at line 2960 of file Instructions.h.


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