LLVM API Documentation

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

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, VANext,
  HANDLE_OTHER_INST, VAArg, HANDLE_OTHER_INST, Select,
  HANDLE_OTHER_INST, UserOp1, Instruction
}
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, VANext,
  HANDLE_OTHER_INST, VAArg, HANDLE_OTHER_INST, Select,
  HANDLE_OTHER_INST, UserOp1, Instruction
}
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, VANext,
  HANDLE_OTHER_INST, VAArg, HANDLE_OTHER_INST, Select,
  HANDLE_OTHER_INST, UserOp1, Instruction
}
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, VANext,
  HANDLE_OTHER_INST, VAArg, HANDLE_OTHER_INST, Select,
  HANDLE_OTHER_INST, UserOp1, Instruction
}

Public Member Functions

 ~Instruction ()
virtual void setName (const std::string &name, SymbolTable *ST=0)
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 ()
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 *I)
 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, const std::string &Name="", Instruction *InsertBefore=0)
 Instruction (const Type *Ty, unsigned iType, 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 
VANext 
HANDLE_OTHER_INST 
VAArg 
HANDLE_OTHER_INST 
Select 
HANDLE_OTHER_INST 
UserOp1 
Instruction 

Definition at line 329 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 
VANext 
HANDLE_OTHER_INST 
VAArg 
HANDLE_OTHER_INST 
Select 
HANDLE_OTHER_INST 
UserOp1 
Instruction 

Definition at line 492 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 
VANext 
HANDLE_OTHER_INST 
VAArg 
HANDLE_OTHER_INST 
Select 
HANDLE_OTHER_INST 
UserOp1 
Instruction 

Definition at line 655 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 
VANext 
HANDLE_OTHER_INST 
VAArg 
HANDLE_OTHER_INST 
Select 
HANDLE_OTHER_INST 
UserOp1 
Instruction 

Definition at line 166 of file Instruction.h.


Constructor & Destructor Documentation

Instruction::Instruction const Type Ty,
unsigned  iType,
const std::string &  Name = "",
Instruction InsertBefore = 0
[protected]
 

Definition at line 26 of file Instruction.cpp.

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

Instruction::Instruction const Type Ty,
unsigned  iType,
const std::string &  Name,
BasicBlock InsertAtEnd
[protected]
 

Definition at line 39 of file Instruction.cpp.

References llvm::BasicBlock::getInstList(), and llvm::cl::init().

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

Definition at line 53 of file Instruction.h.

References Parent.


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::VANextInst, llvm::VAArgInst, llvm::PHINode, llvm::ReturnInst, llvm::BranchInst, llvm::SwitchInst, llvm::InvokeInst, llvm::UnwindInst, llvm::UnreachableInst, llvm::DbgInfoIntrinsic, llvm::DbgStopPointInst, llvm::MemIntrinsic, llvm::MemCpyInst, llvm::MemMoveInst, llvm::MemSetInst, llvm::TmpInstruction, and llvm::ValueHandle.

Definition at line 159 of file Instruction.h.

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

static bool llvm::Instruction::classof const Instruction I  )  [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::VANextInst, llvm::VAArgInst, llvm::PHINode, llvm::ReturnInst, llvm::BranchInst, llvm::SwitchInst, llvm::InvokeInst, llvm::UnwindInst, llvm::UnreachableInst, llvm::TmpInstruction, and llvm::ValueHandle.

Definition at line 158 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::VANextInst, llvm::VAArgInst, 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 79 of file Instruction.cpp.

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

Referenced by HoistThenElseCodeToIf(), OptimizeAwayTrappingUsesOfLoads(), and OptimizeGlobalAddressOfMalloc().

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(), llvm::SimplifyCFG(), and Cilkifier::visitCallInst().

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

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

Referenced by AddressMightEscape(), llvm::CallSite::arg_begin(), AssociativeOpt(), llvm::ChooseInstructionsForDelaySlots(), llvm::ClassifyExpr(), 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::VAArgInst::classof(), llvm::VANextInst::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(), llvm::ConvertExpressionToType(), ConvertOperandToType(), DominatesMergePoint(), llvm::ExpressionConvertibleToType(), FoldOperationIntoSelectOperand(), GatherValueComparisons(), llvm::CallSite::get(), llvm::AliasAnalysis::getModRefInfo(), llvm::SelectInst::getOpcode(), llvm::ShiftInst::getOpcode(), getOpcodeName(), GetSelectFoldableConstant(), GetSelectFoldableOperands(), HoistThenElseCodeToIf(), IdenticalComplexInst(), llvm::InlineFunction(), InsertPHINodesForUsesOutsideLoop(), llvm::InstructionNode::InstructionNode(), isAssociative(), isBinaryOp(), isCommutative(), isIdenticalBinaryInst(), isIdenticalTo(), isInsertShiftHalf(), isOnlyUsedByUnorderedComparisons(), isRelational(), isSafeInstruction(), isTerminator(), isTrapping(), isTrueWhenEqual(), OperandConvertibleToType(), llvm::RemoveSuccessor(), ShouldTraceValue(), llvm::SimplifyCFG(), and llvm::Interpreter::visitAllocationInst().

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

Definition at line 83 of file Instruction.cpp.

References Add(), Alloca, llvm::ISD::And, llvm::ISD::Br, Call, Cast, Load, Malloc, Mul(), llvm::ISD::Or, PHI, llvm::ISD::Ret, Select, llvm::ISD::SetEQ, llvm::ISD::SetGE, llvm::ISD::SetGT, llvm::ISD::SetLE, llvm::ISD::SetLT, llvm::ISD::SetNE, Shl, llvm::ISD::Store, llvm::ISD::Switch, VAArg, VANext, and llvm::ISD::Xor.

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

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

Definition at line 104 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.

References Parent.

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

Definition at line 79 of file Instruction.h.

References Parent.

Referenced by AssociativeOpt(), llvm::AliasAnalysis::canInstructionRangeModify(), llvm::ConvertExpressionToType(), ConvertMallocToType(), ConvertOperandToType(), llvm::DecomposeArrayRef(), llvm::DemoteRegToStack(), llvm::MachineCodeForInstruction::destroy(), llvm::DominatorSetBase::dominates(), DominatesMergePoint(), dyn_castFixedAlloca(), eraseFromParent(), ErasePossiblyDeadInstructionTree(), FindPHIToPartitionLoops(), FoldValueComparisonIntoPredecessors(), llvm::MachineCodeForInstruction::get(), llvm::DSCallSite::getCaller(), llvm::CallSite::getCaller(), getCommonReturnValue(), getConstantEvolvingPHI(), HandleCastToPointer(), HoistThenElseCodeToIf(), IdenticalComplexInst(), InlineCallIfPossible(), llvm::InlineFunction(), Instruction(), isDynamicConstant(), isIdenticalBinaryInst(), isSafeToFoldLoadIntoInstruction(), isSafeToLoadUnconditionally(), LiveAtBBExit(), llvm::DefaultIntrinsicLowering::LowerIntrinsicCall(), print(), RecursiveDelete(), removeFromParent(), llvm::PHINode::removeIncomingValue(), llvm::RemoveSuccessor(), ReplaceCallWith(), llvm::ReplaceInstWithInst(), llvm::Inliner::runOnSCC(), llvm::RunVMAsmParser(), SafeToMergeTerminators(), setName(), llvm::SimplifyCFG(), llvm::SplitCriticalEdge(), and llvm::Interpreter::visitCallSite().

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

Definition at line 87 of file Instruction.h.

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

Definition at line 86 of file Instruction.h.

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

References Add(), llvm::ISD::And, llvm::Type::isFloatingPoint(), Mul(), llvm::ISD::Or, and llvm::ISD::Xor.

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

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

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

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

References Add(), llvm::ISD::And, Mul(), llvm::ISD::Or, llvm::ISD::SetEQ, llvm::ISD::SetNE, and llvm::ISD::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.

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

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

Referenced by HoistThenElseCodeToIf().

bool Instruction::isRelational unsigned  op  )  [static]
 

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

