LLVM: include/llvm/IR/ConstantFolder.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16#ifndef LLVM_IR_CONSTANTFOLDER_H

17#define LLVM_IR_CONSTANTFOLDER_H

18

27

28namespace llvm {

29

30

33

34public:

36

37

38

39

40

41

42

43

48 if (LC && RC) {

52 }

53 return nullptr;

54 }

55

57 bool IsExact) const override {

60 if (LC && RC) {

65 }

66 return nullptr;

67 }

68

70 bool HasNUW, bool HasNSW) const override {

73 if (LC && RC) {

75 unsigned Flags = 0;

76 if (HasNUW)

78 if (HasNSW)

81 }

83 }

84 return nullptr;

85 }

86

91

98

102 if (LC && RC)

104 return nullptr;

105 }

106

110 return nullptr;

111

113

115 return nullptr;

116

118 }

119 return nullptr;

120 }

121

126 if (CC && TC && FC)

128 return nullptr;

129 }

130

135 return nullptr;

136 };

137

142 if (CAgg && CVal)

144 return nullptr;

145 }

146

150 if (CVec && CIdx)

152 return nullptr;

153 }

154

156 Value *Idx) const override {

160 if (CVec && CNewElt && CIdx)

162 return nullptr;

163 }

164

169 if (C1 && C2)

171 return nullptr;

172 }

173

175 Type *DestTy) const override {

180 }

181 return nullptr;

182 }

183

186

187 return nullptr;

188 }

189

190

191

192

193

197

199 Type *DestTy) const override {

201 }

202};

203

204}

205

206#endif

#define LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION()

\macro LLVM_VIRTUAL_ANCHOR_FUNCTION This macro is used to adhere to LLVM's policy that each class wit...

This file contains the declarations for the subclasses of Constant, which represent the different fla...

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

Predicate

This enumeration lists the possible predicates for CmpInst subclasses.

static LLVM_ABI Constant * getExtractElement(Constant *Vec, Constant *Idx, Type *OnlyIfReducedTy=nullptr)

static LLVM_ABI Constant * getPointerCast(Constant *C, Type *Ty)

Create a BitCast, AddrSpaceCast, or a PtrToInt cast constant expression.

static LLVM_ABI Constant * getPointerBitCastOrAddrSpaceCast(Constant *C, Type *Ty)

Create a BitCast or AddrSpaceCast for a pointer type depending on the address space.

static LLVM_ABI bool isDesirableCastOp(unsigned Opcode)

Whether creating a constant expression for this cast is desirable.

static LLVM_ABI Constant * getCast(unsigned ops, Constant *C, Type *Ty, bool OnlyIfReduced=false)

Convenience function for getting a Cast operation.

static LLVM_ABI Constant * getInsertElement(Constant *Vec, Constant *Elt, Constant *Idx, Type *OnlyIfReducedTy=nullptr)

static LLVM_ABI Constant * getShuffleVector(Constant *V1, Constant *V2, ArrayRef< int > Mask, Type *OnlyIfReducedTy=nullptr)

static bool isSupportedGetElementPtr(const Type *SrcElemTy)

Whether creating a constant expression for this getelementptr type is supported.

static LLVM_ABI Constant * get(unsigned Opcode, Constant *C1, Constant *C2, unsigned Flags=0, Type *OnlyIfReducedTy=nullptr)

get - Return a binary or shift operator constant expression, folding if possible.

static LLVM_ABI bool isDesirableBinOp(unsigned Opcode)

Whether creating a constant expression for this binary operator is desirable.

static Constant * getGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList, GEPNoWrapFlags NW=GEPNoWrapFlags::none(), std::optional< ConstantRange > InRange=std::nullopt, Type *OnlyIfReducedTy=nullptr)

Getelementptr form.

Value * FoldBinOpFMF(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, FastMathFlags FMF) const override

Definition ConstantFolder.h:87

Value * FoldCast(Instruction::CastOps Op, Value *V, Type *DestTy) const override

Definition ConstantFolder.h:174

