15 #ifndef LLVM_LIB_IR_CONSTANTSCONTEXT_H
16 #define LLVM_LIB_IR_CONSTANTSCONTEXT_H
39 #define DEBUG_TYPE "ir"
46 void anchor()
override;
55 void *
operator new(
size_t s) {
56 return User::operator
new(s, 1);
59 void *
operator new(size_t,
unsigned) =
delete;
67 void anchor()
override;
79 void *
operator new(
size_t s) {
80 return User::operator
new(s, 2);
83 void *
operator new(size_t,
unsigned) =
delete;
92 void anchor()
override;
103 void *
operator new(
size_t s) {
104 return User::operator
new(s, 3);
107 void *
operator new(size_t,
unsigned) =
delete;
117 void anchor()
override;
128 void *
operator new(
size_t s) {
129 return User::operator
new(s, 2);
132 void *
operator new(size_t,
unsigned) =
delete;
142 void anchor()
override;
154 void *
operator new(
size_t s) {
155 return User::operator
new(s, 3);
158 void *
operator new(size_t,
unsigned) =
delete;
168 void anchor()
override;
183 void *
operator new(
size_t s) {
184 return User::operator
new(s, 3);
187 void *
operator new(size_t,
unsigned) =
delete;
197 void anchor()
override;
208 void *
operator new(
size_t s) {
209 return User::operator
new(s, 1);
212 void *
operator new(size_t,
unsigned) =
delete;
221 return CE->
getOpcode() == Instruction::ExtractValue;
224 return isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V));
232 void anchor()
override;
244 void *
operator new(
size_t s) {
245 return User::operator
new(s, 2);
248 void *
operator new(size_t,
unsigned) =
delete;
257 return CE->
getOpcode() == Instruction::InsertValue;
260 return isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V));
273 void anchor()
override;
292 return CE->
getOpcode() == Instruction::GetElementPtr;
295 return isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V));
303 void anchor()
override;
315 void *
operator new(
size_t s) {
316 return User::operator
new(s, 2);
319 void *
operator new(size_t,
unsigned) =
delete;
325 return CE->
getOpcode() == Instruction::ICmp ||
329 return isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V));
414 : Operands(Operands) {}
417 assert(Storage.
empty() &&
"Expected empty storage");
418 for (
unsigned I = 0,
E = C->getNumOperands();
I !=
E; ++
I)
428 if (
Operands.size() != C->getNumOperands())
457 : AsmString(AsmString), Constraints(Constraints), FTy(FTy),
458 HasSideEffects(HasSideEffects), IsAlignStack(IsAlignStack),
459 AsmDialect(AsmDialect) {}
511 :
Opcode(CE->getOpcode()),
517 :
Opcode(CE->getOpcode()),
521 assert(Storage.
empty() &&
"Expected empty storage");
542 for (
unsigned I = 0,
E =
Ops.size();
I !=
E; ++
I)
562 if ((
Opcode >= Instruction::BinaryOpsBegin &&
563 Opcode < Instruction::BinaryOpsEnd))
569 case Instruction::ExtractElement:
571 case Instruction::InsertElement:
573 case Instruction::ShuffleVector:
575 case Instruction::InsertValue:
577 case Instruction::ExtractValue:
579 case Instruction::GetElementPtr:
582 : cast<PointerType>(
Ops[0]->
getType()->getScalarType())
585 case Instruction::ICmp:
588 case Instruction::FCmp:
595 template <
class ConstantClass>
class ConstantUniqueMap {
607 static inline ConstantClass *getEmptyKey() {
608 return ConstantClassInfo::getEmptyKey();
611 static inline ConstantClass *getTombstoneKey() {
612 return ConstantClassInfo::getTombstoneKey();
615 static unsigned getHashValue(
const ConstantClass *
CP) {
620 static bool isEqual(
const ConstantClass *LHS,
const ConstantClass *RHS) {
624 static unsigned getHashValue(
const LookupKey &Val) {
633 if (RHS == getEmptyKey() || RHS == getTombstoneKey())
635 if (LHS.first != RHS->getType())
637 return LHS.second == RHS;
641 return isEqual(LHS.second, RHS);
662 ConstantClass *Result = V.create(Ty);
664 assert(Result->getType() == Ty &&
"Type specified is not correct!");
677 ConstantClass *Result =
nullptr;
681 Result = create(Ty, V, Lookup);
684 assert(Result &&
"Unexpected nullptr");
690 void remove(ConstantClass *
CP) {
692 assert(I != Map.
end() &&
"Constant not found in constant table!");
693 assert(*I ==
CP &&
"Didn't find correct element?");
698 ConstantClass *
CP,
Value *From,
699 Constant *To,
unsigned NumUpdated = 0,
700 unsigned OperandNo = ~0u) {
712 if (NumUpdated == 1) {
713 assert(OperandNo < CP->getNumOperands() &&
"Invalid index");
714 assert(CP->getOperand(OperandNo) != To &&
"I didn't contain From!");
715 CP->setOperand(OperandNo, To);
717 for (
unsigned I = 0,
E = CP->getNumOperands();
I !=
E; ++
I)
718 if (CP->getOperand(
I) == From)
719 CP->setOperand(
I, To);
730 #endif // LLVM_LIB_IR_CONSTANTSCONTEXT_H
InsertElementConstantExpr(Constant *C1, Constant *C2, Constant *C3)
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
ConstantInfo< ConstantExpr >::TypeClass TypeClass
void push_back(const T &Elt)
ConstantAggrKeyType< ConstantArray > ValType
const_iterator end(StringRef path)
Get end iterator over path.
AsmDialect getDialect() const
ConstantInfo< InlineAsm >::TypeClass TypeClass
uint8_t SubclassOptionalData
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
ConstantExprKeyType(unsigned Opcode, ArrayRef< Constant * > Ops, unsigned short SubclassData=0, unsigned short SubclassOptionalData=0, ArrayRef< unsigned > Indexes=None, Type *ExplicitTy=nullptr)
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
iterator find(const ValueT &V)
static bool classof(const ConstantExpr *CE)
unsigned getNumOperands() const
bool operator==(const InlineAsmKeyType &X) const
const std::string & getAsmString() const
Type * getResultElementType() const
ConstantAggrKeyType(ArrayRef< Constant * > Operands, const ConstantClass *)
ShuffleVectorConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to ...
bool erase(const ValueT &V)
const_iterator begin(StringRef path)
Get begin iterator over path.
const std::string & getConstraintString() const
InlineAsmKeyType(StringRef AsmString, StringRef Constraints, FunctionType *FTy, bool HasSideEffects, bool IsAlignStack, InlineAsm::AsmDialect AsmDialect)
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys=None)
Return the function type for an intrinsic.
std::pair< unsigned, LookupKey > LookupKeyHashed
Key and hash together, so that we compute the hash only once and reuse it.
unsigned getOpcode() const
Return the opcode at the root of this constant expression.
DenseSet< ConstantClass *, MapInfo > MapTy
ConstantInfo< ConstantClass >::TypeClass TypeClass
ConstantExprKeyType(const ConstantExpr *CE, SmallVectorImpl< Constant * > &Storage)
struct fuzzer::@269 Flags
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)
LLVM_NODISCARD bool empty() const
ArrayRef< Constant * > Operands
static Constant * get(unsigned Opcode, Constant *C1, Constant *C2, unsigned Flags=0, Type *OnlyIfReducedTy=nullptr)
get - Return a binary or shift operator constant expression, folding if possible. ...
#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)
ConstantExprKeyType(ArrayRef< Constant * > Operands, const ConstantExpr *CE)
const SmallVector< unsigned, 4 > Indices
Indices - These identify the position for the insertion.
bool operator==(const ConstantAggrKeyType &X) const
static bool isEqual(const Function &Caller, const Function &Callee)
std::pair< TypeClass *, ValType > LookupKey
Class to represent array types.
static bool classof(const Value *V)
bool operator==(const ConstantExprKeyType &X) const
size_t size() const
size - Get the array size.
std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type cast(const Y &Val)
Class to represent pointers.
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
UnaryConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to implemen...
static bool classof(const Value *V)
ConstantExprKeyType ValType
InsertValueConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to im...
ConstantAggrKeyType(const ConstantClass *C, SmallVectorImpl< Constant * > &Storage)
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...
bool hasSideEffects() const
InlineAsmKeyType(const InlineAsm *Asm, SmallVectorImpl< Constant * > &)
The instances of the Type class are immutable: once they are created, they are never changed...
ConstantClass * create(TypeClass *Ty) const
ArrayRef< Constant * > Ops
This is an important base class in LLVM.
bool hasIndices() const
Return true if this is an insertvalue or extractvalue expression, and the getIndices() method may be ...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
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
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
BinaryConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to impleme...
Value * getOperand(unsigned i) const
ConstantClass * replaceOperandsInPlace(ArrayRef< Constant * > Operands, ConstantClass *CP, Value *From, Constant *To, unsigned NumUpdated=0, unsigned OperandNo=~0u)
InsertElementConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to ...
Constant Vector Declarations.
unsigned getPredicate() const
Return the ICMP or FCMP predicate value.
ArrayRef< unsigned > getIndices() const
Assert that this is an insertvalue or exactvalue expression and return the list of indices...
ConstantAggrKeyType< ConstantStruct > ValType
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
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned char SubclassOptionalData
Hold subclass data that can be dropped.
bool isCompare() const
Return true if this is a compare constant expression.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
FunctionType * getFunctionType() const
getFunctionType - InlineAsm's are always pointers to functions.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the generic address space (address sp...
InsertValueConstantExpr(Constant *Agg, Constant *Val, ArrayRef< unsigned > IdxList, Type *DestTy)
ConstantExpr * create(TypeClass *Ty) const
Type * getType() const
All values are typed, get the type of this value.
InlineAsm * create(TypeClass *Ty) const
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
static GetElementPtrConstantExpr * Create(Type *SrcElementTy, Constant *C, ArrayRef< Constant * > IdxList, Type *DestTy, unsigned Flags)
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.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
bool operator==(const ConstantClass *C) const
ConstantAggrKeyType(ArrayRef< Constant * > Operands)
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2, unsigned Flags)
unsigned getRawSubclassOptionalData() const
Return the raw optional flags value contained in this value.
Type * getSourceElementType() const
ConstantAggrKeyType< ConstantVector > ValType
Compile-time customization of User operands.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool classof(const Value *V)
ConstantInfo< ConstantClass >::TypeClass TypeClass
LLVM Value Representation.
ConstantClass * getOrCreate(TypeClass *Ty, ValType V)
Return the specified constant from the map, creating it if necessary.
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...
bool operator==(const InlineAsm *Asm) const
VariadicOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
SelectConstantExpr(Constant *C1, Constant *C2, Constant *C3)
bool isAlignStack() const
static bool classof(const ConstantExpr *CE)
static bool classof(const ConstantExpr *CE)
ConstantInfo< ConstantClass >::ValType ValType