LLVM API Documentation

llvm::Instruction Class Reference

#include <Instruction.h>

Inheritance diagram for llvm::Instruction:

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

Collaboration graph
[legend]
List of all members.

Public Types

 N
 OPC
 num
 opcode
 HANDLE_MEMORY_INST
 Malloc
 Alloca
 Load
 HANDLE_OTHER_INST
 PHI
 Cast
 Call
 Shl
 Select
 UserOp1
 VAArg
 ExtractElement
 InsertElement
 ShuffleVector
 ShuffleVectorInst
enum  TermOps {
  N, OPC, num, opcode,
  num, opcode, num, opcode,
  HANDLE_MEMORY_INST, Malloc, HANDLE_MEMORY_INST, Alloca,
  HANDLE_MEMORY_INST, Load, HANDLE_OTHER_INST, PHI,
  HANDLE_OTHER_INST, Cast, HANDLE_OTHER_INST, Call,
  HANDLE_OTHER_INST, Shl, HANDLE_OTHER_INST, Select,
  HANDLE_OTHER_INST, UserOp1, HANDLE_OTHER_INST, VAArg,
  HANDLE_OTHER_INST, ExtractElement, HANDLE_OTHER_INST, InsertElement,
  HANDLE_OTHER_INST, ShuffleVector, ShuffleVectorInst
}
enum  BinaryOps {
  N, OPC, num, opcode,
  num, opcode, num, opcode,
  HANDLE_MEMORY_INST, Malloc, HANDLE_MEMORY_INST, Alloca,
  HANDLE_MEMORY_INST, Load, HANDLE_OTHER_INST, PHI,
  HANDLE_OTHER_INST, Cast, HANDLE_OTHER_INST, Call,
  HANDLE_OTHER_INST, Shl, HANDLE_OTHER_INST, Select,
  HANDLE_OTHER_INST, UserOp1, HANDLE_OTHER_INST, VAArg,
  HANDLE_OTHER_INST, ExtractElement, HANDLE_OTHER_INST, InsertElement,
  HANDLE_OTHER_INST, ShuffleVector, ShuffleVectorInst
}
enum  MemoryOps {
  N, OPC, num, opcode,
  num, opcode, num, opcode,
  HANDLE_MEMORY_INST, Malloc, HANDLE_MEMORY_INST, Alloca,
  HANDLE_MEMORY_INST, Load, HANDLE_OTHER_INST, PHI,
  HANDLE_OTHER_INST, Cast, HANDLE_OTHER_INST, Call,
  HANDLE_OTHER_INST, Shl, HANDLE_OTHER_INST, Select,
  HANDLE_OTHER_INST, UserOp1, HANDLE_OTHER_INST, VAArg,
  HANDLE_OTHER_INST, ExtractElement, HANDLE_OTHER_INST, InsertElement,
  HANDLE_OTHER_INST, ShuffleVector, ShuffleVectorInst
}
enum  OtherOps {
  N, OPC, num, opcode,
  num, opcode, num, opcode,
  HANDLE_MEMORY_INST, Malloc, HANDLE_MEMORY_INST, Alloca,
  HANDLE_MEMORY_INST, Load, HANDLE_OTHER_INST, PHI,
  HANDLE_OTHER_INST, Cast, HANDLE_OTHER_INST, Call,
  HANDLE_OTHER_INST, Shl, HANDLE_OTHER_INST, Select,
  HANDLE_OTHER_INST, UserOp1, HANDLE_OTHER_INST, VAArg,
  HANDLE_OTHER_INST, ExtractElement, HANDLE_OTHER_INST, InsertElement,
  HANDLE_OTHER_INST, ShuffleVector, ShuffleVectorInst
}

Public Member Functions

 ~Instruction ()
