LLVM API Documentation

llvm::Instruction Class Reference

#include <Instruction.h>

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

List of all members.

Public Types

enum  TermOps { FIRST_TERM_INST }
enum  BinaryOps { FIRST_BINARY_INST }
enum  MemoryOps { FIRST_MEMORY_INST }
enum  CastOps { FIRST_CAST_INST }
enum  OtherOps { FIRST_OTHER_INST }

Public Member Functions

 ~Instruction ()
bool mayWriteToMemory () const
bool mayReadFromMemory () const
virtual Instruction * clone () const =0
bool isIdenticalTo (const Instruction *I) const
bool isSameOperationAs (const Instruction *I) const
 Determine if one instruction is the same operation as another.
bool isUsedOutsideOfBlock (const BasicBlock *BB) const
Instruction * use_back ()
const Instruction * use_back () const
const BasicBlock * getParent () const
BasicBlock * getParent ()
void removeFromParent ()
void eraseFromParent ()
void insertBefore (Instruction *InsertPos)
void insertAfter (Instruction *InsertPos)
void moveBefore (Instruction *MovePos)
unsigned getOpcode () const
const char * getOpcodeName () const
bool isTerminator () const
bool isBinaryOp () const
bool isShift ()
bool isCast () const
bool isLogicalShift () const
bool isArithmeticShift () const
bool isAssociative () const
bool isCommutative () const
bool isTrapping () const

Static Public Member Functions

static const char * getOpcodeName (unsigned OpCode)
static bool isTerminator (unsigned OpCode)
static bool isBinaryOp (unsigned Opcode)
static bool isShift (unsigned Opcode)
 Determine if the Opcode is one of the shift instructions.
static bool isCast (unsigned OpCode)
 Determine if the OpCode is one of the CastInst instructions.
static bool isAssociative (unsigned op, const Type *Ty)
static bool isCommutative (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, Instruction *InsertBefore=0)
 Instruction (const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps, BasicBlock *InsertAtEnd)

Friends

class SymbolTableListTraits< Instruction, BasicBlock >


Detailed Description

Definition at line 26 of file Instruction.h.


Member Enumeration Documentation

Enumerator:
FIRST_TERM_INST 

Definition at line 194 of file Instruction.h.

Enumerator:
FIRST_BINARY_INST 

Definition at line 396 of file Instruction.h.

Enumerator:
FIRST_MEMORY_INST 

Definition at line 598 of file Instruction.h.

Enumerator:
FIRST_CAST_INST 

Definition at line 800 of file Instruction.h.

Enumerator:
FIRST_OTHER_INST 

Definition at line 1002 of file Instruction.h.


Constructor & Destructor Documentation

Instruction::Instruction ( const Type *  Ty,
unsigned  iType,
Use *  Ops,
unsigned  NumOps,
Instruction *  InsertBefore = 0 
) [protected]

Instruction::Instruction ( const Type *  Ty,
unsigned  iType,
Use *  Ops,
unsigned  NumOps,
BasicBlock *  InsertAtEnd 
) [protected]

Instruction::~Instruction (  ) 

Definition at line 48 of file Instruction.cpp.


Member Function Documentation

bool Instruction::mayWriteToMemory (  )  const

mayWriteToMemory - Return true if this instruction may modify memory.

Definition at line 307 of file Instruction.cpp.

References Call, getOpcode(), Load, llvm::SPII::Store, and VAArg.

Referenced by llvm::FindAvailableLoadedValue(), llvm::isInstructionTriviallyDead(), and TryToSinkInstruction().

bool Instruction::mayReadFromMemory (  )  const

mayReadFromMemory - Return true if this instruction may read memory.

Definition at line 289 of file Instruction.cpp.

References Call, getOpcode(), Load, llvm::SPII::Store, and VAArg.

Referenced by TryToSinkInstruction().

virtual Instruction* llvm::Instruction::clone (  )  const [pure virtual]

