File indexing completed on 2026-05-10 08:44:07
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef LLVM_IR_IRBUILDERFOLDER_H
0015 #define LLVM_IR_IRBUILDERFOLDER_H
0016
0017 #include "llvm/ADT/ArrayRef.h"
0018 #include "llvm/IR/GEPNoWrapFlags.h"
0019 #include "llvm/IR/InstrTypes.h"
0020 #include "llvm/IR/Instruction.h"
0021
0022 namespace llvm {
0023
0024
0025 class IRBuilderFolder {
0026 public:
0027 virtual ~IRBuilderFolder();
0028
0029
0030
0031
0032
0033
0034
0035
0036 virtual Value *FoldBinOp(Instruction::BinaryOps Opc, Value *LHS,
0037 Value *RHS) const = 0;
0038
0039 virtual Value *FoldExactBinOp(Instruction::BinaryOps Opc, Value *LHS,
0040 Value *RHS, bool IsExact) const = 0;
0041
0042 virtual Value *FoldNoWrapBinOp(Instruction::BinaryOps Opc, Value *LHS,
0043 Value *RHS, bool HasNUW,
0044 bool HasNSW) const = 0;
0045
0046 virtual Value *FoldBinOpFMF(Instruction::BinaryOps Opc, Value *LHS,
0047 Value *RHS, FastMathFlags FMF) const = 0;
0048
0049 virtual Value *FoldUnOpFMF(Instruction::UnaryOps Opc, Value *V,
0050 FastMathFlags FMF) const = 0;
0051
0052 virtual Value *FoldCmp(CmpInst::Predicate P, Value *LHS,
0053 Value *RHS) const = 0;
0054
0055 virtual Value *FoldGEP(Type *Ty, Value *Ptr, ArrayRef<Value *> IdxList,
0056 GEPNoWrapFlags NW) const = 0;
0057
0058 virtual Value *FoldSelect(Value *C, Value *True, Value *False) const = 0;
0059
0060 virtual Value *FoldExtractValue(Value *Agg,
0061 ArrayRef<unsigned> IdxList) const = 0;
0062
0063 virtual Value *FoldInsertValue(Value *Agg, Value *Val,
0064 ArrayRef<unsigned> IdxList) const = 0;
0065
0066 virtual Value *FoldExtractElement(Value *Vec, Value *Idx) const = 0;
0067
0068 virtual Value *FoldInsertElement(Value *Vec, Value *NewElt,
0069 Value *Idx) const = 0;
0070
0071 virtual Value *FoldShuffleVector(Value *V1, Value *V2,
0072 ArrayRef<int> Mask) const = 0;
0073
0074 virtual Value *FoldCast(Instruction::CastOps Op, Value *V,
0075 Type *DestTy) const = 0;
0076
0077 virtual Value *
0078 FoldBinaryIntrinsic(Intrinsic::ID ID, Value *LHS, Value *RHS, Type *Ty,
0079 Instruction *FMFSource = nullptr) const = 0;
0080
0081
0082
0083
0084
0085 virtual Value *CreatePointerCast(Constant *C, Type *DestTy) const = 0;
0086 virtual Value *CreatePointerBitCastOrAddrSpaceCast(Constant *C,
0087 Type *DestTy) const = 0;
0088 };
0089
0090 }
0091
0092 #endif