virtual bool mayWriteToMemory () const
virtual Instructionclone () const =0
bool isIdenticalTo (Instruction *I) const
const BasicBlockgetParent () const
BasicBlockgetParent ()
InstructiongetNext ()
const InstructiongetNext () const
InstructiongetPrev ()
const InstructiongetPrev () const
void removeFromParent ()
void eraseFromParent ()
void moveBefore (Instruction *MovePos)
unsigned getOpcode () const
virtual const char * getOpcodeName () const
bool isTerminator () const
bool isBinaryOp () const
bool isAssociative () const
bool isCommutative () const
bool isRelational () const
bool isTrapping () const
virtual void print (std::ostream &OS) const
void print (std::ostream &OS, AssemblyAnnotationWriter *AAW) const

Static Public Member Functions

static const char * getOpcodeName (unsigned OpCode)
static bool isTerminator (unsigned OpCode)
static bool isAssociative (unsigned op, const Type *Ty)
static bool isCommutative (unsigned op)
static bool isRelational (unsigned op)
static bool isTrapping (unsigned op)
static bool classof (const Instruction *)
 Methods for support type inquiry through isa, cast, and dyn_cast:.
static bool classof (const Value *V)

Protected Member Functions

 Instruction (const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps, const std::string &Name="", Instruction *InsertBefore=0)
 Instruction (const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps, const std::string &Name, BasicBlock *InsertAtEnd)

Friends

class SymbolTableListTraits< Instruction, BasicBlock, Function,ilist_traits< Instruction > >
class BinaryOperator

Detailed Description

Definition at line 29 of file Instruction.h.


Member Enumeration Documentation

enum llvm::Instruction::BinaryOps

Enumerator:
N 
OPC 
num 
opcode 
num 
opcode 
num 
opcode 
HANDLE_MEMORY_INST 
Malloc 
HANDLE_MEMORY_INST 
Alloca 
HANDLE_MEMORY_INST 
Load 
HANDLE_OTHER_INST 
PHI 
HANDLE_OTHER_INST 
Cast 
HANDLE_OTHER_INST 
Call 
HANDLE_OTHER_INST 
Shl 
HANDLE_OTHER_INST 
Select 
HANDLE_OTHER_INST 
UserOp1 
HANDLE_OTHER_INST 
VAArg 
HANDLE_OTHER_INST 
ExtractElement 
HANDLE_OTHER_INST 
InsertElement 
HANDLE_OTHER_INST 
ShuffleVector 
ShuffleVectorInst 

Definition at line 338 of file Instruction.h.

enum llvm::Instruction::MemoryOps

Enumerator:
N 
OPC 
num 
opcode 
num 
opcode 
num 
opcode 
HANDLE_MEMORY_INST 
Malloc 
HANDLE_MEMORY_INST 
Alloca 
HANDLE_MEMORY_INST 
Load 
HANDLE_OTHER_INST 
PHI 
HANDLE_OTHER_INST 
Cast 
HANDLE_OTHER_INST 
Call 
HANDLE_OTHER_INST 
Shl 
HANDLE_OTHER_INST 
Select 
HANDLE_OTHER_INST 
UserOp1 
HANDLE_OTHER_INST 
VAArg 
HANDLE_OTHER_INST 
ExtractElement 
HANDLE_OTHER_INST 
InsertElement 
HANDLE_OTHER_INST 
ShuffleVector 
ShuffleVectorInst 

Definition at line 505 of file Instruction.h.

enum llvm::Instruction::OtherOps

Enumerator:
N 
OPC 
num 
opcode 
num 
opcode 
num 
opcode 
HANDLE_MEMORY_INST 
Malloc 
HANDLE_MEMORY_INST 
Alloca 
HANDLE_MEMORY_INST 
Load 
HANDLE_OTHER_INST 
PHI 
HANDLE_OTHER_INST 
Cast 
HANDLE_OTHER_INST 
Call 
HANDLE_OTHER_INST 
Shl 
HANDLE_OTHER_INST 
Select 
HANDLE_OTHER_INST 
UserOp1 
HANDLE_OTHER_INST 
VAArg 
HANDLE_OTHER_INST 
ExtractElement 
HANDLE_OTHER_INST 
InsertElement 
HANDLE_OTHER_INST 
ShuffleVector 
ShuffleVectorInst 

Definition at line 672 of file Instruction.h.

enum llvm::Instruction::TermOps

