11 #ifndef LLVM_IR_INSTVISITOR_H
12 #define LLVM_IR_INSTVISITOR_H
27 #define HANDLE_INST(NUM, OPCODE, CLASS) class CLASS;
28 #include "llvm/IR/Instruction.def"
30 #define DELEGATE(CLASS_TO_VISIT) \
31 return static_cast<SubClass*>(this)-> \
32 visit##CLASS_TO_VISIT(static_cast<CLASS_TO_VISIT&>(I))
80 template<
typename SubClass,
typename RetTy=
void>
89 template<
class Iterator>
90 void visit(Iterator Start, Iterator End) {
92 static_cast<SubClass*
>(
this)->
visit(*Start++);
122 #define HANDLE_INST(NUM, OPCODE, CLASS) \
123 case Instruction::OPCODE: return \
124 static_cast<SubClass*>(this)-> \
125 visit##OPCODE(static_cast<CLASS&>(I));
126 #include "llvm/IR/Instruction.def"
154 #define HANDLE_INST(NUM, OPCODE, CLASS) \
155 RetTy visit##OPCODE(CLASS &I) { \
156 if (NUM == Instruction::Call) \
157 return delegateCallInst(I); \
161 #include "llvm/IR/Instruction.def"
262 switch (
F->getIntrinsicID()) {
280 RetTy delegateCallInst(Instruction &I) {
RetTy visitSelectInst(SelectInst &I)
RetTy visitAtomicRMWInst(AtomicRMWInst &I)
ReturnInst - Return a value (possibly void), from a function.
RetTy visitVAStartInst(VAStartInst &I)
RetTy visitMemSetInst(MemSetInst &I)
This class is the base class for the comparison instructions.
RetTy visitCallSite(CallSite CS)
Base class for instruction visitors.
RetTy visitDbgDeclareInst(DbgDeclareInst &I)
RetTy visitDbgInfoIntrinsic(DbgInfoIntrinsic &I)
RetTy visitFPExtInst(FPExtInst &I)
VAEndInst - This represents the llvm.va_end intrinsic.
A Module instance is used to store all the information related to an LLVM module. ...
FenceInst - an instruction for ordering other memory operations.
InstrTy * getInstruction() const
AtomicCmpXchgInst - an instruction that atomically checks whether a specified value is in a memory lo...
RetTy visitCmpInst(CmpInst &I)
RetTy visitFCmpInst(FCmpInst &I)
This class represents zero extension of integer types.
RetTy visitCastInst(CastInst &I)
CallInst - This class represents a function call, abstracting a target machine's calling convention...
RetTy visitBranchInst(BranchInst &I)
RetTy visitLandingPadInst(LandingPadInst &I)
ShuffleVectorInst - This instruction constructs a fixed permutation of two input vectors.
MemSetInst - This class wraps the llvm.memset intrinsic.
void visit(BasicBlock *BB)
This class represents a sign extension of integer types.
LoadInst - an instruction for reading from memory.
RetTy visitPHINode(PHINode &I)
AtomicRMWInst - an instruction that atomically reads a memory location, combines it with another valu...
RetTy visitICmpInst(ICmpInst &I)
RetTy visitExtractElementInst(ExtractElementInst &I)
RetTy visitVACopyInst(VACopyInst &I)
iterator begin()
Instruction iterator methods.
RetTy visitSExtInst(SExtInst &I)
void visitFunction(Function &F)
This class represents a conversion between pointers from one address space to another.
RetTy visitMemCpyInst(MemCpyInst &I)
SelectInst - This class represents the LLVM 'select' instruction.
RetTy visitIntrinsicInst(IntrinsicInst &I)
This is the base class for all instructions that perform data casts.
MemMoveInst - This class wraps the llvm.memmove intrinsic.
RetTy visitUIToFPInst(UIToFPInst &I)
RetTy visitMemMoveInst(MemMoveInst &I)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
RetTy visitFPToUIInst(FPToUIInst &I)
RetTy visitInsertValueInst(InsertValueInst &I)
This class represents a cast from a pointer to an integer.
void visit(Iterator Start, Iterator End)
VAStartInst - This represents the llvm.va_start intrinsic.
This instruction compares its operands according to the predicate given to the constructor.
This class represents a no-op cast from one type to another.
StoreInst - an instruction for storing to memory.
This class represents a cast from floating point to signed integer.
RetTy visitMemTransferInst(MemTransferInst &I)
RetTy visitExtractValueInst(ExtractValueInst &I)
This class represents a truncation of integer types.
RetTy visitVAEndInst(VAEndInst &I)
GetElementPtrInst - an instruction for type-safe pointer arithmetic to access elements of arrays and ...
InsertElementInst - This instruction inserts a single (scalar) element into a VectorType value...
LandingPadInst - The landingpad instruction holds all of the information necessary to generate correc...
Subclasses of this class are all able to terminate a basic block.
void visitBasicBlock(BasicBlock &BB)
RetTy visitVAArgInst(VAArgInst &I)
LLVM Basic Block Representation.
RetTy visitIntToPtrInst(IntToPtrInst &I)
BranchInst - Conditional or Unconditional Branch instruction.
UnreachableInst - This function has undefined behavior.
RetTy visitResumeInst(ResumeInst &I)
ResumeInst - Resume the propagation of an exception.
IndirectBrInst - Indirect Branch Instruction.
RetTy visitTerminatorInst(TerminatorInst &I)
This instruction compares its operands according to the predicate given to the constructor.
RetTy visitSwitchInst(SwitchInst &I)
RetTy visitFPTruncInst(FPTruncInst &I)
RetTy visitLoadInst(LoadInst &I)
This class represents a cast from an integer to a pointer.
RetTy visitDbgValueInst(DbgValueInst &I)
RetTy visitZExtInst(ZExtInst &I)
VAArgInst - This class represents the va_arg llvm instruction, which returns an argument of the speci...
RetTy visitReturnInst(ReturnInst &I)
RetTy visitSIToFPInst(SIToFPInst &I)
RetTy visitInvokeInst(InvokeInst &I)
RetTy visitBinaryOperator(BinaryOperator &I)
MemIntrinsic - This is the common base class for memset/memcpy/memmove.
RetTy visitShuffleVectorInst(ShuffleVectorInst &I)
RetTy visitIndirectBrInst(IndirectBrInst &I)
RetTy visitAtomicCmpXchgInst(AtomicCmpXchgInst &I)
Module.h This file contains the declarations for the Module class.
RetTy visitFPToSIInst(FPToSIInst &I)
DbgInfoIntrinsic - This is the common base class for debug info intrinsics.
This class represents a cast from floating point to unsigned integer.
MemCpyInst - This class wraps the llvm.memcpy intrinsic.
Function * getCalledFunction() const
getCalledFunction - Return the function called, or null if this is an indirect function invocation...
RetTy visitFenceInst(FenceInst &I)
RetTy visitStoreInst(StoreInst &I)
RetTy visitCallInst(CallInst &I)
MemTransferInst - This class wraps the llvm.memcpy/memmove intrinsics.
void visitModule(Module &M)
RetTy visitPtrToIntInst(PtrToIntInst &I)
DbgValueInst - This represents the llvm.dbg.value instruction.
This class represents a cast unsigned integer to floating point.
RetTy visitGetElementPtrInst(GetElementPtrInst &I)
RetTy visitBitCastInst(BitCastInst &I)
RetTy visitAddrSpaceCastInst(AddrSpaceCastInst &I)
RetTy visitAllocaInst(AllocaInst &I)
RetTy visitMemIntrinsic(MemIntrinsic &I)
SwitchInst - Multiway switch.
void visit(BasicBlock &BB)
This class represents a cast from signed integer to floating point.
VACopyInst - This represents the llvm.va_copy intrinsic.
RetTy visit(Instruction &I)
RetTy visitUnreachableInst(UnreachableInst &I)
This class represents a truncation of floating point types.
unsigned getOpcode() const
getOpcode() returns a member of one of the enums like Instruction::Add.
InvokeInst - Invoke instruction.
#define DELEGATE(CLASS_TO_VISIT)
RetTy visitInsertElementInst(InsertElementInst &I)
RetTy visit(Instruction *I)
bool isInvoke() const
isInvoke - true if a InvokeInst is enclosed.
void visitInstruction(Instruction &I)
This class represents an extension of floating point types.
bool isCall() const
isCall - true if a CallInst is enclosed.
DbgDeclareInst - This represents the llvm.dbg.declare instruction.
RetTy visitUnaryInstruction(UnaryInstruction &I)
IntrinsicInst - A useful wrapper class for inspecting calls to intrinsic functions.
AllocaInst - an instruction to allocate memory on the stack.
InsertValueInst - This instruction inserts a struct field of array element value into an aggregate va...
RetTy visitTruncInst(TruncInst &I)