14 #ifndef LLVM_LIB_IR_CONSTANTSCONTEXT_H 15 #define LLVM_LIB_IR_CONSTANTSCONTEXT_H 39 #define DEBUG_TYPE "ir" 53 void *
operator new(
size_t s) {
54 return User::operator
new(s, 1);
73 void *
operator new(
size_t s) {
74 return User::operator
new(s, 2);
93 void *
operator new(
size_t s) {
94 return User::operator
new(s, 3);
114 void *
operator new(
size_t s) {
115 return User::operator
new(s, 2);
136 void *
operator new(
size_t s) {
137 return User::operator
new(s, 3);
161 void *
operator new(
size_t s) {
162 return User::operator
new(s, 3);
177 Indices(IdxList.
begin(), IdxList.
end()) {
182 void *
operator new(
size_t s) {
183 return User::operator
new(s, 1);
193 return CE->
getOpcode() == Instruction::ExtractValue;
196 return isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V));
208 Indices(IdxList.
begin(), IdxList.
end()) {
214 void *
operator new(
size_t s) {
215 return User::operator
new(s, 2);
225 return CE->
getOpcode() == Instruction::InsertValue;
228 return isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V));
244 Type *DestTy,
unsigned Flags) {
251 Type *getSourceElementType()
const;
252 Type *getResultElementType()
const;
258 return CE->
getOpcode() == Instruction::GetElementPtr;
261 return isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V));
279 void *
operator new(
size_t s) {
280 return User::operator
new(s, 2);
287 return CE->
getOpcode() == Instruction::ICmp ||
291 return isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V));
378 : Operands(Operands) {}
382 assert(Storage.
empty() &&
"Expected empty storage");
383 for (
unsigned I = 0,
E = C->getNumOperands();
I !=
E; ++
I)
393 if (Operands.
size() != C->getNumOperands())
395 for (
unsigned I = 0,
E = Operands.
size();
I !=
E; ++
I)
396 if (Operands[
I] != C->getOperand(
I))
408 return new (Operands.
size()) ConstantClass(Ty, Operands);
421 FunctionType *FTy,
bool HasSideEffects,
bool IsAlignStack,
423 : AsmString(AsmString), Constraints(Constraints), FTy(FTy),
424 HasSideEffects(HasSideEffects), IsAlignStack(IsAlignStack),
425 AsmDialect(AsmDialect) {}
428 : AsmString(Asm->getAsmString()), Constraints(Asm->getConstraintString()),
429 FTy(Asm->getFunctionType()), HasSideEffects(Asm->hasSideEffects()),
430 IsAlignStack(Asm->isAlignStack()), AsmDialect(Asm->getDialect()) {}
449 return hash_combine(AsmString, Constraints, HasSideEffects, IsAlignStack,
457 return new InlineAsm(FTy, AsmString, Constraints, HasSideEffects,
458 IsAlignStack, AsmDialect);
471 unsigned short SubclassData = 0,
472 unsigned short SubclassOptionalData = 0,
474 Type *ExplicitTy =
nullptr)
475 : Opcode(Opcode), SubclassOptionalData(SubclassOptionalData),
476 SubclassData(SubclassData), Ops(Ops), Indexes(Indexes),
477 ExplicitTy(ExplicitTy) {}
484 ExplicitTy(nullptr) {}
492 ExplicitTy(nullptr) {
493 assert(Storage.
empty() &&
"Expected empty storage");
514 for (
unsigned I = 0,
E = Ops.
size();
I !=
E; ++
I)
523 return hash_combine(Opcode, SubclassOptionalData, SubclassData,
534 (Opcode >= Instruction::UnaryOpsBegin &&
535 Opcode < Instruction::UnaryOpsEnd))
537 if ((Opcode >= Instruction::BinaryOpsBegin &&
538 Opcode < Instruction::BinaryOpsEnd))
539 return new BinaryConstantExpr(Opcode, Ops[0], Ops[1],
540 SubclassOptionalData);
543 return new SelectConstantExpr(Ops[0], Ops[1], Ops[2]);
544 case Instruction::ExtractElement:
545 return new ExtractElementConstantExpr(Ops[0], Ops[1]);
546 case Instruction::InsertElement:
547 return new InsertElementConstantExpr(Ops[0], Ops[1], Ops[2]);
548 case Instruction::ShuffleVector:
549 return new ShuffleVectorConstantExpr(Ops[0], Ops[1], Ops[2]);
550 case Instruction::InsertValue:
551 return new InsertValueConstantExpr(Ops[0], Ops[1], Indexes, Ty);
552 case Instruction::ExtractValue:
553 return new ExtractValueConstantExpr(Ops[0], Indexes, Ty);
554 case Instruction::GetElementPtr:
556 ExplicitTy ? ExplicitTy
557 : cast<PointerType>(Ops[0]->
getType()->getScalarType())
560 case Instruction::ICmp:
561 return new CompareConstantExpr(Ty, Instruction::ICmp, SubclassData,
563 case Instruction::FCmp:
564 return new CompareConstantExpr(Ty, Instruction::FCmp, SubclassData,
583 static inline ConstantClass *getEmptyKey() {
584 return ConstantClassInfo::getEmptyKey();
587 static inline ConstantClass *getTombstoneKey() {
588 return ConstantClassInfo::getTombstoneKey();
591 static unsigned getHashValue(
const ConstantClass *
CP) {
596 static bool isEqual(
const ConstantClass *LHS,
const ConstantClass *RHS) {
600 static unsigned getHashValue(
const LookupKey &Val) {
609 if (RHS == getEmptyKey() || RHS == getTombstoneKey())
611 if (LHS.first != RHS->getType())
613 return LHS.second == RHS;
617 return isEqual(LHS.second, RHS);
638 ConstantClass *Result = V.create(Ty);
640 assert(Result->getType() == Ty &&
"Type specified is not correct!");
653 ConstantClass *Result =
nullptr;
657 Result = create(Ty, V, Lookup);
660 assert(Result &&
"Unexpected nullptr");
666 void remove(ConstantClass *
CP) {
668 assert(I != Map.
end() &&
"Constant not found in constant table!");
669 assert(*I ==
CP &&
"Didn't find correct element?");
675 Constant *To,
unsigned NumUpdated = 0,
676 unsigned OperandNo = ~0u) {
681 auto ItMap = Map.
find_as(Lookup);
682 if (ItMap != Map.
end())
688 if (NumUpdated == 1) {
690 assert(CP->getOperand(OperandNo) != To &&
"I didn't contain From!");
691 CP->setOperand(OperandNo, To);
693 for (
unsigned I = 0,
E = CP->getNumOperands();
I !=
E; ++
I)
694 if (CP->getOperand(
I) ==
From)
695 CP->setOperand(
I, To);
708 #endif // LLVM_LIB_IR_CONSTANTSCONTEXT_H InsertElementConstantExpr(Constant *C1, Constant *C2, Constant *C3)
const_iterator end(StringRef path)
Get end iterator over path.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
uint8_t SubclassOptionalData
unsigned getOpcode() const
Return the opcode at the root of this constant expression.
bool operator==(const InlineAsm *Asm) const
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
This class represents lattice values for constants.
ConstantInfo< InlineAsm >::TypeClass TypeClass
static bool classof(const ConstantExpr *CE)
void push_back(const T &Elt)
const std::string & getAsmString() const
typename ConstantInfo< llvm::ConstantExpr >::TypeClass TypeClass
ShuffleVectorConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to ...
bool erase(const ValueT &V)
friend struct ConstantExprKeyType
InlineAsmKeyType(StringRef AsmString, StringRef Constraints, FunctionType *FTy, bool HasSideEffects, bool IsAlignStack, InlineAsm::AsmDialect AsmDialect)
bool operator==(const InlineAsmKeyType &X) const
unsigned getPredicate() const
Return the ICMP or FCMP predicate value.
bool hasSideEffects() const
ConstantClass * replaceOperandsInPlace(ArrayRef< Constant *> Operands, ConstantClass *CP, Value *From, Constant *To, unsigned NumUpdated=0, unsigned OperandNo=~0u)
Class to represent struct types.
static int Lookup(ArrayRef< TableEntry > Table, unsigned Opcode)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
CompareConstantExpr(Type *ty, Instruction::OtherOps opc, unsigned short pred, Constant *LHS, Constant *RHS)
mir Rename Register Operands
ArrayRef< Constant * > Operands
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
Class to represent function types.
A constant value that is initialized with an expression using other constant values.
UnaryConstantExpr(unsigned Opcode, Constant *C, Type *Ty)
Type * getType() const
All values are typed, get the type of this value.
const SmallVector< unsigned, 4 > Indices
Indices - These identify the position for the insertion.
Class to represent array types.
static bool classof(const Value *V)
std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type cast(const Y &Val)
Value * getOperand(unsigned i) const
Class to represent pointers.
UnaryConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to implemen...
ConstantExprKeyType(const ConstantExpr *CE, SmallVectorImpl< Constant *> &Storage)
unsigned getRawSubclassOptionalData() const
Return the raw optional flags value contained in this value.
static bool classof(const Value *V)
bool operator==(const ConstantClass *C) const
static GetElementPtrConstantExpr * Create(Type *SrcElementTy, Constant *C, ArrayRef< Constant *> IdxList, Type *DestTy, unsigned Flags)
InsertValueConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to im...
std::pair< iterator, bool > insert_as(const ValueT &V, const LookupKeyT &LookupKey)
Alternative version of insert that uses a different (and possibly less expensive) key type...
The instances of the Type class are immutable: once they are created, they are never changed...
typename ConstantInfo< llvm::ConstantExpr >::ValType ValType
ArrayRef< Constant * > Ops
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
bool hasIndices() const
Return true if this is an insertvalue or extractvalue expression, and the getIndices() method may be ...
ArrayRef< unsigned > Indexes
iterator find_as(const LookupKeyT &Val)
Alternative version of find() which allows a different, and possibly less expensive, key type.
bool operator==(const ConstantExpr *CE) const
BinaryConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to impleme...
ConstantExprKeyType(ArrayRef< Constant *> Operands, const ConstantExpr *CE)
InsertElementConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to ...
Constant Vector Declarations.
ConstantExprKeyType(unsigned Opcode, ArrayRef< Constant *> Ops, unsigned short SubclassData=0, unsigned short SubclassOptionalData=0, ArrayRef< unsigned > Indexes=None, Type *ExplicitTy=nullptr)
bool operator==(const ConstantExprKeyType &X) const
SelectConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to impleme...
ShuffleVectorConstantExpr(Constant *C1, Constant *C2, Constant *C3)
InlineAsm::AsmDialect AsmDialect
bool isAlignStack() const
ConstantAggrKeyType(const ConstantClass *C, SmallVectorImpl< Constant *> &Storage)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const std::string & getConstraintString() const
unsigned char SubclassOptionalData
Hold subclass data that can be dropped.
std::pair< unsigned, LookupKey > LookupKeyHashed
Key and hash together, so that we compute the hash only once and reuse it.
unsigned getNumOperands() const
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the generic address space (address sp...
BlockVerifier::State From
ConstantAggrKeyType(ArrayRef< Constant *> Operands)
InsertValueConstantExpr(Constant *Agg, Constant *Val, ArrayRef< unsigned > IdxList, Type *DestTy)
InlineAsmKeyType(const InlineAsm *Asm, SmallVectorImpl< Constant *> &)
ConstantAggrKeyType(ArrayRef< Constant *> Operands, const ConstantClass *)
static bool classof(const Value *V)
Methods for support type inquiry through isa, cast, and dyn_cast:
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
ConstantClass * create(TypeClass *Ty) const
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Class to represent vector types.
ConstantArray - Constant Array Declarations.
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
GetElementPtrConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to ...
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array...
BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2, unsigned Flags)
LLVM_NODISCARD bool empty() const
iterator find(const_arg_type_t< ValueT > V)
bool isCompare() const
Return true if this is a compare constant expression.
Compile-time customization of User operands.
FunctionType * getFunctionType() const
getFunctionType - InlineAsm's are always pointers to functions.
ArrayRef< unsigned > getIndices() const
Assert that this is an insertvalue or exactvalue expression and return the list of indices...
AsmDialect getDialect() const
InlineAsm * create(TypeClass *Ty) const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ConstantExpr * create(TypeClass *Ty) const
static bool classof(const Value *V)
LLVM Value Representation.
ConstantInfo< ConstantExpr >::TypeClass TypeClass
typename ConstantInfo< ConstantClass >::TypeClass TypeClass
ConstantClass * getOrCreate(TypeClass *Ty, ValType V)
Return the specified constant from the map, creating it if necessary.
bool isEqual(const GCNRPTracker::LiveRegSet &S1, const GCNRPTracker::LiveRegSet &S2)
StringRef - Represent a constant reference to a string, i.e.
FixedNumOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
VariadicOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
std::pair< TypeClass *, ValType > LookupKey
SelectConstantExpr(Constant *C1, Constant *C2, Constant *C3)
bool operator==(const ConstantAggrKeyType &X) const
static bool classof(const ConstantExpr *CE)
static bool classof(const ConstantExpr *CE)
static Constant * get(unsigned Opcode, Constant *C1, unsigned Flags=0, Type *OnlyIfReducedTy=nullptr)
get - Return a unary operator constant expression, folding if possible.