Go to the documentation of this file.
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))
77 template<
typename SubClass,
typename RetTy=
void>
86 template<
class Iterator>
87 void visit(Iterator Start, Iterator End) {
89 static_cast<SubClass*
>(
this)->
visit(*Start++);
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"
269 if (isa<InvokeInst>(
I) || isa<CallBrInst>(
I))
286 if (
const Function *
F =
I.getCalledFunction()) {
287 switch (
F->getIntrinsicID()) {
306 RetTy delegateCallInst(Instruction &
I) {
void visitInstruction(Instruction &I)
RetTy visitCastInst(CastInst &I)
RetTy visitPtrToIntInst(PtrToIntInst &I)
RetTy visitBranchInst(BranchInst &I)
This is an optimization pass for GlobalISel generic memory operations.
RetTy visitCleanupPadInst(CleanupPadInst &I)
RetTy visitDbgLabelInst(DbgLabelInst &I)
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
RetTy visitInsertValueInst(InsertValueInst &I)
Return a value (possibly void), from a function.
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
RetTy visitVAStartInst(VAStartInst &I)
RetTy visitDbgValueInst(DbgValueInst &I)
This class wraps the llvm.memcpy/memmove intrinsics.
RetTy visitDbgVariableIntrinsic(DbgVariableIntrinsic &I)
RetTy visitTruncInst(TruncInst &I)
This class wraps the llvm.memmove intrinsic.
This class represents a no-op cast from one type to another.
The landingpad instruction holds all of the information necessary to generate correct exception handl...
RetTy visitCatchSwitchInst(CatchSwitchInst &I)
RetTy visitVACopyInst(VACopyInst &I)
RetTy visitIntrinsicInst(IntrinsicInst &I)
RetTy visitUnaryOperator(UnaryOperator &I)
RetTy visitCallBase(CallBase &I)
RetTy visitFuncletPadInst(FuncletPadInst &I)
RetTy visitVAArgInst(VAArgInst &I)
RetTy visitBitCastInst(BitCastInst &I)
RetTy visitTerminator(Instruction &I)
This is the common base class for memset/memcpy/memmove.
RetTy visitDbgDeclareInst(DbgDeclareInst &I)
An instruction for ordering other memory operations.
RetTy visitLandingPadInst(LandingPadInst &I)
RetTy visitFPTruncInst(FPTruncInst &I)
RetTy visitInsertElementInst(InsertElementInst &I)
LLVM Basic Block Representation.
This represents the llvm.va_start intrinsic.
RetTy visitZExtInst(ZExtInst &I)
RetTy visitShuffleVectorInst(ShuffleVectorInst &I)
This class represents a conversion between pointers from one address space to another.
RetTy visitMemCpyInst(MemCpyInst &I)
This represents the llvm.dbg.value instruction.
RetTy visitICmpInst(ICmpInst &I)
RetTy visitMemIntrinsic(MemIntrinsic &I)
RetTy visitCatchPadInst(CatchPadInst &I)
RetTy visitIndirectBrInst(IndirectBrInst &I)
This instruction compares its operands according to the predicate given to the constructor.
RetTy visitGetElementPtrInst(GetElementPtrInst &I)
This class wraps the llvm.memcpy.inline intrinsic.
RetTy visitAtomicCmpXchgInst(AtomicCmpXchgInst &I)
This instruction inserts a single (scalar) element into a VectorType value.
RetTy visitFPToSIInst(FPToSIInst &I)
RetTy visitLoadInst(LoadInst &I)
RetTy visitFPExtInst(FPExtInst &I)
RetTy visitPHINode(PHINode &I)
This is the common base class for debug info intrinsics.
This class wraps the llvm.memset and llvm.memset.inline intrinsics.
This class is the base class for the comparison instructions.
RetTy visitCleanupReturnInst(CleanupReturnInst &I)
RetTy visitUnaryInstruction(UnaryInstruction &I)
This is the common base class for debug info intrinsics for variables.
RetTy visitSelectInst(SelectInst &I)
An instruction for storing to memory.
This instruction compares its operands according to the predicate given to the constructor.
RetTy visitSExtInst(SExtInst &I)
This class represents a cast from floating point to signed integer.
This represents the llvm.dbg.declare instruction.
This represents the llvm.dbg.label instruction.
This class represents a truncation of integer types.
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
RetTy visitFreezeInst(FreezeInst &I)
void visit(Iterator Start, Iterator End)
RetTy visitUIToFPInst(UIToFPInst &I)
RetTy visitFPToUIInst(FPToUIInst &I)
void visit(BasicBlock &BB)
<%struct.s * > cast struct s *S to sbyte *< sbyte * > sbyte uint cast struct s *agg result to sbyte *< sbyte * > sbyte uint cast struct s *memtmp to sbyte *< sbyte * > sbyte uint ret void llc ends up issuing two memcpy or custom lower memcpy(of small size) to be ldmia/stmia. I think option 2 is better but the current register allocator cannot allocate a chunk of registers at a time. A feasible temporary solution is to use specific physical registers at the lowering time for small(<
RetTy visitMemCpyInlineInst(MemCpyInlineInst &I)
RetTy visitAddrSpaceCastInst(AddrSpaceCastInst &I)
RetTy visitFenceInst(FenceInst &I)
This class represents the LLVM 'select' instruction.
This class represents a cast from floating point to unsigned integer.
A Module instance is used to store all the information related to an LLVM module.
RetTy visitFCmpInst(FCmpInst &I)
RetTy visitStoreInst(StoreInst &I)
This class represents zero extension of integer types.
void visitModule(Module &M)
RetTy visitReturnInst(ReturnInst &I)
This represents the llvm.va_end intrinsic.
RetTy visitAtomicRMWInst(AtomicRMWInst &I)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This class represents a cast from a pointer to an integer.
Base class for instruction visitors.
This class represents an extension of floating point types.
This is the base class for all instructions that perform data casts.
void visit(BasicBlock *BB)
This class represents a sign extension of integer types.
An instruction for reading from memory.
RetTy visitAllocaInst(AllocaInst &I)
an instruction that atomically reads a memory location, combines it with another value,...
RetTy visitBinaryOperator(BinaryOperator &I)
void visitFunction(Function &F)
Resume the propagation of an exception.
RetTy visitInvokeInst(InvokeInst &I)
void visitBasicBlock(BasicBlock &BB)
#define DELEGATE(CLASS_TO_VISIT)
RetTy visitMemSetInst(MemSetInst &I)
This represents the llvm.va_copy intrinsic.
RetTy visitResumeInst(ResumeInst &I)
RetTy visitCallBrInst(CallBrInst &I)
RetTy visitUnreachableInst(UnreachableInst &I)
This class represents a cast unsigned integer to floating point.
This class represents a cast from an integer to a pointer.
Indirect Branch Instruction.
A wrapper class for inspecting calls to intrinsic functions.
RetTy visit(Instruction *I)
RetTy visitCmpInst(CmpInst &I)
This instruction constructs a fixed permutation of two input vectors.
This class wraps the llvm.memcpy intrinsic.
This class represents a cast from signed integer to floating point.
This class represents a freeze function that returns random concrete value if an operand is either a ...
This class represents a truncation of floating point types.
RetTy visitCallInst(CallInst &I)
RetTy visitSwitchInst(SwitchInst &I)
RetTy visitExtractValueInst(ExtractValueInst &I)
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
This class represents a function call, abstracting a target machine's calling convention.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
This function has undefined behavior.
RetTy visitMemTransferInst(MemTransferInst &I)
an instruction to allocate memory on the stack
RetTy visitDbgInfoIntrinsic(DbgInfoIntrinsic &I)
Conditional or Unconditional Branch instruction.
RetTy visitSIToFPInst(SIToFPInst &I)
This instruction inserts a struct field of array element value into an aggregate value.
RetTy visit(Instruction &I)
RetTy visitVAEndInst(VAEndInst &I)
An instruction that atomically checks whether a specified value is in a memory location,...
RetTy visitExtractElementInst(ExtractElementInst &I)
RetTy visitCatchReturnInst(CatchReturnInst &I)
RetTy visitIntToPtrInst(IntToPtrInst &I)
RetTy visitMemMoveInst(MemMoveInst &I)