Go to the documentation of this file.
16 #ifndef LLVM_TRANSFORMS_SCALAR_GVNEXPRESSION_H
17 #define LLVM_TRANSFORMS_SCALAR_GVNEXPRESSION_H
40 namespace GVNExpression {
68 : EType(ET), Opcode(
O) {}
95 if (
static_cast<unsigned>(HashVal) == 0)
119 OS <<
"opcode = " <<
getOpcode() <<
", ";
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 OS <<
"ExpressionTypeCall, ";
323 OS <<
" represents call at ";
324 Call->printAsOperand(OS);
362 OS <<
"ExpressionTypeLoad, ";
364 OS <<
" represents Load at ";
365 Load->printAsOperand(OS);
379 StoredValue(StoredValue) {}
402 OS <<
"ExpressionTypeStore, ";
404 OS <<
" represents Store " << *Store;
405 OS <<
" with StoredValue ";
413 unsigned MaxIntOperands;
414 unsigned NumIntOperands = 0;
415 unsigned *IntOperands =
nullptr;
420 MaxIntOperands(NumIntOperands) {}
438 return IntOperands + NumIntOperands;
443 assert(NumIntOperands < MaxIntOperands &&
444 "Tried to add too many int operands");
445 assert(IntOperands &&
"Operands not allocated before pushing");
446 IntOperands[NumIntOperands++] = IntOperand;
450 assert(!IntOperands &&
"Operands already allocated");
451 IntOperands =
Allocator.Allocate<
unsigned>(MaxIntOperands);
458 return NumIntOperands == OE.NumIntOperands &&
470 OS <<
"ExpressionTypeAggregateValue, ";
472 OS <<
", intoperands = {";
474 OS <<
"[" <<
i <<
"] = " << IntOperands[
i] <<
" ";
535 OS <<
"ExpressionTypePhi, ";
548 return E->getExpressionType() ==
ET_Dead;
554 Value *VariableValue;
571 return VariableValue ==
OC.VariableValue;
576 VariableValue->
getType(), VariableValue);
582 OS <<
"ExpressionTypeVariable, ";
584 OS <<
" variable = " << *VariableValue;
608 return ConstantValue ==
OC.ConstantValue;
613 ConstantValue->
getType(), ConstantValue);
619 OS <<
"ExpressionTypeConstant, ";
621 OS <<
" constant = " << *ConstantValue;
643 const auto &OU = cast<UnknownExpression>(
Other);
644 return Inst == OU.Inst;
654 OS <<
"ExpressionTypeUnknown, ";
656 OS <<
" inst = " << *Inst;
664 #endif // LLVM_TRANSFORMS_SCALAR_GVNEXPRESSION_H
int_op_inserter & operator=(unsigned int val)
op_inserter(BasicExpression *E)
static bool classof(const Expression *EB)
MemoryExpression(unsigned NumOperands, enum ExpressionType EType, const MemoryAccess *MemoryLeader)
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
void swapOperands(unsigned First, unsigned Second)
Swap two operands.
This is an optimization pass for GlobalISel generic memory operations.
static unsigned getEmptyKey()
ExpressionType getExpressionType() const
bool equals(const Expression &Other) const override
CallExpression(unsigned NumOperands, CallInst *C, const MemoryAccess *MemoryLeader)
void printInternal(raw_ostream &OS, bool PrintEType) const override
virtual hash_code getHashValue() const
UnknownExpression()=delete
unsigned getOpcode() const
static bool classof(const Expression *EB)
void setMemoryLeader(const MemoryAccess *ML)
bool int_op_empty() const
Value * getVariableValue() const
virtual void printInternal(raw_ostream &OS, bool PrintEType) const
raw_ostream & operator<<(raw_ostream &OS, const Expression &E)
MemoryExpression & operator=(const MemoryExpression &)=delete
AggregateValueExpression(unsigned NumOperands, unsigned NumIntOperands)
StoreExpression(unsigned NumOperands, StoreInst *S, Value *StoredValue, const MemoryAccess *MemoryLeader)
bool equals(const Expression &Other) const override
static Capacity get(size_t N)
Get the capacity of an array that can hold at least N elements.
The instances of the Type class are immutable: once they are created, they are never changed.
static bool classof(const Expression *E)
void setOperand(unsigned N, Value *V)
bool operator==(const Expression &Other) const
~StoreExpression() override
int_op_inserter(AggregateValueExpression *E)
virtual bool equals(const Expression &Other) const
static bool classof(const Expression *EB)
std::output_iterator_tag iterator_category
static bool classof(const Expression *EB)
PHIExpression & operator=(const PHIExpression &)=delete
~CallExpression() override
bool equals(const Expression &Other) const override
LLVM Basic Block Representation.
int_op_inserter & operator++(int)
static bool classof(const Expression *EB)
LoadExpression(enum ExpressionType EType, unsigned NumOperands, LoadInst *L, const MemoryAccess *MemoryLeader)
UnknownExpression(Instruction *I)
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
void setLoadInst(LoadInst *L)
Value * getStoredValue() const
AggregateValueExpression()=delete
void printInternal(raw_ostream &OS, bool PrintEType) const override
Value *const * const_op_iterator
void print(raw_ostream &OS) const
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
iterator_range< op_iterator > operands()
int_op_inserter(AggregateValueExpression &E)
(vector float) vec_cmpeq(*A, *B) C
static bool classof(const Expression *EB)
Instruction * getInstruction() const
bool equals(const Expression &Other) const override
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
into llvm powi allowing the code generator to produce balanced multiplication trees First
PHIExpression(unsigned NumOperands, BasicBlock *B)
CallExpression & operator=(const CallExpression &)=delete
MemoryExpression()=delete
int_arg_iterator int_op_begin()
bool exactlyEquals(const Expression &Other) const override
This class implements an extremely fast bulk output stream that can only output to a stream.
~BasicExpression() override
hash_code getHashValue() const override
Value * getOperand(unsigned N) const
BasicExpression(unsigned NumOperands)
~PHIExpression() override
op_inserter & operator*()
Expression & operator=(const Expression &)=delete
void op_push_back(Value *Arg)
void printInternal(raw_ostream &OS, bool PrintEType) const override
op_inserter & operator++(int)
LoadExpression & operator=(const LoadExpression &)=delete
void printInternal(raw_ostream &OS, bool PrintEType) const override
mir Rename Register Operands
virtual bool exactlyEquals(const Expression &Other) const
iterator_range< const_op_iterator > operands() const
void printInternal(raw_ostream &OS, bool PrintEType) const override
The initial backend is deliberately restricted to z10 We should add support for later architectures at some point If an asm ties an i32 r result to an i64 the input will be treated as an leaving the upper bits uninitialised For i64 store i32 val
op_inserter(BasicExpression &E)
const_int_arg_iterator int_op_end() const
int_arg_iterator int_op_end()
static bool classof(const Expression *EB)
An instruction for storing to memory.
void deallocateOperands(RecyclerType &Recycler)
This is an important base class in LLVM.
bool equals(const Expression &Other) const override
void setInstruction(Instruction *I)
hash_code getHashValue() const override
AggregateValueExpression & operator=(const AggregateValueExpression &)=delete
hash_code getComputedHash() const
~AggregateValueExpression() override
BasicExpression & operator=(const BasicExpression &)=delete
LoadInst * getLoadInst() const
bool exactlyEquals(const Expression &Other) const override
Allocate memory in an ever growing pool, as if by bump-pointer.
VariableExpression()=delete
VariableExpression & operator=(const VariableExpression &)=delete
Constant * getConstantValue() const
hash_code getHashValue() const override
static bool classof(const Expression *EB)
DeadExpression & operator=(const DeadExpression &)=delete
bool equals(const Expression &Other) const override
void printInternal(raw_ostream &OS, bool PrintEType) const override
ConstantExpression(Constant *constantValue)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
op_inserter & operator++()
int_op_inserter & operator*()
@ BasicBlock
Various leaf nodes.
hash_code getHashValue() const override
Recycler - This class manages a linked-list of deallocated nodes and facilitates reusing deallocated ...
unsigned getNumOperands() const
StoreExpression & operator=(const StoreExpression &)=delete
void allocateOperands(RecyclerType &Recycler, BumpPtrAllocator &Allocator)
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.
bool equals(const Expression &Other) const override
BasicExpression(unsigned NumOperands, ExpressionType ET)
static unsigned getTombstoneKey()
Type * getType() const
All values are typed, get the type of this value.
const_op_iterator op_begin() const
const_int_arg_iterator int_op_begin() const
bool equals(const Expression &Other) const override
The size of an allocated array is represented by a Capacity instance.
LLVM_DUMP_METHOD void dump() const
virtual void allocateIntOperands(BumpPtrAllocator &Allocator)
hash_code getHashValue() const override
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
An instruction for reading from memory.
Expression(ExpressionType ET=ET_Base, unsigned O=~2U)
VariableExpression(Value *V)
StoreInst * getStoreInst() const
ConstantExpression & operator=(const ConstantExpression &)=delete
Recycle small arrays allocated from a BumpPtrAllocator.
unsigned int_op_size() const
hash_code getHashValue() const override
bool operator!=(const Expression &Other) const
const_op_iterator op_end() const
op_inserter & operator=(Value *val)
hash_code getHashValue() const override
void printInternal(raw_ostream &OS, bool PrintEType) const override
void setOpcode(unsigned opcode)
void printInternal(raw_ostream &OS, bool PrintEType) const override
bool equals(const Expression &Other) const override
int_op_inserter & operator++()
~LoadExpression() override
const unsigned * const_int_arg_iterator
void setConstantValue(Constant *V)
static bool classof(const Expression *EB)
static bool classof(const Expression *EB)
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
const MemoryAccess * getMemoryLeader() const
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
UnknownExpression & operator=(const UnknownExpression &)=delete
A range adaptor for a pair of iterators.
void setVariableValue(Value *V)
void int_op_push_back(unsigned IntOperand)
This class represents a function call, abstracting a target machine's calling convention.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
LoadExpression(unsigned NumOperands, LoadInst *L, const MemoryAccess *MemoryLeader)
unsigned * int_arg_iterator
std::output_iterator_tag iterator_category
void printInternal(raw_ostream &OS, bool PrintEType) const override
LLVM Value Representation.
Optional< std::vector< StOtherPiece > > Other
An opaque object representing a hash code.