17 #ifndef LLVM_TRANSFORMS_SCALAR_GVNEXPRESSION_H 18 #define LLVM_TRANSFORMS_SCALAR_GVNEXPRESSION_H 41 namespace GVNExpression {
69 : EType(ET), Opcode(
O) {}
96 if (static_cast<unsigned>(HashVal) == 0)
120 OS <<
"opcode = " <<
getOpcode() <<
", ";
142 Value **Operands =
nullptr;
143 unsigned MaxOperands;
144 unsigned NumOperands = 0;
165 std::swap(Operands[First], Operands[Second]);
169 assert(Operands &&
"Operands not allocated");
170 assert(N < NumOperands &&
"Operand out of range");
175 assert(Operands &&
"Operands not allocated before setting");
176 assert(N < NumOperands &&
"Operand out of range");
197 assert(NumOperands < MaxOperands &&
"Tried to add too many operands");
198 assert(Operands &&
"Operandss not allocated before pushing");
199 Operands[NumOperands++] =
Arg;
201 bool op_empty()
const {
return getNumOperands() == 0; }
204 assert(!Operands &&
"Operands already allocated");
205 Operands = Recycler.
allocate(RecyclerCapacity::get(MaxOperands), Allocator);
208 Recycler.
deallocate(RecyclerCapacity::get(MaxOperands), Operands);
218 const auto &OE = cast<BasicExpression>(Other);
219 return getType() == OE.getType() && NumOperands == OE.NumOperands &&
220 std::equal(op_begin(), op_end(), OE.op_begin());
231 OS <<
"ExpressionTypeBasic, ";
234 OS <<
"operands = {";
235 for (
unsigned i = 0, e = getNumOperands(); i != e; ++i) {
236 OS <<
"[" << i <<
"] = ";
245 :
public std::iterator<std::output_iterator_tag, void, void, void, void> {
290 return MemoryLeader == OtherMCE.MemoryLeader;
317 OS <<
"ExpressionTypeCall, ";
319 OS <<
" represents call at ";
358 cast<LoadExpression>(Other).getLoadInst() == getLoadInst();
364 OS <<
"ExpressionTypeLoad, ";
366 OS <<
" represents Load at ";
368 OS <<
" with MemoryLeader " << *getMemoryLeader();
381 StoredValue(StoredValue) {}
398 cast<StoreExpression>(Other).getStoreInst() == getStoreInst();
404 OS <<
"ExpressionTypeStore, ";
406 OS <<
" represents Store " << *
Store;
407 OS <<
" with StoredValue ";
409 OS <<
" and MemoryLeader " << *getMemoryLeader();
415 unsigned MaxIntOperands;
416 unsigned NumIntOperands = 0;
417 unsigned *IntOperands =
nullptr;
422 MaxIntOperands(NumIntOperands) {}
440 return IntOperands + NumIntOperands;
445 assert(NumIntOperands < MaxIntOperands &&
446 "Tried to add too many int operands");
447 assert(IntOperands &&
"Operands not allocated before pushing");
448 IntOperands[NumIntOperands++] = IntOperand;
452 assert(!IntOperands &&
"Operands already allocated");
453 IntOperands = Allocator.
Allocate<
unsigned>(MaxIntOperands);
460 return NumIntOperands == OE.NumIntOperands &&
472 OS <<
"ExpressionTypeAggregateValue, ";
474 OS <<
", intoperands = {";
475 for (
unsigned i = 0, e = int_op_size(); i != e; ++i) {
476 OS <<
"[" << i <<
"] = " << IntOperands[i] <<
" ";
483 :
public std::iterator<std::output_iterator_tag, void, void, void, void> {
532 OS <<
"ExpressionTypePhi, ";
551 Value *VariableValue;
568 return VariableValue == OC.VariableValue;
573 VariableValue->
getType(), VariableValue);
579 OS <<
"ExpressionTypeVariable, ";
581 OS <<
" variable = " << *VariableValue;
605 return ConstantValue == OC.ConstantValue;
610 ConstantValue->
getType(), ConstantValue);
616 OS <<
"ExpressionTypeConstant, ";
618 OS <<
" constant = " << *ConstantValue;
640 const auto &OU = cast<UnknownExpression>(Other);
641 return Inst == OU.Inst;
651 OS <<
"ExpressionTypeUnknown, ";
653 OS <<
" inst = " << *Inst;
661 #endif // LLVM_TRANSFORMS_SCALAR_GVNEXPRESSION_H
const_op_iterator op_end() const
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
LoadInst * getLoadInst() const
const_op_iterator op_begin() const
Type
MessagePack types as defined in the standard, with the exception of Integer being divided into a sign...
bool equals(const Expression &Other) const override
void printInternal(raw_ostream &OS, bool PrintEType) const override
PointerUnion< const Value *, const PseudoSourceValue * > ValueType
UnknownExpression(Instruction *I)
hash_code getHashValue() const override
int_op_inserter & operator++(int)
op_inserter & operator=(Value *val)
This class represents lattice values for constants.
PHIExpression(unsigned NumOperands, BasicBlock *B)
T * allocate(Capacity Cap, AllocatorType &Allocator)
Allocate an array of at least the requested capacity.
int_op_inserter & operator=(unsigned int val)
const MemoryAccess * getMemoryLeader() const
static bool classof(const Expression *E)
bool equals(const Expression &Other) const override
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
This class represents a function call, abstracting a target machine's calling convention.
BasicExpression(unsigned NumOperands, ExpressionType ET)
hash_code getHashValue() const override
void setConstantValue(Constant *V)
bool exactlyEquals(const Expression &Other) const override
Recycle small arrays allocated from a BumpPtrAllocator.
StoreInst * getStoreInst() const
bool equals(const Expression &Other) const override
op_inserter & operator++()
An instruction for reading from memory.
bool operator==(const Expression &Other) const
ExpressionType getExpressionType() const
AggregateValueExpression(unsigned NumOperands, unsigned NumIntOperands)
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
MemoryExpression(unsigned NumOperands, enum ExpressionType EType, const MemoryAccess *MemoryLeader)
bool equals(const Expression &Other) const override
hash_code getComputedHash() const
The size of an allocated array is represented by a Capacity instance.
bool equals(const Expression &Other) const override
int_arg_iterator int_op_begin()
void printInternal(raw_ostream &OS, bool PrintEType) const override
raw_ostream & operator<<(raw_ostream &OS, const Expression &E)
void printInternal(raw_ostream &OS, bool PrintEType) const override
int_arg_iterator int_op_end()
Expression & operator=(const Expression &)=delete
int_op_inserter(AggregateValueExpression *E)
void swapOperands(unsigned First, unsigned Second)
Swap two operands.
void printInternal(raw_ostream &OS, bool PrintEType) const override
Type * getType() const
All values are typed, get the type of this value.
static unsigned getEmptyKey()
op_inserter & operator++(int)
const_int_arg_iterator int_op_begin() const
void setMemoryLeader(const MemoryAccess *ML)
LLVM_DUMP_METHOD void dump() const
An instruction for storing to memory.
virtual hash_code getHashValue() const
StoreExpression(unsigned NumOperands, StoreInst *S, Value *StoredValue, const MemoryAccess *MemoryLeader)
void printInternal(raw_ostream &OS, bool PrintEType) const override
int_op_inserter(AggregateValueExpression &E)
const_int_arg_iterator int_op_end() const
void print(raw_ostream &OS) const
static bool classof(const Expression *EB)
LoadExpression(unsigned NumOperands, LoadInst *L, const MemoryAccess *MemoryLeader)
bool int_op_empty() const
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
Allocate memory in an ever growing pool, as if by bump-pointer.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
bool operator!=(const Expression &Other) const
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, size_t Alignment)
Allocate space at the specified alignment.
unsigned getAlignment() const
static unsigned getTombstoneKey()
CallExpression(unsigned NumOperands, CallInst *C, const MemoryAccess *MemoryLeader)
static wasm::ValType getType(const TargetRegisterClass *RC)
void printAsOperand(raw_ostream &O, bool PrintType=true, const Module *M=nullptr) const
Print the name of this Value out to the specified raw_ostream.
hash_code getHashValue() const override
void printInternal(raw_ostream &OS, bool PrintEType) const override
op_inserter(BasicExpression *E)
static bool classof(const Expression *EB)
hash_code getHashValue() const override
void setOperand(unsigned N, Value *V)
void setOpcode(unsigned opcode)
static bool classof(const Expression *EB)
Recycler - This class manages a linked-list of deallocated nodes and facilitates reusing deallocated ...
virtual void printInternal(raw_ostream &OS, bool PrintEType) const
void int_op_push_back(unsigned IntOperand)
Expression(ExpressionType ET=ET_Base, unsigned O=~2U)
int_op_inserter & operator++()
static bool classof(const Expression *EB)
bool exactlyEquals(const Expression &Other) const override
void printInternal(raw_ostream &OS, bool PrintEType) const override
iterator_range< const_op_iterator > operands() const
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
A range adaptor for a pair of iterators.
void setInstruction(Instruction *I)
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
static bool classof(const Expression *EB)
ConstantExpression(Constant *constantValue)
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
An opaque object representing a hash code.
VariableExpression(Value *V)
amdgpu Simplify well known AMD library false Value Value * Arg
virtual bool equals(const Expression &Other) const
LoadExpression(enum ExpressionType EType, unsigned NumOperands, LoadInst *L, const MemoryAccess *MemoryLeader)
static bool classof(const Expression *EB)
hash_code getHashValue() const override
bool equals(const Expression &Other) const override
unsigned getAlignment() const
Return the alignment of the access that is being performed.
op_inserter(BasicExpression &E)
static bool classof(const Expression *EB)
unsigned getNumOperands() const
void printInternal(raw_ostream &OS, bool PrintEType) const override
Value * getStoredValue() const
static bool classof(const Expression *EB)
bool equals(const Expression &Other) const override
op_inserter & operator*()
Instruction * getInstruction() const
BasicExpression(unsigned NumOperands)
iterator_range< op_iterator > operands()
void setVariableValue(Value *V)
unsigned int_op_size() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool classof(const Expression *EB)
LLVM Value Representation.
int_op_inserter & operator*()
static bool classof(const Expression *EB)
Value * getOperand(unsigned N) const
Value * getVariableValue() const
void printInternal(raw_ostream &OS, bool PrintEType) const override
This class implements an extremely fast bulk output stream that can only output to a stream...
virtual void allocateIntOperands(BumpPtrAllocator &Allocator)
This file exposes an interface to building/using memory SSA to walk memory instructions using a use/d...
void deallocate(Capacity Cap, T *Ptr)
Deallocate an array with the specified Capacity.
unsigned getOpcode() const
hash_code getHashValue() const override
virtual bool exactlyEquals(const Expression &Other) const
hash_code getHashValue() const override
void setLoadInst(LoadInst *L)
Value *const * const_op_iterator
void op_push_back(Value *Arg)
void deallocateOperands(RecyclerType &Recycler)
Constant * getConstantValue() const
void allocateOperands(RecyclerType &Recycler, BumpPtrAllocator &Allocator)
void setAlignment(unsigned Align)
A discriminated union of two pointer types, with the discriminator in the low bit of the pointer...