Value * FoldCmp(CmpInst::Predicate P, Value *LHS, Value *RHS) const override

Definition ConstantFolder.h:99

Value * FoldExtractElement(Value *Vec, Value *Idx) const override

Definition ConstantFolder.h:147

Value * FoldShuffleVector(Value *V1, Value *V2, ArrayRef< int > Mask) const override

Definition ConstantFolder.h:165

Constant * CreatePointerBitCastOrAddrSpaceCast(Constant *C, Type *DestTy) const override

Definition ConstantFolder.h:198

Value * FoldInsertValue(Value *Agg, Value *Val, ArrayRef< unsigned > IdxList) const override

Definition ConstantFolder.h:138

Value * FoldExactBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, bool IsExact) const override

Definition ConstantFolder.h:56

Value * FoldNoWrapBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, bool HasNUW, bool HasNSW) const override

Definition ConstantFolder.h:69

Value * FoldGEP(Type *Ty, Value *Ptr, ArrayRef< Value * > IdxList, GEPNoWrapFlags NW) const override

Definition ConstantFolder.h:107

Constant * CreatePointerCast(Constant *C, Type *DestTy) const override

Definition ConstantFolder.h:194

Value * FoldUnOpFMF(Instruction::UnaryOps Opc, Value *V, FastMathFlags FMF) const override

Definition ConstantFolder.h:92

Value * FoldBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS) const override

Definition ConstantFolder.h:44

Value * FoldInsertElement(Value *Vec, Value *NewElt, Value *Idx) const override

Definition ConstantFolder.h:155

Value * FoldExtractValue(Value *Agg, ArrayRef< unsigned > IdxList) const override

Definition ConstantFolder.h:131

Value * FoldBinaryIntrinsic(Intrinsic::ID ID, Value *LHS, Value *RHS, Type *Ty, Instruction *FMFSource) const override

Definition ConstantFolder.h:184

Value * FoldSelect(Value *C, Value *True, Value *False) const override

Definition ConstantFolder.h:122

This is an important base class in LLVM.

This provides a helper for copying FMF from an instruction or setting specified flags.

Convenience struct for specifying and reasoning about fast-math flags.

Represents flags for the getelementptr instruction/expression.

IRBuilderFolder - Interface for constant folding in IRBuilder.

The instances of the Type class are immutable: once they are created, they are never changed.

LLVM Value Representation.

unsigned ID

LLVM IR allows to use arbitrary numbers as calling convention identifiers.

@ C

The default llvm calling convention, compatible with C.

This is an optimization pass for GlobalISel generic memory operations.

LLVM_ABI Constant * ConstantFoldSelectInstruction(Constant *Cond, Constant *V1, Constant *V2)

Attempt to constant fold a select instruction with the specified operands.

decltype(auto) dyn_cast(const From &Val)

dyn_cast - Return the argument parameter cast to the specified type.

LLVM_ABI Constant * ConstantFoldCompareInstruction(CmpInst::Predicate Predicate, Constant *C1, Constant *C2)

LLVM_ABI Constant * ConstantFoldUnaryInstruction(unsigned Opcode, Constant *V)

LLVM_ABI Constant * ConstantFoldExtractValueInstruction(Constant *Agg, ArrayRef< unsigned > Idxs)

Attempt to constant fold an extractvalue instruction with the specified operands and indices.

bool any_of(R &&range, UnaryPredicate P)

Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.

bool isa(const From &Val)

isa - Return true if the parameter to the template is an instance of one of the template type argu...

DWARFExpression::Operation Op

LLVM_ABI Constant * ConstantFoldCastInstruction(unsigned opcode, Constant *V, Type *DestTy)

LLVM_ABI Constant * ConstantFoldInsertValueInstruction(Constant *Agg, Constant *Val, ArrayRef< unsigned > Idxs)

Attempt to constant fold an insertvalue instruction with the specified operands and indices.

LLVM_ABI Constant * ConstantFoldBinaryInstruction(unsigned Opcode, Constant *V1, Constant *V2)