14 #ifndef LLVM_IR_OPERATOR_H 15 #define LLVM_IR_OPERATOR_H 37 void *
operator new(
size_t s) =
delete;
42 return I->getOpcode();
43 return cast<ConstantExpr>(
this)->
getOpcode();
50 return I->getOpcode();
52 return CE->getOpcode();
53 return Instruction::UserOp1;
59 return isa<Instruction>(V) || isa<ConstantExpr>(V);
70 NoUnsignedWrap = (1 << 0),
71 NoSignedWrap = (1 << 1)
78 void setHasNoUnsignedWrap(
bool B) {
82 void setHasNoSignedWrap(
bool B) {
113 return (isa<Instruction>(V) &&
classof(cast<Instruction>(V))) ||
114 (isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V)));
130 void setIsExact(
bool B) {
141 return OpC == Instruction::SDiv ||
142 OpC == Instruction::UDiv ||
143 OpC == Instruction::AShr ||
144 OpC == Instruction::LShr;
148 return isPossiblyExactOpcode(CE->
getOpcode());
151 return isPossiblyExactOpcode(I->
getOpcode());
154 return (isa<Instruction>(V) &&
classof(cast<Instruction>(V))) ||
155 (isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V)));
170 if (F == 0x7F) Flags = ~0U;
197 bool any()
const {
return Flags != 0; }
198 bool none()
const {
return Flags == 0; }
199 bool all()
const {
return Flags == ~0U; }
202 void set() { Flags = ~0U; }
240 Flags &= OtherFlags.Flags;
251 void setFast(
bool B) {
252 setHasAllowReassoc(B);
255 setHasNoSignedZeros(B);
256 setHasAllowReciprocal(B);
257 setHasAllowContract(B);
261 void setHasAllowReassoc(
bool B) {
267 void setHasNoNaNs(
bool B) {
273 void setHasNoInfs(
bool B) {
279 void setHasNoSignedZeros(
bool B) {
285 void setHasAllowReciprocal(
bool B) {
291 void setHasAllowContract(
bool B) {
297 void setHasApproxFunc(
bool B) {
371 float getFPAccuracy()
const;
375 if (
auto *
I = dyn_cast<Instruction>(V))
376 Opcode =
I->getOpcode();
377 else if (
auto *CE = dyn_cast<ConstantExpr>(V))
378 Opcode = CE->getOpcode();
383 case Instruction::FNeg:
384 case Instruction::FAdd:
385 case Instruction::FSub:
386 case Instruction::FMul:
387 case Instruction::FDiv:
388 case Instruction::FRem:
394 case Instruction::FCmp:
396 case Instruction::PHI:
400 while (
ArrayType *ArrTy = dyn_cast<ArrayType>(Ty))
401 Ty = ArrTy->getElementType();
411 template<
typename SuperClass,
unsigned Opc>
421 return (isa<Instruction>(V) &&
classof(cast<Instruction>(V))) ||
422 (isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V)));
460 IsInBounds = (1 << 0),
464 void setIsInBounds(
bool B) {
502 Type *getSourceElementType()
const;
503 Type *getResultElementType()
const;
507 return getPointerOperandType()->getPointerAddressSpace();
536 if (!isa<ConstantInt>(
I))
544 return !isa<ConstantInt>(*use);
561 friend class PtrToInt;
583 return cast<PointerType>(getPointerOperandType())->getAddressSpace();
604 #endif // LLVM_IR_OPERATOR_H
A parsed version of the target data layout string in and methods for querying it. ...
static bool classof(const Instruction *I)
unsigned getOpcode() const
Return the opcode at the root of this constant expression.
bool hasNoNaNs() const
Test if this operation's arguments and results are assumed not-NaN.
bool hasNoInfs() const
Test if this operation's arguments and results are assumed not-infinite.
static bool classof(const Value *V)
void setFast(bool B=true)
This class represents lattice values for constants.
static bool classof(const ConstantExpr *)
static unsigned getOpcode(const Value *V)
If V is an Instruction or ConstantExpr, return its opcode.
unsigned getPointerAddressSpace() const
Method to return the address space of the pointer operand.
static bool classof(const Instruction *)
Optional< unsigned > getInRangeIndex() const
Returns the offset of the index with an inrange attachment, or None if none.
unsigned getPointerAddressSpace() const
Method to return the address space of the pointer operand.
auto count_if(R &&Range, UnaryPredicate P) -> typename std::iterator_traits< decltype(adl_begin(Range))>::difference_type
Wrapper function around std::count_if to count the number of times an element satisfying a given pred...
void setNoInfs(bool B=true)
bool hasAllowContract() const
Test if this operation can be floating-point contracted (FMA).
static FastMathFlags getFast()
static bool classof(const Value *V)
A Use represents the edge between a Value definition and its users.
static bool classof(const Instruction *I)
Type * getPointerOperandType() const
Method to return the pointer operand as a PointerType.
static bool classof(const Value *V)
bool hasAllowReciprocal() const
Test if this operation can use reciprocal multiply instead of division.
Value * getPointerOperand()
static unsigned getPointerOperandIndex()
bool isExact() const
Test whether this division is known to be exact, with zero remainder.
static bool classof(const ConstantExpr *CE)
A constant value that is initialized with an expression using other constant values.
Type * getType() const
All values are typed, get the type of this value.
static bool classof(const Value *V)
unsigned getNumIndices() const
Class to represent array types.
bool isInBounds() const
Test whether this is an inbounds GEP, as defined by LangRef.html.
Predicate all(Predicate P0, Predicate P1)
True iff P0 and P1 are true.
This class represents a no-op cast from one type to another.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
bool allowContract() const
Value * getOperand(unsigned i) const
const Value * getPointerOperand() const
an instruction for type-safe pointer arithmetic to access elements of arrays and structs ...
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags.
bool hasAllZeroIndices() const
Return true if all of the indices of this GEP are zeros.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
void setNoSignedZeros(bool B=true)
Move duplicate certain instructions close to their use
The instances of the Type class are immutable: once they are created, they are never changed...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
A udiv or sdiv instruction, which can be marked as "exact", indicating that no bits are destroyed...
bool isFast() const
'Fast' means all bits are set.
Utility class for integer operators which may exhibit overflow - Add, Sub, Mul, and Shl...
Value * getPointerOperand()
bool allowReciprocal() const
static bool classof(const Value *V)
static bool isPossiblyExactOpcode(unsigned OpC)
bool hasApproxFunc() const
Test if this operation allows approximations of math library functions or intrinsics.
unsigned char SubclassOptionalData
Hold subclass data that can be dropped.
Type * getPointerOperandType() const
Method to return the pointer operand as a PointerType.
bool hasAllowReassoc() const
Test if this operation may be simplified with reassociative transforms.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
unsigned getNumOperands() const
bool hasNoSignedZeros() const
Test if this operation can ignore the sign of zero.
static bool classof(const ConstantExpr *CE)
This is the shared class of boolean and integer constants.
A helper template for defining operators for individual opcodes.
Utility class for floating point operations which can have information about relaxed accuracy require...
This is a utility class that provides an abstraction for the common functionality between Instruction...
bool hasAllConstantIndices() const
Return true if all of the indices of this GEP are constant integers.
void setApproxFunc(bool B=true)
void setNoNaNs(bool B=true)
Class for arbitrary precision integers.
bool hasNoSignedWrap() const
Test whether this operation is known to never undergo signed overflow, aka the nsw property...
static void clear(coro::Shape &Shape)
static bool classof(const Instruction *I)
const_op_iterator idx_end() const
void setAllowContract(bool B=true)
const_op_iterator idx_begin() const
void setAllowReciprocal(bool B=true)
static unsigned getPointerOperandIndex()
const Value * getPointerOperand(const Value *V)
A helper function that returns the pointer operand of a load, store or GEP instruction.
const Value * getPointerOperand() const
static bool classof(const ConstantExpr *CE)
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
LLVM Value Representation.
E & operator &=(E &LHS, E RHS)
unsigned getOpcode() const
Return the opcode for this Instruction or ConstantExpr.
bool allowReassoc() const
Flag queries.
bool isFast() const
Test if this operation allows all non-strict floating-point transforms.
Convenience struct for specifying and reasoning about fast-math flags.
void setAllowReassoc(bool B=true)
Flag setters.
unsigned countNonConstantIndices() const
bool noSignedZeros() const
bool hasNoUnsignedWrap() const
Test whether this operation is known to never undergo unsigned overflow, aka the nuw property...