10#ifndef LLVM_IR_INSTVISITOR_H
11#define LLVM_IR_INSTVISITOR_H
24#define HANDLE_INST(NUM, OPCODE, CLASS) class CLASS;
25#include "llvm/IR/Instruction.def"
27#define DELEGATE(CLASS_TO_VISIT) \
28 return static_cast<SubClass*>(this)-> \
29 visit##CLASS_TO_VISIT(static_cast<CLASS_TO_VISIT&>(I))
77template<
typename SubClass,
typename RetTy=
void>
86 template<
class Iterator>
89 static_cast<SubClass*
>(
this)->
visit(*Start++);
96 visit(M.begin(), M.end());
116 static_assert(std::is_base_of<InstVisitor, SubClass>::value,
117 "Must pass the derived type to this template!");
119 switch (
I.getOpcode()) {
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"
271 if (isa<InvokeInst>(
I) || isa<CallBrInst>(
I))
288 if (
const Function *
F =
I.getCalledFunction()) {
289 switch (
F->getIntrinsicID()) {
295 case Intrinsic::memcpy_inline:
299 case Intrinsic::memset_inline:
301 case Intrinsic::experimental_memset_pattern:
314 RetTy delegateCallInst(Instruction &
I) {
Module.h This file contains the declarations for the Module class.
#define DELEGATE(CLASS_TO_VISIT)
This class represents a conversion between pointers from one address space to another.
an instruction to allocate memory on the stack
An instruction that atomically checks whether a specified value is in a memory location,...
an instruction that atomically reads a memory location, combines it with another value,...
LLVM Basic Block Representation.
iterator begin()
Instruction iterator methods.
This class represents a no-op cast from one type to another.
Conditional or Unconditional Branch instruction.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
This class represents a function call, abstracting a target machine's calling convention.
This is the base class for all instructions that perform data casts.
This class is the base class for the comparison instructions.
This represents the llvm.dbg.declare instruction.
This is the common base class for debug info intrinsics.
This represents the llvm.dbg.label instruction.
This represents the llvm.dbg.value instruction.
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 an extension of floating point types.
This class represents a cast from floating point to signed integer.
This class represents a cast from floating point to unsigned integer.
This class represents a truncation of floating point types.
An instruction for ordering other memory operations.
This class represents a freeze function that returns random concrete value if an operand is either a ...
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
This instruction compares its operands according to the predicate given to the constructor.
Indirect Branch Instruction.
This instruction inserts a single (scalar) element into a VectorType value.
This instruction inserts a struct field of array element value into an aggregate value.
Base class for instruction visitors.
RetTy visitCallBrInst(CallBrInst &I)
RetTy visitIndirectBrInst(IndirectBrInst &I)
RetTy visitFreezeInst(FreezeInst &I)
RetTy visitPtrToIntInst(PtrToIntInst &I)
RetTy visitCmpInst(CmpInst &I)
RetTy visitMemIntrinsic(MemIntrinsic &I)
RetTy visitInvokeInst(InvokeInst &I)
RetTy visitFPToSIInst(FPToSIInst &I)
RetTy visitVACopyInst(VACopyInst &I)
RetTy visitFCmpInst(FCmpInst &I)
RetTy visitDbgInfoIntrinsic(DbgInfoIntrinsic &I)
RetTy visitTerminator(Instruction &I)
RetTy visitExtractElementInst(ExtractElementInst &I)
RetTy visitVAStartInst(VAStartInst &I)
RetTy visitMemCpyInst(MemCpyInst &I)
RetTy visitCallBase(CallBase &I)
RetTy visitTruncInst(TruncInst &I)
void visitFunction(Function &F)
RetTy visitCleanupReturnInst(CleanupReturnInst &I)
RetTy visitInsertValueInst(InsertValueInst &I)
RetTy visit(Instruction &I)
RetTy visitCatchPadInst(CatchPadInst &I)
RetTy visitIntrinsicInst(IntrinsicInst &I)
RetTy visitShuffleVectorInst(ShuffleVectorInst &I)
RetTy visitLandingPadInst(LandingPadInst &I)
void visitBasicBlock(BasicBlock &BB)
RetTy visitUnreachableInst(UnreachableInst &I)
RetTy visitAtomicCmpXchgInst(AtomicCmpXchgInst &I)
RetTy visitIntToPtrInst(IntToPtrInst &I)
RetTy visitSExtInst(SExtInst &I)
RetTy visitBitCastInst(BitCastInst &I)
RetTy visitSwitchInst(SwitchInst &I)
RetTy visitCleanupPadInst(CleanupPadInst &I)
void visit(Iterator Start, Iterator End)
RetTy visit(Instruction *I)
RetTy visitPHINode(PHINode &I)
RetTy visitReturnInst(ReturnInst &I)
RetTy visitExtractValueInst(ExtractValueInst &I)
RetTy visitVAEndInst(VAEndInst &I)
RetTy visitFPToUIInst(FPToUIInst &I)
RetTy visitUnaryOperator(UnaryOperator &I)
RetTy visitDbgLabelInst(DbgLabelInst &I)
RetTy visitStoreInst(StoreInst &I)
RetTy visitMemCpyInlineInst(MemCpyInlineInst &I)
RetTy visitFuncletPadInst(FuncletPadInst &I)
RetTy visitInsertElementInst(InsertElementInst &I)
void visit(BasicBlock *BB)
RetTy visitMemMoveInst(MemMoveInst &I)
RetTy visitAtomicRMWInst(AtomicRMWInst &I)
void visit(BasicBlock &BB)
RetTy visitDbgValueInst(DbgValueInst &I)
RetTy visitUnaryInstruction(UnaryInstruction &I)
RetTy visitAddrSpaceCastInst(AddrSpaceCastInst &I)
RetTy visitFPTruncInst(FPTruncInst &I)
RetTy visitAllocaInst(AllocaInst &I)
RetTy visitBinaryOperator(BinaryOperator &I)
RetTy visitMemSetInlineInst(MemSetInlineInst &I)
RetTy visitSIToFPInst(SIToFPInst &I)
RetTy visitResumeInst(ResumeInst &I)
RetTy visitFPExtInst(FPExtInst &I)
RetTy visitICmpInst(ICmpInst &I)
RetTy visitCatchReturnInst(CatchReturnInst &I)
RetTy visitMemSetPatternInst(MemSetPatternInst &I)
RetTy visitMemTransferInst(MemTransferInst &I)
RetTy visitMemSetInst(MemSetInst &I)
RetTy visitCallInst(CallInst &I)
void visitModule(Module &M)
RetTy visitCatchSwitchInst(CatchSwitchInst &I)
RetTy visitCastInst(CastInst &I)
RetTy visitDbgVariableIntrinsic(DbgVariableIntrinsic &I)
RetTy visitDbgDeclareInst(DbgDeclareInst &I)
RetTy visitBranchInst(BranchInst &I)
RetTy visitSelectInst(SelectInst &I)
RetTy visitGetElementPtrInst(GetElementPtrInst &I)
RetTy visitUIToFPInst(UIToFPInst &I)
RetTy visitFenceInst(FenceInst &I)
void visitInstruction(Instruction &I)
RetTy visitLoadInst(LoadInst &I)
RetTy visitVAArgInst(VAArgInst &I)
RetTy visitZExtInst(ZExtInst &I)
This class represents a cast from an integer to a pointer.
A wrapper class for inspecting calls to intrinsic functions.
The landingpad instruction holds all of the information necessary to generate correct exception handl...
An instruction for reading from memory.
This class wraps the llvm.memcpy.inline intrinsic.
This class wraps the llvm.memcpy intrinsic.
This is the common base class for memset/memcpy/memmove.
This class wraps the llvm.memmove intrinsic.
This class wraps the llvm.memset.inline intrinsic.
This class wraps the llvm.memset and llvm.memset.inline intrinsics.
This class wraps the llvm.experimental.memset.pattern intrinsic.
This class wraps the llvm.memcpy/memmove intrinsics.
A Module instance is used to store all the information related to an LLVM module.
This class represents a cast from a pointer to an integer.
Resume the propagation of an exception.
Return a value (possibly void), from a function.
This class represents a sign extension of integer types.
This class represents a cast from signed integer to floating point.
This class represents the LLVM 'select' instruction.
This instruction constructs a fixed permutation of two input vectors.
An instruction for storing to memory.
This class represents a truncation of integer types.
This class represents a cast unsigned integer to floating point.
This function has undefined behavior.
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
This represents the llvm.va_copy intrinsic.
This represents the llvm.va_end intrinsic.
This represents the llvm.va_start intrinsic.
This class represents zero extension of integer types.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.