Enumerator:
N 
OPC 
num 
opcode 
num 
opcode 
num 
opcode 
HANDLE_MEMORY_INST 
Malloc 
HANDLE_MEMORY_INST 
Alloca 
HANDLE_MEMORY_INST 
Load 
HANDLE_OTHER_INST 
PHI 
HANDLE_OTHER_INST 
Cast 
HANDLE_OTHER_INST 
Call 
HANDLE_OTHER_INST 
Shl 
HANDLE_OTHER_INST 
Select 
HANDLE_OTHER_INST 
UserOp1 
HANDLE_OTHER_INST 
VAArg 
HANDLE_OTHER_INST 
ExtractElement 
HANDLE_OTHER_INST 
InsertElement 
HANDLE_OTHER_INST 
ShuffleVector 
ShuffleVectorInst 

Definition at line 171 of file Instruction.h.


Constructor & Destructor Documentation

Instruction::Instruction ( const Type Ty,
unsigned  iType,
Use Ops,
unsigned  NumOps,
const std::string &  Name = "",
Instruction InsertBefore = 0 
) [protected]

Definition at line 21 of file Instruction.cpp.

References llvm::LeakDetector::addGarbageObject(), and llvm::InsertBefore().

Instruction::Instruction ( const Type Ty,
unsigned  iType,
Use Ops,
unsigned  NumOps,
const std::string &  Name,
BasicBlock InsertAtEnd 
) [protected]

Definition at line 35 of file Instruction.cpp.

References llvm::LeakDetector::addGarbageObject(), and llvm::BasicBlock::getInstList().

llvm::Instruction::~Instruction (  )  [inline]

Definition at line 56 of file Instruction.h.


Member Function Documentation

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

Reimplemented from llvm::User.

Reimplemented in llvm::TerminatorInst, llvm::BinaryOperator, llvm::AllocationInst, llvm::MallocInst, llvm::AllocaInst, llvm::FreeInst, llvm::LoadInst, llvm::StoreInst, llvm::GetElementPtrInst, llvm::SetCondInst, llvm::CastInst, llvm::CallInst, llvm::ShiftInst, llvm::SelectInst, llvm::VAArgInst, llvm::ExtractElementInst, llvm::InsertElementInst, llvm::ShuffleVectorInst, llvm::PHINode, llvm::ReturnInst, llvm::BranchInst, llvm::SwitchInst, llvm::InvokeInst, llvm::UnwindInst, llvm::UnreachableInst, llvm::IntrinsicInst, llvm::DbgInfoIntrinsic, llvm::DbgStopPointInst, llvm::DbgFuncStartInst, llvm::DbgRegionStartInst, llvm::DbgRegionEndInst, llvm::DbgDeclareInst, llvm::MemIntrinsic, llvm::MemCpyInst, llvm::MemMoveInst, llvm::MemSetInst, llvm::TmpInstruction, and llvm::ValueHandle.

Definition at line 164 of file Instruction.h.

References llvm::Value::InstructionVal, and V.

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

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

Reimplemented in llvm::TerminatorInst, llvm::BinaryOperator, llvm::AllocationInst, llvm::MallocInst, llvm::AllocaInst, llvm::FreeInst, llvm::LoadInst, llvm::StoreInst, llvm::GetElementPtrInst, llvm::SetCondInst, llvm::CastInst, llvm::CallInst, llvm::ShiftInst, llvm::SelectInst, llvm::VAArgInst, llvm::ExtractElementInst, llvm::InsertElementInst, llvm::ShuffleVectorInst, llvm::PHINode, llvm::ReturnInst, llvm::BranchInst, llvm::SwitchInst, llvm::InvokeInst, llvm::UnwindInst, llvm::UnreachableInst, llvm::TmpInstruction, and llvm::ValueHandle.

Definition at line 163 of file Instruction.h.

