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"
18#include "llvm/ADT/DenseSet.h"
19#include "llvm/ADT/Hashing.h"
21#include "llvm/ADT/StringRef.h"
22#include "llvm/IR/Constant.h"
23#include "llvm/IR/Constants.h"
26#include "llvm/IR/InlineAsm.h"
27#include "llvm/IR/Instruction.h"
31#include "llvm/Support/Debug.h"
34#include <cassert>
35#include <cstddef>
36#include <cstdint>
37#include <type_traits>
38#include <utility>
39
40#define DEBUG_TYPE "ir"
41
42namespace llvm {
43
44/// CastConstantExpr - This class is private to Constants.cpp, and is used
45/// behind the scenes to implement cast constant exprs.
46class CastConstantExpr final : public ConstantExpr {
47 constexpr static IntrusiveOperandsAllocMarker AllocMarker{1};
48
49public:
50 CastConstantExpr(unsigned Opcode, Constant *C, Type *Ty)
51 : ConstantExpr(Ty, Opcode, AllocMarker) {
52 Op<0>() = C;
53 }
54
55 // allocate space for exactly one operand
56 void *operator new(size_t S) { return User::operator new(S, AllocMarker); }
57 void operator delete(void *Ptr) { User::operator delete(Ptr, AllocMarker); }
58
60
61 static bool classof(const ConstantExpr *CE) {
62 return Instruction::isCast(CE->getOpcode());
63 }
64 static bool classof(const Value *V) {
66 }
67};
68
69/// BinaryConstantExpr - This class is private to Constants.cpp, and is used
70/// behind the scenes to implement binary constant exprs.
71class BinaryConstantExpr final : public ConstantExpr {
72 constexpr static IntrusiveOperandsAllocMarker AllocMarker{2};
73
74public:
75 BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2,
76 unsigned Flags)
77 : ConstantExpr(C1->getType(), Opcode, AllocMarker) {
78 Op<0>() = C1;
79 Op<1>() = C2;
80 assert((Flags & ConstantSubclassBits) == 0 && "invalid flags");
82 }
83
84 // allocate space for exactly two operands
85 void *operator new(size_t S) { return User::operator new(S, AllocMarker); }
86 void operator delete(void *Ptr) { User::operator delete(Ptr, AllocMarker); }
87
88 /// Transparently provide more efficient getOperand methods.
90
91 static bool classof(const ConstantExpr *CE) {
92 return Instruction::isBinaryOp(CE->getOpcode());
93 }
94 static bool classof(const Value *V) {
96 }
97};
98
99/// ExtractElementConstantExpr - This class is private to
100/// Constants.cpp, and is used behind the scenes to implement
101/// extractelement constant exprs.
103 constexpr static IntrusiveOperandsAllocMarker AllocMarker{2};
104
105public:
107 : ConstantExpr(cast<VectorType>(C1->getType())->getElementType(),
108 Instruction::ExtractElement, AllocMarker) {
109 Op<0>() = C1;
110 Op<1>() = C2;
111 }
112
113 // allocate space for exactly two operands
114 void *operator new(size_t S) { return User::operator new(S, AllocMarker); }
115 void operator delete(void *Ptr) { User::operator delete(Ptr, AllocMarker); }
116
117 /// Transparently provide more efficient getOperand methods.
119
120 static bool classof(const ConstantExpr *CE) {
121 return CE->getOpcode() == Instruction::ExtractElement;
122 }
123 static bool classof(const Value *V) {
125 }
126};
127
128/// InsertElementConstantExpr - This class is private to
129/// Constants.cpp, and is used behind the scenes to implement
130/// insertelement constant exprs.
132 constexpr static IntrusiveOperandsAllocMarker AllocMarker{3};
133
134public:
136 : ConstantExpr(C1->getType(), Instruction::InsertElement, AllocMarker) {
137 Op<0>() = C1;
138 Op<1>() = C2;
139 Op<2>() = C3;
140 }
141
142 // allocate space for exactly three operands
143 void *operator new(size_t S) { return User::operator new(S, AllocMarker); }
144 void operator delete(void *Ptr) { User::operator delete(Ptr, AllocMarker); }
145
146 /// Transparently provide more efficient getOperand methods.
148
149 static bool classof(const ConstantExpr *CE) {
150 return CE->getOpcode() == Instruction::InsertElement;
151 }
152 static bool classof(const Value *V) {
154 }
155};
156
157/// ShuffleVectorConstantExpr - This class is private to
158/// Constants.cpp, and is used behind the scenes to implement
159/// shufflevector constant exprs.
161 constexpr static IntrusiveOperandsAllocMarker AllocMarker{2};
162
163public:
166 cast<VectorType>(C1->getType())->getElementType(),
167 Mask.size(), isa<ScalableVectorType>(C1->getType())),
168 Instruction::ShuffleVector, AllocMarker) {
170 "Invalid shuffle vector instruction operands!");
171 Op<0>() = C1;
172 Op<1>() = C2;
173 ShuffleMask.assign(Mask.begin(), Mask.end());
176 }
177
180
181 void *operator new(size_t S) { return User::operator new(S, AllocMarker); }
182 void operator delete(void *Ptr) {
183 return User::operator delete(Ptr, AllocMarker);
184 }
185
186 /// Transparently provide more efficient getOperand methods.
188
189 static bool classof(const ConstantExpr *CE) {
190 return CE->getOpcode() == Instruction::ShuffleVector;
191 }
192 static bool classof(const Value *V) {
194 }
195};
196
197/// GetElementPtrConstantExpr - This class is private to Constants.cpp, and is
198/// used behind the scenes to implement getelementptr constant exprs.
199class GetElementPtrConstantExpr : public ConstantExpr {
200 Type *SrcElementTy;
201 Type *ResElementTy;
202 std::optional<ConstantRange> InRange;
203
204 GetElementPtrConstantExpr(Type *SrcElementTy, Constant *C,
205 ArrayRef<Constant *> IdxList, Type *DestTy,
206 std::optional<ConstantRange> InRange,
208
209public:
210 static GetElementPtrConstantExpr *
211 Create(Type *SrcElementTy, Constant *C, ArrayRef<Constant *> IdxList,
212 Type *DestTy, unsigned Flags, std::optional<ConstantRange> InRange) {
213 IntrusiveOperandsAllocMarker AllocMarker{unsigned(IdxList.size() + 1)};
214 GetElementPtrConstantExpr *Result = new (AllocMarker)
215 GetElementPtrConstantExpr(SrcElementTy, C, IdxList, DestTy,
216 std::move(InRange), AllocMarker);
217 assert((Flags & ConstantSubclassBits) == 0 && "invalid flags");
218 Result->SubclassOptionalData = Flags;
219 return Result;
220 }
221
222 Type *getSourceElementType() const;
223 Type *getResultElementType() const;
224 std::optional<ConstantRange> getInRange() const;
225
226 /// Transparently provide more efficient getOperand methods.
228
229 static bool classof(const ConstantExpr *CE) {
230 return CE->getOpcode() == Instruction::GetElementPtr;
231 }
232 static bool classof(const Value *V) {
234 }
235};
236
237template <>
239 : public FixedNumOperandTraits<CastConstantExpr, 1> {};
241
242template <>
244 : public FixedNumOperandTraits<BinaryConstantExpr, 2> {};
246
247template <>
249 : public FixedNumOperandTraits<ExtractElementConstantExpr, 2> {};
251
252template <>
254 : public FixedNumOperandTraits<InsertElementConstantExpr, 3> {};
256
257template <>
259 : public FixedNumOperandTraits<ShuffleVectorConstantExpr, 2> {};
261
262template <>
264 : public VariadicOperandTraits<GetElementPtrConstantExpr> {};
265
267
268template <class ConstantClass> struct ConstantAggrKeyType;
269struct InlineAsmKeyType;
272
273template <class ConstantClass> struct ConstantInfo;
274template <> struct ConstantInfo<ConstantExpr> {
277};
278template <> struct ConstantInfo<InlineAsm> {
281};
298
299template <class ConstantClass> struct ConstantAggrKeyType {
301
303
306
307 ConstantAggrKeyType(const ConstantClass *C,
309 assert(Storage.empty() && "Expected empty storage");
310 Storage.reserve(C->getNumOperands());
311 for (unsigned I = 0, E = C->getNumOperands(); I != E; ++I)
312 Storage.push_back(C->getOperand(I));
313 Operands = Storage;
314 }
315
316 bool operator==(const ConstantAggrKeyType &X) const {
317 return Operands == X.Operands;
318 }
319
320 bool operator==(const ConstantClass *C) const {
321 if (Operands.size() != C->getNumOperands())
322 return false;
323 for (unsigned I = 0, E = Operands.size(); I != E; ++I)
324 if (Operands[I] != C->getOperand(I))
325 return false;
326 return true;
327 }
328
329 unsigned getHash() const { return hash_combine_range(Operands); }
330
332
333 ConstantClass *create(TypeClass *Ty) const {
335 return new (AllocMarker) ConstantClass(Ty, Operands, AllocMarker);
336 }
337};
338
347
354
356 : AsmString(Asm->getAsmString()), Constraints(Asm->getConstraintString()),
357 FTy(Asm->getFunctionType()), HasSideEffects(Asm->hasSideEffects()),
358 IsAlignStack(Asm->isAlignStack()), AsmDialect(Asm->getDialect()),
359 CanThrow(Asm->canThrow()) {}
360
361 bool operator==(const InlineAsmKeyType &X) const {
362 return HasSideEffects == X.HasSideEffects &&
363 IsAlignStack == X.IsAlignStack && AsmDialect == X.AsmDialect &&
364 AsmString == X.AsmString && Constraints == X.Constraints &&
365 FTy == X.FTy && CanThrow == X.CanThrow;
366 }
367
368 bool operator==(const InlineAsm *Asm) const {
369 return HasSideEffects == Asm->hasSideEffects() &&
370 IsAlignStack == Asm->isAlignStack() &&
371 AsmDialect == Asm->getDialect() &&
372 AsmString == Asm->getAsmString() &&
373 Constraints == Asm->getConstraintString() &&
374 FTy == Asm->getFunctionType() && CanThrow == Asm->canThrow();
375 }
376
381
383
385 assert(PointerType::getUnqual(FTy->getContext()) == Ty);
386 return new InlineAsm(FTy, std::string(AsmString), std::string(Constraints),
388 }
389};
390
392private:
393 uint8_t Opcode;
394 uint8_t SubclassOptionalData;
396 ArrayRef<int> ShuffleMask;
397 Type *ExplicitTy;
398 std::optional<ConstantRange> InRange;
399
400 static ArrayRef<int> getShuffleMaskIfValid(const ConstantExpr *CE) {
401 if (CE->getOpcode() == Instruction::ShuffleVector)
402 return CE->getShuffleMask();
403 return {};
404 }
405
406 static Type *getSourceElementTypeIfValid(const ConstantExpr *CE) {
407 if (auto *GEPCE = dyn_cast<GetElementPtrConstantExpr>(CE))
408 return GEPCE->getSourceElementType();
409 return nullptr;
410 }
411
412 static std::optional<ConstantRange>
413 getInRangeIfValid(const ConstantExpr *CE) {
414 if (auto *GEPCE = dyn_cast<GetElementPtrConstantExpr>(CE))
415 return GEPCE->getInRange();
416 return std::nullopt;
417 }
418
419public:
421 unsigned short SubclassOptionalData = 0,
422 ArrayRef<int> ShuffleMask = {},
423 Type *ExplicitTy = nullptr,
424 std::optional<ConstantRange> InRange = std::nullopt)
425 : Opcode(Opcode), SubclassOptionalData(SubclassOptionalData), Ops(Ops),
426 ShuffleMask(ShuffleMask), ExplicitTy(ExplicitTy),
427 InRange(std::move(InRange)) {}
428
430 : Opcode(CE->getOpcode()),
431 SubclassOptionalData(CE->getRawSubclassOptionalData()), Ops(Operands),
432 ShuffleMask(getShuffleMaskIfValid(CE)),
433 ExplicitTy(getSourceElementTypeIfValid(CE)),
434 InRange(getInRangeIfValid(CE)) {}
435
438 : Opcode(CE->getOpcode()),
439 SubclassOptionalData(CE->getRawSubclassOptionalData()),
440 ShuffleMask(getShuffleMaskIfValid(CE)),
441 ExplicitTy(getSourceElementTypeIfValid(CE)),
442 InRange(getInRangeIfValid(CE)) {
443 assert(Storage.empty() && "Expected empty storage");
444 for (unsigned I = 0, E = CE->getNumOperands(); I != E; ++I)
445 Storage.push_back(CE->getOperand(I));
446 Ops = Storage;
447 }
448
449 static bool rangesEqual(const std::optional<ConstantRange> &A,
450 const std::optional<ConstantRange> &B) {
451 if (!A.has_value() || !B.has_value())
452 return A.has_value() == B.has_value();
453 return A->getBitWidth() == B->getBitWidth() && A == B;
454 }
455
456 bool operator==(const ConstantExprKeyType &X) const {
457 return Opcode == X.Opcode &&
458 SubclassOptionalData == X.SubclassOptionalData && Ops == X.Ops &&
459 ShuffleMask == X.ShuffleMask && ExplicitTy == X.ExplicitTy &&
460 rangesEqual(InRange, X.InRange);
461 }
462
463 bool operator==(const ConstantExpr *CE) const {
464 if (Opcode != CE->getOpcode())
465 return false;
466 if (SubclassOptionalData != CE->getRawSubclassOptionalData())
467 return false;
468 if (Ops.size() != CE->getNumOperands())
469 return false;
470 for (unsigned I = 0, E = Ops.size(); I != E; ++I)
471 if (Ops[I] != CE->getOperand(I))
472 return false;
473 if (ShuffleMask != getShuffleMaskIfValid(CE))
474 return false;
475 if (ExplicitTy != getSourceElementTypeIfValid(CE))
476 return false;
477 if (!rangesEqual(InRange, getInRangeIfValid(CE)))
478 return false;
479 return true;
480 }
481
482 unsigned getHash() const {
483 return hash_combine(Opcode, SubclassOptionalData, hash_combine_range(Ops),
484 hash_combine_range(ShuffleMask), ExplicitTy);
485 }
486
488
490 switch (Opcode) {
491 default:
492 if (Instruction::isCast(Opcode))
493 return new CastConstantExpr(Opcode, Ops[0], Ty);
494 if (Instruction::isBinaryOp(Opcode))
495 return new BinaryConstantExpr(Opcode, Ops[0], Ops[1],
496 SubclassOptionalData);
497 llvm_unreachable("Invalid ConstantExpr!");
498 case Instruction::ExtractElement:
499 return new ExtractElementConstantExpr(Ops[0], Ops[1]);
500 case Instruction::InsertElement:
501 return new InsertElementConstantExpr(Ops[0], Ops[1], Ops[2]);
502 case Instruction::ShuffleVector:
503 return new ShuffleVectorConstantExpr(Ops[0], Ops[1], ShuffleMask);
504 case Instruction::GetElementPtr:
506 ExplicitTy, Ops[0], Ops.slice(1), Ty, SubclassOptionalData, InRange);
507 }
508 }
509};
510
513
515
518
521 assert(Storage.empty() && "Expected empty storage");
522 for (unsigned I = 0, E = C->getNumOperands(); I != E; ++I)
523 Storage.push_back(cast<Constant>(C->getOperand(I)));
524 Operands = Storage;
525 }
526
528 return Operands == X.Operands;
529 }
530
531 bool operator==(const ConstantPtrAuth *C) const {
532 if (Operands.size() != C->getNumOperands())
533 return false;
534 for (unsigned I = 0, E = Operands.size(); I != E; ++I)
535 if (Operands[I] != C->getOperand(I))
536 return false;
537 return true;
538 }
539
540 unsigned getHash() const { return hash_combine_range(Operands); }
541
543
549};
550
551// Free memory for a given constant. Assumes the constant has already been
552// removed from all relevant maps.
553void deleteConstant(Constant *C);
554
555/// Record that a uniqued constant uses \p Op, so that
556/// Constant::removeDeadConstantUsers on a global operand knows it has work to
557/// do.
559 if (auto *GV = dyn_cast<GlobalValue>(Op))
560 GV->setMayHaveConstantUsers();
561}
562
563template <class ConstantClass> class ConstantUniqueMap {
564public:
567 using LookupKey = std::pair<TypeClass *, ValType>;
568
569 /// Key and hash together, so that we compute the hash only once and reuse it.
570 using LookupKeyHashed = std::pair<unsigned, LookupKey>;
571
572private:
573 struct MapInfo {
574 static unsigned getHashValue(const ConstantClass *CP) {
576 return getHashValue(LookupKey(CP->getType(), ValType(CP, Storage)));
577 }
578
579 static bool isEqual(const ConstantClass *LHS, const ConstantClass *RHS) {
580 return LHS == RHS;
581 }
582
583 static unsigned getHashValue(const LookupKey &Val) {
584 return hash_combine(Val.first, Val.second.getHash());
585 }
586
587 static unsigned getHashValue(const LookupKeyHashed &Val) {
588 return Val.first;
589 }
590
591 static bool isEqual(const LookupKey &LHS, const ConstantClass *RHS) {
592 if (LHS.first != RHS->getType())
593 return false;
594 return LHS.second == RHS;
595 }
596
597 static bool isEqual(const LookupKeyHashed &LHS, const ConstantClass *RHS) {
598 return isEqual(LHS.second, RHS);
599 }
600 };
601
602public:
604
605private:
606 MapTy Map;
607
608public:
609 typename MapTy::iterator begin() { return Map.begin(); }
610 typename MapTy::iterator end() { return Map.end(); }
611
613 for (auto &I : Map)
615 }
616
617private:
618 ConstantClass *create(TypeClass *Ty, ValType V, LookupKeyHashed &HashKey) {
619 ConstantClass *Result = V.create(Ty);
620
621 assert(Result->getType() == Ty && "Type specified is not correct!");
622 if constexpr (std::is_base_of_v<User, ConstantClass>)
623 for (Value *Op : Result->operand_values())
625 Map.insert_as(Result, HashKey);
626
627 return Result;
628 }
629
630public:
631 /// Return the specified constant from the map, creating it if necessary.
632 ConstantClass *getOrCreate(TypeClass *Ty, ValType V) {
633 LookupKey Key(Ty, V);
634 /// Hash once, and reuse it for the lookup and the insertion if needed.
635 LookupKeyHashed Lookup(MapInfo::getHashValue(Key), Key);
636
637 ConstantClass *Result = nullptr;
638
639 auto I = Map.find_as(Lookup);
640 if (I == Map.end())
641 Result = create(Ty, V, Lookup);
642 else
643 Result = *I;
644 assert(Result && "Unexpected nullptr");
645
646 return Result;
647 }
648
649 /// Remove this constant from the map
650 void remove(ConstantClass *CP) {
651 typename MapTy::iterator I = Map.find(CP);
652 assert(I != Map.end() && "Constant not found in constant table!");
653 assert(*I == CP && "Didn't find correct element?");
654 Map.erase(I);
655 }
656
658 ConstantClass *CP, Value *From,
659 Constant *To, unsigned NumUpdated = 0,
660 unsigned OperandNo = ~0u) {
661 LookupKey Key(CP->getType(), ValType(Operands, CP));
662 /// Hash once, and reuse it for the lookup and the insertion if needed.
663 LookupKeyHashed Lookup(MapInfo::getHashValue(Key), Key);
664
665 auto ItMap = Map.find_as(Lookup);
666 if (ItMap != Map.end())
667 return *ItMap;
668
669 // Update to the new value. Optimize for the case when we have a single
670 // operand that we're changing, but handle bulk updates efficiently.
671 remove(CP);
673 if (NumUpdated == 1) {
674 assert(OperandNo < CP->getNumOperands() && "Invalid index");
675 assert(CP->getOperand(OperandNo) != To && "I didn't contain From!");
676 CP->setOperand(OperandNo, To);
677 } else {
678 for (unsigned I = 0, E = CP->getNumOperands(); I != E; ++I)
679 if (CP->getOperand(I) == From)
680 CP->setOperand(I, To);
681 }
682 Map.insert_as(CP, Lookup);
683 return nullptr;
684 }
685
686 void dump() const {
687 LLVM_DEBUG(dbgs() << "Constant.cpp: ConstantUniqueMap\n");
688 }
689};
690
692 for (auto &I : Map)
693 delete I;
694}
695
696} // end namespace llvm
697
698#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 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
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...