| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
#ifndef LLVM_IR_IRBUILDERFOLDER_H |
| 15 |
#define LLVM_IR_IRBUILDERFOLDER_H |
| 16 |
|
| 17 |
#include "llvm/ADT/ArrayRef.h" |
| 18 |
#include "llvm/IR/InstrTypes.h" |
| 19 |
#include "llvm/IR/Instruction.h" |
| 20 |
|
| 21 |
namespace llvm { |
| 22 |
|
| 23 |
|
| 24 |
class IRBuilderFolder { |
| 25 |
public: |
| 26 |
virtual ~IRBuilderFolder(); |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
virtual Value *FoldAdd(Value *LHS, Value *RHS, bool HasNUW = false, |
| 35 |
bool HasNSW = false) const = 0; |
| 36 |
|
| 37 |
virtual Value *FoldAnd(Value *LHS, Value *RHS) const = 0; |
| 38 |
|
| 39 |
virtual Value *FoldOr(Value *LHS, Value *RHS) const = 0; |
| 40 |
|
| 41 |
virtual Value *FoldICmp(CmpInst::Predicate P, Value *LHS, |
| 42 |
Value *RHS) const = 0; |
| 43 |
|
| 44 |
virtual Value *FoldGEP(Type *Ty, Value *Ptr, ArrayRef<Value *> IdxList, |
| 45 |
bool IsInBounds = false) const = 0; |
| 46 |
|
| 47 |
virtual Value *FoldSelect(Value *C, Value *True, Value *False) const = 0; |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
virtual Value *CreateFAdd(Constant *LHS, Constant *RHS) const = 0; |
| 54 |
virtual Value *CreateSub(Constant *LHS, Constant *RHS, |
| 55 |
bool HasNUW = false, bool HasNSW = false) const = 0; |
| 56 |
virtual Value *CreateFSub(Constant *LHS, Constant *RHS) const = 0; |
| 57 |
virtual Value *CreateMul(Constant *LHS, Constant *RHS, |
| 58 |
bool HasNUW = false, bool HasNSW = false) const = 0; |
| 59 |
virtual Value *CreateFMul(Constant *LHS, Constant *RHS) const = 0; |
| 60 |
virtual Value *CreateUDiv(Constant *LHS, Constant *RHS, |
| 61 |
bool isExact = false) const = 0; |
| 62 |
virtual Value *CreateSDiv(Constant *LHS, Constant *RHS, |
| 63 |
bool isExact = false) const = 0; |
| 64 |
virtual Value *CreateFDiv(Constant *LHS, Constant *RHS) const = 0; |
| 65 |
virtual Value *CreateURem(Constant *LHS, Constant *RHS) const = 0; |
| 66 |
virtual Value *CreateSRem(Constant *LHS, Constant *RHS) const = 0; |
| 67 |
virtual Value *CreateFRem(Constant *LHS, Constant *RHS) const = 0; |
| 68 |
virtual Value *CreateShl(Constant *LHS, Constant *RHS, |
| 69 |
bool HasNUW = false, bool HasNSW = false) const = 0; |
| 70 |
virtual Value *CreateLShr(Constant *LHS, Constant *RHS, |
| 71 |
bool isExact = false) const = 0; |
| 72 |
virtual Value *CreateAShr(Constant *LHS, Constant *RHS, |
| 73 |
bool isExact = false) const = 0; |
| 74 |
virtual Value *CreateXor(Constant *LHS, Constant *RHS) const = 0; |
| 75 |
virtual Value *CreateBinOp(Instruction::BinaryOps Opc, |
| 76 |
Constant *LHS, Constant *RHS) const = 0; |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
virtual Value *CreateNeg(Constant *C, |
| 83 |
bool HasNUW = false, bool HasNSW = false) const = 0; |
| 84 |
virtual Value *CreateFNeg(Constant *C) const = 0; |
| 85 |
virtual Value *CreateNot(Constant *C) const = 0; |
| 86 |
virtual Value *CreateUnOp(Instruction::UnaryOps Opc, Constant *C) const = 0; |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
virtual Value *CreateCast(Instruction::CastOps Op, Constant *C, |
| 93 |
Type *DestTy) const = 0; |
| 94 |
virtual Value *CreatePointerCast(Constant *C, Type *DestTy) const = 0; |
| 95 |
virtual Value *CreatePointerBitCastOrAddrSpaceCast(Constant *C, |
| 96 |
Type *DestTy) const = 0; |
| 97 |
virtual Value *CreateIntCast(Constant *C, Type *DestTy, |
| 98 |
bool isSigned) const = 0; |
| 99 |
virtual Value *CreateFPCast(Constant *C, Type *DestTy) const = 0; |
| 100 |
virtual Value *CreateBitCast(Constant *C, Type *DestTy) const = 0; |
| 101 |
virtual Value *CreateIntToPtr(Constant *C, Type *DestTy) const = 0; |
| 102 |
virtual Value *CreatePtrToInt(Constant *C, Type *DestTy) const = 0; |
| 103 |
virtual Value *CreateZExtOrBitCast(Constant *C, Type *DestTy) const = 0; |
| 104 |
virtual Value *CreateSExtOrBitCast(Constant *C, Type *DestTy) const = 0; |
| 105 |
virtual Value *CreateTruncOrBitCast(Constant *C, Type *DestTy) const = 0; |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
virtual Value *CreateFCmp(CmpInst::Predicate P, Constant *LHS, |
| 112 |
Constant *RHS) const = 0; |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
virtual Value *CreateExtractElement(Constant *Vec, Constant *Idx) const = 0; |
| 119 |
virtual Value *CreateInsertElement(Constant *Vec, Constant *NewElt, |
| 120 |
Constant *Idx) const = 0; |
| 121 |
virtual Value *CreateShuffleVector(Constant *V1, Constant *V2, |
| 122 |
ArrayRef<int> Mask) const = 0; |
| 123 |
virtual Value *CreateExtractValue(Constant *Agg, |
| 124 |
ArrayRef<unsigned> IdxList) const = 0; |
| 125 |
virtual Value *CreateInsertValue(Constant *Agg, Constant *Val, |
| 126 |
ArrayRef<unsigned> IdxList) const = 0; |
| 127 |
}; |
| 128 |
|
| 129 |
} |
| 130 |
|
| 131 |
#endif |