virtual Instruction* llvm::Instruction::clone (  )  const [pure 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

Implemented in llvm::TerminatorInst, llvm::BinaryOperator, llvm::AllocationInst, llvm::MallocInst, llvm::AllocaInst, llvm::FreeInst, llvm::LoadInst, llvm::StoreInst, llvm::GetElementPtrInst, llvm::CastInst, llvm::CallInst, llvm::ShiftInst, llvm::SelectInst, llvm::VAArgInst, llvm::ExtractElementInst, llvm::InsertElementInst, llvm::ShuffleVectorInst, llvm::PHINode, llvm::ReturnInst, llvm::BranchInst, llvm::SwitchInst, llvm::InvokeInst, llvm::UnwindInst, llvm::UnreachableInst, llvm::TmpInstruction, and llvm::ValueHandle.

Referenced by HoistThenElseCodeToIf().

void Instruction::eraseFromParent (  ) 

eraseFromParent - This method unlinks 'this' from the containing basic block and deletes it.

Definition at line 64 of file Instruction.cpp.

References llvm::BasicBlock::getInstList(), and getParent().

Referenced by BreakUpSubtract(), ConvertShiftToMul(), FoldCondBranchOnPHI(), HoistThenElseCodeToIf(), llvm::DefaultIntrinsicLowering::LowerIntrinsicCall(), LowerNegateToMultiply(), OptimizeGEPExpression(), OptimizeGlobalAddressOfMalloc(), llvm::PHINode::removeIncomingValue(), llvm::BasicBlock::removePredecessor(), ReplaceUsesOfWith(), and llvm::UpgradeIntrinsicCall().

const Instruction* llvm::Instruction::getNext (  )  const [inline]

Definition at line 85 of file Instruction.h.

References Next.

Instruction* llvm::Instruction::getNext (  )  [inline]

Definition at line 84 of file Instruction.h.

References Next.

Referenced by llvm::DecomposeArrayRef().

unsigned llvm::Instruction::getOpcode (  )  const [inline]

Subclass classification... getOpcode() returns a member of one of the enums that is coming soon (down below)...

Reimplemented in llvm::BinaryOperator, llvm::ShiftInst, and llvm::SelectInst.

Definition at line 108 of file Instruction.h.

References llvm::Value::getValueType(), and llvm::Value::InstructionVal.

Referenced by llvm::CallSite::arg_begin(), AssociativeOpt(), CheapToScalarize(), llvm::ChooseInstructionsForDelaySlots(), llvm::ValueHandle::classof(), llvm::TmpInstruction::classof(), llvm::UnreachableInst::classof(), llvm::UnwindInst::classof(), llvm::InvokeInst::classof(), llvm::SwitchInst::classof(), llvm::BranchInst::classof(), llvm::ReturnInst::classof(), llvm::PHINode::classof(), llvm::ShuffleVectorInst::classof(), llvm::InsertElementInst::classof(), llvm::ExtractElementInst::classof(), llvm::VAArgInst::classof(), llvm::SelectInst::classof(), llvm::ShiftInst::classof(), llvm::CallInst::classof(), llvm::CastInst::classof(), llvm::SetCondInst::classof(), llvm::GetElementPtrInst::classof(), llvm::StoreInst::classof(), llvm::LoadInst::classof(), llvm::FreeInst::classof(), llvm::AllocaInst::classof(), llvm::MallocInst::classof(), llvm::AllocationInst::classof(), llvm::TerminatorInst::classof(), ComputeMaskedBits(), llvm::ConvertExpressionToType(), ConvertOperandToType(), DominatesMergePoint(), llvm::ExpressionConvertibleToType(), GatherConstantSetEQs(), GatherConstantSetNEs(), GatherValueComparisons(), llvm::CallSite::get(), llvm::AliasAnalysis::getModRefInfo(), llvm::SelectInst::getOpcode(), llvm::ShiftInst::getOpcode(), getOpcodeName(), GetSelectFoldableConstant(), GetSelectFoldableOperands(), HoistThenElseCodeToIf(), IdenticalComplexInst(), llvm::InlineFunction(), llvm::InstructionNode::InstructionNode(), isAssociative(), isBinaryOp(), isCommutative(), isIdenticalBinaryInst(), isIdenticalTo(), isRelational(), isTerminator(), isTrapping(), isTrueWhenEqual(), isUnmovableInstruction(), OperandConvertibleToType(), PrintOps(), llvm::RemoveSuccessor(), ShouldTraceValue(), llvm::SimplifyCFG(), llvm::SelectionDAGLowering::visit(), and llvm::Interpreter::visitAllocationInst().

const char * Instruction::getOpcodeName ( unsigned  OpCode  )  [static]

Definition at line 77 of file Instruction.cpp.

References Alloca, Call, Cast, ExtractElement, InsertElement, Load, Malloc, PHI, Select, Shl, ShuffleVector, Store, and VAArg.

virtual const char* llvm::Instruction::getOpcodeName (  )  const [inline, virtual]

Reimplemented in llvm::TmpInstruction, and llvm::ValueHandle.

Definition at line 109 of file Instruction.h.

References getOpcode().

Referenced by llvm::InstructionNode::dumpNode(), and llvm::ConstantExpr::getOpcodeName().

BasicBlock* llvm::Instruction::getParent (  )  [inline]

Definition at line 80 of file Instruction.h.

const BasicBlock* llvm::Instruction::getParent (  )  const [inline]

Definition at line 79 of file Instruction.h.

Referenced by AssociativeOpt(), llvm::AliasAnalysis::canInstructionRangeModify(), llvm::ConvertExpressionToType(), ConvertOperandToType(), llvm::DecomposeArrayRef(), llvm::DemoteRegToStack(), llvm::MachineCodeForInstruction::destroy(), DominatesMergePoint(), eraseFromParent(), ErasePossiblyDeadInstructionTree(), FoldCondBranchOnPHI(), FoldTwoEntryPHINode(), FoldValueComparisonIntoPredecessors(), llvm::MachineCodeForInstruction::get(), llvm::DSCallSite::getCaller(), llvm::CallSite::getCaller(), getCommonReturnValue(), getConstantEvolvingPHI(), HoistThenElseCodeToIf(), IdenticalComplexInst(), InlineCallIfPossible(), llvm::InlineFunction(), InsertGEPComputeCode(), isDynamicConstant(), isIdenticalBinaryInst(), isIdenticalSelectInst(), isSafeToLoadUnconditionally(), IVUseShouldUsePostIncValue(), LiveAtBBExit(), moveBefore(), llvm::MSchedGraphSB::MSchedGraphSB(), OptimizeGEPExpression(), print(), PrintOps(), RecursiveDelete(), removeFromParent(), llvm::RemoveSuccessor(), ReplaceCallWith(), llvm::ReplaceInstWithInst(), llvm::Inliner::runOnSCC(), SafeToMergeTerminators(), SimplifyEqualityComparisonWithOnlyPredecessor(), llvm::SplitCriticalEdge(), llvm::SCEVExpander::visitAddRecExpr(), and llvm::Interpreter::visitCallSite().

const Instruction* llvm::Instruction::getPrev (  )  const [inline]

Definition at line 87 of file Instruction.h.

References Prev.

Instruction* llvm::Instruction::getPrev (  )  [inline]

Definition at line 86 of file Instruction.h.

References Prev.

Referenced by llvm::Interpreter::visitCallSite().

bool Instruction::isAssociative ( unsigned  Opcode,
const Type Ty 
) [static]

isAssociative - Return true if the instruction is associative:

Associative operators satisfy: x op (y op z) === (x op y) op z)