bool Instruction::isIdenticalTo ( const 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.

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

References llvm::Intrinsic::getAttributes(), llvm::User::getNumOperands(), getOpcode(), llvm::User::getOperand(), llvm::AttrListPtr::getRawPointer(), llvm::Value::getType(), and LI.

Referenced by HoistThenElseCodeToIf().

bool Instruction::isSameOperationAs ( const Instruction *  I  )  const

Determine if one instruction is the same operation as another.

This function determines if the specified instruction executes the same operation as the current one. This means that the opcodes, type, operand types and any other factors affecting the operation must be the same. This is similar to isIdenticalTo except the operands themselves don't have to be identical.

Returns:
true if the specified instruction is the same operation as the current one.

Definition at line 218 of file Instruction.cpp.

References llvm::Intrinsic::getAttributes(), llvm::User::getNumOperands(), getOpcode(), llvm::User::getOperand(), llvm::AttrListPtr::getRawPointer(), llvm::Value::getType(), and LI.

bool Instruction::isUsedOutsideOfBlock ( const BasicBlock *  BB  )  const

isUsedOutsideOfBlock - Return true if there are any uses of this instruction in blocks other than the specified block. Note that PHI nodes are considered to evaluate their operands in the corresponding predecessor block.

isUsedOutsideOfBlock - Return true if there are any uses of I outside of the specified block. Note that PHI nodes are considered to evaluate their operands in the corresponding predecessor block.

Definition at line 270 of file Instruction.cpp.

References llvm::dyn_cast(), E, llvm::PHINode::getIncomingBlock(), llvm::Value::use_begin(), and llvm::Value::use_end().

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

use_back - Specialize the methods defined in Value, as we know that an instruction can only be used by other instructions.

Reimplemented from llvm::Value.

Definition at line 82 of file Instruction.h.

References llvm::Value::use_begin().

Referenced by ConvertShiftToMul(), DeadPHICycle(), llvm::DemoteRegToStack(), and ShouldBreakUpSubtract().

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

Reimplemented from llvm::Value.

Definition at line 83 of file Instruction.h.

References llvm::Value::use_begin().

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

Definition at line 87 of file Instruction.h.

Referenced by BlockIsSimpleEnoughToThreadThrough(), llvm::AliasAnalysis::canInstructionRangeModify(), ChangeToCall(), ChangeToUnreachable(), llvm::CloneAndPruneFunctionInto(), llvm::DemotePHIToStack(), llvm::DemoteRegToStack(), llvm::DominatorTree::dominates(), DominatesMergePoint(), llvm::Value::DoPHITranslation(), eraseFromParent(), llvm::SelectionDAGLowering::FindMergedConditions(), llvm::findStopPoint(), FoldBranchToCommonDest(), FoldCondBranchOnPHI(), FoldTwoEntryPHINode(), FoldValueComparisonIntoPredecessors(), llvm::CallSite::getCaller(), getCommonReturnValue(), getConstantEvolvingPHI(), llvm::MemoryDependenceAnalysis::getDependency(), llvm::InlineCostAnalyzer::getInlineCost(), llvm::MemoryDependenceAnalysis::getNonLocalCallDependency(), getSCEVStartAndStride(), HandleInlinedInvoke(), HoistThenElseCodeToIf(), InBlock(), llvm::InlineFunction(), llvm::BasicInlinerImpl::inlineFunctions(), insertAfter(), insertBefore(), llvm::SCEVExpander::InsertBinop(), Instruction(), isDynamicConstant(), IsNonLocalValue(), isSafeToLoadUnconditionally(), isSafeToSinkLoad(), llvm::AllocaInst::isStaticAlloca(), llvm::Value::isUsedInBasicBlock(), isUsedOutsideOfDefiningBlock(), IVUseShouldUsePostIncValue(), LLVMGetNextInstruction(), LLVMGetPreviousInstruction(), LLVMPositionBuilderBefore(), moveBefore(), OptimizeCmpExpression(), OptimizeNoopCopyExpression(), removeFromParent(), llvm::RemoveSuccessor(), ReplaceCallWith(), llvm::ReplaceInstWithInst(), SafeToMergeTerminators(), SimplifyCondBranchToCondBranch(), SimplifyCondBranchToTwoReturns(), SimplifyEqualityComparisonWithOnlyPredecessor(), llvm::SparseSolver::Solve(), SpeculativelyExecuteBB(), llvm::SplitCriticalEdge(), SplitEdgeNicely(), TryToSinkInstruction(), llvm::UnrollLoop(), UpdateCallGraphAfterInlining(), llvm::SCEVExpander::visitAddRecExpr(), and llvm::Interpreter::visitCallSite().

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

Definition at line 88 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 63 of file Instruction.cpp.

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

void Instruction::eraseFromParent (  ) 

void Instruction::insertBefore ( Instruction *  InsertPos  ) 

insertBefore - Insert an unlinked instructions into a basic block immediately before the specified instruction.

insertBefore - Insert an unlinked instructions into a basic block immediately before the specified instruction.

Definition at line 73 of file Instruction.cpp.

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

void Instruction::insertAfter ( Instruction *  InsertPos  ) 

insertAfter - Insert an unlinked instructions into a basic block immediately after the specified instruction.

insertAfter - Insert an unlinked instructions into a basic block immediately after the specified instruction.

Definition at line 79 of file Instruction.cpp.

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

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.

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

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

Referenced by AssociativeOpt(), and TryToSinkInstruction().

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::CastInst, llvm::CmpInst, and llvm::SelectInst.

Definition at line 117 of file Instruction.h.

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

Referenced by AssociativeOpt(), llvm::CannotBeNegativeZero(), CheapToScalarize(), llvm::BitCastInst::classof(), llvm::PtrToIntInst::classof(), llvm::IntToPtrInst::classof(), llvm::FPToSIInst::classof(), llvm::FPToUIInst::classof(), llvm::SIToFPInst::classof(), llvm::UIToFPInst::classof(), llvm::FPExtInst::classof(), llvm::FPTruncInst::classof(), llvm::SExtInst::classof(), llvm::ZExtInst::classof(), llvm::TruncInst::classof(), llvm::UnreachableInst::classof(), llvm::UnwindInst::classof(), llvm::InvokeInst::classof(), llvm::SwitchInst::classof(), llvm::BranchInst::classof(), llvm::ReturnInst::classof(), llvm::PHINode::classof(), llvm::InsertValueInst::classof(), llvm::ExtractValueInst::classof(), llvm::ShuffleVectorInst::classof(), llvm::InsertElementInst::classof(), llvm::ExtractElementInst::classof(), llvm::VAArgInst::classof(), llvm::SelectInst::classof(), llvm::CallInst::classof(), llvm::VFCmpInst::classof(), llvm::VICmpInst::classof(), llvm::FCmpInst::classof(), llvm::ICmpInst::classof(), llvm::GetElementPtrInst::classof(), llvm::StoreInst::classof(), llvm::LoadInst::classof(), llvm::FreeInst::classof(), llvm::AllocaInst::classof(), llvm::MallocInst::classof(), llvm::AllocationInst::classof(), llvm::UnaryInstruction::classof(), llvm::ConstantFoldInstruction(), DominatesMergePoint(), EvaluateExpression(), llvm::SelectionDAGLowering::FindMergedConditions(), FoldOperationIntoSelectOperand(), GatherConstantSetEQs(), GatherConstantSetNEs(), GatherValueComparisons(), llvm::AliasAnalysis::getModRefInfo(), getOpcodeName(), GetSelectFoldableConstant(), GetSelectFoldableOperands(), HoistThenElseCodeToIf(), llvm::InlineFunction(), isArithmeticShift(), isAssociative(), isBinaryOp(), isCast(), isCommutative(), isIdenticalTo(), isLogicalShift(), isSameOperationAs(), isShift(), isTerminator(), isTrapping(), isUnmovableInstruction(), mayReadFromMemory(), mayWriteToMemory(), MightBeFoldableInst(), llvm::PointerMayBeCaptured(), llvm::RemoveSuccessor(), llvm::FastISel::SelectInstruction(), SpeculativelyExecuteBB(), X86FastISel::TargetSelectInstruction(), llvm::SelectionDAGLowering::visit(), llvm::Interpreter::visitAllocationInst(), and WriteInstruction().

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

Definition at line 118 of file Instruction.h.

References getOpcode().

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

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

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

Definition at line 120 of file Instruction.h.

References getOpcode().

Referenced by llvm::ConstantFoldInstOperands().

bool llvm::Instruction::isShift (  )  [inline]

Definition at line 121 of file Instruction.h.

References getOpcode().

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

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

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

Definition at line 128 of file Instruction.h.

static bool llvm::Instruction::isBinaryOp ( unsigned  Opcode  )  [inline, static]

Definition at line 132 of file Instruction.h.

static bool llvm::Instruction::isShift ( unsigned  Opcode  )  [inline, static]

Determine if the Opcode is one of the shift instructions.

Definition at line 137 of file Instruction.h.

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

isLogicalShift - Return true if this is a logical shift left or a logical shift right.

Definition at line 143 of file Instruction.h.

References getOpcode(), and llvm::LShr.

Referenced by CollectBSwapParts().

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

isLogicalShift - Return true if this is a logical shift left or a logical shift right.

Definition at line 149 of file Instruction.h.

References getOpcode().

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

Determine if the OpCode is one of the CastInst instructions.

Definition at line 154 of file Instruction.h.

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

References Add(), And(), llvm::Type::isFPOrFPVector(), llvm::APIntOps::Or(), and llvm::APIntOps::Xor().

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.

Reimplemented in llvm::ICmpInst, and llvm::FCmpInst.

Definition at line 175 of file Instruction.h.

References getOpcode().

Referenced by 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 347 of file Instruction.cpp.

References Add(), And(), llvm::APIntOps::Or(), and llvm::APIntOps::Xor().

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

isTrapping - Return true if the instruction may trap.

Definition at line 180 of file Instruction.h.

References getOpcode().

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

isTrapping - Return true if the instruction may trap.

Definition at line 362 of file Instruction.cpp.

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

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

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


Friends And Related Function Documentation

friend class SymbolTableListTraits< Instruction, BasicBlock > [friend]

Definition at line 32 of file Instruction.h.


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