14#ifndef LLVM_IR_OPERATOR_H
15#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);
87 void setHasNoUnsignedWrap(
bool B) {
91 void setHasNoSignedWrap(
bool B) {
110 return I->getOpcode() == Instruction::Add ||
111 I->getOpcode() == Instruction::Sub ||
112 I->getOpcode() == Instruction::Mul ||
113 I->getOpcode() == Instruction::Shl;
116 return CE->getOpcode() == Instruction::Add ||
117 CE->getOpcode() == Instruction::Sub ||
118 CE->getOpcode() == Instruction::Mul ||
119 CE->getOpcode() == Instruction::Shl;
122 return (isa<Instruction>(V) &&
classof(cast<Instruction>(V))) ||
123 (isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V)));
139 void setIsExact(
bool B) {
150 return OpC == Instruction::SDiv ||
151 OpC == Instruction::UDiv ||
152 OpC == Instruction::AShr ||
153 OpC == Instruction::LShr;
163 return (isa<Instruction>(V) &&
classof(cast<Instruction>(V))) ||
164 (isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V)));
175 void setFast(
bool B) {
176 setHasAllowReassoc(
B);
179 setHasNoSignedZeros(
B);
180 setHasAllowReciprocal(
B);
181 setHasAllowContract(
B);
185 void setHasAllowReassoc(
bool B) {
191 void setHasNoNaNs(
bool B) {
197 void setHasNoInfs(
bool B) {
203 void setHasNoSignedZeros(
bool B) {
209 void setHasAllowReciprocal(
bool B) {
215 void setHasAllowContract(
bool B) {
221 void setHasApproxFunc(
bool B) {
229 void setFastMathFlags(FastMathFlags FMF) {
235 void copyFastMathFlags(FastMathFlags FMF) {
299 if (
auto *
I = dyn_cast<Instruction>(V))
301 else if (
auto *CE = dyn_cast<ConstantExpr>(V))
307 case Instruction::FNeg:
308 case Instruction::FAdd:
309 case Instruction::FSub:
310 case Instruction::FMul:
311 case Instruction::FDiv:
312 case Instruction::FRem:
318 case Instruction::FCmp:
320 case Instruction::PHI:
321 case Instruction::Select:
322 case Instruction::Call: {
323 Type *Ty = V->getType();
324 while (
ArrayType *ArrTy = dyn_cast<ArrayType>(Ty))
325 Ty = ArrTy->getElementType();
335template<
typename SuperClass,
unsigned Opc>
339 return I->getOpcode() == Opc;
342 return CE->getOpcode() == Opc;
345 return (isa<Instruction>(V) &&
classof(cast<Instruction>(V))) ||
346 (isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V)));
376 IsInBounds = (1 << 0),
380 void setIsInBounds(
bool B) {
461 if (!isa<ConstantInt>(
I))
469 return !isa<ConstantInt>(*
use);
506 APInt &ConstantOffset)
const;
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Move duplicate certain instructions close to their use
This file implements a map that provides insertion order iteration.
static constexpr uint32_t Opcode
Class for arbitrary precision integers.
This class represents a conversion between pointers from one address space to another.
const Value * getPointerOperand() const
unsigned getDestAddressSpace() const
unsigned getSrcAddressSpace() const
Value * getPointerOperand()
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Class to represent array types.
This class represents a no-op cast from one type to another.
A helper template for defining operators for individual opcodes.
static bool classof(const Value *V)
static bool classof(const ConstantExpr *CE)
static bool classof(const Instruction *I)
A constant value that is initialized with an expression using other constant values.
This is the shared class of boolean and integer constants.
A parsed version of the target data layout string in and methods for querying it.
Utility class for floating point operations which can have information about relaxed accuracy require...
bool hasAllowReassoc() const
Test if this operation may be simplified with reassociative transforms.
bool isFast() const
Test if this operation allows all non-strict floating-point transforms.
static bool classof(const Value *V)
bool hasNoNaNs() const
Test if this operation's arguments and results are assumed not-NaN.
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags.
bool hasAllowReciprocal() const
Test if this operation can use reciprocal multiply instead of division.
bool hasNoSignedZeros() const
Test if this operation can ignore the sign of zero.
bool hasAllowContract() const
Test if this operation can be floating-point contracted (FMA).
bool hasNoInfs() const
Test if this operation's arguments and results are assumed not-infinite.
bool hasApproxFunc() const
Test if this operation allows approximations of math library functions or intrinsics.
float getFPAccuracy() const
Get the maximum error permitted by this operation in ULPs.
Convenience struct for specifying and reasoning about fast-math flags.
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,...
const_op_iterator idx_end() const
const Value * getPointerOperand() const
const_op_iterator idx_begin() const
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.
unsigned getNumIndices() const
unsigned countNonConstantIndices() const
Type * getSourceElementType() const
Type * getResultElementType() const
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.
bool hasAllZeroIndices() const
Return true if all of the indices of this GEP are zeros.
std::optional< unsigned > getInRangeIndex() const
Returns the offset of the index with an inrange attachment, or std::nullopt if none.
Value * getPointerOperand()
bool hasAllConstantIndices() const
Return true if all of the indices of this GEP are constant integers.
iterator_range< op_iterator > indices()
iterator_range< const_op_iterator > indices() const
Align getMaxPreservedAlignment(const DataLayout &DL) const
Compute the maximum alignment that this GEP is garranteed to preserve.
unsigned getPointerAddressSpace() const
Method to return the address space of the pointer operand.
static unsigned getPointerOperandIndex()
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
This class implements a map that also provides access to all stored values in a deterministic order.
This is a utility class that provides an abstraction for the common functionality between Instruction...
static bool classof(const ConstantExpr *)
bool hasPoisonGeneratingFlags() const
Return true if this operator has flags which may cause this operator to evaluate to poison despite ha...
bool hasPoisonGeneratingFlagsOrMetadata() const
Return true if this operator has poison-generating flags or metadata.
static bool classof(const Instruction *)
unsigned getOpcode() const
Return the opcode for this Instruction or ConstantExpr.
static bool classof(const Value *V)
static unsigned getOpcode(const Value *V)
If V is an Instruction or ConstantExpr, return its opcode.
Utility class for integer operators which may exhibit overflow - Add, Sub, Mul, and Shl.
static bool classof(const Value *V)
bool hasNoSignedWrap() const
Test whether this operation is known to never undergo signed overflow, aka the nsw property.
bool hasNoUnsignedWrap() const
Test whether this operation is known to never undergo unsigned overflow, aka the nuw property.
static bool classof(const ConstantExpr *CE)
static bool classof(const Instruction *I)
A udiv or sdiv instruction, which can be marked as "exact", indicating that no bits are destroyed.
static bool classof(const ConstantExpr *CE)
bool isExact() const
Test whether this division is known to be exact, with zero remainder.
static bool isPossiblyExactOpcode(unsigned OpC)
static bool classof(const Value *V)
static bool classof(const Instruction *I)
Type * getPointerOperandType() const
Method to return the pointer operand as a PointerType.
static unsigned getPointerOperandIndex()
unsigned getPointerAddressSpace() const
Method to return the address space of the pointer operand.
const Value * getPointerOperand() const
Value * getPointerOperand()
The instances of the Type class are immutable: once they are created, they are never changed.
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.
A Use represents the edge between a Value definition and its users.
Value * getOperand(unsigned i) const
unsigned getNumOperands() const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
unsigned char SubclassOptionalData
Hold subclass data that can be dropped.
An efficient, type-erasing, non-owning reference to a callable.
A range adaptor for a pair of iterators.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
constexpr unsigned BitWidth
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...
This struct is a compact representation of a valid (non-zero power of two) alignment.