LLVM 24.0.0git
ConstantsContext.h
Go to the documentation of this file.
1//===-- ConstantsContext.h - Constants-related Context Interals -*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines various helper methods and classes used by
10// LLVMContextImpl for creating and managing constants.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_IR_CONSTANTSCONTEXT_H
15#define LLVM_LIB_IR_CONSTANTSCONTEXT_H
16
17#include "llvm/ADT/ArrayRef.h"
19#include "llvm/ADT/DenseSet.h"
20#include "llvm/ADT/Hashing.h"
22#include "llvm/ADT/StringRef.h"
23#include "llvm/IR/Constant.h"
24#include "llvm/IR/Constants.h"
27#include "llvm/IR/InlineAsm.h"
28#include "llvm/IR/Instruction.h"
32#include "llvm/Support/Debug.h"
35#include <cassert>
36#include <cstddef>
37#include <cstdint>
38#include <type_traits>
39#include <utility>
40
41#define DEBUG_TYPE "ir"
42
43namespace llvm {
44
45/// CastConstantExpr - This class is private to Constants.cpp, and is used
46/// behind the scenes to implement cast constant exprs.
47class CastConstantExpr final : public ConstantExpr {
48 constexpr static IntrusiveOperandsAllocMarker AllocMarker{1};
49
50public:
51 CastConstantExpr(unsigned Opcode, Constant *C, Type *Ty)
52 : ConstantExpr(Ty, Opcode, AllocMarker) {
53 Op<0>() = C;
54 }
55
56 // allocate space for exactly one operand
57 void *operator new(size_t S) { return User::operator new(S, AllocMarker); }
58 void operator delete(void *Ptr) { User::operator delete(Ptr, AllocMarker); }
59
61
62 static bool classof(const ConstantExpr *CE) {
63 return Instruction::isCast(CE->getOpcode());
64 }
65 static bool classof(const Value *V) {
67 }
68};
69
70/// BinaryConstantExpr - This class is private to Constants.cpp, and is used
71/// behind the scenes to implement binary constant exprs.
72class BinaryConstantExpr final : public ConstantExpr {
73 constexpr static IntrusiveOperandsAllocMarker AllocMarker{2};
74
75public:
76 BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2,
77 unsigned Flags)
78 : ConstantExpr(C1->getType(), Opcode, AllocMarker) {
79 Op<0>() = C1;
80 Op<1>() = C2;
81 assert((Flags & ConstantSubclassBits) == 0 && "invalid flags");
83 }
84
85 // allocate space for exactly two operands
86 void *operator new(size_t S) { return User::operator new(S, AllocMarker); }
87 void operator delete(void *Ptr) { User::operator delete(Ptr, AllocMarker); }
88
89 /// Transparently provide more efficient getOperand methods.
91
92 static bool classof(const ConstantExpr *CE) {
93 return Instruction::isBinaryOp(CE->getOpcode());
94 }
95 static bool classof(const Value *V) {
97 }
98};
99
100/// ExtractElementConstantExpr - This class is private to
101/// Constants.cpp, and is used behind the scenes to implement
102/// extractelement constant exprs.
104 constexpr static IntrusiveOperandsAllocMarker AllocMarker{2};
105
106public:
108 : ConstantExpr(cast<VectorType>(C1->getType())->getElementType(),
109 Instruction::ExtractElement, AllocMarker) {
110 Op<0>() = C1;
111 Op<1>() = C2;
112 }
113
114 // allocate space for exactly two operands
115 void *operator new(size_t S) { return User::operator new(S, AllocMarker); }
116 void operator delete(void *Ptr) { User::operator delete(Ptr, AllocMarker); }
117
118 /// Transparently provide more efficient getOperand methods.
120
121 static bool classof(const ConstantExpr *CE) {
122 return CE->getOpcode() == Instruction::ExtractElement;
123 }
124 static bool classof(const Value *V) {
126 }
127};
128
129/// InsertElementConstantExpr - This class is private to
130/// Constants.cpp, and is used behind the scenes to implement
131/// insertelement constant exprs.
133 constexpr static IntrusiveOperandsAllocMarker AllocMarker{3};
134
135public:
137 : ConstantExpr(C1->getType(), Instruction::InsertElement, AllocMarker) {
138 Op<0>() = C1;
139 Op<1>() = C2;
140 Op<2>() = C3;
141 }
142
143 // allocate space for exactly three operands
144 void *operator new(size_t S) { return User::operator new(S, AllocMarker); }
145 void operator delete(void *Ptr) { User::operator delete(Ptr, AllocMarker); }
146
147 /// Transparently provide more efficient getOperand methods.
149
150 static bool classof(const ConstantExpr *CE) {
151 return CE->getOpcode() == Instruction::InsertElement;
152 }
153 static bool classof(const Value *V) {
155 }
156};
157
158/// ShuffleVectorConstantExpr - This class is private to
159/// Constants.cpp, and is used behind the scenes to implement
160/// shufflevector constant exprs.
162 constexpr static IntrusiveOperandsAllocMarker AllocMarker{2};
163
164public:
167 cast<VectorType>(C1->getType())->getElementType(),
168 Mask.size(), isa<ScalableVectorType>(C1->getType())),
169 Instruction::ShuffleVector, AllocMarker) {
171 "Invalid shuffle vector instruction operands!");
172 Op<0>() = C1;
173 Op<1>() = C2;
174 ShuffleMask.assign(Mask.begin(), Mask.end());
177 }
178
181
182 void *operator new(size_t S) { return User::operator new(S, AllocMarker); }
183 void operator delete(void *Ptr) {
184 return User::operator delete(Ptr, AllocMarker);
185 }
186
187 /// Transparently provide more efficient getOperand methods.
189
190 static bool classof(const ConstantExpr *CE) {
191 return CE->getOpcode() == Instruction::ShuffleVector;
192 }
193 static bool classof(const Value *V) {
195 }
196};
197
198/// GetElementPtrConstantExpr - This class is private to Constants.cpp, and is
199/// used behind the scenes to implement getelementptr constant exprs.
200class GetElementPtrConstantExpr : public ConstantExpr {
201 Type *SrcElementTy;
202 Type *ResElementTy;
203 std::optional<ConstantRange> InRange;
204
205 GetElementPtrConstantExpr(Type *SrcElementTy, Constant *C,
206 ArrayRef<Constant *> IdxList, Type *DestTy,
207 std::optional<ConstantRange> InRange,
209
210public:
211 static GetElementPtrConstantExpr *
212 Create(Type *SrcElementTy, Constant *C, ArrayRef<Constant *> IdxList,
213 Type *DestTy, unsigned Flags, std::optional<ConstantRange> InRange) {
214 IntrusiveOperandsAllocMarker AllocMarker{unsigned(IdxList.size() + 1)};
215 GetElementPtrConstantExpr *Result = new (AllocMarker)
216 GetElementPtrConstantExpr(SrcElementTy, C, IdxList, DestTy,
217 std::move(InRange), AllocMarker);
218 assert((Flags & ConstantSubclassBits) == 0 && "invalid flags");
219 Result->SubclassOptionalData = Flags;
220 return Result;
221 }
222
223 Type *getSourceElementType() const;
224 Type *getResultElementType() const;
225 std::optional<ConstantRange> getInRange() const;
226
227 /// Transparently provide more efficient getOperand methods.
229
230 static bool classof(const ConstantExpr *CE) {
231 return CE->getOpcode() == Instruction::GetElementPtr;
232 }
233 static bool classof(const Value *V) {
235 }
236};
237
238template <>
240 : public FixedNumOperandTraits<CastConstantExpr, 1> {};
242
243template <>
245 : public FixedNumOperandTraits<BinaryConstantExpr, 2> {};
247
248template <>
250 : public FixedNumOperandTraits<ExtractElementConstantExpr, 2> {};
252
253template <>
255 : public FixedNumOperandTraits<InsertElementConstantExpr, 3> {};
257
258template <>
260 : public FixedNumOperandTraits<ShuffleVectorConstantExpr, 2> {};
262
263template <>
265 : public VariadicOperandTraits<GetElementPtrConstantExpr> {};
266
268
269template <class ConstantClass> struct ConstantAggrKeyType;
270struct InlineAsmKeyType;
273
274template <class ConstantClass> struct ConstantInfo;
275template <> struct ConstantInfo<ConstantExpr> {
278};
279template <> struct ConstantInfo<InlineAsm> {
282};
299
300template <class ConstantClass> struct ConstantAggrKeyType {
302
304
307
308 ConstantAggrKeyType(const ConstantClass *C,
310 assert(Storage.empty() && "Expected empty storage");
311 Storage.reserve(C->getNumOperands());
312 for (unsigned I = 0, E = C->getNumOperands(); I != E; ++I)
313 Storage.push_back(C->getOperand(I));
314 Operands = Storage;
315 }
316
317 bool operator==(const ConstantAggrKeyType &X) const {
318 return Operands == X.Operands;
319 }
320
321 bool operator==(const ConstantClass *C) const {
322 if (Operands.size() != C->getNumOperands())
323 return false;
324 for (unsigned I = 0, E = Operands.size(); I != E; ++I)
325 if (Operands[I] != C->getOperand(I))
326 return false;
327 return true;
328 }
329
330 unsigned getHash() const { return hash_combine_range(Operands); }
331
333
334 ConstantClass *create(TypeClass *Ty) const {
336 return new (AllocMarker) ConstantClass(Ty, Operands, AllocMarker);
337 }
338};
339
348
355
357 : AsmString(Asm->getAsmString()), Constraints(Asm->getConstraintString()),
358 FTy(Asm->getFunctionType()), HasSideEffects(Asm->hasSideEffects()),
359 IsAlignStack(Asm->isAlignStack()), AsmDialect(Asm->getDialect()),
360 CanThrow(Asm->canThrow()) {}
361
362 bool operator==(const InlineAsmKeyType &X) const {
363 return HasSideEffects == X.HasSideEffects &&
364 IsAlignStack == X.IsAlignStack && AsmDialect == X.AsmDialect &&
365 AsmString == X.AsmString && Constraints == X.Constraints &&
366 FTy == X.FTy && CanThrow == X.CanThrow;
367 }
368
369 bool operator==(const InlineAsm *Asm) const {
370 return HasSideEffects == Asm->hasSideEffects() &&
371 IsAlignStack == Asm->isAlignStack() &&
372 AsmDialect == Asm->getDialect() &&
373 AsmString == Asm->getAsmString() &&
374 Constraints == Asm->getConstraintString() &&
375 FTy == Asm->getFunctionType() && CanThrow == Asm->canThrow();
376 }
377
382
384
386 assert(PointerType::getUnqual(FTy->getContext()) == Ty);
387 return new InlineAsm(FTy, std::string(AsmString), std::string(Constraints),
389 }
390};
391
393private:
394 uint8_t Opcode;
395 uint8_t SubclassOptionalData;
397 ArrayRef<int> ShuffleMask;
398 Type *ExplicitTy;
399 std::optional<ConstantRange> InRange;
400
401 static ArrayRef<int> getShuffleMaskIfValid(const ConstantExpr *CE) {
402 if (CE->getOpcode() == Instruction::ShuffleVector)
403 return CE->getShuffleMask();
404 return {};
405 }
406
407 static Type *getSourceElementTypeIfValid(const ConstantExpr *CE) {
408 if (auto *GEPCE = dyn_cast<GetElementPtrConstantExpr>(CE))
409 return GEPCE->getSourceElementType();
410 return nullptr;
411 }
412
413 static std::optional<ConstantRange>
414 getInRangeIfValid(const ConstantExpr *CE) {
415 if (auto *GEPCE = dyn_cast<GetElementPtrConstantExpr>(CE))
416 return GEPCE->getInRange();
417 return std::nullopt;
418 }
419
420public:
422 unsigned short SubclassOptionalData = 0,
423 ArrayRef<int> ShuffleMask = {},
424 Type *ExplicitTy = nullptr,
425 std::optional<ConstantRange> InRange = std::nullopt)
426 : Opcode(Opcode), SubclassOptionalData(SubclassOptionalData), Ops(Ops),
427 ShuffleMask(ShuffleMask), ExplicitTy(ExplicitTy),
428 InRange(std::move(InRange)) {}
429
431 : Opcode(CE->getOpcode()),
432 SubclassOptionalData(CE->getRawSubclassOptionalData()), Ops(Operands),
433 ShuffleMask(getShuffleMaskIfValid(CE)),
434 ExplicitTy(getSourceElementTypeIfValid(CE)),
435 InRange(getInRangeIfValid(CE)) {}
436
439 : Opcode(CE->getOpcode()),
440 SubclassOptionalData(CE->getRawSubclassOptionalData()),
441 ShuffleMask(getShuffleMaskIfValid(CE)),
442 ExplicitTy(getSourceElementTypeIfValid(CE)),
443 InRange(getInRangeIfValid(CE)) {
444 assert(Storage.empty() && "Expected empty storage");
445 for (unsigned I = 0, E = CE->getNumOperands(); I != E; ++I)
446 Storage.push_back(CE->getOperand(I));
447 Ops = Storage;
448 }
449
450 static bool rangesEqual(const std::optional<ConstantRange> &A,
451 const std::optional<ConstantRange> &B) {
452 if (!A.has_value() || !B.has_value())
453 return A.has_value() == B.has_value();
454 return A->getBitWidth() == B->getBitWidth() && A == B;
455 }
456
457 bool operator==(const ConstantExprKeyType &X) const {
458 return Opcode == X.Opcode &&
459 SubclassOptionalData == X.SubclassOptionalData && Ops == X.Ops &&
460 ShuffleMask == X.ShuffleMask && ExplicitTy == X.ExplicitTy &&
461 rangesEqual(InRange, X.InRange);
462 }
463
464 bool operator==(const ConstantExpr *CE) const {
465 if (Opcode != CE->getOpcode())
466 return false;
467 if (SubclassOptionalData != CE->getRawSubclassOptionalData())
468 return false;
469 if (Ops.size() != CE->getNumOperands())
470 return false;
471 for (unsigned I = 0, E = Ops.size(); I != E; ++I)
472 if (Ops[I] != CE->getOperand(I))
473 return false;
474 if (ShuffleMask != getShuffleMaskIfValid(CE))
475 return false;
476 if (ExplicitTy != getSourceElementTypeIfValid(CE))
477 return false;
478 if (!rangesEqual(InRange, getInRangeIfValid(CE)))
479 return false;
480 return true;
481 }
482
483 unsigned getHash() const {
484 return hash_combine(Opcode, SubclassOptionalData, hash_combine_range(Ops),
485 hash_combine_range(ShuffleMask), ExplicitTy);
486 }
487
489
491 switch (Opcode) {
492 default:
493 if (Instruction::isCast(Opcode))
494 return new CastConstantExpr(Opcode, Ops[0], Ty);
495 if (Instruction::isBinaryOp(Opcode))
496 return new BinaryConstantExpr(Opcode, Ops[0], Ops[1],
497 SubclassOptionalData);
498 llvm_unreachable("Invalid ConstantExpr!");
499 case Instruction::ExtractElement:
500 return new ExtractElementConstantExpr(Ops[0], Ops[1]);
501 case Instruction::InsertElement:
502 return new InsertElementConstantExpr(Ops[0], Ops[1], Ops[2]);
503 case Instruction::ShuffleVector:
504 return new ShuffleVectorConstantExpr(Ops[0], Ops[1], ShuffleMask);
505 case Instruction::GetElementPtr:
507 ExplicitTy, Ops[0], Ops.slice(1), Ty, SubclassOptionalData, InRange);
508 }
509 }
510};
511
514
516
519
522 assert(Storage.empty() && "Expected empty storage");
523 for (unsigned I = 0, E = C->getNumOperands(); I != E; ++I)
524 Storage.push_back(cast<Constant>(C->getOperand(I)));
525 Operands = Storage;
526 }
527
529 return Operands == X.Operands;
530 }
531
532 bool operator==(const ConstantPtrAuth *C) const {
533 if (Operands.size() != C->getNumOperands())
534 return false;
535 for (unsigned I = 0, E = Operands.size(); I != E; ++I)
536 if (Operands[I] != C->getOperand(I))
537 return false;
538 return true;
539 }
540
541 unsigned getHash() const { return hash_combine_range(Operands); }
542
544
550};
551
552// Free memory for a given constant. Assumes the constant has already been
553// removed from all relevant maps.
554void deleteConstant(Constant *C);
555
556/// Record that a uniqued constant uses \p Op, so that
557/// Constant::removeDeadConstantUsers on a global operand knows it has work to
558/// do.
560 if (auto *GV = dyn_cast<GlobalValue>(Op))
561 GV->setMayHaveConstantUsers();
562}
563
564template <class ConstantClass> class ConstantUniqueMap {
565public:
568 using LookupKey = std::pair<TypeClass *, ValType>;
569
570 /// Key and hash together, so that we compute the hash only once and reuse it.
571 using LookupKeyHashed = std::pair<unsigned, LookupKey>;
572
573private:
574 struct MapInfo {
575 using ConstantClassInfo = DenseMapInfo<ConstantClass *>;
576
577 static unsigned getHashValue(const ConstantClass *CP) {
579 return getHashValue(LookupKey(CP->getType(), ValType(CP, Storage)));
580 }
581
582 static bool isEqual(const ConstantClass *LHS, const ConstantClass *RHS) {
583 return LHS == RHS;
584 }
585
586 static unsigned getHashValue(const LookupKey &Val) {
587 return hash_combine(Val.first, Val.second.getHash());
588 }
589
590 static unsigned getHashValue(const LookupKeyHashed &Val) {
591 return Val.first;
592 }
593
594 static bool isEqual(const LookupKey &LHS, const ConstantClass *RHS) {
595 if (LHS.first != RHS->getType())
596 return false;
597 return LHS.second == RHS;
598 }
599
600 static bool isEqual(const LookupKeyHashed &LHS, const ConstantClass *RHS) {
601 return isEqual(LHS.second, RHS);
602 }
603 };
604
605public:
607
608private:
609 MapTy Map;
610
611public:
612 typename MapTy::iterator begin() { return Map.begin(); }
613 typename MapTy::iterator end() { return Map.end(); }
614
616 for (auto &I : Map)
618 }
619
620private:
621 ConstantClass *create(TypeClass *Ty, ValType V, LookupKeyHashed &HashKey) {
622 ConstantClass *Result = V.create(Ty);
623
624 assert(Result->getType() == Ty && "Type specified is not correct!");
625 if constexpr (std::is_base_of_v<User, ConstantClass>)
626 for (Value *Op : Result->operand_values())
628 Map.insert_as(Result, HashKey);
629
630 return Result;
631 }
632
633public:
634 /// Return the specified constant from the map, creating it if necessary.
635 ConstantClass *getOrCreate(TypeClass *Ty, ValType V) {
636 LookupKey Key(Ty, V);
637 /// Hash once, and reuse it for the lookup and the insertion if needed.
638 LookupKeyHashed Lookup(MapInfo::getHashValue(Key), Key);
639
640 ConstantClass *Result = nullptr;
641
642 auto I = Map.find_as(Lookup);
643 if (I == Map.end())
644 Result = create(Ty, V, Lookup);
645 else
646 Result = *I;
647 assert(Result && "Unexpected nullptr");
648
649 return Result;
650 }
651
652 /// Remove this constant from the map
653 void remove(ConstantClass *CP) {
654 typename MapTy::iterator I = Map.find(CP);
655 assert(I != Map.end() && "Constant not found in constant table!");
656 assert(*I == CP && "Didn't find correct element?");
657 Map.erase(I);
658 }
659
661 ConstantClass *CP, Value *From,
662 Constant *To, unsigned NumUpdated = 0,
663 unsigned OperandNo = ~0u) {
664 LookupKey Key(CP->getType(), ValType(Operands, CP));
665 /// Hash once, and reuse it for the lookup and the insertion if needed.
666 LookupKeyHashed Lookup(MapInfo::getHashValue(Key), Key);
667
668 auto ItMap = Map.find_as(Lookup);
669 if (ItMap != Map.end())
670 return *ItMap;
671
672 // Update to the new value. Optimize for the case when we have a single
673 // operand that we're changing, but handle bulk updates efficiently.
674 remove(CP);
676 if (NumUpdated == 1) {
677 assert(OperandNo < CP->getNumOperands() && "Invalid index");
678 assert(CP->getOperand(OperandNo) != To && "I didn't contain From!");
679 CP->setOperand(OperandNo, To);
680 } else {
681 for (unsigned I = 0, E = CP->getNumOperands(); I != E; ++I)
682 if (CP->getOperand(I) == From)
683 CP->setOperand(I, To);
684 }
685 Map.insert_as(CP, Lookup);
686 return nullptr;
687 }
688
689 void dump() const {
690 LLVM_DEBUG(dbgs() << "Constant.cpp: ConstantUniqueMap\n");
691 }
692};
693
695 for (auto &I : Map)
696 delete I;
697}
698
699} // end namespace llvm
700
701#endif // LLVM_LIB_IR_CONSTANTSCONTEXT_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define X(NUM, ENUM, NAME)
Definition ELF.h:665
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This file defines DenseMapInfo traits for DenseMap.
This file defines the DenseSet and SmallDenseSet classes.
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
#define I(x, y, z)
Definition MD5.cpp:57
static bool InRange(int64_t Value, unsigned short Shift, int LBound, int HBound)
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
int64_t C1
SI Fold Operands
This file defines the SmallVector class.
#define LLVM_DEBUG(...)
Definition Debug.h:119
static bool canThrow(const Value *V)
static int Lookup(ArrayRef< TableEntry > Table, unsigned Opcode)
Value * RHS
Value * LHS
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
size_t size() const
Get the array size.
Definition ArrayRef.h:141
Class to represent array types.
BinaryConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to impleme...
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
static bool classof(const ConstantExpr *CE)
static bool classof(const Value *V)
BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2, unsigned Flags)
CastConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to implement...
static bool classof(const Value *V)
static bool classof(const ConstantExpr *CE)
CastConstantExpr(unsigned Opcode, Constant *C, Type *Ty)
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
ConstantArray - Constant Array Declarations.
Definition Constants.h:590
A constant value that is initialized with an expression using other constant values.
Definition Constants.h:1316
ConstantExpr(Type *ty, unsigned Opcode, AllocInfo AllocInfo)
Definition Constants.h:1324
friend class Constant
Definition Constants.h:1318
static LLVM_ABI 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.
A signed pointer, in the ptrauth sense.
Definition Constants.h:1223
typename ConstantInfo< ConstantClass >::ValType ValType
typename ConstantInfo< ConstantClass >::TypeClass TypeClass
ConstantClass * getOrCreate(TypeClass *Ty, ValType V)
Return the specified constant from the map, creating it if necessary.
std::pair< unsigned, LookupKey > LookupKeyHashed
Key and hash together, so that we compute the hash only once and reuse it.
void remove(ConstantClass *CP)
Remove this constant from the map.
ConstantClass * replaceOperandsInPlace(ArrayRef< Constant * > Operands, ConstantClass *CP, Value *From, Constant *To, unsigned NumUpdated=0, unsigned OperandNo=~0u)
DenseSet< ConstantClass *, MapInfo > MapTy
std::pair< TypeClass *, ValType > LookupKey
Constant Vector Declarations.
Definition Constants.h:674
This is an important base class in LLVM.
Definition Constant.h:44
static constexpr unsigned ConstantSubclassBits
Bits reserved in SubclassOptionalData, not to be used for ConstantExpr flags.
Definition Constant.h:53
Implements a dense probed hash-table based set.
Definition DenseSet.h:283
ExtractElementConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to...
ExtractElementConstantExpr(Constant *C1, Constant *C2)
static bool classof(const ConstantExpr *CE)
static bool classof(const Value *V)
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
Class to represent function types.
GetElementPtrConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to ...
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
std::optional< ConstantRange > getInRange() const
static bool classof(const ConstantExpr *CE)
static bool classof(const Value *V)
static GetElementPtrConstantExpr * Create(Type *SrcElementTy, Constant *C, ArrayRef< Constant * > IdxList, Type *DestTy, unsigned Flags, std::optional< ConstantRange > InRange)
InsertElementConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to ...
static bool classof(const ConstantExpr *CE)
InsertElementConstantExpr(Constant *C1, Constant *C2, Constant *C3)
static bool classof(const Value *V)
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
bool isCast() const
bool isBinaryOp() const
Class to represent pointers.
static PointerType * getUnqual(LLVMContext &C)
This constructs an opaque pointer to an object in the default address space (address space zero).
Class to represent scalable SIMD vectors.
ShuffleVectorConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to ...
SmallVector< int, 4 > ShuffleMask
static bool classof(const ConstantExpr *CE)
ShuffleVectorConstantExpr(Constant *C1, Constant *C2, ArrayRef< int > Mask)
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
static bool classof(const Value *V)
static LLVM_ABI bool isValidOperands(const Value *V1, const Value *V2, const Value *Mask)
Return true if a shufflevector instruction can be formed with the specified operands.
static LLVM_ABI Constant * convertShuffleMaskForBitcode(ArrayRef< int > Mask, Type *ResultTy)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void reserve(size_type N)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Class to represent struct types.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
LLVM Value Representation.
Definition Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:257
unsigned char SubclassOptionalData
Hold arbitary subclass data.
Definition Value.h:85
Base class of all SIMD vector types.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
bool isEqual(const GCNRPTracker::LiveRegSet &S1, const GCNRPTracker::LiveRegSet &S2)
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
Definition STLExtras.h:1685
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
void noteConstantOperand(Value *Op)
Record that a uniqued constant uses Op, so that Constant::removeDeadConstantUsers on a global operand...
void deleteConstant(Constant *C)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
DWARFExpression::Operation Op
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1933
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
Definition Hashing.h:307
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
Definition Hashing.h:287
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:879
bool operator==(const ConstantClass *C) const
ConstantAggrKeyType(ArrayRef< Constant * > Operands)
ConstantAggrKeyType(ArrayRef< Constant * > Operands, const ConstantClass *)
typename ConstantInfo< ConstantArray >::TypeClass TypeClass
ConstantClass * create(TypeClass *Ty) const
ConstantAggrKeyType(const ConstantClass *C, SmallVectorImpl< Constant * > &Storage)
bool operator==(const ConstantAggrKeyType &X) const
ConstantExprKeyType(unsigned Opcode, ArrayRef< Constant * > Ops, unsigned short SubclassOptionalData=0, ArrayRef< int > ShuffleMask={}, Type *ExplicitTy=nullptr, std::optional< ConstantRange > InRange=std::nullopt)
ConstantExprKeyType(const ConstantExpr *CE, SmallVectorImpl< Constant * > &Storage)
ConstantInfo< ConstantExpr >::TypeClass TypeClass
static bool rangesEqual(const std::optional< ConstantRange > &A, const std::optional< ConstantRange > &B)
ConstantExpr * create(TypeClass *Ty) const
bool operator==(const ConstantExprKeyType &X) const
bool operator==(const ConstantExpr *CE) const
ConstantExprKeyType(ArrayRef< Constant * > Operands, const ConstantExpr *CE)
ConstantAggrKeyType< ConstantArray > ValType
ConstantAggrKeyType< ConstantStruct > ValType
ConstantAggrKeyType< ConstantVector > ValType
bool operator==(const ConstantPtrAuthKeyType &X) const
ArrayRef< Constant * > Operands
ConstantPtrAuthKeyType(ArrayRef< Constant * > Operands, const ConstantPtrAuth *)
ConstantPtrAuthKeyType(const ConstantPtrAuth *C, SmallVectorImpl< Constant * > &Storage)
ConstantPtrAuthKeyType(ArrayRef< Constant * > Operands)
bool operator==(const ConstantPtrAuth *C) const
ConstantPtrAuth * create(TypeClass *Ty) const
ConstantInfo< ConstantPtrAuth >::TypeClass TypeClass
An information struct used to provide DenseMap with the various necessary components for a given valu...
FixedNumOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
bool operator==(const InlineAsmKeyType &X) const
ConstantInfo< InlineAsm >::TypeClass TypeClass
InlineAsm * create(TypeClass *Ty) const
bool operator==(const InlineAsm *Asm) const
InlineAsmKeyType(const InlineAsm *Asm, SmallVectorImpl< Constant * > &)
InlineAsmKeyType(StringRef AsmString, StringRef Constraints, FunctionType *FTy, bool HasSideEffects, bool IsAlignStack, InlineAsm::AsmDialect AsmDialect, bool canThrow)
InlineAsm::AsmDialect AsmDialect
Compile-time customization of User operands.
Definition User.h:42
Information about how a User object was allocated, to be passed into the User constructor.
Definition User.h:79
Indicates this User has operands co-allocated.
Definition User.h:60
VariadicOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...