LLVM API Documentation

llvm::SwitchInst Class Reference

#include <Instructions.h>

Inheritance diagram for llvm::SwitchInst:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 SwitchInst (Value *Value, BasicBlock *Default, unsigned NumCases, Instruction *InsertBefore=0)
 SwitchInst (Value *Value, BasicBlock *Default, unsigned NumCases, BasicBlock *InsertAtEnd)
 ~SwitchInst ()
ValuegetCondition () const
void setCondition (Value *V)
BasicBlockgetDefaultDest () const
unsigned getNumCases () const
ConstantIntgetCaseValue (unsigned i)
const ConstantIntgetCaseValue (unsigned i) const
unsigned findCaseValue (const ConstantInt *C) const
void addCase (ConstantInt *OnVal, BasicBlock *Dest)
void removeCase (unsigned idx)
virtual SwitchInstclone () const
unsigned getNumSuccessors () const
BasicBlockgetSuccessor (unsigned idx) const
void setSuccessor (unsigned idx, BasicBlock *NewSucc)
ConstantIntgetSuccessorValue (unsigned idx) const

Static Public Member Functions

static bool classof (const SwitchInst *)
static bool classof (const Instruction *I)
 Methods for support type inquiry through isa, cast, and dyn_cast:.
static bool classof (const Value *V)

Detailed Description

SwitchInst - Multiway switch

Definition at line 1217 of file Instructions.h.


Constructor & Destructor Documentation

llvm::SwitchInst::SwitchInst ( Value Value,
BasicBlock Default,
unsigned  NumCases,
Instruction InsertBefore = 0 
) [inline]

SwitchInst ctor - 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 autoinsert before another instruction.

Definition at line 1231 of file Instructions.h.

References llvm::CodeModel::Default, and llvm::cl::init().

llvm::SwitchInst::SwitchInst ( Value Value,
BasicBlock Default,
unsigned  NumCases,
BasicBlock InsertAtEnd 
) [inline]

SwitchInst ctor - 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 autoinserts at the end of the specified BasicBlock.

Definition at line 1241 of file Instructions.h.

References llvm::CodeModel::Default, and llvm::cl::init().

SwitchInst::~SwitchInst (  ) 

Definition at line 1219 of file Instructions.cpp.

References llvm::User::OperandList.


Member Function Documentation

Value* llvm::SwitchInst::getCondition (  )  const [inline]

Definition at line 1250 of file Instructions.h.

References llvm::UnaryInstruction::getOperand().

Referenced by AddReachableCodeToWorklist().

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

Definition at line 1251 of file Instructions.h.

References llvm::UnaryInstruction::setOperand(), and V.

BasicBlock* llvm::SwitchInst::getDefaultDest (  )  const [inline]

Definition at line 1253 of file Instructions.h.

References llvm::UnaryInstruction::getOperand().

Referenced by llvm::SelectionDAGLowering::visitSwitch(), and llvm::Interpreter::visitSwitchInst().

unsigned llvm::SwitchInst::getNumCases (  )  const [inline]

getNumCases - return the number of 'cases' in this switch instruction. Note that case #0 is always the default case.

Definition at line 1259 of file Instructions.h.

References llvm::UnaryInstruction::getNumOperands().

Referenced by SimplifyEqualityComparisonWithOnlyPredecessor().

ConstantInt* llvm::SwitchInst::getCaseValue ( unsigned  i  )  [inline]

getCaseValue - Return the specified case value. Note that case #0, the default destination, does not have a case value.

Definition at line 1265 of file Instructions.h.

Referenced by AddReachableCodeToWorklist(), and SimplifyEqualityComparisonWithOnlyPredecessor().

const ConstantInt* llvm::SwitchInst::getCaseValue ( unsigned  i  )  const [inline]

getCaseValue - Return the specified case value. Note that case #0, the default destination, does not have a case value.

Definition at line 1272 of file Instructions.h.

unsigned llvm::SwitchInst::findCaseValue ( const ConstantInt C  )  const [inline]

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

Definition at line 1280 of file Instructions.h.

References C.

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

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

Definition at line 1226 of file Instructions.cpp.

References Dest, llvm::Use::init(), llvm::User::NumOperands, and llvm::User::OperandList.

Referenced by FoldValueComparisonIntoPredecessors(), llvm::BytecodeReader::ParseInstruction(), and llvm::SimplifyCFG().

void SwitchInst::removeCase ( unsigned  idx  ) 

removeCase - This method removes the specified successor from the switch instruction. Note that this cannot be used to remove the default destination (successor #0).

Definition at line 1241 of file Instructions.cpp.

References llvm::User::getNumOperands(), llvm::User::NumOperands, llvm::User::OperandList, and llvm::Use::set().

Referenced by SimplifyEqualityComparisonWithOnlyPredecessor().

SwitchInst * SwitchInst::clone (  )  const [virtual]

clone() - Create a copy of 'this' instruction that is identical in all ways except the following: The instruction has no parent The instruction has no name

Implements llvm::TerminatorInst.

Definition at line 1339 of file Instructions.cpp.

unsigned llvm::SwitchInst::getNumSuccessors (  )  const [inline]

getNumSuccessors - Return the number of successors that this terminator has.

Reimplemented from llvm::TerminatorInst.

Definition at line 1299 of file Instructions.h.

References llvm::UnaryInstruction::getNumOperands().

Referenced by AddReachableCodeToWorklist(), FoldValueComparisonIntoPredecessors(), and llvm::SelectionDAGLowering::visitSwitch().

BasicBlock* llvm::SwitchInst::getSuccessor ( unsigned  idx  )  const [inline]

getSuccessor - Return the specified successor.

Reimplemented from llvm::TerminatorInst.

Definition at line 1300 of file Instructions.h.

References llvm::UnaryInstruction::getOperand().

Referenced by AddReachableCodeToWorklist(), FoldValueComparisonIntoPredecessors(), SimplifyEqualityComparisonWithOnlyPredecessor(), and llvm::SelectionDAGLowering::visitSwitch().

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

setSuccessor - Update the specified successor to point at the provided block.

Reimplemented from llvm::TerminatorInst.

Definition at line 1304 of file Instructions.h.

References llvm::UnaryInstruction::setOperand().

Referenced by FoldValueComparisonIntoPredecessors().

ConstantInt* llvm::SwitchInst::getSuccessorValue ( unsigned  idx  )  const [inline]

Definition at line 1311 of file Instructions.h.

References llvm::UnaryInstruction::getOperand().

Referenced by llvm::SelectionDAGLowering::visitSwitch().

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

Definition at line 1317 of file Instructions.h.

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

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

Reimplemented from llvm::TerminatorInst.

Definition at line 1318 of file Instructions.h.

References llvm::Instruction::getOpcode().

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

Reimplemented from llvm::TerminatorInst.

Definition at line 1321 of file Instructions.h.

References llvm::CastInst::classof(), and V.


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