15 #ifndef LLVM_IR_OPERATOR_H 16 #define LLVM_IR_OPERATOR_H 38 void *
operator new(
size_t s) =
delete;
43 return I->getOpcode();
44 return cast<ConstantExpr>(
this)->
getOpcode();
51 return I->getOpcode();
53 return CE->getOpcode();
54 return Instruction::UserOp1;
60 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;
191 bool any()
const {
return Flags != 0; }
192 bool none()
const {
return Flags == 0; }
193 bool all()
const {
return Flags == ~0U; }
196 void set() { Flags = ~0U; }
234 Flags &= OtherFlags.Flags;
245 void setFast(
bool B) {
246 setHasAllowReassoc(B);
249 setHasNoSignedZeros(B);
250 setHasAllowReciprocal(B);
251 setHasAllowContract(B);
255 void setHasAllowReassoc(
bool B) {
261 void setHasNoNaNs(
bool B) {
267 void setHasNoInfs(
bool B) {
273 void setHasNoSignedZeros(
bool B) {
279 void setHasAllowReciprocal(
bool B) {
285 void setHasAllowContract(
bool B) {
291 void setHasApproxFunc(
bool B) {
365 float getFPAccuracy()
const;
369 if (
auto *
I = dyn_cast<Instruction>(V))
370 Opcode =
I->getOpcode();
371 else if (
auto *CE = dyn_cast<ConstantExpr>(V))
372 Opcode = CE->getOpcode();
377 case Instruction::FCmp:
380 case Instruction::ExtractElement:
381 case Instruction::ShuffleVector:
382 case Instruction::InsertElement:
391 template<
typename SuperClass,
unsigned Opc>
401 return (isa<Instruction>(V) &&
classof(cast<Instruction>(V))) ||
402 (isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V)));
440 IsInBounds = (1 << 0),
444 void setIsInBounds(
bool B) {
482 Type *getSourceElementType()
const;
483 Type *getResultElementType()
const;
487 return getPointerOperandType()->getPointerAddressSpace();
516 if (!isa<ConstantInt>(
I))
524 return !isa<ConstantInt>(*use);
541 friend class PtrToInt;
563 return cast<PointerType>(getPointerOperandType())->getAddressSpace();
584 #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.
Value * getPointerOperand(Value *V)
A helper function that returns the pointer operand of a load, store or GEP instruction.
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 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
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)
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
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...