15 #ifndef LLVM_LIB_IR_CONSTANTSCONTEXT_H
16 #define LLVM_LIB_IR_CONSTANTSCONTEXT_H
40 #define DEBUG_TYPE "ir"
54 void *
operator new(
size_t s) {
55 return User::operator
new(s, 1);
74 void *
operator new(
size_t s) {
75 return User::operator
new(s, 2);
94 void *
operator new(
size_t s) {
95 return User::operator
new(s, 3);
115 void *
operator new(
size_t s) {
116 return User::operator
new(s, 2);
137 void *
operator new(
size_t s) {
138 return User::operator
new(s, 3);
162 void *
operator new(
size_t s) {
163 return User::operator
new(s, 3);
183 void *
operator new(
size_t s) {
184 return User::operator
new(s, 1);
194 return CE->
getOpcode() == Instruction::ExtractValue;
197 return isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V));
215 void *
operator new(
size_t s) {
216 return User::operator
new(s, 2);
226 return CE->
getOpcode() == Instruction::InsertValue;
229 return isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V));
259 return CE->
getOpcode() == Instruction::GetElementPtr;
262 return isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V));
280 void *
operator new(
size_t s) {
281 return User::operator
new(s, 2);
288 return CE->
getOpcode() == Instruction::ICmp ||
292 return isa<ConstantExpr>(V) &&
classof(cast<ConstantExpr>(V));
379 : Operands(Operands) {}
383 assert(Storage.
empty() &&
"Expected empty storage");
384 for (
unsigned I = 0,
E = C->getNumOperands();
I !=
E; ++
I)
394 if (
Operands.size() != C->getNumOperands())
424 : AsmString(AsmString), Constraints(Constraints), FTy(FTy),
425 HasSideEffects(HasSideEffects), IsAlignStack(IsAlignStack),
426 AsmDialect(AsmDialect) {}
481 :
Opcode(CE->getOpcode()),
488 :
Opcode(CE->getOpcode()),
492 assert(Storage.
empty() &&
"Expected empty storage");
513 for (
unsigned I = 0,
E =
Ops.size();
I !=
E; ++
I)
534 if ((
Opcode >= Instruction::BinaryOpsBegin &&
535 Opcode < Instruction::BinaryOpsEnd))
541 case Instruction::ExtractElement:
543 case Instruction::InsertElement:
545 case Instruction::ShuffleVector:
547 case Instruction::InsertValue:
549 case Instruction::ExtractValue:
551 case Instruction::GetElementPtr:
554 : cast<PointerType>(
Ops[0]->
getType()->getScalarType())
557 case Instruction::ICmp:
560 case Instruction::FCmp:
567 template <
class ConstantClass>
class ConstantUniqueMap {
580 static inline ConstantClass *getEmptyKey() {
581 return ConstantClassInfo::getEmptyKey();
584 static inline ConstantClass *getTombstoneKey() {
585 return ConstantClassInfo::getTombstoneKey();
588 static unsigned getHashValue(
const ConstantClass *
CP) {
593 static bool isEqual(
const ConstantClass *LHS,
const ConstantClass *RHS) {
597 static unsigned getHashValue(
const LookupKey &Val) {
606 if (RHS == getEmptyKey() || RHS == getTombstoneKey())
608 if (LHS.first != RHS->getType())
610 return LHS.second == RHS;
614 return isEqual(LHS.second, RHS);
635 ConstantClass *Result = V.create(Ty);
637 assert(Result->getType() == Ty &&
"Type specified is not correct!");
650 ConstantClass *Result =
nullptr;
654 Result = create(Ty, V, Lookup);
657 assert(Result &&
"Unexpected nullptr");
663 void remove(ConstantClass *
CP) {
665 assert(I != Map.
end() &&
"Constant not found in constant table!");
666 assert(*I ==
CP &&
"Didn't find correct element?");
671 ConstantClass *
CP,
Value *From,
672 Constant *To,
unsigned NumUpdated = 0,
673 unsigned OperandNo = ~0u) {
685 if (NumUpdated == 1) {
686 assert(OperandNo < CP->getNumOperands() &&
"Invalid index");
687 assert(CP->getOperand(OperandNo) != To &&
"I didn't contain From!");
688 CP->setOperand(OperandNo, To);
690 for (
unsigned I = 0,
E = CP->getNumOperands();
I !=
E; ++
I)
691 if (CP->getOperand(
I) == From)
692 CP->setOperand(
I, To);
703 #endif // LLVM_LIB_IR_CONSTANTSCONTEXT_H
InsertElementConstantExpr(Constant *C1, Constant *C2, Constant *C3)
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
void push_back(const T &Elt)
const_iterator end(StringRef path)
Get end iterator over path.
AsmDialect getDialect() const
uint8_t SubclassOptionalData
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
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)
ConstantInfo< InlineAsm >::TypeClass TypeClass
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
static bool classof(const ConstantExpr *CE)
unsigned getNumOperands() const
bool operator==(const InlineAsmKeyType &X) const
const std::string & getAsmString() const
typename ConstantInfo< llvm::ConstantExpr >::TypeClass TypeClass
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 std::string & getConstraintString() const
InlineAsmKeyType(StringRef AsmString, StringRef Constraints, FunctionType *FTy, bool HasSideEffects, bool IsAlignStack, InlineAsm::AsmDialect AsmDialect)
unsigned getOpcode() const
Return the opcode at the root of this constant expression.
ConstantExprKeyType(const ConstantExpr *CE, SmallVectorImpl< Constant * > &Storage)
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)
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.
UnaryConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to implemen...
static bool classof(const Value *V)
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...
typename ConstantInfo< llvm::ConstantExpr >::ValType ValType
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...
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
static wasm::ValType getType(const TargetRegisterClass *RC)
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.
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 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.
llvm_unreachable("Unknown RegBank!")
bool operator==(const ConstantClass *C) const
static std::vector< std::string > Flags
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
iterator find(const_arg_type_t< ValueT > V)
Compile-time customization of User operands.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.
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...
std::pair< TypeClass *, ValType > LookupKey
SelectConstantExpr(Constant *C1, Constant *C2, Constant *C3)
bool isAlignStack() const
static bool classof(const ConstantExpr *CE)
static bool classof(const ConstantExpr *CE)