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);
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;
154 return (isa<Instruction>(V) &&
classof(cast<Instruction>(V))) ||
155 (isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V)));
172 UnsafeAlgebra = (1 << 0),
175 NoSignedZeros = (1 << 3),
176 AllowReciprocal = (1 << 4),
177 AllowContract = (1 << 5)
202 Flags = (
Flags & ~AllowContract) | B * AllowContract;
205 Flags |= UnsafeAlgebra;
209 setAllowReciprocal();
210 setAllowContract(
true);
214 Flags &= OtherFlags.Flags;
224 void setHasUnsafeAlgebra(
bool B) {
233 setHasNoSignedZeros(
true);
234 setHasAllowReciprocal(
true);
238 void setHasNoNaNs(
bool B) {
244 void setHasNoInfs(
bool B) {
250 void setHasNoSignedZeros(
bool B) {
256 void setHasAllowReciprocal(
bool B) {
262 void setHasAllowContract(
bool B) {
270 void setFastMathFlags(FastMathFlags FMF) {
276 void copyFastMathFlags(FastMathFlags FMF) {
325 float getFPAccuracy()
const;
338 return (isa<Instruction>(V) &&
classof(cast<Instruction>(V))) ||
339 (isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V)));
344 template<
typename SuperClass,
unsigned Opc>
354 return (isa<Instruction>(V) &&
classof(cast<Instruction>(V))) ||
355 (isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V)));
393 IsInBounds = (1 << 0),
397 void setIsInBounds(
bool B) {
435 Type *getSourceElementType()
const;
436 Type *getResultElementType()
const;
440 return getPointerOperandType()->getPointerAddressSpace();
469 if (!isa<ConstantInt>(
I))
488 friend class PtrToInt;
510 return cast<PointerType>(getPointerOperandType())->getAddressSpace();
531 #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)
static bool classof(const ConstantExpr *CE)
static bool classof(const Value *V)
void setNoNaNs()
Flag setters.
static bool classof(const ConstantExpr *)
unsigned getNumOperands() const
bool hasNoSignedWrap() const
Test whether this operation is known to never undergo signed overflow, aka the nsw property...
static unsigned getOpcode(const Value *V)
If V is an Instruction or ConstantExpr, return its opcode.
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags.
void setAllowContract(bool B)
bool hasNoSignedZeros() const
Test whether this operation can treat the sign of zero as insignificant, aka the 'S' fast-math proper...
static bool classof(const Instruction *)
unsigned getPointerAddressSpace() const
Method to return the address space of the pointer operand.
bool isExact() const
Test whether this division is known to be exact, with zero remainder.
unsigned getOpcode() const
Return the opcode at the root of this constant expression.
bool hasAllConstantIndices() const
Return true if all of the indices of this GEP are constant integers.
Type * getPointerOperandType() const
Method to return the pointer operand as a PointerType.
static Value * getPointerOperand(Instruction &Inst)
bool hasAllowReciprocal() const
Test whether this operation is permitted to use reciprocal instead of division, aka the 'R' fast-math...
bool noSignedZeros() const
static bool classof(const Value *V)
A Use represents the edge between a Value definition and its users.
static bool classof(const Instruction *I)
static bool classof(const Value *V)
Value * getPointerOperand()
static unsigned getPointerOperandIndex()
static bool classof(const ConstantExpr *CE)
A constant value that is initialized with an expression using other constant values.
static bool classof(const Value *V)
This class represents a no-op cast from one type to another.
static bool classof(const Instruction *I)
bool allowReciprocal() const
void operator&=(const FastMathFlags &OtherFlags)
bool hasNoNaNs() const
Test whether this operation's arguments and results are to be treated as non-NaN, aka the 'N' fast-ma...
bool unsafeAlgebra() const
Optional< unsigned > getInRangeIndex() const
Returns the offset of the index with an inrange attachment, or None if none.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs ...
The instances of the Type class are immutable: once they are created, they are never changed...
bool hasNoInfs() const
Test whether this operation's arguments and results are to be treated as NoN-Inf, aka the 'I' fast-ma...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
const_op_iterator idx_begin() const
A udiv or sdiv instruction, which can be marked as "exact", indicating that no bits are destroyed...
Utility class for integer arithmetic operators which may exhibit overflow - Add, Sub, and Mul.
Value * getPointerOperand()
Value * getOperand(unsigned i) const
Type * getPointerOperandType() const
Method to return the pointer operand as a PointerType.
static bool classof(const Value *V)
static bool isPossiblyExactOpcode(unsigned OpC)
const Value * getPointerOperand() const
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
unsigned char SubclassOptionalData
Hold subclass data that can be dropped.
bool allowContract() const
const Value * getPointerOperand() const
static bool classof(const ConstantExpr *CE)
This is the shared class of boolean and integer constants.
bool hasAllowContract() const
Test whether this operation is permitted to be floating-point contracted.
unsigned getNumIndices() const
A helper template for defining operators for individual opcodes.
void setAllowReciprocal()
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...
Type * getType() const
All values are typed, get the type of this value.
bool hasAllZeroIndices() const
Return true if all of the indices of this GEP are zeros.
bool any() const
Whether any flag is set.
Class for arbitrary precision integers.
bool hasUnsafeAlgebra() const
Test whether this operation is permitted to be algebraically transformed, aka the 'A' fast-math prope...
static bool classof(const Instruction *I)
void clear()
Set all the flags to false.
unsigned getOpcode() const
Return the opcode for this Instruction or ConstantExpr.
static std::vector< std::string > Flags
const_op_iterator idx_end() const
bool isInBounds() const
Test whether this is an inbounds GEP, as defined by LangRef.html.
unsigned getPointerAddressSpace() const
Method to return the address space of the pointer operand.
static unsigned getPointerOperandIndex()
static bool classof(const ConstantExpr *CE)
LLVM Value Representation.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
Convenience struct for specifying and reasoning about fast-math flags.
bool hasNoUnsignedWrap() const
Test whether this operation is known to never undergo unsigned overflow, aka the nuw property...
bool noNaNs() const
Flag queries.