15 #ifndef LLVM_IR_OPERATOR_H
16 #define LLVM_IR_OPERATOR_H
26 class GetElementPtrInst;
36 void *
operator new(size_t,
unsigned) =
delete;
37 void *
operator new(
size_t s) =
delete;
50 return I->getOpcode();
51 return cast<ConstantExpr>(
this)->
getOpcode();
58 return I->getOpcode();
60 return CE->getOpcode();
61 return Instruction::UserOp1;
67 return isa<Instruction>(V) || isa<ConstantExpr>(V);
84 void setHasNoUnsignedWrap(
bool B) {
88 void setHasNoSignedWrap(
bool B) {
107 return I->
getOpcode() == Instruction::Add ||
113 return CE->
getOpcode() == Instruction::Add ||
119 return (isa<Instruction>(V) &&
classof(cast<Instruction>(V))) ||
120 (isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V)));
135 void setIsExact(
bool B) {
146 return OpC == Instruction::SDiv ||
147 OpC == Instruction::UDiv ||
148 OpC == Instruction::AShr ||
149 OpC == Instruction::LShr;
158 return (isa<Instruction>(V) &&
classof(cast<Instruction>(V))) ||
159 (isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V)));
172 UnsafeAlgebra = (1 << 0),
175 NoSignedZeros = (1 << 3),
176 AllowReciprocal = (1 << 4)
201 Flags |= UnsafeAlgebra;
205 setAllowReciprocal();
209 Flags &= OtherFlags.Flags;
220 void setHasUnsafeAlgebra(
bool B) {
229 setHasNoSignedZeros(
true);
230 setHasAllowReciprocal(
true);
233 void setHasNoNaNs(
bool B) {
238 void setHasNoInfs(
bool B) {
243 void setHasNoSignedZeros(
bool B) {
248 void setHasAllowReciprocal(
bool B) {
256 void setFastMathFlags(FastMathFlags FMF) {
262 void copyFastMathFlags(FastMathFlags FMF) {
305 float getFPAccuracy()
const;
312 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
318 template<
typename SuperClass,
unsigned Opc>
328 return (isa<Instruction>(V) &&
classof(cast<Instruction>(V))) ||
329 (isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V)));
367 IsInBounds = (1 << 0)
372 void setIsInBounds(
bool B) {
403 Type *getSourceElementType()
const;
407 return getPointerOperandType()->getPointerAddressSpace();
436 if (!isa<ConstantInt>(
I))
455 friend class PtrToInt;
476 return cast<PointerType>(getPointerOperandType())->getAddressSpace();
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 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.
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
getOpcode - 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)
ConstantExpr - 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
GetElementPtrInst - an instruction for type-safe pointer arithmetic to access elements of arrays and ...
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
isFPOrFPVectorTy - Return true if this is a FP type or a vector of FP.
unsigned char SubclassOptionalData
Hold subclass data that can be dropped.
const Value * getPointerOperand() const
static bool classof(const ConstantExpr *CE)
This is the shared class of boolean and integer constants.
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.
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
getOpcode() 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.