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

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
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::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 169 of file Instruction.h.

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 336 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 503 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 670 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(), llvm::BasicBlock::getInstList(), and getParent().

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().

Instruction::~Instruction (  ) 

Definition at line 47 of file Instruction.cpp.


Member Function Documentation

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 60 of file Instruction.h.

Referenced by llvm::isInstructionTriviallyDead().

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, and llvm::ValueHandle.

Referenced by HoistThenElseCodeToIf().

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 142 of file Instruction.cpp.

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

Referenced by HoistThenElseCodeToIf().

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

Definition at line 77 of file Instruction.h.

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

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

Definition at line 78 of file Instruction.h.

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

Definition at line 82 of file Instruction.h.

References Next.

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

Definition at line 83 of file Instruction.h.

References Next.

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

Definition at line 84 of file Instruction.h.

References Prev.

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

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

Definition at line 85 of file Instruction.h.

References Prev.

void Instruction::removeFromParent (  ) 

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

Definition at line 66 of file Instruction.cpp.

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

void Instruction::eraseFromParent (  ) 

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

Definition at line 70 of file Instruction.cpp.

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

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

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 77 of file Instruction.cpp.

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

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

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 106 of file Instruction.h.

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

Referenced by llvm::CallSite::arg_begin(), AssociativeOpt(), CanEvaluateInDifferentType(), CheapToScalarize(), llvm::ValueHandle::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(), CollectBSwapParts(), 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(), 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* llvm::Instruction::getOpcodeName (  )  const [inline]

Reimplemented in llvm::ValueHandle.

Definition at line 107 of file Instruction.h.

References getOpcode().

Referenced by llvm::ConstantExpr::getOpcodeName().

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

Definition at line 83 of file Instruction.cpp.

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

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

Definition at line 112 of file Instruction.h.

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

Definition at line 116 of file Instruction.h.

References getOpcode().

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

Definition at line 120 of file Instruction.h.

References getOpcode().

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 131 of file Instruction.h.

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

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 172 of file Instruction.cpp.

References llvm::Type::isFloatingPoint().

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 141 of file Instruction.h.

References getOpcode().

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

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 188 of file Instruction.cpp.

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

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

Definition at line 146 of file Instruction.h.

References getOpcode().

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

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

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

Definition at line 205 of file Instruction.cpp.

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

isTrappingInstruction - Return true if the instruction may trap.

Definition at line 152 of file Instruction.h.

References getOpcode().

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

isTrappingInstruction - Return true if the instruction may trap.

Definition at line 222 of file Instruction.cpp.

References Call, Load, and llvm::SPII::Store.

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

print - Implement operator<< on Value...

Implements llvm::Value.

Definition at line 157 of file Instruction.h.

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

Definition at line 1306 of file AsmWriter.cpp.

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

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, and llvm::ValueHandle.

Definition at line 161 of file Instruction.h.

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, and llvm::ValueHandle.

Definition at line 162 of file Instruction.h.

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


Friends And Related Function Documentation

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

Definition at line 40 of file Instruction.h.

friend class BinaryOperator [friend]

Definition at line 47 of file Instruction.h.


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