Definition at line 203 of file Instruction.cpp.

References llvm::ISD::SetEQ, llvm::ISD::SetGE, llvm::ISD::SetGT, llvm::ISD::SetLE, llvm::ISD::SetLT, and llvm::ISD::SetNE.

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

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

Definition at line 143 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 113 of file Instruction.h.

References getOpcode().

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

Definition at line 109 of file Instruction.h.

bool Instruction::isTrapping unsigned  op  )  [static]
 

isTrappingInstruction - Return true if the instruction may trap.

Definition at line 220 of file Instruction.cpp.

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

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

isTrappingInstruction - Return true if the instruction may trap.

Definition at line 149 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, and llvm::InvokeInst.

Definition at line 62 of file Instruction.h.

Referenced by llvm::isInstructionTriviallyDead().

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

Definition at line 1214 of file AsmWriter.cpp.

References llvm::GlobalValue::getParent(), llvm::BasicBlock::getParent(), getParent(), and llvm::AssemblyWriter::write().

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

print - Implement operator<< on Value...

Implements llvm::Value.

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

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

void Instruction::setName const std::string &  name,
SymbolTable ST = 0
[virtual]
 

Reimplemented from llvm::Value.

Definition at line 64 of file Instruction.cpp.

References llvm::BasicBlock::getParent(), getParent(), llvm::Function::getSymbolTable(), llvm::Value::hasName(), llvm::SymbolTable::insert(), llvm::SymbolTable::remove(), and llvm::Value::setName().

Referenced by llvm::CloneBasicBlock(), llvm::ConvertExpressionToType(), ConvertOperandToType(), HoistThenElseCodeToIf(), ReplaceCallWith(), and llvm::SimplifyCFG().


Friends And Related Function Documentation

friend class BinaryOperator [friend]
 

Definition at line 45 of file Instruction.h.

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

Definition at line 37 of file Instruction.h.


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