In LLVM, the Add, Mul, And, Or, and Xor operators are associative, when not applied to floating point types.

Definition at line 166 of file Instruction.cpp.

References llvm::Type::isFloatingPoint().

bool llvm::Instruction::isAssociative (  )  const [inline]

isAssociative - Return true if the instruction is associative:

Associative operators satisfy: x op (y op z) === (x op y) op z

In LLVM, the Add, Mul, And, Or, and Xor operators are associative, when not applied to floating point types.

Definition at line 133 of file Instruction.h.

References getOpcode(), and llvm::Value::getType().

bool llvm::Instruction::isBinaryOp (  )  const [inline]

Definition at line 122 of file Instruction.h.

References getOpcode().

bool Instruction::isCommutative ( unsigned  op  )  [static]

isCommutative - Return true if the instruction is commutative:

Commutative operators satisfy: (x op y) === (y op x)

In LLVM, these are the associative operators, plus SetEQ and SetNE, when applied to any type.

Definition at line 182 of file Instruction.cpp.

bool llvm::Instruction::isCommutative (  )  const [inline]

isCommutative - Return true if the instruction is commutative:

Commutative operators satisfy: (x op y) === (y op x)

In LLVM, these are the associative operators, plus SetEQ and SetNE, when applied to any type.

Definition at line 143 of file Instruction.h.

