Go to the documentation of this file.
14 #ifndef LLVM_IR_OPERATOR_H
15 #define LLVM_IR_OPERATOR_H
39 void *
operator new(
size_t s) =
delete;
44 return I->getOpcode();
45 return cast<ConstantExpr>(
this)->getOpcode();
52 return I->getOpcode();
54 return CE->getOpcode();
55 return Instruction::UserOp1;
61 return isa<Instruction>(V) || isa<ConstantExpr>(V);
84 void setHasNoUnsignedWrap(
bool B) {
88 void setHasNoSignedWrap(
bool B) {
108 I->getOpcode() == Instruction::Sub ||
110 I->getOpcode() == Instruction::Shl;
114 CE->getOpcode() == Instruction::Sub ||
116 CE->getOpcode() == Instruction::Shl;
119 return (isa<Instruction>(V) &&
classof(cast<Instruction>(V))) ||
120 (isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V)));
136 void setIsExact(
bool B) {
147 return OpC == Instruction::SDiv ||
148 OpC == Instruction::UDiv ||
149 OpC == Instruction::AShr ||
150 OpC == Instruction::LShr;
160 return (isa<Instruction>(V) &&
classof(cast<Instruction>(V))) ||
161 (isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V)));
172 void setFast(
bool B) {
173 setHasAllowReassoc(
B);
176 setHasNoSignedZeros(
B);
177 setHasAllowReciprocal(
B);
178 setHasAllowContract(
B);
182 void setHasAllowReassoc(
bool B) {
188 void setHasNoNaNs(
bool B) {
194 void setHasNoInfs(
bool B) {
200 void setHasNoSignedZeros(
bool B) {
206 void setHasAllowReciprocal(
bool B) {
212 void setHasAllowContract(
bool B) {
218 void setHasApproxFunc(
bool B) {
226 void setFastMathFlags(FastMathFlags FMF) {
232 void copyFastMathFlags(FastMathFlags FMF) {
296 if (
auto *
I = dyn_cast<Instruction>(V))
297 Opcode =
I->getOpcode();
298 else if (
auto *CE = dyn_cast<ConstantExpr>(V))
299 Opcode = CE->getOpcode();
304 case Instruction::FNeg:
305 case Instruction::FAdd:
306 case Instruction::FSub:
307 case Instruction::FMul:
308 case Instruction::FDiv:
309 case Instruction::FRem:
315 case Instruction::FCmp:
317 case Instruction::PHI:
321 while (
ArrayType *ArrTy = dyn_cast<ArrayType>(Ty))
322 Ty = ArrTy->getElementType();
332 template<
typename SuperClass,
unsigned Opc>
336 return I->getOpcode() == Opc;
339 return CE->getOpcode() == Opc;
342 return (isa<Instruction>(V) &&
classof(cast<Instruction>(V))) ||
343 (isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V)));
381 IsInBounds = (1 << 0),
385 void setIsInBounds(
bool B) {
465 if (!isa<ConstantInt>(
I))
473 return !isa<ConstantInt>(*
use);
510 APInt &ConstantOffset)
const;
577 #endif // LLVM_IR_OPERATOR_H
Move duplicate certain instructions close to their use
This is an optimization pass for GlobalISel generic memory operations.
bool isFast() const
Test if this operation allows all non-strict floating-point transforms.
This is a utility class that provides an abstraction for the common functionality between Instruction...
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
const Value * getPointerOperand() const
A parsed version of the target data layout string in and methods for querying it.
unsigned getNumIndices() const
unsigned char SubclassOptionalData
Hold subclass data that can be dropped.
iterator_range< const_op_iterator > indices() const
static bool classof(const Instruction *I)
This class represents a no-op cast from one type to another.
static bool classof(const ConstantExpr *CE)
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
Optional< unsigned > getInRangeIndex() const
Returns the offset of the index with an inrange attachment, or None if none.
The instances of the Type class are immutable: once they are created, they are never changed.
const Value * getPointerOperand() const
This class implements a map that also provides access to all stored values in a deterministic order.
bool hasNoUnsignedWrap() const
Test whether this operation is known to never undergo unsigned overflow, aka the nuw property.
bool hasNoNaNs() const
Test if this operation's arguments and results are assumed not-NaN.
Class to represent array types.
static bool classof(const Value *V)
Convenience struct for specifying and reasoning about fast-math flags.
auto count_if(R &&Range, UnaryPredicate P)
Wrapper function around std::count_if to count the number of times an element satisfying a given pred...
A udiv or sdiv instruction, which can be marked as "exact", indicating that no bits are destroyed.
bool hasNoInfs() const
Test if this operation's arguments and results are assumed not-infinite.
static bool isPossiblyExactOpcode(unsigned OpC)
This is the shared class of boolean and integer constants.
const_op_iterator idx_begin() const
Type * getResultElementType() const
static bool classof(const ConstantExpr *CE)
This class represents a conversion between pointers from one address space to another.
unsigned getDestAddressSpace() const
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
(vector float) vec_cmpeq(*A, *B) C
Value * getPointerOperand()
A helper template for defining operators for individual opcodes.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
unsigned getOpcode() const
Return the opcode for this Instruction or ConstantExpr.
static unsigned getPointerOperandIndex()
Align getMaxPreservedAlignment(const DataLayout &DL) const
Compute the maximum alignment that this GEP is garranteed to preserve.
bool hasNoSignedZeros() const
Test if this operation can ignore the sign of zero.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Value * getPointerOperand()
static bool classof(const Value *V)
Value * getPointerOperand()
An efficient, type-erasing, non-owning reference to a callable.
static bool classof(const Value *V)
static bool classof(const Value *V)
bool hasAllZeroIndices() const
Return true if all of the indices of this GEP are zeros.
static bool classof(const Instruction *I)
static bool classof(const ConstantExpr *)
unsigned countNonConstantIndices() const
multiplies can be turned into SHL s
bool hasAllowReciprocal() const
Test if this operation can use reciprocal multiply instead of division.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
bool hasAllowReassoc() const
Test if this operation may be simplified with reassociative transforms.
Utility class for floating point operations which can have information about relaxed accuracy require...
bool hasPoisonGeneratingFlags() const
Return true if this operator has flags which may cause this operator to evaluate to poison despite ha...
static unsigned getOpcode(const Value *V)
If V is an Instruction or ConstantExpr, return its opcode.
static bool classof(const Value *V)
unsigned getPointerAddressSpace() const
Method to return the address space of the pointer operand.
bool hasApproxFunc() const
Test if this operation allows approximations of math library functions or intrinsics.
Class for arbitrary precision integers.
bool hasAllConstantIndices() const
Return true if all of the indices of this GEP are constant integers.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
iterator_range< op_iterator > indices()
Type * getType() const
All values are typed, get the type of this value.
static bool classof(const Instruction *)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static unsigned getPointerOperandIndex()
Utility class for integer operators which may exhibit overflow - Add, Sub, Mul, and Shl.
bool hasAllowContract() const
Test if this operation can be floating-point contracted (FMA).
unsigned getPointerAddressSpace() const
Method to return the address space of the pointer operand.
A constant value that is initialized with an expression using other constant values.
bool hasNoSignedWrap() const
Test whether this operation is known to never undergo signed overflow, aka the nsw property.
unsigned getSrcAddressSpace() const
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags.
bool isInBounds() const
Test whether this is an inbounds GEP, as defined by LangRef.html.
Type * getPointerOperandType() const
Method to return the pointer operand as a PointerType.
bool accumulateConstantOffset(const DataLayout &DL, APInt &Offset, function_ref< bool(Value &, APInt &)> ExternalAnalysis=nullptr) const
Accumulate the constant address offset of this GEP if possible.
constexpr unsigned BitWidth
bool collectOffset(const DataLayout &DL, unsigned BitWidth, MapVector< Value *, APInt > &VariableOffsets, APInt &ConstantOffset) const
Collect the offset of this GEP as a map of Values to their associated APInt multipliers,...
static bool classof(const ConstantExpr *CE)
Type * getSourceElementType() const
unsigned getNumOperands() const
float getFPAccuracy() const
Get the maximum error permitted by this operation in ULPs.
const_op_iterator idx_end() const
static bool classof(const Instruction *I)
A range adaptor for a pair of iterators.
const Value * getPointerOperand() const
Value * getOperand(unsigned i) const
bool isExact() const
Test whether this division is known to be exact, with zero remainder.
Type * getPointerOperandType() const
Method to return the pointer operand as a PointerType.
LLVM Value Representation.
A Use represents the edge between a Value definition and its users.