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++);
119 static_assert(std::is_base_of<InstVisitor, SubClass>::value,
120 "Must pass the derived type to this template!");
125 #define HANDLE_INST(NUM, OPCODE, CLASS) \ 126 case Instruction::OPCODE: return \ 127 static_cast<SubClass*>(this)-> \ 128 visit##OPCODE(static_cast<CLASS&>(I)); 129 #include "llvm/IR/Instruction.def" 157 #define HANDLE_INST(NUM, OPCODE, CLASS) \ 158 RetTy visit##OPCODE(CLASS &I) { \ 159 if (NUM == Instruction::Call) \ 160 return delegateCallInst(I); \ 164 #include "llvm/IR/Instruction.def" 274 if (isa<InvokeInst>(I))
302 switch (
F->getIntrinsicID()) {
RetTy visitSelectInst(SelectInst &I)
RetTy visitAtomicRMWInst(AtomicRMWInst &I)
Return a value (possibly void), from a function.
RetTy visitUnaryOperator(UnaryOperator &I)
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.
This represents the llvm.dbg.label instruction.
This class represents lattice values for constants.
RetTy visitDbgDeclareInst(DbgDeclareInst &I)
RetTy visitDbgInfoIntrinsic(DbgInfoIntrinsic &I)
RetTy visitFPExtInst(FPExtInst &I)
This represents the llvm.va_end intrinsic.
A Module instance is used to store all the information related to an LLVM module. ...
An instruction for ordering other memory operations.
an instruction that atomically checks whether a specified value is in a memory location, and, if it is, stores a new value there.
RetTy visitCmpInst(CmpInst &I)
RetTy visitTerminator(Instruction &I)
RetTy visitFCmpInst(FCmpInst &I)
This class represents zero extension of integer types.
RetTy visitCastInst(CastInst &I)
This class represents a function call, abstracting a target machine's calling convention.
RetTy visitBranchInst(BranchInst &I)
RetTy visitLandingPadInst(LandingPadInst &I)
This instruction constructs a fixed permutation of two input vectors.
This class wraps the llvm.memset intrinsic.
void visit(BasicBlock *BB)
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
This class represents a sign extension of integer types.
An instruction for reading from memory.
RetTy visitDbgVariableIntrinsic(DbgVariableIntrinsic &I)
RetTy visitPHINode(PHINode &I)
an instruction that atomically reads a memory location, combines it with another value, and then stores the result back.
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)
This class represents the LLVM 'select' instruction.
RetTy visitIntrinsicInst(IntrinsicInst &I)
This is the base class for all instructions that perform data casts.
This class wraps the llvm.memmove intrinsic.
RetTy visitUIToFPInst(UIToFPInst &I)
RetTy visitMemMoveInst(MemMoveInst &I)
InstrTy * getInstruction() const
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)
This represents the llvm.va_start intrinsic.
This is the common base class for debug info intrinsics for variables.
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.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
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)
an instruction for type-safe pointer arithmetic to access elements of arrays and structs ...
RetTy visitFuncletPadInst(FuncletPadInst &I)
This instruction inserts a single (scalar) element into a VectorType value.
The landingpad instruction holds all of the information necessary to generate correct exception handl...
void visitBasicBlock(BasicBlock &BB)
RetTy visitVAArgInst(VAArgInst &I)
RetTy visitCallBase(CallBase &I)
LLVM Basic Block Representation.
RetTy visitIntToPtrInst(IntToPtrInst &I)
Conditional or Unconditional Branch instruction.
This function has undefined behavior.
RetTy visitResumeInst(ResumeInst &I)
Resume the propagation of an exception.
Indirect Branch Instruction.
RetTy visitCatchReturnInst(CatchReturnInst &I)
This instruction compares its operands according to the predicate given to the constructor.
RetTy visitDbgLabelInst(DbgLabelInst &I)
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)
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
RetTy visitReturnInst(ReturnInst &I)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
RetTy visitSIToFPInst(SIToFPInst &I)
RetTy visitInvokeInst(InvokeInst &I)
RetTy visitBinaryOperator(BinaryOperator &I)
This is the common base class for memset/memcpy/memmove.
RetTy visitShuffleVectorInst(ShuffleVectorInst &I)
RetTy visitIndirectBrInst(IndirectBrInst &I)
RetTy visitCatchSwitchInst(CatchSwitchInst &I)
RetTy visitAtomicCmpXchgInst(AtomicCmpXchgInst &I)
Module.h This file contains the declarations for the Module class.
RetTy visitFPToSIInst(FPToSIInst &I)
RetTy visitCatchPadInst(CatchPadInst &I)
This is the common base class for debug info intrinsics.
This class represents a cast from floating point to unsigned integer.
This class wraps the llvm.memcpy intrinsic.
RetTy visitCleanupPadInst(CleanupPadInst &I)
RetTy visitFenceInst(FenceInst &I)
RetTy visitStoreInst(StoreInst &I)
RetTy visitCallInst(CallInst &I)
This class wraps the llvm.memcpy/memmove intrinsics.
void visitModule(Module &M)
RetTy visitPtrToIntInst(PtrToIntInst &I)
This represents the llvm.dbg.value instruction.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation.
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)
void visit(BasicBlock &BB)
This class represents a cast from signed integer to floating point.
This represents the llvm.va_copy intrinsic.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
RetTy visit(Instruction &I)
RetTy visitUnreachableInst(UnreachableInst &I)
This class represents a truncation of floating point types.
#define DELEGATE(CLASS_TO_VISIT)
RetTy visitInsertElementInst(InsertElementInst &I)
RetTy visit(Instruction *I)
void visitInstruction(Instruction &I)
This class represents an extension of floating point types.
This represents the llvm.dbg.declare instruction.
RetTy visitCleanupReturnInst(CleanupReturnInst &I)
RetTy visitUnaryInstruction(UnaryInstruction &I)
A wrapper class for inspecting calls to intrinsic functions.
an instruction to allocate memory on the stack
This instruction inserts a struct field of array element value into an aggregate value.
RetTy visitTruncInst(TruncInst &I)