16#ifndef LLVM_TRANSFORMS_SCALAR_GVNEXPRESSION_H
17#define LLVM_TRANSFORMS_SCALAR_GVNEXPRESSION_H
40namespace GVNExpression {
68 : EType(ET), Opcode(O) {}
95 if (
static_cast<unsigned>(HashVal) == 0)
141 Value **Operands =
nullptr;
142 unsigned MaxOperands;
143 unsigned NumOperands = 0;
169 assert(
N < NumOperands &&
"Operand out of range");
175 assert(
N < NumOperands &&
"Operand out of range");
196 assert(NumOperands < MaxOperands &&
"Tried to add too many operands");
217 const auto &OE = cast<BasicExpression>(
Other);
218 return getType() == OE.getType() && NumOperands == OE.NumOperands &&
230 OS <<
"ExpressionTypeBasic, ";
233 OS <<
"operands = {";
235 OS <<
"[" << i <<
"] = ";
294 return MemoryLeader == OtherMCE.MemoryLeader;
321 cast<CallExpression>(
Other).Call == Call;
327 OS <<
"ExpressionTypeCall, ";
329 OS <<
" represents call at ";
330 Call->printAsOperand(
OS);
368 OS <<
"ExpressionTypeLoad, ";
370 OS <<
" represents Load at ";
371 Load->printAsOperand(
OS);
385 StoredValue(StoredValue) {}
408 OS <<
"ExpressionTypeStore, ";
410 OS <<
" represents Store " << *Store;
411 OS <<
" with StoredValue ";
419 unsigned MaxIntOperands;
420 unsigned NumIntOperands = 0;
421 unsigned *IntOperands =
nullptr;
426 MaxIntOperands(NumIntOperands) {}
444 return IntOperands + NumIntOperands;
449 assert(NumIntOperands < MaxIntOperands &&
450 "Tried to add too many int operands");
451 assert(IntOperands &&
"Operands not allocated before pushing");
452 IntOperands[NumIntOperands++] = IntOperand;
456 assert(!IntOperands &&
"Operands already allocated");
457 IntOperands =
Allocator.Allocate<
unsigned>(MaxIntOperands);
464 return NumIntOperands == OE.NumIntOperands &&
476 OS <<
"ExpressionTypeAggregateValue, ";
478 OS <<
", intoperands = {";
479 for (
unsigned i = 0, e =
int_op_size(); i != e; ++i) {
480 OS <<
"[" << i <<
"] = " << IntOperands[i] <<
" ";
541 OS <<
"ExpressionTypePhi, ";
554 return E->getExpressionType() ==
ET_Dead;
560 Value *VariableValue;
577 return VariableValue == OC.VariableValue;
582 VariableValue->
getType(), VariableValue);
588 OS <<
"ExpressionTypeVariable, ";
590 OS <<
" variable = " << *VariableValue;
614 return ConstantValue == OC.ConstantValue;
619 ConstantValue->
getType(), ConstantValue);
625 OS <<
"ExpressionTypeConstant, ";
627 OS <<
" constant = " << *ConstantValue;
649 const auto &OU = cast<UnknownExpression>(
Other);
650 return Inst == OU.Inst;
660 OS <<
"ExpressionTypeUnknown, ";
662 OS <<
" inst = " << *Inst;
This file defines the BumpPtrAllocator interface.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
mir Rename Register Operands
This file exposes an interface to building/using memory SSA to walk memory instructions using a use/d...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
The size of an allocated array is represented by a Capacity instance.
static Capacity get(size_t N)
Get the capacity of an array that can hold at least N elements.
Recycle small arrays allocated from a BumpPtrAllocator.
LLVM Basic Block Representation.
Allocate memory in an ever growing pool, as if by bump-pointer.
This class represents a function call, abstracting a target machine's calling convention.
This is an important base class in LLVM.
int_arg_iterator int_op_begin()
AggregateValueExpression()=delete
unsigned int_op_size() const
static bool classof(const Expression *EB)
~AggregateValueExpression() override
AggregateValueExpression(const AggregateValueExpression &)=delete
bool equals(const Expression &Other) const override
void printInternal(raw_ostream &OS, bool PrintEType) const override
bool int_op_empty() const
AggregateValueExpression(unsigned NumOperands, unsigned NumIntOperands)
void int_op_push_back(unsigned IntOperand)
virtual void allocateIntOperands(BumpPtrAllocator &Allocator)
const_int_arg_iterator int_op_begin() const
hash_code getHashValue() const override
int_arg_iterator int_op_end()
AggregateValueExpression & operator=(const AggregateValueExpression &)=delete
const_int_arg_iterator int_op_end() const
BasicExpression(unsigned NumOperands)
~BasicExpression() override
void allocateOperands(RecyclerType &Recycler, BumpPtrAllocator &Allocator)
iterator_range< const_op_iterator > operands() const
const_op_iterator op_begin() const
Value *const * const_op_iterator
bool equals(const Expression &Other) const override
const_op_iterator op_end() const
void op_push_back(Value *Arg)
BasicExpression(unsigned NumOperands, ExpressionType ET)
BasicExpression & operator=(const BasicExpression &)=delete
hash_code getHashValue() const override
void deallocateOperands(RecyclerType &Recycler)
iterator_range< op_iterator > operands()
void setOperand(unsigned N, Value *V)
void swapOperands(unsigned First, unsigned Second)
Swap two operands.
BasicExpression(const BasicExpression &)=delete
static bool classof(const Expression *EB)
Value * getOperand(unsigned N) const
unsigned getNumOperands() const
void printInternal(raw_ostream &OS, bool PrintEType) const override
CallExpression(const CallExpression &)=delete
bool equals(const Expression &Other) const override
~CallExpression() override
CallExpression & operator=(const CallExpression &)=delete
void printInternal(raw_ostream &OS, bool PrintEType) const override
static bool classof(const Expression *EB)
CallExpression(unsigned NumOperands, CallInst *C, const MemoryAccess *MemoryLeader)
bool exactlyEquals(const Expression &Other) const override
hash_code getHashValue() const override
void printInternal(raw_ostream &OS, bool PrintEType) const override
static bool classof(const Expression *EB)
ConstantExpression & operator=(const ConstantExpression &)=delete
ConstantExpression(const ConstantExpression &)=delete
void setConstantValue(Constant *V)
Constant * getConstantValue() const
bool equals(const Expression &Other) const override
ConstantExpression(Constant *constantValue)
static bool classof(const Expression *E)
DeadExpression(const DeadExpression &)=delete
DeadExpression & operator=(const DeadExpression &)=delete
bool operator==(const Expression &Other) const
virtual hash_code getHashValue() const
Expression & operator=(const Expression &)=delete
virtual bool exactlyEquals(const Expression &Other) const
static unsigned getEmptyKey()
Expression(const Expression &)=delete
Expression(ExpressionType ET=ET_Base, unsigned O=~2U)
bool operator!=(const Expression &Other) const
unsigned getOpcode() const
ExpressionType getExpressionType() const
static unsigned getTombstoneKey()
LLVM_DUMP_METHOD void dump() const
virtual void printInternal(raw_ostream &OS, bool PrintEType) const
hash_code getComputedHash() const
virtual bool equals(const Expression &Other) const
void setOpcode(unsigned opcode)
void print(raw_ostream &OS) const
LoadExpression(const LoadExpression &)=delete
LoadExpression(enum ExpressionType EType, unsigned NumOperands, LoadInst *L, const MemoryAccess *MemoryLeader)
static bool classof(const Expression *EB)
void setLoadInst(LoadInst *L)
bool equals(const Expression &Other) const override
LoadInst * getLoadInst() const
LoadExpression & operator=(const LoadExpression &)=delete
~LoadExpression() override
void printInternal(raw_ostream &OS, bool PrintEType) const override
bool exactlyEquals(const Expression &Other) const override
LoadExpression(unsigned NumOperands, LoadInst *L, const MemoryAccess *MemoryLeader)
void setMemoryLeader(const MemoryAccess *ML)
static bool classof(const Expression *EB)
MemoryExpression()=delete
hash_code getHashValue() const override
MemoryExpression & operator=(const MemoryExpression &)=delete
MemoryExpression(const MemoryExpression &)=delete
MemoryExpression(unsigned NumOperands, enum ExpressionType EType, const MemoryAccess *MemoryLeader)
bool equals(const Expression &Other) const override
const MemoryAccess * getMemoryLeader() const
PHIExpression(const PHIExpression &)=delete
bool equals(const Expression &Other) const override
PHIExpression & operator=(const PHIExpression &)=delete
~PHIExpression() override
PHIExpression(unsigned NumOperands, BasicBlock *B)
void printInternal(raw_ostream &OS, bool PrintEType) const override
hash_code getHashValue() const override
static bool classof(const Expression *EB)
StoreExpression(unsigned NumOperands, StoreInst *S, Value *StoredValue, const MemoryAccess *MemoryLeader)
StoreExpression(const StoreExpression &)=delete
bool exactlyEquals(const Expression &Other) const override
bool equals(const Expression &Other) const override
StoreExpression & operator=(const StoreExpression &)=delete
static bool classof(const Expression *EB)
~StoreExpression() override
void printInternal(raw_ostream &OS, bool PrintEType) const override
StoreInst * getStoreInst() const
Value * getStoredValue() const
hash_code getHashValue() const override
UnknownExpression(const UnknownExpression &)=delete
bool equals(const Expression &Other) const override
void setInstruction(Instruction *I)
static bool classof(const Expression *EB)
UnknownExpression & operator=(const UnknownExpression &)=delete
UnknownExpression(Instruction *I)
UnknownExpression()=delete
void printInternal(raw_ostream &OS, bool PrintEType) const override
Instruction * getInstruction() const
VariableExpression & operator=(const VariableExpression &)=delete
bool equals(const Expression &Other) const override
static bool classof(const Expression *EB)
void setVariableValue(Value *V)
VariableExpression(const VariableExpression &)=delete
Value * getVariableValue() const
VariableExpression(Value *V)
VariableExpression()=delete
void printInternal(raw_ostream &OS, bool PrintEType) const override
hash_code getHashValue() const override
int_op_inserter & operator=(unsigned int val)
int_op_inserter & operator++(int)
std::output_iterator_tag iterator_category
int_op_inserter(AggregateValueExpression &E)
int_op_inserter & operator++()
int_op_inserter(AggregateValueExpression *E)
int_op_inserter & operator*()
op_inserter(BasicExpression &E)
op_inserter & operator++()
op_inserter(BasicExpression *E)
std::output_iterator_tag iterator_category
op_inserter & operator=(Value *val)
op_inserter & operator++(int)
op_inserter & operator*()
An instruction for reading from memory.
Recycler - This class manages a linked-list of deallocated nodes and facilitates reusing deallocated ...
An instruction for storing to memory.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
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.
An opaque object representing a hash code.
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
@ C
The default llvm calling convention, compatible with C.
raw_ostream & operator<<(raw_ostream &OS, const Expression &E)
@ BasicBlock
Various leaf nodes.
This is an optimization pass for GlobalISel generic memory operations.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.