References getOpcode().

Referenced by isIdenticalBinaryInst(), and llvm::BinaryOperator::swapOperands().

bool Instruction::isIdenticalTo ( Instruction I  )  const

isIdenticalTo - Return true if the specified instruction is exactly identical to the current one. This means that all operands match and any extra information (e.g. load is volatile) agree.

Definition at line 136 of file Instruction.cpp.

References llvm::User::getNumOperands(), getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), and LI.

Referenced by HoistThenElseCodeToIf().

bool Instruction::isRelational ( unsigned  op  )  [static]

isRelational - Return true if the instruction is a Set* instruction:

Definition at line 199 of file Instruction.cpp.

bool llvm::Instruction::isRelational (  )  const [inline]

isRelational - Return true if the instruction is a Set* instruction:

Definition at line 148 of file Instruction.h.

References getOpcode().

Referenced by llvm::ConstantFoldBinaryInstruction(), llvm::ConstantExpr::get(), and llvm::ConstantExpr::getTy().

bool llvm::Instruction::isTerminator (  )  const [inline]

Definition at line 118 of file Instruction.h.

References getOpcode().

static bool llvm::Instruction::isTerminator ( unsigned  OpCode  )  [inline, static]

Definition at line 114 of file Instruction.h.

bool Instruction::isTrapping ( unsigned  op  )  [static]

isTrappingInstruction - Return true if the instruction may trap.

Definition at line 216 of file Instruction.cpp.

References Call, Load, and Store.

bool llvm::Instruction::isTrapping (  )  const [inline]

isTrappingInstruction - Return true if the instruction may trap.

Definition at line 154 of file Instruction.h.

References getOpcode().

virtual bool llvm::Instruction::mayWriteToMemory (  )  const [inline, virtual]

mayWriteToMemory - Return true if this instruction may modify memory.

Reimplemented in llvm::FreeInst, llvm::LoadInst, llvm::StoreInst, llvm::CallInst, llvm::VAArgInst, llvm::ExtractElementInst, llvm::InsertElementInst, llvm::ShuffleVectorInst, and llvm::InvokeInst.

Definition at line 62 of file Instruction.h.

Referenced by llvm::isInstructionTriviallyDead().

void Instruction::moveBefore ( Instruction MovePos  ) 

moveBefore - Unlink this instruction from its current basic block and insert it into the basic block that MovePos lives in, right before MovePos.

Definition at line 71 of file Instruction.cpp.

References llvm::BasicBlock::getInstList(), and getParent().

Referenced by NegateValue(), and llvm::UpgradeIntrinsicCall().

void Instruction::print ( std::ostream &  OS,
AssemblyAnnotationWriter AAW 
) const

Definition at line 1303 of file AsmWriter.cpp.

References F, llvm::BasicBlock::getParent(), and getParent().

virtual void llvm::Instruction::print ( std::ostream &  OS  )  const [inline, virtual]

print - Implement operator<< on Value...

Implements llvm::Value.

Definition at line 159 of file Instruction.h.

void Instruction::removeFromParent (  ) 

removeFromParent - This method unlinks 'this' from the containing basic block, but does not delete it.

Definition at line 60 of file Instruction.cpp.

References llvm::BasicBlock::getInstList(), and getParent().


Friends And Related Function Documentation

friend class BinaryOperator [friend]

Definition at line 47 of file Instruction.h.

friend class SymbolTableListTraits< Instruction, BasicBlock, Function,ilist_traits< Instruction > > [friend]

Definition at line 40 of file Instruction.h.


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